From b51e3b3d5bb721cec65952498d1c2c882d1a01d6 Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期一, 15 十二月 2025 17:14:22 +0800
Subject: [PATCH] wms功能完善

---
 src/main/java/com/zy/asrs/controller/MesController.java |   80 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/MesController.java b/src/main/java/com/zy/asrs/controller/MesController.java
index 6a0cde5..6a7ba4a 100644
--- a/src/main/java/com/zy/asrs/controller/MesController.java
+++ b/src/main/java/com/zy/asrs/controller/MesController.java
@@ -1,13 +1,19 @@
 package com.zy.asrs.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.Cools;
 import com.core.common.R;
+import com.zy.asrs.entity.BasStation;
 import com.zy.asrs.entity.mes.*;
+import com.zy.asrs.service.BasStationService;
 import com.zy.asrs.service.MesService;
 import com.zy.common.web.BaseController;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
 
 @RestController
 public class MesController extends BaseController {
@@ -28,9 +34,39 @@
     // 鍑哄簱鐢宠
     @PostMapping("/api/mes/outBoundOrder")
     public MesReturn outBoundOrder(@RequestBody MesInApply param){
-
         MesReturn mesReturn = new MesReturn();
-        mesReturn.setSuccess(mesService.outBoundOrder(param) == 1 ? "1" : "2");
+        // 缁堢偣涓虹┖锛岃绠楁帴椹充綅
+        BasStation basStation = null;
+        if (Cools.isEmpty(param.getNextStationId())) {
+            List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("loc_sts", "O"));
+            if(basStations.isEmpty()) {
+                mesReturn.setSuccess("2");
+                mesReturn.setMessage("鏃犵┖鎺ラ┏浣嶏紝璇风◢鍚庡啀璇�!");
+                return mesReturn;
+            }
+            // 鎺ラ┏鐐�
+            basStation = basStations.get(0);
+            param.setNextStationId(basStation.getDevNo());
+
+            // 鍏堟洿鏂版帴椹崇偣鐘舵��
+            basStation.setModiTime(new Date());
+            basStation.setLocSts("S");
+            basStation.setBarcode(param.getDjNo());
+            basStationService.updateById(basStation);
+        }
+        int i = mesService.outBoundOrder(param);
+        if(i == 1) {
+            mesReturn.setSuccess("1");
+        } else {
+            // 閲婃斁鎺ラ┏鐐�
+            if(basStation != null) {
+                basStation.setModiTime(new Date());
+                basStation.setLocSts("O");
+                basStation.setBarcode("");
+                basStationService.updateById(basStation);
+            }
+            mesReturn.setSuccess("2");
+        }
         return mesReturn;
     }
 
@@ -66,11 +102,47 @@
         return mesService.allowOutStation(param);
     }
 
-    // 涓嬪彂杩愯緭浠诲姟
+    @Resource
+    private BasStationService basStationService;
+
+    // 涓嬪彂杩愯緭浠诲姟锛宮es璋冪敤涓嬪垁06(鍛煎彨agv鎼繍)
     @PostMapping("/api/mes/submitTask")
     public JSONObject submitTask(@RequestBody TransTask param){
+        // 缁堢偣涓虹┖锛岃绠楁帴椹充綅
+        BasStation basStation = null;
+        if (Cools.isEmpty(param.getNextStationId())) {
+            List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("loc_sts", "O"));
+            if(basStations.isEmpty()) {
+                JSONObject result = new JSONObject();
+                result.put("taskno", param.getTaskno());
+                result.put("Success", "2");
+                result.put("Message", "鏃犵┖鎺ラ┏浣嶏紝璇风◢鍚庡啀璇�!");
+                return result;
+            }
+            // 鎺ラ┏鐐�
+            basStation = basStations.get(0);
+            param.setNextStationId(basStation.getDevNo());
 
-        return mesService.submitTask(param);
+            // 鍏堟洿鏂版帴椹崇偣鐘舵��
+            basStation.setModiTime(new Date());
+            basStation.setLocSts("S");
+            basStation.setBarcode(param.getDjNo());
+            basStationService.updateById(basStation);
+        }
+
+        param.setAgvFactory(1); // 娴峰悍
+        param.setNextStationId("A1");
+        JSONObject sendAgvTask = mesService.submitTask(param);
+        if (!"1".equals(sendAgvTask.getString("Success"))) {
+            // 閲婃斁鎺ラ┏鐐�
+            if(basStation != null) {
+                basStation.setModiTime(new Date());
+                basStation.setLocSts("O");
+                basStation.setBarcode("");
+                basStationService.updateById(basStation);
+            }
+        }
+        return sendAgvTask;
     }
 
     // 鎺ュ彈鎴愬搧鍒�鍙互鍏ュ簱浜岀淮鐮�

--
Gitblit v1.9.1