From 1c0dbad152362ac704a27ecfc5b5d08247385d87 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期二, 21 十月 2025 17:12:48 +0800
Subject: [PATCH] 13

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  450 ++++++++-----------------------------------------------
 1 files changed, 71 insertions(+), 379 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 cfbc7fb..2759dad 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -7,13 +7,12 @@
 import com.core.common.*;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
-import com.zy.asrs.entity.param.*;
+import com.zy.asrs.entity.param.CombParam;
+import com.zy.asrs.entity.param.ForwardAGVTaskParam;
+import com.zy.asrs.entity.param.MobileAdjustParam;
+import com.zy.asrs.entity.param.OpenOrderPakinParam;
 import com.zy.asrs.mapper.BasDevpMapper;
 import com.zy.asrs.service.*;
-import com.zy.asrs.third.CodeDataParam;
-import com.zy.asrs.third.CodeParam;
-import com.zy.asrs.third.MesResponse;
-import com.zy.asrs.third.TokenUtils;
 import com.zy.asrs.utils.MatUtils;
 import com.zy.common.constant.AgvSiteConstant;
 import com.zy.common.constant.ApiInterfaceConstant;
@@ -29,9 +28,6 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -56,8 +52,6 @@
     private WrkMastService wrkMastService;
     @Autowired
     private WrkDetlService wrkDetlService;
-    @Autowired
-    private PackService packService;
     @Autowired
     private OpenService openService;
     @Autowired
@@ -137,12 +131,7 @@
         String message = "";
         boolean success = false;
         try {
-            response = new HttpHandler.Builder()
-                    .setUri(ApiInterfaceConstant.AGV_IP)
-                    .setPath(ApiInterfaceConstant.AGV_CALL_IN_PATH)
-                    .setJson(body)
-                    .build()
-                    .doPost();
+            response = new HttpHandler.Builder().setUri(ApiInterfaceConstant.AGV_IP).setPath(ApiInterfaceConstant.AGV_CALL_IN_PATH).setJson(body).build().doPost();
             JSONObject jsonObject = JSON.parseObject(response);
             if (jsonObject.getInteger("code").equals(0)) {
                 success = true;
@@ -158,15 +147,7 @@
         } finally {
             try {
                 // 淇濆瓨鎺ュ彛鏃ュ織
-                apiLogService.save(
-                        "鍏ュ簱鍛煎彨agv",
-                        ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH,
-                        null,
-                        "127.0.0.1",
-                        body,
-                        response,
-                        success
-                );
+                apiLogService.save("鍏ュ簱鍛煎彨agv", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH, null, "127.0.0.1", body, response, success);
             } catch (Exception e) {
                 log.error("", e);
             }
@@ -192,12 +173,7 @@
         String message = "";
         boolean success = false;
         try {
-            response = new HttpHandler.Builder()
-                    .setUri(ApiInterfaceConstant.AGV_IP)
-                    .setPath(ApiInterfaceConstant.AGV_BIND_PATH)
-                    .setJson(body)
-                    .build()
-                    .doPost();
+            response = new HttpHandler.Builder().setUri(ApiInterfaceConstant.AGV_IP).setPath(ApiInterfaceConstant.AGV_BIND_PATH).setJson(body).build().doPost();
             JSONObject res = JSON.parseObject(response);
             message = jsonObject.getString("message");
             if (res.getInteger("code").equals(0)) {
@@ -210,15 +186,7 @@
         } finally {
             try {
                 // 淇濆瓨鎺ュ彛鏃ュ織
-                apiLogService.save(
-                        "璋冪敤agv瑙g粦鏆傚瓨浣�",
-                        ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH,
-                        null,
-                        "127.0.0.1",
-                        body,
-                        response,
-                        success
-                );
+                apiLogService.save("璋冪敤agv瑙g粦鏆傚瓨浣�", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, null, "127.0.0.1", body, response, success);
             } catch (Exception e) {
                 log.error("", e);
             }
@@ -242,12 +210,7 @@
         String response = "";
         boolean success = false;
         try {
-            response = new HttpHandler.Builder()
-                    .setUri(ApiInterfaceConstant.AGV_IP)
-                    .setPath(ApiInterfaceConstant.AGV_BIND_PATH)
-                    .setJson(body)
-                    .build()
-                    .doPost();
+            response = new HttpHandler.Builder().setUri(ApiInterfaceConstant.AGV_IP).setPath(ApiInterfaceConstant.AGV_BIND_PATH).setJson(body).build().doPost();
             JSONObject res = JSON.parseObject(response);
             if (res.getInteger("code").equals(0)) {
                 success = true;
@@ -259,15 +222,7 @@
         } finally {
             try {
                 // 淇濆瓨鎺ュ彛鏃ュ織
-                apiLogService.save(
-                        "璋冪敤agv缁戝畾浠撲綅",
-                        ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH,
-                        null,
-                        "127.0.0.1",
-                        body,
-                        response,
-                        success
-                );
+                apiLogService.save("璋冪敤agv缁戝畾浠撲綅", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, null, "127.0.0.1", body, response, success);
             } catch (Exception e) {
                 log.error("", e);
             }
@@ -281,32 +236,26 @@
         if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
             throw new CoolException(BaseRes.PARAM);
         }
-        HashMap<String, Object> comData = new HashMap<>();
-        param.getCombMats().forEach(elem -> {
-            // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
-            if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
-                    eq("zpallet", param.getBarcode())
-                    .eq("io_status", "N")
-                    .eq("matnr", elem.getMatnr()).eq("batch", elem.getBatch())) > 0) {
-                throw new CoolException(param.getBarcode() + "宸叉湁鐩稿悓鏁版嵁");
-            }
-            if (comData.get(elem.getThreeCode()) == null) {
-                comData.put(elem.getThreeCode(), elem);
-            } else {
-                throw new CoolException(elem.getThreeCode() + "璇ユ潯鐮佹壂鐮佷簡澶氭");
-            }
-        });
-
+//        if(param.getCombMats().size()>1){
+//            throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒");
+//        }
+        // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
+        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
+            throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+        }
 
         if (param.getBarcode().length() != 8) {
             throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
         }
+//        if (param.getCombMats().size()>1){
+//            throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode());
+//        }
 
         int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()));
         int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()));
