| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.chrono.IsoEra; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * 移动端服务核心类 |
| | |
| | | |
| | | Date now = new Date(); |
| | | if (Cools.isEmpty(param.getBillNo())) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | Random rand = new Random(); |
| | | Integer r = rand.nextInt(900)+ 100; |
| | | String billNo = sdf.format(new Date()) + r; |
| | | Integer seqNo=0; |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | MatCode matCode = matCodeService.selectOne(new EntityWrapper<MatCode>().eq("mat_no", combMat.getMatNo())); |
| | | if (Cools.isEmpty(matCode)) { |
| | | throw new CoolException("物料数据错误"); |
| | | } |
| | | seqNo++; |
| | | PltBarcode pltBarcode = new PltBarcode(); |
| | | pltBarcode.setBarcode(param.getBarcode()); |
| | | pltBarcode.setBillNo(""); |
| | | pltBarcode.setSeqNo(0); |
| | | pltBarcode.setBillNo(billNo); |
| | | pltBarcode.setSeqNo(seqNo); |
| | | pltBarcode.setBillType(5); |
| | | pltBarcode.setMatNo(matCode.getMatNo()); |
| | | pltBarcode.setMatName(matCode.getMatName()); |
| | |
| | | pltBarcode.setUnit(matCode.getUnit()); |
| | | pltBarcode.setSpecs(matCode.getSpecs()); |
| | | pltBarcode.setSize(matCode.getSize()); |
| | | if(Cools.isEmpty(combMat.getSupplier())){ |
| | | String supp = sdf.format(new Date()) + r; |
| | | pltBarcode.setSupplier(supp); |
| | | }else{ |
| | | pltBarcode.setSupplier(combMat.getSupplier()); |
| | | } |
| | | pltBarcode.setMemo(combMat.getMemo()); |
| | | pltBarcode.setColor(matCode.getColor()); |
| | | pltBarcode.setLinkErp(0); |
| | | pltBarcode.setModiUser(userId); |
| | | pltBarcode.setModiTime(now); |
| | | pltBarcode.setAppeUser(userId); |
| | | pltBarcode.setAppeTime(now); |
| | | |
| | | if(matCode.getWeight()==null){ |
| | | matCode.setWeight(0.0); |
| | | } |
| | | if(matCode.getStr6()==null){ |
| | | matCode.setStr6(0.0); |
| | | pltBarcode.setAllQty(pltBarcode.getQty()); |
| | | }else { |
| | | pltBarcode.setAllQty(matCode.getStr6()*pltBarcode.getQty()); |
| | | } |
| | | pltBarcode.setWeight(matCode.getWeight()); |
| | | pltBarcode.setAllWeight(matCode.getWeight()*pltBarcode.getQty()+30); |
| | | pltBarcode.setVendor(combMat.getVendor()); |
| | | pltBarcode.setSource(combMat.getSource()); |
| | | pltBarcode.setQtyBox(matCode.getStr6()); |
| | | if (!pltBarcodeService.insert(pltBarcode)) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | | } |
| | | } else { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | Random rand = new Random(); |
| | | Integer r = rand.nextInt(900)+ 100; |
| | | // 关联通知单组托 |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | WaitMatin waitMatin = waitMatinService.selectOne(new EntityWrapper<WaitMatin>() |
| | | |
| | | .eq("bill_no",param.getBillNo()).eq("seq_no",combMat.getSeqNo())); |
| | | |
| | | MatCode matCode = matCodeService.selectOne(new EntityWrapper<MatCode>().eq("mat_no", combMat.getMatNo())); |
| | | |
| | | if (waitMatin == null) { |
| | | throw new CoolException("通知单不存在" + combMat.getMatNo() + "数据!"); |
| | |
| | | pltBarcode.setModiTime(now); |
| | | pltBarcode.setAppeUser(userId); |
| | | pltBarcode.setAppeTime(now); |
| | | |
| | | if(Cools.isEmpty(combMat.getSupplier())){ |
| | | String supp = sdf.format(new Date()) + r; |
| | | pltBarcode.setSupplier(supp); |
| | | }else{ |
| | | pltBarcode.setSupplier(combMat.getSupplier()); |
| | | } |
| | | if(matCode.getWeight()==null){ |
| | | matCode.setWeight(0.0); |
| | | } |
| | | if(matCode.getStr6()==null){ |
| | | matCode.setStr6(0.0); |
| | | pltBarcode.setAllQty(pltBarcode.getQty()); |
| | | }else { |
| | | pltBarcode.setAllQty(matCode.getStr6()*pltBarcode.getQty()); |
| | | } |
| | | pltBarcode.setWeight(matCode.getWeight()); |
| | | pltBarcode.setAllWeight(matCode.getWeight()*pltBarcode.getQty()+30); |
| | | pltBarcode.setVendor(combMat.getVendor()); |
| | | pltBarcode.setSource(combMat.getSource()); |
| | | pltBarcode.setQtyBox(matCode.getStr6()); |
| | | pltBarcode.setMemo(combMat.getMemo()); |
| | | if (!pltBarcodeService.insert(pltBarcode)) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |