Browse Source

绍兴新需求,归档导出报告

master
wangguangyuan 3 months ago
parent
commit
fe328025ac
10 changed files with 788 additions and 11 deletions
  1. +3
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/IPatrolResultService.java
  2. +145
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java
  3. +610
    -10
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java
  4. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/domain/PatrolTaskResultMain.java
  5. +2
    -1
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/mapper/PatrolTaskResultMainMapper.java
  6. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/IPatrolTaskResultMainService.java
  7. +4
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/impl/PatrolTaskResultMainServiceImpl.java
  8. +3
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/mapper/PatrolTaskStatusMapper.java
  9. +8
    -0
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskResultMainMapper.xml
  10. +9
    -0
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskStatusMapper.xml

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

@ -1,6 +1,7 @@
package com.inspect.partrolresult.service;
import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.insreport.domain.InspectionReport;
import com.inspect.partrolresult.domain.*;
import com.inspect.resultmain.domain.PatrolTaskResultMain;
import com.inspect.system.base.openDomain.BasedataEqpBookMoMain;
@ -98,4 +99,6 @@ public interface IPatrolResultService {
BasedataEqpBookChannel selectChannelName(String channelCode);
List<PatrolResult> selectPatrolResultListByMainIds(List<Long> mainIds);
InspectionReport getInspectionReport(List<Long> lineIds, PatrolTaskResultMain patrolTaskResultMain);
}

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

