|
|
|
@ -7,7 +7,9 @@ import com.inspect.analysis.domain.AlgValue; |
|
|
|
import com.inspect.analysis.domain.AnalyseResPoint; |
|
|
|
import com.inspect.analysis.domain.ResultAnalysis; |
|
|
|
import com.inspect.analysis.mapper.ResultAnalysisMapper; |
|
|
|
import com.inspect.analysis.utils.ResultAnalysisUtils; |
|
|
|
import com.inspect.base.core.constant.AlgConstants; |
|
|
|
import com.inspect.base.core.enums.TaskType; |
|
|
|
import com.inspect.base.core.exception.ServiceException; |
|
|
|
import com.inspect.base.core.utils.DateUtils; |
|
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
|
@ -34,11 +36,6 @@ import com.inspect.task.domain.PatrolTask; |
|
|
|
import com.inspect.task.mapper.PatrolTaskMapper; |
|
|
|
import com.inspect.taskstatus.domain.PatrolTaskStatus; |
|
|
|
import com.inspect.taskstatus.mapper.PatrolTaskStatusMapper; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import io.seata.common.util.CollectionUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
@ -48,20 +45,30 @@ import org.springframework.cloud.context.config.annotation.RefreshScope; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
@RefreshScope |
|
|
|
public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(PatrolResultServiceImpl.class); |
|
|
|
|
|
|
|
@Value("${inspect.task.report.voltage:±800kv}") |
|
|
|
private String voltage; |
|
|
|
|
|
|
|
@Value("${inspect.task.report.all:0}") |
|
|
|
private String exportReportFlag; |
|
|
|
|
|
|
|
private final PatrolResultMapper patrolResultMapper; |
|
|
|
private static final Set<String> validAlgTypes = new HashSet<>(Arrays.asList( |
|
|
|
AlgConstants.METER, |
|
|
|
AlgConstants.XB, |
|
|
|
AlgConstants.INFRA_1800, |
|
|
|
AlgConstants.INFRA_YU3, |
|
|
|
AlgConstants.INFRA_CAMERA, |
|
|
|
AlgConstants.INFRA_CAMERA_REVERSE, |
|
|
|
AlgConstants.INFRARED, |
|
|
|
AlgConstants.INFRARED2, |
|
|
|
AlgConstants.GIS_METER_2, |
|
|
|
AlgConstants.GIS_METER |
|
|
|
)); |
|
|
|
final |
|
|
|
PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper; |
|
|
|
private final PatrolResultMapper patrolResultMapper; |
|
|
|
private final PatrolTaskResultMainMapper patrolTaskResultMainMapper; |
|
|
|
private final PatrolTaskStatusMapper patrolTaskStatusMapper; |
|
|
|
private final PatrolTaskMapper patrolTaskMapper; |
|
|
|
@ -69,20 +76,15 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
private final InspectionReportImgMapper inspectionReportImgMapper; |
|
|
|
private final InspectionReportDataMapper inspectionReportDataMapper; |
|
|
|
private final ResultAnalysisMapper resultAnalysisMapper; |
|
|
|
|
|
|
|
private final FeignBasedataAreaService feignBasedataAreaService; |
|
|
|
|
|
|
|
@Value("${inspect.task.report.voltage:±800kv}") |
|
|
|
private String voltage; |
|
|
|
@Value("${inspect.task.report.all:0}") |
|
|
|
private String exportReportFlag; |
|
|
|
@Autowired |
|
|
|
private MessageUtils messageUtils; |
|
|
|
|
|
|
|
private static final Set<String> validAlgTypes = new HashSet<>(Arrays.asList( |
|
|
|
AlgConstants.METER, |
|
|
|
AlgConstants.XB, |
|
|
|
AlgConstants.INFRA_1800, |
|
|
|
AlgConstants.INFRA_YU3, |
|
|
|
AlgConstants.INFRA_CAMERA, |
|
|
|
AlgConstants.INFRA_CAMERA_REVERSE |
|
|
|
));; |
|
|
|
@Resource |
|
|
|
private ResultAnalysisUtils resultAnalysisUtils; |
|
|
|
|
|
|
|
public PatrolResultServiceImpl(PatrolResultMapper patrolResultMapper, PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper, PatrolTaskResultMainMapper patrolTaskResultMainMapper, PatrolTaskStatusMapper patrolTaskStatusMapper, PatrolTaskMapper patrolTaskMapper, InspectionReportMapper inspectionReportMapper, InspectionReportImgMapper inspectionReportImgMapper, InspectionReportDataMapper inspectionReportDataMapper, ResultAnalysisMapper resultAnalysisMapper, FeignBasedataAreaService feignBasedataAreaService) { |
|
|
|
this.patrolResultMapper = patrolResultMapper; |
|
|
|
@ -130,11 +132,21 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
return patrolResultMapper.selectPatrolDataResultByTaskCode(patrolResult); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<PatrolData> selectPatrolDataResultByTaskCodeV2(ResultAnalysis resultAnalysis) { |
|
|
|
return this.patrolResultMapper.selectPatrolDataResultByTaskCodeV2(resultAnalysis); |
|
|
|
PatrolTaskStatus patrolTaskStatus = patrolTaskStatusMapper.selectPatrolTaskStatusByTaskPatrolledId(resultAnalysis.getTaskPatrolId()); |
|
|
|
if (patrolTaskStatus != null) { |
|
|
|
if (patrolTaskStatus.getTaskType().equals(TaskType.MAIN.getCode())) { |
|
|
|
List<String> taskPatrolIds = patrolTaskStatus.getChildren().stream().map(PatrolTaskStatus::getTaskPatrolledId).collect(Collectors.toList()); |
|
|
|
resultAnalysis.setTaskPatrolIds(taskPatrolIds); |
|
|
|
} else { |
|
|
|
resultAnalysis.setTaskPatrolIds(Collections.singletonList(patrolTaskStatus.getTaskPatrolledId())); |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("---------------[TASK] query resultAnalysis {}", resultAnalysis); |
|
|
|
return this.patrolResultMapper.selectPatrolDataResultByTaskCodeV3(resultAnalysis); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<PatrolData> selectPatrolDataResultByTaskCodeList(PatrolTaskStatus patrolTaskStatus) { |
|
|
|
return patrolResultMapper.selectPatrolDataResultByTaskCodeList(patrolTaskStatus); |
|
|
|
} |
|
|
|
@ -366,7 +378,6 @@ 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(); |
|
|
|
@ -504,6 +515,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public List<Long> saveReportShaoxing(PatrolTaskResultMain resultMain, List<Long> lineIds, List<PatrolResult> resultList) { |
|
|
|
log.info("saveReportShaoxing PatrolTaskResultMain:{},lineIds:{},resultList:{} ", resultMain, lineIds, resultList); |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
List<Long> reportIds = new ArrayList<>(); |
|
|
|
// 获取站信息 |
|
|
|
@ -535,7 +547,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
|
|
|
|
List<String> taskNames = resultList.stream().map(PatrolResult::getTaskName).distinct().collect(Collectors.toList()); |
|
|
|
String taskName = StringUtils.join(taskNames, ","); |
|
|
|
boolean isMultipleTasks = CollectionUtils.isNotEmpty(taskPatrolledIds) && taskPatrolledIds.size() > 1; |
|
|
|
boolean isMultipleTasks = CollectionUtils.isNotEmpty(lineIds) && lineIds.size() > 1; |
|
|
|
if (isMultipleTasks) { |
|
|
|
// 说明多个任务合并,任务名称修改为巡视日期-巡视报告 例如:2026年3月23日-巡视报告 |
|
|
|
Date date = CollectionUtils.isNotEmpty(startTimes) ? startTimes.get(0) : new Date(); |
|
|
|
@ -557,10 +569,16 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); |
|
|
|
// 分组,按点位ID和算法类型进行分组 |
|
|
|
groupKeyListMap = patrolResultRefs.stream().collect(Collectors.groupingBy(item -> new GroupKey(item.getDeviceId(), item.getAlgType(), item.getTaskPatrolledId()))); |
|
|
|
groupKeyListMap.forEach((key, value) -> { |
|
|
|
for (Map.Entry<GroupKey, List<PatrolResultRef>> entry : groupKeyListMap.entrySet()) { |
|
|
|
GroupKey key = entry.getKey(); |
|
|
|
List<PatrolResultRef> value = entry.getValue(); |
|
|
|
PatrolResultRef patrolResultRef = new PatrolResultRef(); |
|
|
|
patrolResultRef.setDeviceId(key.objectId); |
|
|
|
patrolResultRef.setAlgType(key.algType); |
|
|
|
// 纠偏算法不归档 |
|
|
|
if (AlgConstants.CORRECTION.equals(key.algType)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
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) { |
|
|
|
@ -584,7 +602,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
patrolResultRef.setAlgName(value.get(0).getAlgName()); |
|
|
|
patrolResultRef.setResultType("0"); |
|
|
|
resultRefs.add(patrolResultRef); |
|
|
|
}); |
|
|
|
} |
|
|
|
patrolResultRefs = resultRefs; |
|
|
|
startTime = PrintUtil.useTime("导出报告:筛选缺陷数据", startTime); |
|
|
|
} else { |
|
|
|
@ -594,6 +612,10 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
List<PatrolResultRef> value = entry.getValue(); |
|
|
|
GroupKey key = entry.getKey(); |
|
|
|
String algType = key.algType; |
|
|
|
// 纠偏算法不归档 |
|
|
|
if (AlgConstants.CORRECTION.equals(algType)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
List<PatrolResultRef> filterResults = value.stream().filter(item -> "1".equals(item.getFilter())).collect(Collectors.toList()); |
|
|
|
List<PatrolResultRef> AIResults = value.stream().filter(item -> "0".equals(item.getFilter())).collect(Collectors.toList()); |
|
|
|
PatrolResultRef filterResult = filterResults.isEmpty() ? null : filterResults.get(0); |
|
|
|
@ -713,11 +735,13 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
resultMain.setCheckTime(new Date()); |
|
|
|
resultMain.setFileStatus("1"); |
|
|
|
String mainId = String.valueOf(resultMain.getLineId()); |
|
|
|
|
|
|
|
// 查询当前的结果信息 |
|
|
|
PatrolResult patrolResult = resultList.stream().filter(item -> mainId.equals(item.getMainId())).findFirst().orElse(null); |
|
|
|
assert patrolResult != null; |
|
|
|
String taskCode = patrolResult.getTaskCode(); |
|
|
|
String taskPatrolId = patrolResult.getTaskPatrolledId(); |
|
|
|
PatrolTaskResultMain main = patrolTaskResultMainMapper.selectPatrolTaskResultMainByLineId(lineId); |
|
|
|
String taskPatrolId = main.getTaskPatrolledId(); |
|
|
|
if (StringUtils.isEmpty(taskPatrolId)) { |
|
|
|
throw new ServiceException("LACK PLAN ID: " + mainId); |
|
|
|
} else { |
|
|
|
@ -750,7 +774,8 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
report.setFilter("0"); |
|
|
|
report.setStationType(stationType); |
|
|
|
inspectionReportMapper.insertInspectionReport(report); |
|
|
|
batchInsertReportData_shaoxing(String.valueOf(report.getLineId()), patrolResultRefs, basePointAreaInfoList, taskPatrolledIds); |
|
|
|
// 为每个报告生成数据 |
|
|
|
batchInsertReportData_shaoxing(String.valueOf(report.getLineId()), patrolResultRefs, basePointAreaInfoList, lineIds); |
|
|
|
reportIds.add(report.getLineId()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -922,7 +947,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
if ("0".equals(exportReportFlag) && aiQxNum == 0 && csQxNum == 0) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Map<String,PatrolResultRef> keyPatrolResultRef = new HashMap<>(); |
|
|
|
Map<String, PatrolResultRef> keyPatrolResultRef = new HashMap<>(); |
|
|
|
List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(lineIds, "0"); |
|
|
|
List<PatrolResultRef> patrolResultRefsFilter = patrolResultMapper.selectResultRefByLineIds(lineIds, "1"); |
|
|
|
for (PatrolResultRef AIRef : patrolResultRefs) { |
|
|
|
@ -940,7 +965,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(resultMain.getTaskResult()); |
|
|
|
@ -973,18 +998,18 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
String AiNum = statisticsAnalyseNumV2(mainId, "0"); |
|
|
|
String[] nums = new String[]{AiNum, filterNum}; |
|
|
|
startTime = PrintUtil.useTime("统计分析数据", startTime); |
|
|
|
if(resultList.isEmpty()) { |
|
|
|
if (resultList.isEmpty()) { |
|
|
|
throw new ServiceException("缺少巡检结果:" + mainId); |
|
|
|
} else { |
|
|
|
PatrolResult patrolResult = resultList.get(0); |
|
|
|
String taskCode = patrolResult.getTaskCode(); |
|
|
|
String taskPatrolId = patrolResult.getTaskPatrolledId(); |
|
|
|
if(StringUtils.isEmpty(taskPatrolId)) { |
|
|
|
if (StringUtils.isEmpty(taskPatrolId)) { |
|
|
|
throw new ServiceException("缺少执行ID:" + mainId); |
|
|
|
} else { |
|
|
|
List<PatrolTaskStatus> taskStatuses = this.patrolTaskStatusMapper.selectPatrolTaskStatusList(new PatrolTaskStatus(taskPatrolId)); |
|
|
|
startTime = PrintUtil.useTime("查询状态数据", startTime); |
|
|
|
if(taskStatuses.isEmpty()) { |
|
|
|
if (taskStatuses.isEmpty()) { |
|
|
|
throw new ServiceException("缺少状态数据:" + mainId); |
|
|
|
} else { |
|
|
|
PatrolTaskStatus taskStatus = taskStatuses.get(0); |
|
|
|
@ -992,7 +1017,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
patrolTask.setTaskCode(taskCode); |
|
|
|
List<PatrolTask> list = this.patrolTaskMapper.selectPatrolTaskList(patrolTask); |
|
|
|
startTime = PrintUtil.useTime("查询任务计划", startTime); |
|
|
|
if(list.isEmpty()) { |
|
|
|
if (list.isEmpty()) { |
|
|
|
throw new ServiceException("任务计划丢失:" + taskCode); |
|
|
|
} else { |
|
|
|
PatrolTask task = list.get(0); |
|
|
|
@ -1005,31 +1030,31 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
ResultAnalysis ras = resultAnalysisMapper.selectTaskAbnormalData(resultAnalysis); |
|
|
|
int ii = 0; |
|
|
|
int iii = 0; |
|
|
|
if(0 == ras.getCsQxNum()) { |
|
|
|
if (0 == ras.getCsQxNum()) { |
|
|
|
ras.setFilter("0"); |
|
|
|
ii = 0; |
|
|
|
iii = 0; |
|
|
|
} |
|
|
|
|
|
|
|
if(0 == ras.getAiQxNum()) { |
|
|
|
if (0 == ras.getAiQxNum()) { |
|
|
|
ras.setFilter("1"); |
|
|
|
ii = 0; |
|
|
|
iii = 1; |
|
|
|
} |
|
|
|
|
|
|
|
if(0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) { |
|
|
|
if (0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) { |
|
|
|
ras.setFilter("2"); |
|
|
|
ii = 2; |
|
|
|
} |
|
|
|
Long[] ids = new Long[ii]; |
|
|
|
List list1 = new ArrayList<>(); |
|
|
|
|
|
|
|
for(int i = 0; i < 2; ++i) { |
|
|
|
if(0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) { |
|
|
|
for (int i = 0; i < 2; ++i) { |
|
|
|
if (0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) { |
|
|
|
iii = i; |
|
|
|
} |
|
|
|
|
|
|
|
if(i != Integer.parseInt(ras.getFilter())) { |
|
|
|
if (i != Integer.parseInt(ras.getFilter())) { |
|
|
|
InspectionReport report = new InspectionReport(); |
|
|
|
resetReport(report, nums[iii], mainId, task, taskStatus); |
|
|
|
report.setFilter(iii + ""); |
|
|
|
@ -1056,6 +1081,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void resetReport(InspectionReport report, String analyseNum, String mainId, PatrolTask task, PatrolTaskStatus taskStatus) { |
|
|
|
report.setPatrolStatistics(analyseNum); |
|
|
|
//report.setInspectionDate(task.getCreateTime()); |
|
|
|
@ -1071,7 +1097,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
// List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineId(mainId); |
|
|
|
// List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(mainIds, filter); |
|
|
|
if ("0".equals(exportReportFlag)) { |
|
|
|
List <PatrolResultRef> resultRefs = new ArrayList<>(); |
|
|
|
List<PatrolResultRef> resultRefs = new ArrayList<>(); |
|
|
|
// 只导出缺陷 |
|
|
|
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); |
|
|
|
// 分组,按点位ID和算法类型进行分组 |
|
|
|
@ -1148,7 +1174,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
reportData.setAlgName(patrolResultRef.getAlgName()); |
|
|
|
String threshold = patrolResultRef.getThreshold(); |
|
|
|
if(StringUtils.isBlank(threshold)) { |
|
|
|
if (StringUtils.isBlank(threshold)) { |
|
|
|
threshold = ""; |
|
|
|
} |
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { |
|
|
|
@ -1182,7 +1208,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
// ++okNum; |
|
|
|
// } |
|
|
|
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); |
|
|
|
if(resultType == null) { |
|
|
|
if (resultType == null) { |
|
|
|
continue; |
|
|
|
} else if (resultType.equals("0")) { |
|
|
|
reportData.setPointStatus(messageUtils.get("缺陷")); |
|
|
|
@ -1242,11 +1268,11 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void batchInsertReportData_shaoxing(String reportId, List<PatrolResultRef> patrolResultRefs, List<BasePointAreaInfo> basePointAreaInfoList, List<String> taskPatrolledIds) { |
|
|
|
Map<String, Map<String, Long>> taskCounterMap = new HashMap<>(); |
|
|
|
public void batchInsertReportData_shaoxing(String reportId, List<PatrolResultRef> patrolResultRefs, List<BasePointAreaInfo> basePointAreaInfoList, List<Long> lineIds) { |
|
|
|
Map<Long, Map<String, Long>> taskCounterMap = new HashMap<>(); |
|
|
|
|
|
|
|
// 为每个任务初始化计数器 |
|
|
|
for (String item : taskPatrolledIds) { |
|
|
|
for (Long item : lineIds) { |
|
|
|
Map<String, Long> counter = new HashMap<>(); |
|
|
|
counter.put("defect", 0L); |
|
|
|
counter.put("ok", 0L); |
|
|
|
@ -1268,6 +1294,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
// 获取该结果所属的任务名 |
|
|
|
String resultTaskName = patrolResultRef.getTaskName(); |
|
|
|
String taskPatrolledId = patrolResultRef.getTaskPatrolledId(); |
|
|
|
Long mainId = patrolResultRef.getMainId(); |
|
|
|
BasePointAreaInfo basePointAreaInfo; |
|
|
|
try { |
|
|
|
basePointAreaInfo = basePointAreaInfoList.stream().filter((item) -> item != null && patrolResultRef.getDeviceId().equals(item.getDeviceId())).findFirst().get(); |
|
|
|
@ -1287,6 +1314,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
reportData.setAcquisitionTime(DateUtils.parse(DateUtils.yyyyMMddHHmmss2, patrolResultRef.getTime())); |
|
|
|
reportData.setTaskName(resultTaskName); |
|
|
|
reportData.setTaskPatrolledId(taskPatrolledId); |
|
|
|
reportData.setTaskResultId(String.valueOf(mainId)); |
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && validAlgTypes.contains(patrolResultRef.getAlgType())) { |
|
|
|
reportData.setInspectionResults(patrolResultRef.getValue()); |
|
|
|
} else { |
|
|
|
@ -1294,7 +1322,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
reportData.setAlgName(patrolResultRef.getAlgName()); |
|
|
|
String threshold = patrolResultRef.getThreshold(); |
|
|
|
if(StringUtils.isBlank(threshold)) { |
|
|
|
if (StringUtils.isBlank(threshold)) { |
|
|
|
threshold = ""; |
|
|
|
} |
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { |
|
|
|
@ -1309,15 +1337,19 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
reportData.setInspectionResults(patrolResultRef.getValue()); |
|
|
|
} |
|
|
|
|
|
|
|
// 给读数增加单位 |
|
|
|
String resValue = resultAnalysisUtils.addUnit2Value(reportData.getInspectionResults(), patrolResultRef.getAlgType(), patrolResultRef.getUnit()); |
|
|
|
reportData.setInspectionResults(resValue); |
|
|
|
|
|
|
|
String pointStatus = patrolResultRef.getPointStatus(); |
|
|
|
String resultType = patrolResultRef.getResultType(); |
|
|
|
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); |
|
|
|
if(resultType == null) { |
|
|
|
if (resultType == null) { |
|
|
|
continue; |
|
|
|
} else if (resultType.equals("0")) { |
|
|
|
reportData.setPointStatus(messageUtils.get("缺陷")); |
|
|
|
// 按任务统计异常编号 |
|
|
|
Map<String, Long> counter = taskCounterMap.get(taskPatrolledId); |
|
|
|
Map<String, Long> counter = taskCounterMap.get(mainId); |
|
|
|
if (counter != null) { |
|
|
|
counter.put("defect", counter.get("defect") + 1); |
|
|
|
reportData.setCode(counter.get("defect")); |
|
|
|
@ -1328,7 +1360,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} else if (resultType.equals("1")) { |
|
|
|
reportData.setPointStatus(messageUtils.get("正常")); |
|
|
|
// 按任务统计异常编号 |
|
|
|
Map<String, Long> counter = taskCounterMap.get(taskPatrolledId); |
|
|
|
Map<String, Long> counter = taskCounterMap.get(mainId); |
|
|
|
if (counter != null) { |
|
|
|
counter.put("ok", counter.get("ok") + 1); |
|
|
|
reportData.setCode(counter.get("ok")); |
|
|
|
@ -1339,7 +1371,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} else { |
|
|
|
reportData.setPointStatus(messageUtils.get("异常")); |
|
|
|
// 按任务统计异常编号 |
|
|
|
Map<String, Long> counter = taskCounterMap.get(taskPatrolledId); |
|
|
|
Map<String, Long> counter = taskCounterMap.get(mainId); |
|
|
|
if (counter != null) { |
|
|
|
counter.put("fail", counter.get("fail") + 1); |
|
|
|
reportData.setCode(counter.get("fail")); |
|
|
|
@ -1394,7 +1426,7 @@ 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<>(); |
|
|
|
List<PatrolResultRef> resultRefs = new ArrayList<>(); |
|
|
|
// 只导出缺陷 |
|
|
|
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); |
|
|
|
// 分组,按点位ID和算法类型进行分组 |
|
|
|
@ -1424,6 +1456,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
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.setAlgType(value.get(0).getAlgType()); |
|
|
|
patrolResultRef.setResultType("0"); |
|
|
|
resultRefs.add(patrolResultRef); |
|
|
|
}); |
|
|
|
@ -1466,7 +1499,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
reportData.setAlgName(patrolResultRef.getAlgName()); |
|
|
|
String threshold = patrolResultRef.getThreshold(); |
|
|
|
if(StringUtils.isBlank(threshold)) { |
|
|
|
if (StringUtils.isBlank(threshold)) { |
|
|
|
threshold = ""; |
|
|
|
} |
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { |
|
|
|
@ -1483,7 +1516,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
|
|
|
|
String resultType = patrolResultRef.getResultType(); |
|
|
|
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); |
|
|
|
if(resultType == null) { |
|
|
|
if (resultType == null) { |
|
|
|
continue; |
|
|
|
} else if (resultType.equals("0")) { |
|
|
|
reportData.setPointStatus(messageUtils.get("缺陷")); |
|
|
|
@ -1559,7 +1592,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
List<InspectionReportImg> reportImages = new ArrayList<>(); |
|
|
|
|
|
|
|
int i; |
|
|
|
for(i = 0; i < patrolResultRefs.size(); ++i) { |
|
|
|
for (i = 0; i < patrolResultRefs.size(); ++i) { |
|
|
|
PatrolResultRef ref = patrolResultRefs.get(i); |
|
|
|
ref.setAlgName(algInfos.stream().filter((alg) -> { |
|
|
|
return alg.getAlgSubtypeCode().equals(ref.getAlgType()); |
|
|
|
@ -1730,7 +1763,6 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
return String.format(messageUtils.get("缺陷总数:%d个"), confirmNum); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String statisticsAnalyseNumLingZhou(List<Long> lineIds) { |
|
|
|
int okNum = 0; |
|
|
|
int failNum = 0; |
|
|
|
@ -1777,7 +1809,6 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String statisticsAnalyseNumShaoxing(List<Long> lineIds) { |
|
|
|
int okNum = 0; |
|
|
|
int failNum = 0; |
|
|
|
@ -1850,7 +1881,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
|
|
|
|
int totalNum = analyses.size(); |
|
|
|
int lastNum = totalNum - failNum - confirmNum; |
|
|
|
if(lastNum != okNum) { |
|
|
|
if (lastNum != okNum) { |
|
|
|
; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1928,7 +1959,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
report.setStationType(stationType); |
|
|
|
Map<GroupKey, List<PatrolResultRef>> groupKeyListMap; |
|
|
|
if ("0".equals(exportReportFlag)) { |
|
|
|
List <PatrolResultRef> resultRefs = new ArrayList<>(); |
|
|
|
List<PatrolResultRef> resultRefs = new ArrayList<>(); |
|
|
|
// 只导出缺陷 |
|
|
|
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); |
|
|
|
// 分组,按点位ID和算法类型进行分组 |
|
|
|
@ -2093,7 +2124,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
reportData.setAlgName(patrolResultRef.getAlgName()); |
|
|
|
String threshold = patrolResultRef.getThreshold(); |
|
|
|
if(StringUtils.isBlank(threshold)) { |
|
|
|
if (StringUtils.isBlank(threshold)) { |
|
|
|
threshold = ""; |
|
|
|
} |
|
|
|
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { |
|
|
|
@ -2110,7 +2141,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
|
|
|
|
String resultType = patrolResultRef.getResultType(); |
|
|
|
// log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); |
|
|
|
if(resultType == null) { |
|
|
|
if (resultType == null) { |
|
|
|
continue; |
|
|
|
} else if (resultType.equals("0")) { |
|
|
|
reportData.setPointStatus(messageUtils.get("缺陷")); |
|
|
|
@ -2155,6 +2186,32 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
return report; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<AlgInfo> selectPointAlgInfo(String patrolPointId) { |
|
|
|
return patrolResultMapper.selectPointAlgInfo(patrolPointId); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<AlgInfo> selectAlgInfoByCode(String codes) { |
|
|
|
return patrolResultMapper.selectAlgInfoByCode(codes); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据以下条件返回任务的全部或某设备类型的点位及其算法 |
|
|
|
* @param sendCode 任务编码 |
|
|
|
* @param specifiedAlg 设备唯一标识 |
|
|
|
* @return 任务指定算法 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<String> selectAlgList(String taskCode, String sendCode, String specifiedAlg) { |
|
|
|
String devType = "摄像头".equals(sendCode) ? "2" : null; |
|
|
|
List<String> algList = patrolResultMapper.selectAlgList(taskCode, sendCode, devType); |
|
|
|
if (StringUtils.isNotEmpty(specifiedAlg)) { |
|
|
|
return algList.stream().map(item -> specifiedAlg).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return algList; |
|
|
|
} |
|
|
|
|
|
|
|
private PatrolResultRef mergePatrolResultRef(PatrolResultRef filterResult, PatrolResultRef AIResult, String resultType) { |
|
|
|
PatrolResultRef merged = new PatrolResultRef(); |
|
|
|
merged.setDeviceId(filterResult.getDeviceId()); |
|
|
|
@ -2200,6 +2257,15 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
public int hashCode() { |
|
|
|
return Objects.hash(objectId, algType, taskPatrolled); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String toString() { |
|
|
|
return "GroupKey{" + |
|
|
|
"objectId='" + objectId + '\'' + |
|
|
|
", algType='" + algType + '\'' + |
|
|
|
", taskPatrolled='" + taskPatrolled + '\'' + |
|
|
|
'}'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|