|
|
|
@ -22,6 +22,8 @@ import com.inspect.insreport.domain.InspectionReport; |
|
|
|
import com.inspect.insreport.mapper.InspectionReportMapper; |
|
|
|
import com.inspect.insreportdata.domain.InspectionReportData; |
|
|
|
import com.inspect.insreportdata.mapper.InspectionReportDataMapper; |
|
|
|
import com.inspect.insreporttask.domain.InspectionReportTask; |
|
|
|
import com.inspect.insreporttask.mapper.InspectionReportTaskMapper; |
|
|
|
import com.inspect.message.MessageUtils; |
|
|
|
import com.inspect.partrolresult.domain.*; |
|
|
|
import com.inspect.partrolresult.mapper.PatrolResultMapper; |
|
|
|
@ -76,6 +78,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
private final InspectionReportMapper inspectionReportMapper; |
|
|
|
private final InspectionReportImgMapper inspectionReportImgMapper; |
|
|
|
private final InspectionReportDataMapper inspectionReportDataMapper; |
|
|
|
private final InspectionReportTaskMapper inspectionReportTaskMapper; |
|
|
|
private final ResultAnalysisMapper resultAnalysisMapper; |
|
|
|
private final FeignBasedataAreaService feignBasedataAreaService; |
|
|
|
@Value("${inspect.task.report.voltage:±800kv}") |
|
|
|
@ -87,7 +90,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
@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) { |
|
|
|
public PatrolResultServiceImpl(PatrolResultMapper patrolResultMapper, PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper, PatrolTaskResultMainMapper patrolTaskResultMainMapper, PatrolTaskStatusMapper patrolTaskStatusMapper, PatrolTaskMapper patrolTaskMapper, InspectionReportMapper inspectionReportMapper, InspectionReportImgMapper inspectionReportImgMapper, InspectionReportDataMapper inspectionReportDataMapper, InspectionReportTaskMapper inspectionReportTaskMapper, ResultAnalysisMapper resultAnalysisMapper, FeignBasedataAreaService feignBasedataAreaService) { |
|
|
|
this.patrolResultMapper = patrolResultMapper; |
|
|
|
this.patrolResultDefaultvalueMapper = patrolResultDefaultvalueMapper; |
|
|
|
this.patrolTaskResultMainMapper = patrolTaskResultMainMapper; |
|
|
|
@ -96,6 +99,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
this.inspectionReportMapper = inspectionReportMapper; |
|
|
|
this.inspectionReportImgMapper = inspectionReportImgMapper; |
|
|
|
this.inspectionReportDataMapper = inspectionReportDataMapper; |
|
|
|
this.inspectionReportTaskMapper = inspectionReportTaskMapper; |
|
|
|
this.resultAnalysisMapper = resultAnalysisMapper; |
|
|
|
this.feignBasedataAreaService = feignBasedataAreaService; |
|
|
|
} |
|
|
|
@ -743,59 +747,81 @@ public class PatrolResultServiceImpl implements IPatrolResultService { |
|
|
|
} else { |
|
|
|
patrolStatistics = String.format(messageUtils.get("本次任务巡视总结果数量:%d个,正常结果数量:%d个,缺陷结果数量:%d个"), total, okNum, defectNum); |
|
|
|
} |
|
|
|
for (Long lineId : lineIds) { |
|
|
|
// 一次归档(单个任务 / 多个任务合并归档)只生成一份报告: |
|
|
|
// 1) 报告头(inspection_report)只插一条,明细数据(inspection_report_data)覆盖本次归档的全部任务; |
|
|
|
// 2) 被归档的每个任务执行都通过 inspection_report_task 关联到这一条报告, |
|
|
|
// 任务粒度与明细行中的 task_patrolled_id / task_name 保持一致, |
|
|
|
// 便于从任意任务/进度入口定位到这条合并报告。 |
|
|
|
List<InspectionReportTask> reportTasks = new ArrayList<>(); |
|
|
|
Long reportLineId = null; |
|
|
|
for (int idx = 0; idx < lineIds.size(); idx++) { |
|
|
|
Long lineId = lineIds.get(idx); |
|
|
|
resultMain.setLineId(lineId); |
|
|
|
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(); |
|
|
|
PatrolTaskResultMain main = patrolTaskResultMainMapper.selectPatrolTaskResultMainByLineId(lineId); |
|
|
|
String taskPatrolId = main.getTaskPatrolledId(); |
|
|
|
if (StringUtils.isEmpty(taskPatrolId)) { |
|
|
|
throw new ServiceException("LACK PLAN ID: " + mainId); |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
if (reportLineId == null) { |
|
|
|
// 以本次归档第一个执行任务的信息生成报告头 |
|
|
|
PatrolResult patrolResult = resultList.stream().filter(item -> mainId.equals(item.getMainId())).findFirst().orElse(null); |
|
|
|
assert patrolResult != null; |
|
|
|
String taskCode = patrolResult.getTaskCode(); |
|
|
|
List<PatrolTaskStatus> taskStatuses = this.patrolTaskStatusMapper.selectPatrolTaskStatusList(PatrolTaskStatus.builder().taskPatrolledId(taskPatrolId).build()); |
|
|
|
if (taskStatuses.isEmpty()) { |
|
|
|
throw new ServiceException("LACKING STATUS: " + mainId); |
|
|
|
} |
|
|
|
List<PatrolTask> list = patrolTaskMapper.selectPatrolTaskList(PatrolTask.builder().taskCode(taskCode).build()); |
|
|
|
PatrolTask task = new PatrolTask(); |
|
|
|
if (list.isEmpty()) { |
|
|
|
log.error("TASK PLAN LOST: " + taskCode); |
|
|
|
} else { |
|
|
|
List<PatrolTask> list = patrolTaskMapper.selectPatrolTaskList(PatrolTask.builder().taskCode(taskCode).build()); |
|
|
|
PatrolTask task = new PatrolTask(); |
|
|
|
if (list.isEmpty()) { |
|
|
|
log.error("TASK PLAN LOST: " + taskCode); |
|
|
|
} else { |
|
|
|
task = list.get(0); |
|
|
|
} |
|
|
|
InspectionReport report = new InspectionReport(); |
|
|
|
report.setPatrolStatistics(patrolStatistics); |
|
|
|
report.setInspectionDate(new Date()); |
|
|
|
report.setTaskResultId(mainId); |
|
|
|
report.setInspectionStartTime(startTimes.get(0)); |
|
|
|
report.setInspectionEndTime(DateUtils.parseDate(endTimes.get(endTimes.size() - 1))); |
|
|
|
report.setTaskId(task.getTaskId() == null ? "" : 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("0"); |
|
|
|
report.setStationType(stationType); |
|
|
|
// 位置 = 省份 + 地市(如 四川省成都市) |
|
|
|
report.setLocation(buildLocation(provinceName, cityName)); |
|
|
|
inspectionReportMapper.insertInspectionReport(report); |
|
|
|
// 为每个报告生成数据 |
|
|
|
batchInsertReportData_shaoxing(String.valueOf(report.getLineId()), patrolResultRefs, basePointAreaInfoList, lineIds); |
|
|
|
reportIds.add(report.getLineId()); |
|
|
|
task = list.get(0); |
|
|
|
} |
|
|
|
InspectionReport report = new InspectionReport(); |
|
|
|
report.setPatrolStatistics(patrolStatistics); |
|
|
|
report.setInspectionDate(startTimes.get(0)); |
|
|
|
report.setTaskResultId(mainId); |
|
|
|
report.setInspectionStartTime(startTimes.get(0)); |
|
|
|
report.setInspectionEndTime(DateUtils.parseDate(endTimes.get(endTimes.size() - 1))); |
|
|
|
report.setTaskId(task.getTaskId() == null ? "" : 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("0"); |
|
|
|
report.setStationType(stationType); |
|
|
|
// 位置 = 省份 + 地市(如 四川省成都市) |
|
|
|
report.setLocation(buildLocation(provinceName, cityName)); |
|
|
|
inspectionReportMapper.insertInspectionReport(report); |
|
|
|
// 为这一份报告生成明细数据(覆盖本次归档的所有任务) |
|
|
|
batchInsertReportData_shaoxing(String.valueOf(report.getLineId()), patrolResultRefs, basePointAreaInfoList, lineIds); |
|
|
|
reportLineId = report.getLineId(); |
|
|
|
reportIds.add(reportLineId); |
|
|
|
} |
|
|
|
this.patrolTaskResultMainMapper.updatePatrolTaskResultMain(resultMain); |
|
|
|
this.patrolResultMapper.updatePatrolResultByMainId(String.valueOf(lineId)); |
|
|
|
|
|
|
|
// 记录 任务-报告 关联(同一份报告下每个任务一条) |
|
|
|
InspectionReportTask reportTask = new InspectionReportTask(); |
|
|
|
reportTask.setReportLineId(reportLineId); |
|
|
|
reportTask.setTaskResultLineId(lineId); |
|
|
|
reportTask.setTaskPatrolledId(taskPatrolId); |
|
|
|
reportTask.setTaskName(main.getTaskName()); |
|
|
|
reportTask.setCreateTime(new Date()); |
|
|
|
reportTasks.add(reportTask); |
|
|
|
} |
|
|
|
if (!reportTasks.isEmpty()) { |
|
|
|
inspectionReportTaskMapper.batchInsertInspectionReportTask(reportTasks); |
|
|
|
} |
|
|
|
startTime = PrintUtil.useTime("导出报告:全部数据入库", startTime); |
|
|
|
return reportIds; |
|
|
|
|