|
|
|
@ -347,7 +347,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public List<Long> saveReportLingzhou(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList, int aiQxNum, int csQxNum) { |
|
|
|
public List<Long> saveReportLingzhou_v1(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList, int aiQxNum, int csQxNum) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
List<Long> reportIds = new ArrayList<>(); |
|
|
|
// String mainId = String.valueOf(resultMain.getLineId()); |
|
|
|
@ -357,7 +357,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
resultMain.setFileStatus("1"); |
|
|
|
this.patrolTaskResultMainMapper.updatePatrolTaskResultMain(resultMain); |
|
|
|
this.patrolResultMapper.updatePatrolResultByMainId(String.valueOf(lineId)); |
|
|
|
reportIds.addAll(saveReportDataLingzhou(resultList, resultMain, lineIds, aiQxNum, csQxNum)); |
|
|
|
reportIds.addAll(saveReportDataLingzhou_v1(resultList, resultMain, lineIds, aiQxNum, csQxNum)); |
|
|
|
} |
|
|
|
|
|
|
|
PrintUtil.useTime("获取所有报告id", startTime); |
|
|
|
@ -366,6 +366,118 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
// return saveReportData(resultList, resultMain, lineIds); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
public List<Long> saveReportLingzhou_v2(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
List<Long> reportIds = new ArrayList<>(); |
|
|
|
if (resultList.isEmpty()) { |
|
|
|
log.error("EMPTY REPORT DATA"); |
|
|
|
return reportIds; |
|
|
|
} |
|
|
|
String AiNum = statisticsAnalyseNumLingZhou(lineIds); |
|
|
|
List<String> taskNames = resultList.stream().map(PatrolResult::getTaskName).distinct().collect(Collectors.toList()); |
|
|
|
List<String> taskPatrolledIds = resultList.stream().map(PatrolResult::getTaskPatrolledId).distinct().collect(Collectors.toList()); |
|
|
|
String taskName = StringUtils.join(taskNames, ","); |
|
|
|
|
|
|
|
List<PatrolTaskStatus> taskStatuses = this.patrolTaskStatusMapper.selectPatrolTaskStatusListByTaskPatrolledIds(taskPatrolledIds); |
|
|
|
if (taskStatuses.isEmpty()) { |
|
|
|
log.error("LACKING STATUS: " + resultMain.getLineId()); |
|
|
|
} |
|
|
|
List<Date> startTimes = taskStatuses.stream().map(PatrolTaskStatus::getStartTime).sorted().collect(Collectors.toList()); |
|
|
|
List<String> endTimes = taskStatuses.stream().map(PatrolTaskStatus::getEndTime).sorted().collect(Collectors.toList()); |
|
|
|
|
|
|
|
Map<String, String> stationMap = patrolResultMapper.selectBasedataStation(); |
|
|
|
String stationName = stationMap.get("station_name"); |
|
|
|
String stationType = stationMap.get("station_type"); |
|
|
|
String voltLevel = stationMap.get("volt_level"); |
|
|
|
AjaxResult ajaxResult = feignBasedataAreaService.evnList(); |
|
|
|
List<JSONObject> jsonObjects = JSONObject.parseArray(JSON.toJSONString(ajaxResult.get("data")), JSONObject.class); |
|
|
|
log.debug("EVN LIST: " + jsonObjects); |
|
|
|
List<String> envoList = new ArrayList<>(); |
|
|
|
for (JSONObject jsonObject : jsonObjects) { |
|
|
|
String typeName = jsonObject.getString("typeName"); |
|
|
|
String valueUnit = jsonObject.getString("valueUnit"); |
|
|
|
if (StringUtils.isEmpty(valueUnit) || StringUtils.isEmpty(typeName)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
envoList.add(typeName + ":" + valueUnit); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, PatrolResultRef> keyPatrolResultRef = new HashMap<>(); |
|
|
|
List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(lineIds, "0"); |
|
|
|
List<PatrolResultRef> patrolResultRefsFilter = patrolResultMapper.selectResultRefByLineIds(lineIds, "1"); |
|
|
|
for (PatrolResultRef AIRef : patrolResultRefs) { |
|
|
|
keyPatrolResultRef.put(AIRef.getDeviceId() + "_" + AIRef.getAlgType(), AIRef); |
|
|
|
} |
|
|
|
for (PatrolResultRef filterRef : patrolResultRefsFilter) { |
|
|
|
keyPatrolResultRef.putIfAbsent(filterRef.getDeviceId() + "_" + filterRef.getAlgType(), filterRef); |
|
|
|
} |
|
|
|
patrolResultRefs = new ArrayList<>(keyPatrolResultRef.values()); |
|
|
|
|
|
|
|
// 每个任务生成一份报告 |
|
|
|
for (Long lineId : lineIds) { |
|
|
|
resultMain.setLineId(lineId); |
|
|
|
resultMain.setCheckTime(new Date()); |
|
|
|
resultMain.setFileStatus("1"); |
|
|
|
this.patrolTaskResultMainMapper.updatePatrolTaskResultMain(resultMain); |
|
|
|
this.patrolResultMapper.updatePatrolResultByMainId(String.valueOf(lineId)); |
|
|
|
startTime = System.currentTimeMillis(); |
|
|
|
String mainId = String.valueOf(resultMain.getLineId()); |
|
|
|
String[] nums = new String[]{AiNum}; |
|
|
|
|
|
|
|
PatrolResult patrolResult = resultList.stream().filter(item -> mainId.equals(item.getMainId())).findFirst().orElse(null); |
|
|
|
assert patrolResult != null; |
|
|
|
String taskCode = patrolResult.getTaskCode(); |
|
|
|
String taskPatrolId = patrolResult.getTaskPatrolledId(); |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(taskPatrolId)) { |
|
|
|
throw new ServiceException("LACK PLAN ID: " + mainId); |
|
|
|
} else { |
|
|
|
if (taskStatuses.isEmpty()) { |
|
|
|
throw new ServiceException("LACKING STATUS: " + mainId); |
|
|
|
} else { |
|
|
|
// PatrolTaskStatus taskStatus = taskStatuses.stream().filter(item -> taskPatrolId.equals(item.getTaskPatrolledId())).findFirst().orElse(null); |
|
|
|
List<PatrolTask> list = patrolTaskMapper.selectPatrolTaskList(PatrolTask.builder().taskCode(taskCode).build()); |
|
|
|
if (list.isEmpty()) { |
|
|
|
throw new ServiceException("TASK PLAN LOST: " + taskCode); |
|
|
|
} else { |
|
|
|
PatrolTask task = list.get(0); |
|
|
|
for (int i = 0; i < nums.length; i++) { |
|
|
|
InspectionReport report = new InspectionReport(); |
|
|
|
// resetReport(report, nums[i], mainId, task, taskStatus); |
|
|
|
report.setPatrolStatistics(nums[i]); |
|
|
|
report.setInspectionDate(new Date()); |
|
|
|
report.setTaskResultId(mainId); |
|
|
|
report.setInspectionStartTime(startTimes.get(0)); |
|
|
|
report.setInspectionEndTime(DateUtils.parseDate(endTimes.get(endTimes.size() - 1))); |
|
|
|
report.setTaskId(String.valueOf(task.getTaskId())); |
|
|
|
report.setEnvInfo(StringUtils.join(envoList, ",")); |
|
|
|
report.setTaskPatrolledId(taskPatrolId); |
|
|
|
report.setInspectionTaskName(taskName); |
|
|
|
report.setDescription(resultMain.getTaskResult()); |
|
|
|
report.setCheckPerson(resultMain.getCheckPerson()); |
|
|
|
report.setCheckTime(resultMain.getCheckTime()); |
|
|
|
report.setStationName(stationName); |
|
|
|
report.setVoltLevel(StringUtils.isEmpty(voltLevel) ? voltage : voltLevel); |
|
|
|
report.setFilter(String.valueOf(i)); |
|
|
|
report.setStationType(stationType); |
|
|
|
inspectionReportMapper.insertInspectionReport(report); |
|
|
|
PrintUtil.useTime("NEW TASK REPORT", startTime); // 12s |
|
|
|
batchInsertReportData(String.valueOf(report.getLineId()), lineIds, String.valueOf(i), patrolResultRefs); |
|
|
|
PrintUtil.useTime("BATCH INSERT DETAIL", startTime); // 13s |
|
|
|
log.info("[ARCHIVE] reportId: {}", report.getLineId()); |
|
|
|
reportIds.add(report.getLineId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PrintUtil.useTime("获取所有报告id", startTime); |
|
|
|
return reportIds; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public List<Long> saveReportShaoxing(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList, int aiQxNum, int csQxNum) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
@ -585,7 +697,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public List<Long> saveReportDataLingzhou(List<PatrolResult> resultList, PatrolTaskResultMain resultMain, List<Long> lineIds, int aiQxNum, int csQxNum) { |
|
|
|
public List<Long> saveReportDataLingzhou_v1(List<PatrolResult> resultList, PatrolTaskResultMain resultMain, List<Long> lineIds, int aiQxNum, int csQxNum) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
String mainId = String.valueOf(resultMain.getLineId()); |
|
|
|
// String analyseNum = statisticsAnalyseNum(lineIds, resultList.size()); |
|
|
|
@ -1189,18 +1301,18 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
|
|
|
|
|
|
|
|
int totalNum = keyToAnalysisMap.size(); |
|
|
|
log.info("lineIds:{},statisticsAnalyseNum analyses:{}", lineIds, analysesAI); |
|
|
|
for (ResultAnalysis analyse : keyToAnalysisMap.values()) { |
|
|
|
String resultType = analyse.getResultType(); |
|
|
|
if (resultType.equals("0")) { |
|
|
|
++confirmNum; |
|
|
|
} else if (resultType.equals("1")) { |
|
|
|
++okNum; |
|
|
|
} else if (resultType.equals("2")) { |
|
|
|
++failNum; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ("0".equals(exportReportFlag)) { |
|
|
|
for (ResultAnalysis analyse : keyToAnalysisMap.values()) { |
|
|
|
String resultType = analyse.getResultType(); |
|
|
|
if (resultType.equals("0")) { |
|
|
|
++confirmNum; |
|
|
|
} else if (resultType.equals("1")) { |
|
|
|
++okNum; |
|
|
|
} else if (resultType.equals("2")) { |
|
|
|
++failNum; |
|
|
|
} |
|
|
|
} |
|
|
|
return String.format(messageUtils.get("缺陷点位:%d个。"), confirmNum); |
|
|
|
} else { |
|
|
|
// return String.format(messageUtils.get("本次任务巡视总点位:%d个,已检点位:%d个,未检点位:0个,正常点位:%d个,异常点位:%d个,缺陷点位:%d个。"), totalNum, totalNum, okNum, failNum, confirmNum); |
|
|
|
|