报告模版新增pattern字段

This commit is contained in:
caozehui
2026-06-12 13:29:35 +08:00
parent e2c7e745c8
commit b35bbf11f7
12 changed files with 92 additions and 105 deletions

View File

@@ -112,25 +112,25 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
throw new BusinessException(IcdResponseEnum.FILE_NOT_NULL); throw new BusinessException(IcdResponseEnum.FILE_NOT_NULL);
} }
this.executeRestartCmd(commInstallPath); //this.executeRestartCmd(commInstallPath);
return this.save(pqIcdPath); return this.save(pqIcdPath);
} }
/** // /**
* 执行重启通讯服务脚本 // * 执行重启通讯服务脚本
* // *
* @param commInstallPath // * @param commInstallPath
*/ // */
private void executeRestartCmd(String commInstallPath) { // private void executeRestartCmd(String commInstallPath) {
// 以管理员身份运行bat脚本 // // 以管理员身份运行bat脚本
String batFilePath = commInstallPath + "\\重启所有服务.bat"; // String batFilePath = commInstallPath + "\\重启所有服务.bat";
try { // try {
Runtime.getRuntime().exec(batFilePath); // Runtime.getRuntime().exec(batFilePath);
} catch (IOException e) { // } catch (IOException e) {
log.error("重启通讯服务失败", e); // log.error("重启通讯服务失败", e);
} // }
} // }
private String getCommInstallPath() { private String getCommInstallPath() {
String workDir = System.getProperty("user.dir"); String workDir = System.getProperty("user.dir");
@@ -186,7 +186,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
} }
} }
this.executeRestartCmd(commInstallPath); //this.executeRestartCmd(commInstallPath);
return this.updateById(pqIcdPath); return this.updateById(pqIcdPath);
} }

View File

@@ -29,13 +29,4 @@ public interface AdPlanMapper extends MPJBaseMapper<AdPlan> {
* @return * @return
*/ */
PqReport getPqReportById(String id); PqReport getPqReportById(String id);
/**
* 获取所有报告模板名称
*
* @return
*/
List<String> listAllReportTemplateName();
} }

View File

@@ -2,7 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.gather.plan.mapper.AdPlanMapper"> <mapper namespace="com.njcn.gather.plan.mapper.AdPlanMapper">
<select id="getReportIdByNameAndVersion" resultType="java.lang.String"> <select id="getReportIdByNameAndVersion" resultType="java.lang.String">
SELECT id SELECT id
FROM pq_report FROM pq_report
@@ -17,10 +16,4 @@
WHERE id = #{id} WHERE id = #{id}
and state = 1 and state = 1
</select> </select>
<select id="listAllReportTemplateName" resultType="java.lang.String">
SELECT concat(name, '_', version) as name
FROM pq_report
WHERE state = 1
</select>
</mapper> </mapper>

View File

@@ -1906,7 +1906,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
pullDowns.add(pullDown); pullDowns.add(pullDown);
// 报告模板 // 报告模板
List<String> strings = this.baseMapper.listAllReportTemplateName(); List<String> strings = SpringUtil.getBean(IPqReportService.class).listOptions(patternId).stream()
.map(option -> option.getDisplayName())
.collect(Collectors.toList());
pullDown = new PullDown(); pullDown = new PullDown();
pullDown.setFirstCol(8); pullDown.setFirstCol(8);
pullDown.setLastCol(8); pullDown.setLastCol(8);

View File

@@ -134,11 +134,12 @@ public class ReportController extends BaseController {
} }
@OperateInfo @OperateInfo
@GetMapping("/listAllName") @GetMapping("/listOptions")
@ApiOperation("查询所有报告模板名称") @ApiOperation("查询所有报告模板名称")
public HttpResult<List<String>> listAllName() { public HttpResult<List<PqReportVO.OptionVO>> listOptions(@RequestParam("pattern") String pattern) {
String methodDescribe = getMethodDescribe("listAllName"); String methodDescribe = getMethodDescribe("listOptions");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe); LogUtil.njcnDebug(log, "{}锛屾煡璇㈠弬鏁颁负锛歿}", methodDescribe, pattern);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listOptions(pattern), methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)

View File

