package com.shkpr.service.alambizplugin.components; import com.global.base.log.LogLevelFlag; import com.global.base.log.LogPrintMgr; import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdImportParams; import com.shkpr.service.alambizplugin.commtools.CRSUtil; import com.shkpr.service.alambizplugin.commtools.ExcelUtils; import com.shkpr.service.alambizplugin.commtools.PointCodeUtil; import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils; import com.shkpr.service.alambizplugin.commtools.norule.JPSurveyApplyColumn; import com.shkpr.service.alambizplugin.commtools.norule.RuleFormatSetting; import com.shkpr.service.alambizplugin.commtools.norule.SurveyCommonAssistant; import com.shkpr.service.alambizplugin.components.checker.DuplicatePointsFinder; import com.shkpr.service.alambizplugin.components.checker.InvalidLinesFinder; import com.shkpr.service.alambizplugin.components.checker.InvalidPropertiesFinder; import com.shkpr.service.alambizplugin.constants.CommAsyncStatusEnum; import com.shkpr.service.alambizplugin.constants.CommCRSDefine; import com.shkpr.service.alambizplugin.constants.ExcelEnum; import com.shkpr.service.alambizplugin.constants.GisMetadataDefine; import com.shkpr.service.alambizplugin.constants.GisSurveyExcelDefine; import com.shkpr.service.alambizplugin.constants.GisSurveyImportStatusEnum; import com.shkpr.service.alambizplugin.constants.LogFlagBusiType; import com.shkpr.service.alambizplugin.dbdao.services.intef.GisMetadataLayerTemplateService; import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyJobInfoService; import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyThirdCopyService; import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyProjectInfoService; import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate; import com.shkpr.service.alambizplugin.dto.GisMetadataPropertyTemplate; import com.shkpr.service.alambizplugin.dto.GisSurveyCondition; import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy; import com.shkpr.service.alambizplugin.dto.GisSurveyPropertyValueThirdCopy; import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement; import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResult; import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail; import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportSubtask; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.PrecisionModel; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Component; import org.springframework.util.concurrent.ListenableFuture; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.Duration; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; import java.util.stream.Collectors; /** * 第三方导入执行器 * * @author 欧阳劲驰 * @since 1.0.0 */ @Component public class GisSurveyThirdImporter { /** * log */ private final String mStrClassName; private final String mBizType; private final GeometryFactory geometryFactory; private final GisSurveyProjectInfoService projectInfoService; private final GisSurveyJobInfoService jobInfoService; private final GisMetadataLayerTemplateService layerTemplateService; private final GisSurveyLayerApplyThirdCopyService layerApplyThirdCopyService; private final DuplicatePointsFinder duplicatePointsFinder; private final InvalidLinesFinder invalidLinesFinder; private final InvalidPropertiesFinder invalidPropertiesFinder; public GisSurveyThirdImporter(GisSurveyProjectInfoService projectInfoService , GisSurveyJobInfoService jobInfoService , GisMetadataLayerTemplateService layerTemplateService , GisSurveyLayerApplyThirdCopyService layerApplyThirdCopyService , DuplicatePointsFinder duplicatePointsFinder , InvalidLinesFinder invalidLinesFinder , InvalidPropertiesFinder invalidPropertiesFinder) { mStrClassName = "GisSurveyThirdImporter"; mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue(); geometryFactory = new GeometryFactory(new PrecisionModel(), 4490); this.projectInfoService = projectInfoService; this.jobInfoService = jobInfoService; this.layerTemplateService = layerTemplateService; this.layerApplyThirdCopyService = layerApplyThirdCopyService; this.duplicatePointsFinder = duplicatePointsFinder; this.invalidLinesFinder = invalidLinesFinder; this.invalidPropertiesFinder = invalidPropertiesFinder; } /** * 第三方导入任务 * * @param params 系统检查参数 * @param inputStreams 文件输入流 * @param onStartSubtask 启动子任务 * @param onDeprecatedSubtask 弃用子任务(完成数据收集/取消) * @return 系统检查返回 */ @Async public ListenableFuture thirdImportTask(GisSurveyThirdImportParams params, List inputStreams , Consumer onStartSubtask, Consumer onDeprecatedSubtask) { //构建返回 GisSurveyThirdImportResult result = GisSurveyThirdImportResult.fail(params); result.setOperator(params.getOperator()); //无效属性任务 ListenableFuture>>> invalidPropertiesFuture = null; //重复点号任务 ListenableFuture>> duplicatePointsFuture = null; //无效线任务 ListenableFuture>> invalidLinesFuture = null; //点集合 List> points = new ArrayList<>(); //线集合 List> lines = new ArrayList<>(); try { LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName , String.format( "开始执行第三方导入;任务id: %s" , params.getJobId() ) ); //解析excel parseExcel(inputStreams, points, lines); //项目约束条件 List projectConstraints = projectInfoService.findConstraintsByJobId(params.getJobId()); //提取图层名 List pointLayerNames = getLayerNames(points, GisSurveyExcelDefine.FILE.POINT_LAYER); List lineLayerNames = getLayerNames(lines, GisSurveyExcelDefine.FILE.LINE_LAYER); //图层模版 List pointLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), pointLayerNames); List lineLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), lineLayerNames); //无效属性检查 invalidPropertiesFuture = invalidPropertiesFinder.findInvalidProperties(points, lines , pointLayerTemplates, lineLayerTemplates, params.getCheckConstraint(), projectConstraints); //重复点检查 duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, pointLayerTemplates); //无效线检查 invalidLinesFuture = invalidLinesFinder.finderInvalidLines(points, lines, pointLayerTemplates, lineLayerTemplates); //返回子任务 onStartSubtask.accept( new GisSurveyThirdImportSubtask(invalidPropertiesFuture, duplicatePointsFuture, invalidLinesFuture) ); //等待结果 GisSurveyThirdImportResultDetail>> invalidPropertiesResult = invalidPropertiesFuture.get(); //存入无效属性结果 result.setInvalidLayersResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.INVALID_LAYERS)); result.setMissingRequirementsResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.MISSING_REQUIREMENTS)); result.setInvalidTypesResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.INVALID_TYPES)); result.setOutRangesResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.OUT_RANGES)); result.setOutConstraintResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.OUT_CONSTRAINT)); //存入重复点结果 result.setDuplicatePointsResult(duplicatePointsFuture.get()); //存入无效线结果 result.setInvalidLinesResult(invalidLinesFuture.get()); //结果未通过 if (!checkResult(result)) { result.setImportStatus(GisSurveyImportStatusEnum.DATA_ERROR.getCode()); result.setCompleteTime(LocalDateTime.now()); LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName , String.format( "第三方导入结果未通过;任务id: %s, 用时(毫秒):%d", params.getJobId(), Duration.between(result.getRequestTime(), result.getCompleteTime()).toMillis() ) ); //弃用子任务 onDeprecatedSubtask.accept(params.getJobId()); return new AsyncResult<>(result); } //解码点线数据 List layerApplyList = decodeDataToLayerApply(points, lines, pointLayerTemplates, lineLayerTemplates, params); //重置点号 if (params.getResetNo()) resetNo(params.getJobId(), layerApplyList); //批量写入 Boolean saved = layerApplyThirdCopyService.saveAll(params.getJobId(), layerApplyList); if (!saved) { result.setCompleteTime(LocalDateTime.now()); LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName , String.format( "第三方导入入库失败;任务id: %s, 用时(毫秒):%d", params.getJobId(), Duration.between(result.getRequestTime(), LocalDateTime.now()).toMillis() ) ); //弃用子任务 onDeprecatedSubtask.accept(params.getJobId()); return new AsyncResult<>(result); } //完成任务 result.setImportStatus(GisSurveyImportStatusEnum.SUCCESS.getCode()); result.setCompleteTime(LocalDateTime.now()); LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName , String.format( "结束执行第三方导入;任务id: %s, 用时(毫秒):%d", params.getJobId(), Duration.between(result.getRequestTime(), result.getCompleteTime()).toMillis() ) ); //弃用子任务 onDeprecatedSubtask.accept(params.getJobId()); return new AsyncResult<>(result); } catch (InterruptedException | ExecutionException | IOException | RuntimeException e) { LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName , String.format( "监测到中断或执行异常,开始清除子任务 任务id:%s error:%s", params.getJobId(), e ) ); //清除子任务 if (invalidPropertiesFuture != null) invalidPropertiesFuture.cancel(true); if (duplicatePointsFuture != null) duplicatePointsFuture.cancel(true); if (invalidLinesFuture != null) invalidLinesFuture.cancel(true); //失败信息 result.setImportStatus(CommAsyncStatusEnum.FAIL.getCode()); result.setCompleteTime(LocalDateTime.now()); //弃用子任务 onDeprecatedSubtask.accept(params.getJobId()); return new AsyncResult<>(result); } } /** * 解析excel * * @param inputStreams 输入流 * @param points 点集合 * @param lines 线集合 * @throws IOException io异常 */ private void parseExcel(List inputStreams, List> points, List> lines) throws IOException, InterruptedException { LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行解析excel ======>"); long begin = System.currentTimeMillis(); //解析文件 for (InputStream inputStream : inputStreams) { //检查线程中断,并响应 if (Thread.interrupted()) throw new InterruptedException(); //解析excel Map>> excelData = ExcelUtils.parseExcelFile(inputStream, ExcelEnum.XLSX , GisSurveyExcelDefine.FILE_HANDLE.HEADER_ROW_NUM, GisSurveyExcelDefine.FILE_HANDLE.DATA_ROW_NUM); //填入集合 if (excelData != null && excelData.containsKey(GisMetadataDefine.TYPE_KINE.POINT)) points.addAll(excelData.get(GisMetadataDefine.TYPE_KINE.POINT)); if (excelData != null && excelData.containsKey(GisMetadataDefine.TYPE_KINE.LINE)) lines.addAll(excelData.get(GisMetadataDefine.TYPE_KINE.LINE)); //释放流 inputStream.close(); } long end = System.currentTimeMillis(); LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName , String.format( "结束执行执行解析excel,用时(毫秒):%d" , (end - begin) ) ); } /** * 获取图层名称 * * @param datas 数据 * @param layerKey 文件图层的key * @return 图层名称集合 */ private List getLayerNames(List> datas, String layerKey) { //去重图层 return datas.parallelStream() .filter(data -> data.get(layerKey) != null) .map(data -> data.get(layerKey)) .distinct() .collect(Collectors.toList()); } /** * 解包无效属性 * * @param invalidPropertiesResult 无效属性结果 * @param resultKey 结果key * @return 具体结果 */ private GisSurveyThirdImportResultDetail> untarInvalidProperties( GisSurveyThirdImportResultDetail>> invalidPropertiesResult , String resultKey) { //获取结果 List importElements = invalidPropertiesResult.getResults().get(resultKey); return new GisSurveyThirdImportResultDetail<>(true, importElements); } /** * 检查结果 * * @param result 结果 * @return 结果通过状态 */ private Boolean checkResult(GisSurveyThirdImportResult result) { List invalidLayers = result.getInvalidLayersResult().getResults(); List missingRequirements = result.getMissingRequirementsResult().getResults(); List invalidTypesResult = result.getInvalidTypesResult().getResults(); List outRanges = result.getOutRangesResult().getResults(); List outConstraint = result.getOutConstraintResult().getResults(); List duplicatePoints = result.getDuplicatePointsResult().getResults(); List invalidLines = result.getInvalidLinesResult().getResults(); //检查是否都为空 return CollectionUtils.isEmpty(invalidLayers) && CollectionUtils.isEmpty(missingRequirements) && CollectionUtils.isEmpty(invalidTypesResult) && CollectionUtils.isEmpty(outRanges) && CollectionUtils.isEmpty(outConstraint) && CollectionUtils.isEmpty(duplicatePoints) && CollectionUtils.isEmpty(invalidLines); } /** * 解码数据到采集元素对象 *

从Map转为 {@code GisSurveyLayerApplyThirdCopy}

* * @param points 点数据 * @param lines 线数据 * @param pointLayerTemplates 点图层模版 * @param lineLayerTemplates 线图层模版 * @param params 导入参数 * @return 格式化后数据 */ private List decodeDataToLayerApply(List> points, List> lines , List pointLayerTemplates, List lineLayerTemplates, GisSurveyThirdImportParams params) { LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "导入结果通过,开始解码点线数据 ======>"); long begin = System.currentTimeMillis(); //按模版名分组,便于快速找到模版 Map poineTemplateMap = pointLayerTemplates.stream() .collect(Collectors.toMap( GisMetadataLayerTemplate::getName, it -> it, (it1, it2) -> it1 )); Map lineTemplateMap = lineLayerTemplates.stream() .collect(Collectors.toMap( GisMetadataLayerTemplate::getName, it -> it, (it1, it2) -> it1 )); //采集元素象集合 List result = new ArrayList<>(); //点号映射,用于线写入上下游节点 Map pointNoMapping = new HashMap<>(); //格式化点 for (Map point : points) { //获取模版 GisMetadataLayerTemplate layerTemplate = poineTemplateMap.get(point.get(GisSurveyExcelDefine.FILE.POINT_LAYER)); //解码点对象 GisSurveyLayerApplyThirdCopy layerApply = decodePointToLayerApply(point, layerTemplate, params); //存入点号 pointNoMapping.put(layerApply.getNo(), layerApply.getCode()); result.add(layerApply); } //格式化线 for (Map line : lines) { //获取模版 GisMetadataLayerTemplate layerTemplate = lineTemplateMap.get(line.get(GisSurveyExcelDefine.FILE.LINE_LAYER)); //解码对象 GisSurveyLayerApplyThirdCopy layerApply = decodeLineToLayerApply(line, layerTemplate, params, pointNoMapping); result.add(layerApply); } long end = System.currentTimeMillis(); LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName , String.format( "结束执行解码点线数据,用时(毫秒):%d" , (end - begin) ) ); return result; } /** * 解码点数据到采集元素对象 * * @param point 点数据 * @param layerTemplate 图层模版 * @param params 导入参数 * @return 采集元素拷贝对象 */ private GisSurveyLayerApplyThirdCopy decodePointToLayerApply(Map point, GisMetadataLayerTemplate layerTemplate, GisSurveyThirdImportParams params) { GisSurveyLayerApplyThirdCopy layerApply = new GisSurveyLayerApplyThirdCopy(); //必填项 layerApply.setJobId(params.getJobId()); layerApply.setCode(PointCodeUtil.generateCode()); layerApply.setLayer(layerTemplate.getKey()); layerApply.setKind(GisMetadataDefine.TYPE_KINE.POINT); //默认值 layerApply.setApply(GisSurveyExcelDefine.DEFAULT_VALUE.APPLY); layerApply.setSource(GisSurveyExcelDefine.DEFAULT_VALUE.SOURCE); //点号(长度64截断) String noStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.NO); if (StringUtils.isNotBlank(noStr)) layerApply.setNo(StringUtils.substring(noStr, 0, 64)); //经纬度 Double lng = null; Double lat = null; //遍历属性模版 List propertyValueList = new ArrayList<>(); for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) { //解析属性 GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(point, layerApply , propertyTemplate, params); //不为空,填入数据 if (propertyValue != null) { propertyValueList.add(propertyValue); //经纬度属性 if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.LNG) && NumberUtils.isParsable(propertyValue.getValue())) lng = Double.valueOf(propertyValue.getValue()); if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.LAT) && NumberUtils.isParsable(propertyValue.getValue())) lat = Double.valueOf(propertyValue.getValue()); //高程和埋深 if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.ELEVATION) && NumberUtils.isParsable(propertyValue.getValue())) layerApply.setElevation(Double.valueOf(propertyValue.getValue())); if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.DEPTH) && NumberUtils.isParsable(propertyValue.getValue())) layerApply.setDepth(Double.valueOf(propertyValue.getValue())); } } //处理经纬度 if (lng != null && lat != null) { //构建geom Geometry geometry = geometryFactory.createPoint(new Coordinate(lng, lat)); //如源不为大地2000 if (!Objects.equals(params.getSourceCRSCode(), CommCRSDefine.CGCS2000)) { //转换坐标系 Geometry transform = CRSUtil.transform(geometry, params.getSourceCRSCode(), CommCRSDefine.CGCS2000); if (transform != null) { //回填geom geometry = transform; //获取解析后的经纬度 Coordinate coordinate = geometry.getCoordinate(); String lngStr = BigDecimal.valueOf(coordinate.getX()).toPlainString(); String latStr = BigDecimal.valueOf(coordinate.getY()).toPlainString(); //回填经纬度属性 propertyValueList.stream() .filter(it -> Objects.equals(it.getProperty(), GisSurveyExcelDefine.TEMPLATE.LAT)) .forEach(it -> it.setValue(latStr)); propertyValueList.stream() .filter(it -> Objects.equals(it.getProperty(), GisSurveyExcelDefine.TEMPLATE.LNG)) .forEach(it -> it.setValue(lngStr)); } } //设置geom layerApply.setGis(geometry); } //设置属性 layerApply.setPropertyValues(propertyValueList); return layerApply; } /** * 解码线数据到采集元素对象 * * @param line 线数据 * @param layerTemplate 图层模版 * @param params 导入参数 * @param pointNoMapping 点号映射 * @return 采集元素拷贝对象 */ private GisSurveyLayerApplyThirdCopy decodeLineToLayerApply(Map line, GisMetadataLayerTemplate layerTemplate, GisSurveyThirdImportParams params, Map pointNoMapping) { GisSurveyLayerApplyThirdCopy layerApply = new GisSurveyLayerApplyThirdCopy(); //必填项 layerApply.setJobId(params.getJobId()); layerApply.setCode(PointCodeUtil.generateCode()); layerApply.setLayer(layerTemplate.getKey()); layerApply.setKind(GisMetadataDefine.TYPE_KINE.LINE); //默认值 layerApply.setApply(GisSurveyExcelDefine.DEFAULT_VALUE.APPLY); layerApply.setSource(GisSurveyExcelDefine.DEFAULT_VALUE.SOURCE); //上下游节点 String upNoStr = ThirdImportTemplateUtils.getValue(line, layerTemplate, GisSurveyExcelDefine.TEMPLATE.UP_NO); if (StringUtils.isNotBlank(upNoStr)) { layerApply.setUpNode(pointNoMapping.get(upNoStr)); } String downNoStr = ThirdImportTemplateUtils.getValue(line, layerTemplate, GisSurveyExcelDefine.TEMPLATE.DOWN_NO); if (StringUtils.isNotBlank(downNoStr)) { layerApply.setDownNode(pointNoMapping.get(downNoStr)); } //遍历属性模版 List propertyValueList = new ArrayList<>(); for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) { //解析属性 GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(line, layerApply, propertyTemplate, params); if (propertyValue != null) propertyValueList.add(propertyValue); } layerApply.setPropertyValues(propertyValueList); return layerApply; } /** * 解码数据到属性值对象 * * @param data 数据 * @param layerApply 采集元素 * @param propertyTemplate 属性模版 * @param params 导出参数 * @return 属性值对象 */ private GisSurveyPropertyValueThirdCopy decodeDataToPropertyValue(Map data, GisSurveyLayerApplyThirdCopy layerApply , GisMetadataPropertyTemplate propertyTemplate, GisSurveyThirdImportParams params) { //点号直接返回点号属性 if (Objects.equals(GisSurveyExcelDefine.TEMPLATE.CODE, propertyTemplate.getKey())) return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getCode() , propertyTemplate.getKey(), layerApply.getCode()); if (Objects.equals(GisSurveyExcelDefine.TEMPLATE.UP_NODE, propertyTemplate.getKey())) return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getCode() , propertyTemplate.getKey(), layerApply.getUpNode()); if (Objects.equals(GisSurveyExcelDefine.TEMPLATE.DOWN_NODE, propertyTemplate.getKey())) return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getCode() , propertyTemplate.getKey(), layerApply.getDownNode()); //获取表头 String templateName = propertyTemplate.getName(); //获取值 String value = data.get(templateName); //构建dto if (StringUtils.isNotBlank(value)) { //double按数字处理,否则按字符串处理 if (propertyTemplate.getType().equals(GisSurveyExcelDefine.DATA_TYPE.DOUBLE) && propertyTemplate.getPrecisions() != null) { //如能被解析,则处理精度,否则设置为0 if (NumberUtils.isParsable(value)) { //值按精度设置小数位,并抹去0 value = new BigDecimal(value) .setScale(propertyTemplate.getPrecisions(), RoundingMode.DOWN) .stripTrailingZeros() .toPlainString(); } else value = "0"; } else { //值长度64截断 value = StringUtils.substring(value, 0, 64); } return new GisSurveyPropertyValueThirdCopy(params.getJobId() , layerApply.getCode(), propertyTemplate.getKey(), value); } return null; } /** * 重置点号 * * @param jobId 任务id * @param layerApplyList 采集元素集合 */ private void resetNo(String jobId, List layerApplyList) { LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始重置点号 ======>"); long begin = System.currentTimeMillis(); //点号规则 final List ruleFormat = jobInfoService.findRuleFormat(jobId); //点号映射 Map noMapping = new ConcurrentHashMap<>(); //并行遍历元素,处理点的点号 layerApplyList.parallelStream() .filter(la -> Objects.equals(la.getKind(), GisMetadataDefine.TYPE_KINE.POINT)) .forEach(la -> { //生成点号 String no = SurveyCommonAssistant.genNo( la.getCode(), la.getPropertyValues().stream() .map(pv -> new JPSurveyApplyColumn(pv.getProperty(), pv.getValue())) .collect(Collectors.toList()), ruleFormat ); //设置元素点号 la.setNo(no); //设置属性点号 la.getPropertyValues().stream() .filter(it -> Objects.equals(it.getProperty(), GisSurveyExcelDefine.TEMPLATE.NO)) .forEach(it -> it.setValue(no)); //设置点号映射 noMapping.put(la.getCode(), no); }); //处理线的上下点号 layerApplyList.parallelStream() .filter(la -> Objects.equals(la.getKind(), GisMetadataDefine.TYPE_KINE.LINE)) .forEach(la -> { //处理上点号 if (noMapping.containsKey(la.getUpNode())) { //设置属性点号 la.getPropertyValues().stream() .filter(it -> Objects.equals(it.getProperty(), GisSurveyExcelDefine.TEMPLATE.UP_NO)) .forEach(it -> it.setValue(noMapping.get(la.getUpNode()))); } //处理下点号 if (noMapping.containsKey(la.getDownNode())) { //设置属性点号 la.getPropertyValues().stream() .filter(it -> Objects.equals(it.getProperty(), GisSurveyExcelDefine.TEMPLATE.DOWN_NO)) .forEach(it -> it.setValue(noMapping.get(la.getDownNode()))); } }); long end = System.currentTimeMillis(); LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName , String.format( "结束执行执行重置点号,用时(毫秒):%d" , (end - begin) ) ); } }