From 619b45d00468b35509f5138b2dfa5131e2963e34 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 25 三月 2024 13:16:39 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  117 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 98 insertions(+), 19 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 5de7f20..163d97b 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -77,14 +77,53 @@
     @Override
     @Transactional
     public void comb(CombParam param, Long userId) {
-        if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
-            throw new CoolException(BaseRes.PARAM);
-        }
+//        if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
+//            throw new CoolException(BaseRes.PARAM);
+//        }
         // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
         if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
                 eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
             throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
         }
+
+        //鍒ゆ柇鎵樼洏鏄惁宸茬粡鍦ㄥ簱
+        if (locDetlService.selectCount(new EntityWrapper<LocDetl>()
+                .eq("zpallet", param.getBarcode())) > 0) {
+            throw new CoolException(param.getBarcode() + "鏁版嵁宸茬粡鍦ㄥ簱");
+        }
+
+        //鍒ゆ柇鏄惁瀛樺湪鏂欑鐮� => 瀛樺湪鏂欑鐮佸垯瑕佹眰鎻愪氦涓婃潵鐨勭墿鏂檒ist蹇呴』鍏ㄩ儴閮芥湁鏂欑鐮�
+        boolean hasContainerCode = false;
+        int containerCodeCount = 0;//鏂欑鐮佹暟閲�
+        for (CombParam.CombMat combMat : param.getCombMats()) {
+            if (combMat.getContainerCode() != null) {
+                hasContainerCode = true;
+                containerCodeCount++;
+                continue;
+            }
+        }
+
+        //鍒ゆ柇鏂欑鏄惁宸茬粡鍑虹幇鍦ㄥ叆搴撻�氱煡妗c�佸簱瀛樹腑
+        if (hasContainerCode) {
+            if (containerCodeCount != param.getCombMats().size()) {
+                throw new CoolException(param.getBarcode() + "鎵樼洏鏈�" + (param.getCombMats().size()-containerCodeCount) + "涓湭鎵弿鐨勬枡绠�");
+            }
+
+            for (CombParam.CombMat combMat : param.getCombMats()) {
+                //鍒ゆ柇鏂欑鏄惁姝e湪鍏ュ簱
+                if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
+                        eq("supp_code", combMat.getContainerCode()).eq("io_status", "N")) > 0) {
+                    throw new CoolException(combMat.getContainerCode() + "鏂欑姝e湪杩涜鍏ュ簱");
+                }
+
+                //鍒ゆ柇鏂欑鏄惁宸茬粡鍦ㄥ簱
+                if (locDetlService.selectCount(new EntityWrapper<LocDetl>()
+                        .eq("supp_code", combMat.getContainerCode())) > 0) {
+                    throw new CoolException(combMat.getContainerCode() + "鏂欑宸茬粡鍦ㄥ簱");
+                }
+            }
+        }
+
 
         // todo: 涓嶄笅绾块噸鏂板叆搴�
         WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode());
@@ -149,12 +188,12 @@
             param.getCombMats().forEach(elem -> {
 
                 // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch());
+                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch(),elem.getCsocode(),elem.getIsoseq());
                 if (elem.getAnfme() > orderDetl.getEnableQty()) {
                     throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
                 }
                 // 淇敼璁㈠崟鏄庣粏鏁伴噺
-                if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) {
+                if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme(),elem.getCsocode(),elem.getIsoseq())) {
                     throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触");
                 }
 
@@ -393,12 +432,12 @@
 
                 // 淇敼浣滀笟鏁伴噺 ----------------------------------------
                 // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch());
+                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq());
                 if (detlDto.getAnfme() > orderDetl.getEnableQty()) {
                     throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
                 }
                 // 淇敼璁㈠崟鏄庣粏鏁伴噺
