From b7e08df5a07b3fa832a46ecc31983e16f2bccc8c Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 24 七月 2023 14:56:01 +0800
Subject: [PATCH] # 出库作业,和库存明细管理 排序

---
 src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java |   86 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 74 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
index 3753ebd..6d43269 100644
--- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -125,7 +125,7 @@
         // 鐢熸垚宸ヤ綔妗f槑缁�
         List<MatCodeCountDto> matDtos = new ArrayList<>();
         param.getList().forEach(elem -> {
-            matDtos.add(new MatCodeCountDto(elem.getMatNo(), elem.getCount()));
+            matDtos.add(new MatCodeCountDto(elem.getMatNo(), elem.getSupplier(), elem.getCount(),elem.getMemo(),elem.getSource(),elem.getVendor()));
         });
         wrkDetlService.createWorkDetail(workNo, matDtos, param.getBarcode(), userId);
         // 鏇存柊婧愮珯鐐逛俊鎭�
@@ -264,6 +264,10 @@
             }
             // 鐢熸垚宸ヤ綔妗f槑缁�
             for (LocDetlDto detlDto : dto.getLocDetlDtos()) {
+                MatCode matCode = matCodeService.selectById(detlDto.getLocDetl().getMatNo());
+                if(Cools.isEmpty(matCode)){
+                    throw new CoolException("浜у搧缂栫爜鍦ㄥ熀纭�鏁版嵁涓笉瀛樺湪锛岃纭");
+                }
                 // 鍑哄簱鏃讹紝鏁伴噺涓�0鐨勭洿鎺ュ拷鐣�
                 if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;}
                 WrkDetl wrkDetl = new WrkDetl();
@@ -276,6 +280,17 @@
                 wrkDetl.setAppeUser(userId);
                 wrkDetl.setModiTime(new Date());
                 wrkDetl.setModiUser(userId);
+                wrkDetl.setMemo(detlDto.getLocDetl().getMemo());
+                wrkDetl.setQtyBox(matCode.getStr6()!=null ? matCode.getStr6() : 0);
+                wrkDetl.setWeight(matCode.getWeight()!=null ? matCode.getWeight() : 0);
+                wrkDetl.setAllWeight(matCode.getWeight()!=null ? qty*matCode.getWeight()+30 : 0);
+                wrkDetl.setAllQty(matCode.getStr6()!=null ? qty*matCode.getStr6() : 0);
+                wrkDetl.setVendor(detlDto.getLocDetl().getVendor());
+                wrkDetl.setSource(detlDto.getLocDetl().getSource());
+                wrkDetl.setSupplier(detlDto.getLocDetl().getSupplier());
+                wrkDetl.setStr5(matCode.getStr5());
+                wrkDetl.setStr4(matCode.getStr4());
+                wrkDetl.setStr3(matCode.getStr3());
                 if (!wrkDetlService.insert(wrkDetl)) {
                     throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
                 }
@@ -408,6 +423,15 @@
             // 鑾峰彇宸ヤ綔鍙�
             int workNo = commonService.getWorkNo(1);
 
+            //2022-06-16 ADD, 鍑哄簱搴撲綅濡傛灉鏄繁搴撲綅1鍙疯揣鏋讹紝涓斿搴旀祬搴撲綅涔熶负D鏃讹紝鍏堝嚭娴呭簱浣�
+            if(Utils.isDeepLoc(slaveProperties, locNo)){
+                String shallow = Utils.getShallowLoc(slaveProperties,locNo);
+                LocMast shallowLoc = locMastService.selectById(shallow);
+                if(!Cools.isEmpty(shallowLoc) && shallowLoc.getLocSts().equals("D")){
+                    locNo = shallowLoc.getLocNo();
+                }
+            }
+
             // 鑾峰彇搴撲綅
             LocMast locMast = locMastService.selectById(locNo);
             if (Cools.isEmpty(locMast)) {
@@ -490,6 +514,7 @@
                 LocDetl sqlParam = new LocDetl();
                 sqlParam.setLocNo(paramLocDetl.getLocNo());
                 sqlParam.setMatNo(paramLocDetl.getMatNo());
+                sqlParam.setSupplier(paramLocDetl.getSupplier());
                 LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam));
                 if (null != one) locDetlDtos.add(new LocDetlDto(one, one.getQty()));
             }
@@ -504,6 +529,7 @@
 
     @Override
     @Transactional
+    //绉诲簱
     public void locMove(String sourceLocNo, String locNo, Long userId) {
         LocMast sourceLoc = locMastService.selectById(sourceLocNo);
         if (Cools.isEmpty(sourceLoc)){
@@ -530,10 +556,11 @@
             }
         }
 
+        Date now = new Date();
         // 淇濆瓨宸ヤ綔妗�
         WrkMast wrkMast = new WrkMast();
         wrkMast.setWrkNo(workNo);
-        wrkMast.setIoTime(new Date());
+        wrkMast.setIoTime(now);
         wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
         wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
         wrkMast.setIoPri(10D);
@@ -547,9 +574,9 @@
         wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮�
         wrkMast.setLinkMis("N");
         wrkMast.setAppeUser(userId);
-        wrkMast.setAppeTime(new Date());
+        wrkMast.setAppeTime(now);
         wrkMast.setModiUser(userId);
