From f21906b6464a0e6b42aade6f70127f7b8d6611f3 Mon Sep 17 00:00:00 2001
From: chengsc <11752@DESKTOP-DS49RCP>
Date: 星期三, 11 六月 2025 16:56:39 +0800
Subject: [PATCH] 修改任务模板问题

---
 Admin.NET/WCS.Application/Util/AGVStorageUtil.cs |  383 ++++++++++++++++--------------------------------------
 1 files changed, 112 insertions(+), 271 deletions(-)

diff --git a/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs b/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs
index fda7ab5..2177065 100644
--- a/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs
+++ b/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs
@@ -7,6 +7,7 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WCS.Application.Entity;
 
 namespace WCS.Application;
 public static class AGVStorageUtil
@@ -14,290 +15,130 @@
     private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
     private static readonly SysCacheService sysCacheService = App.GetRequiredService<SysCacheService>();
     private static readonly SysConfigService _sysConfigService = App.GetRequiredService<SysConfigService>();
-    private static List<string[]> listStorage = new List<string[]>();
-    private static string[] listPallet = new[] { "cache_Z53", "cache_Z52", "cache_Z51" };
+    
     static AGVStorageUtil()
     {
-        listStorage.Add(new[] { "cache_Z11", "cache_Z12", "cache_Z13" });
-        listStorage.Add(new[] { "cache_Z21", "cache_Z22", "cache_Z23" });
-        listStorage.Add(new[] { "cache_Z31", "cache_Z32", "cache_Z33" });
-        listStorage.Add(new[] { "cache_Z41", "cache_Z42", "cache_Z43" });
     }
