|
|
|
@ -375,7 +375,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
log.error("EMPTY REPORT DATA"); |
|
|
|
return reportIds; |
|
|
|
} |
|
|
|
String AiNum = statisticsAnalyseNumLingZhou(lineIds); |
|
|
|
// 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, ","); |
|
|
|
@ -407,14 +407,38 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
Map<String, PatrolResultRef> keyPatrolResultRef = new HashMap<>(); |
|
|
|
List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(lineIds, "0"); |
|
|
|
List<PatrolResultRef> patrolResultRefsFilter = patrolResultMapper.selectResultRefByLineIds(lineIds, "1"); |
|
|
|
int qxNumFilter = 0; |
|
|
|
int ycNumFilter = 0; |
|
|
|
int qxNumAI = 0; |
|
|
|
for (PatrolResultRef AIRef : patrolResultRefs) { |
|
|
|
keyPatrolResultRef.put(AIRef.getDeviceId() + "_" + AIRef.getAlgType(), AIRef); |
|
|
|
// if ("0".equals(AIRef.getResultType())) { |
|
|
|
// ++qxNumAI; |
|
|
|
// } |
|
|
|
} |
|
|
|
for (PatrolResultRef filterRef : patrolResultRefsFilter) { |
|
|
|
keyPatrolResultRef.putIfAbsent(filterRef.getDeviceId() + "_" + filterRef.getAlgType(), filterRef); |
|
|
|
// if ("0".equals(filterRef.getResultType())) { |
|
|
|
// ++qxNumFilter; |
|
|
|
// } else if ("2".equals(filterRef.getResultType())) { |
|
|
|
// ++ycNumFilter; |
|
|
|
// } |
|
|
|
} |
|
|
|
patrolResultRefs = new ArrayList<>(keyPatrolResultRef.values()); |
|
|
|
|
|
|
|
for (PatrolResultRef patrolResultRef : patrolResultRefs) { |
|
|
|
if ("0".equals(patrolResultRef.getFilter()) && "0".equals(patrolResultRef.getResultType())) { |
|
|
|
++qxNumAI; |
|
|
|
} |
|
|
|
if ("1".equals(patrolResultRef.getFilter()) && "0".equals(patrolResultRef.getResultType())) { |
|
|
|
++qxNumFilter; |
|
|
|
} |
|
|
|
if ("2".equals(patrolResultRef.getResultType())) { |
|
|
|
++ycNumFilter; |
|
|
|
} |
|
|
|
} |
|
|
|
int totalNum = patrolResultRefs.size(); |
|
|
|
String AiNum = String.format(messageUtils.get("本次任务巡视总点位:%d个,已检点位:%d个,未检点位:0个,初筛缺陷点位:%d个,异常点位:%d个;大模型复检缺陷点位:%d个。"), totalNum, totalNum, qxNumFilter, ycNumFilter, qxNumAI); |
|
|
|
List<BasePointAreaInfo> basePointAreaInfoList = patrolResultMapper.selectBaseInfoByMainIds(lineIds); |
|
|
|
// 每个任务生成一份报告 |
|
|
|
for (Long lineId : lineIds) { |
|
|
|
resultMain.setLineId(lineId); |
|
|
|
@ -464,7 +488,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
report.setStationType(stationType); |
|
|
|
inspectionReportMapper.insertInspectionReport(report); |
|
|
|
PrintUtil.useTime("NEW TASK REPORT", startTime); // 12s |
|
|
|
batchInsertReportData(String.valueOf(report.getLineId()), lineIds, String.valueOf(i), patrolResultRefs); |
|
|
|
batchInsertReportData_Lingzhou(String.valueOf(report.getLineId()), basePointAreaInfoList, String.valueOf(i), patrolResultRefs); |
|
|
|
PrintUtil.useTime("BATCH INSERT DETAIL", startTime); // 13s |
|
|
|
log.info("[ARCHIVE] reportId: {}", report.getLineId()); |
|
|
|
reportIds.add(report.getLineId()); |
|
|
|
@ -1084,6 +1108,156 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void batchInsertReportData_Lingzhou(String reportId, List<BasePointAreaInfo> basePointAreaInfoList, String filter, List<PatrolResultRef> patrolResultRefs) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
if ("0".equals(exportReportFlag)) { |
|
|
|
List <PatrolResultRef> resultRefs = new ArrayList<>(); |
|
|
|
// 只导出缺陷 |
|
|
|
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); |
|
|
|
// 分组,按点位ID和算法类型进行分组 |
|
|
|
Map<GroupKey, List<PatrolResultRef>> groupKeyListMap = patrolResultRefs.stream().collect(Collectors.groupingBy(item -> new GroupKey(item.getDeviceId(), item.getAlgType(), item.getTaskPatrolledId()))); |
|
|
|
groupKeyListMap.forEach((key, value) -> { |
|
|
|
PatrolResultRef patrolResultRef = new PatrolResultRef(); |
|
|
|
patrolResultRef.setDeviceId(key.objectId); |
|
|
|
patrolResultRef.setAlgType(key.algType); |
|
|
|
patrolResultRef.setDescription(value.stream().sorted(Comparator.comparing(PatrolResultRef::getFilter).reversed()).map(PatrolResultRef::getDescription).collect(Collectors.joining(","))); |
|
|
|
patrolResultRef.setValue(value.stream().sorted(Comparator.comparing(PatrolResultRef::getFilter).reversed()).map(PatrolResultRef::getValue).collect(Collectors.joining(","))); |
|
|
|
for (PatrolResultRef resultRef : value) { |
|
|
|
// 初筛有缺陷,展示初筛结果 |
|
|
|
if ("1".equals(resultRef.getFilter()) && StringUtils.isEmpty(patrolResultRef.getResultContent())) { |
|
|
|
patrolResultRef.setResultContent(resultRef.getResultContent()); |
|
|
|
} |
|
|
|
if ("1".equals(resultRef.getFilter()) && StringUtils.isEmpty(patrolResultRef.getFilePath())) { |
|
|
|
patrolResultRef.setFilePath(resultRef.getFilePath()); |
|
|
|
} |
|
|
|
// 大模型有缺陷,展示大模型结果 |
|
|
|
if ("0".equals(resultRef.getFilter())) { |
|
|
|
patrolResultRef.setResultContent(resultRef.getResultContent()); |
|
|
|
patrolResultRef.setFilePath(resultRef.getFilePath()); |
|
|
|
} |
|
|
|
} |
|
|
|
patrolResultRef.setDevType(value.stream().map(item -> item.getDevType() != null ? item.getDevType() : "").distinct().findFirst().orElse("")); |
|
|
|
patrolResultRef.setDeviceSource(value.stream().map(item -> item.getDeviceSource() != null ? item.getDeviceSource() : "").distinct().findFirst().orElse("")); |
|
|
|
patrolResultRef.setTime(value.stream().map(item -> item.getTime() != null ? item.getTime() : "").distinct().findFirst().orElse("")); |
|
|
|
patrolResultRef.setThreshold(value.stream().map(item -> item.getThreshold() != null ? item.getThreshold() : "").distinct().findFirst().orElse("")); |
|
|
|
patrolResultRef.setAlgName(value.get(0).getAlgName()); |
|
|
|
patrolResultRef.setResultType("0"); |
|
|
|
resultRefs.add(patrolResultRef); |
|
|
|
}); |
|
|
|
patrolResultRefs = resultRefs; |
|
|
|
} |
|
|
|
|
|
|
|
startTime = PrintUtil.useTime("SELECT RESULT", startTime); |
|
|
|
PrintUtil.useTime("AREA INQUERY", startTime); |
|
|
|
log.info("REPORTS SIZE: {}", patrolResultRefs.size()); |
|
|
|
List<InspectionReportData> reportDatas = new ArrayList<>(); |
|
|
|
List<InspectionReportImg> reportImages = new ArrayList<>(); |
|
|
|
|
|
|
|
long okNum = 1L; |
|
|
|
long failNum = 1L; |
|
|
|
long defectNum = 1L; |
|
|
|
int index; |
|
|
|
for (index = 0; index < patrolResultRefs.size(); ++index) { |
|
|
|
PatrolResultRef patrolResultRef = patrolResultRefs.get(index); |
|
|
|
BasePointAreaInfo basePointAreaInfo; |
|
|
|
try { |
|
|
|
basePointAreaInfo = basePointAreaInfoList.stream().filter((item) -> item != null && patrolResultRef.getDeviceId().equals(item.getDeviceId())).findFirst().get(); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("[REPORT DETAIL] The point lacking belonging area: {}", patrolResultRef.getDeviceId()); |
|
|
|
basePointAreaInfo = new BasePointAreaInfo(); |
|
|
|
} |
|
|
|
|
|
|
|
InspectionReportData reportData = new InspectionReportData(); |
|
|
|
reportData.setReportId(reportId); |
|
|
|
reportData.setArea(basePointAreaInfo.getAreaName()); |
|
|
|
reportData.setTimeInterval(basePointAreaInfo.getJgName()); |
|
|
|
reportData.setEqName(basePointAreaInfo.getMainName()); |
|
|
|
reportData.setParts(basePointAreaInfo.getDeviceName()); |
|
|
|
reportData.setPointName(basePointAreaInfo.getPatrolPointName()); |
|
|
|
reportData.setDataSources(patrolResultRef.getDeviceSource()); |
|
|
|
reportData.setAcquisitionTime(DateUtils.parse(DateUtils.yyyyMMddHHmmss2, patrolResultRef.getTime())); |
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && validAlgTypes.contains(patrolResultRef.getAlgType())) { |
|
|
|
reportData.setInspectionResults(patrolResultRef.getValue()); |
|
|
|
} else { |
|
|
|
reportData.setInspectionResults(patrolResultRef.getDescription()); |
|
|
|
} |
|
|
|
reportData.setAlgName(patrolResultRef.getAlgName()); |
|
|
|
String threshold = patrolResultRef.getThreshold(); |
|
|
|
if(StringUtils.isBlank(threshold)) { |
|
|
|
threshold = ""; |
|
|
|
} |
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { |
|
|
|
reportData.setInspectionResults(patrolResultRef.getValue()); |
|
|
|
} |
|
|
|
|
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && (threshold.contains("sub_52") || threshold.contains("sub_53")) |
|
|
|
&& !"0".equals(patrolResultRef.getValue()) |
|
|
|
&& !"1".equals(patrolResultRef.getValue()) |
|
|
|
&& !"-1".equals(patrolResultRef.getValue()) |
|
|
|
&& !"check image".equals(patrolResultRef.getValue())) { |
|
|
|
reportData.setInspectionResults(patrolResultRef.getValue()); |
|
|
|
} |
|
|
|
|
|
|
|
String resultType = patrolResultRef.getResultType(); |
|
|
|
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); |
|
|
|
if(resultType == null) { |
|
|
|
continue; |
|
|
|
} else if (resultType.equals("0")) { |
|
|
|
reportData.setPointStatus(messageUtils.get("缺陷")); |
|
|
|
// 缺陷编号 |
|
|
|
reportData.setCode(defectNum); |
|
|
|
++defectNum; |
|
|
|
} else if (resultType.equals("1")) { |
|
|
|
reportData.setPointStatus(messageUtils.get("正常")); |
|
|
|
reportData.setCode(okNum); |
|
|
|
++okNum; |
|
|
|
} else { |
|
|
|
reportData.setPointStatus(messageUtils.get("异常")); |
|
|
|
// 异常编号 |
|
|
|
reportData.setCode(failNum); |
|
|
|
++failNum; |
|
|
|
} |
|
|
|
|
|
|
|
final String reportDataId = reportId + "_" + (100000 + index); |
|
|
|
reportData.setLineId(reportDataId); |
|
|
|
reportDatas.add(reportData); |
|
|
|
log.info("batchInsertReportData reportData:" + reportData); |
|
|
|
String resultContent = patrolResultRef.getResultContent(); |
|
|
|
AnalyseResPoint analyseResPoint = JSONObject.parseObject(resultContent, AnalyseResPoint.class); |
|
|
|
String imgUrl = analyseResPoint.getResImageUrl(); |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(imgUrl)) { |
|
|
|
imgUrl = patrolResultRef.getFilePath().split(StringUtils.COMMA)[0]; |
|
|
|
} |
|
|
|
|
|
|
|
InspectionReportImg reportImg = new InspectionReportImg(); |
|
|
|
reportImg.setReportInfoId(reportDataId); |
|
|
|
reportImg.setImg(imgUrl); |
|
|
|
reportImg.setImgSrc(imgUrl); |
|
|
|
reportImg.setImgType("0"); |
|
|
|
reportImg.setCreatTime(new Date()); |
|
|
|
reportImages.add(reportImg); |
|
|
|
log.info("batchInsertReportData reportImg:" + reportImg); |
|
|
|
} |
|
|
|
|
|
|
|
index = reportDatas.size() / 50; |
|
|
|
if (reportDatas.size() % 50 > 0) { |
|
|
|
++index; |
|
|
|
} |
|
|
|
|
|
|
|
log.info("[REPORT] BATCH INSERT PROGRESS: reportDatas size: {}", reportDatas.size()); |
|
|
|
for (int j = 0; j < reportDatas.size(); j += 50) { |
|
|
|
log.info("[REPORT] BATCH INSERT PROGRESS: {}/{}", j / 50 + 1, j % 50 + 1); |
|
|
|
int end = j + 50; |
|
|
|
if (end > reportDatas.size() - 1) { |
|
|
|
end = reportDatas.size(); |
|
|
|
} |
|
|
|
|
|
|
|
inspectionReportDataMapper.batchInsertInspectionReportData(reportDatas.subList(j, end)); |
|
|
|
inspectionReportImgMapper.batchInsertInspectionReportImg(reportImages.subList(j, end)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void batchInsertReportDataV2(String reportId, String mainId, String filter) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
long okNum = 1L; |
|
|
|
|