Browse Source

绍兴bug修复

master
WangGuangYuan 4 months ago
parent
commit
2f7828173a
3 changed files with 93 additions and 82 deletions
  1. +2
    -2
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java
  2. +70
    -60
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java
  3. +21
    -20
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java

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

@ -541,11 +541,11 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList());
}
log.info("batchInsertReportData patrolResultRefs:" + patrolResultRefs);
// log.info("batchInsertReportData patrolResultRefs:" + patrolResultRefs);
startTime = PrintUtil.useTime("SELECT RESULT", startTime);
// List<BasePointAreaInfo> basePointAreaInfoList = patrolResultMapper.selectBaseInfoByMainId(mainId);
List<BasePointAreaInfo> basePointAreaInfoList = patrolResultMapper.selectBaseInfoByMainIds(mainIds);
log.info("batchInsertReportData basePointAreaInfoList:" + basePointAreaInfoList);
// log.info("batchInsertReportData basePointAreaInfoList:" + basePointAreaInfoList);
PrintUtil.useTime("AREA INQUERY", startTime);
log.info("REPORTS SIZE: {}", patrolResultRefs.size());
List<InspectionReportData> reportDatas = new ArrayList<>();


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

@ -188,8 +188,8 @@ public class PatrolTaskResultMainController extends BaseController {
lineIds.add(lineId);
}
logger.info("---归档--lineIds size: {},lineIds:{}", lineIds.size(), lineIds);
int analyseNum, collectNum;
AtomicInteger modifyNum = new AtomicInteger(0);
// int analyseNum, collectNum;
// AtomicInteger modifyNum = new AtomicInteger(0);
// List<PatrolResult> resultList = patrolResultService.selectPatrolResultList(new PatrolResult(mainId));
List<PatrolResult> resultList = patrolResultService.selectPatrolResultListByMainIds(lineIds);
if (resultList.isEmpty()) {
@ -211,24 +211,24 @@ public class PatrolTaskResultMainController extends BaseController {
return AjaxResult.error("没有缺陷数据, 无需归档!");
}
// List<PatrolResultAux> patrolResultAuxList = iPatrolResultAuxService.selectPatrolResultAuxListByMainId(new PatrolResultAux(mainId));
List<PatrolResultAux> patrolResultAuxList = iPatrolResultAuxService.selectPatrolResultAuxListByMainIds(lineIds);
for (PatrolResultAux aux : patrolResultAuxList) {
resultList.forEach((item) -> {
if (aux.getResultId().equals(String.valueOf(item.getLineId()))) {
item.setValue(aux.getValue());
if (!"1".equals(item.getDataType())) {
modifyNum.addAndGet(1);
}
}
});
}
// List<PatrolResultAux> patrolResultAuxList = iPatrolResultAuxService.selectPatrolResultAuxListByMainIds(lineIds);
// for (PatrolResultAux aux : patrolResultAuxList) {
// resultList.forEach((item) -> {
// if (aux.getResultId().equals(String.valueOf(item.getLineId()))) {
// item.setValue(aux.getValue());
// if (!"1".equals(item.getDataType())) {
// modifyNum.addAndGet(1);
// }
// }
// });
// }
startTime = PrintUtil.useTime("INQUIRY MEND DATA", startTime);
collectNum = resultList.size();
// startTime = PrintUtil.useTime("INQUIRY MEND DATA", startTime);
// collectNum = resultList.size();
// analyseNum = resultAnalysisService.selectResultAnalysisByMainId(lineId);
analyseNum = resultAnalysisService.selectResultAnalysisByMainIds(lineIds);
startTime = PrintUtil.useTime("INQUIRY ANALYZE DATA", startTime);
logger.info("[ARCHIVE] Id: {}, collectNum: {}, analyseNum: {}, modifyNum:{}", mainId, collectNum, analyseNum, modifyNum.get());
// analyseNum = resultAnalysisService.selectResultAnalysisByMainIds(lineIds);
// startTime = PrintUtil.useTime("INQUIRY ANALYZE DATA", startTime);
// logger.info("[ARCHIVE] Id: {}, collectNum: {}, analyseNum: {}, modifyNum:{}", mainId, collectNum, analyseNum, modifyNum.get());
// 使用CompletableFuture异步执行saveReport
int finalAiQxNum = aiQxNum;
@ -240,7 +240,7 @@ public class PatrolTaskResultMainController extends BaseController {
logger.error("Report saving failed", ex);
return Collections.emptyList();
});
PrintUtil.useTime("saveReport", startTime);
// 当saveReport完成后再异步处理所有导出任务
saveReportFuture.thenAcceptAsync(reportIds -> {
logger.info("-----------[ARCHIVE] Saved export reportIds: {}", reportIds);
@ -260,6 +260,7 @@ public class PatrolTaskResultMainController extends BaseController {
logger.error("Error occurred during saveReport: ", ex);
return null;
});
PrintUtil.useTime("exportExcelWordAndZip", startTime);
// logger.info("-----------[ARCHIVE] EndTime: {}, reportIds: {}", DateUtil.now(), reportIds);
return toAjax(1);
@ -788,7 +789,7 @@ public class PatrolTaskResultMainController extends BaseController {
images.add(originalImgSrc);
String pointName = reportData.getPointName();
pointName = (pointName != null) ? pointName : "unnamed";
PatrolResult patrolResult = patrolResultService.selectPatrolResultByDeviceName(pointName);
// PatrolResult patrolResult = patrolResultService.selectPatrolResultByDeviceName(pointName);
// 提取文件扩展名
String extension = "";
int dotIndex = originalImgSrc.lastIndexOf('.');
@ -798,7 +799,7 @@ public class PatrolTaskResultMainController extends BaseController {
// 生成唯一文件名包含 lineId 防止重复
String uniqueFileName = String.format("%s_%s_%s_%d%s",
(patrolResult != null ? patrolResult.getDeviceId() : ""),
originalImgSrc.split("_")[2],
pointName,
reportData.getLineId(),
imgIndex,
@ -811,27 +812,27 @@ public class PatrolTaskResultMainController extends BaseController {
}
Map<String, byte[]> streamHashMap = new HashMap<>();
// for (String algorithmBaseImagePath : images) {
// try {
// sftpClient.downLoad(algorithmBaseImagePath, (inputStream) -> {
// byte[] bytes = streamHashMap.get(algorithmBaseImagePath);
// byte[] byInputStream = getStringByInputStream(inputStream);
// if (bytes == null) {
// streamHashMap.put(algorithmBaseImagePath, byInputStream);
// }
//
// });
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
images.parallelStream().forEach(imagePath -> {
byte[] shm = streamHashMap.get(imagePath);
byte[] bytes = downloadAndCompressImage(imagePath);
if (shm == null) {
streamHashMap.put(imagePath, bytes);
for (String algorithmBaseImagePath : images) {
try {
sftpClient.downLoad(algorithmBaseImagePath, (inputStream) -> {
byte[] bytes = streamHashMap.get(algorithmBaseImagePath);
byte[] byInputStream = getStringByInputStream(inputStream);
if (bytes == null) {
streamHashMap.put(algorithmBaseImagePath, byInputStream);
}
});
} catch (Exception e) {
e.printStackTrace();
}
});
}
// images.parallelStream().forEach(imagePath -> {
// byte[] shm = streamHashMap.get(imagePath);
// byte[] bytes = downloadAndCompressImage(imagePath);
// if (shm == null) {
// streamHashMap.put(imagePath, bytes);
// }
// });
@ -851,28 +852,37 @@ public class PatrolTaskResultMainController extends BaseController {
}
String reportName = namePrefix + inspectionReport.getInspectionTaskName() + "_" + timestamp;
// 上传媒体包
uploadFile(basePath, reportName, ".zip", outputStream -> {
try (ZipOutputStream zipOut = new ZipOutputStream(outputStream)) {
for (Map.Entry<String, byte[]> entry : streamHashMap.entrySet()) {
String imagePath = entry.getKey();
String pointFileName = imgSrcToFileNameMap.getOrDefault(imagePath, "unnamed");
byte[] imageData = entry.getValue();
// String fileName = new File(imagePath).getName();
ZipEntry zipEntry = new ZipEntry(pointFileName);
zipOut.putNextEntry(zipEntry);
zipOut.write(imageData);
zipOut.closeEntry();
CompletableFuture<Void> zipUploadFuture = CompletableFuture.runAsync(() -> {
uploadFile(basePath, reportName, ".zip", outputStream -> {
try (ZipOutputStream zipOut = new ZipOutputStream(outputStream)) {
for (Map.Entry<String, byte[]> entry : streamHashMap.entrySet()) {
String imagePath = entry.getKey();
String pointFileName = imgSrcToFileNameMap.getOrDefault(imagePath, "unnamed");
byte[] imageData = entry.getValue();
// String fileName = new File(imagePath).getName();
ZipEntry zipEntry = new ZipEntry(pointFileName);
zipOut.putNextEntry(zipEntry);
zipOut.write(imageData);
zipOut.closeEntry();
}
} catch (IOException e) {
throw new RuntimeException("生成ZIP文件失败", e);
}
} catch (IOException e) {
throw new RuntimeException("生成ZIP文件失败", e);
}
});
});
}, executor);
// 上传Excel
uploadFile(basePath, reportName, ".xls", sxssfWorkbook::write);
CompletableFuture<Void> excelUploadFuture = CompletableFuture.runAsync(() -> {
uploadFile(basePath, reportName, ".xls", sxssfWorkbook::write);
}, executor);
// 上传Word
uploadFile(basePath, reportName, ".docx", wordDocument::write);
inspectionReport.setFilePath(basePath + reportName + ".xls");
inspectionReportService.updateInspectionReport(inspectionReport);
CompletableFuture<Void> wordUploadFuture = CompletableFuture.runAsync(() -> {
uploadFile(basePath, reportName, ".docx", wordDocument::write);
}, executor);
CompletableFuture.allOf(zipUploadFuture, excelUploadFuture, wordUploadFuture).whenComplete((v, t) -> {
inspectionReport.setFilePath(basePath + reportName + ".xls");
inspectionReportService.updateInspectionReport(inspectionReport);
});
} catch (Exception e) {
e.printStackTrace();
}


+ 21
- 20
inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java View File

@ -132,20 +132,20 @@ public class PatrolTaskController extends BaseController {
} else {
task.setFileStatus("0");
}
String areaIdS = task.getAreaIdS();
AjaxResult ajaxResult = FeignBasedataAreaService.list((new JSONObject()).fluentPut("areaIdS", areaIdS));
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult));
// 检查响应是否成功
if ("200".equals(ajaxResult.get("code").toString())) {
JSONArray data = jsonObject.getJSONArray("data");
if (data != null && !data.isEmpty()) {
List<String> areaNames = data.stream()
.filter(item -> "station_in".equals(((JSONObject) item).getString("areaType")))
.map(item -> ((JSONObject) item).getString("areaName"))
.collect(Collectors.toList());
task.setAreaName(StringUtils.join(areaNames, StringUtils.COMMA));
}
}
// String areaIdS = task.getAreaIdS();
// AjaxResult ajaxResult = FeignBasedataAreaService.list((new JSONObject()).fluentPut("areaIdS", areaIdS));
// JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult));
// // 检查响应是否成功
// if ("200".equals(ajaxResult.get("code").toString())) {
// JSONArray data = jsonObject.getJSONArray("data");
// if (data != null && !data.isEmpty()) {
// List<String> areaNames = data.stream()
// .filter(item -> "station_in".equals(((JSONObject) item).getString("areaType")))
// .map(item -> ((JSONObject) item).getString("areaName"))
// .collect(Collectors.toList());
// task.setAreaName(StringUtils.join(areaNames, StringUtils.COMMA));
// }
// }
}
if (StringUtils.isNotEmpty(patrolTask.getAreaName())) {
@ -543,6 +543,7 @@ public class PatrolTaskController extends BaseController {
jsonText = message;
try {
patrolTaskList = JSONArray.parseArray("[" + message + "]", PatrolTask.class);
patrolTaskList = toPatrolTaskList(parseObject, flag);
//eqList = JSONArray.parseArray(message + "", PatrolTask.class);
} catch (Exception e) {
logger.warn("2 Exception: {}", e.getMessage());
@ -1725,12 +1726,12 @@ public class PatrolTaskController extends BaseController {
}
}
if (jsonObject.get("areaName") != null) {
jsonObjectString = jsonObject.get("areaName").toString();
if (StringUtils.isNotEmpty(jsonObjectString)) {
patrolTask.setAreaName(jsonObjectString);
}
}
// if (jsonObject.get("areaName") != null) {
// jsonObjectString = jsonObject.get("areaName").toString();
// if (StringUtils.isNotEmpty(jsonObjectString)) {
// patrolTask.setAreaName(jsonObjectString);
// }
// }
if (jsonObject.get("stationCode") != null) {
jsonObjectString = jsonObject.get("stationCode").toString();


Loading…
Cancel
Save