|
|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.inspect.partrolresult.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.inspect.analysis.domain.AlgValue; |
|
|
|
import com.inspect.analysis.domain.AnalyseResPoint; |
|
|
|
@ -11,6 +12,8 @@ import com.inspect.base.core.constant.AlgConstants; |
|
|
|
import com.inspect.base.core.exception.ServiceException; |
|
|
|
import com.inspect.base.core.utils.DateUtils; |
|
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
|
import com.inspect.base.core.web.domain.AjaxResult; |
|
|
|
import com.inspect.fegin.FeignBasedataAreaService; |
|
|
|
import com.inspect.img.domain.InspectionReportImg; |
|
|
|
import com.inspect.img.mapper.InspectionReportImgMapper; |
|
|
|
import com.inspect.insreport.domain.InspectionReport; |
|
|
|
@ -27,6 +30,7 @@ import com.inspect.patrolresultdefault.mapper.PatrolResultDefaultValueMapper; |
|
|
|
import com.inspect.resultmain.domain.PatrolTaskResultMain; |
|
|
|
import com.inspect.resultmain.mapper.PatrolTaskResultMainMapper; |
|
|
|
import com.inspect.system.base.openDomain.BasedataEqpBookMoMain; |
|
|
|
import com.inspect.system.base.openDomain.PatrolTaskDomain; |
|
|
|
import com.inspect.task.domain.PatrolData; |
|
|
|
import com.inspect.task.domain.PatrolTask; |
|
|
|
import com.inspect.task.mapper.PatrolTaskMapper; |
|
|
|
@ -64,6 +68,8 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
private final InspectionReportDataMapper inspectionReportDataMapper; |
|
|
|
private final ResultAnalysisMapper resultAnalysisMapper; |
|
|
|
|
|
|
|
private final FeignBasedataAreaService feignBasedataAreaService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MessageUtils messageUtils; |
|
|
|
|
|
|
|
@ -76,7 +82,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
AlgConstants.INFRA_CAMERA_REVERSE |
|
|
|
));; |
|
|
|
|
|
|
|
public PatrolResultServiceImpl(PatrolResultMapper patrolResultMapper, PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper, PatrolTaskResultMainMapper patrolTaskResultMainMapper, PatrolTaskStatusMapper patrolTaskStatusMapper, PatrolTaskMapper patrolTaskMapper, InspectionReportMapper inspectionReportMapper, InspectionReportImgMapper inspectionReportImgMapper, InspectionReportDataMapper inspectionReportDataMapper, ResultAnalysisMapper resultAnalysisMapper) { |
|
|
|
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; |
|
|
|
this.patrolResultDefaultvalueMapper = patrolResultDefaultvalueMapper; |
|
|
|
this.patrolTaskResultMainMapper = patrolTaskResultMainMapper; |
|
|
|
@ -86,6 +92,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
this.inspectionReportImgMapper = inspectionReportImgMapper; |
|
|
|
this.inspectionReportDataMapper = inspectionReportDataMapper; |
|
|
|
this.resultAnalysisMapper = resultAnalysisMapper; |
|
|
|
this.feignBasedataAreaService = feignBasedataAreaService; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -337,6 +344,26 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
return saveReportData(resultList, resultMain, lineIds, aiQxNum, csQxNum); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public List<Long> saveReportLingzhou(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()); |
|
|
|
for (Long lineId : lineIds) { |
|
|
|
resultMain.setLineId(lineId); |
|
|
|
resultMain.setCheckTime(new Date()); |
|
|
|
resultMain.setFileStatus("1"); |
|
|
|
this.patrolTaskResultMainMapper.updatePatrolTaskResultMain(resultMain); |
|
|
|
this.patrolResultMapper.updatePatrolResultByMainId(String.valueOf(lineId)); |
|
|
|
reportIds.addAll(saveReportDataLingzhou(resultList, resultMain, lineIds, aiQxNum, csQxNum)); |
|
|
|
} |
|
|
|
|
|
|
|
PrintUtil.useTime("AMENDING DATA", startTime); |
|
|
|
return reportIds; |
|
|
|
// resultMain.setLineId(currentLineId); |
|
|
|
// return saveReportData(resultList, resultMain, lineIds); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public List saveReportV2(PatrolTaskResultMain resultMain, List<PatrolResult> resultList) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
@ -432,6 +459,105 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public List<Long> saveReportDataLingzhou(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()); |
|
|
|
// String filterNum = statisticsAnalyseNumLingZhou(lineIds, "1"); |
|
|
|
String AiNum = statisticsAnalyseNumLingZhou(lineIds, "0"); |
|
|
|
// String[] nums = new String[]{AiNum, filterNum}; |
|
|
|
String[] nums = new String[]{AiNum}; |
|
|
|
startTime = PrintUtil.useTime("STATISTICS ANALYZE DATA", startTime); |
|
|
|
if (resultList.isEmpty()) { |
|
|
|
throw new ServiceException("LACK INSPECT RESULT: " + mainId); |
|
|
|
} else { |
|
|
|
PatrolResult patrolResult = resultList.stream().filter(item -> mainId.equals(item.getMainId())).findFirst().orElse(null); |
|
|
|
assert patrolResult != null; |
|
|
|
String taskCode = patrolResult.getTaskCode(); |
|
|
|
String taskPatrolId = patrolResult.getTaskPatrolledId(); |
|
|
|
List<String> taskNames = resultList.stream().map(PatrolResult::getTaskName).distinct().collect(Collectors.toList()); |
|
|
|
String taskName = StringUtils.join(taskNames, ","); |
|
|
|
if (StringUtils.isEmpty(taskPatrolId)) { |
|
|
|
throw new ServiceException("LACK PLAN ID: " + mainId); |
|
|
|
} else { |
|
|
|
List<PatrolTaskStatus> taskStatuses = this.patrolTaskStatusMapper.selectPatrolTaskStatusList(PatrolTaskStatus.builder().taskPatrolledId(taskPatrolId).build()); |
|
|
|
startTime = PrintUtil.useTime("INQUIRY STATUS", startTime); |
|
|
|
if (taskStatuses.isEmpty()) { |
|
|
|
throw new ServiceException("LACKING STATUS: " + mainId); |
|
|
|
} else { |
|
|
|
PatrolTaskStatus taskStatus = taskStatuses.get(0); |
|
|
|
List<PatrolTask> list = patrolTaskMapper.selectPatrolTaskList(PatrolTask.builder().taskCode(taskCode).build()); |
|
|
|
startTime = PrintUtil.useTime("INQUIRY TASK PLAN", startTime); |
|
|
|
if (list.isEmpty()) { |
|
|
|
throw new ServiceException("TASK PLAN LOST: " + taskCode); |
|
|
|
} else { |
|
|
|
List<Long> reportIds = new ArrayList<>(); |
|
|
|
PatrolTask task = list.get(0); |
|
|
|
// List<InspectionReport> reports = inspectionReportMapper.selectInspectionReportList(new InspectionReport(mainId)); |
|
|
|
// startTime = PrintUtil.useTime("INQUIRY TASK REPORT", startTime); |
|
|
|
// InspectionReport report; |
|
|
|
// if (!reports.isEmpty()) { |
|
|
|
// report = reports.get(0); |
|
|
|
// resetReport(report, analyseNum, mainId, task, taskStatus); |
|
|
|
// inspectionReportMapper.updateInspectionReport(report); |
|
|
|
// PrintUtil.useTime("MODIFY TASK REPORT", startTime); |
|
|
|
// } else { |
|
|
|
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.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); |
|
|
|
} |
|
|
|
for (int i = 0; i < nums.length; i++) { |
|
|
|
if ("0".equals(exportReportFlag) && i == 0 && aiQxNum == 0) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ("0".equals(exportReportFlag) && i == 1 && csQxNum == 0) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(lineIds, String.valueOf(i)); |
|
|
|
if (patrolResultRefs.isEmpty()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
InspectionReport report = new InspectionReport(); |
|
|
|
resetReport(report, nums[i], mainId, task, taskStatus); |
|
|
|
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); |
|
|
|
batchInsertReportData(String.valueOf(report.getLineId()), lineIds, String.valueOf(i), patrolResultRefs); |
|
|
|
PrintUtil.useTime("BATCH INSERT DETAIL", startTime); |
|
|
|
log.info("[ARCHIVE] reportId: {}", report.getLineId()); |
|
|
|
Long lineId = report.getLineId(); |
|
|
|
reportIds.add(lineId); |
|
|
|
} |
|
|
|
// } |
|
|
|
return reportIds; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public List saveReportDataV2(List<PatrolResult> resultList, PatrolTaskResultMain resultMain) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
String mainId = String.valueOf(resultMain.getLineId()); |
|
|
|
@ -867,6 +993,35 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
return String.format(messageUtils.get("缺陷总数:%d个"), totalNum); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String statisticsAnalyseNumLingZhou(List<Long> lineIds, String filter) { |
|
|
|
int okNum = 0; |
|
|
|
int failNum = 0; |
|
|
|
int confirmNum = 0; |
|
|
|
List<ResultAnalysis> analyses = resultAnalysisMapper.selectResultAnalysisListByMainIdsNew(lineIds, filter); |
|
|
|
int totalNum = analyses.size(); |
|
|
|
log.info("lineIds:{},statisticsAnalyseNum analyses:{}", lineIds, analyses); |
|
|
|
for (ResultAnalysis analyse : analyses) { |
|
|
|
String resultType = analyse.getResultType(); |
|
|
|
if (resultType.equals("0")) { |
|
|
|
++confirmNum; |
|
|
|
} else if (resultType.equals("1")) { |
|
|
|
++okNum; |
|
|
|
} else if (resultType.equals("2")) { |
|
|
|
++failNum; |
|
|
|
} |
|
|
|
} |
|
|
|
// |
|
|
|
// int lastNum = totalNum - failNum - confirmNum; |
|
|
|
// if (lastNum != okNum) { |
|
|
|
// okNum = lastNum; |
|
|
|
// } |
|
|
|
|
|
|
|
// return String.format("总点位:%d个,已检点位:%d个,未检点位:0个,正常点位:%d个,异常点位:%d个,待人工确认点位:%d个。", totalNum, totalNum, okNum, failNum, confirmNum); |
|
|
|
return String.format(messageUtils.get("本次任务巡视总点位:%d个,已检点位:%d个,未检点位:0个,正常点位:%d个,异常点位:%d个,缺陷点位:%d个。"), totalNum, totalNum, okNum, failNum, confirmNum); |
|
|
|
// return String.format(messageUtils.get("缺陷总数:%d个"), totalNum); |
|
|
|
} |
|
|
|
|
|
|
|
public String statisticsAnalyseNumV2(String mainId, String filter) { |
|
|
|
int okNum = 0; |
|
|
|
int failNum = 0; |
|
|
|
|