|  |  |  | 
|---|
|  |  |  | import com.zy.common.utils.Synchro; | 
|---|
|  |  |  | import com.zy.system.entity.User; | 
|---|
|  |  |  | import com.zy.system.service.SaasLogService; | 
|---|
|  |  |  | import lombok.Synchronized; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  | private PlaQtyService plaQtyService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SaasLogService saasLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | orderService.checkComplete(order.getOrderNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SaasUtils.insertLog(0,jsonLocNo,jsonOrderDetl.getMatnr(), jsonOrderDetl.getAnfme(),user.getUsername(), | 
|---|
|  |  |  | null,null,null,null,null); | 
|---|
|  |  |  | null,null,null,null,null,null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | SaasUtils.insertLog(1,jsonLocNo,jsonOrderDetl.getMatnr(), jsonOrderDetl.getAnfme(),user.getUsername(), | 
|---|
|  |  |  | null,null,null,null,null); | 
|---|
|  |  |  | null,null,null,null,null,null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("下架完成"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | plaService.updateById(pla); | 
|---|
|  |  |  | SaasUtils.insertLog(0,locNo,pla.getBrand(),pla.getWeightAnfme(),user.getUsername(), | 
|---|
|  |  |  | null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop()); | 
|---|
|  |  |  | null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | @Synchronized | 
|---|
|  |  |  | public void plaPakout(String brand, String locNo, String batch, Integer packageNo, String orderNo, String plaQtyId, String wrkNo, Double anfme, boolean isReplace) { | 
|---|
|  |  |  | Pla pla = plaService.selectByBatchAndPackageNo(batch, packageNo,brand); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | manPakOut.setCount(manPakOut.getCount() + anfme); | 
|---|
|  |  |  | if (manPakOut.getAnfme().equals(manPakOut.getCount())){ | 
|---|
|  |  |  | manPakOut.setStatus(1); | 
|---|
|  |  |  | manPakOut.setUpdateTime(new Date()); | 
|---|
|  |  |  | manPakOutService.updateById(manPakOut); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | pla.setStatus(GlobleParameter.PLA_STATUS_3); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("pla出库v1,订单出库,更新为待出库或则全部出库,pla:{},anfme:{},是否替换:{}",pla,anfme,isReplace); | 
|---|
|  |  |  | plaService.updateById(pla); | 
|---|
|  |  |  | SaasUtils.insertLog(1,locNo,pla.getBrand(),anfme,null,null, | 
|---|
|  |  |  | pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop()); | 
|---|
|  |  |  | pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新订单明细 | 
|---|
|  |  |  | Order order = orderService.selectByNo(orderNo); | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectById(plaQty.getOrderDetlId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (orderDetl == null){ | 
|---|
|  |  |  | throw new CoolException("订单明细不存在或者不匹配"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderDetl.setQty(orderDetl.getQty() + anfme); | 
|---|
|  |  |  | orderDetlService.updateById(orderDetl); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("当前物料剩余库存不足"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.info("无订单拣货出库,更新为待出库或则全部出库,pla:{},anfme:{}",pla,anfme); | 
|---|
|  |  |  | pla.setWeightAnfme(pla.getWeightAnfme() - anfme); | 
|---|
|  |  |  | if(pla.getWeightAnfme() > 0){ | 
|---|
|  |  |  | pla.setStatus(GlobleParameter.PLA_STATUS_3); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | plaService.updateById(pla); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SaasUtils.insertLog(1,pla.getLocNo(),pla.getBrand(),anfme,null,null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop()); | 
|---|
|  |  |  | SaasUtils.insertLog(1,pla.getLocNo(),pla.getBrand(),anfme,null,null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public void replacePla(Pla plaNew, ManPakOut manPakOut, PlaQty plaQty){ | 
|---|
|  |  |  | //还原旧物料状态 | 
|---|
|  |  |  | Pla plaOld = plaService.selectByBatchAndPackageNo(manPakOut.getBatch(), Integer.parseInt(manPakOut.getBarcode()), manPakOut.getMaktx()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新新物料信息 | 
|---|
|  |  |  | plaNew.setQtyAnfme(plaOld.getQtyAnfme()); | 
|---|
|  |  |  | plaNew.setStatus(plaOld.getStatus()); | 
|---|
|  |  |  | plaService.updateById(plaNew); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | plaOld.setStatus(GlobleParameter.PLA_STATUS_1); | 
|---|
|  |  |  | plaOld.setQtyAnfme(0.0); | 
|---|
|  |  |  | 
|---|
|  |  |  | manPakOut.setMaktx(plaNew.getBrand()); | 
|---|
|  |  |  | manPakOut.setBatch(plaNew.getBatch()); | 
|---|
|  |  |  | manPakOut.setBarcode(plaNew.getPackageNo() + ""); | 
|---|
|  |  |  | manPakOut.setUpdateTime(new Date()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | manPakOutService.updateById(manPakOut); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Pla> pdaSelectInfmt(String barcode) { | 
|---|
|  |  |  | EntityWrapper<Pla> plaEntityWrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | String[] split = barcode.split(";"); | 
|---|
|  |  |  | if (split.length == 4){ | 
|---|
|  |  |  | plaEntityWrapper.eq("brand",split[0]); | 
|---|
|  |  |  | plaEntityWrapper.eq("batch",split[1]); | 
|---|
|  |  |  | plaEntityWrapper.eq("package_no",split[2]); | 
|---|
|  |  |  | plaEntityWrapper.eq("line",split[3]); | 
|---|
|  |  |  | }else if (split.length == 1){ | 
|---|
|  |  |  | Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", barcode)); | 
|---|
|  |  |  | if (Cools.isEmpty(node)){ | 
|---|
|  |  |  | throw new CoolException("请检查输入的库位码"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | plaEntityWrapper.eq("loc_no",barcode); | 
|---|
|  |  |  | plaEntityWrapper.notLike("status","全部出库"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | throw new CoolException("条码信息有误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Pla> plaList = plaService.selectList(plaEntityWrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(plaList)){ | 
|---|
|  |  |  | throw new CoolException("未查询到库存物料信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return plaList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public boolean checkMaximum(String locNo, int packageNum){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Node node = nodeService.selectByUuid(locNo); | 
|---|
|  |  |  | Node nodeParent = nodeService.selectById(node.getParentId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Cools.isEmpty(nodeParent.getMajor())){ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //当前库存包数 | 
|---|
|  |  |  | int count = plaService.selectCount(new EntityWrapper<Pla>().eq("loc_no", locNo) | 
|---|
|  |  |  | .notIn("status", "全部出库")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(nodeParent.getMajor() < count + packageNum){ | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|