From b8975f62b72528006a840e63810f1644560ac4fd Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期六, 23 四月 2022 09:58:18 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
index bc4b8f7..c0045f2 100644
--- a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -5,16 +5,14 @@
 import com.core.common.DateUtils;
 import com.core.common.SnowflakeIdWorker;
 import com.core.exception.CoolException;
-import com.zy.asrs.entity.DocType;
-import com.zy.asrs.entity.Mat;
-import com.zy.asrs.entity.Order;
-import com.zy.asrs.entity.OrderDetl;
+import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.OpenOrderCompleteParam;
 import com.zy.asrs.entity.param.OpenOrderPakinParam;
 import com.zy.asrs.entity.param.OpenOrderPakoutParam;
 import com.zy.asrs.entity.result.OpenOrderCompeteResult;
 import com.zy.asrs.entity.result.StockVo;
 import com.zy.asrs.service.*;
+import com.zy.asrs.utils.MatUtils;
 import com.zy.common.model.DetlDto;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +42,10 @@
     private MatService matService;
     @Autowired
     private LocDetlService locDetlService;
+    @Autowired
+    private PackService packService;
+    @Autowired
+    private TagService tagService;
 
     @Override
     @Transactional
@@ -311,4 +313,48 @@
         return locDetlService.queryStockTotal();
     }
 
+    @Override
+    @Transactional
+    public void packageUp(String barcode) {
+        Mat analyse = MatUtils.analyseMat(barcode);
+        Pack pack = packService.selectByBarcode(barcode);
+        if (null != pack) {
+            throw new CoolException(barcode + "閲嶅鎻愪氦");
+        }
+        Date now = new Date();
+        pack = new Pack(
+                barcode,    // 鏉$爜[闈炵┖]
+                analyse.getMatnr(),    // 鍟嗗搧缂栧彿
+                analyse.getBarcode(),    // 鎵瑰彿
+                1L,    // 璁㈠崟鐘舵��
+                1,    // 鐘舵��
+                now,    // 娣诲姞鏃堕棿
+                null,    // 娣诲姞浜哄憳
+                now,    // 淇敼鏃堕棿
+                null,    // 淇敼浜哄憳
+                null    // 澶囨敞
+        );
+        if (!packService.insert(pack)) {
+            throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
+        }
+
+        Mat mat = matService.selectByMatnr(analyse.getMatnr());
+        if (mat == null) {
+            mat = new Mat();
+            // todo
+            mat.setTagId(tagService.getTop().getId());
+            mat.setMatnr(analyse.getMatnr());
+            mat.setMaktx(barcode);
+            mat.setStatus(1);
+            mat.setCreateTime(now);
+            mat.setUpdateTime(now);
+            mat.setMemo("鎵撳寘涓婄嚎");
+            if (!matService.insert(mat)) {
+                throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
+            } else {
+                log.info("鎵撳寘涓婄嚎娣诲姞鏂扮墿鏂橻鍟嗗搧缂栧彿锛歿}]", mat.getMatnr());
+            }
+        }
+    }
+
 }

--
Gitblit v1.9.1