-//        int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode()));
-        if (countLoc > 0 || countWrk > 0) {
-            throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+        int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
+        if (countLoc > 0 || countWrk > 0 || countwait > 0) {
+            throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
         }
 
         Date now = new Date();
@@ -317,15 +266,6 @@
             // 鐢熸垚鍏ュ簱閫氱煡妗�
             List<DetlDto> detlDtos = new ArrayList<>();
             param.getCombMats().forEach(elem -> {
-
-                // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
-                if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
-                        eq("zpallet", param.getBarcode())
-                        .eq("io_status", "N")
-                        .eq("matnr", elem.getMatnr()).eq("three_code", elem.getThreeCode())) > 0) {
-                    throw new CoolException(param.getBarcode() + "宸叉湁鐩稿悓鏁版嵁");
-                }
-
                 DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
                 if (DetlDto.has(detlDtos, detlDto)) {
                     DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
@@ -344,8 +284,8 @@
                 }
                 WaitPakin waitPakin = new WaitPakin();
                 waitPakin.sync(mat);
-                waitPakin.setSku(detlDto.getBatch());
-                //waitPakin.setBatch(detlDto.getBatch());
+                waitPakin.setTemp2(detlDto.getTemp2());
+                waitPakin.setBatch(detlDto.getBatch());
                 waitPakin.setZpallet(param.getBarcode());   // 鎵樼洏鐮�
                 waitPakin.setIoStatus("N");     // 鍏ュ嚭鐘舵��
                 waitPakin.setAnfme(detlDto.getAnfme());  // 鏁伴噺
@@ -360,135 +300,53 @@
             }
             // 鍏宠仈缁勬墭
         } else {
-            Order order = orderService.selectByNo(param.getOrderNo());
+
+            OrderPakin order = orderService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", param.getOrderNo()));
             if (Cools.isEmpty(order) || order.getSettle() > 2) {
                 throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
             }
             // 鐢熸垚鍏ュ簱閫氱煡妗�
             List<DetlDto> detlDtos = new ArrayList<>();
-
-            List<String> codes = new ArrayList<>();
-            for (CombParam.CombMat elem : param.getCombMats()) {
-                codes.add(elem.getThreeCode());
-            }
-            List<CodeDataParam> data = getData(TokenUtils.getToken(url), new CodeParam(codes));
-            List<CombParam.CombMat> combMats = param.getCombMats();
-            for (int i = 0; i < data.size(); i++) {
-
-                //}
-                //for (CombParam.CombMat elem : param.getCombMats()) {
-                CombParam.CombMat elem = combMats.get(i);
-                CodeDataParam codeDataParam = data.get(i);
-
-                elem.setTemp1(codeDataParam.getQuality());
-                elem.setAnfme(codeDataParam.getQty());
-                //elem.setBatch(codeDataParam.getBatchNum());
-                elem.setThreeCode(codeDataParam.getBarcode());
-                elem.setMatnr(codeDataParam.getProductionCode());
-                elem.setMaktx(codeDataParam.getProductionName());
-//            param.getCombMats().forEach(elem -> {
+            param.getCombMats().forEach(elem -> {
 
                 // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch());
-                if (Cools.isEmpty(orderDetl)) {
-                     orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), null);
-                    if (Cools.isEmpty(orderDetl)){
-                        throw new CoolException("璇ュ崟鎹腑鏈壘鍒板搴旂墿鏂欐槑缁�");
-                    }
-                }
-                if (Cools.isEmpty(codeDataParam.getQuality())) {
-                    throw new CoolException("鏉$爜鏈繑鍥炶川閲忕姸鎬�");
-                }
-                if (Integer.parseInt(codeDataParam.getQuality()) != orderDetl.getInspect()) {
-                    throw new CoolException("鍗曟嵁璐ㄩ噺鐘舵�佸拰缁勬墭鐗╂枡涓嶅尮閰�");
-                }
-                if (elem.getAnfme() > orderDetl.getEnableQty()) {
-                    throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+                OrderDetlPakout orderDetlPakout = orderDetlService.selectById(elem.getDetlId());
+                if (elem.getAnfme() > orderDetlPakout.getEnableQty()) {
+                    throw new CoolException(orderDetlPakout.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
                 }
                 // 淇敼璁㈠崟浣滀笟鏁伴噺
-                if (!orderDetlService.increaseWorkQty2(orderDetl.getId(),  elem.getAnfme())) {
+                if (!orderDetlService.increaseWorkQtyById(orderDetlPakout.getId(), elem.getAnfme())) {
                     throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
                 }
 
-//                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getManu());
-                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(), elem.getThreeCode()
-                        , orderDetl.getManu(), codeDataParam.getBatchNum(), orderDetl.getSupp(), orderDetl.getTemp1(), orderDetl.getTemp2(), orderDetl.getTemp3(), orderDetl.getTemp4());
-                detlDto.setTemp1(codeDataParam.getQuality());
-                detlDto.setFromOrderNo(codeDataParam.getBarcode());
-                if (DetlDto.has(detlDtos, detlDto)) {
-                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getFromOrderNo());
-                    assert one != null;
-                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
-                } else {
-                    detlDtos.add(detlDto);
-                }
-//            });
-            }
-            for (DetlDto detlDto : detlDtos) {
-                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
+                Mat mat = matService.selectByMatnr(orderDetlPakout.getMatnr());
                 if (Cools.isEmpty(mat)) {
-                    throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
+                    throw new CoolException(orderDetlPakout.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
                 }
                 WaitPakin waitPakin = new WaitPakin();
                 waitPakin.sync(mat);
-                waitPakin.setSku(detlDto.getBatch());
                 waitPakin.setOrderNo(order.getOrderNo());   // 鍗曟嵁缂栧彿
-                //waitPakin.setBatch(detlDto.getBatch());     // 搴忓垪鐮�
+                waitPakin.setBatch(orderDetlPakout.getBatch());     // 搴忓垪鐮�
                 waitPakin.setZpallet(param.getBarcode());   // 鎵樼洏鐮�
                 waitPakin.setIoStatus("N");     // 鍏ュ嚭鐘舵��
-                waitPakin.setAnfme(detlDto.getAnfme());  // 鏁伴噺
+                waitPakin.setAnfme(elem.getAnfme());  // 鏁伴噺
                 waitPakin.setStatus("Y");    // 鐘舵��
                 waitPakin.setAppeUser(userId);
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
-                waitPakin.setDanger(detlDto.getDanger());
-                waitPakin.setManu(detlDto.getMark()); //鏍囪
-                waitPakin.setOrigin(order.getItemName());//浠撳簱
-                waitPakin.setSupp(detlDto.getSuppName()); //渚涘簲鍟�
-                waitPakin.setSku(detlDto.getCustomer()); //瀹㈡埛鍚嶇О
-                waitPakin.setThreeCode(detlDto.getFromOrderNo()); //鏉$爜
-                waitPakin.setTemp1(detlDto.getTemp1());
-                waitPakin.setTemp2(detlDto.getTemp2());
-                waitPakin.setTemp3(detlDto.getTemp3());
-                waitPakin.setTemp4(detlDto.getTemp4());
-                int countWrk2 = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()));
-                if (countWrk2 > 0) {
-                    throw new CoolException("宸ヤ綔妗f潯鐮佹暟鎹凡瀛樺湪===>>" + param.getBarcode());
-                }
+
+                waitPakin.setBatch(orderDetlPakout.getBatch());
                 if (!waitPakinService.insert(waitPakin)) {
                     throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
                 }
-            }
+            });
+
             orderService.updateSettle(order.getId(), 2L, userId);
         }
 
     }
 