-    /// <summary>
-    /// 鑾峰彇鎴愬搧鏁伴噺
-    /// </summary>
-    /// <returns></returns>
-    public static int ProductCount()
+
+    public static string GetTaskModle(string straLocate,string endLocate,out string type1,out string type2,out string jiebo)
     {
-        int i = 0;
-        foreach (var item in listStorage)
+        type1 = "";
+        type2 = "";
+        jiebo = "";
+        var taskModle = "";//浠诲姟妯℃澘
+        //鍓嶇紑L绔嬪簱 鍓嶇紑B 骞冲簱  
+        var locate1q = straLocate.Substring(0,1);   
+        var locate2q = endLocate.Substring(0, 1);
+        
+        if (locate1q == null || locate2q == null)
         {
-            foreach (var mod in item.Reverse())
-            {
-                var value = _sysConfigService.GetConfigValue<bool>(mod).Result;
-                if (value)
-                    i++;
-            }
+            return taskModle;
         }
-        return i;
-    }
-    /// <summary>
-    /// 鑾峰彇鎴愬搧瑕佸叆鐨勫偍浣�
-    /// </summary>
-    /// <returns></returns>
-    public static string GetProductInStorage(string TaskNo = "")
-    {
-        List<string> listResult = new List<string>();
-        foreach (var item in listStorage)
+        switch (locate1q)
         {
-            List<string> listItem = new List<string>();
-            foreach (var mod in item.Reverse())
-            {
-                var value = _sysConfigService.GetConfigValue<bool>(mod).Result;
-                if (!value)
-                    listItem.Add(mod.Split('_')[1]);
-                else
-                    break;
-            }
-            listResult.AddRange(listItem.AsEnumerable().Reverse());
-        }
-        //妫�鏌ユ槸鍚︽湁姝e湪鍏ョ殑浠诲姟
-        foreach (var result in listResult)
-        {
-            if (!_db.Queryable<WcsTask>().Where(s => s.Type == PLCTypeEnum.AGV && s.Status <= TaskStatusEnum.Doing && s.EndLocate == result && s.TaskNo != TaskNo).Any())
-                return result;
-        }
-        return "";
-        //Log.Error("鏃犲彲鍏ョ殑鍌ㄤ綅");
-        //throw Oops.Bah("鏃犲彲鍏ョ殑鍌ㄤ綅");
-    }
-    /// <summary>
-    /// 鑾峰彇鎴愬搧瑕佸嚭鐨勫偍浣�
-    /// </summary>
-    /// <returns></returns>
-    public static string GetProductOutStorage()
-    {
-        foreach (var item in listStorage.AsEnumerable().Reverse())
-        {
-            foreach (var mod in item.Reverse())
-            {
-                var value = _sysConfigService.GetConfigValue<bool>(mod).Result;
-                if (value)
-                    return mod.Split('_')[1];
-            }
-        }
-        return "";
-        //Log.Error("鏃犲彲鍑虹殑鍌ㄤ綅");
-        //throw Oops.Bah("鏃犲彲鍑虹殑鍌ㄤ綅");
-    }
-    /// <summary>
-    /// 鑾峰彇鎵樼洏瑕佸叆鐨勫偍浣�
-    /// </summary>
-    /// <returns></returns>
-    public static string GetPalletInStorage(string TaskNo = "")
-    {
-        List<string> listResult = new List<string>();
-        foreach (var item in listPallet)
-        {
-            var value = _sysConfigService.GetConfigValue<bool>(item).Result;
-            if (!value)
-                listResult.Add(item.Split('_')[1]);
-            else
+            case "L":
+                type1 = "STORAGE";
+                break;
+            case "B":
+                type1 = "SITE";
+                break;
+            default:
                 break;
         }
-        //妫�鏌ユ槸鍚︽湁姝e湪鍏ョ殑浠诲姟
-        foreach (var result in listResult.AsEnumerable().Reverse())
+
+        switch (locate2q)
         {
-            if (!_db.Queryable<WcsTask>().Where(s => s.Type == PLCTypeEnum.AGV && s.Status <= TaskStatusEnum.Doing && s.EndLocate == result && s.TaskNo != TaskNo).Any())
-                return result;
+            case "L":
+                type2 = "STORAGE";
+                break;
+            case "B":
+                type2 = "SITE";
+                break;
+            default:
+                break;
         }
-        return "";
-        //Log.Error("鏃犲彲鍏ョ殑鍌ㄤ綅");
-        //throw Oops.Bah("鏃犲彲鍏ョ殑鍌ㄤ綅");
-    }
-    /// <summary>
-    /// 鑾峰彇鎵樼洏瑕佸嚭鐨勫偍浣�
-    /// </summary>
-    /// <returns></returns>
-    public static string GetPalletOutStorage()
-    {
-        foreach (var item in listPallet)
+        
+        var  AreaAll = new List<string>() { "B06", "B07", "B09" };//1002銆�1003鍏ㄩ儴鍖哄煙
+        var Area1002 = new List<string>() { "B06"};//1002杞﹂棿鍖哄煙
+        var Area10031 = new List<string>() { "B09"};//1003 1妤艰溅闂村尯鍩�
+        var Area10032 = new List<string>() { "B07"};//1003 2妤艰溅闂村尯鍩�
+
+        var locate1 = _db.Queryable<WcsStorageLocat>().First(m => m.IsDelete == false && m.LocatNo == straLocate);
+        var locate2 = _db.Queryable<WcsStorageLocat>().First(m => m.IsDelete == false && m.LocatNo == endLocate);
+
+        if (locate1q == "B" )
         {
-            var value = _sysConfigService.GetConfigValue<bool>(item).Result;
-            if (value)
-                return item.Split('_')[1];
+            if ( Area1002.Contains(locate1.AreaNo) )
+            {
+                jiebo = "1JB";//鎺ラ┏浣�
+            }
+            if (Area10031.Contains(locate1.AreaNo) || Area10032.Contains(locate1.AreaNo))
+            {
+                jiebo = "2JB";
+            }
         }
-        return "";
-        //Log.Error("鏃犲彲鍑虹殑鍌ㄤ綅");
-        //throw Oops.Bah("鏃犲彲鍑虹殑鍌ㄤ綅");
+        if (locate2q == "B")
+        {
+            if ( Area1002.Contains(locate2.AreaNo))
+            {
+                jiebo = "1JB";//鎺ラ┏浣�
+            }
+            if (Area10031.Contains(locate2.AreaNo) || Area10032.Contains(locate2.AreaNo))
+            {
+                jiebo = "2JB";
+            }
+        }
+        
+        if (type1 == "" || type2 == "")
+        {
+            return taskModle;
+        }
+        //鍒ゆ柇鑾峰彇浠诲姟妯℃澘  STORAGE 璐ф灦浠撲綅  SITE 骞冲簱浠撲綅  ZONE 鍖哄煙
+        switch (type1)
+        {
+            case "STORAGE" when type2 == "SITE":
+                {
+                    taskModle = "FJ";
+                    if (locate1.AreaNo == "B10")
+                    {
+                        taskModle = "DPJRK";
+                    }
+                }
+                break;
+            case "SITE" when type2 == "STORAGE":
+                {
+                    taskModle = "YCRK"; 
+
+                }
+                break;
+            case "SITE" when type2 == "SITE":
+                {
+                    if ((Area10032.Contains(locate1.AreaNo) || Area10031.Contains(locate1.AreaNo)) && locate2.AreaNo == "B04")
+                    {
+                        taskModle = "CPRK1003";
+                    }
+                    else if(Area1002.Contains(locate1.AreaNo) && locate2.AreaNo == "B04")
+                    {
+                        taskModle = "CPRK1002";
+                    }
+                    else if ((Area10032.Contains(locate2.AreaNo) || Area10031.Contains(locate2.AreaNo)) && !AreaAll.Contains(locate1.AreaNo))
+                    {
+                        taskModle = "YCLSX";
+                    }
+                    else if (Area1002.Contains(locate2.AreaNo) && !AreaAll.Contains(locate1.AreaNo))
+                    {
+                        taskModle = "YCLSX2";
+                    }
+                    else if (locate2.AreaNo == "B10")
+                    { 
+                        taskModle = "PF-FMR-STACK-NOTIFY-TASK"; 
+                    }
+                }
+                break;
+            default:
+                break;
+        }
+        return taskModle;
     }
 
-    #region 灞炴��
-
-    public static bool Z11
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z11").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z11", value);
-        }
-    }
-    public static bool Z12
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z12").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z12", value);
-        }
-    }
-    public static bool Z13
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z13").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z13", value);
-        }
-    }
-    public static bool Z21
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z21").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z21", value);
-        }
-    }
-    public static bool Z22
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z22").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z22", value);
-        }
-    }
-    public static bool Z23
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z23").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z23", value);
-        }
-    }
-    public static bool Z31
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z31").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z31", value);
-        }
-    }
-    public static bool Z32
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z32").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z32", value);
-        }
-    }
-    public static bool Z33
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z33").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z33", value);
-        }
-    }
-    public static bool Z41
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z41").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z41", value);
-        }
-    }
-    public static bool Z42
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z42").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z42", value);
-        }
-    }
-    public static bool Z43
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z43").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z43", value);
-        }
-    }
-    public static bool Z51
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z51").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z51", value);
-        }
-    }
-    public static bool Z52
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z52").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z52", value);
-        }
-    }
-    public static bool Z53
-    {
-        get
-        {
-            return _sysConfigService.GetConfigValue<bool>("cache_Z53").Result;
-        }
-        set
-        {
-            _sysConfigService.UpdateConfigValue("cache_Z53", value);
-        }
-    }
-    #endregion
 }

--
Gitblit v1.8.0