ADD:导入子计划元信息;
This commit is contained in:
@@ -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<PqDev> devList;
|
||||
private List<PqStandardDev> standardDevList;
|
||||
private List<DevType> devTypeList;
|
||||
private List<PqIcdPath> icdPathList;
|
||||
private List<PqErrSys> errSysList;
|
||||
private List<PqErrSysDtls> errSysDtlsList;
|
||||
private PqReport reportTemplate;
|
||||
|
||||
@@ -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<AdPlanMapper, AdPlan> impleme
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
private final IPqErrSysDtlsService pqErrSysDtlsService;
|
||||
private final IPqStandardDevService pqStandardDevService;
|
||||
private final IPqIcdPathService pqIcdPathService;
|
||||
|
||||
@Override
|
||||
public List<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam) {
|
||||
@@ -286,7 +289,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> 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<AdPlan> list = new ArrayList<>();
|
||||
@@ -1551,6 +1554,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
// 获取检设备类型数据
|
||||
List<DevType> devTypeList = devTypeService.list();
|
||||
subPlanMetaData.setDevTypeList(devTypeList);
|
||||
List<PqIcdPath> pqIcdPathList = pqIcdPathService.list();
|
||||
subPlanMetaData.setIcdPathList(pqIcdPathList);
|
||||
|
||||
// 获取检测计划绑定的被检设备数据
|
||||
List<PqDev> devList = pqDevService.list(new QueryWrapper<PqDev>().eq("Plan_Id", planId));
|
||||
@@ -1637,6 +1642,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> 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<AdPlanMapper, AdPlan> 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<PqDev> devList = subPlanMetaDataVO.getDevList();
|
||||
List<PqStandardDev> 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<AdPlanMapper, AdPlan> 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<PqDevSub>().eq(PqDevSub::getDevId, dev.getId()));
|
||||
}
|
||||
});
|
||||
List<String> devIds = devList.stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
// 守时检测
|
||||
@@ -1720,7 +1733,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
if (CollUtil.isNotEmpty(typeList)) {
|
||||
dictTypeService.saveOrUpdateBatch(typeList);
|
||||
List<DictData> dataList = dict.getDataList();
|
||||
if(CollUtil.isNotEmpty(dataList)) {
|
||||
if (CollUtil.isNotEmpty(dataList)) {
|
||||
dictDataService.saveOrUpdateBatch(dataList);
|
||||
}
|
||||
}
|
||||
@@ -1748,6 +1761,11 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<DevType> devTypeList = subPlanMetaDataVO.getDevTypeList();
|
||||
if (CollUtil.isNotEmpty(devTypeList)) {
|
||||
devTypeService.saveOrUpdateBatch(devTypeList);
|
||||
// 批量更新ICD路径数据
|
||||
List<PqIcdPath> 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<AdPlanMapper, AdPlan> 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, "导入失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user