-
-    public List<CodeDataParam> getData(Map<String, Object> token, CodeParam codeParam) {
-        String response = null;
-        try {
-            response = new HttpHandler.Builder()
-                    .setHeaders(token)
-                    .setUri(url)
-                    .setPath(code)
-                    .setJson(JSON.toJSONString(codeParam))
-                    .build()
-                    .doPost();
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        log.info("getData:{}", response);
-        MesResponse jsonObject = JSON.parseObject(response, MesResponse.class);
-        if (jsonObject.getCode().equals(200)) {
-            JSONObject jsonObject1 = JSON.parseObject(jsonObject.getData());
-            if (jsonObject1.getString("barcodeList") != null) {
-                return JSON.parseArray(jsonObject1.getString("barcodeList"), CodeDataParam.class);
-            }
-        }
-        throw new CoolException(jsonObject.getMessage());
-    }
 
     @Override
     @Transactional
@@ -500,14 +358,13 @@
         if (param.getCombMats().stream().anyMatch(obj -> obj.getAnfme() == null)) {
             throw new CoolException("鍏ュ簱鐗╂枡鏁伴噺涓嶈兘涓虹┖");
         }
-        Order order = orderService.selectByNo(param.getOrderNo());
+        OrderPakin order = orderService.selectByNo(param.getOrderNo());
         if (Cools.isEmpty(order) || order.getSettle() > 2) {
             throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
         }
 
         // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
-        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
-                eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
+        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
             throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
         }
 
