Browse Source

fix:巡视归档媒体包图片名修改

master
wangguangyuan 8 months ago
parent
commit
9d7f2f550e
2 changed files with 33 additions and 10 deletions
  1. +29
    -6
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java
  2. +4
    -4
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskResultMainMapper.xml

+ 29
- 6
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java View File

@ -208,7 +208,7 @@ public class PatrolTaskResultMainController extends BaseController {
(new Thread(() -> {
long beginTime = (new Date()).getTime();
logger.info("[EXPORT REPORTS] StartTime: {}, reportId: {}", DateUtil.now(), reportId);
exportExcelAndWord(String.valueOf(reportId));
exportExcelWordAndZip(String.valueOf(reportId));
PrintUtil.useTime("EXPORT REPORTS END", beginTime);
})).start();
return toAjax(1);
@ -672,8 +672,9 @@ public class PatrolTaskResultMainController extends BaseController {
}
}
public void exportExcelAndWord(String lineId) {
public void exportExcelWordAndZip(String lineId) {
List<String> images = new ArrayList<>();
Map<String, String> imgSrcToFileNameMap = new HashMap<>();
InspectionReport inspectionReport =
inspectionReportService.selectInspectionReportByLineId(Long.valueOf(lineId));
InspectionReportData inspectionReportData = new InspectionReportData();
@ -690,9 +691,31 @@ public class PatrolTaskResultMainController extends BaseController {
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")) {
images.add(reportImg.getImgSrc());
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",
pointName,
reportData.getLineId(),
imgIndex,
extension);
imgSrcToFileNameMap.put(originalImgSrc, uniqueFileName);
imgIndex++;
}
}
}
@ -728,10 +751,10 @@ public class PatrolTaskResultMainController extends BaseController {
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(fileName);
// String fileName = new File(imagePath).getName();
ZipEntry zipEntry = new ZipEntry(pointFileName);
zipOut.putNextEntry(zipEntry);
zipOut.write(imageData);
zipOut.closeEntry();


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

@ -75,18 +75,18 @@
SELECT
max(a.line_id) as line_id,
max(a.task_id) as task_id,
group_concat(a.task_patrolled_id) as task_patrolled_id,
group_concat(DISTINCT a.task_patrolled_id) as task_patrolled_id,
a.task_name as task_name,
max(a.task_code) as task_code,
max(a.create_time) as create_time,
a.create_by as create_by,
max(a.file_status) as file_status,
group_concat(a.area_name) as area_name,
group_concat(DISTINCT a.area_name) as area_name,
max(a.task_type) as task_type,
max(a.task_time) as task_time,
max(a.interval_name) as interval_name,
group_concat(a.dev_type) as dev_type,
group_concat(a.task_result) as task_result,
group_concat(DISTINCT a.dev_type) as dev_type,
group_concat(DISTINCT a.task_result) as task_result,
max(a.request_id) as request_id,
max(a.check_person) as check_person,
max(a.check_time) as check_time,


Loading…
Cancel
Save