From 4e7c38ae990b82399eab275bd9d18079785eaa38 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期一, 31 十月 2022 14:05:41 +0800
Subject: [PATCH] Merge branch 'bfasrs' of http://47.97.1.152:5880/r/zy-asrs into bfasrs

---
 src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java |  108 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 94 insertions(+), 14 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 d846ed2..06a9b5e 100644
--- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -1,5 +1,6 @@
 package com.zy.asrs.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.core.common.BaseRes;
@@ -19,6 +20,7 @@
 import com.zy.common.model.enums.WorkNoType;
 import com.zy.common.properties.SlaveProperties;
 import com.zy.common.service.CommonService;
+import com.zy.common.web.BaseController;
 import com.zy.common.web.WcsController;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -213,6 +215,9 @@
                 ioType = dto.isAll() ? 101 : 103;
             } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) {
                 ioType = 107;
+                if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) {
+                    throw new CoolException("鍙兘瀛樺湪涓�绗旂洏鐐逛换鍔�");
+                }
             }
             assert ioType != null;
             // 鑾峰彇搴撲綅
@@ -327,16 +332,14 @@
         // 鐢熸垚宸ヤ綔妗f槑缁�
         for (LocDto locDto : taskDto.getLocDtos()) {
             if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; }
-            OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch());
-            if (orderDetl == null) {
-                orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null);
-            }
             LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch());
             if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) {
                 throw new CoolException(locDto.getLocNo() + "搴撲綅涓�" + locDto.getMatnr() + "鍟嗗搧搴撳瓨涓嶈冻锛�");
             }
+            Mat mat = matService.selectByMatnr(locDto.getMatnr());
+            assert mat != null;
             WrkDetl wrkDetl = new WrkDetl();
-            wrkDetl.sync(orderDetl);
+            wrkDetl.sync(mat);
             wrkDetl.setZpallet(wrkMast.getBarcode());
             wrkDetl.setIoTime(now);
             wrkDetl.setWrkNo(workNo);
@@ -351,10 +354,40 @@
                 throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
             }
             // 淇敼璁㈠崟鏄庣粏
-            if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) {
-                throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触");
+            if (BaseController.isJSON(locDto.getOrderNo())) {
+                String[] orderNos = GetOrderNo(locDto.getOrderNo());
+                Double anfme = locDto.getAnfme();
+                for (String orderNo:orderNos){
+                    OrderDetl orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), locDto.getBatch());
+                    if (orderDetl == null) {
+                        orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), null);
+                    }
+                    if (orderDetl.getAnfme()<=anfme){
+                        if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getAnfme())) {
+                            throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触");
+                        }
+                        anfme=anfme-orderDetl.getAnfme();
+                    }else{
+                        if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(),anfme)) {
+                            throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触");
+                        }
+                    }
+                    orderService.updateSettle(orderDetl.getOrderId(), 2L, userId);
+                }
+            } else {
+                // 璁㈠崟鍚堝苟鍑哄簱
+                List<OrderDto> orderDtoList = JSON.parseArray(locDto.getOrderNo(), OrderDto.class);
+                for (OrderDto orderDto : orderDtoList) {
+                    OrderDetl orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch());
+                    if (orderDetl == null) {
+                        orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), null);
+                    }
+                    if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDto.getAnfme())) {
+                        throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触");
+                    }
+                    orderService.updateSettle(orderDetl.getOrderId(), 2L, userId);
+                }
             }
-            orderService.updateSettle(orderDetl.getOrderId(), 2L, userId);
         }
         // 淇敼搴撲綅鐘舵��:   F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
         locMast = locMastService.selectById(taskDto.getLocNo());
@@ -368,6 +401,39 @@
         } else {
             throw new CoolException(taskDto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
         }
+    }
+
+    private String[] GetOrderNo(String orderNo){
+        String s1 = Recombination(orderNo, ",");
+        String s2 = Recombination(s1, "\"}");
+        String[] s3= s2.split("\"");
+        String[] s =new String[(s3.length-1)/3];
+        int i=0;
+        int j=0;
+        for (String ss:s3){
+            if (ss.equals("orderNo")){
+                s[i]=s3[j+2];
+                i++;
+            }
+            j++;
+        }
+        return s;
+    }
+    private String Recombination(String a,String b){
+        String[] d=a.split(b);
+        String c="";
+        if (b.equals(",")){
+            for (int i=0;i<d.length;i++){
+                if (i%2!=0){
+                    c=c+d[i];
+                }
+            }
+        }else if(b.equals("\"}")){
+            for (int i=0;i<d.length-1;i++){
+                c=c+d[i];
+            }
+        }
+        return c;
     }
 
     @Override
@@ -504,6 +570,9 @@
     @Override
     @Transactional
     public void locCheckOut(StockOutParam param, Long userId) {
+        if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) {
+            throw new CoolException("鍙兘瀛樺湪涓�绗旂洏鐐逛换鍔�");
+        }
         // 鐩爣绔欑偣鐘舵�佹娴�
         BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite());
         // 鑾峰彇搴撲綅鏄庣粏
@@ -589,7 +658,7 @@
                 throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
             }
         } else {
-            throw new CoolException("婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
+            throw new CoolException(sourceLoc.getLocNo() + "婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
         }
         // 淇敼鐩爣搴撲綅鐘舵��
         if (loc.getLocSts().equals("O")) {
@@ -809,11 +878,19 @@
         List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
         for (WrkDetl wrkDetl : wrkDetls) {
             if (!Cools.isEmpty(wrkDetl.getOrderNo())) {
-                if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) {
-                    throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触");
+                if (BaseController.isJSON(wrkDetl.getOrderNo())) {
+                    if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) {
+                        throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触");
+                    }
+                } else {
+                    // 璁㈠崟鍚堝苟鍑哄簱
+                    List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class);
+                    for (OrderDto orderDto : orderDtoList) {
+                        if (!orderDetlService.decrease(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) {
+                            throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触");
+                        }
+                    }
                 }
-                // 鐢熸垚鏂扮殑鍑哄簱浣滀笟
-//                        stockOutRe(wrkMast, wrkDetls);
             }
         }
         // 鍙栨秷鎿嶄綔浜哄憳璁板綍
@@ -934,6 +1011,9 @@
         if (Cools.isEmpty(locNos)) {
             return;
         }
+        if (true && !Cools.isEmpty(locNos)) {
+            throw new CoolException("鏆備笉鏀寔绉诲簱浠诲姟");    // todo:luxiaotao 绉诲簱寮�鍏�
+        }
         LocMast one = locMastService.selectById(locNos.get(0));
         List<Integer> rows = Utils.getGroupLoc(Integer.parseInt(locNos.get(0).substring(0, 2)));
         List<LocMast> locMasts = locMastService.queryFreeLocMast(rows, rows.size(), one.getLocType1());
@@ -1029,7 +1109,7 @@
                         throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
                     }
                 } else {
-                    throw new CoolException("婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
+                    throw new CoolException(sourceLoc.getLocNo() + "婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
                 }
                 // 淇敼鐩爣搴撲綅鐘舵��
                 if (loc.getLocSts().equals("O")) {

--
Gitblit v1.9.1