@@ -2,18 +2,17 @@ package com.njcn.gather.report.mapper;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.report.pojo.po.PqReport; 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; import java.util.List;
/**
* @author makejava
* @date 2025-03-19
*/
public interface PqReportMapper extends MPJBaseMapper<PqReport> { public interface PqReportMapper extends MPJBaseMapper<PqReport> {
/** /**
* 获取所有已被计划绑定的报告模板id * 获取所有已被计划绑定的报告模板id
* @return * @return
*/ */
List<String> getBoundReportIds(); List<String> getBoundReportIds();
}
List<PqReportVO.OptionVO> listOptionsByPattern(@Param("pattern") String pattern);
}

View File

@@ -2,9 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.gather.report.mapper.PqReportMapper"> <mapper namespace="com.njcn.gather.report.mapper.PqReportMapper">
<select id="getBoundReportIds" resultType="java.lang.String"> <select id="getBoundReportIds" resultType="java.lang.String">
select distinct Report_Template_Id from ad_plan where state = 1 select distinct Report_Template_Id from ad_plan where state = 1
</select> </select>
</mapper>
<select id="listOptionsByPattern" resultType="com.njcn.gather.report.pojo.vo.PqReportVO$OptionVO">
select
id,
name,
version,
concat(name, '_', version) as displayName
from pq_report
where state = 1
and pattern = #{pattern}
order by update_time desc
</select>
</mapper>

View File

