From 7ec0d6926482a21b38c246ad460ca25cc78d6ffc Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期五, 17 四月 2026 12:56:05 +0800
Subject: [PATCH] 1.erp对接 2.电视机对接

---
 src/main/java/com/zy/asrs/controller/OpenController.java |   86 +++++++++++++++++++++++++++++++-----------
 1 files changed, 63 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 6f6cf15..e018904 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -467,6 +467,26 @@
             log.info("[comb] cache: {}", param == null ? "null" : JSON.toJSONString(param));
             request.setAttribute("cache", param);
         }
+
+        if (Cools.isEmpty(param)) {
+            return R.error("娌℃湁鍏ュ簱鏁版嵁");
+        }
+        boolean boo =false;
+        for (MesToCombParam mesToCombParam : param) {
+            if (mesToCombParam.getOperateType()==2){
+                int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", mesToCombParam.getPalletId()));
+                int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", mesToCombParam.getPalletId()));
+                int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",mesToCombParam.getPalletId()).eq("io_status", "Y"));
+                if (countLoc > 0 || countWrk > 0 || countwait > 0) {
+                return R.error(mesToCombParam.getPalletId()+"-宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�,鏃犳硶鍒犻櫎");
+                }
+                waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet",mesToCombParam.getPalletId()));
+                boo = true;
+            }
+        }
+        if (boo){
+            return R.ok();
+        }
         List<MesToCombParam> errorComb = Lists.newArrayList();
         List<MesToCombParam> validComb = Lists.newArrayList();
         for (MesToCombParam mesToCombParam : param) {
@@ -515,7 +535,7 @@
         }
         log.info("[outOrder] cache: {}", JSON.toJSONString(params));
         request.setAttribute("cache", params);
