From cf8b2e91499acfe209cd02f5714822b81d6d9598 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期三, 13 十二月 2023 17:42:35 +0800
Subject: [PATCH] 平库库存调整修改

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java     |   22 +++----
 src/main/java/com/zy/asrs/controller/MobileController.java        |    2 
 src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java |  118 +++++++++++++++++++++++++++++++--------
 src/main/java/com/zy/asrs/controller/OutController.java           |    4 
 4 files changed, 107 insertions(+), 39 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/MobileController.java b/src/main/java/com/zy/asrs/controller/MobileController.java
index 9796c20..dc5563c 100644
--- a/src/main/java/com/zy/asrs/controller/MobileController.java
+++ b/src/main/java/com/zy/asrs/controller/MobileController.java
@@ -338,7 +338,7 @@
     骞冲簱 搴撲綅鎺ㄨ崘
      */
     @RequestMapping("/node/recommend/loc")
-    @ManagerAuth(memo = "搴撲綅鎺ㄨ崘")
+    //@ManagerAuth(memo = "搴撲綅鎺ㄨ崘")
     public R recommendNodeLoc(@RequestBody HashMap<String,String> param){
 
         String zpallet = param.get("zpallet");
diff --git a/src/main/java/com/zy/asrs/controller/OutController.java b/src/main/java/com/zy/asrs/controller/OutController.java
index 442a91a..918f8b0 100644
--- a/src/main/java/com/zy/asrs/controller/OutController.java
+++ b/src/main/java/com/zy/asrs/controller/OutController.java
@@ -246,9 +246,9 @@
                 //骞冲簱
                 if("鏃犻渶绔欑偣".equals(locDto.getAgvStaNo())){
                     generateManPakout(locDto);
+                }else {
+                    generateTaskDtoForAgv(locDto,agvTaskDtos);
                 }
-                generateTaskDtoForAgv(locDto,agvTaskDtos);
-
                 //鍥涢」搴�
             }else{
                 generateTaskDtoForBase(locDto,taskDtos);
diff --git a/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java
index f7fd388..7f731bf 100644
--- a/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/ManLocDetlServiceImpl.java
@@ -5,7 +5,6 @@
 import com.baomidou.mybatisplus.plugins.Page;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import com.core.common.Cools;
-import com.core.exception.CoolException;
 import com.zy.asrs.entity.ManLocDetl;
 import com.zy.asrs.entity.Mat;
 import com.zy.asrs.entity.Node;
@@ -17,6 +16,7 @@
 import com.zy.asrs.service.NodeService;
 import com.zy.asrs.service.WaitPakinService;
 import com.zy.asrs.utils.SaasUtils;
+import com.zy.asrs.utils.Utils;
 import com.zy.common.model.LocDto;
 import com.zy.system.entity.User;
 import org.springframework.beans.BeanUtils;
@@ -154,33 +154,101 @@
     @Override
     public void adjustLocDetl(LocDetlAdjustParam param, Long userId, User user) {
         Date now = new Date();
-        for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()) {
-            ManLocDetl manLocDetl = this.baseMapper.selectItem(param.getLocNo(), locDetlAdjust.getMatnr(), locDetlAdjust.getBatch(),locDetlAdjust.getThreeCode(),locDetlAdjust.getDeadTime(),locDetlAdjust.getSuppCode());
+        List<ManLocDetl> manLocDetls = this.selectList(new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo()));
+        for (ManLocDetl manLocDetl : manLocDetls){
+            Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo());
+            wrapper.eq("matnr",manLocDetl.getMatnr());
+            Utils.wapperSetCondition(wrapper,"container_code",manLocDetl.getContainerCode());
+            Utils.wapperSetCondition(wrapper,"batch",manLocDetl.getBatch());
+            Utils.wapperSetCondition(wrapper,"csocode",manLocDetl.getCsocode());
+            Utils.wapperSetCondition(wrapper,"isoseq",manLocDetl.getIsoseq());
 
-            if(Cools.isEmpty(manLocDetl)){
-                addManlocDetl(locDetlAdjust,param.getLocNo());
-                continue;
+            boolean existFlag = false;
+            for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()){
+                if(Cools.eq(manLocDetl.getMatnr(),locDetlAdjust.getMatnr())
+                        && Cools.eq(manLocDetl.getContainerCode(),locDetlAdjust.getSuppCode())
+                        && Cools.eq(manLocDetl.getBatch(),locDetlAdjust.getBatch())
+                        && Cools.eq(manLocDetl.getCsocode(),locDetlAdjust.getThreeCode())
+                        && Cools.eq(manLocDetl.getIsoseq(),locDetlAdjust.getDeadTime())){
+                    if(!locDetlAdjust.getCount().equals(manLocDetl.getAnfme())){
+                        manLocDetl.setAnfme(locDetlAdjust.getCount());
+                        manLocDetl.setModiTime(now);
+                        this.update(manLocDetl,wrapper);
+                        SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername());
+                    }
+                    existFlag = true;
+                }
             }
