|
@@ -0,0 +1,146 @@
|
|
|
+package com.shkpr.service.alambizplugin.components.checker;
|
|
|
+
|
|
|
+import com.global.base.log.LogLevelFlag;
|
|
|
+import com.global.base.log.LogPrintMgr;
|
|
|
+import com.shkpr.service.alambizplugin.commtools.BeanUtil;
|
|
|
+import com.shkpr.service.alambizplugin.components.GisSurveySystemCheckResultManager;
|
|
|
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultHead;
|
|
|
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
|
|
|
+import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckElement;
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
|
|
|
+import com.shkpr.service.alambizplugin.exception.UncheckedInterruptedException;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.commons.lang3.math.NumberUtils;
|
|
|
+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.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 高程差寻找器
|
|
|
+ *
|
|
|
+ * @author 欧阳劲驰
|
|
|
+ * @since 1.0.0
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class ElevationDiffFinder {
|
|
|
+ /**
|
|
|
+ * log
|
|
|
+ */
|
|
|
+ private final String mStrClassName;
|
|
|
+ private final String mBizType;
|
|
|
+ private final GisSurveySystemCheckResultManager systemCheckResultManager;
|
|
|
+
|
|
|
+
|
|
|
+ public ElevationDiffFinder(GisSurveySystemCheckResultManager systemCheckResultManager) {
|
|
|
+ mStrClassName = "ElevationDiffFinder";
|
|
|
+ mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
|
|
|
+ this.systemCheckResultManager = systemCheckResultManager;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 寻找高程差异常
|
|
|
+ * <p>根据高程差和勘测长度判断,不涉及拓扑点</p><p>异常规则:高程差大于勘测长度</p>
|
|
|
+ *
|
|
|
+ * @param lines 线集合
|
|
|
+ * @param systemCheckId 系统检查id
|
|
|
+ * @return 高程差异常集合
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public ListenableFuture<GisSurveySystemCheckResultDetail> findElevationDiff(List<GisSurveyLayerApplyLine> lines
|
|
|
+ , GisSurveySystemCheckId systemCheckId) throws InterruptedException {
|
|
|
+ try {
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找高程差异常========>");
|
|
|
+ long begin = System.currentTimeMillis();
|
|
|
+
|
|
|
+ //并行流寻找高度差异常
|
|
|
+ List<GisSurveySystemCheckElement> elements = lines.parallelStream()
|
|
|
+ //响应中断
|
|
|
+ .peek(line -> {
|
|
|
+ if (Thread.currentThread().isInterrupted())
|
|
|
+ throw new UncheckedInterruptedException(new InterruptedException());
|
|
|
+ })
|
|
|
+ .filter(line -> {
|
|
|
+ //勘测长度字符串判断
|
|
|
+ if (StringUtils.isBlank(line.getSurveyLength()) && NumberUtils.isParsable(line.getSurveyLength()))
|
|
|
+ return false;
|
|
|
+ try {
|
|
|
+ //判断高程差是否大于勘测长度
|
|
|
+ return line.getElevationDiff() > Double.parseDouble(line.getSurveyLength());
|
|
|
+ } catch (NumberFormatException numberFormatException) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .map(line -> BeanUtil.copy(line, GisSurveySystemCheckElement.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return new AsyncResult<>(createResult(elements, systemCheckId, begin));
|
|
|
+ } catch (UncheckedInterruptedException e) {
|
|
|
+ throw e.getCause();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建结果
|
|
|
+ *
|
|
|
+ * @param data 数据
|
|
|
+ * @param systemCheckId 系统检查id
|
|
|
+ * @param begin 开始时间
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ private GisSurveySystemCheckResultDetail createResult(List<GisSurveySystemCheckElement> data
|
|
|
+ , GisSurveySystemCheckId systemCheckId, long begin) {
|
|
|
+ //数据大小
|
|
|
+ final int size = data.size();
|
|
|
+ //结果路径
|
|
|
+ String resultPath = GisSurveySystemCheckResultPath.ELEVATION_DIFF;
|
|
|
+ //excel路径
|
|
|
+ String excelPath = GisSurveySystemCheckResultPath.ELEVATION_DIFF_EXCEL;
|
|
|
+ //写入结果
|
|
|
+ systemCheckResultManager.writeResult(data, systemCheckId, resultPath);
|
|
|
+ //写入excel
|
|
|
+ systemCheckResultManager.writeExcel(GisSurveySystemCheckResultHead.ELEVATION_DIFF,
|
|
|
+ buildExcel(data), systemCheckId, excelPath);
|
|
|
+
|
|
|
+ long end = System.currentTimeMillis();
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
|
+ , String.format(
|
|
|
+ "结束执行寻找孤立点,用时(毫秒):%d"
|
|
|
+ , (end - begin)
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ //构建结果
|
|
|
+ return new GisSurveySystemCheckResultDetail(true
|
|
|
+ , GisSurveySystemCheckResultPath.relativePath(systemCheckId, resultPath)
|
|
|
+ , GisSurveySystemCheckResultPath.relativePath(systemCheckId, excelPath)
|
|
|
+ , size);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建excel数据
|
|
|
+ *
|
|
|
+ * @param data 数据
|
|
|
+ * @return excel数据
|
|
|
+ */
|
|
|
+ private List<Map<String, Object>> buildExcel(List<GisSurveySystemCheckElement> data) {
|
|
|
+ return data.stream().map(element -> {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put(GisSurveySystemCheckResultHead.KEYS.UP_NO, element.getUpNo());
|
|
|
+ map.put(GisSurveySystemCheckResultHead.KEYS.DOWN_NO, element.getDownNo());
|
|
|
+ map.put(GisSurveySystemCheckResultHead.KEYS.CODE, element.getCode());
|
|
|
+ map.put(GisSurveySystemCheckResultHead.KEYS.UP_NODE, element.getUpNode());
|
|
|
+ map.put(GisSurveySystemCheckResultHead.KEYS.DOWN_NODE, element.getDownNode());
|
|
|
+ map.put(GisSurveySystemCheckResultHead.KEYS.NAME, element.getName());
|
|
|
+ return map;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+}
|