@@ -527,12 +384,12 @@
         Date now = new Date();
         for (CombParam.CombMat combMat : param.getCombMats()) {
             // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-            OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch());
-            if (Cools.isEmpty(orderDetl)) {
+            OrderDetlPakout orderDetlPakout = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch());
+            if (Cools.isEmpty(orderDetlPakout)) {
                 throw new CoolException("璇ュ崟鎹腑鏈壘鍒板搴旂墿鏂欐槑缁�");
             }
-            if (combMat.getAnfme() > orderDetl.getEnableQty()) {
-                throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+            if (combMat.getAnfme() > orderDetlPakout.getEnableQty()) {
+                throw new CoolException(orderDetlPakout.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
             }
             // 淇敼璁㈠崟浣滀笟鏁伴噺
             if (!orderDetlService.increaseWorkQty(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) {
@@ -552,18 +409,17 @@
             wrkDetl.setAppeUser(userId);
             wrkDetl.setModiTime(now);
             wrkDetl.setModiUser(userId);
-            wrkDetl.setManu(orderDetl.getManu());
-            wrkDetl.setSupp(orderDetl.getSupp());
-            wrkDetl.setTemp1(orderDetl.getTemp1());
-            wrkDetl.setTemp2(orderDetl.getTemp2());
-            wrkDetl.setTemp3(orderDetl.getTemp3());
-            wrkDetl.setTemp4(orderDetl.getTemp4());
+            wrkDetl.setManu(orderDetlPakout.getManu());
+            wrkDetl.setSupp(orderDetlPakout.getSupp());
+            wrkDetl.setTemp1(orderDetlPakout.getTemp1());
+            wrkDetl.setTemp2(orderDetlPakout.getTemp2());
+            wrkDetl.setTemp3(orderDetlPakout.getTemp3());
+            wrkDetl.setTemp4(orderDetlPakout.getTemp4());
             wrkDetlService.insert(wrkDetl);
         }
 
 
     }
-
 
 
     // 鏌ユ壘鍟嗗搧
@@ -649,162 +505,7 @@
 
     }
 
-    @Override
-    @Transactional
-    public void packComb(CombParam param, Long userId) {
-        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湪杩涜鍏ュ簱");
-        }
-        Date now = new Date();
 
-        boolean packDown = Parameter.get().getPackDown().equals("true");
-
-        // 鏃犲崟缁勬墭
-        if (Cools.isEmpty(param.getOrderNo())) {
-
-            // 鐢熸垚鍏ュ簱閫氱煡妗�
-            List<DetlDto> detlDtos = new ArrayList<>();
-            param.getCombMats().forEach(elem -> {
-                // 鎵撳寘涓婄嚎鏁版嵁鏍¢獙
-                if (packDown) {
-                    Pack pack = packService.selectByBarcode(elem.getMatnr());
-                    if (pack == null) {
-                        throw new CoolException(elem.getMatnr() + "鏉$爜鍐椾綑锛岃妫�鏌ワ紒");
-                    }
-                    if (pack.getSettle() != 1) {
-                        throw new CoolException(elem.getMatnr() + "鏉$爜宸蹭笅绾匡紝璇锋鏌ワ紒");
-                    }
-                }
-                Mat analyse = MatUtils.analyseMat(elem.getMatnr());
-                // 鏉$爜銆佺墿鏂欎唬鐮併�佸簭鍒楀彿銆佹暟閲�
-                DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme());
-//                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
-                if (DetlDto.has(detlDtos, detlDto)) {
-                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
-                    assert one != null;
-                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
-                } else {
-                    detlDtos.add(detlDto);
-                }
-            });
-
-            if (packDown) {
-                MesCombParam mesCombParam = new MesCombParam();
-                mesCombParam.setZpallet(param.getBarcode());
-                mesCombParam.setPakinTime(DateUtils.convert(now));
-                mesCombParam.setLgort("5008");
-                mesCombParam.setPlantCode("5000");
-                mesCombParam.setFromCode("5012-20");
-                mesCombParam.setStationCode("JJQ-PFZPDB-XX");
-                for (DetlDto detlDto : detlDtos) {
-                    mesCombParam.getList().add(new MesCombParam.Detl(detlDto.getOrderNo(), detlDto.getAnfme()));
-                }
-                String response = "";
-                boolean success = false;
-//                try {
-//                    response = new HttpHandler.Builder()
-//                            .setUri(url)
-//                            .setPath(code)
-//                            .setJson(JSON.toJSONString(mesCombParam))
-//                            .build()
-//                            .doPost();
-//                    JSONObject jsonObject = JSON.parseObject(response);
-//                    if (jsonObject.getInteger("code").equals(200)) {
-//                        success = true;
-//                    } else if (jsonObject.getInteger("code").equals(500)) {
-//                        log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
-//                        throw new CoolException(jsonObject.getString("msg"));
-//                    } else {
-//                        log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
-//                        throw new CoolException("涓婃姤mes绯荤粺澶辫触");
-//                    }
-//                } catch (Exception e) {
-//                    log.error("fail", e);
-//                    throw new CoolException(e.getMessage());
-//                } finally {
-//                    try {
-//                        // 淇濆瓨鎺ュ彛鏃ュ織
-//                        apiLogService.save(
-//                                "鎵撳寘涓嬬嚎甯墭涓婃姤",
-//                                MesConstant.URL + MesConstant.PACK_DOWN_URL,
-//                                null,
-//                                "127.0.0.1",
-//                                JSON.toJSONString(mesCombParam),
-//                                response,
-//                                success
-//                        );
-//                    } catch (Exception e) { log.error("", e); }
-//                }
-
-            }
-
-            // 鐢熸垚鍏ュ簱鍗曟嵁
-            String orderNo = "PACK" + snowflakeIdWorker.nextId();
-            OpenOrderPakinParam openParam = new OpenOrderPakinParam();
-            openParam.setOrderNo(orderNo);
-            openParam.setInboundDate(DateUtils.convert(now));
-            openParam.setOrderType("鎵撳寘鍏ュ簱鍗�");
-            openParam.setDetails(detlDtos);
-            openService.pakinOrderCreate(openParam);
-            Order order = orderService.selectByNo(orderNo);
-            if (null == order) {
-                throw new CoolException("鐢熸垚鍗曟嵁澶辫触");
-            }
-            if (!orderService.updateSettle(order.getId(), 2L, userId)) {
-                throw new CoolException("淇敼鍗曟嵁鐘舵�佸け璐�");
-            }
-
-            // 鐢熸垚鍏ュ簱閫氱煡妗�
-            for (DetlDto detlDto : detlDtos) {
-
-                // 淇敼浣滀笟鏁伴噺 ----------------------------------------
-                // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch());
-                if (detlDto.getAnfme() > orderDetl.getEnableQty()) {
-                    throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
-                }
-                // 淇敼璁㈠崟浣滀笟鏁伴噺
-                if (!orderDetlService.increaseWorkQty(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme())) {
-                    throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
-                }
-
-                // 淇濆瓨鍏ュ簱閫氱煡妗�
-                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
-                if (Cools.isEmpty(mat)) {
-                    throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
-                }
-                WaitPakin waitPakin = new WaitPakin();
-                waitPakin.sync(mat);
-                waitPakin.setOrderNo(orderNo);
-                waitPakin.setBatch(detlDto.getBatch());
-                waitPakin.setZpallet(param.getBarcode());   // 鎵樼洏鐮�
-                waitPakin.setIoStatus("N");     // 鍏ュ嚭鐘舵��
-                waitPakin.setAnfme(detlDto.getAnfme());  // 鏁伴噺
-                waitPakin.setStatus("Y");    // 鐘舵��
-                waitPakin.setAppeUser(userId);
-                waitPakin.setAppeTime(now);
-                waitPakin.setModiUser(userId);
-                waitPakin.setModiTime(now);
-                if (!waitPakinService.insert(waitPakin)) {
-                    throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
-                }
-                // 淇敼鎵撳寘鏁版嵁鐘舵��
-                Pack pack = packService.selectByBarcode(detlDto.getOrderNo());
-                pack.setSettle(2L);
-                pack.setUpdateTime(now);
-                pack.setUpdateBy(userId);
-                if (!packService.updateById(pack)) {
-                    throw new CoolException("淇敼鎵撳寘鏁版嵁寮傚父");
-                }
-            }
-
-        }
-    }
 
     @Override
     @Transactional
