From 3b87f36219202b4cec47840bd9f56fdbe53e7d04 Mon Sep 17 00:00:00 2001
From: DESKTOP-9BNTV8O <DESKTOP-9BNTV8O@163.com>
Date: 星期二, 11 三月 2025 20:49:17 +0800
Subject: [PATCH] 初版提交

---
 Admin.NET/WCS.Application/Util/HttpService.cs |  268 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 189 insertions(+), 79 deletions(-)

diff --git a/Admin.NET/WCS.Application/Util/HttpService.cs b/Admin.NET/WCS.Application/Util/HttpService.cs
index b471dc6..e23ca4e 100644
--- a/Admin.NET/WCS.Application/Util/HttpService.cs
+++ b/Admin.NET/WCS.Application/Util/HttpService.cs
@@ -2,6 +2,7 @@
 using Elastic.Clients.Elasticsearch;
 using Furion.Logging;
 using Furion.RemoteRequest.Extensions;
+using NetTaste;
 using Newtonsoft.Json;
 using System.Text;
 using WCS.Application.Entity;
@@ -10,6 +11,8 @@
 namespace WCS.Application;
 public class HttpService
 {
+    private static readonly object OLock = new object();
+
     private dynamic Urls;
 
     private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
@@ -30,28 +33,113 @@
     /// <param name="endLocat"></param>
     /// <param name="taskNo"></param>
     /// <returns></returns>
-    public string RequestRoadWay(string palletNo, string startLocat, string taskModel, string ceng, ref string endLocat, ref string taskNo)
+    public string RequestRoadWay(string palletNo, string startLocat, string taskModel, string ceng, ref string endLocat, ref string taskNo, int palletHeight)
     {
-        string returnStr = "";
+        Log.Information("璋冪敤WMS鎺ュ彛鍙嶉浠诲姟鎺ュ彛-鏄惁閲嶅鐢宠锛�" + palletNo);
+        lock (OLock) 
+        { 
+            string returnStr = "";
        
 
-        var task = _db.Queryable<WcsTask>().First(m => m.IsDelete == false && (m.Status == TaskStatusEnum.Wait || m.Status == TaskStatusEnum.Doing) && m.TaskType == TaskTypeEnum.In && m.PalletNo == palletNo);
+            var task = _db.Queryable<WcsTask>().First(m => m.IsDelete == false && (m.Status == TaskStatusEnum.Wait || m.Status == TaskStatusEnum.Doing) && m.TaskType == TaskTypeEnum.In && m.PalletNo == palletNo);
 
+            if (task == null)
+            {
+                var model = new RequestAsnTask()
+                {
+                    PalletNo = palletNo,
+                    HouseNo = "W01",
+                    TaskModel = taskModel,
+                    PalletHeight = palletHeight
+                };
+
+                string url = Urls.WMSAddress + ":" + Urls.WMSPort;
+                var result =  (url + "/api/DownAPi/RequestRoadWay").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseTasks>().Result;
+                if (result == null)
+                {
+                    returnStr = "-1:璋冪敤WMS鎺ュ彛澶辫触";
+                    return returnStr;
+                }
+                Log.Information("璋冪敤WMS鎺ュ彛鍙嶉浠诲姟鎺ュ彛" + result.ToJson());
+                if (result.Success == 0)
+                {
+
+                    var taskAdd = new WcsTask()
+                    {
+                        TaskType = TaskTypeEnum.In,
+                        Status = TaskStatusEnum.Wait,
+                        Origin = "WMS",
+                        StartLocate = startLocat,
+                        PalletNo = palletNo,
+                        TaskNo = result.TaskList.TaskNo,
+                        Levels = 999,
+                        EndLocate = result.TaskList.EndLocate,
+                        EndRoadway = result.TaskList.EndRoadway,
+                        PalletQty = palletHeight//鎵樼洏楂樺害
+                    };
+                
+                    _db.Insertable(taskAdd).ExecuteCommand();
+                    endLocat = result.TaskList.EndRoadway;
+                    returnStr = result.TaskList.EndLocate;
+                    taskNo = taskAdd.TaskNo;
+                }
+                else
+                {
+                    returnStr = "-1:" + result.Message;
+                    return returnStr;
+                }
+            }
+            else
+            {
+                returnStr = task.EndLocate;
+                endLocat = task.EndRoadway;
+                taskNo = task.TaskNo;
+            }
+
+            endLocat = PLCCommon.RoadwayToStationNum(endLocat, ceng);
+
+            return returnStr;
+        }
+    }
+
+        /// <summary>
+        /// 璋冪敤WMS鎺ュ彛鑷姩鐮佸灈缁戝畾淇℃伅杩斿洖宸烽亾鍙�
+        /// </summary>
+        /// <returns></returns>
+        public string BindRequestRoadWay(string orderNo, string palletNo,decimal qty ,string type,string skuNo, string lotNo, string lotText, string supplierLot, List<WcsBoxInfo> detail,
+        string startLocat, string taskModel, string ceng, ref string endLocat, ref string taskNo, int palletHeight)
+    {
+        string returnStr = "";
+
+        var task = _db.Queryable<WcsTask>().First(m => m.IsDelete == false && (m.Status == TaskStatusEnum.Wait || m.Status == TaskStatusEnum.Doing) && m.TaskType == TaskTypeEnum.In && m.PalletNo == palletNo);
         if (task == null)
         {
-            var model = new RequestAsnTask()
+            var model = new BoxPalletBindVm()
             {
+                OrderCode = "",//鏆傛棤涓婃父绯荤粺缂栧彿
+                AsnNo = orderNo,
+                AsnDetailNo = 0,//鏆傛棤鍏ュ簱鍗曟槑缁嗙紪鍙凤紝WMS鏍规嵁鐗╂枡鎵规鏌ユ壘
                 PalletNo = palletNo,
-                HouseNo = "W01",
-                TaskModel = taskModel
+                Qty = qty,
+                Type = type,
+                SkuNo = skuNo,
+                LotNo = lotNo,
+                LotText = lotText,
+                SupplierLot = supplierLot,
+                PalletHeight = palletHeight,
+                Detail = detail
             };
-
+            Log.Information("璋冪敤WMS鑷姩鐮佸灈鎺ュ彛--璇锋眰鎶ユ枃锛�" + model.ToJson());
             string url = Urls.WMSAddress + ":" + Urls.WMSPort;
-            var result =  (url + "/api/DownAPi/RequestRoadWay").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseTasks>().Result;
-            Log.Information("璋冪敤WMS鎺ュ彛鍙嶉浠诲姟鎺ュ彛" + result.ToJson());
+            var result = (url + "/api/DownApi/BindRequestRoadWay").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseTasks>().Result;
+            Log.Information("璋冪敤WMS鑷姩鐮佸灈鎺ュ彛--杩斿洖鎶ユ枃锛�" + result.ToJson());
             if (result.Success == 0)
             {
-                                
+                if (result.TaskList == null)
+                {
+                    returnStr = $"-1:鍚慦MS鐢宠缁勬墭鍏ュ簱澶辫触";
+                    return returnStr;
+                }
                 var taskAdd = new WcsTask()
                 {
                     TaskType = TaskTypeEnum.In,
@@ -62,78 +150,14 @@
                     TaskNo = result.TaskList.TaskNo,
                     Levels = 999,
                     EndLocate = result.TaskList.EndLocate,
-                    EndRoadway = result.TaskList.EndRoadway
-                };
-                
-                _db.Insertable(taskAdd).ExecuteCommand();
-                endLocat = result.TaskList.EndRoadway;
-                returnStr = result.TaskList.EndLocate;
-                
-            }
-            else
-            {
-                returnStr = "-1:" + result.Message;
-                return returnStr;
-            }
-        }
-        else
-        {
-            returnStr = task.EndLocate;
-            endLocat = task.EndRoadway;
-            taskNo = task.TaskNo;
-        }
-
-        endLocat = PLCCommon.RoadwayToStationNum(endLocat, ceng);
-
-        return returnStr;
-    }
-
-    /// <summary>
-    /// 璋冪敤WMS鎺ュ彛鑷姩鐮佸灈缁戝畾淇℃伅杩斿洖宸烽亾鍙�
-    /// </summary>
-    /// <returns></returns>
-    public string BindRequestRoadWay(string orderNo, string palletNo,decimal qty ,string type,string skuNo, string lotNo, string lotText, string supplierLot, List<WcsBoxInfo> detail,
-        string startLocat, string taskModel, string ceng, ref string endLocat, ref string taskNo)
-    {
-        string returnStr = "";
-
-        var task = _db.Queryable<WcsTask>().First(m => m.IsDelete == false && (m.Status == TaskStatusEnum.Wait || m.Status == TaskStatusEnum.Doing) && m.TaskType == TaskTypeEnum.In && m.PalletNo == palletNo);
-        if (task == null)
-        {
-            var model = new BoxPalletBindVm()
-            {
-                OrderCode= "",//鏆傛棤涓婃父绯荤粺缂栧彿
-                AsnNo= orderNo,
-                AsnDetailNo=0,//鏆傛棤鍏ュ簱鍗曟槑缁嗙紪鍙凤紝WMS鏍规嵁鐗╂枡鎵规鏌ユ壘
-                PalletNo=palletNo,
-                Qty= qty,
-                Type=type,
-                SkuNo=skuNo,
-                LotNo= lotNo,
-                LotText= lotText,
-                SupplierLot= supplierLot,
-                Detail=detail
-            };
-            string url = Urls.WMSAddress + ":" + Urls.WMSPort;
-            var result = (url + "/api/DownAPi/BindRequestRoadWay").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseTasks>().Result;
-            Log.Information("璋冪敤WMS鎺ュ彛鍙嶉浠诲姟鎺ュ彛" + result.ToJson());
-            if (result.Success == 0)
-            {
-                var taskAdd = new WcsTask()
-                {
-                    TaskType = TaskTypeEnum.In,
-                    Status = TaskStatusEnum.Wait,
-                    Origin = "WMS",
-                    StartLocate = startLocat,
-                    PalletNo = palletNo,
-                    TaskNo = result.TaskList.TaskNo,
-                    EndLocate = result.TaskList.EndLocate,
-                    EndRoadway = result.TaskList.EndRoadway
+                    EndRoadway = result.TaskList.EndRoadway,
+                    PalletQty = palletHeight//鎵樼洏楂樺害
                 };
 
                 _db.Insertable(taskAdd).ExecuteCommand();
                 endLocat = result.TaskList.EndRoadway;
                 returnStr = result.TaskList.EndLocate;
+                taskNo = taskAdd.TaskNo;
             }
             else
             {
@@ -161,7 +185,7 @@
     /// <param name="starRoadWay"></param>
     /// <param name="taskNo"></param>
     /// <returns></returns>
-    public string RequestLocate(string palletNo, string startLocat, string taskModel, string starRoadWay, ref string taskNo)
+    public string RequestLocate(string palletNo, string startLocat, string taskModel, string starRoadWay, ref string taskNo, int palletHeight)
     {
         string returnStr = "";
 
@@ -177,7 +201,8 @@
                 PalletNo = palletNo,
                 HouseNo = "W01",
                 RoadWayNo = starRoadWay,
-                TaskModel = taskModel
+                TaskModel = taskModel,
+                PalletHeight = palletHeight
             };
 
             string url = Urls.WMSAddress + ":" + Urls.WMSPort;
@@ -196,6 +221,7 @@
                         //IsSuccess =TaskSuccessEnum.Success,
                         Origin = "WMS",
                         StartLocate = startLocat,
+                        Levels = 999,
                         PalletNo = palletNo,
                         EndLocate = result.TaskList.EndLocate,
                         EndRoadway = result.TaskList.EndRoadway
@@ -306,6 +332,7 @@
                         StartLocate = item.StartLocate,
                         StartRoadway=item.StartRoadway,
                         PalletNo = item.PalletNo,
+                        Levels = 999,
                         EndLocate = item.EndLocate,
                         EndRoadway = item.EndRoadway
                     };
@@ -328,4 +355,87 @@
         }
         return returnStr;
     }
+    /// <summary>
+    /// 璋冪敤WMS鎺ュ彛缁欏皬杞︿笅鍙戝叆搴撲换鍔�
+    /// </summary>
+    /// <param name="endLocation"></param>
+    /// <returns></returns>
+    public async Task<ResponseModel> IssuedAgvTask(string endLocation)
+    {
+        var model = new
+        {
+            EndLocation = endLocation
+        };
+        string url = Urls.WMSAddress + ":" + Urls.WMSPort;
+        var result = await (url + "/api/DownAPi/WcsIssuedAgvTask").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseModel>();
+        Log.Information("璋冪敤WMS鎺ュ彛WCS鐢宠缁欏皬杞︿笅鍙戝叆搴撲换鍔℃帴鍙�" + result.ToJson());
+        return result;
+    }
+
+    /// <summary>
+    /// 鏍规嵁鍑哄簱浠诲姟鍙疯幏鍙栧嚭搴撳崟绫诲瀷
+    /// </summary>
+    /// <param name="endLocation"></param>
+    /// <returns></returns>
+    public async Task<ResponseModel> GetSoOrderTypeByTaskNo(string taskNo)
+    {
+        var model = new
+        {
+            TaskNo = taskNo
+        };
+        string url = Urls.WMSAddress + ":" + Urls.WMSPort;
+        var result = await (url + "/api/DownAPi/GetSoOrderTypeByTaskNo").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseModel>();
+        Log.Information("璋冪敤WMS鎺ュ彛鏍规嵁鍑哄簱浠诲姟鍙疯幏鍙栧嚭搴撳崟绫诲瀷" + result.ToJson());
+        return result;
+    }
+
+    /// <summary>
+    /// 鏍规嵁鎵樼洏鍙疯幏鍙栨墭鐩樹笂鐗╂枡鍝佺淇℃伅
+    /// </summary>
+    /// <param name="palletNo">鎵樼洏鍙�</param>
+    /// <returns></returns>
+    public string GetPalletPzNo(string palletNo)
+    {
+        var model = new
+        {
+            PalletNo = palletNo
+        };
+        string url = Urls.WMSAddress + ":" + Urls.WMSPort;
+        var result = (url + "/api/DownAPi/GetStockDetailByPalletNo").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseSkuInfo>().Result;
+        Log.Information("璋冪敤WMS鎺ュ彛鏍规嵁鎵樼洏鍙疯幏鍙栨墭鐩樺簱瀛樻槑缁嗕俊鎭�" + result.ToJson());
+
+        string pzNo = string.Empty;
+        if (result.Success == 0)
+        {
+            var palletSkuInfo = result.PalletSkuInfo;
+            var pzInfo = _db.Queryable<WcsMateialPzInfo>().First(w => w.SkuNo == palletSkuInfo.SkuNo && w.SkuName == palletSkuInfo.SkuName);
+            if (pzInfo != null)
+            {
+                pzNo = pzInfo.PZNo;
+            }
+        }
+        return pzNo;
+    }
+    /// <summary>
+    /// 鎴愬搧绠辩爜鎷嗗灈鎷h揣
+    /// </summary>
+    /// <param name="taskNo"></param>
+    /// <returns></returns>
+    public string BoxUnstackd(string palletNo)
+    {
+        string returnStr = "";
+        var model = new
+        {
+            PalletNo = palletNo
+        };
+        string url = Urls.WMSAddress + ":" + Urls.WMSPort;
+        var result = (url + "/api/DownAPi/BoxUnstackd").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<WmsResponseModel>().Result;
+        Log.Information("璋冪敤WMS鎺ュ彛鎴愬搧绠辩爜鎷嗗灈鎷h揣" + result.ToJson());
+
+        if (result.Success != 0)
+        {
+            returnStr = "-1:" + result.Message;
+        }
+        return returnStr;
+    }
 }

--
Gitblit v1.8.0