From d06e44eb1c8818c8d19709602631eb7888d4f0e9 Mon Sep 17 00:00:00 2001
From: chengsc <11752@DESKTOP-DS49RCP>
Date: 星期二, 06 五月 2025 08:53:01 +0800
Subject: [PATCH] 修改程序,AGV交互

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

diff --git a/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs b/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs
index b9569e0..cb33fc5 100644
--- a/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs
+++ b/Admin.NET/WCS.Application/Util/AGVStorageUtil.cs
@@ -15,290 +15,60 @@
     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 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 (locate1 == null || locate2 == null)
         {
-            foreach (var mod in item.Reverse())
-            {
-                var value = _sysConfigService.GetConfigValue<bool>(mod).Result;
-                if (value)
-                    i++;
-            }
+            return "";
         }
-        return i;
-    }
-    /// <summary>
-    /// 鑾峰彇鎴愬搧瑕佸叆鐨勫偍浣�
-    /// </summary>
-    /// <returns></returns>
-    public static string GetProductInStorage(string TaskNo = "")
-    {
-        List<string> listResult = new List<string>();
-        foreach (var item in listStorage)
+        switch (locate1.WareHouseNo)
         {
-            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 "W02":
+                type1 = "SITE";
+                break;
+            case "W04":
+                type1 = "STORAGE";
+                break;
+            default:
                 break;
         }
-        //妫�鏌ユ槸鍚︽湁姝e湪鍏ョ殑浠诲姟
-        foreach (var result in listResult.AsEnumerable().Reverse())
+
+        switch (locate2.WareHouseNo)
         {
-            if (!_db.Queryable<WcsTask>().Where(s => s.Type == PLCTypeEnum.AGV && s.Status <= TaskStatusEnum.Doing && s.EndLocate == result && s.TaskNo != TaskNo).Any())
-                return result;
+            case "W02":
+                type2 = "SITE";
+                break;
+            case "W04":
+                type2 = "STORAGE";
+                break;
+            default:
+                break;
         }
-        return "";
-        //Log.Error("鏃犲彲鍏ョ殑鍌ㄤ綅");
-        //throw Oops.Bah("鏃犲彲鍏ョ殑鍌ㄤ綅");
-    }
-    /// <summary>
-    /// 鑾峰彇鎵樼洏瑕佸嚭鐨勫偍浣�
-    /// </summary>
-    /// <returns></returns>
-    public static string GetPalletOutStorage()
-    {
-        foreach (var item in listPallet)
+        var Area1002 = new List<string>() { "",""};//1002杞﹂棿鍖哄煙
+        var Area1003 = new List<string>() { "",""};//1003杞﹂棿鍖哄煙
+        if (Area1002.Contains(locate2.AreaNo))
         {
-            var value = _sysConfigService.GetConfigValue<bool>(item).Result;
-            if (value)
-                return item.Split('_')[1];
+            jiebo = "1JB";//鎺ラ┏浣�
         }
-        return "";
-        //Log.Error("鏃犲彲鍑虹殑鍌ㄤ綅");
-        //throw Oops.Bah("鏃犲彲鍑虹殑鍌ㄤ綅");
+        if (Area1003.Contains(locate2.AreaNo))
+        {
+            jiebo = "2JB";
+        }
+        if (type1 == "" || type2 == "")
+        {
+            return "";
+        }
+        return "CJ1";
     }
 
-    #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