@@ -814,34 +515,32 @@
 
         BasDevp sta = basDevpService.checkSiteStatus(staNo);
         //鏍规嵁璁㈠崟鍙风敓鎴愬嚭搴撲换鍔″伐浣滄。
-        Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderNo));
+        OrderPakin order = orderService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", orderNo));
         if (order.getSettle() != 1 && order.getSettle() != 2) {
             throw new CoolException("璇ヨ鍗曞凡澶勭悊");
         }
 
-        List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", orderNo));
+        List<OrderDetlPakout> orderDetlPakouts = orderDetlService.selectList(new EntityWrapper<OrderDetlPakout>().eq("order_no", orderNo));
         Date now = new Date();
-        for (OrderDetl orderDetl : orderDetls) {
+        for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) {
             //鏌ヨ鎵�鏈夊簱浣嶇姸鎬佷负F鐨勫簱浣嶄俊鎭�
-            List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, null, orderDetl.getSupp(), orderDetl.getTemp1(), orderDetl.getTemp2());
+            List<LocDetl> locDetls = locDetlService.queryStock(orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), null, null, orderDetlPakout.getSupp(), orderDetlPakout.getTemp1(), orderDetlPakout.getTemp2());
             if (locDetls.size() == 0) {
                 throw new CoolException("搴撳瓨涓病鏈夎鐗╂枡");
             }
             for (LocDetl locDetl : locDetls) {
                 //濡傛灉璇ュ簱浣嶅嚭搴撹矾绾挎墍鐢ㄧ殑鍫嗗灈鏈簅ut_enable涓嶄负Y,璺宠繃璇ュ惊鐜�
-                LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
-                        .eq("loc_no", locDetl.getLocNo()));
+                LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo()));
                 if (Cools.isEmpty(locMast)) {
                     continue;
                 }
