From a07b4b6ff1c98dcf81338bb45d59308db7c058a9 Mon Sep 17 00:00:00 2001 From: 李旭东 <woaiguo66@sina.com> Date: 星期五, 03 十一月 2023 17:18:56 +0800 Subject: [PATCH] Merge branch 'master' of http://111.30.93.211:10101/r/supipe --- hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 112 insertions(+), 0 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 new file mode 100644 index 0000000..0f80f09 --- /dev/null +++ b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java @@ -0,0 +1,112 @@ +package com.thhy.materials.modules.biz.pipeoutplan.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.thhy.general.common.BasicResult; +import com.thhy.general.config.SysUserInfo; +import com.thhy.general.utils.UUIDUtils; +import com.thhy.general.utils.UserInfoUtils; +import com.thhy.materials.modules.biz.pipeoutplan.entity.PipeOutPlanEntity; +import com.thhy.materials.modules.biz.pipeoutplan.entity.PipeOutPlanMothEntity; +import com.thhy.materials.modules.biz.pipeoutplan.mapper.PipeOutPlanMapper; +import com.thhy.materials.modules.biz.pipeoutplan.service.PipeOutPlanService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +/** + * @Author QiuYuHao + * @CreateDate 2023-11-03 9:42:41 + * 发运管理逻辑实现层 + */ +@Service +public class PipeOutPlanServiceImpl implements PipeOutPlanService { + + @Autowired + private PipeOutPlanMapper pipeOutPlanMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public BasicResult insert(PipeOutPlanEntity pipeOutPlanEntity) { + PipeOutPlanEntity isExit = pipeOutPlanMapper.selectInfoByProIdAndYear(pipeOutPlanEntity.getProId(), pipeOutPlanEntity.getPlanYear()); + if (isExit != null){ + return BasicResult.faild("500","同一项目、年份有且只有一个计划",null); + } + String planOutId = UUIDUtils.create(); + pipeOutPlanEntity.setPlanOutId(planOutId); + pipeOutPlanMapper.insert(pipeOutPlanEntity); + List<PipeOutPlanMothEntity> monthList = pipeOutPlanEntity.getMonthList(); + for (PipeOutPlanMothEntity vo : monthList) { + vo.setPipeOutPlanId(planOutId); + vo.setId(UUIDUtils.create()); + pipeOutPlanMapper.insertMoth(vo); + } + return BasicResult.success(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public BasicResult delete(String pipeNeedId) { + pipeOutPlanMapper.delete(pipeNeedId); + pipeOutPlanMapper.deleteMoth(pipeNeedId); + return BasicResult.success(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public BasicResult update(PipeOutPlanEntity pipeOutPlanEntity) { + PipeOutPlanEntity isExit = pipeOutPlanMapper.selectInfoByProIdAndYear(pipeOutPlanEntity.getProId(), pipeOutPlanEntity.getPlanYear()); + 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(); + for (PipeOutPlanMothEntity vo : monthList) { + vo.setPipeOutPlanId(planOutId); + vo.setId(UUIDUtils.create()); + pipeOutPlanMapper.insertMoth(vo); + } + return BasicResult.success(); + } + + @Override + public BasicResult selectInfo(String pipeNeedId) { + PipeOutPlanEntity pipeOutPlanEntity = pipeOutPlanMapper.selectInfo(pipeNeedId); + List<PipeOutPlanMothEntity> mothList = pipeOutPlanMapper.findMothList(pipeNeedId); + pipeOutPlanEntity.setMonthList(mothList); + return BasicResult.success(pipeOutPlanEntity); + } + + @Override + public BasicResult findAll(Map<String, Object> map) { + Integer pageNum = (Integer) map.get("pageNum"); + Integer pageSize = (Integer) map.get("pageSize"); + PageHelper.startPage(pageNum,pageSize); + SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(); + map.put("companyId",userInfo.getCompanyId()); + List<PipeOutPlanEntity> all = pipeOutPlanMapper.findAll(map); + all.forEach(obj->{ + String proId = obj.getProId(); + Integer planYear = obj.getPlanYear(); + 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