-                if (!orderDetlService.increase(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme())) {
+                if (!orderDetlService.increase(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme(),detlDto.getCsocode(),detlDto.getIsoseq())) {
                     throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触");
                 }
 
@@ -453,21 +492,19 @@
         waitPakinList.forEach(waitPakin -> {
             //鏂欐兂鐮�
             String containerCode = waitPakin.getSuppCode();
-            //濡傛灉褰撳墠鏂欐兂鐮佸凡瀛樺湪锛屽垯淇敼璇ユ枡鎯崇殑鐗╂枡鏁伴噺
-            ManLocDetl manLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>().eq("container_code", containerCode));
+            //濡傛灉褰撳墠搴撲綅宸插瓨鍦ㄨ揣鐗�
+            Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", locNo).eq("matnr",waitPakin.getMatnr());
+            Utils.wapperSetCondition(wrapper,"container_code",containerCode);
+            Utils.wapperSetCondition(wrapper,"batch",waitPakin.getBatch());
+            Utils.wapperSetCondition(wrapper,"csocode",waitPakin.getThreeCode());
+            Utils.wapperSetCondition(wrapper,"isoseq",waitPakin.getDeadTime());
+            ManLocDetl manLocDetl = manLocDetlService.selectOne(wrapper);
             if(Cools.isEmpty(manLocDetl)){
                 saveManlocDetl(waitPakin,now,locNo);
             }else{
-                if(Cools.eq(manLocDetl.getMatnr(),waitPakin.getMatnr())
-                        && Cools.eq(manLocDetl.getCsocode(),waitPakin.getThreeCode())
-                        && Cools.eq(manLocDetl.getIsoseq(),waitPakin.getDeadTime())){
-                    manLocDetl.setAnfme(manLocDetl.getAnfme() + waitPakin.getAnfme());
-                    manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>()
-                            .eq("loc_no",manLocDetl.getLocNo())
-                            .eq("container_code",manLocDetl.getContainerCode()));
-                }else{
-                    saveManlocDetl(waitPakin,now,locNo);
-                }
+                manLocDetl.setAnfme(manLocDetl.getAnfme() + waitPakin.getAnfme());
+                manLocDetlService.update(manLocDetl,wrapper);
+
             }
             //鐢熸垚骞冲簱鍏ュ嚭搴撴棩蹇�
             SaasUtils.insertLog(0,locNo,waitPakin.getMatnr(), waitPakin.getAnfme(),user.getUsername());
@@ -578,6 +615,48 @@
         });
     }
 
+    @Override
+    public void nodePakinNoComb(CombParam param) {
+        if(Cools.isEmpty(param.getLocno())){
+            throw new CoolException("搴撲綅鍙锋湭濉啓锛屾棤娉曞叆搴�");
+        }
+        param.getCombMats().forEach(combMat -> {
+            Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocno()).eq("matnr",combMat.getMatnr());
+            Utils.wapperSetCondition(wrapper,"container_code",combMat.getContainerCode());
+            Utils.wapperSetCondition(wrapper,"batch",combMat.getBatch());
+            Utils.wapperSetCondition(wrapper,"csocode",combMat.getCsocode());
+            Utils.wapperSetCondition(wrapper,"isoseq",combMat.getIsoseq());
+            ManLocDetl manLocDetl = manLocDetlService.selectOne(wrapper);
+            if(Cools.isEmpty(manLocDetl)){
+                saveManlocDetl(combMat,param.getLocno());
+            }else{
+                manLocDetl.setAnfme(manLocDetl.getAnfme() + combMat.getAnfme());
+                manLocDetlService.update(manLocDetl,wrapper);
+            }
+            //鐢熸垚骞冲簱鍏ュ嚭搴撴棩蹇�
+            SaasUtils.insertLog(0,param.getLocno(),combMat.getMatnr(), combMat.getAnfme(),"");
+        });
+
+    }
+
+    private boolean saveManlocDetl(CombParam.CombMat combMat, String locNo){
+        Node node = nodeService.selectOne(new EntityWrapper<Node>()
+                .eq("name", locNo));
+        Mat mat = matService.selectByMatnr(combMat.getMatnr());
+        ManLocDetl manLocDetl = new ManLocDetl();
+        BeanUtils.copyProperties(mat,manLocDetl);
+        manLocDetl.setAnfme(combMat.getAnfme());
+        manLocDetl.setNodeId(node.getId());
+        manLocDetl.setContainerCode(combMat.getContainerCode());
+        manLocDetl.setCsocode(combMat.getCsocode());
+        manLocDetl.setIsoseq(combMat.getIsoseq());
+        manLocDetl.setCreateTime(new Date());
+        manLocDetl.setModiTime(new Date());
+        manLocDetl.setLocNo(locNo);
+        manLocDetl.setStatus(1);
+        return manLocDetlService.insert(manLocDetl);
+    }
+
     private void saveManlocDetl(WaitPakin waitPakin, Date now, String locNo){
 
         Node node = nodeService.selectOne(new EntityWrapper<Node>()

--
Gitblit v1.9.1