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 | 140 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 118 insertions(+), 22 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 01ada7a..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,8 +16,10 @@ 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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -131,8 +132,8 @@ @Override - public ManLocDetl selectItem(String locNo, String matnr, String batch) { - return this.baseMapper.selectItem(locNo, matnr, batch); + public ManLocDetl selectItem(String locNo, String matnr, String batch, String csocode, String isoseq, String containerCode) { + return this.baseMapper.selectItem(locNo, matnr, batch,csocode,isoseq,containerCode); } @Override @@ -153,27 +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()); - 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("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑鐗╂枡,璇疯仈绯荤鐞嗗憳"); + 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()); + + 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; + } } - 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 @@ -230,10 +305,31 @@ private void wapperSetCondition(Wrapper wrapper,String column, String condition){ if(Cools.isEmpty(condition)){ - wrapper.isNull(column); + wrapper.andNew().eq(column,"").or().isNull(column); }else { - wrapper.eq(column,condition); + wrapper.andNew().eq(column,condition); } } + 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)); + Mat mat = matService.selectByMatnr(param.getMatnr()); + BeanUtils.copyProperties(mat,manLocDetl); + manLocDetl.setNodeId(node.getId()); + manLocDetl.setBatch(param.getBatch()); + manLocDetl.setAnfme(param.getCount()); + manLocDetl.setContainerCode(param.getSuppCode()); + manLocDetl.setCsocode(param.getThreeCode()); + manLocDetl.setIsoseq(param.getDeadTime()); + manLocDetl.setCreateTime(now); + manLocDetl.setModiTime(now); + manLocDetl.setLocNo(locNo); + manLocDetl.setStatus(1); + this.insert(manLocDetl); + + return manLocDetl; + } + } -- Gitblit v1.9.1