diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/websocket/WebSocketHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/websocket/WebSocketHandler.java index 30584eb5..a7ed7dcb 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/websocket/WebSocketHandler.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/websocket/WebSocketHandler.java @@ -5,9 +5,7 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.util.socket.CnSocketUtil; import com.njcn.gather.detection.util.socket.FormalTestManager; -import com.njcn.gather.detection.util.socket.SocketManager; import com.njcn.gather.device.pojo.enums.PatternEnum; -import com.njcn.gather.plan.pojo.enums.DataSourceEnum; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.CorruptedFrameException; @@ -373,40 +371,43 @@ public class WebSocketHandler extends SimpleChannelInboundHandler implements LambdaUpdateChainWrapper w = pqDevSubService.lambdaUpdate() .set(PqDevSub::getCheckState, checkState) .set(PqDevSub::getCheckResult, checkResult) + .set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue()) .set(PqDevSub::getCheckTime, LocalDateTime.now()) .eq(PqDevSub::getDevId, devId); - if(ObjectUtil.isNotNull(user)){ + if (ObjectUtil.isNotNull(user)) { w.set(PqDevSub::getCheckBy, user.getName()); } - if(checkState.equals(CheckStateEnum.CHECKED.getValue())){ + if (checkState.equals(CheckStateEnum.CHECKED.getValue())) { w.set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue()); } w.update(); @@ -552,15 +554,23 @@ public class PqDevServiceImpl extends ServiceImpl implements List pqDevVOList = this.baseMapper.selectByQueryParam(param); if (CollUtil.isNotEmpty(pqDevVOList)) { - Set set = pqDevVOList.stream().map(PqDevVO::getCheckResult).collect(Collectors.toSet()); - if (set.contains(CheckResultEnum.NOT_ACCORD.getValue())) { - this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.NOT_ACCORD.getValue()); - } else if (set.contains(CheckResultEnum.UNCHECKED.getValue())) { + Set set = pqDevVOList.stream().filter(obj -> CheckStateEnum.CHECKED.getValue().equals(obj.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).map(PqDevVO::getCheckResult).collect(Collectors.toSet()); + if (checkState == CheckStateEnum.CHECKED.getValue()) { + set.add(checkResult); + } + if (CollUtil.isEmpty(set)) { this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.UNCHECKED.getValue()); } else { - this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.ACCORD.getValue()); + if (set.contains(CheckResultEnum.NOT_ACCORD.getValue())) { + this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.NOT_ACCORD.getValue()); + } else if (set.contains(CheckResultEnum.UNCHECKED.getValue())) { + this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.UNCHECKED.getValue()); + } else { + this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.ACCORD.getValue()); + } } + set = pqDevVOList.stream().map(PqDevVO::getCheckState).collect(Collectors.toSet()); if (set.contains(CheckStateEnum.UNCHECKED.getValue())) { this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue()); 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 ca29f2ff..4581d8d2 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 @@ -207,7 +207,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme } List pqDevVOList = pqDevMapper.selectByQueryParam(queryParam1); if (CollUtil.isNotEmpty(pqDevVOList)) { - long count = pqDevVOList.stream().filter(pqDev -> CheckStateEnum.CHECKED.getValue().equals(pqDev.getCheckState())).count(); + long count = pqDevVOList.stream().filter(pqDev -> CheckStateEnum.CHECKED.getValue().equals(pqDev.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(pqDev.getCheckState())).count(); adPlanVO.setProgress((float) count / pqDevVOList.size()); } else { adPlanVO.setProgress(0.0f); @@ -531,7 +531,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme @Override public List> listByPattern(String pattern) { - List adPlanList = this.lambdaQuery().eq(AdPlan::getPattern, pattern).eq(AdPlan::getState, DataStateEnum.ENABLE.getCode()).list(); + List adPlanList = this.lambdaQuery().eq(AdPlan::getPattern, pattern).eq(AdPlan::getState, DataStateEnum.ENABLE.getCode()).orderByDesc(AdPlan::getCreateTime).list(); Map> map1 = adPlanList.stream().collect(Collectors.groupingBy(AdPlan::getTestState)); List> result = new ArrayList<>(); 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 042594eb..571a2d87 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 @@ -35,14 +35,14 @@ import java.util.List; @RestController @RequestMapping("/report") @RequiredArgsConstructor -public class ReportController extends BaseController { +public class ReportController extends BaseController { private final IPqReportService pqReportService; /** * 此方法临时的,给楼下使用,实际需要优化 * 1、不同的设备需要不同的模板; - * 2、数据页的内容暂时是固定的,后期可能是动态的; + * 2、数据页的内容暂时是固定的,后期可能是动态 的; */ @OperateInfo @PostMapping("/generateReport") 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 f89112d9..b8abd88c 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 @@ -89,7 +89,6 @@ import org.docx4j.jaxb.Context; import org.docx4j.openpackaging.packages.WordprocessingMLPackage; import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; import org.docx4j.wml.*; -import org.docx4j.wml.Color; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; @@ -571,7 +570,6 @@ public class PqReportServiceImpl extends ServiceImpl i /** - * * 根据设备类型生成报告 * 注:该方法目前仅支持楼下出厂检测场景,属于模板占位符替换方式,后期可能会有调整 * @@ -809,10 +807,10 @@ public class PqReportServiceImpl extends ServiceImpl i ensureDirectoryExists(dirPath); // 构建文件名:cityName_gdName_subName_name.docx String fileName = String.format("%s_%s_%s_%s.docx", - pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市", - pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司", - pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站", - pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备"); + pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市", + pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司", + pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站", + pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备"); Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument); baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName))); this.updateDevAndPlanState(devId, devReportParam.getPlanId()); @@ -1065,7 +1063,6 @@ public class PqReportServiceImpl extends ServiceImpl i * 实时数据:3秒数据(150周波数据) * 录波:录波数据 * 分钟统计数据:分钟统计数据-最大值、分钟统计数据-最小值、分钟统计数据-平均值、分钟统计数据-CP95值 - * */ private String getDataTypeFromParam(AdPlan adPlan) { String dataSource = adPlan.getDatasourceId(); @@ -1088,11 +1085,11 @@ public class PqReportServiceImpl extends ServiceImpl i AdPlanTestConfig adPlanTestConfig = adPlanTestConfigService.getByPlanId(adPlan.getId()); StringBuilder sampleCount = new StringBuilder(); for (String item : dataSourceArray) { - if(item.equalsIgnoreCase(DataSourceEnum.REAL_DATA.getValue())){ + if (item.equalsIgnoreCase(DataSourceEnum.REAL_DATA.getValue())) { sampleCount.append("实时数据采集").append(adPlanTestConfig.getRealTime()).append("组,"); - }else if(item.equalsIgnoreCase(DataSourceEnum.WAVE_DATA.getValue())){ + } else if (item.equalsIgnoreCase(DataSourceEnum.WAVE_DATA.getValue())) { sampleCount.append("录波数据采集").append(adPlanTestConfig.getWaveRecord()).append("组,"); - }else{ + } else { sampleCount.append("统计数据采集").append(adPlanTestConfig.getStatistics()).append("组,"); } } @@ -1805,10 +1802,10 @@ public class PqReportServiceImpl extends ServiceImpl i if (dictDataById != null && "Contrast".equals(dictDataById.getCode())) { // 比对模式:使用新的路径结构 String fileName = String.format("%s_%s_%s_%s.docx", - pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市", - pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司", - pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站", - pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备"); + pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市", + pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司", + pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站", + pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备"); filePath = reportPath.concat(File.separator).concat(plan.getName()).concat(File.separator).concat(fileName); downloadFileName = fileName; } else { @@ -1837,7 +1834,7 @@ public class PqReportServiceImpl extends ServiceImpl i try { // 对中文文件名进行URL编码// 将+号替换为%20(空格的正确编码) String encodedFileName = URLEncoder.encode(downloadFileName, "UTF-8") - .replaceAll("\\+", "%20"); + .replaceAll("\\+", "%20"); // 使用RFC 5987标准格式 response.setHeader("Content-Disposition", @@ -1879,12 +1876,12 @@ public class PqReportServiceImpl extends ServiceImpl i for (int i = 0; i < pqDevVOList.size(); i++) { pqDevVO = pqDevVOList.get(i); + tempPqDevVO = pqDevVO; if (!pqDevVO.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) { throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED); } if (!pqDevVO.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) { devIds.add(pqDevVO.getId()); - tempPqDevVO = pqDevVO; } } @@ -1986,7 +1983,6 @@ public class PqReportServiceImpl extends ServiceImpl i } /** - * * 比对模式下需要获取的数据 * 处理基础模版中的信息,非数据页报告 * 因为Docx4j工具包替换时会默认增加${}