From ddf6da0855f82928e990ca148bbca3c249724234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BE=E5=90=8C=E5=AD=A6?= Date: Wed, 20 Aug 2025 11:27:42 +0800 Subject: [PATCH] =?UTF-8?q?ADD:=E5=AF=BC=E5=85=A5=E5=AD=90=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=85=83=E4=BF=A1=E6=81=AF=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/pojo/vo/AdSubPlanMetaDataVO.java | 2 + .../plan/service/impl/AdPlanServiceImpl.java | 46 +++++++++++++++---- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdSubPlanMetaDataVO.java b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdSubPlanMetaDataVO.java index 2acbfc54..fd90bda5 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdSubPlanMetaDataVO.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdSubPlanMetaDataVO.java @@ -4,6 +4,7 @@ import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.po.PqStandardDev; import com.njcn.gather.err.pojo.po.PqErrSys; import com.njcn.gather.err.pojo.po.PqErrSysDtls; +import com.njcn.gather.icd.pojo.po.PqIcdPath; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.report.pojo.po.PqReport; import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; @@ -26,6 +27,7 @@ public class AdSubPlanMetaDataVO { private List devList; private List standardDevList; private List devTypeList; + private List icdPathList; private List errSysList; private List errSysDtlsList; private PqReport reportTemplate; 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 43124cec..9a165fa8 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 @@ -38,6 +38,8 @@ import com.njcn.gather.err.pojo.po.PqErrSys; import com.njcn.gather.err.pojo.po.PqErrSysDtls; import com.njcn.gather.err.service.IPqErrSysDtlsService; import com.njcn.gather.err.service.IPqErrSysService; +import com.njcn.gather.icd.pojo.po.PqIcdPath; +import com.njcn.gather.icd.service.IPqIcdPathService; import com.njcn.gather.monitor.pojo.po.PqMonitor; import com.njcn.gather.monitor.service.IPqMonitorService; import com.njcn.gather.plan.mapper.AdPlanMapper; @@ -128,6 +130,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme private final IPqMonitorService pqMonitorService; private final IPqErrSysDtlsService pqErrSysDtlsService; private final IPqStandardDevService pqStandardDevService; + private final IPqIcdPathService pqIcdPathService; @Override public List listAdPlan(AdPlanParam.QueryParam queryParam) { @@ -286,7 +289,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme AdPlan plan1 = this.getById(param.getId()); // 更新子计划 String fatherPlanId = plan1.getFatherPlanId(); - if (StrUtil.isNotEmpty(fatherPlanId) && !StrUtil.equals(fatherPlanId,"0")) { + if (StrUtil.isNotEmpty(fatherPlanId) && !StrUtil.equals(fatherPlanId, "0")) { this.updateBindStandardDev(param.getId(), param.getStandardDevIds()); List list = new ArrayList<>(); @@ -1551,6 +1554,8 @@ public class AdPlanServiceImpl extends ServiceImpl impleme // 获取检设备类型数据 List devTypeList = devTypeService.list(); subPlanMetaData.setDevTypeList(devTypeList); + List pqIcdPathList = pqIcdPathService.list(); + subPlanMetaData.setIcdPathList(pqIcdPathList); // 获取检测计划绑定的被检设备数据 List devList = pqDevService.list(new QueryWrapper().eq("Plan_Id", planId)); @@ -1637,6 +1642,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme throw new BusinessException(CommonResponseEnum.FAIL); } } + @Transactional @Override public boolean importSubPlanDataZip(MultipartFile file, String patternId, HttpServletResponse response) { @@ -1675,17 +1681,19 @@ public class AdPlanServiceImpl extends ServiceImpl impleme FileUtil.del(tempDir); throw new BusinessException(CommonResponseEnum.FAIL, "ZIP文件中未找到检测计划信息"); } + // 检查导入的子计划是否属于当前模式 if (!StrUtil.equals(plan.getPattern(), patternId)) { FileUtil.del(tempDir); throw new BusinessException(CommonResponseEnum.FAIL, "该检修计划当前模式不支持导入"); } + // 更新检测计划信息 plan.setFatherPlanId(CommonEnum.FATHER_ID.getValue()); saveOrUpdate(plan); List devList = subPlanMetaDataVO.getDevList(); List standardDevList = subPlanMetaDataVO.getStandardDevList(); - if(CollUtil.isEmpty(devList) || CollUtil.isEmpty(standardDevList)) { + if (CollUtil.isEmpty(devList) || CollUtil.isEmpty(standardDevList)) { FileUtil.del(tempDir); throw new BusinessException(CommonResponseEnum.FAIL, "该检修计划未找到被检设备或标准设备信息"); } @@ -1702,7 +1710,12 @@ public class AdPlanServiceImpl extends ServiceImpl impleme pqDevSub.setCheckState(CheckStateEnum.UNCHECKED.getValue()); pqDevSub.setReportState(DevReportStateEnum.UNCHECKED.getValue()); pqDevSub.setCheckResult(CheckResultEnum.UNCHECKED.getValue()); - pqDevSubService.save(pqDevSub); + Integer count = pqDevSubService.lambdaQuery().eq(PqDevSub::getDevId, dev.getId()).count(); + if (count.intValue() == 0) { + pqDevSubService.save(pqDevSub); + } else { + pqDevSubService.update(pqDevSub, new LambdaUpdateWrapper().eq(PqDevSub::getDevId, dev.getId())); + } }); List devIds = devList.stream().map(PqDev::getId).collect(Collectors.toList()); // 守时检测 @@ -1720,7 +1733,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme if (CollUtil.isNotEmpty(typeList)) { dictTypeService.saveOrUpdateBatch(typeList); List dataList = dict.getDataList(); - if(CollUtil.isNotEmpty(dataList)) { + if (CollUtil.isNotEmpty(dataList)) { dictDataService.saveOrUpdateBatch(dataList); } } @@ -1748,6 +1761,11 @@ public class AdPlanServiceImpl extends ServiceImpl impleme List devTypeList = subPlanMetaDataVO.getDevTypeList(); if (CollUtil.isNotEmpty(devTypeList)) { devTypeService.saveOrUpdateBatch(devTypeList); + // 批量更新ICD路径数据 + List icdPathList = subPlanMetaDataVO.getIcdPathList(); + if (CollUtil.isNotEmpty(icdPathList)) { + pqIcdPathService.saveOrUpdateBatch(icdPathList); + } } tableGenService.deleteTable(Collections.singletonList(plan.getCode().toString())); tableGenService.genTable(plan.getCode().toString(), true); @@ -1755,16 +1773,26 @@ public class AdPlanServiceImpl extends ServiceImpl impleme // 更新报告模版 PqReport reportTemplate = subPlanMetaDataVO.getReportTemplate(); SpringUtil.getBean(IPqReportService.class).saveOrUpdate(reportTemplate); + // 模版文件复制到指定位置 + for (File f : files) { + if (f.isFile() && f.getName().endsWith(".docx")) { + String basePath = reportTemplate.getBasePath(); + // 将文件复制到basePath所在的目录下 + File baseFile = new File(basePath); + File baseDir = baseFile.getParentFile(); + if (!baseDir.exists()) { + baseDir.mkdirs(); + } + FileUtil.copy(f, baseDir, true); + } + } // 删除临时目录 FileUtil.del(tempDir); return true; - } catch (IOException e) { - log.error("导入子计划数据失败: ", e); - throw new BusinessException(CommonResponseEnum.FAIL); } catch (Exception e) { - log.error("处理JSON数据失败: ", e); - throw new BusinessException(CommonResponseEnum.FAIL); + log.error("导入子计划元信息zip失败: ", e); + throw new BusinessException(CommonResponseEnum.FAIL, "导入失败"); } }