Browse Source

绍兴新需求,任务导出,合并缺陷

master
wangguangyuan 3 months ago
parent
commit
d7212846b6
3 changed files with 105 additions and 45 deletions
  1. +85
    -27
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java
  2. +18
    -18
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java
  3. +2
    -0
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml

+ 85
- 27
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java View File

@ -1162,21 +1162,24 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
int failNum = 0;
int confirmNum = 0;
List<ResultAnalysis> analyses = resultAnalysisMapper.selectResultAnalysisListByMainIdsNew(lineIds, null);
int totalNum = analyses.size();
log.info("lineIds:{},statisticsAnalyseNum analyses:{}", lineIds, analyses);
for (ResultAnalysis analyse : analyses) {
String resultType = analyse.getResultType();
if ("0".equals(resultType)) {
++confirmNum;
} else if (("1").equals(resultType)) {
++okNum;
} else if (("2").equals(resultType)) {
++failNum;
}
}
if ("0".equals(exportReportFlag)) {
return String.format(messageUtils.get("缺陷点位:%d个。"), confirmNum);
// 直导缺陷
List<ResultAnalysis> qxResultAnalyses = analyses.stream().filter(analysis -> "0".equals(analysis.getResultType())).collect(Collectors.toList());
long count = qxResultAnalyses.stream().map(analysis -> analysis.getAlgType() + "|" + analysis.getObjectId()).distinct().count();
return String.format(messageUtils.get("缺陷点位:%d个。"), count);
} else {
int totalNum = analyses.size();
log.info("lineIds:{},statisticsAnalyseNum analyses:{}", lineIds, analyses);
for (ResultAnalysis analyse : analyses) {
String resultType = analyse.getResultType();
if ("0".equals(resultType)) {
++confirmNum;
} else if (("1").equals(resultType)) {
++okNum;
} else if (("2").equals(resultType)) {
++failNum;
}
}
return String.format(messageUtils.get("本次任务巡视总点位:%d个,已检点位:%d个,未检点位:0个,正常点位:%d个,异常点位:%d个,缺陷点位:%d个。"), totalNum, totalNum, okNum, failNum, confirmNum);
}
}
@ -1274,18 +1277,18 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
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.info("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);
}
// AjaxResult ajaxResult = feignBasedataAreaService.evnList();
// List<JSONObject> jsonObjects = JSONObject.parseArray(JSON.toJSONString(ajaxResult.get("data")), JSONObject.class);
// log.info("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);
// }
InspectionReport report = new InspectionReport();
report.setInspectionDate(new Date());
@ -1294,7 +1297,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
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.setEnvInfo(StringUtils.join(envoList,","));
// report.setTaskPatrolledId(taskPatrolId);
report.setInspectionTaskName(taskName);
report.setDescription(patrolTaskResultMain.getTaskResult());
@ -1306,8 +1309,39 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
report.setStationType(stationType);
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())));
groupKeyListMap.forEach((key, value) -> {
PatrolResultRef patrolResultRef = new PatrolResultRef();
patrolResultRef.setDeviceId(key.objectId);
patrolResultRef.setAlgType(key.algType);
patrolResultRef.setDescription(value.stream().map(PatrolResultRef::getDescription).collect(Collectors.joining(",")));
patrolResultRef.setValue(value.stream().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.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;
}
List<BasePointAreaInfo> basePointAreaInfoList = patrolResultMapper.selectBaseInfoByMainIds(lineIds);
@ -1401,6 +1435,30 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
return report;
}
private static class GroupKey {
private final String objectId;
private final String algType;
public GroupKey(String objectId, String algType) {
this.objectId = objectId;
this.algType = algType;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GroupKey groupKey = (GroupKey) o;
return Objects.equals(objectId, groupKey.objectId) && Objects.equals(algType, groupKey.algType);
}
@Override
public int hashCode() {
return Objects.hash(objectId, algType);
}
}
public static void main(String[] args) {
List<String> students = new ArrayList<>();
students.add("s1");


+ 18
- 18
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java View File

@ -497,24 +497,24 @@ public class PatrolTaskResultMainController extends BaseController {
if (StringUtils.isNotEmpty(reportImg.getImgSrc()) && reportImg.getImgType().equals("0")) {
String originalImgSrc = reportImg.getImgSrc();
images.add(originalImgSrc);
String pointName = reportData.getPointName();
pointName = (pointName != null) ? pointName : "unnamed";
// 提取文件扩展名
String extension = "";
int dotIndex = originalImgSrc.lastIndexOf('.');
if (dotIndex > 0) {
extension = originalImgSrc.substring(dotIndex);
}
// 生成唯一文件名包含 lineId 防止重复
String uniqueFileName = String.format("%s_%s_%d%s",
originalImgSrc.split("_")[2],
pointName,
imgIndex,
extension);
imgSrcToFileNameMap.put(originalImgSrc, uniqueFileName);
imgIndex++;
// String pointName = reportData.getPointName();
// pointName = (pointName != null) ? pointName : "unnamed";
// // 提取文件扩展名
// String extension = "";
// int dotIndex = originalImgSrc.lastIndexOf('.');
// if (dotIndex > 0) {
// extension = originalImgSrc.substring(dotIndex);
// }
//
// // 生成唯一文件名包含 lineId 防止重复
// String uniqueFileName = String.format("%s_%s_%d%s",
// originalImgSrc.split("_")[2],
// pointName,
// imgIndex,
// extension);
//
// imgSrcToFileNameMap.put(originalImgSrc, uniqueFileName);
// imgIndex++;
}
}
}


+ 2
- 0
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml View File

@ -604,6 +604,7 @@
<result property="value" column="value"/>
<result property="threshold" column="threshold"/>
<result property="filePath" column="file_path"/>
<result property="filter" column="filter"/>
<result property="description" column="description"/>
<result property="pointStatus" column="point_status"/>
<result property="valueUnit" column="value_unit"/>
@ -640,6 +641,7 @@
b.res_value value,
a.threshold,
a.file_path,
b.filter,
b.description,
b.point_status,
b.result_type,


Loading…
Cancel
Save