diff --git a/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java b/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java index b4da9708..b66fb5f4 100644 --- a/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java @@ -112,25 +112,25 @@ public class PqIcdPathServiceImpl extends ServiceImpl { * @return */ PqReport getPqReportById(String id); - - /** - * 获取所有报告模板名称 - * - * @return - */ - List listAllReportTemplateName(); - } - diff --git a/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml b/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml index dd9a7351..f2cbd490 100644 --- a/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml +++ b/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml @@ -2,7 +2,6 @@ - - - diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 143afde3..2e8ded21 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -1906,7 +1906,9 @@ public class AdPlanServiceImpl extends ServiceImpl impleme pullDowns.add(pullDown); // 报告模板 - List strings = this.baseMapper.listAllReportTemplateName(); + List strings = SpringUtil.getBean(IPqReportService.class).listOptions(patternId).stream() + .map(option -> option.getDisplayName()) + .collect(Collectors.toList()); pullDown = new PullDown(); pullDown.setFirstCol(8); pullDown.setLastCol(8); diff --git a/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java b/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java index 60754ba1..a6ef3c9b 100644 --- a/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java +++ b/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java @@ -134,11 +134,12 @@ public class ReportController extends BaseController { } @OperateInfo - @GetMapping("/listAllName") + @GetMapping("/listOptions") @ApiOperation("查询所有报告模板名称") - public HttpResult> listAllName() { - String methodDescribe = getMethodDescribe("listAllName"); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe); + public HttpResult> listOptions(@RequestParam("pattern") String pattern) { + String methodDescribe = getMethodDescribe("listOptions"); + LogUtil.njcnDebug(log, "{}锛屾煡璇㈠弬鏁颁负锛歿}", methodDescribe, pattern); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listOptions(pattern), methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE) diff --git a/detection/src/main/java/com/njcn/gather/report/mapper/PqReportMapper.java b/detection/src/main/java/com/njcn/gather/report/mapper/PqReportMapper.java index 2fc9c2f2..36d0d1c0 100644 --- a/detection/src/main/java/com/njcn/gather/report/mapper/PqReportMapper.java +++ b/detection/src/main/java/com/njcn/gather/report/mapper/PqReportMapper.java @@ -2,18 +2,17 @@ package com.njcn.gather.report.mapper; import com.github.yulichang.base.MPJBaseMapper; import com.njcn.gather.report.pojo.po.PqReport; +import com.njcn.gather.report.pojo.vo.PqReportVO; +import org.apache.ibatis.annotations.Param; import java.util.List; -/** - * @author makejava - * @date 2025-03-19 - */ public interface PqReportMapper extends MPJBaseMapper { /** * 获取所有已被计划绑定的报告模板id * @return */ List getBoundReportIds(); -} + List listOptionsByPattern(@Param("pattern") String pattern); +} diff --git a/detection/src/main/java/com/njcn/gather/report/mapper/mapping/PqReportMapper.xml b/detection/src/main/java/com/njcn/gather/report/mapper/mapping/PqReportMapper.xml index a215e556..31c304b2 100644 --- a/detection/src/main/java/com/njcn/gather/report/mapper/mapping/PqReportMapper.xml +++ b/detection/src/main/java/com/njcn/gather/report/mapper/mapping/PqReportMapper.xml @@ -2,9 +2,19 @@ - - + + diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/param/ReportParam.java b/detection/src/main/java/com/njcn/gather/report/pojo/param/ReportParam.java index b574e788..56c84b46 100644 --- a/detection/src/main/java/com/njcn/gather/report/pojo/param/ReportParam.java +++ b/detection/src/main/java/com/njcn/gather/report/pojo/param/ReportParam.java @@ -6,10 +6,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.springframework.web.multipart.MultipartFile; -/** - * @author caozehui - * @data 2025-03-19 - */ @Data public class ReportParam { @@ -19,23 +15,29 @@ public class ReportParam { @ApiModelProperty(value = "版本号", required = true) private String version; + @ApiModelProperty(value = "模式id", required = true) + private String pattern; + @ApiModelProperty(value = "描述信息", required = true) private String description; @ApiModelProperty(value = "基础模板文件", required = true) private MultipartFile baseFile; - @ApiModelProperty(value = "检测项模版文件", required = true) + @ApiModelProperty(value = "检测项模板文件", required = true) private MultipartFile detailFile; @Data @EqualsAndHashCode(callSuper = true) public static class QueryParam extends BaseParam { - @ApiModelProperty(value = "报告模板名称", required = true) + @ApiModelProperty(value = "报告模板名称") private String name; - @ApiModelProperty(value = "版本号", required = true) + @ApiModelProperty(value = "版本号") private String version; + + @ApiModelProperty(value = "模式id", required = true) + private String pattern; } @Data diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/po/PqReport.java b/detection/src/main/java/com/njcn/gather/report/pojo/po/PqReport.java index 25c8b89e..f9459ea1 100644 --- a/detection/src/main/java/com/njcn/gather/report/pojo/po/PqReport.java +++ b/detection/src/main/java/com/njcn/gather/report/pojo/po/PqReport.java @@ -6,17 +6,13 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; -import java.time.LocalDateTime; -/** - * @author makejava - * @date 2025-03-19 - */ @Data @EqualsAndHashCode(callSuper = true) @TableName("pq_report") public class PqReport extends BaseEntity implements Serializable { private static final long serialVersionUID = 582972970946593407L; + /** * 报告模板id */ @@ -32,13 +28,18 @@ public class PqReport extends BaseEntity implements Serializable { */ private String version; + /** + * 模式id + */ + private String pattern; + /** * 基础模板文件路径 */ private String basePath; /** - * 检测项模版文件路径 + * 检测项模板文件路径 */ private String detailPath; @@ -52,4 +53,3 @@ public class PqReport extends BaseEntity implements Serializable { */ private Integer state; } - diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java b/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java index d7bbd885..4c15611a 100644 --- a/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java +++ b/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java @@ -9,60 +9,42 @@ import lombok.Data; import java.time.LocalDateTime; -/** - * @author caozehui - * @data 2025-03-19 - */ @Data public class PqReportVO { - /** - * 报告模板id - */ private String id; - /** - * 报告模板名称 - */ private String name; - /** - * 版本号 - */ private String version; + private String pattern; - /** - * 基础模板文件路径 - */ private FileVO baseFileVO; - /** - * 检测项模版文件路径 - */ private FileVO detailFileVO; - /** - * 描述信息 - */ private String description; - /** - * 创建时间 - */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonSerialize(using = LocalDateTimeSerializer.class) private LocalDateTime createTime; - /** - * 状态:0-删除 1-正常 - */ - //private Integer state; - @Data - public static class FileVO{ + public static class FileVO { private String name; private String url; } + + @Data + public static class OptionVO { + private String id; + + private String name; + + private String version; + + private String displayName; + } } diff --git a/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java b/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java index 1045c03d..0c58432d 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java +++ b/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java @@ -55,19 +55,12 @@ public interface IPqReportService extends IService { */ boolean delete(List ids); - /** - * 查询所有报告名称 - * - * @return key为报告id,value为报告名称 - */ - List listAllName(); + List listOptions(String pattern); void generateReport(DevReportParam devReportParam); - void downloadReport(DevReportParam devReportParam, HttpServletResponse response); - /** * 设备归档操作 * @@ -82,5 +75,4 @@ public interface IPqReportService extends IService { * @param deviceIds 被检设备ID列表,为空时上传所有已生成报告的设备 */ void uploadReportToCloud(List deviceIds); - } diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java index e3e8eea4..08447229 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java @@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.utils.images.ImageConverter; import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant; @@ -206,6 +207,7 @@ public class PqReportServiceImpl extends ServiceImpl i QueryWrapper wrapper = new QueryWrapper<>(); wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName()) .eq(StrUtil.isNotBlank(queryParam.getVersion()), "version", queryParam.getVersion()) + .eq("pattern", queryParam.getPattern()) .eq("state", DataStateEnum.ENABLE.getCode()); wrapper.orderByDesc("Update_Time"); Page page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper); @@ -307,11 +309,8 @@ public class PqReportServiceImpl extends ServiceImpl i } @Override - public List listAllName() { - List reportList = this.lambdaQuery() - .eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).list(); - List collect = reportList.stream().map(pqReport -> pqReport.getName() + "_" + pqReport.getVersion()).collect(Collectors.toList()); - return collect; + public List listOptions(String pattern) { + return this.baseMapper.listOptionsByPattern(pattern); } /** @@ -324,7 +323,7 @@ public class PqReportServiceImpl extends ServiceImpl i private void uploadFile(ReportParam reportParam, PqReport pqReport, boolean isAdd) { MultipartFile baseFile = reportParam.getBaseFile(); MultipartFile detailFile = reportParam.getDetailFile(); - String relativePath = reportParam.getName() + File.separator + reportParam.getVersion() + File.separator; + String relativePath = this.buildReportTemplateRelativeDir(reportParam.getPattern(), reportParam.getName(), reportParam.getVersion()); String newDir = pathConfig.getReportTemplatePath() + File.separator + relativePath; long FILE_SIZE_LIMIT = 5 * 1024 * 1024; @@ -2494,7 +2493,8 @@ public class PqReportServiceImpl extends ServiceImpl i */ private void checkRepeat(ReportParam reportParam, boolean isExcludeSelf) { QueryWrapper wrapper = new QueryWrapper(); - wrapper.eq("name", reportParam.getName()) + wrapper.eq("pattern", reportParam.getPattern()) + .eq("name", reportParam.getName()) .eq("version", reportParam.getVersion()) .eq("state", DataStateEnum.ENABLE.getCode()); if (isExcludeSelf) { @@ -2508,6 +2508,21 @@ public class PqReportServiceImpl extends ServiceImpl i } } + private String sanitizePathSegment(String value) { + return StrUtil.blankToDefault(value, StrUtil.EMPTY).replaceAll("[\\\\/:*?\"<>|]", "_").trim(); + } + + private String buildReportTemplateRelativeDir(String patternId, String name, String version) { + DictData dictData = dictDataService.getDictDataById(patternId); + if (ObjectUtil.isNull(dictData) || StrUtil.isBlank(dictData.getName())) { + throw new BusinessException(CommonResponseEnum.FAIL, "模式不存在或字典名称缺失"); + } + String patternName = this.sanitizePathSegment(dictData.getName()); + String reportName = this.sanitizePathSegment(name); + String reportVersion = this.sanitizePathSegment(version); + return patternName + File.separator + reportName + File.separator + reportVersion + File.separator; + } + @Override public void uploadReportToCloud(List deviceIds) { log.info("开始批量上传检测报告到云端,设备ID列表:{}", deviceIds);