-
-            this.baseMapper.delete(new EntityWrapper<ManLocDetl>()
-                    .eq("loc_no", param.getLocNo()).eq("matnr",locDetlAdjust.getMatnr()));
-            Mat mat = matService.selectOne(new EntityWrapper<Mat>()
-                    .eq("matnr", locDetlAdjust.getMatnr()));
-            if (mat == null) {
-                throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑鐗╂枡,璇疯仈绯荤鐞嗗憳");
-            }
-            Node node = nodeService.selectOne(new EntityWrapper<Node>()
-                    .eq("uuid", param.getLocNo()));
-            if (node == null) {
-                throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑搴撲綅,璇疯仈绯荤鐞嗗憳");
+            if(!existFlag){
+                this.delete(wrapper);
+                SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),0.0,user.getUsername());
 
             }
-            manLocDetl.setAnfme(locDetlAdjust.getCount());
-            manLocDetl.setUpdateBy(userId);
-            manLocDetl.setModiTime(now);
-            SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername());
-            this.baseMapper.insert(manLocDetl);
         }
+
+        for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()){
+            Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo());
+            wrapper.eq("matnr",locDetlAdjust.getMatnr());
+            Utils.wapperSetCondition(wrapper,"container_code",locDetlAdjust.getSuppCode());
+            Utils.wapperSetCondition(wrapper,"batch",locDetlAdjust.getBatch());
+            Utils.wapperSetCondition(wrapper,"csocode",locDetlAdjust.getThreeCode());
+            Utils.wapperSetCondition(wrapper,"isoseq",locDetlAdjust.getDeadTime());
+
+            boolean existFlag = false;
+            for (ManLocDetl manLocDetl : manLocDetls){
+                if(Cools.eq(manLocDetl.getMatnr(),locDetlAdjust.getMatnr())
+                        && Cools.eq(manLocDetl.getContainerCode(),locDetlAdjust.getSuppCode())
+                        && Cools.eq(manLocDetl.getBatch(),locDetlAdjust.getBatch())
+                        && Cools.eq(manLocDetl.getCsocode(),locDetlAdjust.getThreeCode())
+                        && Cools.eq(manLocDetl.getIsoseq(),locDetlAdjust.getDeadTime())){
+                    if(!locDetlAdjust.getCount().equals(manLocDetl.getAnfme())){
+                        manLocDetl.setAnfme(locDetlAdjust.getCount());
+                        manLocDetl.setModiTime(now);
+                        this.update(manLocDetl,wrapper);
+                        SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername());
+                    }
+                    existFlag = true;
+                }
+            }
+            if(!existFlag){
+                ManLocDetl manLocDetl = addManlocDetl(locDetlAdjust, param.getLocNo());
+                SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),0.0,user.getUsername());
+
+            }
+        }
+
+
+//        for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()) {
+//
+//            ManLocDetl manLocDetl = this.baseMapper.selectItem(param.getLocNo(), locDetlAdjust.getMatnr(), locDetlAdjust.getBatch(),locDetlAdjust.getThreeCode(),locDetlAdjust.getDeadTime(),locDetlAdjust.getSuppCode());
+//
+//            if(Cools.isEmpty(manLocDetl)){
+//                addManlocDetl(locDetlAdjust,param.getLocNo());
+//                continue;
+//            }
+//            Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo()).eq("matnr", locDetlAdjust.getMatnr());
+//            Utils.wapperSetCondition(wrapper,"container_code",manLocDetl.getContainerCode());
+//            Utils.wapperSetCondition(wrapper,"csocode",manLocDetl.getCsocode());
+//            Utils.wapperSetCondition(wrapper,"isoseq",manLocDetl.getIsoseq());
+//            Utils.wapperSetCondition(wrapper,"batch",manLocDetl.getBatch());
+//            this.baseMapper.delete(wrapper);
+//            Mat mat = matService.selectOne(new EntityWrapper<Mat>()
+//                    .eq("matnr", locDetlAdjust.getMatnr()));
+//            if (mat == null) {
+//                throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑鐗╂枡,璇疯仈绯荤鐞嗗憳");
+//            }
+//            Node node = nodeService.selectOne(new EntityWrapper<Node>()
+//                    .eq("uuid", param.getLocNo()));
+//            if (node == null) {
+//                throw new CoolException("鏃犳硶鎵惧埌闇�瑕佽皟鏁寸殑搴撲綅,璇疯仈绯荤鐞嗗憳");
+//
+//            }
+//            manLocDetl.setAnfme(locDetlAdjust.getCount());
+//            manLocDetl.setUpdateBy(userId);
+//            manLocDetl.setModiTime(now);
+//            SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme(),user.getUsername());
+//            this.baseMapper.insert(manLocDetl);
+//        }
     }
 
     @Override
@@ -243,7 +311,7 @@
         }
     }
 
-    private void addManlocDetl(LocDetlAdjustParam.LocDetlAdjust param, String locNo){
+    private ManLocDetl addManlocDetl(LocDetlAdjustParam.LocDetlAdjust param, String locNo){
         Date now = new Date();
         ManLocDetl manLocDetl = new ManLocDetl();
         Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", locNo));
@@ -260,6 +328,8 @@
         manLocDetl.setLocNo(locNo);
         manLocDetl.setStatus(1);
         this.insert(manLocDetl);
+
+        return manLocDetl;
     }
 
 }
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 9aeabad..541d386 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -492,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());

--
Gitblit v1.9.1