From 85deecd28f589f280a3db19fb35fcb6d9081b781 Mon Sep 17 00:00:00 2001
From: wang..123 <brook_w@163.com>
Date: 星期五, 18 二月 2022 09:57:18 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 175 +++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 147 insertions(+), 28 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 5f5b2b2..cb0209b 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -4,17 +4,23 @@
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.exception.CoolException;
+import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.MatCode;
-import com.zy.asrs.entity.WaitPakin;
+import com.zy.asrs.entity.PltBarcode;
+import com.zy.asrs.entity.WrkDetl;
import com.zy.asrs.entity.param.CombParam;
-import com.zy.asrs.service.MatCodeService;
-import com.zy.asrs.service.MobileService;
-import com.zy.asrs.service.WaitPakinService;
+import com.zy.asrs.service.*;
+import com.zy.ints.entity.WaitMatin;
+import com.zy.ints.service.WaitMatinService;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* 绉诲姩绔湇鍔℃牳蹇冪被
@@ -26,7 +32,13 @@
@Autowired
private MatCodeService matCodeService;
@Autowired
- private WaitPakinService waitPakinService;
+ private WaitMatinService waitMatinService;
+ @Autowired
+ private LocDetlService locDetlService;
+ @Autowired
+ private WrkDetlService wrkDetlService;
+ @Autowired
+ private PltBarcodeService pltBarcodeService;
@Override
@Transactional
@@ -34,31 +46,138 @@
if (Cools.isEmpty(param.getBarcode()) || param.getCombMats().isEmpty()) {
throw new CoolException(BaseRes.PARAM);
}
- int count = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
- eq("barcode", param.getBarcode()).eq("status", "N"));
- if (count > 0) {
- throw new CoolException("绠卞彿鏁版嵁宸插瓨鍦�");
+// int countPak = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
+// eq("zpallet", param.getBarcode()).eq("io_status", "N"));
+ int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
+ int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode()));
+ int countPlt = pltBarcodeService.selectCount(new EntityWrapper<PltBarcode>().eq("barcode",param.getBarcode()));
+ if (countPlt > 0 || countLoc > 0 || countWrk > 0) {
+ throw new CoolException("鏉$爜鏁版嵁宸插瓨鍦�");
}
- for (CombParam.CombMat combMat : param.getCombMats()) {
- MatCode matCode = matCodeService.selectById(combMat.getMatNo());
- if (Cools.isEmpty(matCode)) {
- throw new CoolException("鐗╂枡鏁版嵁閿欒");
+
+ 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(billNo);
+ pltBarcode.setSeqNo(seqNo);
+ pltBarcode.setBillType(5);
+ pltBarcode.setMatNo(matCode.getMatNo());
+ pltBarcode.setMatName(matCode.getMatName());
+ pltBarcode.setQty(combMat.getCount());
+ 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("淇濆瓨鏁版嵁澶辫触");
+ }
}
- WaitPakin waitPakin = new WaitPakin(
- param.getBarcode(), // 鎵樼洏鐮�
- matCode.getMatNo(), // 鐗╂枡缂栫爜
- matCode.getMatName(), // 鐗╂枡鎻忚堪
- combMat.getCount(), // 鏁伴噺
- matCode.getStr1(), // 鍗曚綅
- "N", // 鐘舵��
- null, // 澶囨敞
- new Date(), // 淇敼鏃堕棿
- userId, // 淇敼浜哄憳
- new Date(), // 娣诲姞鏃堕棿
- userId // 鍒涘缓鑰�
- );
- if (!waitPakinService.insert(waitPakin)) {
- 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() + "鏁版嵁锛�");
+ }
+
+ if (combMat.getCount() > (waitMatin.getQty()-waitMatin.getInQty())) {
+ throw new CoolException(combMat.getMatNo() + "缁勬墭鐗╂枡鏁伴噺涓嶈冻锛�");
+ }
+
+ PltBarcode pltBarcode = new PltBarcode();
+ pltBarcode.setBarcode(param.getBarcode());
+ pltBarcode.setBillNo(waitMatin.getBillNo());
+ pltBarcode.setSeqNo(waitMatin.getSeqNo());
+ pltBarcode.setBillType(waitMatin.getBillType());
+ pltBarcode.setMatNo(waitMatin.getMatNo());
+ pltBarcode.setMatName(waitMatin.getMatName());
+ pltBarcode.setQty(combMat.getCount());
+ pltBarcode.setUnit(waitMatin.getUnit());
+ pltBarcode.setSpecs(waitMatin.getSpecs());
+ pltBarcode.setSize(waitMatin.getSize());
+ pltBarcode.setColor(waitMatin.getColor());
+ pltBarcode.setLinkErp(waitMatin.getLinkErp());
+ pltBarcode.setModiUser(userId);
+ 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("淇濆瓨鏁版嵁澶辫触");
+ }
+
+ waitMatin.setInQty(combMat.getCount() + waitMatin.getInQty());
+ if (!waitMatinService.update(waitMatin,new EntityWrapper<WaitMatin>()
+ .eq("bill_no",param.getBillNo()).eq("seq_no",combMat.getSeqNo()))){
+ throw new CoolException("鏇存柊鏁版嵁澶辫触");
+ }
+
}
}
}
--
Gitblit v1.9.1