@ -1256,6 +1256,151 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
return patrolResultMapper.selectPatrolResultListByMainIds(mainIds);
}
@Override
public InspectionReport getInspectionReport(List<Long> lineIds, PatrolTaskResultMain patrolTaskResultMain) {
List<String> taskPatrolledIds = patrolTaskResultMain.getTaskPatrolledIds();
// 巡视统计描述
String patrolStatistics = statisticsAnalyseNumShaoxing(lineIds);
// 查询任务状态信息
List<PatrolTaskStatus> patrolTaskStatuses = patrolTaskStatusMapper.selectPatrolTaskStatusListByTaskPatrolledIds(taskPatrolledIds);
List<Date> startTimes = patrolTaskStatuses.stream().map(PatrolTaskStatus::getStartTime).sorted().collect(Collectors.toList());
List<String> endTimes = patrolTaskStatuses.stream().map(PatrolTaskStatus::getEndTime).sorted().collect(Collectors.toList());
// 查询巡视结果信息
List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(lineIds, null);
List<String> taskNames = patrolTaskStatuses.stream().map(PatrolTaskStatus::getTaskName).distinct().collect(Collectors.toList());
String taskName = StringUtils.join(taskNames, ",");
Map<String, String> stationMap = patrolResultMapper.selectBasedataStation();
String stationName = stationMap.get("station_name");
String stationType = stationMap.get("station_type");
String voltLevel = stationMap.get("volt_level");
AjaxResult ajaxResult = feignBasedataAreaService.evnList();
List<JSONObject> jsonObjects = JSONObject.parseArray(JSON.toJSONString(ajaxResult.get("data")), JSONObject.class);
log.info("EVN LIST: " + jsonObjects);
List<String> envoList = new ArrayList<>();
for (JSONObject jsonObject : jsonObjects) {
String typeName = jsonObject.getString("typeName");
String valueUnit = jsonObject.getString("valueUnit");
if (StringUtils.isEmpty(valueUnit) || StringUtils.isEmpty(typeName)) {
continue;
}
envoList.add(typeName + ":" + valueUnit);
}
InspectionReport report = new InspectionReport();
report.setInspectionDate(new Date());
// report.setTaskResultId(mainId);
report.setPatrolStatistics(patrolStatistics);
report.setInspectionStartTime(startTimes.get(0));
report.setInspectionEndTime(DateUtils.parseDate(endTimes.get(endTimes.size() - 1)));
// report.setTaskId(String.valueOf(task.getTaskId()));
report.setEnvInfo(StringUtils.join(envoList,","));
// report.setTaskPatrolledId(taskPatrolId);
report.setInspectionTaskName(taskName);
report.setDescription(patrolTaskResultMain.getTaskResult());
report.setCheckPerson(patrolTaskResultMain.getCheckPerson());
report.setCheckTime(new Date());
report.setStationName(stationName);
report.setVoltLevel(StringUtils.isEmpty(voltLevel) ? voltage : voltLevel);
// report.setFilter(String.valueOf(i));
report.setStationType(stationType);
if ("0".equals(exportReportFlag)) {
// 导出缺陷
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList());
}
List<BasePointAreaInfo> basePointAreaInfoList = patrolResultMapper.selectBaseInfoByMainIds(lineIds);
// log.info("batchInsertReportData basePointAreaInfoList:" + basePointAreaInfoList);
log.info("REPORTS SIZE: {}", patrolResultRefs.size());
List<InspectionReportData> reportDatas = new ArrayList<>();
long okNum = 1L;
long failNum = 1L;
long defectNum = 1L;
int index;
for (index = 0; index < patrolResultRefs.size(); ++index) {
PatrolResultRef patrolResultRef = patrolResultRefs.get(index);
String devType = patrolResultRef.getDevType();
BasePointAreaInfo basePointAreaInfo;
try {
basePointAreaInfo = basePointAreaInfoList.stream().filter((item) -> item != null && patrolResultRef.getDeviceId().equals(item.getDeviceId())).findFirst().get();
} catch (Exception e) {
log.error("[REPORT DETAIL] The point lacking belonging area: {}", patrolResultRef.getDeviceId());
basePointAreaInfo = new BasePointAreaInfo();
}
InspectionReportData reportData = new InspectionReportData();
reportData.setArea(basePointAreaInfo.getAreaName());
reportData.setTimeInterval(basePointAreaInfo.getJgName());
reportData.setEqName(basePointAreaInfo.getMainName());
reportData.setParts(basePointAreaInfo.getDeviceName());
reportData.setPointName(basePointAreaInfo.getPatrolPointName());
reportData.setDataSources("0".equals(devType) ? messageUtils.get("无人机") : "1".equals(devType) ? messageUtils.get("机器人") : messageUtils.get("高清视频"));
reportData.setAcquisitionTime(DateUtils.parse(DateUtils.yyyyMMddHHmmss2, patrolResultRef.getTime()));
if ("1".equals(patrolResultRef.getResultType()) && validAlgTypes.contains(patrolResultRef.getAlgType())) {
reportData.setInspectionResults(patrolResultRef.getValue());
} else {
reportData.setInspectionResults(patrolResultRef.getDescription());
}
reportData.setAlgName(patrolResultRef.getAlgName());
String threshold = patrolResultRef.getThreshold();
if(StringUtils.isBlank(threshold)) {
threshold = "";
}
if (threshold.contains("sub_53")) {
reportData.setInspectionResults(patrolResultRef.getValue());
}
if ((threshold.contains("sub_52") || threshold.contains("sub_53"))
&& !"0".equals(patrolResultRef.getValue())
&& !"1".equals(patrolResultRef.getValue())
&& !"-1".equals(patrolResultRef.getValue())
&& !"check image".equals(patrolResultRef.getValue())) {
reportData.setInspectionResults(patrolResultRef.getValue());
}
String resultType = patrolResultRef.getResultType();
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef);
if(resultType == null) {
continue;
} else if (resultType.equals("0")) {
reportData.setPointStatus(messageUtils.get("缺陷"));
// 缺陷编号
reportData.setCode(defectNum);
++defectNum;
} else if (resultType.equals("1")) {
reportData.setPointStatus(messageUtils.get("正常"));
reportData.setCode(okNum);
++okNum;
} else {
reportData.setPointStatus(messageUtils.get("异常"));
// 异常编号
reportData.setCode(failNum);
++failNum;
}
String resultContent = patrolResultRef.getResultContent();
AnalyseResPoint analyseResPoint = JSONObject.parseObject(resultContent, AnalyseResPoint.class);
String imgUrl = analyseResPoint.getResImageUrl();
if (StringUtils.isEmpty(imgUrl)) {
imgUrl = patrolResultRef.getFilePath().split(StringUtils.COMMA)[0];
}
List<InspectionReportImg> reportImages = new ArrayList<>();
InspectionReportImg reportImg = new InspectionReportImg();
reportImg.setImg(imgUrl);
reportImg.setImgSrc(imgUrl);
reportImg.setImgType("0");
reportImg.setCreatTime(new Date());
reportImages.add(reportImg);
reportData.setReportImgList(reportImages);
reportDatas.add(reportData);
}
report.setReportDatalist(reportDatas);
return report;
}
public static void main(String[] args) {
List<String> students = new ArrayList<>();
students.add("s1");


+ 610
- 10
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java View File

@ -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);


+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/domain/PatrolTaskResultMain.java View File

