From c8131be7ad55d2c652205527666075c1b5034b27 Mon Sep 17 00:00:00 2001
From: chengsc <11752@DESKTOP-DS49RCP>
Date: 星期二, 06 五月 2025 11:11:21 +0800
Subject: [PATCH] 去除console

---
 Admin.NET/WCS.Application/PLC/PLCCommon.cs |  233 ++++++++++++++++++++++------------------------------------
 1 files changed, 88 insertions(+), 145 deletions(-)

diff --git a/Admin.NET/WCS.Application/PLC/PLCCommon.cs b/Admin.NET/WCS.Application/PLC/PLCCommon.cs
index 9cb4230..96111c1 100644
--- a/Admin.NET/WCS.Application/PLC/PLCCommon.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCCommon.cs
@@ -1,12 +1,15 @@
 锘縰sing Elastic.Clients.Elasticsearch.Tasks;
 using Furion.Logging;
 using Microsoft.AspNetCore.SignalR;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
 using RazorEngine.Compilation.ImpromptuInterface.Dynamic;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WCS.Application.Entity;
+using WCS.Application.Util;
 
 namespace WCS.Application;
 public static class PLCCommon
@@ -442,156 +445,96 @@
     }
     
     /// <summary>
-    /// 鏍规嵁宸烽亾鍜屽眰鏁扮‘瀹氬贩閬撳彛鍏ュ簱宸ヤ綅
+    /// 鏍规嵁鐩爣缁勮幏鍙栦綅缃渶浼樼殑鍥涢」杞﹀彇璐у伐浣�
     /// </summary>
-    /// <param name="endRoadway"></param>
-    /// <param name="ceng"></param>
+    /// <param name="endRoadway">鐩爣缁�</param>
+    /// <param name="ceng">鐢宠宸ヤ綅</param>
     /// <returns></returns>
     public static string RoadwayToStationNum(string endRoadway, string ceng)
     {
         string stationNum = "";
-        switch (endRoadway)
-        {
-            case "R01":
-                if (ceng == "1")
-                {
-                    stationNum = "145";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "252";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "401";
-                }
-                break;
-            case "R02":
-                if (ceng == "1")
-                {
-                    stationNum = "137";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "260";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "405";
-                }
-                break;
-            case "R03":
-                if (ceng == "1")
-                {
-                    stationNum = "127";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "270";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "409";
-                }
-                break;
-            case "R04":
-                if (ceng == "1")
-                {
-                    stationNum = "119";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "278";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "413";
-                }
-                break;
-            case "R05":
-                if (ceng == "1")
-                {
-                    stationNum = "109";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "288";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "417";
-                }
-                break;
-            case "R06":
-                if (ceng == "1")
-                {
-                    stationNum = "101";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "301";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "421";
-                }
-                break;
-            case "R07":
-                if (ceng == "1")
-                {
-                    stationNum = "091";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "307";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "425";
-                }
-                break;
-            case "R08":
-                if (ceng == "1")
-                {
-                    stationNum = "83";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "315";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "429";
-                }
-                break;
-            case "R09":
-                if (ceng == "1")
-                {
-                    stationNum = "73";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "325";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "433";
-                }
-                break;
-            case "R10":
-                if (ceng == "1")
-                {
-                    stationNum = "65";
-                }
-                if (ceng == "2")
-                {
-                    stationNum = "337";
-                }
-                if (ceng == "3")
-                {
-                    stationNum = "437";
-                }
-                break;
+
+        string[] lists = endRoadway.Split("MR");
+        var model = _db.Queryable<WcsStorageLocat>().First(m => m.RoadwayNo == endRoadway && m.IsDelete == false);
+        string stat = model.AisleOne;
+
+        if (model.Layer == 1)
+        {   // 涓�灞�
+            switch (ceng)       // 鐢宠鐨勫叆搴撳彛
+            {
+                case "009":
+                    
+                    var path13 = Math.Abs(19 - int.Parse(stat.Substring(0,2))) + Math.Abs(6 - int.Parse(stat.Substring(2,2)));
+                    var path14 = Math.Abs(19 - int.Parse(stat.Substring(0,2))) + Math.Abs(12 - int.Parse(stat.Substring(2,2)));
+
+                    if (path13 <= path14)
+                    {
+                        stationNum = "013";
+                    }
+                    else 
+                    {
+                        stationNum = "014";
+                    }
+
+                    ; break;
+                case "017":
+                    stationNum = "002"
+                    ; break;
+                case "018":
+                    var path03 = Math.Abs(03 - int.Parse(stat.Substring(0, 2))) + Math.Abs(06 - int.Parse(stat.Substring(2, 2)));
+                    var path05 = Math.Abs(03 - int.Parse(stat.Substring(0, 2))) + Math.Abs(12 - int.Parse(stat.Substring(2, 2)));
+
+                    if (path03 <= path05)
+                    {
+                        stationNum = "003";
+                    }
+                    else
+                    {
+                        stationNum = "005";
+                    }
+
+                    ; break;
+                default: break;
+            }
+        }
+        else 
+        {  // 浜屽眰
+            switch (ceng)       // 鐢宠鐨勫叆搴撳彛
+            {
+                case "009":
+
+                    var path15 = Math.Abs(19 - int.Parse(stat.Substring(0, 2))) + Math.Abs(6 - int.Parse(stat.Substring(2, 2)));
+                    var path16 = Math.Abs(19 - int.Parse(stat.Substring(0, 2))) + Math.Abs(12 - int.Parse(stat.Substring(2, 2)));
+
+                    if (path15 <= path16)
+                    {
+                        stationNum = "015";
+                    }
+                    else
+                    {
+                        stationNum = "016";
+                    }
+
+          ; break;
+                case "017":
+                    stationNum = "006"
+                    ; break;
+                case "018":
+                    var path03 = Math.Abs(03 - int.Parse(stat.Substring(0, 2))) + Math.Abs(06 - int.Parse(stat.Substring(2, 2)));
+                    var path05 = Math.Abs(03 - int.Parse(stat.Substring(0, 2))) + Math.Abs(12 - int.Parse(stat.Substring(2, 2)));
+
+                    if (path03 <= path05)
+                    {
+                        stationNum = "007";
+                    }
+                    else
+                    {
+                        stationNum = "008";
+                    }
+
+          ; break;
+                default: break;
+            }
         }
 
         return stationNum;

--
Gitblit v1.8.0