-                BasCrnp crn_no = basCrnpService.selectOne(new EntityWrapper<BasCrnp>()
-                        .eq("crn_no", locMast.getCrnNo()));
+                BasCrnp crn_no = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", locMast.getCrnNo()));
                 if (Cools.isEmpty(crn_no) || !crn_no.getOutEnable().equals("Y")) {
                     continue;
                 }
 
                 //鍙嚭搴撴暟閲� = 璁㈠崟鏁伴噺 - 浣滀笟涓暟閲�
-                Double outQty = orderDetl.getAnfme() - orderDetl.getWorkQty();
+                Double outQty = orderDetlPakout.getAnfme() - orderDetlPakout.getWorkQty();
                 if (outQty <= 0) {
                     break;
                 }
@@ -850,22 +549,21 @@
                 Double curOutQty = outQty >= locDetl.getAnfme() ? locDetl.getAnfme() : outQty;   //鏈鍑哄簱閲�
                 int ioType = sumCount <= curOutQty ? 101 : 103;
 
-                stockOut(orderDetl, sta, locDetl, curOutQty, ioType, userId, now);
+                stockOut(orderDetlPakout, sta, locDetl, curOutQty, ioType, userId, now);
                 order.setSettle(2L);
                 order.setUpdateBy(userId);
                 order.setUpdateTime(now);
