From 2f0e0fa257c147a223d79ff8a52118768f43eee8 Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期三, 11 九月 2024 18:53:35 +0800
Subject: [PATCH] 修改输送线交互逻辑

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

diff --git a/Admin.NET/WCS.Application/Util/HttpService.cs b/Admin.NET/WCS.Application/Util/HttpService.cs
index cb84eb5..9509fb6 100644
--- a/Admin.NET/WCS.Application/Util/HttpService.cs
+++ b/Admin.NET/WCS.Application/Util/HttpService.cs
@@ -1,18 +1,299 @@
 锘縰sing Furion.Logging;
 using Furion.RemoteRequest.Extensions;
+using Newtonsoft.Json;
 using System.Text;
+using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionResponse.Types;
 
 namespace WCS.Application;
 public class HttpService
 {
     private dynamic Urls;
+
+    private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
     public HttpService()
     {
         var _sysConfigService = App.GetService<SysConfigService>();//todo 杩欓噷闇�瑕佹祴璇曚笅鐢熷懡鍛ㄦ湡闂
         Urls = _sysConfigService.GetSystemInfo().Result;
     }
+
+
     /// <summary>
-    /// 璋冪敤WMS鎺ュ彛鍙嶉浠诲姟鎺ュ彛
+    /// 璋冪敤WMS鎺ュ彛鐢宠宸烽亾鎺ュ彛
+    /// </summary>
+    /// <param name="palletNo"></param>
+    /// <param name="startLocat"></param>
+    /// <param name="taskModel"></param>
+    /// <param name="ceng"></param>
+    /// <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)
+    {
+        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()
+            {
+                PalletNo = palletNo,
+                HouseNo = "W01",
+                TaskModel = taskModel
+            };
+
+            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());
+            if (result.StatusCode == "0")
+            {
+                                
+                var taskAdd = new WcsTask()
+                {
+                    TaskType = TaskTypeEnum.In,
+                    Origin = "WMS",
+                    StartLocate = startLocat,
+                    TaskNo = result.TaskList.TaskNo,
+                    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;
+        // 纭畾鐩爣宸ヤ綅//闇�娣诲姞灞傛暟纭
+        //switch (endLocat)
+        //{
+        //    case "R01":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "145";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "252";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "101";
+        //        }
+        //        break;
+        //    case "R02":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "137";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "260";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "405";
+        //        }
+        //        break;
+        //    case "R03":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "127";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "270";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "409";
+        //        }
+        //        break;
+        //    case "R04":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "119";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "278";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "413";
+        //        }
+        //        break;
+        //    case "R05":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "109";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "288";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "417";
+        //        }
+        //        break;
+        //    case "R06":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "101";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "301";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "421";
+        //        }
+        //        break;
+        //    case "R07":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "091";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "307";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "425";
+        //        }
+        //        break;
+        //    case "R08":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "083";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "315";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "429";
+        //        }
+        //        break;
+        //    case "R09":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "073";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "325";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "433";
+        //        }
+        //        break;
+        //    case "R10":
+        //        if (ceng == "1")
+        //        {
+        //            endLocat = "065";
+        //        }
+        //        else if (ceng == "2")
+        //        {
+        //            endLocat = "337";
+        //        }
+        //        else if (ceng == "3")
+        //        {
+        //            endLocat = "437";
+        //        }
+        //        break;
+        //}
+
+
+
+    }
+
+    /// <summary>
+    /// 璋冪敤WMS鎺ュ彛鐢宠鍌ㄤ綅鎺ュ彛
+    /// </summary>
+    /// <param name="palletNo"></param>
+    /// <param name="startLocat"></param>
+    /// <param name="taskModel"></param>
+    /// <param name="starRoadWay"></param>
+    /// <param name="taskNo"></param>
+    /// <returns></returns>
+    public string RequestLocate(string palletNo, string startLocat, string taskModel, string starRoadWay, 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 && string.IsNullOrWhiteSpace(m.EndLocate));
+
+        if (task == null)
+        {
+            var model = new RequestAsnTask()
+            {
+                PalletNo = palletNo,
+                HouseNo = "W01",
+                RoadWayNo = starRoadWay,
+                TaskModel = taskModel
+            };
+
+            string url = Urls.WMSAddress + ":" + Urls.WMSPort;
+            var result = (url + "/api/DownAPi/RequestLocation").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseTasks>().Result;
+            Log.Information("璋冪敤WMS鐢宠鍌ㄤ綅鎺ュ彛鍙嶉浠诲姟鎺ュ彛" + result.ToJson());
+            if (result.StatusCode == "0")
+            {
+
+                var taskAdd = new WcsTask()
+                {
+                    TaskType = TaskTypeEnum.In,
+                    Origin = "WMS",
+                    StartLocate = startLocat,
+                    TaskNo = result.TaskList.TaskNo,
+                    EndLocate = result.TaskList.EndLocate,
+                    EndRoadway = result.TaskList.EndRoadway
+                };
+
+                _db.Updateable(taskAdd).ExecuteCommand();
+                returnStr = result.TaskList.EndLocate;
+                taskNo = result.TaskList.TaskNo;
+            }
+            else
+            {
+                returnStr = "-1:" + result.Message;
+                return returnStr;
+            }
+        }
+        else
+        {
+            returnStr = task.EndLocate;
+            taskNo = task.TaskNo;
+        }
+
+        return returnStr;
+        
+    }
+
+
+    /// <summary>
+    /// 璋冪敤WMS鎺ュ彛 鍙嶉浠诲姟鎺ュ彛
     /// </summary>
     /// <param name="model">浠诲姟瀹屾垚鐘舵��</param>
     /// <returns></returns>

--
Gitblit v1.8.0