From e61f3a539207541051ede7e2b583528e8698e526 Mon Sep 17 00:00:00 2001 From: mashuai Date: Tue, 11 Mar 2025 10:59:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DevInfoServiceImpl.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index aac0c34..c41476b 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -121,6 +121,11 @@ public class DevInfoServiceImpl implements DevInfoService { } /*else if (item.getFileType().equals(Long.valueOf(EXAMINATION_PDF))) { devInfoVo.getExaminationPdf().add(item); }*/ else if (item.getFileType().equals(Long.valueOf(INSURANCE_PDF))) { + String result = ""; + if (StringUtils.isNotBlank(item.getFileName())) { + result = extracted(item.getFileName()); + } + item.setFileName("合格证" + result); devInfoVo.getInsurancePdf().add(item); } @@ -137,6 +142,13 @@ public class DevInfoServiceImpl implements DevInfoService { table.setCheckDate(qc.getQcTime()); table.setNextCheckDate(qc.getNextCheckTime()); List info = bmFileInfoMapper.getInfoByMaIdAndTaskId(qc); + for (BmFileInfo fileInfo : info) { + String result = ""; + if (StringUtils.isNotBlank(fileInfo.getFileName())) { + result = extracted(fileInfo.getFileName()); + } + fileInfo.setFileName("检测证明" + result); + } devInfoVo.getExaminationPdf().addAll(info); } tableList.add(table); @@ -187,6 +199,23 @@ public class DevInfoServiceImpl implements DevInfoService { return devInfoVo; } + /** + * 根据文件名截取文件名 + * @param fileName + */ + private String extracted(String fileName) { + String result = ""; + // 找到最后一个下划线的索引位置 + int underscoreIndex = fileName.lastIndexOf("_"); + // 找到点号的索引位置 + int dotIndex = fileName.lastIndexOf("."); + if (underscoreIndex != -1 && dotIndex != -1) { + // 从下划线的下一个位置开始截取到点号的位置 + result = fileName.substring(underscoreIndex + 1, dotIndex); + } + return result; + } + /** * 更新设备搜索量 *