-                if (!orderService.update(order, new EntityWrapper<Order>().eq("order_no", orderNo))) {
+                if (!orderService.update(order, new EntityWrapper<OrderPakin>().eq("order_no", orderNo))) {
                     throw new CoolException("鏇存柊璁㈠崟鐘舵�佸け璐�");
                 }
-                orderDetl.setWorkQty(orderDetl.getWorkQty() + curOutQty);
-                orderDetl.setUpdateBy(userId);
-                orderDetl.setUpdateTime(now);
-                Wrapper wrapper = new EntityWrapper<OrderDetl>().eq("order_no", orderNo)
-                        .eq("matnr", orderDetl.getMatnr());
-                if (!Cools.isEmpty(orderDetl.getBatch())) {
-                    wrapper.eq("batch", orderDetl.getBatch());
+                orderDetlPakout.setWorkQty(orderDetlPakout.getWorkQty() + curOutQty);
+                orderDetlPakout.setUpdateBy(userId);
+                orderDetlPakout.setUpdateTime(now);
+                Wrapper wrapper = new EntityWrapper<OrderDetlPakout>().eq("order_no", orderNo).eq("matnr", orderDetlPakout.getMatnr());
+                if (!Cools.isEmpty(orderDetlPakout.getBatch())) {
+                    wrapper.eq("batch", orderDetlPakout.getBatch());
                 }
-                if (!orderDetlService.update(orderDetl, wrapper)) {
+                if (!orderDetlService.update(orderDetlPakout, wrapper)) {
                     throw new CoolException("鏇存柊璁㈠崟鏄庣粏澶辫触");
                 }
             }
@@ -937,19 +635,13 @@
     }
 
 
-
-
     @Override
     @Transactional
-    public void stockOut(OrderDetl orderDetl, BasDevp staNo, LocDetl locDetl,
-                         Double curOutQty, Integer ioType, Long userId, Date now) {
+    public void stockOut(OrderDetlPakout orderDetlPakout, BasDevp staNo, LocDetl locDetl, Double curOutQty, Integer ioType, Long userId, Date now) {
         // 鑾峰彇搴撲綅
         LocMast locMast = locMastService.selectById(locDetl.getLocNo());
         // 鑾峰彇璺緞
-        Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
-                .eq("type_no", ioType)
-                .eq("stn_no", staNo.getDevNo())
-                .eq("crn_no", locMast.getCrnNo());
+        Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>().eq("type_no", ioType).eq("stn_no", staNo.getDevNo()).eq("crn_no", locMast.getCrnNo());
 
         StaDesc staDesc = staDescService.selectOne(wrapper);
         if (Cools.isEmpty(staDesc)) {
@@ -987,7 +679,7 @@
         wrkDetl.setWrkNo(workNo);
         wrkDetl.setIoTime(now);
         wrkDetl.setAnfme(curOutQty); // 鏁伴噺
-        wrkDetl.setOrderNo(orderDetl.getOrderNo());
+        wrkDetl.setOrderNo(orderDetlPakout.getOrderNo());
         wrkDetl.setAppeTime(now);
         wrkDetl.setAppeUser(userId);
         wrkDetl.setModiTime(now);

--
Gitblit v1.9.1