报告模版新增pattern字段
This commit is contained in:
@@ -112,25 +112,25 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
throw new BusinessException(IcdResponseEnum.FILE_NOT_NULL);
|
||||
}
|
||||
|
||||
this.executeRestartCmd(commInstallPath);
|
||||
//this.executeRestartCmd(commInstallPath);
|
||||
|
||||
return this.save(pqIcdPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行重启通讯服务脚本
|
||||
*
|
||||
* @param commInstallPath
|
||||
*/
|
||||
private void executeRestartCmd(String commInstallPath) {
|
||||
// 以管理员身份运行bat脚本
|
||||
String batFilePath = commInstallPath + "\\重启所有服务.bat";
|
||||
try {
|
||||
Runtime.getRuntime().exec(batFilePath);
|
||||
} catch (IOException e) {
|
||||
log.error("重启通讯服务失败", e);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * 执行重启通讯服务脚本
|
||||
// *
|
||||
// * @param commInstallPath
|
||||
// */
|
||||
// private void executeRestartCmd(String commInstallPath) {
|
||||
// // 以管理员身份运行bat脚本
|
||||
// String batFilePath = commInstallPath + "\\重启所有服务.bat";
|
||||
// try {
|
||||
// Runtime.getRuntime().exec(batFilePath);
|
||||
// } catch (IOException e) {
|
||||
// log.error("重启通讯服务失败", e);
|
||||
// }
|
||||
// }
|
||||
|
||||
private String getCommInstallPath() {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -29,13 +29,4 @@ public interface AdPlanMapper extends MPJBaseMapper<AdPlan> {
|
||||
* @return
|
||||
*/
|
||||
PqReport getPqReportById(String id);
|
||||
|
||||
/**
|
||||
* 获取所有报告模板名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<String> listAllReportTemplateName();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<!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">
|
||||
|
||||
|
||||
<select id="getReportIdByNameAndVersion" resultType="java.lang.String">
|
||||
SELECT id
|
||||
FROM pq_report
|
||||
@@ -17,10 +16,4 @@
|
||||
WHERE id = #{id}
|
||||
and state = 1
|
||||
</select>
|
||||
<select id="listAllReportTemplateName" resultType="java.lang.String">
|
||||
SELECT concat(name, '_', version) as name
|
||||
FROM pq_report
|
||||
WHERE state = 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -1906,7 +1906,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
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.setFirstCol(8);
|
||||
pullDown.setLastCol(8);
|
||||
|
||||
@@ -134,11 +134,12 @@ public class ReportController extends BaseController {
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/listAllName")
|
||||
@GetMapping("/listOptions")
|
||||
@ApiOperation("查询所有报告模板名称")
|
||||
public HttpResult<List<String>> listAllName() {
|
||||
String methodDescribe = getMethodDescribe("listAllName");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe);
|
||||
public HttpResult<List<PqReportVO.OptionVO>> 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)
|
||||
|
||||
@@ -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<PqReport> {
|
||||
/**
|
||||
* 获取所有已被计划绑定的报告模板id
|
||||
* @return
|
||||
*/
|
||||
List<String> getBoundReportIds();
|
||||
}
|
||||
|
||||
List<PqReportVO.OptionVO> listOptionsByPattern(@Param("pattern") String pattern);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,19 @@
|
||||
<!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">
|
||||
|
||||
|
||||
<select id="getBoundReportIds" resultType="java.lang.String">
|
||||
select distinct Report_Template_Id from ad_plan where state = 1
|
||||
</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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +55,12 @@ public interface IPqReportService extends IService<PqReport> {
|
||||
*/
|
||||
boolean delete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 查询所有报告名称
|
||||
*
|
||||
* @return key为报告id,value为报告名称
|
||||
*/
|
||||
List<String> listAllName();
|
||||
List<PqReportVO.OptionVO> listOptions(String pattern);
|
||||
|
||||
void generateReport(DevReportParam devReportParam);
|
||||
|
||||
|
||||
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
||||
|
||||
|
||||
/**
|
||||
* 设备归档操作
|
||||
*
|
||||
@@ -82,5 +75,4 @@ public interface IPqReportService extends IService<PqReport> {
|
||||
* @param deviceIds 被检设备ID列表,为空时上传所有已生成报告的设备
|
||||
*/
|
||||
void uploadReportToCloud(List<String> deviceIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -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<PqReportMapper, PqReport> i
|
||||
QueryWrapper<PqReport> 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<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
|
||||
public List<String> listAllName() {
|
||||
List<PqReport> reportList = this.lambdaQuery()
|
||||
.eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<String> collect = reportList.stream().map(pqReport -> pqReport.getName() + "_" + pqReport.getVersion()).collect(Collectors.toList());
|
||||
return collect;
|
||||
public List<PqReportVO.OptionVO> listOptions(String pattern) {
|
||||
return this.baseMapper.listOptionsByPattern(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +323,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> 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<PqReportMapper, PqReport> i
|
||||
*/
|
||||
private void checkRepeat(ReportParam reportParam, boolean isExcludeSelf) {
|
||||
QueryWrapper<PqReport> 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<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
|
||||
public void uploadReportToCloud(List<String> deviceIds) {
|
||||
log.info("开始批量上传检测报告到云端,设备ID列表:{}", deviceIds);
|
||||
|
||||
Reference in New Issue
Block a user