@ -77,6 +77,7 @@ public class PatrolTaskResultMain extends BaseEntity {
)
private String checkPerson;
private String taskPatrolledId;
private List<String> taskPatrolledIds;
private String unifiedTaskPatrolledId;
@JsonFormat(
@ -113,6 +114,7 @@ public class PatrolTaskResultMain extends BaseEntity {
", requestId='" + requestId + '\'' +
", checkPerson='" + checkPerson + '\'' +
", taskPatrolledId='" + taskPatrolledId + '\'' +
", taskPatrolledIds='" + taskPatrolledIds + '\'' +
", checkTime=" + checkTime +
'}';
}


+ 2
- 1
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/mapper/PatrolTaskResultMainMapper.java View File

@ -14,6 +14,8 @@ public interface PatrolTaskResultMainMapper {
PatrolTaskResultMain selectPatrolTaskResultMainByTaskPatrolledId(@Param("taskPatrolledId") String tasKPatrolledId);
List<PatrolTaskResultMain> selectPatrolTaskResultMainByTaskPatrolledIds(@Param("taskPatrolledIds") List<String> taskPatrolledIds);
List<PatrolTaskResultMain> selectPatrolTaskResultMain(PatrolTaskResultMain resultMain);
String selectUnifiedTaskPatrolledId(PatrolTaskResultMain resultMain);
@ -31,5 +33,4 @@ public interface PatrolTaskResultMainMapper {
List<Long> selectLineIds(Long lineId);
List<Long> selectLineIdsByList(@Param("lineIds") List<Long> lineIds);
}

+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/IPatrolTaskResultMainService.java View File

@ -11,6 +11,8 @@ public interface IPatrolTaskResultMainService {
PatrolTaskResultMain selectPatrolTaskResultMainByTaskPatrolledId(String taskPatrolledId);
List<PatrolTaskResultMain> selectPatrolTaskResultMainByTaskPatrolledIds(List<String> taskPatrolledIds);
List<PatrolTaskResultMain> selectPatrolTaskResultMain(PatrolTaskResultMain patrolTaskResultMain);
String selectUnifiedTaskPatrolledId(PatrolTaskResultMain patrolTaskResultMain);


+ 4
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/impl/PatrolTaskResultMainServiceImpl.java View File

@ -30,6 +30,10 @@ public class PatrolTaskResultMainServiceImpl implements IPatrolTaskResultMainSer
return this.patrolTaskResultMainMapper.selectPatrolTaskResultMainByTaskPatrolledId(taskPatrolledId);
}
public List<PatrolTaskResultMain> selectPatrolTaskResultMainByTaskPatrolledIds(List<String> taskPatrolledIds) {
return this.patrolTaskResultMainMapper.selectPatrolTaskResultMainByTaskPatrolledIds(taskPatrolledIds);
}
public List<PatrolTaskResultMain> selectPatrolTaskResultMain(PatrolTaskResultMain patrolTaskResultMain) {
return this.patrolTaskResultMainMapper.selectPatrolTaskResultMain(patrolTaskResultMain);
}


+ 3
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/mapper/PatrolTaskStatusMapper.java View File

@ -3,6 +3,7 @@ package com.inspect.taskstatus.mapper;
import com.inspect.taskstatus.domain.PatrolTaskStatus;
import com.inspect.taskstatus.domain.TaskCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -35,4 +36,6 @@ public interface PatrolTaskStatusMapper {
int deletePatrolTaskStatusByLineId(Long lineId);
int deletePatrolTaskStatusByLineIds(Long[] lineIds);
List<PatrolTaskStatus> selectPatrolTaskStatusListByTaskPatrolledIds(@Param("taskPatrolledIds") List<String> taskPatrolledIds);
}

+ 8
- 0
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskResultMainMapper.xml View File

@ -165,6 +165,14 @@
ORDER BY line_id desc limit 1
</select>
<select id="selectPatrolTaskResultMainByTaskPatrolledIds" resultMap="PatrolTaskResultMainResult">
<include refid="selectPatrolTaskResultMainVo"/>
where task_patrolled_id in
<foreach collection="taskPatrolledIds" item="taskPatrolledId" open="(" separator="," close=")">
#{taskPatrolledId}
</foreach>
</select>
<insert id="insertPatrolTaskResultMain" parameterType="PatrolTaskResultMain" useGeneratedKeys="true"
keyProperty="lineId">


+ 9
- 0
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskStatusMapper.xml View File

@ -194,6 +194,15 @@
where task_patrolled_id = #{taskPatrolledId}
</select>
<select id="selectPatrolTaskStatusListByTaskPatrolledIds"
resultMap="PatrolTaskStatusResult">
<include refid="selectPatrolTaskStatusVo"/>
where task_patrolled_id in
<foreach collection="taskPatrolledIds" item="taskPatrolledId" open="(" separator="," close=")">
#{taskPatrolledId}
</foreach>
</select>
<insert id="insertPatrolTaskStatus" parameterType="PatrolTaskStatus" useGeneratedKeys="true" keyProperty="lineId">
insert into patrol_task_status
<trim prefix="(" suffix=")" suffixOverrides=",">


Loading…
Cancel
Save