修改运行图相关数据导入导出逻辑
This commit is contained in:
parent
f7f6b4d77a
commit
c362c47fcd
@ -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<RunPlanTemplate> runPlanTemplates = runPlanTemplateDAO.selectByExampleWithBLOBs(runPlanTemplateExample);
|
||||
releaseVO.setRunPlanTemplateList(runPlanTemplates);
|
||||
|
||||
RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample();
|
||||
runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId);
|
||||
List<RunPlanLoad> runPlanLoads = runPlanLoadDAO.selectByExample(runPlanLoadExample);
|
||||
releaseVO.setRunPlanLoadList(runPlanLoads);
|
||||
|
||||
SchedulingPlanExample schedulingPlanExample = new SchedulingPlanExample();
|
||||
schedulingPlanExample.createCriteria().andMapIdEqualTo(mapId);
|
||||
List<SchedulingPlan> schedulingPlans = schedulingPlanDAO.selectByExampleWithBLOBs(schedulingPlanExample);
|
||||
if (!CollectionUtils.isEmpty(schedulingPlans)) {
|
||||
releaseVO.setSchedulingPlanList(schedulingPlans);
|
||||
}
|
||||
|
||||
if(!CollectionUtils.isEmpty(runPlanTemplates)){
|
||||
RunPlanTemplateVersionExample runPlanTemplateVersionExample = new RunPlanTemplateVersionExample();
|
||||
List<Long> runPlanTemplateIds = runPlanTemplates.stream().map(RunPlanTemplate::getId).collect(Collectors.toList());
|
||||
//运行图加载计划
|
||||
RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample();
|
||||
runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId).andTemplatePlanIdIn(runPlanTemplateIds);
|
||||
List<RunPlanLoad> runPlanLoads = runPlanLoadDAO.selectByExample(runPlanLoadExample);
|
||||
releaseVO.setRunPlanLoadList(runPlanLoads);
|
||||
//派班计划
|
||||
SchedulingPlanExample schedulingPlanExample = new SchedulingPlanExample();
|
||||
schedulingPlanExample.createCriteria().andMapIdEqualTo(mapId).andRunPlanIdIn(runPlanTemplateIds);
|
||||
List<SchedulingPlan> schedulingPlans = schedulingPlanDAO.selectByExampleWithBLOBs(schedulingPlanExample);
|
||||
if (!CollectionUtils.isEmpty(schedulingPlans)) {
|
||||
releaseVO.setSchedulingPlanList(schedulingPlans);
|
||||
}
|
||||
//运行图版本
|
||||
RunPlanTemplateVersionExample runPlanTemplateVersionExample = new RunPlanTemplateVersionExample();
|
||||
runPlanTemplateVersionExample.createCriteria().andPlanIdIn(runPlanTemplateIds);
|
||||
List<RunPlanTemplateVersion> 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<RunPlanLoad> runPlanLoads = releaseVO.getRunPlanLoadList();
|
||||
RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample();
|
||||
runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId);
|
||||
runPlanLoadDAO.deleteByExample(runPlanLoadExample);
|
||||
//删除旧的模板运行图数据
|
||||
//删除旧的运行图相关数据
|
||||
List<RunPlanTemplate> runPlanTemplates = releaseVO.getRunPlanTemplateList();
|
||||
RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample();
|
||||
runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId);
|
||||
List<RunPlanTemplate> oldRunPlanTemplates = runPlanTemplateDAO.selectByExample(runPlanTemplateExample);
|
||||
List<Long> oldRunPlanTemplateIds = oldRunPlanTemplates.stream().map(RunPlanTemplate::getId).collect(Collectors.toList());
|
||||
runPlanTemplateDAO.deleteByExample(runPlanTemplateExample);
|
||||
for (RunPlanTemplate runPlanTemplate : runPlanTemplates) {
|
||||
iRunPlanTemplateService.deletePlan(runPlanTemplate.getId(), user);
|
||||
}
|
||||
// //删除旧的运行图加载数据
|
||||
// List<RunPlanLoad> runPlanLoads = releaseVO.getRunPlanLoadList();
|
||||
// RunPlanLoadExample runPlanLoadExample = new RunPlanLoadExample();
|
||||
// runPlanLoadExample.createCriteria().andMapIdEqualTo(mapId);
|
||||
// runPlanLoadDAO.deleteByExample(runPlanLoadExample);
|
||||
// //删除旧的模板运行图数据
|
||||
// List<RunPlanTemplate> runPlanTemplates = releaseVO.getRunPlanTemplateList();
|
||||
// RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample();
|
||||
// runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId);
|
||||
// List<RunPlanTemplate> oldRunPlanTemplates = runPlanTemplateDAO.selectByExample(runPlanTemplateExample);
|
||||
// List<Long> oldRunPlanTemplateIds = oldRunPlanTemplates.stream().map(RunPlanTemplate::getId).collect(Collectors.toList());
|
||||
// runPlanTemplateDAO.deleteByExample(runPlanTemplateExample);
|
||||
//插入新的模板运行图数据并记录id变化
|
||||
Map<Long, Long> 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<RunPlanLoad> 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<SchedulingPlan> schedulingPlans = releaseVO.getSchedulingPlanList();
|
||||
@ -238,12 +251,12 @@ public class ReleaseService implements IReleaseService {
|
||||
}
|
||||
List<RunPlanTemplateVersion> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user