Browse Source

巡视归档没有缺陷问题修改

master
WangGuangYuan 4 months ago
parent
commit
a1be8199d6
3 changed files with 38 additions and 11 deletions
  1. +1
    -1
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/IPatrolResultService.java
  2. +16
    -6
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java
  3. +21
    -4
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java

+ 1
- 1
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/IPatrolResultService.java View File

@ -81,7 +81,7 @@ public interface IPatrolResultService {
List<ResultValue> select6FsResultValue(PatrolResult patrolResult);
List<Long> saveReport(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList);
List<Long> saveReport(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList, int aiQxNum, int csQxNum);
List saveReportV2(PatrolTaskResultMain patrolTaskResultMain, List<PatrolResult> patrolResultList);


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

@ -322,7 +322,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
}
@Transactional
public List<Long> saveReport(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList) {
public List<Long> saveReport(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList, int aiQxNum, int csQxNum) {
long startTime = System.currentTimeMillis();
// String mainId = String.valueOf(resultMain.getLineId());
for (Long lineId : lineIds) {
@ -334,7 +334,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
}
PrintUtil.useTime("AMENDING DATA", startTime);
resultMain.setLineId(currentLineId);
return saveReportData(resultList, resultMain, lineIds);
return saveReportData(resultList, resultMain, lineIds, aiQxNum, csQxNum);
}
@Transactional
@ -350,7 +350,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
return reportIds;
}
public List<Long> saveReportData(List<PatrolResult> resultList, PatrolTaskResultMain resultMain, List<Long> lineIds) {
public List<Long> saveReportData(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());
@ -394,6 +394,16 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
String stationType = stationMap.get("station_type");
String voltLevel = stationMap.get("volt_level");
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()));
@ -408,7 +418,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
report.setStationType(stationType);
inspectionReportMapper.insertInspectionReport(report);
PrintUtil.useTime("NEW TASK REPORT", startTime);
batchInsertReportData(String.valueOf(report.getLineId()), lineIds, String.valueOf(i));
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();
@ -521,11 +531,11 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
report.setInspectionEndTime(DateUtil.parseDateTime(taskStatus.getEndTime()));
}
public void batchInsertReportData(String reportId, List<Long> mainIds, String filter) {
public void batchInsertReportData(String reportId, List<Long> mainIds, String filter, List<PatrolResultRef> patrolResultRefs) {
log.info("batchInsertReportData reportId:" + reportId + ", mainIds:" + mainIds + ", filter:" + filter);
long startTime = System.currentTimeMillis();
// List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineId(mainId);
List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(mainIds, filter);
// List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(mainIds, filter);
if ("0".equals(exportReportFlag)) {
// 导出缺陷
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList());


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

@ -79,6 +79,9 @@ public class PatrolTaskResultMainController extends BaseController {
@Value("${sftp.stationCode}")
private String stationCode;
@Value("${inspect.task.report.all:0}")
private String exportReportFlag;
private final IPatrolTaskResultMainService patrolTaskResultMainService;
private final IPatrolResultService patrolResultService;
private final IInspectionReportDataService inspectionReportDataService;
@ -190,11 +193,23 @@ public class PatrolTaskResultMainController extends BaseController {
// List<PatrolResult> resultList = patrolResultService.selectPatrolResultList(new PatrolResult(mainId));
List<PatrolResult> resultList = patrolResultService.selectPatrolResultListByMainIds(lineIds);
if (resultList.isEmpty()) {
final String result = "[ARCHIVE] Fail, Data is gathering, Please wait!";
logger.error(result);
return AjaxResult.error(result);
logger.error("[归档]失败, 数据采集中...");
return AjaxResult.error("数据采集中请稍后....");
}
ResultAnalysis resultAnalysis = new ResultAnalysis();
int csQxNum = 0, aiQxNum = 0;
List<String> taskPatrolledIds = resultList.stream().map(PatrolResult::getTaskPatrolledId).distinct().collect(Collectors.toList());
for (String taskPatrolledId : taskPatrolledIds) {
resultAnalysis.setTaskPatrolledId(taskPatrolledId);
ResultAnalysis ras = patrolResultService.selectTaskAbnormalData(resultAnalysis);
csQxNum += ras.getCsQxNum();
aiQxNum += ras.getAiQxNum();
}
if("0".equals(exportReportFlag) && 0 == csQxNum && 0 == aiQxNum) {
logger.error("[归档]没有缺陷数据, 无需归档!");
return AjaxResult.error("没有缺陷数据, 无需归档!");
}
// List<PatrolResultAux> patrolResultAuxList = iPatrolResultAuxService.selectPatrolResultAuxListByMainId(new PatrolResultAux(mainId));
List<PatrolResultAux> patrolResultAuxList = iPatrolResultAuxService.selectPatrolResultAuxListByMainIds(lineIds);
for (PatrolResultAux aux : patrolResultAuxList) {
@ -216,9 +231,11 @@ public class PatrolTaskResultMainController extends BaseController {
logger.info("[ARCHIVE] Id: {}, collectNum: {}, analyseNum: {}, modifyNum:{}", mainId, collectNum, analyseNum, modifyNum.get());
// 使用CompletableFuture异步执行saveReport
int finalAiQxNum = aiQxNum;
int finalCsQxNum = csQxNum;
CompletableFuture<List<Long>> saveReportFuture = CompletableFuture.supplyAsync(() -> {
logger.info("[ARCHIVE] Start saving reports");
return patrolResultService.saveReport(resultMain, lineIds, lineId, resultList);
return patrolResultService.saveReport(resultMain, lineIds, lineId, resultList, finalAiQxNum, finalCsQxNum);
}, executor).exceptionally(ex -> {
logger.error("Report saving failed", ex);
return Collections.emptyList();


Loading…
Cancel
Save