-        wrkMast.setModiTime(new Date());
+        wrkMast.setModiTime(now);
         boolean res = wrkMastService.insert(wrkMast);
         if (!res) {
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
@@ -559,12 +586,12 @@
         for (LocDetl locDetl : locDetls) {
             WrkDetl wrkDetl = new WrkDetl();
             wrkDetl.setWrkNo(workNo);
-            wrkDetl.setIoTime(new Date());
+            wrkDetl.setIoTime(now);
             wrkDetl.setQty(locDetl.getQty());
             VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗
-            wrkDetl.setAppeTime(new Date());
+            wrkDetl.setAppeTime(now);
             wrkDetl.setAppeUser(userId);
-            wrkDetl.setModiTime(new Date());
+            wrkDetl.setModiTime(now);
             wrkDetl.setModiUser(userId);
             if (!wrkDetlService.insert(wrkDetl)) {
                 throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
@@ -574,7 +601,7 @@
         if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) {
             sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害
             sourceLoc.setModiUser(userId);
-            sourceLoc.setModiTime(new Date());
+            sourceLoc.setModiTime(now);
             if (!locMastService.updateById(sourceLoc)){
                 throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
             }
@@ -584,7 +611,7 @@
         // 淇敼鐩爣搴撲綅鐘舵��
         if (loc.getLocSts().equals("O")) {
             loc.setLocSts("S"); // S.鍏ュ簱棰勭害
-            loc.setModiTime(new Date());
+            loc.setModiTime(now);
             loc.setModiUser(userId);
             if (!locMastService.updateById(loc)) {
                 throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
@@ -650,6 +677,7 @@
             LocDetl sqlParam = new LocDetl();
             sqlParam.setLocNo(locMast.getLocNo());
             sqlParam.setMatNo(adjust.getMatNo());
+            sqlParam.setSupplier(adjust.getSupplier());
             LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam));
             // 淇濆瓨鏂板簱瀛樻槑缁�
             if (Cools.isEmpty(one)) {
@@ -661,11 +689,29 @@
                 locDetl.setLocNo(locMast.getLocNo());
                 locDetl.setQty(adjust.getCount()); // 鏁伴噺
                 VersionUtils.setLocDetl(locDetl, matCode); // 鐗堟湰鎺у埗
+
+                if (Cools.isEmpty(adjust.getSupplier())){
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+                    locDetl.setSupplier(sdf.format(new Date()));
+                }else {
+                    locDetl.setSupplier(adjust.getSupplier());
+                }
+
+
                 locDetl.setModiUser(userId); // 鎿嶄綔浜哄憳淇℃伅
                 locDetl.setModiTime(new Date());
                 locDetl.setAppeUser(userId);
                 locDetl.setAppeTime(new Date());
                 locDetl.setZpallet(param.getZpallet());//鎵樼洏鍙�
+                locDetl.setVendor(adjust.getVendor());
+                locDetl.setSource(adjust.getSource());
+                locDetl.setSupplier(adjust.getSupplier());
+                locDetl.setQtyBox(matCode.getStr6());
+                locDetl.setAllQty(matCode.getStr6()*adjust.getCount());
+                locDetl.setAllWeight(matCode.getWeight()*adjust.getCount()+30);
+                locDetl.setStr3(matCode.getStr3());
+                locDetl.setStr4(matCode.getStr4());
+                locDetl.setStr5(matCode.getStr5());
                 if (!locDetlService.insert(locDetl)) {
                     throw new CoolException("淇濆瓨搴撳瓨鏄庣粏澶辫触");
                 }
@@ -686,13 +732,25 @@
                             throw new CoolException("娓呴櫎搴撳瓨鏄庣粏澶辫触");
                         }
                     } else {
+                        MatCode matCode = matCodeService.selectById(adjust.getMatNo());
                         LocDetl sqlParam1 = new LocDetl();
                         sqlParam1.setQty(adjust.getCount());
+                        sqlParam1.setSupplier(adjust.getSupplier());
                         sqlParam1.setModiTime(new Date());
                         sqlParam1.setModiUser(userId);
+                        sqlParam1.setVendor(adjust.getVendor());
+                        sqlParam1.setSource(adjust.getSource());
+                        sqlParam1.setSupplier(adjust.getSupplier());
+                        sqlParam1.setQtyBox(matCode.getStr6());
+                        sqlParam1.setAllQty(matCode.getStr6()*adjust.getCount());
+                        sqlParam1.setAllWeight(matCode.getWeight()*adjust.getCount()+30);
+                        sqlParam1.setStr5(matCode.getStr5());
+                        sqlParam1.setStr4(matCode.getStr4());
+                        sqlParam1.setStr3(matCode.getStr3());
                         if (!locDetlService.update(sqlParam1, new EntityWrapper<LocDetl>()
                                 .eq("loc_no", locMast.getLocNo())
-                                .eq("mat_no", adjust.getMatNo()))) {
+                                .eq("mat_no", adjust.getMatNo())
+                                .eq("supplier",adjust.getSupplier()))) {
                             throw new CoolException("淇敼搴撳瓨鏄庣粏澶辫触");
                         }
                     }
@@ -757,7 +815,11 @@
                 locSts = "D";
             // 搴撲綅杞Щ ===>> D.绌烘《/绌烘爤鏉�
             } else if (wrkMast.getIoType() == 11) {
-                locSts = "F";
+                if(wrkMast.getEmptyMk().equals("Y")){
+                    locSts = "D";
+                }else {
+                    locSts = "F";
+                }
                 // 搴撲綅杞Щ锛氱洰鏍囧簱浣�
                 LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
                 if (Cools.isEmpty(locMast)) {
@@ -787,7 +849,7 @@
 
         if (wrkMast.getIoType() != 10 && wrkMast.getIoType() != 110) {
             // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。
-            if (!wrkDetlLogService.save(wrkMast.getWrkNo())) {
+            if (!wrkMast.getEmptyMk().equals("Y") && !wrkDetlLogService.save(wrkMast.getWrkNo())) {
                 throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏鍘嗗彶妗eけ璐�, workNo = " + wrkMast.getWrkNo());
             }
             // 鍒犻櫎宸ヤ綔妗f槑缁�

--
Gitblit v1.9.1