From 2896d6fa447cf6a678ba27ba2e19224379f14dd4 Mon Sep 17 00:00:00 2001 From: 邱宇豪 <qyh123230312> Date: 星期五, 03 十一月 2023 16:48:43 +0800 Subject: [PATCH] 20231103_qiuyh_发运计划 --- hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java index 40f5c7f..0f80f09 100644 --- a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java +++ b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.Map; +import java.util.stream.Stream; /** * @Author QiuYuHao @@ -32,17 +33,18 @@ @Transactional(rollbackFor = Exception.class) public BasicResult insert(PipeOutPlanEntity pipeOutPlanEntity) { PipeOutPlanEntity isExit = pipeOutPlanMapper.selectInfoByProIdAndYear(pipeOutPlanEntity.getProId(), pipeOutPlanEntity.getPlanYear()); - if (isExit == null){ + if (isExit != null){ return BasicResult.faild("500","同一项目、年份有且只有一个计划",null); } String planOutId = UUIDUtils.create(); pipeOutPlanEntity.setPlanOutId(planOutId); pipeOutPlanMapper.insert(pipeOutPlanEntity); List<PipeOutPlanMothEntity> monthList = pipeOutPlanEntity.getMonthList(); - monthList.forEach(vo->{ + for (PipeOutPlanMothEntity vo : monthList) { vo.setPipeOutPlanId(planOutId); + vo.setId(UUIDUtils.create()); pipeOutPlanMapper.insertMoth(vo); - }); + } return BasicResult.success(); } @@ -58,17 +60,19 @@ @Transactional(rollbackFor = Exception.class) public BasicResult update(PipeOutPlanEntity pipeOutPlanEntity) { PipeOutPlanEntity isExit = pipeOutPlanMapper.selectInfoByProIdAndYear(pipeOutPlanEntity.getProId(), pipeOutPlanEntity.getPlanYear()); - if (isExit == null){ + if (!pipeOutPlanEntity.getPlanOutId().equals(isExit.getPlanOutId()) && isExit != null){ return BasicResult.faild("500","同一项目、年份有且只有一个计划",null); } pipeOutPlanMapper.update(pipeOutPlanEntity); String planOutId = pipeOutPlanEntity.getPlanOutId(); pipeOutPlanMapper.deleteMoth(planOutId); List<PipeOutPlanMothEntity> monthList = pipeOutPlanEntity.getMonthList(); - monthList.forEach(vo->{ + for (PipeOutPlanMothEntity vo : monthList) { vo.setPipeOutPlanId(planOutId); + vo.setId(UUIDUtils.create()); pipeOutPlanMapper.insertMoth(vo); - }); return BasicResult.success(); + } + return BasicResult.success(); } @Override @@ -90,7 +94,15 @@ all.forEach(obj->{ String proId = obj.getProId(); Integer planYear = obj.getPlanYear(); - obj.setMonthList(pipeOutPlanMapper.findMothListByProIdAndYear(proId,planYear.toString())); + String planOutId = obj.getPlanOutId(); + List<PipeOutPlanMothEntity> mothListByProIdAndYear = pipeOutPlanMapper.findMothListByProIdAndYear(proId, planYear.toString(), planOutId); + Integer completePlanProductNum = 0; + for (PipeOutPlanMothEntity pipeOutPlanMothEntity : mothListByProIdAndYear) { + Integer completePlanProduct = pipeOutPlanMothEntity.getCompletePlanProduct(); + completePlanProductNum+=completePlanProduct; + } + obj.setMonthList(mothListByProIdAndYear); + obj.setCompletePipeNum(completePlanProductNum); }); return BasicResult.success(new PageInfo<>(all)); } -- Gitblit v1.9.3