@@ -6,10 +6,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
/**
* @author caozehui
* @data 2025-03-19
*/
@Data @Data
public class ReportParam { public class ReportParam {
@@ -19,23 +15,29 @@ public class ReportParam {
@ApiModelProperty(value = "版本号", required = true) @ApiModelProperty(value = "版本号", required = true)
private String version; private String version;
@ApiModelProperty(value = "模式id", required = true)
private String pattern;
@ApiModelProperty(value = "描述信息", required = true) @ApiModelProperty(value = "描述信息", required = true)
private String description; private String description;
@ApiModelProperty(value = "基础模板文件", required = true) @ApiModelProperty(value = "基础模板文件", required = true)
private MultipartFile baseFile; private MultipartFile baseFile;
@ApiModelProperty(value = "检测项模文件", required = true) @ApiModelProperty(value = "检测项模文件", required = true)
private MultipartFile detailFile; private MultipartFile detailFile;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam { public static class QueryParam extends BaseParam {
@ApiModelProperty(value = "报告模板名称", required = true) @ApiModelProperty(value = "报告模板名称")
private String name; private String name;
@ApiModelProperty(value = "版本号", required = true) @ApiModelProperty(value = "版本号")
private String version; private String version;
@ApiModelProperty(value = "模式id", required = true)
private String pattern;
} }
@Data @Data

View File

@@ -6,17 +6,13 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author makejava
* @date 2025-03-19
*/
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("pq_report") @TableName("pq_report")
public class PqReport extends BaseEntity implements Serializable { public class PqReport extends BaseEntity implements Serializable {
private static final long serialVersionUID = 582972970946593407L; private static final long serialVersionUID = 582972970946593407L;
/** /**
* 报告模板id * 报告模板id
*/ */
@@ -32,13 +28,18 @@ public class PqReport extends BaseEntity implements Serializable {
*/ */
private String version; private String version;
/**
* 模式id
*/
private String pattern;
/** /**
* 基础模板文件路径 * 基础模板文件路径
*/ */
private String basePath; private String basePath;
/** /**
* 检测项模文件路径 * 检测项模文件路径
*/ */
private String detailPath; private String detailPath;
@@ -52,4 +53,3 @@ public class PqReport extends BaseEntity implements Serializable {
*/ */
private Integer state; private Integer state;
} }

View File

@@ -9,60 +9,42 @@ import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/**
* @author caozehui
* @data 2025-03-19
*/
@Data @Data
public class PqReportVO { public class PqReportVO {
/**
* 报告模板id
*/
private String id; private String id;
/**
* 报告模板名称
*/
private String name; private String name;
/**
* 版本号
*/
private String version; private String version;
private String pattern;
/**
* 基础模板文件路径
*/
private FileVO baseFileVO; private FileVO baseFileVO;
/**
* 检测项模版文件路径
*/
private FileVO detailFileVO; private FileVO detailFileVO;
/**
* 描述信息
*/
private String description; private String description;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class) @JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime; private LocalDateTime createTime;
/**
* 状态0-删除 1-正常
*/
//private Integer state;
@Data @Data
public static class FileVO { public static class FileVO {
private String name; private String name;
private String url; private String url;
} }
@Data
public static class OptionVO {
private String id;
private String name;
private String version;
private String displayName;
}
} }

View File

@@ -55,19 +55,12 @@ public interface IPqReportService extends IService<PqReport> {
*/ */
boolean delete(List<String> ids); boolean delete(List<String> ids);
/** List<PqReportVO.OptionVO> listOptions(String pattern);
* 查询所有报告名称
*
* @return key为报告idvalue为报告名称
*/
List<String> listAllName();
void generateReport(DevReportParam devReportParam); void generateReport(DevReportParam devReportParam);
void downloadReport(DevReportParam devReportParam, HttpServletResponse response); void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
/** /**
* 设备归档操作 * 设备归档操作
* *
@@ -82,5 +75,4 @@ public interface IPqReportService extends IService<PqReport> {
* @param deviceIds 被检设备ID列表为空时上传所有已生成报告的设备 * @param deviceIds 被检设备ID列表为空时上传所有已生成报告的设备
*/ */
void uploadReportToCloud(List<String> deviceIds); void uploadReportToCloud(List<String> deviceIds);
} }

View File

@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.DataStateEnum; 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.pojo.exception.BusinessException;
import com.njcn.common.utils.images.ImageConverter; import com.njcn.common.utils.images.ImageConverter;
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant; import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
@@ -206,6 +207,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
QueryWrapper<PqReport> wrapper = new QueryWrapper<>(); QueryWrapper<PqReport> wrapper = new QueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName()) wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName())
.eq(StrUtil.isNotBlank(queryParam.getVersion()), "version", queryParam.getVersion()) .eq(StrUtil.isNotBlank(queryParam.getVersion()), "version", queryParam.getVersion())
.eq("pattern", queryParam.getPattern())
.eq("state", DataStateEnum.ENABLE.getCode()); .eq("state", DataStateEnum.ENABLE.getCode());
wrapper.orderByDesc("Update_Time"); wrapper.orderByDesc("Update_Time");
Page<PqReport> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper); Page<PqReport> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper);
@@ -307,11 +309,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
} }
@Override @Override
public List<String> listAllName() { public List<PqReportVO.OptionVO> listOptions(String pattern) {
List<PqReport> reportList = this.lambdaQuery() return this.baseMapper.listOptionsByPattern(pattern);
.eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).list();
List<String> collect = reportList.stream().map(pqReport -> pqReport.getName() + "_" + pqReport.getVersion()).collect(Collectors.toList());
return collect;
} }
/** /**
@@ -324,7 +323,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
private void uploadFile(ReportParam reportParam, PqReport pqReport, boolean isAdd) { private void uploadFile(ReportParam reportParam, PqReport pqReport, boolean isAdd) {
MultipartFile baseFile = reportParam.getBaseFile(); MultipartFile baseFile = reportParam.getBaseFile();
MultipartFile detailFile = reportParam.getDetailFile(); 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; String newDir = pathConfig.getReportTemplatePath() + File.separator + relativePath;
long FILE_SIZE_LIMIT = 5 * 1024 * 1024; long FILE_SIZE_LIMIT = 5 * 1024 * 1024;
@@ -2494,7 +2493,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
*/ */
private void checkRepeat(ReportParam reportParam, boolean isExcludeSelf) { private void checkRepeat(ReportParam reportParam, boolean isExcludeSelf) {
QueryWrapper<PqReport> wrapper = new QueryWrapper(); QueryWrapper<PqReport> wrapper = new QueryWrapper();
wrapper.eq("name", reportParam.getName()) wrapper.eq("pattern", reportParam.getPattern())
.eq("name", reportParam.getName())
.eq("version", reportParam.getVersion()) .eq("version", reportParam.getVersion())
.eq("state", DataStateEnum.ENABLE.getCode()); .eq("state", DataStateEnum.ENABLE.getCode());
if (isExcludeSelf) { if (isExcludeSelf) {
@@ -2508,6 +2508,21 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> 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 @Override
public void uploadReportToCloud(List<String> deviceIds) { public void uploadReportToCloud(List<String> deviceIds) {
log.info("开始批量上传检测报告到云端设备ID列表{}", deviceIds); log.info("开始批量上传检测报告到云端设备ID列表{}", deviceIds);