-        Map<String, List<OutTaskParam>> linesByBatch = new LinkedHashMap<>();
+        Map<String, List<OutTaskParam>> linesByBatchSeq = new LinkedHashMap<>();
         for (OutTaskParam outTaskParam : params) {
             if (Cools.isEmpty(outTaskParam) || Cools.isEmpty(outTaskParam.getOrderId())) {
                 return R.error("鍑哄簱鍗曞彿涓嶈兘涓虹┖");
@@ -526,10 +546,10 @@
             if (Cools.isEmpty(outTaskParam.getStationId())) {
                 return R.error("鎵樼洏銆�" + outTaskParam.getPalletId() + "銆嶅嚭搴撳彛缂栫爜涓嶈兘涓虹┖");
             }
-            linesByBatch.computeIfAbsent(outTaskParam.getBatchSeq(), k -> new ArrayList<>()).add(outTaskParam);
+            linesByBatchSeq.computeIfAbsent(outTaskParam.getBatchSeq(), k -> new ArrayList<>()).add(outTaskParam);
         }
 
-        for (Map.Entry<String, List<OutTaskParam>> entry : linesByBatch.entrySet()) {
+        for (Map.Entry<String, List<OutTaskParam>> entry : linesByBatchSeq.entrySet()) {
             List<OutTaskParam> lines = entry.getValue();
             OutTaskParam head = lines.get(0);
             String oid = head.getOrderId();
@@ -564,8 +584,13 @@
             }
         }
 
+        List<OutTaskParam> groupedParams = new ArrayList<>(params.size());
+        for (List<OutTaskParam> lines : linesByBatchSeq.values()) {
+            groupedParams.addAll(lines);
+        }
+
         Set<String> seenPallet = new LinkedHashSet<>();
-        for (OutTaskParam outTaskParam : params) {
+        for (OutTaskParam outTaskParam : groupedParams) {
             String pid = outTaskParam.getPalletId();
             String palletKey = pid == null ? "" : pid;
             if (!seenPallet.add(palletKey)) {
@@ -594,7 +619,7 @@
 
         List<OutTaskParam> missingStock = Lists.newArrayList();
         List<OutTaskParam> missingLoc = Lists.newArrayList();
-        for (OutTaskParam outTaskParam : params) {
+        for (OutTaskParam outTaskParam : groupedParams) {
             int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", outTaskParam.getPalletId()));
             if (countLoc == 0) {
                 missingStock.add(outTaskParam);
@@ -622,7 +647,7 @@
             return R.error("娌℃湁鎵惧埌鎵樼洏鐮佸搴斿簱浣嶏細" + String.join("锛�", badPalletIds)).add(missingLoc);
         }
 
-        return openService.outOrderBatch(params);
+        return openService.outOrderBatch(linesByBatchSeq);
     }
 
     /**
@@ -674,11 +699,20 @@
         return param.getOrderId() + "#" + param.getBatchSeq();
     }
 
+    /**
+     * 鎺ㄨ崘鍑哄簱绔欑偣
+     */
+    @PostMapping("/pakoutStaNo")
+    public synchronized R pakoutStaNo(@RequestBody List<String> barcodes) {
+        String StaNo = "1,2,3,4,5";
+        return R.ok().add(StaNo);
+    }
+
 
     /*************************************鐢佃鏈虹▼搴�***********************************************/
 
     @GetMapping("/locDetl/statistics")
-    public R locDetlStatistics(){
+    public synchronized R locDetlStatistics(){
         HashMap<String, Object> param = new HashMap<>();
         Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(1, 100, param, LocDetl.class));
         for (LocDetl locDetl : stockStatis.getRecords()) {
@@ -691,7 +725,7 @@
     }
 
     @GetMapping("/line/charts")
-    public R locIoLineCharts(){
+    public synchronized R locIoLineCharts(){
         Map<String,Object> map=new HashMap<String, Object>();
         List<AxisBean> list = new ArrayList<AxisBean>();
 
@@ -784,7 +818,7 @@
      * 鍏ュ嚭搴撴寜灏忔椂鎶樼嚎锛氭í杞翠负銆屽綋鍓嶆暣鐐硅捣鍚戝墠鍏� 12 灏忔椂銆嶆粴鍔ㄧ獥鍙o紝涓庡簱琛� ymd锛坹yyy-MM-dd HH锛夊榻�
      */
     @GetMapping("/line/charts/hourly")
-    public R locIoLineChartsHourly() {
+     public synchronized R locIoLineChartsHourly() {
         Map<String, Object> map = new HashMap<>();
         List<AxisBean> list = new ArrayList<>();
 
@@ -819,13 +853,15 @@
                 if (w.getYmd() != null && key.equals(w.getYmd().trim())) {
                     inV = w.getInqty();
                     outV = w.getOutqty();
-                    inC = w.getCube_inqty();
-                    outC = w.getCube_outqty();
+                    inC = w.getCubeInqty();
+                    outC = w.getCubeOutqty();
                     break;
                 }
             }
             data1.add(inV);
             data2.add(outV);
+            data3.add(inC);
+            data4.add(outC);
             calendar.add(Calendar.HOUR_OF_DAY, 1);
         }
 
@@ -841,18 +877,21 @@
         outqty.setData(data2.toArray(array2));
         list.add(outqty);
 
-        AxisBean cubeInqty = new AxisBean();
-        cubeInqty.setName("鍏ュ簱浣撶Н");
-        Integer[] array3 = new Integer[data3.size()];
-        cubeInqty.setData(data3.toArray(array3));
-        list.add(cubeInqty);
+        if (data3.size() >0) {
+            AxisBean cubeInqty = new AxisBean();
+            cubeInqty.setName("鍏ュ簱浣撶Н");
+            Integer[] array3 = new Integer[data3.size()];
+            cubeInqty.setData(data3.toArray(array3));
+            list.add(cubeInqty);
+        }
 
-        AxisBean cubeOutqty = new AxisBean();
-        cubeOutqty.setName("鍑哄簱浣撶Н");
-        Integer[] array4 = new Integer[data4.size()];
-        cubeOutqty.setData(data4.toArray(array4));
-        list.add(cubeOutqty);
-
+        if (data3.size() >0) {
+            AxisBean cubeOutqty = new AxisBean();
+            cubeOutqty.setName("鍑哄簱浣撶Н");
+            Integer[] array4 = new Integer[data4.size()];
+            cubeOutqty.setData(data4.toArray(array4));
+            list.add(cubeOutqty);
+        }
         map.put("categories", categories);
         map.put("rows", list);
         return R.ok(map);
@@ -889,7 +928,8 @@
         }
 
         // 鎬诲簱浣嶆暟
-        Integer total = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty());
+        Integer total1 = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty());
+        Integer total = total1>40000?40000:total1;
         // 浣跨敤涓�
         Integer used = locUseRate.getFqty() + locUseRate.getUqty();
         // 搴撲綅浣跨敤鐜�

--
Gitblit v1.9.1