diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index 8ec69d35..d0773825 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -983,6 +983,7 @@ public class SocketDevResponseService { } + // key为 检测大项对应的code,value为当前大项的检测结果 Map> targetTestMap = new HashMap<>(); /** @@ -1028,6 +1029,7 @@ public class SocketDevResponseService { System.out.println(sourceIssue.getType() + sourceIssue.getIndex() + "当前测试大项已经全部结束》》》》》》》》"); //当residueCount为0则认为大项中的小项已经全部跑完,开始组装信息推送给前端 List resultList = new ArrayList<>(); + // 获取当前检测大项的所有设备的检测结果 List allDevTestList = targetTestMap.get(sourceIssue.getType()); Map> map = allDevTestList.stream().collect(Collectors.groupingBy(DevLineTestResult::getDeviceId)); map.forEach((dev, list) -> { @@ -1059,6 +1061,7 @@ public class SocketDevResponseService { List sourceIssueList = SocketManager.getSourceList(); if (CollUtil.isNotEmpty(sourceIssueList)) { SourceIssue sourceIssues = SocketManager.getSourceList().get(0); + // 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息 if (residueCount == 0) { CnSocketUtil.sendToWebSocket(param.getUserPageId(), sourceIssues.getType() + stepBegin, null, new ArrayList<>(), null); } diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java index 4f45494c..aa9bb0e5 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java @@ -351,7 +351,7 @@ public class SocketSourceResponseService { String s = param.getUserPageId() + DEV; SourceIssue sourceIssue = SocketManager.getSourceList().get(0); - List comm = sourceIssue.getDevValueTypeList(); + List comm = sourceIssue.getDevValueTypeList(); //形如:类型&小项code这种形式。例如:real$VRMS、real$IRMS System.out.println("向装置下发的参数>>>>>>>>" + comm); socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType()); int ignoreCount; diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java b/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java index 7b23e08e..1b804e24 100644 --- a/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java +++ b/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java @@ -21,7 +21,8 @@ public enum ReportResponseEnum { NO_CHECK_DATA("A012010", "没有检测数据,无法生成报告!"), FILE_RENAME_FAILED("A012011", "文件重命名失败"), REPORT_NAME_PATTERN_ERROR("A012012","报告名称格式错误,可包含中文、字母、数字、中划线,长度不能超过50个字符"), - REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误,可包含中文、字母、数字、中划线,点号,长度不能超过50个字符"); + REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误,可包含中文、字母、数字、中划线,点号,长度不能超过50个字符"), + FILE_SIZE_ERROR("A012014","文件大小不能超过5MB" ); private String code; private String message; 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 0893c51b..434e51ad 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 @@ -126,6 +126,8 @@ public class PqReportServiceImpl extends ServiceImpl i private final ISysUserService sysUserService; + private final long FILE_SIZE_LIMIT = 5 * 1024 * 1024; + @Override public Page list(ReportParam.QueryParam queryParam) { QueryWrapper wrapper = new QueryWrapper<>(); @@ -263,6 +265,9 @@ public class PqReportServiceImpl extends ServiceImpl i if (baseOriginalFilename.equals(detailOriginalFilename)) { throw new BusinessException(ReportResponseEnum.FILE_NAME_SAME_ERROR); } + if(baseFile.getSize() > FILE_SIZE_LIMIT || detailFile.getSize() > FILE_SIZE_LIMIT){ + throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR); + } pqReport.setBasePath(newDir + baseOriginalFilename); pqReport.setDetailPath(newDir + detailOriginalFilename); @@ -284,6 +289,9 @@ public class PqReportServiceImpl extends ServiceImpl i if (!baseFileOriginalFilename.endsWith(".docx")) { throw new BusinessException(ReportResponseEnum.FILE_SUFFIX_ERROR); } + if(baseFile.getSize() > FILE_SIZE_LIMIT){ + throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR); + } } String detailFileOriginalFilename = ""; @@ -292,6 +300,9 @@ public class PqReportServiceImpl extends ServiceImpl i if (!detailFileOriginalFilename.endsWith(".docx")) { throw new BusinessException(ReportResponseEnum.FILE_SUFFIX_ERROR); } + if(detailFile.getSize() > FILE_SIZE_LIMIT){ + throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR); + } } if (!"".equals(baseFileOriginalFilename) && !"".equals(detailFileOriginalFilename)) { diff --git a/system/src/main/java/com/njcn/gather/system/config/CustomCacheConfig.java b/system/src/main/java/com/njcn/gather/system/config/CustomCacheConfig.java deleted file mode 100644 index 60530f51..00000000 --- a/system/src/main/java/com/njcn/gather/system/config/CustomCacheConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.njcn.gather.system.config; - -import cn.hutool.extra.spring.SpringUtil; -import com.njcn.common.bean.CustomCacheUtil; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author caozehui - * @data 2025-03-24 - */ -@Configuration -public class CustomCacheConfig { - - /** - * 将自定缓存工具类注入到spring容器中 - * - * @return - */ - @Bean - public CustomCacheUtil customCacheUtil() { - CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME); - return customCacheUtil; - } - -} diff --git a/system/src/main/java/com/njcn/gather/system/config/WebConfig.java b/system/src/main/java/com/njcn/gather/system/config/WebConfig.java new file mode 100644 index 00000000..c47c723d --- /dev/null +++ b/system/src/main/java/com/njcn/gather/system/config/WebConfig.java @@ -0,0 +1,45 @@ +package com.njcn.gather.system.config; + +import cn.hutool.extra.spring.SpringUtil; +import com.njcn.common.bean.CustomCacheUtil; +import org.springframework.boot.web.servlet.MultipartConfigFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.util.unit.DataSize; + +import javax.servlet.MultipartConfigElement; + +/** + * @author caozehui + * @data 2025-03-24 + */ +@Configuration +public class WebConfig { + + /** + * 将自定缓存工具类注入到spring容器中 + * + * @return + */ + @Bean + public CustomCacheUtil customCacheUtil() { + CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME); + return customCacheUtil; + } + + /** + * 配置上传文件大小限制 + * + * @return + */ + @Bean + public MultipartConfigElement multipartConfigElement() { + MultipartConfigFactory factory = new MultipartConfigFactory(); + // 单个文件最大6MB + factory.setMaxFileSize(DataSize.ofMegabytes(6)); + // 整个请求最大12MB + factory.setMaxRequestSize(DataSize.ofMegabytes(12)); + return factory.createMultipartConfig(); + } + +}