diff --git a/src/main/java/club/joylink/rtss/services/ReleaseService.java b/src/main/java/club/joylink/rtss/services/ReleaseService.java index 9033e1482..57a62e9da 100644 --- a/src/main/java/club/joylink/rtss/services/ReleaseService.java +++ b/src/main/java/club/joylink/rtss/services/ReleaseService.java @@ -67,6 +67,9 @@ public class ReleaseService implements IReleaseService { @Autowired private IscsDAO iscsDAO; + @Autowired + private IRunPlanTemplateService iRunPlanTemplateService; + @Override public ReleaseVO exportAsJson(Long mapId, ReleaseConfigVO config) { ReleaseVO releaseVO = new ReleaseVO(mapId); @@ -83,27 +86,29 @@ public class ReleaseService implements IReleaseService { releaseVO.setRealLineConfig(realLine); if (config.isRunPlan()) { - this.confirmRunPlanExist(mapId); + //运行图模板 +// this.confirmRunPlanExist(mapId); RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample(); runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId); List runPlanTemplates = runPlanTemplateDAO.selectByExampleWithBLOBs(runPlanTemplateExample); releaseVO.setRunPlanTemplateList(runPlanTemplates); - RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample(); - runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId); - List runPlanLoads = runPlanLoadDAO.selectByExample(runPlanLoadExample); - releaseVO.setRunPlanLoadList(runPlanLoads); - - SchedulingPlanExample schedulingPlanExample = new SchedulingPlanExample(); - schedulingPlanExample.createCriteria().andMapIdEqualTo(mapId); - List schedulingPlans = schedulingPlanDAO.selectByExampleWithBLOBs(schedulingPlanExample); - if (!CollectionUtils.isEmpty(schedulingPlans)) { - releaseVO.setSchedulingPlanList(schedulingPlans); - } - if(!CollectionUtils.isEmpty(runPlanTemplates)){ - RunPlanTemplateVersionExample runPlanTemplateVersionExample = new RunPlanTemplateVersionExample(); List runPlanTemplateIds = runPlanTemplates.stream().map(RunPlanTemplate::getId).collect(Collectors.toList()); + //运行图加载计划 + RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample(); + runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId).andTemplatePlanIdIn(runPlanTemplateIds); + List runPlanLoads = runPlanLoadDAO.selectByExample(runPlanLoadExample); + releaseVO.setRunPlanLoadList(runPlanLoads); + //派班计划 + SchedulingPlanExample schedulingPlanExample = new SchedulingPlanExample(); + schedulingPlanExample.createCriteria().andMapIdEqualTo(mapId).andRunPlanIdIn(runPlanTemplateIds); + List schedulingPlans = schedulingPlanDAO.selectByExampleWithBLOBs(schedulingPlanExample); + if (!CollectionUtils.isEmpty(schedulingPlans)) { + releaseVO.setSchedulingPlanList(schedulingPlans); + } + //运行图版本 + RunPlanTemplateVersionExample runPlanTemplateVersionExample = new RunPlanTemplateVersionExample(); runPlanTemplateVersionExample.createCriteria().andPlanIdIn(runPlanTemplateIds); List runPlanTemplateVersions = runPlanTemplateVersionDAO.selectByExample(runPlanTemplateVersionExample); if (!CollectionUtils.isEmpty(runPlanTemplateVersions)) { @@ -194,18 +199,23 @@ public class ReleaseService implements IReleaseService { cacheController.remove(BusinessConsts.CachePrefix.Map + mapId); if (!CollectionUtils.isEmpty(releaseVO.getRunPlanTemplateList())) { - //删除旧的运行图加载数据 - List runPlanLoads = releaseVO.getRunPlanLoadList(); - RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample(); - runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId); - runPlanLoadDAO.deleteByExample(runPlanLoadExample); - //删除旧的模板运行图数据 + //删除旧的运行图相关数据 List runPlanTemplates = releaseVO.getRunPlanTemplateList(); - RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample(); - runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId); - List oldRunPlanTemplates = runPlanTemplateDAO.selectByExample(runPlanTemplateExample); - List oldRunPlanTemplateIds = oldRunPlanTemplates.stream().map(RunPlanTemplate::getId).collect(Collectors.toList()); - runPlanTemplateDAO.deleteByExample(runPlanTemplateExample); + for (RunPlanTemplate runPlanTemplate : runPlanTemplates) { + iRunPlanTemplateService.deletePlan(runPlanTemplate.getId(), user); + } +// //删除旧的运行图加载数据 +// List runPlanLoads = releaseVO.getRunPlanLoadList(); +// RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample(); +// runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId); +// runPlanLoadDAO.deleteByExample(runPlanLoadExample); +// //删除旧的模板运行图数据 +// List runPlanTemplates = releaseVO.getRunPlanTemplateList(); +// RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample(); +// runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId); +// List oldRunPlanTemplates = runPlanTemplateDAO.selectByExample(runPlanTemplateExample); +// List oldRunPlanTemplateIds = oldRunPlanTemplates.stream().map(RunPlanTemplate::getId).collect(Collectors.toList()); +// runPlanTemplateDAO.deleteByExample(runPlanTemplateExample); //插入新的模板运行图数据并记录id变化 Map runPlanTemplateIdMap = new HashMap<>(); for (RunPlanTemplate template : runPlanTemplates) { @@ -216,12 +226,15 @@ public class ReleaseService implements IReleaseService { runPlanTemplateIdMap.put(oldId, template.getId()); } //替换运行图加载数据关联的模版运行图id;插入运行图加载数据 - for (RunPlanLoad runPlanLoad : runPlanLoads) { - runPlanLoad.setId(null); - runPlanLoad.setMapId(mapId); - runPlanLoad.setTemplatePlanId(runPlanTemplateIdMap.get(runPlanLoad.getTemplatePlanId())); + List runPlanLoads = releaseVO.getRunPlanLoadList(); + if (!CollectionUtils.isEmpty(runPlanLoads)) { + for (RunPlanLoad runPlanLoad : runPlanLoads) { + runPlanLoad.setId(null); + runPlanLoad.setMapId(mapId); + runPlanLoad.setTemplatePlanId(runPlanTemplateIdMap.get(runPlanLoad.getTemplatePlanId())); + } + runPlanLoadDAO.batchInsertWithId(runPlanLoads); } - runPlanLoadDAO.batchInsertWithId(runPlanLoads); if (!CollectionUtils.isEmpty(releaseVO.getSchedulingPlanList())) { //删除旧的派班计划数据 List schedulingPlans = releaseVO.getSchedulingPlanList(); @@ -238,12 +251,12 @@ public class ReleaseService implements IReleaseService { } List runPlanTemplateVersionList = releaseVO.getRunPlanTemplateVersionList(); if (!CollectionUtils.isEmpty(runPlanTemplateVersionList)) { - //删除旧的运行图版本数据 - if (!CollectionUtils.isEmpty(oldRunPlanTemplateIds)) { - RunPlanTemplateVersionExample runPlanTemplateVersionExample = new RunPlanTemplateVersionExample(); - runPlanTemplateVersionExample.createCriteria().andPlanIdIn(oldRunPlanTemplateIds); - runPlanTemplateVersionDAO.deleteByExample(runPlanTemplateVersionExample); - } +// //删除旧的运行图版本数据 +// if (!CollectionUtils.isEmpty(oldRunPlanTemplateIds)) { +// RunPlanTemplateVersionExample runPlanTemplateVersionExample = new RunPlanTemplateVersionExample(); +// runPlanTemplateVersionExample.createCriteria().andPlanIdIn(oldRunPlanTemplateIds); +// runPlanTemplateVersionDAO.deleteByExample(runPlanTemplateVersionExample); +// } //替换运行图版本数据关联的模板运行图id;插入运行图版本数据 for (RunPlanTemplateVersion version : runPlanTemplateVersionList) { version.setId(null);