From ca46cd86ae201e157766517a9df1a7ede5f53d29 Mon Sep 17 00:00:00 2001 From: wangguangyuan Date: Tue, 16 Sep 2025 10:24:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=8D=E5=85=B4=E6=8A=A5=E5=91=8A=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PatrolResultServiceImpl.java | 8 +- .../PatrolTaskResultMainController.java | 108 +++++++++++------- 2 files changed, 69 insertions(+), 47 deletions(-) diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java index 3b5888a..70a159b 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java @@ -802,8 +802,8 @@ public class PatrolResultServiceImpl implements IPatrolResultService { PatrolResultRef patrolResultRef = new PatrolResultRef(); patrolResultRef.setDeviceId(key.objectId); patrolResultRef.setAlgType(key.algType); - patrolResultRef.setDescription(value.stream().map(PatrolResultRef::getDescription).collect(Collectors.joining(","))); - patrolResultRef.setValue(value.stream().map(PatrolResultRef::getValue).collect(Collectors.joining(","))); + 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) { // 初筛有缺陷,展示初筛结果 if ("1".equals(resultRef.getFilter()) && StringUtils.isEmpty(patrolResultRef.getResultContent())) { @@ -1350,8 +1350,8 @@ public class PatrolResultServiceImpl implements IPatrolResultService { PatrolResultRef patrolResultRef = new PatrolResultRef(); patrolResultRef.setDeviceId(key.objectId); patrolResultRef.setAlgType(key.algType); - patrolResultRef.setDescription(value.stream().map(PatrolResultRef::getDescription).collect(Collectors.joining(","))); - patrolResultRef.setValue(value.stream().map(PatrolResultRef::getValue).collect(Collectors.joining(","))); + 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) { // 初筛有缺陷,展示初筛结果 if ("1".equals(resultRef.getFilter()) && StringUtils.isEmpty(patrolResultRef.getResultContent())) { diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java index 6601951..afbbc8f 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java @@ -478,7 +478,7 @@ public class PatrolTaskResultMainController extends BaseController { } lineIds = lineIds.stream().distinct().collect(Collectors.toList()); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=\"task_export_" + System.currentTimeMillis() + ".xlsx\""); + response.setHeader("Content-Disposition", "attachment; filename=\"InspectionReport_" + System.currentTimeMillis() + ".xlsx\""); // InspectionReport inspectionReport = new InspectionReport(); InspectionReport inspectionReport = patrolResultService.getInspectionReport(lineIds, patrolTaskResultMain); List inspectionReportDataList = inspectionReport.getReportDatalist(); @@ -520,13 +520,27 @@ public class PatrolTaskResultMainController extends BaseController { } Map streamHashMap = new HashMap<>(); - images.parallelStream().forEach(imagePath -> { - byte[] shm = streamHashMap.get(imagePath); - byte[] bytes = downloadAndCompressImage(imagePath); - if (shm == null) { - streamHashMap.put(imagePath, bytes); +// 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(); } - }); + } try (SXSSFWorkbook sxssfWorkbook = getSXSSFWorkbookShaoxing(inspectionReport, streamHashMap); ServletOutputStream outputStream = response.getOutputStream()) { @@ -601,7 +615,12 @@ public class PatrolTaskResultMainController extends BaseController { // 点位汇总 // List statusList = Arrays.asList(MessageUtils.get("异常"), MessageUtils.get("待人工确认"), MessageUtils.get("正常")); - List statusList = Collections.singletonList(MessageUtils.get("缺陷")); + List statusList = new ArrayList<>(); + statusList.add(MessageUtils.get("缺陷")); + if ("1".equals(exportReportFlag)) { + statusList.add(MessageUtils.get("正常")); + statusList.add(MessageUtils.get("异常")); + } for (String status : statusList) { addStatusSection(doc, report, status, images); } @@ -832,10 +851,12 @@ public class PatrolTaskResultMainController extends BaseController { setTableHeaderStyle(table); // 填充数据 List dataList = report.getReportDatalist(); - - for (InspectionReportData data : dataList) { - XWPFTableRow row = table.createRow(); - fillDataRow(row, data, images); + if (dataList != null && dataList.size() > 0) { + dataList = dataList.stream().filter(data -> status.equals(data.getPointStatus())).collect(Collectors.toList()); + for (InspectionReportData data : dataList) { + XWPFTableRow row = table.createRow(); + fillDataRow(row, data, images); + } } addEmptyParagraph(doc); } @@ -1546,27 +1567,27 @@ public class PatrolTaskResultMainController extends BaseController { } Map 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); +// } +// }); @@ -2347,18 +2368,19 @@ public class PatrolTaskResultMainController extends BaseController { } } - InspectionReportData inspectionReportData = new InspectionReportData(); + List list = new ArrayList(); -// inspectionReportData.setPointStatus(MessageUtils.get("异常")); -// list.add(inspectionReportData); -// InspectionReportData inspection = new InspectionReportData(); -// inspection.setPointStatus(MessageUtils.get("待人工确认")); -// list.add(inspection); -// InspectionReportData inection = new InspectionReportData(); -// inection.setPointStatus(MessageUtils.get("正常")); -// list.add(inection); - inspectionReportData.setPointStatus(MessageUtils.get("缺陷")); - list.add(inspectionReportData); + InspectionReportData inspectionReportQxData = new InspectionReportData(); + inspectionReportQxData.setPointStatus(MessageUtils.get("缺陷")); + list.add(inspectionReportQxData); + if ("1".equals(exportReportFlag)) { + InspectionReportData inspectionReportZcData = new InspectionReportData(); + inspectionReportZcData.setPointStatus(MessageUtils.get("正常")); + list.add(inspectionReportZcData); + InspectionReportData inspectionReportYcData = new InspectionReportData(); + inspectionReportYcData.setPointStatus(MessageUtils.get("异常")); + list.add(inspectionReportYcData); + } int total = 0; label186: