From 59f80df1e377e8775969ca4acadfa2eadd6e37ae Mon Sep 17 00:00:00 2001 From: zhangchao <zc857179121@qq.com> Date: 星期一, 04 十一月 2024 19:01:38 +0800 Subject: [PATCH] excel导出优化 --- src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java | 120 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 95 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java index 6a6a33f..7f731bf 100644 --- a/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.core.common.Cools; -import com.core.exception.CoolException; import com.zy.asrs.entity.ManLocDetl; import com.zy.asrs.entity.Mat; import com.zy.asrs.entity.Node; @@ -17,6 +16,7 @@ import com.zy.asrs.service.NodeService; import com.zy.asrs.service.WaitPakinService; import com.zy.asrs.utils.SaasUtils; +import com.zy.asrs.utils.Utils; import com.zy.common.model.LocDto; import com.zy.system.entity.User; import org.springframework.beans.BeanUtils; @@ -154,33 +154,101 @@ @Override public void adjustLocDetl(LocDetlAdjustParam param, Long userId, User user) { Date now = new Date(); - for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()) { - ManLocDetl manLocDetl = this.baseMapper.selectItem(param.getLocNo(), locDetlAdjust.getMatnr(), locDetlAdjust.getBatch(),locDetlAdjust.getThreeCode(),locDetlAdjust.getDeadTime(),locDetlAdjust.getSuppCode()); + List<ManLocDetl> manLocDetls = this.selectList(new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo())); + for (ManLocDetl manLocDetl : manLocDetls){ + Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo()); + wrapper.eq("matnr",manLocDetl.getMatnr()); + Utils.wapperSetCondition(wrapper,"container_code",manLocDetl.getContainerCode()); + Utils.wapperSetCondition(wrapper,"batch",manLocDetl.getBatch()); + Utils.wapperSetCondition(wrapper,"csocode",manLocDetl.getCsocode()); + Utils.wapperSetCondition(wrapper,"isoseq",manLocDetl.getIsoseq()); - if(Cools.isEmpty(manLocDetl)){ - addManlocDetl(locDetlAdjust,param.getLocNo()); - continue; + boolean existFlag = false; + for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()){ + if(Cools.eq(manLocDetl.getMatnr(),locDetlAdjust.getMatnr()) + && Cools.eq(manLocDetl.getContainerCode(),locDetlAdjust.getSuppCode()) + && Cools.eq(manLocDetl.getBatch(),locDetlAdjust.getBatch()) + && Cools.eq(manLocDetl.getCsocode(),locDetlAdjust.getThreeCode()) + && Cools.eq(manLocDetl.getIsoseq(),locDetlAdjust.getDeadTime())){ + if(!locDetlAdjust.getCount().equals(manLocDetl.getAnfme())){ + manLocDetl.setAnfme(locDetlAdjust.getCount()); + manLocDetl.setModiTime(now); + this.update(manLocDetl,wrapper); + SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername()); + } + existFlag = true; + } } - - this.baseMapper.delete(new EntityWrapper<ManLocDetl>() - .eq("loc_no", param.getLocNo()).eq("matnr",locDetlAdjust.getMatnr())); - Mat mat = matService.selectOne(new EntityWrapper<Mat>() - .eq("matnr", locDetlAdjust.getMatnr())); - if (mat == null) { - throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑鐗╂枡,璇疯仈绯荤鐞嗗憳"); - } - Node node = nodeService.selectOne(new EntityWrapper<Node>() - .eq("uuid", param.getLocNo())); - if (node == null) { - throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑搴撲綅,璇疯仈绯荤鐞嗗憳"); + if(!existFlag){ + this.delete(wrapper); + SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),0.0,user.getUsername()); } - manLocDetl.setAnfme(locDetlAdjust.getCount()); - manLocDetl.setUpdateBy(userId); - manLocDetl.setModiTime(now); - SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername()); - this.baseMapper.insert(manLocDetl); } + + for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()){ + Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo()); + wrapper.eq("matnr",locDetlAdjust.getMatnr()); + Utils.wapperSetCondition(wrapper,"container_code",locDetlAdjust.getSuppCode()); + Utils.wapperSetCondition(wrapper,"batch",locDetlAdjust.getBatch()); + Utils.wapperSetCondition(wrapper,"csocode",locDetlAdjust.getThreeCode()); + Utils.wapperSetCondition(wrapper,"isoseq",locDetlAdjust.getDeadTime()); + + boolean existFlag = false; + for (ManLocDetl manLocDetl : manLocDetls){ + if(Cools.eq(manLocDetl.getMatnr(),locDetlAdjust.getMatnr()) + && Cools.eq(manLocDetl.getContainerCode(),locDetlAdjust.getSuppCode()) + && Cools.eq(manLocDetl.getBatch(),locDetlAdjust.getBatch()) + && Cools.eq(manLocDetl.getCsocode(),locDetlAdjust.getThreeCode()) + && Cools.eq(manLocDetl.getIsoseq(),locDetlAdjust.getDeadTime())){ + if(!locDetlAdjust.getCount().equals(manLocDetl.getAnfme())){ + manLocDetl.setAnfme(locDetlAdjust.getCount()); + manLocDetl.setModiTime(now); + this.update(manLocDetl,wrapper); + SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername()); + } + existFlag = true; + } + } + if(!existFlag){ + ManLocDetl manLocDetl = addManlocDetl(locDetlAdjust, param.getLocNo()); + SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),0.0,user.getUsername()); + + } + } + + +// for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()) { +// +// ManLocDetl manLocDetl = this.baseMapper.selectItem(param.getLocNo(), locDetlAdjust.getMatnr(), locDetlAdjust.getBatch(),locDetlAdjust.getThreeCode(),locDetlAdjust.getDeadTime(),locDetlAdjust.getSuppCode()); +// +// if(Cools.isEmpty(manLocDetl)){ +// addManlocDetl(locDetlAdjust,param.getLocNo()); +// continue; +// } +// Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo()).eq("matnr", locDetlAdjust.getMatnr()); +// Utils.wapperSetCondition(wrapper,"container_code",manLocDetl.getContainerCode()); +// Utils.wapperSetCondition(wrapper,"csocode",manLocDetl.getCsocode()); +// Utils.wapperSetCondition(wrapper,"isoseq",manLocDetl.getIsoseq()); +// Utils.wapperSetCondition(wrapper,"batch",manLocDetl.getBatch()); +// this.baseMapper.delete(wrapper); +// Mat mat = matService.selectOne(new EntityWrapper<Mat>() +// .eq("matnr", locDetlAdjust.getMatnr())); +// if (mat == null) { +// throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑鐗╂枡,璇疯仈绯荤鐞嗗憳"); +// } +// Node node = nodeService.selectOne(new EntityWrapper<Node>() +// .eq("uuid", param.getLocNo())); +// if (node == null) { +// throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑搴撲綅,璇疯仈绯荤鐞嗗憳"); +// +// } +// manLocDetl.setAnfme(locDetlAdjust.getCount()); +// manLocDetl.setUpdateBy(userId); +// manLocDetl.setModiTime(now); +// SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername()); +// this.baseMapper.insert(manLocDetl); +// } } @Override @@ -239,11 +307,11 @@ if(Cools.isEmpty(condition)){ wrapper.andNew().eq(column,"").or().isNull(column); }else { - wrapper.eq(column,condition); + wrapper.andNew().eq(column,condition); } } - private void addManlocDetl(LocDetlAdjustParam.LocDetlAdjust param, String locNo){ + private ManLocDetl addManlocDetl(LocDetlAdjustParam.LocDetlAdjust param, String locNo){ Date now = new Date(); ManLocDetl manLocDetl = new ManLocDetl(); Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", locNo)); @@ -260,6 +328,8 @@ manLocDetl.setLocNo(locNo); manLocDetl.setStatus(1); this.insert(manLocDetl); + + return manLocDetl; } } -- Gitblit v1.9.1