|
|
|
@ -330,7 +330,8 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
|
CompletableFuture<?>[] exportFutures = reportIds.stream() |
|
|
|
.map(reportId -> CompletableFuture.runAsync(() -> { |
|
|
|
logger.info("[EXPORT] Start export for reportId: {}", reportId); |
|
|
|
exportExcelWordAndZipLingzhou(String.valueOf(reportId)); |
|
|
|
// exportExcelWordAndZipLingzhou(String.valueOf(reportId)); |
|
|
|
exportExcelWordAndZipShaoxing(String.valueOf(reportId)); |
|
|
|
}, executor)) |
|
|
|
.toArray(CompletableFuture[]::new); |
|
|
|
|
|
|
|
@ -461,17 +462,76 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
|
businessType = BizType.EXPORT |
|
|
|
) |
|
|
|
@PostMapping({"/reportExport"}) |
|
|
|
public ResponseEntity taskInfoExport(HttpServletResponse response, PatrolTaskResultMain patrolTaskResultMain) throws Exception { |
|
|
|
public ResponseEntity reportExport(HttpServletResponse response, PatrolTaskResultMain patrolTaskResultMain) throws Exception { |
|
|
|
logger.info("开始导出报告,patrolTaskResultMain:{}", patrolTaskResultMain.toString()); |
|
|
|
|
|
|
|
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
// response.setHeader("Content-Disposition", "attachment; filename=\"task_export_" + System.currentTimeMillis() + ".xlsx\""); |
|
|
|
List<String> taskPatrolledIds = patrolTaskResultMain.getTaskPatrolledIds(); |
|
|
|
List<PatrolTaskResultMain> patrolTaskResultMains = patrolTaskResultMainService.selectPatrolTaskResultMainByTaskPatrolledIds(taskPatrolledIds); |
|
|
|
logger.info("-----------patrolTaskResultMains: {}", patrolTaskResultMains); |
|
|
|
if (patrolTaskResultMains.size() == 0) { |
|
|
|
logger.error("[归档]失败, 数据采集中..."); |
|
|
|
return ResponseEntity.ok("数据采集中请稍后...."); |
|
|
|
} |
|
|
|
List<Long> lineIds = patrolTaskResultMains.stream().map(PatrolTaskResultMain::getLineId).collect(Collectors.toList()); |
|
|
|
List<Long> longs = patrolTaskResultMainService.selectLineIdsByList(lineIds); |
|
|
|
if (longs != null && longs.size() > 0) { |
|
|
|
lineIds.addAll(longs); |
|
|
|
} |
|
|
|
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\""); |
|
|
|
// InspectionReport inspectionReport = new InspectionReport(); |
|
|
|
// |
|
|
|
// try (SXSSFWorkbook sxssfWorkbook = getSXSSFWorkbookLingzhou(inspectionReport, streamHashMap); |
|
|
|
// ServletOutputStream outputStream = response.getOutputStream()) { |
|
|
|
// sxssfWorkbook.write(outputStream); |
|
|
|
// } |
|
|
|
InspectionReport inspectionReport = patrolResultService.getInspectionReport(lineIds, patrolTaskResultMain); |
|
|
|
List<InspectionReportData> inspectionReportDataList = inspectionReport.getReportDatalist(); |
|
|
|
List<String> images = new ArrayList<>(); |
|
|
|
Map<String, String> imgSrcToFileNameMap = new HashMap<>(); |
|
|
|
for (InspectionReportData reportData : inspectionReportDataList) { |
|
|
|
// InspectionReportImg inspectionReportImg = new InspectionReportImg(); |
|
|
|
// inspectionReportImg.setReportInfoId(reportData.getLineId()); |
|
|
|
// List<InspectionReportImg> reportImgList = |
|
|
|
// inspectionReportImgService.selectInspectionReportImgList(inspectionReportImg); |
|
|
|
// reportData.setReportImgList(reportImgList); |
|
|
|
List<InspectionReportImg> reportImgList = reportData.getReportImgList(); |
|
|
|
|
|
|
|
int imgIndex = 1; // 每个报告数据项下的图片索引 |
|
|
|
for (InspectionReportImg reportImg : reportImgList) { |
|
|
|
if (StringUtils.isNotEmpty(reportImg.getImgSrc()) && reportImg.getImgType().equals("0")) { |
|
|
|
String originalImgSrc = reportImg.getImgSrc(); |
|
|
|
images.add(originalImgSrc); |
|
|
|
String pointName = reportData.getPointName(); |
|
|
|
pointName = (pointName != null) ? pointName : "unnamed"; |
|
|
|
// 提取文件扩展名 |
|
|
|
String extension = ""; |
|
|
|
int dotIndex = originalImgSrc.lastIndexOf('.'); |
|
|
|
if (dotIndex > 0) { |
|
|
|
extension = originalImgSrc.substring(dotIndex); |
|
|
|
} |
|
|
|
|
|
|
|
// 生成唯一文件名(包含 lineId 防止重复) |
|
|
|
String uniqueFileName = String.format("%s_%s_%d%s", |
|
|
|
originalImgSrc.split("_")[2], |
|
|
|
pointName, |
|
|
|
imgIndex, |
|
|
|
extension); |
|
|
|
|
|
|
|
imgSrcToFileNameMap.put(originalImgSrc, uniqueFileName); |
|
|
|
imgIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, byte[]> streamHashMap = new HashMap<>(); |
|
|
|
|
|
|
|
images.parallelStream().forEach(imagePath -> { |
|
|
|
byte[] shm = streamHashMap.get(imagePath); |
|
|
|
byte[] bytes = downloadAndCompressImage(imagePath); |
|
|
|
if (shm == null) { |
|
|
|
streamHashMap.put(imagePath, bytes); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
try (SXSSFWorkbook sxssfWorkbook = getSXSSFWorkbookShaoxing(inspectionReport, streamHashMap); |
|
|
|
ServletOutputStream outputStream = response.getOutputStream()) { |
|
|
|
sxssfWorkbook.write(outputStream); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok("报告导出成功!"); |
|
|
|
@ -1434,6 +1494,133 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void exportExcelWordAndZipShaoxing(String lineId) { |
|
|
|
List<String> images = new ArrayList<>(); |
|
|
|
Map<String, String> imgSrcToFileNameMap = new HashMap<>(); |
|
|
|
InspectionReport inspectionReport = |
|
|
|
inspectionReportService.selectInspectionReportByLineId(Long.valueOf(lineId)); |
|
|
|
InspectionReportData inspectionReportData = new InspectionReportData(); |
|
|
|
inspectionReportData.setReportId(String.valueOf(inspectionReport.getLineId())); |
|
|
|
List<InspectionReportData> inspectionReportDataList = |
|
|
|
inspectionReportDataService.selectInspectionReportDataList(inspectionReportData); |
|
|
|
if (!inspectionReportDataList.isEmpty()) { |
|
|
|
inspectionReport.setReportDatalist(inspectionReportDataList); |
|
|
|
} else { |
|
|
|
logger.info("--exportExcelWordAndZip------report lineId:{},filter:{} no report data!", lineId, inspectionReport.getFilter()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
for (InspectionReportData reportData : inspectionReportDataList) { |
|
|
|
InspectionReportImg inspectionReportImg = new InspectionReportImg(); |
|
|
|
inspectionReportImg.setReportInfoId(reportData.getLineId()); |
|
|
|
List<InspectionReportImg> reportImgList = |
|
|
|
inspectionReportImgService.selectInspectionReportImgList(inspectionReportImg); |
|
|
|
reportData.setReportImgList(reportImgList); |
|
|
|
|
|
|
|
int imgIndex = 1; // 每个报告数据项下的图片索引 |
|
|
|
for (InspectionReportImg reportImg : reportImgList) { |
|
|
|
if (StringUtils.isNotEmpty(reportImg.getImgSrc()) && reportImg.getImgType().equals("0")) { |
|
|
|
String originalImgSrc = reportImg.getImgSrc(); |
|
|
|
images.add(originalImgSrc); |
|
|
|
String pointName = reportData.getPointName(); |
|
|
|
pointName = (pointName != null) ? pointName : "unnamed"; |
|
|
|
// 提取文件扩展名 |
|
|
|
String extension = ""; |
|
|
|
int dotIndex = originalImgSrc.lastIndexOf('.'); |
|
|
|
if (dotIndex > 0) { |
|
|
|
extension = originalImgSrc.substring(dotIndex); |
|
|
|
} |
|
|
|
|
|
|
|
// 生成唯一文件名(包含 lineId 防止重复) |
|
|
|
String uniqueFileName = String.format("%s_%s_%s_%d%s", |
|
|
|
originalImgSrc.split("_")[2], |
|
|
|
pointName, |
|
|
|
reportData.getLineId(), |
|
|
|
imgIndex, |
|
|
|
extension); |
|
|
|
|
|
|
|
imgSrcToFileNameMap.put(originalImgSrc, uniqueFileName); |
|
|
|
imgIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SXSSFWorkbook sxssfWorkbook = getSXSSFWorkbookShaoxing(inspectionReport, streamHashMap); |
|
|
|
XWPFDocument wordDocument = getXWPFDocumentLingzhou(inspectionReport, streamHashMap); |
|
|
|
logger.info("[ARCHIVE] hssfWorkbook: {}", sxssfWorkbook); |
|
|
|
try { |
|
|
|
String basePath = this.basePath + stationCode + "/Model/"; |
|
|
|
Date startTime = inspectionReport.getInspectionStartTime() != null ? |
|
|
|
inspectionReport.getInspectionStartTime() : new Date(); |
|
|
|
String timestamp = DateUtils.format(DateUtils.yyyyMMddHHmmss2, startTime) + "_" + System.currentTimeMillis(); |
|
|
|
String namePrefix = ""; |
|
|
|
if ("1".equals(inspectionReport.getFilter())) { |
|
|
|
namePrefix = MessageUtils.get("初筛") + "_"; |
|
|
|
} else if ("0".equals(inspectionReport.getFilter())) { |
|
|
|
namePrefix = MessageUtils.get("大模型") + "_"; |
|
|
|
} |
|
|
|
String reportName = inspectionReport.getInspectionTaskName() + "_" + timestamp; |
|
|
|
// 上传媒体包 |
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, executor); |
|
|
|
// 上传Excel |
|
|
|
CompletableFuture<Void> excelUploadFuture = CompletableFuture.runAsync(() -> { |
|
|
|
uploadFile(basePath, reportName, ".xls", sxssfWorkbook::write); |
|
|
|
}, executor); |
|
|
|
// 上传Word |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private byte[] downloadAndCompressImage(String imagePath) { |
|
|
|
try { |
|
|
|
// 直接下载并压缩图片 |
|
|
|
@ -2953,6 +3140,419 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
|
return wb; |
|
|
|
} |
|
|
|
|
|
|
|
public SXSSFWorkbook getSXSSFWorkbookShaoxing(InspectionReport inspectionReport, Map<String, byte[]> inputStreamMap) { |
|
|
|
// 使用SXSSFWorkbook并设置行访问窗口大小(1000行) |
|
|
|
SXSSFWorkbook wb = new SXSSFWorkbook(1000); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SXSSFSheet sheet = wb.createSheet(System.currentTimeMillis() + ""); |
|
|
|
CellStyle colStyle = createCellStyle((SXSSFWorkbook) wb, (short) 15, true, true); |
|
|
|
CellStyle colStyle2 = createCellStylenoborder((SXSSFWorkbook) wb, (short) 15, true, true); |
|
|
|
CellStyle colright = getColRight((SXSSFWorkbook) wb, (short) 10, true, false); |
|
|
|
CellRangeAddress callRangeAddress01 = new CellRangeAddress(0, 0, 0, 14); |
|
|
|
CellRangeAddress callRangeAddress02 = new CellRangeAddress(1, 1, 0, 3); |
|
|
|
CellRangeAddress callRangeAddress03 = new CellRangeAddress(1, 1, 4, 7); |
|
|
|
CellRangeAddress callRangeAddress04 = new CellRangeAddress(1, 1, 8, 11); |
|
|
|
CellRangeAddress callRangeAddress05 = new CellRangeAddress(1, 1, 12, 14); |
|
|
|
CellRangeAddress callRangeAddress21 = new CellRangeAddress(2, 2, 0, 3); |
|
|
|
CellRangeAddress callRangeAddress22 = new CellRangeAddress(2, 2, 4, 7); |
|
|
|
CellRangeAddress callRangeAddress23 = new CellRangeAddress(2, 2, 8, 11); |
|
|
|
CellRangeAddress callRangeAddress24 = new CellRangeAddress(2, 2, 12, 14); |
|
|
|
CellRangeAddress callRangeAddress31 = new CellRangeAddress(3, 3, 0, 3); |
|
|
|
CellRangeAddress callRangeAddress32 = new CellRangeAddress(3, 3, 4, 7); |
|
|
|
CellRangeAddress callRangeAddress33 = new CellRangeAddress(3, 3, 8, 11); |
|
|
|
CellRangeAddress callRangeAddress34 = new CellRangeAddress(3, 3, 12, 14); |
|
|
|
CellRangeAddress callRangeAddress41 = new CellRangeAddress(4, 4, 0, 3); |
|
|
|
CellRangeAddress callRangeAddress42 = new CellRangeAddress(4, 4, 4, 7); |
|
|
|
CellRangeAddress callRangeAddress43 = new CellRangeAddress(4, 4, 8, 11); |
|
|
|
CellRangeAddress callRangeAddress44 = new CellRangeAddress(4, 4, 12, 14); |
|
|
|
CellRangeAddress callRangeAddress51 = new CellRangeAddress(5, 5, 0, 3); |
|
|
|
CellRangeAddress callRangeAddress52 = new CellRangeAddress(5, 5, 4, 14); |
|
|
|
sheet.addMergedRegion(callRangeAddress01); |
|
|
|
sheet.addMergedRegion(callRangeAddress02); |
|
|
|
sheet.addMergedRegion(callRangeAddress03); |
|
|
|
sheet.addMergedRegion(callRangeAddress04); |
|
|
|
sheet.addMergedRegion(callRangeAddress05); |
|
|
|
sheet.addMergedRegion(callRangeAddress21); |
|
|
|
sheet.addMergedRegion(callRangeAddress22); |
|
|
|
sheet.addMergedRegion(callRangeAddress23); |
|
|
|
sheet.addMergedRegion(callRangeAddress24); |
|
|
|
sheet.addMergedRegion(callRangeAddress31); |
|
|
|
sheet.addMergedRegion(callRangeAddress32); |
|
|
|
sheet.addMergedRegion(callRangeAddress33); |
|
|
|
sheet.addMergedRegion(callRangeAddress34); |
|
|
|
sheet.addMergedRegion(callRangeAddress41); |
|
|
|
sheet.addMergedRegion(callRangeAddress42); |
|
|
|
sheet.addMergedRegion(callRangeAddress43); |
|
|
|
sheet.addMergedRegion(callRangeAddress44); |
|
|
|
sheet.addMergedRegion(callRangeAddress51); |
|
|
|
sheet.addMergedRegion(callRangeAddress52); |
|
|
|
Row row0 = sheet.createRow(0); |
|
|
|
row0.setHeight((short) 600); |
|
|
|
Cell cell0 = row0.createCell(0); |
|
|
|
cell0.setCellValue(MessageUtils.get("巡视报告")); |
|
|
|
CellStyle stylea = wb.createCellStyle(); |
|
|
|
stylea.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
stylea.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
Font font = wb.createFont(); |
|
|
|
font.setFontHeightInPoints((short) 20); |
|
|
|
font.setFontHeight((short) 500); |
|
|
|
font.setBold(true); |
|
|
|
stylea.setFont(font); |
|
|
|
cell0.setCellStyle(stylea); |
|
|
|
Row row1 = sheet.createRow(1); |
|
|
|
Cell cell11 = row1.createCell(0); |
|
|
|
cell11.setCellValue(MessageUtils.get("变电站")); |
|
|
|
cell11.setCellStyle(colStyle2); |
|
|
|
Cell cell12 = row1.createCell(4); |
|
|
|
cell12.setCellValue(inspectionReport.getStationName()); |
|
|
|
cell12.setCellStyle(colStyle2); |
|
|
|
Cell cell13 = row1.createCell(8); |
|
|
|
cell13.setCellValue(MessageUtils.get("电压等级")); |
|
|
|
cell13.setCellStyle(colStyle2); |
|
|
|
Cell cell14 = row1.createCell(12); |
|
|
|
cell14.setCellValue(inspectionReport.getVoltLevel()); |
|
|
|
cell14.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
for (int i = 0; i < 15; ++i) { |
|
|
|
if (i != 0 && i != 4 && i != 8 && i != 12) { |
|
|
|
cell14 = row1.createCell(i); |
|
|
|
cell14.setCellStyle(colStyle2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Row row2 = sheet.createRow(2); |
|
|
|
Cell cell21 = row2.createCell(0); |
|
|
|
cell21.setCellValue(MessageUtils.get("审核人")); |
|
|
|
cell21.setCellStyle(colStyle2); |
|
|
|
Cell cell22 = row2.createCell(4); |
|
|
|
cell22.setCellValue(inspectionReport.getCheckPerson()); |
|
|
|
cell22.setCellStyle(colStyle2); |
|
|
|
Cell cell23 = row2.createCell(8); |
|
|
|
cell23.setCellValue(MessageUtils.get("审核时间")); |
|
|
|
cell23.setCellStyle(colStyle2); |
|
|
|
Cell cell24 = row2.createCell(12); |
|
|
|
cell24.setCellValue(DateUtil.formatDateTime(inspectionReport.getCheckTime())); |
|
|
|
cell24.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
for (int i = 0; i < 15; ++i) { |
|
|
|
if (i != 0 && i != 4 && i != 8 && i != 12) { |
|
|
|
cell14 = row2.createCell(i); |
|
|
|
cell14.setCellStyle(colStyle2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Row row3 = sheet.createRow(3); |
|
|
|
Cell cell31 = row3.createCell(0); |
|
|
|
cell31.setCellValue(MessageUtils.get("巡视开始时间")); |
|
|
|
cell31.setCellStyle(colStyle2); |
|
|
|
Cell cell32 = row3.createCell(4); |
|
|
|
if (inspectionReport.getInspectionStartTime() != null) { |
|
|
|
cell32.setCellValue(DateUtil.formatDateTime(inspectionReport.getInspectionStartTime())); |
|
|
|
} |
|
|
|
|
|
|
|
cell32.setCellStyle(colStyle2); |
|
|
|
Cell cell33 = row3.createCell(8); |
|
|
|
cell33.setCellValue(MessageUtils.get("巡视结束时间")); |
|
|
|
cell33.setCellStyle(colStyle2); |
|
|
|
Cell cell34 = row3.createCell(12); |
|
|
|
if (inspectionReport.getInspectionEndTime() != null) { |
|
|
|
cell34.setCellValue(DateUtil.formatDateTime(inspectionReport.getInspectionEndTime())); |
|
|
|
} |
|
|
|
|
|
|
|
cell34.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
for (int i = 0; i < 15; ++i) { |
|
|
|
if (i != 0 && i != 4 && i != 8 && i != 12) { |
|
|
|
cell14 = row3.createCell(i); |
|
|
|
cell14.setCellStyle(colStyle2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Row row6 = sheet.createRow(4); |
|
|
|
Cell cell61 = row6.createCell(0); |
|
|
|
cell61.setCellValue(MessageUtils.get("巡视任务")); |
|
|
|
cell61.setCellStyle(colStyle2); |
|
|
|
Cell cell62 = row6.createCell(4); |
|
|
|
cell62.setCellValue(inspectionReport.getInspectionTaskName()); |
|
|
|
cell62.setCellStyle(colStyle2); |
|
|
|
Cell cell63 = row6.createCell(8); |
|
|
|
cell63.setCellValue(MessageUtils.get("巡视统计")); |
|
|
|
cell63.setCellStyle(colStyle2); |
|
|
|
Cell cell64 = row6.createCell(12); |
|
|
|
cell64.setCellValue(inspectionReport.getPatrolStatistics()); |
|
|
|
cell64.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
for (int i = 0; i < 15; ++i) { |
|
|
|
if (i != 0 && i != 4 && i != 8 && i != 12) { |
|
|
|
cell14 = row6.createCell(i); |
|
|
|
cell14.setCellStyle(colStyle2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Row row7 = sheet.createRow(5); |
|
|
|
row7.setHeight((short) 1000); |
|
|
|
Cell cell71 = row7.createCell(0); |
|
|
|
cell71.setCellValue(MessageUtils.get("巡视结论")); |
|
|
|
cell71.setCellStyle(colStyle2); |
|
|
|
Cell cell72 = row7.createCell(4); |
|
|
|
cell72.setCellValue(inspectionReport.getDescription()); |
|
|
|
cell72.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
//qinyl |
|
|
|
for (int j = 0; j < 15; ++j) { |
|
|
|
if (j != 0 && j != 4) { |
|
|
|
cell14 = row7.createCell(j); |
|
|
|
cell14.setCellStyle(colStyle2); |
|
|
|
} |
|
|
|
} |
|
|
|
List<InspectionReportData> list = new ArrayList<>(); |
|
|
|
InspectionReportData inspectionReportQxData = new InspectionReportData(); |
|
|
|
inspectionReportQxData.setPointStatus(MessageUtils.get("缺陷")); |
|
|
|
list.add(inspectionReportQxData); |
|
|
|
// 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: |
|
|
|
for (Iterator var74 = list.iterator(); var74.hasNext(); total += 2) { |
|
|
|
InspectionReportData arr = (InspectionReportData) var74.next(); |
|
|
|
SXSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
|
|
|
CellRangeAddress callRangeAddressa1 = new CellRangeAddress(6 + total, 6 + total, 0, 14); |
|
|
|
sheet.addMergedRegion(callRangeAddressa1); |
|
|
|
Row rowa1 = sheet.createRow(6 + total); |
|
|
|
Cell cella1 = rowa1.createCell(0); |
|
|
|
cella1.setCellValue(arr.getPointStatus() + MessageUtils.get("点位汇总")); |
|
|
|
CellStyle styleab = wb.createCellStyle(); |
|
|
|
styleab.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
styleab.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
Font fonta = wb.createFont(); |
|
|
|
fonta.setFontHeightInPoints((short) 20); |
|
|
|
styleab.setFont(fonta); |
|
|
|
cella1.setCellStyle(styleab); |
|
|
|
|
|
|
|
//qinyl |
|
|
|
for (int j = 0; j < 15; ++j) { |
|
|
|
if (j != 0) { |
|
|
|
cell14 = rowa1.createCell(j); |
|
|
|
cell14.setCellStyle(colStyle2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
CellRangeAddress callRangeAddressa12 = new CellRangeAddress(7 + total, 7 + total, 12, 14); |
|
|
|
sheet.addMergedRegion(callRangeAddressa12); |
|
|
|
rowa1 = sheet.createRow(7 + total); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total, 2, 4)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total, 5, 6)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total, 9, 10)); |
|
|
|
cella1 = rowa1.createCell(0); |
|
|
|
cella1.setCellValue(MessageUtils.get("编号")); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowa1.createCell(1); |
|
|
|
cella1.setCellValue(MessageUtils.get("区域")); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowa1.createCell(2); |
|
|
|
cella1.setCellValue(MessageUtils.get("设备")); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowa1.createCell(3); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowa1.createCell(4); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowa1.createCell(5); |
|
|
|
cella1.setCellValue(MessageUtils.get("点位")); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowa1.createCell(6); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
|
|
|
|
cella1 = rowa1.createCell(7); |
|
|
|
cella1.setCellValue(MessageUtils.get("数据来源")); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowa1.createCell(8); |
|
|
|
cella1.setCellValue(MessageUtils.get("采集时间")); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowa1.createCell(9); |
|
|
|
cella1.setCellValue(MessageUtils.get("巡视结果")); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowa1.createCell(10); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
|
|
|
|
cella1 = rowa1.createCell(11); |
|
|
|
cella1.setCellValue(MessageUtils.get("算法类型")); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowa1.createCell(12); |
|
|
|
cella1.setCellValue(MessageUtils.get("巡视图像")); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowa1.createCell(13); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowa1.createCell(14); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
|
|
|
|
InspectionReportData insa = new InspectionReportData(); |
|
|
|
insa.setReportId(inspectionReport.getLineId() + ""); |
|
|
|
insa.setPointStatus(arr.getPointStatus()); |
|
|
|
List<InspectionReportData> listarr = new ArrayList(); |
|
|
|
if (inspectionReport.getReportDatalist() != null && inspectionReport.getReportDatalist().size() > 0) { |
|
|
|
listarr = (List) inspectionReport.getReportDatalist().stream().filter((a) -> { |
|
|
|
return arr.getPointStatus().equals(a.getPointStatus()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
Iterator var85 = ((List) listarr).iterator(); |
|
|
|
|
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
if (!var85.hasNext()) { |
|
|
|
continue label186; |
|
|
|
} |
|
|
|
|
|
|
|
InspectionReportData brr = (InspectionReportData) var85.next(); |
|
|
|
++total; |
|
|
|
// InspectionReportImg inspectionReportImg = new InspectionReportImg(); |
|
|
|
// inspectionReportImg.setReportInfoId(brr.getLineId() + ""); |
|
|
|
List<InspectionReportImg> imgList = new ArrayList(); |
|
|
|
if (brr.getReportImgList() != null && brr.getReportImgList().size() > 0) { |
|
|
|
imgList = brr.getReportImgList(); |
|
|
|
} |
|
|
|
|
|
|
|
CellRangeAddress callRangeAddressa4 = new CellRangeAddress(7 + total, 7 + total, 12, 14); |
|
|
|
sheet.addMergedRegion(callRangeAddressa4); |
|
|
|
Row rowb1 = sheet.createRow(7 + total); |
|
|
|
if (((List) imgList).size() > 0) { |
|
|
|
rowb1.setHeight((short) 1000); |
|
|
|
} |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(0); |
|
|
|
cella1.setCellValue((double) brr.getCode().longValue()); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(1); |
|
|
|
cella1.setCellValue(brr.getArea()); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(2); |
|
|
|
cella1.setCellValue(brr.getEqName()); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(3); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(4); |
|
|
|
// cella1.setCellValue(brr.getParts()); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(5); |
|
|
|
cella1.setCellValue(brr.getPointName()); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(6); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(7); |
|
|
|
cella1.setCellValue(brr.getDataSources()); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(8); |
|
|
|
if (brr.getAcquisitionTime() != null) { |
|
|
|
cella1.setCellValue(DateUtil.formatDateTime(brr.getAcquisitionTime())); |
|
|
|
} |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(9); |
|
|
|
cella1.setCellValue(brr.getInspectionResults()); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(10); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(11); |
|
|
|
cella1.setCellValue(brr.getAlgName()); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
|
|
|
|
String str = ""; |
|
|
|
cella1 = rowb1.createCell(12); |
|
|
|
cella1.setCellValue(str); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(13); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(14); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
if (((List) imgList).size() > 0) { |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 0, 0)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 1, 1)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 2, 4)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 5, 6)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 7, 7)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 8, 8)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 9, 10)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total + ((List) imgList).size(), 11, 11)); |
|
|
|
new ArrayList(); |
|
|
|
Iterator var93 = ((List) imgList).iterator(); |
|
|
|
|
|
|
|
while (var93.hasNext()) { |
|
|
|
InspectionReportImg crr = (InspectionReportImg) var93.next(); |
|
|
|
++total; |
|
|
|
CellRangeAddress callRangeAddressb4 = new CellRangeAddress(7 + total, 7 + total, 12, 14); |
|
|
|
sheet.addMergedRegion(callRangeAddressb4); |
|
|
|
rowb1 = sheet.createRow(7 + total); |
|
|
|
rowb1.setHeight((short) 1000); |
|
|
|
cella1 = rowb1.createCell(0); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(1); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(2); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(3); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(4); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(5); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(6); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(7); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(8); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(9); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(10); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(11); |
|
|
|
cella1.setCellStyle(colStyle2); |
|
|
|
cella1 = rowb1.createCell(12); |
|
|
|
if (crr.getImgType().equals("0")) { |
|
|
|
try { |
|
|
|
insertImage(wb, patriarch, this.images(crr.getImg(), inputStreamMap), 7 + total, 0, 2); |
|
|
|
} catch (Exception var97) { |
|
|
|
var97.printStackTrace(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String sheetName = crr.getImgSrc(); |
|
|
|
cella1.setCellFormula("HYPERLINK(\"" + sheetName + "\")"); |
|
|
|
cella1.setCellStyle(colright); |
|
|
|
} |
|
|
|
|
|
|
|
cella1 = rowb1.createCell(13); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
cella1 = rowb1.createCell(14); |
|
|
|
cella1.setCellStyle(colStyle); |
|
|
|
} |
|
|
|
} else { |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total, 2, 4)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total, 5, 6)); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(7 + total, 7 + total, 9, 10)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return wb; |
|
|
|
} |
|
|
|
|
|
|
|
private static HSSFCellStyle createCellStyle(HSSFWorkbook workbook, short fontsize, boolean flag, boolean flag1) { |
|
|
|
HSSFCellStyle style = workbook.createCellStyle(); |
|
|
|
style.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|