From 9719a7f0ccbb70e4e51a93cbe1733d1424c16f6d Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期五, 06 十二月 2024 12:03:56 +0800
Subject: [PATCH] 优化Api数据库缓存模块,增加MES岗位缓存跟不良代码缓存

---
 Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs                        |    2 
 Tiger.Api/Controllers/Test/TestController.R.cs                        |   16 
 Tiger.Business.WMS/Transaction/OutWorkOrder.cs                        |    6 
 Tiger.Controllers.System/Controllers/Base/CacheController.CodeRule.cs |   11 
 Tiger.Business.MES/DbCache/Cache.cs                                   |   28 ++
 Tiger.Business/DbCache/Cache.cs                                       |   28 ++
 Tiger.Business.WMS/Transaction/OutSale.cs                             |    2 
 Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs                  |    2 
 Tiger.Business.WMS/Transaction/OutSplit.cs                            |    4 
 Tiger.Api/ApiWebHostService.cs                                        |    6 
 Tiger.Business.WMS/iWMS/iWMS.cs                                       |    4 
 Tiger.Business.MES/iERP/MES_U9C.cs                                    |    8 
 Tiger.Business.WMS/Transaction/OutOther.cs                            |    2 
 Tiger.Business.WMS/iWMS/ReceiptInfo.cs                                |    4 
 Tiger.Api/DbCache/DbCacheBus.cs                                       |   74 ++++++
 Tiger.Api/Startup.cs                                                  |    4 
 Tiger.Controllers.System/Controllers/Base/CacheController.SysParam.cs |    7 
 Tiger.Business/SYS/Biz.Sys_Params.cs                                  |    2 
 Tiger.Business.MES/WorkAction/ThreeInOne.cs                           |    4 
 Tiger.Api/Autofac/SingleInstance.json                                 |   32 ++
 Tiger.Business.MES/Task/Jobs.U9C_ME_GetWo.cs                          |    4 
 Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs               |    4 
 Tiger.Business.MES/WorkAction/Assembly.cs                             |    8 
 Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs                  |    4 
 Tiger.Business.WMS/Transaction/InReceipt.cs                           |    6 
 Tiger.Business/Tiger.Business.csproj                                  |    1 
 Tiger.IBusiness/DbCache/IMesDefectCache.cs                            |   21 +
 Tiger.Business.MES/Transaction/Position.cs                            |   10 
 Tiger.Business.WMS/Transaction/OutTransfer.cs                         |    2 
 Tiger.Business.WMS/BS/BS.Transfer.cs                                  |    2 
 Tiger.Business.WMS/Transaction/OutNoBillcode.cs                       |    2 
 Tiger.Business.WMS/AGV/Agv.cs                                         |    2 
 Tiger.IBusiness/DbCache/IMesPositionCache.cs                          |   21 +
 Tiger.Business/DbCache/Biz.CodeRule.cs                                |   19 -
 /dev/null                                                             |   19 -
 Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs               |    8 
 Tiger.Business.MES/DbCache/MesPositionCache.cs                        |  108 +++++++++
 Tiger.Business.MES/WorkAction/YadaAssembly.cs                         |    8 
 Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs             |    2 
 Tiger.Business.MES/DbCache/MesDefectCache.cs                          |  112 ++++++++++
 Tiger.Business.MES/WorkAction/VerifyCustomSN.cs                       |    4 
 Tiger.Business.MES/BIZ/BizBasRule.cs                                  |    2 
 Tiger.Business.WMS/BS/BS.ItemCount.cs                                 |    2 
 Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs                |    2 
 44 files changed, 510 insertions(+), 109 deletions(-)

diff --git a/Tiger.Api/ApiWebHostService.cs b/Tiger.Api/ApiWebHostService.cs
index be53ff7..3c6a088 100644
--- a/Tiger.Api/ApiWebHostService.cs
+++ b/Tiger.Api/ApiWebHostService.cs
@@ -7,6 +7,7 @@
 using Rhea.Common;
 using Tiger.IBusiness;
 using System.ServiceProcess;
+using Tiger.Api.DbCache;
 
 namespace Tiger.Api
 {
@@ -55,9 +56,10 @@
                 //鍏抽棴鏈嶅姟鎬荤嚎
                 DI.Resolve<IServicesBus>().StopServices();
                 //鍏抽棴DB缂撳瓨鑷姩鏇存柊
-                DI.Resolve<IDbCacheBus>().StopAutoUpdate();
+                //DI.Resolve<IDbCacheBus>().StopAutoUpdate();
+                DbCacheBus.StopAutoUpdate();
                 //MQTTHelper.MQTTConn?.Close();
-	            base.OnStopping();
+                base.OnStopping();
             }
             catch (System.Exception ex)
             {
diff --git a/Tiger.Api/Autofac/SingleInstance.json b/Tiger.Api/Autofac/SingleInstance.json
index bb34f00..83804b8 100644
--- a/Tiger.Api/Autofac/SingleInstance.json
+++ b/Tiger.Api/Autofac/SingleInstance.json
@@ -137,9 +137,37 @@
       "injectProperties": true,
       "instanceScope": "SingleInstance" //鐢熷懡鍛ㄦ湡
     },
+    //{
+    //  "type": "Tiger.Business.DbCacheBus,Tiger.Business",
+    //  "services": [ { "type": "Tiger.IBusiness.IDbCacheBus,Tiger.IBusiness" } ],
+    //  "autoActivate": true,
+    //  "injectProperties": true,
+    //  "instanceScope": "SingleInstance" //鐢熷懡鍛ㄦ湡
+    //},
     {
-      "type": "Tiger.Business.DbCacheBus,Tiger.Business",
-      "services": [ { "type": "Tiger.IBusiness.IDbCacheBus,Tiger.IBusiness" } ],
+      "type": "Tiger.Business.DbCache.CodeRuleCache,Tiger.Business",
+      "services": [ { "type": "Tiger.IBusiness.ICodeRuleCache,Tiger.IBusiness" } ],
+      "autoActivate": true,
+      "injectProperties": true,
+      "instanceScope": "SingleInstance" //鐢熷懡鍛ㄦ湡
+    },
+    {
+      "type": "Tiger.Business.DbCache.SysParamCache,Tiger.Business",
+      "services": [ { "type": "Tiger.IBusiness.ISysParamCache,Tiger.IBusiness" } ],
+      "autoActivate": true,
+      "injectProperties": true,
+      "instanceScope": "SingleInstance" //鐢熷懡鍛ㄦ湡
+    },
+    {
+      "type": "Tiger.Business.DbCache.MesDefectCache,Tiger.Business.MES",
+      "services": [ { "type": "Tiger.IBusiness.IMesDefectCache,Tiger.IBusiness" } ],
+      "autoActivate": true,
+      "injectProperties": true,
+      "instanceScope": "SingleInstance" //鐢熷懡鍛ㄦ湡
+    },
+    {
+      "type": "Tiger.Business.DbCache.MesPositionCache,Tiger.Business.MES",
+      "services": [ { "type": "Tiger.IBusiness.IMesPositionCache,Tiger.IBusiness" } ],
       "autoActivate": true,
       "injectProperties": true,
       "instanceScope": "SingleInstance" //鐢熷懡鍛ㄦ湡
diff --git a/Tiger.Api/Controllers/Test/TestController.R.cs b/Tiger.Api/Controllers/Test/TestController.R.cs
index 61c346a..80cdd05 100644
--- a/Tiger.Api/Controllers/Test/TestController.R.cs
+++ b/Tiger.Api/Controllers/Test/TestController.R.cs
@@ -66,9 +66,9 @@
         public async Task<IActionResult> GetAsync(string param)
         {
             //var data = await Biz.Db.Queryable<SYS_PARAM>().Where(q => q.PARAM_CODE == param).FirstAsync();
-            //var data = Biz.SysParam["Blue"];
-            //var data = Biz.SysParam.Groups;
-            //var data = Biz.CodeRule["X0001"]; 
+            //var data = Cache.SysParam["Blue"];
+            //var data = Cache.SysParam.Groups;
+            //var data = Cache.CodeRule["X0001"]; 
             //鍙栧彿娴嬭瘯
             //var data = Biz.Db.Queryable<BAS_CODE_RULE>().Where(q => q.RULE_CODE == "X0001").IncludesAllFirstLayer().First();
             //var key = string.Join("|", data.Details.Where(q => q.DATA_TYPE == BAS_CODE_DTL.DATA_TYPEs.DbCheck.GetValue()).Select(q => q.GenerateValue));
@@ -81,7 +81,7 @@
             //        try
             //        {
             //            var dtl = data.Details.First(q => q.RULE_SEQ == 6);
-            //            var sn = Biz.CodeRule.FetchSerialNo(key, dtl, index.ToString(), false);
+            //            var sn = Cache.CodeRule.FetchSerialNo(key, dtl, index.ToString(), false);
             //            Console.WriteLine($"{index}: {DateTime.Now:HH:mm:ss.fff} > 鍙栧彿瀹屾垚[{sn}]");
             //        }
             //        catch (Exception ex)
@@ -90,14 +90,14 @@
             //        }
             //    });
             //}
-            //var data = Biz.CodeRule["X0001"].Generate("PDFG", 5);
-            //var data1 = Biz.CodeRule["X0001"].TryGenerate("PDFG", 6);
+            //var data = Cache.CodeRule["X0001"].Generate("PDFG", 5);
+            //var data1 = Cache.CodeRule["X0001"].TryGenerate("PDFG", 6);
             //鏉$爜瑙勫垯楠岃瘉
             //Expression<Func<BAS_CODE_RULE, bool>> predicate = q => true;
             ////predicate = predicate.And(q => q.RULE_CODE == "X0002" || q.RULE_CODE == "X0001");
             //predicate = predicate.And(q => q.RULE_TYPE == 0);
-            ////var data = Biz.CodeRule.Rules.Where(predicate.Compile());
-            //var data = Biz.CodeRule.Verify("AB23#7930000002010", predicate.Compile());
+            ////var data = Cache.CodeRule.Rules.Where(predicate.Compile());
+            //var data = Cache.CodeRule.Verify("AB23#7930000002010", predicate.Compile());
             return Ok("");
         }
 
diff --git a/Tiger.Api/DbCache/DbCacheBus.cs b/Tiger.Api/DbCache/DbCacheBus.cs
new file mode 100644
index 0000000..316a0d8
--- /dev/null
+++ b/Tiger.Api/DbCache/DbCacheBus.cs
@@ -0,0 +1,74 @@
+锘縰sing Rhea.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Tiger.IBusiness;
+
+namespace Tiger.Api.DbCache
+{
+    public partial class Cache
+    {
+        /// <summary>
+        /// 鑾峰彇鏉$爜瑙勫垯缂撳瓨
+        /// </summary>
+        public static ICodeRuleCache CodeRule => DI.Resolve<ICodeRuleCache>();
+        /// <summary>
+        /// 鑾峰彇绯荤粺鍙傛暟缂撳瓨
+        /// </summary>
+        public static ISysParamCache SysParam => DI.Resolve<ISysParamCache>();
+        /// <summary>
+        /// 鑾峰彇涓嶈壇浠g爜缂撳瓨
+        /// </summary>
+        public static IMesDefectCache MesDefect => DI.Resolve<IMesDefectCache>();
+        /// <summary>
+        /// 鑾峰彇宀椾綅缂撳瓨
+        /// </summary>
+        public static IMesPositionCache MesPosition => DI.Resolve<IMesPositionCache>();
+    }//endClass
+
+    /// <summary>
+    /// 鐩戞帶鎬绘帶
+    /// </summary>
+    public class DbCacheBus
+    {
+        
+        #region Functions
+        public static void StartAutoUpdate()
+        {
+            if (BizConfig.Configuration["IsUseDbCache"]?.ToLower() == "true")
+            {
+                //寮�鍚郴缁熷弬鏁扮紦瀛�
+                Cache.SysParam.Start();
+                ConsoleExt.WriteLine("Start SysParam Cache Auto Update Thread..........", ConsoleColor.Yellow);
+                //寮�鍚郴缁熷弬鏁扮紦瀛�
+                Cache.CodeRule.Start();
+                ConsoleExt.WriteLine("Start CodeRule Cache Auto Update Thread..........", ConsoleColor.Yellow);
+                //寮�鍚笉鑹唬鐮佺紦瀛�
+                Cache.MesDefect.Start();
+                ConsoleExt.WriteLine("Start MesDefect Cache Auto Update Thread..........", ConsoleColor.Yellow);
+                //寮�鍚矖浣嶇紦瀛�
+                Cache.MesPosition.Start();
+                ConsoleExt.WriteLine("Start MesPosition Cache Auto Update Thread..........", ConsoleColor.Yellow);
+            }
+        }
+
+        public static void StopAutoUpdate()
+        {
+            if (BizConfig.Configuration["IsUseDbCache"]?.ToLower() == "true")
+            {
+	            //鍏抽棴绯荤粺鍙傛暟缂撳瓨
+	            Cache.SysParam.Stop();
+                //鍏抽棴绯荤粺鍙傛暟缂撳瓨
+                Cache.CodeRule.Stop();
+                //鍏抽棴涓嶈壇浠g爜缂撳瓨
+                Cache.MesDefect.Stop();
+                //鍏抽棴宀椾綅缂撳瓨
+                Cache.MesPosition.Stop();
+            }
+        }
+        #endregion
+    }
+}
diff --git a/Tiger.Api/Startup.cs b/Tiger.Api/Startup.cs
index fd0f5d6..22cdfab 100644
--- a/Tiger.Api/Startup.cs
+++ b/Tiger.Api/Startup.cs
@@ -16,6 +16,7 @@
 using System.Linq;
 using System.Reflection;
 using Tiger.Api.Controllers;
+using Tiger.Api.DbCache;
 using Tiger.IBusiness;
 using Tiger.IBusiness.Utility;
 
@@ -158,7 +159,8 @@
             //寮�鍚湇鍔℃�荤嚎
             DI.Resolve<IServicesBus>().StartServices(app.ApplicationServices.GetService<ISchedulerFactory>());
             //寮�鍚疍B缂撳瓨鑷姩鏇存柊
-            DI.Resolve<IDbCacheBus>().StartAutoUpdate();
+            //DI.Resolve<IDbCacheBus>().StartAutoUpdate();
+            DbCacheBus.StartAutoUpdate();
             //寮�鍚疢QTT鏈嶅姟
             MQTTHelper.Start();
         }
diff --git a/Tiger.Business.MES/BIZ/BizBasRule.cs b/Tiger.Business.MES/BIZ/BizBasRule.cs
index 33c308f..d3bf9f8 100644
--- a/Tiger.Business.MES/BIZ/BizBasRule.cs
+++ b/Tiger.Business.MES/BIZ/BizBasRule.cs
@@ -121,7 +121,7 @@
             var result = new ApiAction();
             try
             {
-                result.Data = input.IsTry == "Y" ? Biz.CodeRule[input.Code]?.TryGenerate(input.Prefix, $"{input.BatchNo}-{input.Qty}-").Data.ToString() ?? "" : Biz.CodeRule[input.Code]?.Generate(input.Prefix, $"{input.BatchNo}-{input.Qty}-").Data.ToString() ?? "";
+                result.Data = input.IsTry == "Y" ? Cache.CodeRule[input.Code]?.TryGenerate(input.Prefix, $"{input.BatchNo}-{input.Qty}-").Data.ToString() ?? "" : Cache.CodeRule[input.Code]?.Generate(input.Prefix, $"{input.BatchNo}-{input.Qty}-").Data.ToString() ?? "";
             }
             catch (Exception ex)
             {
diff --git a/Tiger.Business.MES/DbCache/Cache.cs b/Tiger.Business.MES/DbCache/Cache.cs
new file mode 100644
index 0000000..89dc661
--- /dev/null
+++ b/Tiger.Business.MES/DbCache/Cache.cs
@@ -0,0 +1,28 @@
+锘縰sing Tiger.Model;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+using Rhea.Common;
+using System.Net;
+using System.Linq;
+using Newtonsoft.Json;
+using Tiger.Business.DbCache;
+using Tiger.IBusiness;
+
+namespace Tiger.Business.DbCache
+{
+    public partial class Cache
+    {
+        /// <summary>
+        /// 鑾峰彇涓嶈壇浠g爜缂撳瓨
+        /// </summary>
+        public static IMesDefectCache Defect => DI.Resolve<IMesDefectCache>();
+        /// <summary>
+        /// 鑾峰彇宀椾綅缂撳瓨
+        /// </summary>
+        public static IMesPositionCache Position => DI.Resolve<IMesPositionCache>();
+    }//endClass
+}
diff --git a/Tiger.Business.MES/DbCache/MesDefectCache.cs b/Tiger.Business.MES/DbCache/MesDefectCache.cs
new file mode 100644
index 0000000..649afda
--- /dev/null
+++ b/Tiger.Business.MES/DbCache/MesDefectCache.cs
@@ -0,0 +1,112 @@
+锘縰sing Rhea.Common;
+using System;
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Tiger.IBusiness;
+using Tiger.Model;
+
+namespace Tiger.Business.DbCache
+{
+    /// <summary>
+    /// 涓嶈壇浠g爜鏁版嵁搴撴暟鎹紦瀛�
+    /// </summary>
+    public class MesDefectCache : IMesDefectCache
+    {
+        #region Variables
+        private WhileThread AutoUpdateThread;
+        private DateTime LastUpdateTime = DateTime.MinValue;
+        #endregion
+
+        #region Propertys
+        public string Id { get; set; } = Guid.NewGuid().ToString("N");
+        public string Tag { get; set; } = "MesDefectCache";
+        public string Name { get; set; } = "MesDefectCache";
+        public bool IsRunning { get; set; }
+        private List<BAS_DEFECT_GRP> _groups = new();
+        public List<BAS_DEFECT_GRP> Groups { get { Update(); return _groups; } set => _groups = value; }
+        private List<BAS_DEFECT> _defects = new();
+        public List<BAS_DEFECT> Defects { get { Update(); return _defects; } set => _defects = value; }
+        public BAS_DEFECT this[string code, string group = null] { get { Update(); return _defects.FirstOrDefault(q => q.DFT_CODE == code && (group.IsNullOrEmpty() || q.DFTG_CODE == group)); } }
+        #endregion
+
+        #region Functions
+        /// <summary>
+        /// 鍚姩鑷姩鏇存柊缂撳瓨
+        /// </summary>
+        public void Start()
+        {
+            try
+            {
+                AutoUpdateThread = new(AutoUpdate);
+                AutoUpdateThread.Start();
+                Logger.Default.Info("Start MesDefect Cache Auto Update Thread");
+            }
+            catch (System.Exception ex)
+            {
+                Logger.Default.Fatal(ex, "Start MesDefect Cache Auto Update Thread Exception");
+            }
+        }
+
+        /// <summary>
+        /// 鍏抽棴鑷姩鏇存柊缂撳瓨
+        /// </summary>
+        public void Stop()
+        {
+            try
+            {
+                AutoUpdateThread?.Stop();
+                Logger.Console.Info("Stop MesDefect Cache Auto Update Thread");
+            }
+            catch (System.Exception ex)
+            {
+                Logger.Console.Fatal(ex, "Stop MesDefect Cache Auto Update Thread Exception");
+            }
+        }
+
+        /// <summary>
+        /// 鏇存柊鏁版嵁缂撳瓨
+        /// </summary>
+        public void Update()
+        {
+            var lastUpdate = Biz.Db.Queryable<BAS_DEFECT>().Max(q => q.UPDATE_TIME);
+            if (LastUpdateTime < lastUpdate)
+            {
+                _groups = Biz.Db.Queryable<BAS_DEFECT_GRP>().IncludesAllFirstLayer().ToList();
+                var defectList = new List<BAS_DEFECT>();
+                foreach (var group in _groups)
+                {
+                    defectList.AddRange(group.Defects);
+                }
+                _defects = defectList;
+                LastUpdateTime = defectList.Max(q => q.UPDATE_TIME);
+                Logger.Console.Info($"Get MesDefect successful, total {Defects.Count} params in {Groups.Count} groups, last update time is {LastUpdateTime:yyyy-MM-dd HH:mm:ss}");
+            }
+        }
+
+        /// <summary>
+        /// 鑷姩鏇存柊
+        /// </summary>
+        private void AutoUpdate()
+        {
+            try
+            {
+                Update();
+            }
+            catch (System.Exception ex)
+            {
+                Logger.Console.Fatal(ex, "MesDefect Cache Auto Update Exception");
+                LastUpdateTime = DateTime.MinValue;
+            }
+
+            //浼戠湢30鍒嗛挓
+            Thread.Sleep(30 * 60 * 1000);//
+        }
+
+
+        #endregion
+    }
+}
diff --git a/Tiger.Business.MES/DbCache/MesPositionCache.cs b/Tiger.Business.MES/DbCache/MesPositionCache.cs
new file mode 100644
index 0000000..f2d6625
--- /dev/null
+++ b/Tiger.Business.MES/DbCache/MesPositionCache.cs
@@ -0,0 +1,108 @@
+锘縰sing Newtonsoft.Json.Linq;
+using Rhea.Common;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Data;
+using System.Data.Entity;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Tiger.Business.MES.Transaction;
+using Tiger.IBusiness;
+using Tiger.Model;
+
+namespace Tiger.Business.DbCache
+{
+    /// <summary>
+    /// 宀椾綅鏁版嵁搴撴暟鎹紦瀛�
+    /// </summary>
+    public class MesPositionCache : IMesPositionCache
+    {
+        #region Variables
+        private WhileThread AutoUpdateThread;
+        private DateTime LastUpdateTime = DateTime.MinValue;
+        #endregion
+
+        #region Propertys
+        public string Id { get; set; } = Guid.NewGuid().ToString("N");
+        public string Tag { get; set; } = "MesPositionCache";
+        public string Name { get; set; } = "MesPositionCache";
+        public bool IsRunning { get; set; }
+        private List<MES_POSITION> _Positions = new();
+        public List<MES_POSITION> Positions { get { Update(); return _Positions; } set => _Positions = value; }
+        public MES_POSITION this[string code] { get { Update(); return _Positions.FirstOrDefault(q => q.POST_CODE == code); } }
+        #endregion
+
+        #region Functions
+        /// <summary>
+        /// 鍚姩鑷姩鏇存柊缂撳瓨
+        /// </summary>
+        public void Start()
+        {
+            try
+            {
+                AutoUpdateThread = new(AutoUpdate);
+                AutoUpdateThread.Start();
+                Logger.Default.Info("Start MesPosition Cache Auto Update Thread");
+            }
+            catch (System.Exception ex)
+            {
+                Logger.Default.Fatal(ex, "Start MesPosition Cache Auto Update Thread Exception");
+            }
+        }
+
+        /// <summary>
+        /// 鍏抽棴鑷姩鏇存柊缂撳瓨
+        /// </summary>
+        public void Stop()
+        {
+            try
+            {
+                AutoUpdateThread?.Stop();
+                Logger.Console.Info("Stop MesPosition Cache Auto Update Thread");
+            }
+            catch (System.Exception ex)
+            {
+                Logger.Console.Fatal(ex, "Stop MesPosition Cache Auto Update Thread Exception");
+            }
+        }
+
+        /// <summary>
+        /// 鏇存柊鏁版嵁缂撳瓨
+        /// </summary>
+        public void Update()
+        {
+            var lastUpdate = Biz.Db.Queryable<MES_POSITION>().Max(q => q.UPDATE_TIME);
+            if (LastUpdateTime < lastUpdate)
+            {
+                _Positions = Biz.Db.Queryable<MES_POSITION>().IncludesAllFirstLayer().ToList();
+                LastUpdateTime = lastUpdate;
+                Logger.Console.Info($"Get MesPosition successful, total {Positions.Count}, last update time is {LastUpdateTime:yyyy-MM-dd HH:mm:ss}");
+            }
+        }
+
+        /// <summary>
+        /// 鑷姩鏇存柊
+        /// </summary>
+        private void AutoUpdate()
+        {
+            try
+            {
+                Update();
+            }
+            catch (System.Exception ex)
+            {
+                Logger.Console.Fatal(ex, "MesPosition Cache Auto Update Exception");
+                LastUpdateTime = DateTime.MinValue;
+            }
+
+            //浼戠湢30鍒嗛挓
+            Thread.Sleep(30 * 60 * 1000);//
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file
diff --git a/Tiger.Business.MES/Task/Jobs.U9C_ME_GetWo.cs b/Tiger.Business.MES/Task/Jobs.U9C_ME_GetWo.cs
index f684dce..2807bcf 100644
--- a/Tiger.Business.MES/Task/Jobs.U9C_ME_GetWo.cs
+++ b/Tiger.Business.MES/Task/Jobs.U9C_ME_GetWo.cs
@@ -37,7 +37,7 @@
             Logger.Scheduler.Info(context.Trigger.ConvertToMonitor());
             try
             {
-                var _lastRunTime = Biz.SysParam["GetWo_LastRun", "Interface_LastRun"].PARAM_VALUE;
+                var _lastRunTime = Cache.SysParam["GetWo_LastRun", "Interface_LastRun"].PARAM_VALUE;
                 var LastRunTime = string.IsNullOrEmpty(_lastRunTime) ? DateTime.Now.AddMinutes(-10) : Convert.ToDateTime(_lastRunTime);
                 if ((DateTime.Now - LastRunTime).TotalMinutes > 10)
                 {
@@ -138,7 +138,7 @@
             {
                 string msg = "";
                 string status = "Successed";
-                var _lastRunTime = Biz.SysParam["GetWo_LastRun", "Interface_LastRun"].PARAM_VALUE;
+                var _lastRunTime = Cache.SysParam["GetWo_LastRun", "Interface_LastRun"].PARAM_VALUE;
                 var LastRunTime = string.IsNullOrEmpty(_lastRunTime) ? DateTime.Now.AddMinutes(-10) : Convert.ToDateTime(_lastRunTime);
                 StartTime = DateTime.Now;
                 //if ((DateTime.Now - LastRunTime).TotalMinutes > 10)
diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs
index d7fc0b3..7003188 100644
--- a/Tiger.Business.MES/Transaction/Position.cs
+++ b/Tiger.Business.MES/Transaction/Position.cs
@@ -779,9 +779,9 @@
                             switch (pv.VAR_METHOD)
                             {
                                 case "GetCartonGenerate":
-                                    return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
+                                    return Cache.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
                                 case "GetHW21SNGenerate":
-                                    return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("SN:", "05").Data.ToString() ?? "";
+                                    return Cache.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("SN:", "05").Data.ToString() ?? "";
                                 default:
                                     return "";
                             }
@@ -838,7 +838,7 @@
         /// <returns></returns>
         private string GetBoxCode()
         {
-            return Biz.CodeRule["WhiteBoxNo"]?.Generate("W", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
+            return Cache.CodeRule["WhiteBoxNo"]?.Generate("W", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
         }
 
         /// <summary>
@@ -847,7 +847,7 @@
         /// <returns></returns>
         private string GetCardCode()
         {
-            return Biz.CodeRule["CartonNo"]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
+            return Cache.CodeRule["CartonNo"]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
         }
 
         /// <summary>
@@ -957,7 +957,7 @@
         /// <returns></returns>
         public string GenerateSN(string ruleCode, IWorkAction curAction)
         {
-            var rule = Biz.CodeRule[ruleCode ?? ""];
+            var rule = Cache.CodeRule[ruleCode ?? ""];
             if (!rule.IsNullOrEmpty())
             {
                 switch (rule.RULE_CODE)
diff --git a/Tiger.Business.MES/WorkAction/Assembly.cs b/Tiger.Business.MES/WorkAction/Assembly.cs
index 7173fd3..b3eab36 100644
--- a/Tiger.Business.MES/WorkAction/Assembly.cs
+++ b/Tiger.Business.MES/WorkAction/Assembly.cs
@@ -158,9 +158,9 @@
                     //鏍规嵁鏉$爜瑙勫垯楠岃瘉涓婃枡鏄惁姝g‘
                     if (!item.RuleCode.IsNullOrEmpty())
                     {
-                        if (!Biz.CodeRule[item.RuleCode].IsNullOrEmpty())
+                        if (!Cache.CodeRule[item.RuleCode].IsNullOrEmpty())
                         {
-                            var result = Biz.CodeRule[item.RuleCode].Verify(input.SN);
+                            var result = Cache.CodeRule[item.RuleCode].Verify(input.SN);
                             if (!result.IsSuccessed)
                             {
                                 isOK = false;
@@ -186,9 +186,9 @@
                         {
                             if (!subItem.RULE_CODE.IsNullOrEmpty())
                             {
-                                if (!Biz.CodeRule[subItem.RULE_CODE].IsNullOrEmpty())
+                                if (!Cache.CodeRule[subItem.RULE_CODE].IsNullOrEmpty())
                                 {
-                                    var result = Biz.CodeRule[item.RuleCode].Verify(input.SN);
+                                    var result = Cache.CodeRule[item.RuleCode].Verify(input.SN);
                                     //鍙鏈変竴涓浛浠f枡閫氳繃楠岃瘉鍒欏彲浠ヤ笂鏂�
                                     if (result.IsSuccessed)
                                     {
diff --git a/Tiger.Business.MES/WorkAction/ThreeInOne.cs b/Tiger.Business.MES/WorkAction/ThreeInOne.cs
index abcb818..01901ee 100644
--- a/Tiger.Business.MES/WorkAction/ThreeInOne.cs
+++ b/Tiger.Business.MES/WorkAction/ThreeInOne.cs
@@ -297,9 +297,9 @@
                 action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotSameCustomer", CustCSN.CUST_SN, CustCSN.CUST_CODE, CurPosition.WorkBatch.WO.CUST_CODE);
             }
             //楠岃瘉浜у搧瀹㈡埛鏍囩鏉$爜瑙勫垯
-            if (isOK && !CustInfo.IsNullOrEmpty() && !CustInfo.RULE_CODE.IsNullOrEmpty() && !Biz.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty())
+            if (isOK && !CustInfo.IsNullOrEmpty() && !CustInfo.RULE_CODE.IsNullOrEmpty() && !Cache.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty())
             {
-                var result = Biz.CodeRule[CustInfo.RULE_CODE].Verify(CustCSN.CUST_SN);
+                var result = Cache.CodeRule[CustInfo.RULE_CODE].Verify(CustCSN.CUST_SN);
                 if (!result.IsSuccessed)
                 {
                     CurStep.SetStatusMessage(StepStatus.Error, Biz.L("璇锋壂鎻忔纭殑瀹㈡埛鏍囩"));
diff --git a/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs b/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs
index cac915d..a037fb5 100644
--- a/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs
+++ b/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs
@@ -104,9 +104,9 @@
             {
                 var isOK = true;
                 //楠岃瘉閫昏緫
-                if (!CustInfo.RULE_CODE.IsNullOrEmpty() && !Biz.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty())
+                if (!CustInfo.RULE_CODE.IsNullOrEmpty() && !Cache.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty())
                 {
-                    var result = Biz.CodeRule[CustInfo.RULE_CODE].Verify(CurPosition.CurSN);
+                    var result = Cache.CodeRule[CustInfo.RULE_CODE].Verify(CurPosition.CurSN);
                     if (!result.IsSuccessed)
                     {
                         CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩楠岃瘉澶辫触"));
diff --git a/Tiger.Business.MES/WorkAction/YadaAssembly.cs b/Tiger.Business.MES/WorkAction/YadaAssembly.cs
index e199743..3be3ab7 100644
--- a/Tiger.Business.MES/WorkAction/YadaAssembly.cs
+++ b/Tiger.Business.MES/WorkAction/YadaAssembly.cs
@@ -162,9 +162,9 @@
                     //鏍规嵁鏉$爜瑙勫垯楠岃瘉涓婃枡鏄惁姝g‘
                     if (!item.RuleCode.IsNullOrEmpty())
                     {
-                        if (!Biz.CodeRule[item.RuleCode].IsNullOrEmpty())
+                        if (!Cache.CodeRule[item.RuleCode].IsNullOrEmpty())
                         {
-                            var result = Biz.CodeRule[item.RuleCode].Verify(input.SN);
+                            var result = Cache.CodeRule[item.RuleCode].Verify(input.SN);
                             if (!result.IsSuccessed)
                             {
                                 isOK = false;
@@ -190,9 +190,9 @@
                         {
                             if (!subItem.RULE_CODE.IsNullOrEmpty())
                             {
-                                if (!Biz.CodeRule[subItem.RULE_CODE].IsNullOrEmpty())
+                                if (!Cache.CodeRule[subItem.RULE_CODE].IsNullOrEmpty())
                                 {
-                                    var result = Biz.CodeRule[item.RuleCode].Verify(input.SN);
+                                    var result = Cache.CodeRule[item.RuleCode].Verify(input.SN);
                                     //鍙鏈変竴涓浛浠f枡閫氳繃楠岃瘉鍒欏彲浠ヤ笂鏂�
                                     if (result.IsSuccessed)
                                     {
diff --git a/Tiger.Business.MES/iERP/MES_U9C.cs b/Tiger.Business.MES/iERP/MES_U9C.cs
index 8bf3e4a..f173244 100644
--- a/Tiger.Business.MES/iERP/MES_U9C.cs
+++ b/Tiger.Business.MES/iERP/MES_U9C.cs
@@ -26,13 +26,13 @@
 {
     public partial class MES_U9C : IMES_U9C
     {
-        public static string U9CAuthLoginUrl { get; set; } = Biz.SysParam["U9CAuthLoginUrl_Test", "U9CUrl"].PARAM_VALUE; // "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?"; 娴嬭瘯
-        //public static string U9CAuthLoginUrl { get; set; } = Biz.SysParam["U9CAuthLoginUrl", "U9CUrl"].PARAM_VALUE; //姝e紡
+        public static string U9CAuthLoginUrl { get; set; } = Cache.SysParam["U9CAuthLoginUrl_Test", "U9CUrl"].PARAM_VALUE; // "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?"; 娴嬭瘯
+        //public static string U9CAuthLoginUrl { get; set; } = Cache.SysParam["U9CAuthLoginUrl", "U9CUrl"].PARAM_VALUE; //姝e紡
         public static string secret = "&entcode=02&orgcode=101&clientid=mes&clientsecret=12c8ee7e9bb74ad2a6a0fb3315c8af20";
         public static string RcvRptDocCreateUrl
-        { get; set; } = Biz.SysParam["RcvRptDocCreateUrl_Test", "U9CUrl"].PARAM_VALUE;  //"http://172.16.80.20/u9C/webapi/RcvRptDoc/Create"; 娴嬭瘯
+        { get; set; } = Cache.SysParam["RcvRptDocCreateUrl_Test", "U9CUrl"].PARAM_VALUE;  //"http://172.16.80.20/u9C/webapi/RcvRptDoc/Create"; 娴嬭瘯
         //public static string RcvRptDocCreateUrl
-        //{ get; set; } = Biz.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE;  //姝e紡
+        //{ get; set; } = Cache.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE;  //姝e紡
 
         /// <summary>
         /// 鍏ュ簱鍗曟帴鍙�
diff --git a/Tiger.Business.WMS/AGV/Agv.cs b/Tiger.Business.WMS/AGV/Agv.cs
index bf79621..a62919e 100644
--- a/Tiger.Business.WMS/AGV/Agv.cs
+++ b/Tiger.Business.WMS/AGV/Agv.cs
@@ -18,7 +18,7 @@
         /// <summary>
         /// AGV鎺ュ彛URL
         /// </summary>
-        public static string agvurl { get; set; } = @$"{Biz.SysParam["agvUrl", "AgvApiAddress"].PARAM_VALUE}"; //@"http://10.12.16.249:10007/rcs/order/";
+        public static string agvurl { get; set; } = @$"{Cache.SysParam["agvUrl", "AgvApiAddress"].PARAM_VALUE}"; //@"http://10.12.16.249:10007/rcs/order/";
 
         /// <summary>
         /// 澶囨枡瀹屾垚閫氱煡
diff --git a/Tiger.Business.WMS/BS/BS.ItemCount.cs b/Tiger.Business.WMS/BS/BS.ItemCount.cs
index 6f700b8..99cf780 100644
--- a/Tiger.Business.WMS/BS/BS.ItemCount.cs
+++ b/Tiger.Business.WMS/BS/BS.ItemCount.cs
@@ -26,7 +26,7 @@
         {
             var action = new ApiAction();
 
-            Result ruleResult = Biz.CodeRule["PD001"].Generate("PD");  //iWMS.GetBillNoByType("CI");
+            Result ruleResult = Cache.CodeRule["PD001"].Generate("PD");  //iWMS.GetBillNoByType("CI");
             if (!ruleResult.IsSuccessed)
             {
                 throw new Exception(ruleResult.ExceptionMsg.Message);
diff --git a/Tiger.Business.WMS/BS/BS.Transfer.cs b/Tiger.Business.WMS/BS/BS.Transfer.cs
index c9fe692..47b2278 100644
--- a/Tiger.Business.WMS/BS/BS.Transfer.cs
+++ b/Tiger.Business.WMS/BS/BS.Transfer.cs
@@ -24,7 +24,7 @@
         {
             var action = new ApiAction();
 
-            Result ruleResult = Biz.CodeRule["TF001"].Generate("TF");  //iWMS.GetBillNoByType("CI");
+            Result ruleResult = Cache.CodeRule["TF001"].Generate("TF");  //iWMS.GetBillNoByType("CI");
             if (!ruleResult.IsSuccessed)
             {
                 throw new Exception(ruleResult.ExceptionMsg.Message);
diff --git a/Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs b/Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs
index f642305..a10afd8 100644
--- a/Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs
+++ b/Tiger.Business.WMS/DigitalTwin/Sharetronic/ShelfApi.cs
@@ -20,7 +20,7 @@
     /// </summary>
     public class Api
     {
-        private static int WaitingTime = Biz.SysParam["Shelf_OperationWaitingTime"].PARAM_VALUE.ToInt32(30);
+        private static int WaitingTime = Cache.SysParam["Shelf_OperationWaitingTime"].PARAM_VALUE.ToInt32(30);
         private static async Task<ShelfApiResult> RunAsync(string url, object obj = null)
         {
             try
diff --git a/Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs b/Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs
index 55b2af9..880b01a 100644
--- a/Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs
+++ b/Tiger.Business.WMS/T100ToWMS/MaterialInfoBusiness.cs
@@ -577,7 +577,7 @@
                                     MailTextBody = $"Hi All锛�<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;{orderType}[{model.payload.std_data.parameter.indc008}]璋冩嫧涓诲姩杩囪处澶辫触锛�<br/> T100杩斿洖娑堟伅锛歿result.payload.std_data.execution.description}",
                                     MailBodyType = "Html",
                                     MailFilePath = null,
-                                    Recipients = Biz.SysParam.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> {  "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
+                                    Recipients = Cache.SysParam.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> {  "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
                                     Cc = new List<string>(),
                                     Sender = "WMS Email Admin",
                                     SenderAddress = "xcerp@sharetronic.com",
@@ -1922,7 +1922,7 @@
                         MailTextBody = "浠ヤ笅鐗╂枡棰勮秴鏈燂紝璇峰強鏃跺鐞嗭紒<br/><br/>" + string.Join(" ", msg),
                         MailBodyType = "Html",
                         MailFilePath = null,
-                        Recipients = Biz.SysParam.Params.Where(q => q.PRMG_CODE == "MaterialExtended").Select(q => q.PARAM_VALUE).ToList(),
+                        Recipients = Cache.SysParam.Params.Where(q => q.PRMG_CODE == "MaterialExtended").Select(q => q.PARAM_VALUE).ToList(),
                         Cc = new List<string>(),
                         Sender = "WMS Email Admin",
                         SenderAddress = "xcerp@sharetronic.com",
diff --git a/Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs b/Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs
index b6c4d1a..4f62779 100644
--- a/Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs
+++ b/Tiger.Business.WMS/Task/ERP/Jobs.VenderFromErpJob.cs
@@ -25,7 +25,7 @@
             Logger.Scheduler.Info(context.Trigger.ConvertToMonitor());
             try
             {
-                var _lastRunTime = Biz.SysParam["Vender_LastTime"].PARAM_VALUE;
+                var _lastRunTime = Cache.SysParam["Vender_LastTime"].PARAM_VALUE;
                 var  LastRunTime = string.IsNullOrEmpty(_lastRunTime) ? DateTime.Now.AddDays(-1) : Convert.ToDateTime(_lastRunTime);
                 if ((DateTime.Now - LastRunTime).TotalDays >= 1)
                 {
diff --git a/Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs b/Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs
index ac1ac0b..e41bd05 100644
--- a/Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs
+++ b/Tiger.Business.WMS/Task/iSRM/Jobs.QqtSrmJob.cs
@@ -26,7 +26,7 @@
             Logger.Scheduler.Info(context.Trigger.ConvertToMonitor());
             try
             {
-                var _lastRunTime = Biz.SysParam["LastRun"].PARAM_VALUE;
+                var _lastRunTime = Cache.SysParam["LastRun"].PARAM_VALUE;
                 var LastRunTime = string.IsNullOrEmpty(_lastRunTime) ? DateTime.Now.AddMinutes(-30) : Convert.ToDateTime(_lastRunTime);
                 if ((DateTime.Now - LastRunTime).TotalMinutes > 30)
                 {
diff --git a/Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs b/Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs
index 81b204b..341b8df 100644
--- a/Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs
+++ b/Tiger.Business.WMS/Transaction/CustSupplyCheckingNew.cs
@@ -336,7 +336,7 @@
                 //var nWarehouseCodes = nScannedBarcodes.Select(x => x.WarehouseCode).Distinct().ToList();
 
                 //鏂板缓鍏朵粬鍏ュ簱鍗曟嵁澶� OtherInstockHeader
-                Result ruleResult = Biz.CodeRule["CI001"].Generate("CI");  //iWMS.GetBillNoByType("CI");
+                Result ruleResult = Cache.CodeRule["CI001"].Generate("CI");  //iWMS.GetBillNoByType("CI");
                 if (!ruleResult.IsSuccessed)
                 {
                     throw new Exception(ruleResult.ExceptionMsg.Message);
@@ -452,7 +452,7 @@
                             pmdtud011 = "0"
                         });
 
-                        Result iqcResult = Biz.CodeRule["IQC001"].Generate("IQC");
+                        Result iqcResult = Cache.CodeRule["IQC001"].Generate("IQC");
                         if (!iqcResult.IsSuccessed)
                         {
                             throw new Exception(iqcResult.ExceptionMsg.Message);
diff --git a/Tiger.Business.WMS/Transaction/InReceipt.cs b/Tiger.Business.WMS/Transaction/InReceipt.cs
index e7f00bf..a4edbd1 100644
--- a/Tiger.Business.WMS/Transaction/InReceipt.cs
+++ b/Tiger.Business.WMS/Transaction/InReceipt.cs
@@ -344,7 +344,7 @@
                 //var nWarehouseCodes = nScannedBarcodes.Select(x => x.WarehouseCode).Distinct().ToList();
 
                 ////鏂板缓鍗曟嵁
-                //Result ruleResult = Biz.CodeRule["R001"].Generate("RE");
+                //Result ruleResult = Cache.CodeRule["R001"].Generate("RE");
                 //if (!ruleResult.IsSuccessed)
                 //{
                 //    throw new Exception(ruleResult.ExceptionMsg.Message);
@@ -373,7 +373,7 @@
                 foreach (var resDtl in res)
                 {
                     //鏂板缓鍗曟嵁
-                    Result ruleResult = Biz.CodeRule["R001"].Generate("RE");
+                    Result ruleResult = Cache.CodeRule["R001"].Generate("RE");
                     if (!ruleResult.IsSuccessed)
                     {
                         throw new Exception(ruleResult.ExceptionMsg.Message);
@@ -423,7 +423,7 @@
                                 QTY = item.QTY
                             });
 
-                            Result iqcResult = Biz.CodeRule["IQC001"].Generate("IQC");
+                            Result iqcResult = Cache.CodeRule["IQC001"].Generate("IQC");
                             if (!iqcResult.IsSuccessed)
                             {
                                 throw new Exception(iqcResult.ExceptionMsg.Message);
diff --git a/Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs b/Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs
index 59e285c..3d40296 100644
--- a/Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs
+++ b/Tiger.Business.WMS/Transaction/OtherInLocationChecking.cs
@@ -302,7 +302,7 @@
                 //var nWarehouseCodes = nScannedBarcodes.Select(x => x.WarehouseCode).Distinct().ToList();
 
                 //鏂板缓鍏朵粬鍏ュ簱鍗曟嵁澶� OtherInstockHeader
-                Result ruleResult = Biz.CodeRule["OI001"].Generate("OI");  //iWMS.GetBillNoByType("CI");
+                Result ruleResult = Cache.CodeRule["OI001"].Generate("OI");  //iWMS.GetBillNoByType("CI");
                 if (!ruleResult.IsSuccessed)
                 {
                     throw new Exception(ruleResult.ExceptionMsg.Message);
diff --git a/Tiger.Business.WMS/Transaction/OutNoBillcode.cs b/Tiger.Business.WMS/Transaction/OutNoBillcode.cs
index 7de8deb..5fd86eb 100644
--- a/Tiger.Business.WMS/Transaction/OutNoBillcode.cs
+++ b/Tiger.Business.WMS/Transaction/OutNoBillcode.cs
@@ -24,7 +24,7 @@
             UserCode = userCode;
             ApiHost = apiHost;
             OrgCode = orgCode;
-            Result ruleResult = Biz.CodeRule["NB001"].Generate("NB");  //iWMS.GetBillNoByType("CI");
+            Result ruleResult = Cache.CodeRule["NB001"].Generate("NB");  //iWMS.GetBillNoByType("CI");
             if (!ruleResult.IsSuccessed)
             {
                 throw new Exception(ruleResult.ExceptionMsg.Message);
diff --git a/Tiger.Business.WMS/Transaction/OutOther.cs b/Tiger.Business.WMS/Transaction/OutOther.cs
index 4101933..e144659 100644
--- a/Tiger.Business.WMS/Transaction/OutOther.cs
+++ b/Tiger.Business.WMS/Transaction/OutOther.cs
@@ -402,7 +402,7 @@
                 //}
                 var MaxDC = CurPoolList.Any(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE) ? CurPoolList.Where(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE).Max(t => t.PROD_DATE) : DateTime.MinValue;
                 //鍒ゆ柇绯荤粺鍙傛暟鏄惁璁剧疆鍏堣繘鍏堝嚭
-                if (Biz.SysParam["YesOrNo"].PARAM_VALUE == "Y")
+                if (Cache.SysParam["YesOrNo"].PARAM_VALUE == "Y")
                 {
                     if (CurInv.Items.Max(x => x.PROD_DATE).Date > MaxDC.Date)
                     {
diff --git a/Tiger.Business.WMS/Transaction/OutSale.cs b/Tiger.Business.WMS/Transaction/OutSale.cs
index 90b7056..59ddfa8 100644
--- a/Tiger.Business.WMS/Transaction/OutSale.cs
+++ b/Tiger.Business.WMS/Transaction/OutSale.cs
@@ -327,7 +327,7 @@
                 //}
                 var MaxDC = CurPoolList.Any(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE) ? CurPoolList.Where(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE).Max(t => t.PROD_DATE) : DateTime.MinValue;
                 //鍒ゆ柇绯荤粺鍙傛暟鏄惁璁剧疆鍏堣繘鍏堝嚭
-                if (Biz.SysParam["YesOrNo"].PARAM_VALUE == "Y")
+                if (Cache.SysParam["YesOrNo"].PARAM_VALUE == "Y")
                 {
                     if (CurInv.Items.Max(x => x.PROD_DATE).Date > MaxDC.Date)
                     {
diff --git a/Tiger.Business.WMS/Transaction/OutSplit.cs b/Tiger.Business.WMS/Transaction/OutSplit.cs
index 69da3fa..b362074 100644
--- a/Tiger.Business.WMS/Transaction/OutSplit.cs
+++ b/Tiger.Business.WMS/Transaction/OutSplit.cs
@@ -370,7 +370,7 @@
                                                     .Where(x => x.FTY_CODE == FTY_CODE)
                                                     .First();
                     //鍙戦�佸埌MES
-                    if (Biz.SysParam["IsSend", "SendToMES"].PARAM_VALUE.ToString() == "Y" && !ReqNo.IsNullOrEmpty() && Biz.Db.Queryable<BIZ_ERP_PROD_OUT>().Where(x => x.BILLCODE == ReqNo).Any())
+                    if (Cache.SysParam["IsSend", "SendToMES"].PARAM_VALUE.ToString() == "Y" && !ReqNo.IsNullOrEmpty() && Biz.Db.Queryable<BIZ_ERP_PROD_OUT>().Where(x => x.BILLCODE == ReqNo).Any())
                     {
                         var dtl = Biz.Db.Queryable<BIZ_ERP_PROD_OUT_DTL>().Where(x => x.BILLCODE == ReqNo).First();
                         var sourcecode = dtl != null ? dtl.SOURCECODE : "";
@@ -389,7 +389,7 @@
                             erpBillCode = ReqNo, //MES鎺ュ彛澧炲姞瀛楁锛岃繑鍥炲鏂欏畬鎴愮殑褰撳墠棰嗘枡鍗曞彿 2023/05/17 Ben Lin
                             taskid = ""
                         };
-                        var mesApi = _factory != null ? _factory.MES_API : Biz.SysParam["apiUrl", "SendToMES"].PARAM_VALUE.ToString();
+                        var mesApi = _factory != null ? _factory.MES_API : Cache.SysParam["apiUrl", "SendToMES"].PARAM_VALUE.ToString();
                         var res = HttpHelper.PostAsync(mesApi, JsonConvert.SerializeObject(toMes)).Result;
                         var _action = JsonConvert.DeserializeObject<ApiAction>(res.Message);
                         Logger.Interface.Info($"鐢熶骇棰嗘枡-鑷姩鎷嗗垎鐗╂枡 =>鎷嗗垎鐗╂枡鍙戞枡鍙戦�丮ES瀹屾垚锛屽崟鍙凤細[{ReqNo}]锛孧ES浼犲叆Json:{JsonConvert.SerializeObject(toMes)}锛孧ES杩斿洖锛歿res.Message}");
diff --git a/Tiger.Business.WMS/Transaction/OutTransfer.cs b/Tiger.Business.WMS/Transaction/OutTransfer.cs
index 57d37d7..5684fae 100644
--- a/Tiger.Business.WMS/Transaction/OutTransfer.cs
+++ b/Tiger.Business.WMS/Transaction/OutTransfer.cs
@@ -334,7 +334,7 @@
                 //}
                 var MaxDC = CurPoolList.Any(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE) ? CurPoolList.Where(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE).Max(t => t.PROD_DATE) : DateTime.MinValue;
                 //鍒ゆ柇绯荤粺鍙傛暟鏄惁璁剧疆鍏堣繘鍏堝嚭
-                if (Biz.SysParam["YesOrNo"].PARAM_VALUE == "Y")
+                if (Cache.SysParam["YesOrNo"].PARAM_VALUE == "Y")
                 {
                     if (CurInv.Items.Max(x => x.PROD_DATE).Date > MaxDC.Date)
                     {
diff --git a/Tiger.Business.WMS/Transaction/OutWorkOrder.cs b/Tiger.Business.WMS/Transaction/OutWorkOrder.cs
index b66ddc0..f0b24b6 100644
--- a/Tiger.Business.WMS/Transaction/OutWorkOrder.cs
+++ b/Tiger.Business.WMS/Transaction/OutWorkOrder.cs
@@ -420,7 +420,7 @@
                 //}
                 var MaxDC = CurPoolList.Any(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE) ? CurPoolList.Where(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE).Max(t => t.PROD_DATE) : DateTime.MinValue;
                 //鍒ゆ柇绯荤粺鍙傛暟鏄惁璁剧疆鍏堣繘鍏堝嚭
-                if (Biz.SysParam["YesOrNo"].PARAM_VALUE == "Y")
+                if (Cache.SysParam["YesOrNo"].PARAM_VALUE == "Y")
                 {
                     if (CurInv.Items.Max(x => x.PROD_DATE).Date > MaxDC.Date)
                     {
@@ -775,10 +775,10 @@
                 }
 
                 //鍙戦�佸埌MES
-                var isSend = Biz.SysParam["IsSend", "SendToMES"].PARAM_VALUE.ToString() == "Y";
+                var isSend = Cache.SysParam["IsSend", "SendToMES"].PARAM_VALUE.ToString() == "Y";
                 if (isSend && !isCutting)
                 {
-                    var mesApi = _factory != null ? _factory.MES_API : Biz.SysParam["apiUrl", "SendToMES"].PARAM_VALUE.ToString();
+                    var mesApi = _factory != null ? _factory.MES_API : Cache.SysParam["apiUrl", "SendToMES"].PARAM_VALUE.ToString();
                     var response = HttpHelper.PostAsync(mesApi, JsonConvert.SerializeObject(toMes)).Result;
                     var _action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                     Logger.Interface.Info($"宸ュ崟棰嗘枡 =>鍙戞枡瀹屾垚锛屽崟鍙穂{req.BILLCODE}]锛屾潯鐮乕{CurInv.SN}]锛岀姸鎬乕{req.STATUS.GetEnumDesc<BIZ_ERP_PROD_OUT.STATUSs>()}]锛孧ES杩斿洖锛歿response.Message}");
diff --git a/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs b/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs
index cb6742e..67482d1 100644
--- a/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs
+++ b/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs
@@ -545,7 +545,7 @@
                 //}
                 var MaxDC = CurPoolList.Any(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE) ? CurPoolList.Where(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE).Max(t => t.PROD_DATE) : DateTime.MinValue;
                 //鍒ゆ柇绯荤粺鍙傛暟鏄惁璁剧疆鍏堣繘鍏堝嚭
-                if (Biz.SysParam["YesOrNo"].PARAM_VALUE == "Y")
+                if (Cache.SysParam["YesOrNo"].PARAM_VALUE == "Y")
                 {
                     if (CurInv.Items.Max(x => x.PROD_DATE).Date > MaxDC.Date)
                     {
@@ -911,7 +911,7 @@
                         type = "done"
                     };
                     //JObject resp = PostMesApi(@"http://172.18.8.56:9533/api/WMS/Agv/materialPreparation", JsonConvert.SerializeObject(agvMPInput));
-                    var agvurl = _factory != null ? _factory.AGV_API : @$"{Biz.SysParam["agvUrl", "AgvApiAddress"].PARAM_VALUE}"; ;
+                    var agvurl = _factory != null ? _factory.AGV_API : @$"{Cache.SysParam["agvUrl", "AgvApiAddress"].PARAM_VALUE}"; ;
                     var agvResult = DI.Resolve<IAGV>().materialPreparation(agvMPInput, agvurl);
 
                     req.STATUS = BIZ_ERP_PROD_OUT.STATUSs.COMPLETE.GetValue();
@@ -932,10 +932,10 @@
                 }
 
                 //鍙戦�佸埌MES
-                var isSend = Biz.SysParam["IsSend", "SendToMES"].PARAM_VALUE.ToString() == "Y";
+                var isSend = Cache.SysParam["IsSend", "SendToMES"].PARAM_VALUE.ToString() == "Y";
                 if (isSend && !isCutting)
                 {
-                    var mesApi = _factory != null ? _factory.MES_API : Biz.SysParam["apiUrl", "SendToMES"].PARAM_VALUE.ToString();
+                    var mesApi = _factory != null ? _factory.MES_API : Cache.SysParam["apiUrl", "SendToMES"].PARAM_VALUE.ToString();
                     var response = HttpHelper.PostAsync(mesApi, JsonConvert.SerializeObject(toMes)).Result;
                     var _action = JsonConvert.DeserializeObject<ApiAction>(response.Message);
                     Logger.Interface.Info($"鐢熶骇棰嗘枡 =>鍙戞枡瀹屾垚锛屽崟鍙穂{req.BILLCODE}]锛屾潯鐮乕{CurInv.SN}]锛岀姸鎬乕{req.STATUS.GetEnumDesc<BIZ_ERP_PROD_OUT.STATUSs>()}]锛孧ES浼犲叆Json:{JsonConvert.SerializeObject(toMes)}锛� MES杩斿洖锛歿response.Message}");
diff --git a/Tiger.Business.WMS/iWMS/ReceiptInfo.cs b/Tiger.Business.WMS/iWMS/ReceiptInfo.cs
index 750a282..42e0585 100644
--- a/Tiger.Business.WMS/iWMS/ReceiptInfo.cs
+++ b/Tiger.Business.WMS/iWMS/ReceiptInfo.cs
@@ -145,7 +145,7 @@
 
                     // 鐢熸垚鏀舵枡鍗�
                     //鏂板缓鍗曟嵁
-                    Result ruleResult = Biz.CodeRule["R001"].Generate("RE");
+                    Result ruleResult = Cache.CodeRule["R001"].Generate("RE");
                     if (!ruleResult.IsSuccessed)
                     {
                         throw new Exception(ruleResult.ExceptionMsg.Message);
@@ -192,7 +192,7 @@
                                 QTY = item.QTY
                             });
 
-                            Result iqcResult = Biz.CodeRule["IQC001"].Generate("IQC");
+                            Result iqcResult = Cache.CodeRule["IQC001"].Generate("IQC");
                             if (!iqcResult.IsSuccessed)
                             {
                                 throw new Exception(iqcResult.ExceptionMsg.Message);
diff --git a/Tiger.Business.WMS/iWMS/iWMS.cs b/Tiger.Business.WMS/iWMS/iWMS.cs
index 99aaf1c..e951299 100644
--- a/Tiger.Business.WMS/iWMS/iWMS.cs
+++ b/Tiger.Business.WMS/iWMS/iWMS.cs
@@ -285,7 +285,7 @@
                                         MailTextBody = $"Hi All锛�<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;棰嗘枡鍗昜{entity_h.BILLCODE}]杩囪处澶辫触锛�<br/> T100杩斿洖娑堟伅锛歿ret.payload.std_data.execution.description}",
                                         MailBodyType = "Html",
                                         MailFilePath = null,
-                                        Recipients = Biz.SysParam.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> { "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
+                                        Recipients = Cache.SysParam.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> { "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
                                         Cc = new List<string>(),
                                         Sender = "WMS Email Admin",
                                         SenderAddress = "xcerp@sharetronic.com",
@@ -426,7 +426,7 @@
                                         MailTextBody = $"Hi All锛�<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;棰嗘枡鍗昜{entity_h.BILLCODE}]杩囪处澶辫触锛�<br/> T100杩斿洖娑堟伅锛歿ret.payload.std_data.execution.description}",
                                         MailBodyType = "Html",
                                         MailFilePath = null,
-                                        Recipients = Biz.SysParam.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> { "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
+                                        Recipients = Cache.SysParam.Params.Where(q => q.PRMG_CODE == "PickingEmailGroup").Select(q => q.PARAM_VALUE).ToList(), // new List<string> { "ben.lin@tigerclouds.com", "dyfang@sharetronic.com", "dianzicang@sharetronic.com" },
                                         Cc = new List<string>(),
                                         Sender = "WMS Email Admin",
                                         SenderAddress = "xcerp@sharetronic.com",
diff --git a/Tiger.Business/DbCache/Biz.CodeRule.cs b/Tiger.Business/DbCache/Biz.CodeRule.cs
index b6c2ed3..6b1800f 100644
--- a/Tiger.Business/DbCache/Biz.CodeRule.cs
+++ b/Tiger.Business/DbCache/Biz.CodeRule.cs
@@ -14,17 +14,10 @@
 using System.Diagnostics;
 using System.Threading;
 using System.Data;
+using Tiger.IBusiness;
 
 namespace Tiger.Business
 {
-    public partial class Biz
-    {
-        /// <summary>
-        /// 鑾峰彇鏉$爜瑙勫垯缂撳瓨
-        /// </summary>
-        public static CodeRuleCache CodeRule => DbCacheBus.CodeRuleCache;
-    }
-
     /// <summary>
     /// BAS_CODE_RULE 鎵╁睍绫�
     /// </summary>
@@ -38,7 +31,7 @@
         /// <returns></returns>
         public static Result Verify(this BAS_CODE_RULE rule, string sn)
         {
-            return Biz.CodeRule.Verify(sn, rule);
+            return Cache.CodeRule.Verify(sn, rule);
         }
 
         /// <summary>
@@ -49,7 +42,7 @@
         /// <returns></returns>
         public static Result Generate(this BAS_CODE_RULE rule, params object?[] args)
         {
-            return Biz.CodeRule.Generate(rule.RULE_CODE, args);
+            return Cache.CodeRule.Generate(rule.RULE_CODE, args);
         }
 
         /// <summary>
@@ -60,7 +53,7 @@
         /// <returns></returns>
         public static Result TryGenerate(this BAS_CODE_RULE rule, params object?[] args)
         {
-            return Biz.CodeRule.TryGenerate(rule.RULE_CODE, args);
+            return Cache.CodeRule.TryGenerate(rule.RULE_CODE, args);
         }
     }//endClass
 
@@ -187,7 +180,7 @@
         public Expression<Func<BAS_CODE_RULE, bool>> Expression { get; set; }
         public Exception VerifyException { get; set; }
         private List<RuleVerifier> _Verifiers = new();
-        public List<RuleVerifier> Verifiers => _Verifiers.IsNullOrEmpty() ? Biz.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList() : _Verifiers;
+        public List<RuleVerifier> Verifiers => _Verifiers.IsNullOrEmpty() ? Cache.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList() : _Verifiers;
         /// <summary>
         /// 鏄惁瀹屾垚楠岃瘉
         /// </summary>
@@ -213,7 +206,7 @@
             var begin = DateTime.Now;
             ElapsedTime = 0;
             //Debug.WriteLine($"{Code} verify begin at {begin:T}");
-            _Verifiers = Biz.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList();
+            _Verifiers = Cache.CodeRule.Rules.WhereIF(!Predicate.IsNullOrEmpty(), Predicate).Select(q => new RuleVerifier(q)).ToList();
             foreach (var item in Verifiers)
             {
                 Work.DoAsync(() => { item.Verify(Code); });
diff --git a/Tiger.Business/DbCache/Biz.SysParam.cs b/Tiger.Business/DbCache/Biz.SysParam.cs
deleted file mode 100644
index 6affe32..0000000
--- a/Tiger.Business/DbCache/Biz.SysParam.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-锘縰sing Tiger.Model;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using System.Text;
-using System.Threading.Tasks;
-using Rhea.Common;
-using System.Net;
-using System.Linq;
-using Newtonsoft.Json;
-using Tiger.Business.DbCache;
-
-namespace Tiger.Business
-{
-    public partial class Biz
-    {
-        /// <summary>
-        /// 鑾峰彇绯荤粺鍙傛暟缂撳瓨
-        /// </summary>
-        public static SysParamCache SysParam => DbCacheBus.SysParamCache;
-        //public static SysParamCacheOld SysParamOld => DbCacheBus.SysParamCacheOld;
-    }//endClass
-}
diff --git a/Tiger.Business/DbCache/Cache.cs b/Tiger.Business/DbCache/Cache.cs
new file mode 100644
index 0000000..c85e2c8
--- /dev/null
+++ b/Tiger.Business/DbCache/Cache.cs
@@ -0,0 +1,28 @@
+锘縰sing Tiger.Model;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+using Rhea.Common;
+using System.Net;
+using System.Linq;
+using Newtonsoft.Json;
+using Tiger.Business.DbCache;
+using Tiger.IBusiness;
+
+namespace Tiger.Business
+{
+    public partial class Cache
+    {
+        /// <summary>
+        /// 鑾峰彇鏉$爜瑙勫垯缂撳瓨
+        /// </summary>
+        public static ICodeRuleCache CodeRule => DI.Resolve<ICodeRuleCache>();
+        /// <summary>
+        /// 鑾峰彇绯荤粺鍙傛暟缂撳瓨
+        /// </summary>
+        public static ISysParamCache SysParam => DI.Resolve<ISysParamCache>();
+    }//endClass
+}
diff --git a/Tiger.Business/DbCache/DbCacheBus.cs b/Tiger.Business/DbCache/DbCacheBus.cs
deleted file mode 100644
index 9d85ed0..0000000
--- a/Tiger.Business/DbCache/DbCacheBus.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-锘縰sing Rhea.Common;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Tiger.Business.DbCache;
-using Tiger.IBusiness;
-
-namespace Tiger.Business
-{
-    /// <summary>
-    /// 鐩戞帶鎬绘帶
-    /// </summary>
-    public class DbCacheBus : IDbCacheBus
-    {
-        public static SysParamCache SysParamCache = new();
-        //public static SysParamCacheOld SysParamCacheOld = new();
-        public static CodeRuleCache CodeRuleCache = new();
-        #region Functions
-        public ISysParamCache GetSysParamCache() => SysParamCache;
-        public ICodeRuleCache GetCodeRuleCache() => CodeRuleCache;
-        public void StartAutoUpdate()
-        {
-            if (BizConfig.Configuration["IsUseDbCache"]?.ToLower() == "true")
-            {
-	            //寮�鍚郴缁熷弬鏁扮紦瀛�
-	            SysParamCache.Start();
-                //SysParamCacheOld.Start();
-                ConsoleExt.WriteLine("Start SysParam Cache Auto Update Thread..........", ConsoleColor.Yellow);
-                //寮�鍚郴缁熷弬鏁扮紦瀛�
-                CodeRuleCache.Start();
-                ConsoleExt.WriteLine("Start CodeRule Cache Auto Update Thread..........", ConsoleColor.Yellow);
-            }
-        }
-
-        public void StopAutoUpdate()
-        {
-            if (BizConfig.Configuration["IsUseDbCache"]?.ToLower() == "true")
-            {
-	            //鍏抽棴绯荤粺鍙傛暟缂撳瓨
-	            SysParamCache.Stop();
-                //SysParamCacheOld.Stop();
-                //鍏抽棴绯荤粺鍙傛暟缂撳瓨
-                CodeRuleCache.Stop();
-            }
-        }
-        #endregion
-    }
-}
diff --git a/Tiger.Business/DbCache/SysParamCacheOld.cs b/Tiger.Business/DbCache/SysParamCacheOld.cs
deleted file mode 100644
index befe9ef..0000000
--- a/Tiger.Business/DbCache/SysParamCacheOld.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-锘縰sing Rhea.Common;
-using System;
-using System.Collections.Generic;
-using System.Data.Entity;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Tiger.IBusiness;
-using Tiger.Model;
-
-namespace Tiger.Business.DbCache
-{
-    /// <summary>
-    /// 绯荤粺鍙傛暟鏁版嵁搴撴暟鎹紦瀛�
-    /// </summary>
-    public class SysParamCacheOld : ISysParamCache
-    {
-        #region Variables
-        private WhileThread AutoUpdateThread;
-        private DateTime LastUpdateTime = DateTime.MinValue;
-        #endregion
-
-        #region Propertys
-        public string Id { get; set; } = Guid.NewGuid().ToString("N");
-        public string Tag { get; set; } = "SysParamCache";
-        public string Name { get; set; } = "SysParamCache";
-        public bool IsRunning { get; set; }
-        private List<SYS_PARAMGROUP> _groups = new();
-        public List<SYS_PARAMGROUP> Groups { get { Update(); return _groups; } set => _groups = value; }
-        private List<SYS_PARAM> _params = new();
-        public List<SYS_PARAM> Params { get { Update(); return _params; } set => _params = value; }
-        public SYS_PARAM this[string code, string group = null] { get { Update(); return _params.FirstOrDefault(q => q.PARAM_CODE == code && (group.IsNullOrEmpty() || q.PRMG_CODE == group)); } }
-        #endregion
-
-        #region Functions
-        /// <summary>
-        /// 鍚姩鑷姩鏇存柊缂撳瓨
-        /// </summary>
-        public void Start()
-        {
-            try
-            {
-                AutoUpdateThread = new(AutoUpdate);
-                AutoUpdateThread.Start();
-                Logger.Default.Info("Start SysParam Cache Auto Update Thread");
-            }
-            catch (System.Exception ex)
-            {
-                Logger.Default.Fatal(ex, "Start SysParam Cache Auto Update Thread Exception");
-            }
-        }
-
-        /// <summary>
-        /// 鍏抽棴鑷姩鏇存柊缂撳瓨
-        /// </summary>
-        public void Stop()
-        {
-            try
-            {
-                AutoUpdateThread?.Stop();
-                Logger.Console.Info("Stop SysParam Cache Auto Update Thread");
-            }
-            catch (System.Exception ex)
-            {
-                Logger.Console.Fatal(ex, "Stop SysParam Cache Auto Update Thread Exception");
-            }
-        }
-
-        /// <summary>
-        /// 鏇存柊鏁版嵁缂撳瓨
-        /// </summary>
-        public void Update()
-        {
-            DbClient _db = Biz.DataSource["WMS57"].Client;
-            var lastUpdate = _db.Queryable<SYS_PARAM>().Max(q => q.UPDATE_TIME);
-            if (LastUpdateTime < lastUpdate)
-            {
-                _groups = _db.Queryable<SYS_PARAMGROUP>().IncludesAllFirstLayer().ToList();
-                var paramList = new List<SYS_PARAM>();
-                foreach (var group in _groups)
-                {
-                    paramList.AddRange(group.Params);
-                }
-                _params = paramList;
-                LastUpdateTime = paramList.Max(q => q.UPDATE_TIME);
-                Logger.Console.Info($"Get SysParam successful, total {Params.Count} params in {Groups.Count} groups, last update time is {LastUpdateTime:yyyy-MM-dd HH:mm:ss}");
-            }
-        }
-
-        /// <summary>
-        /// 鑷姩鏇存柊
-        /// </summary>
-        private void AutoUpdate()
-        {
-            try
-            {
-                Update();
-            }
-            catch (System.Exception ex)
-            {
-                Logger.Console.Fatal(ex, "SysParam Cache Auto Update Exception");
-                LastUpdateTime = DateTime.MinValue;
-            }
-
-            //浼戠湢30鍒嗛挓
-            Thread.Sleep(30 * 60 * 1000);//
-        }
-
-
-        #endregion
-    }
-}
diff --git a/Tiger.Business/SYS/Biz.Sys_Params.cs b/Tiger.Business/SYS/Biz.Sys_Params.cs
index 329e782..dba0035 100644
--- a/Tiger.Business/SYS/Biz.Sys_Params.cs
+++ b/Tiger.Business/SYS/Biz.Sys_Params.cs
@@ -24,7 +24,7 @@
             var action = new ApiAction<List<SYS_PARAM>>();
             try
             {
-                action.Data = code.IsNullOrEmpty()? Biz.SysParam.Params.Where(x=>x.PRMG_CODE == group).ToList(): new List<SYS_PARAM>() { Biz.SysParam[code, group] } ;
+                action.Data = code.IsNullOrEmpty()? Cache.SysParam.Params.Where(x=>x.PRMG_CODE == group).ToList(): new List<SYS_PARAM>() { Cache.SysParam[code, group] } ;
                 action.Message = $"鑾峰彇鍙傛暟鎴愬姛銆�";
             }
             catch (Exception ex)
diff --git a/Tiger.Business/Tiger.Business.csproj b/Tiger.Business/Tiger.Business.csproj
index d6cc7ee..979f7cc 100644
--- a/Tiger.Business/Tiger.Business.csproj
+++ b/Tiger.Business/Tiger.Business.csproj
@@ -66,6 +66,7 @@
     <Compile Remove="BaseService.cs" />
     <Compile Remove="Common\ApiConfig.cs" />
     <Compile Remove="DbBaseR.cs" />
+    <Compile Remove="DbCache\DbCacheBus.cs" />
     <Compile Remove="DbClientR.cs" />
     <Compile Remove="MES\Biz.WorkAction.cs" />
   </ItemGroup>
diff --git a/Tiger.Controllers.System/Controllers/Base/CacheController.CodeRule.cs b/Tiger.Controllers.System/Controllers/Base/CacheController.CodeRule.cs
index a493696..9891a95 100644
--- a/Tiger.Controllers.System/Controllers/Base/CacheController.CodeRule.cs
+++ b/Tiger.Controllers.System/Controllers/Base/CacheController.CodeRule.cs
@@ -6,6 +6,7 @@
 using System.Threading.Tasks;
 using Tiger.Model;
 using System.Linq.Expressions;
+using Tiger.Api.DbCache;
 
 namespace Tiger.Api.Controllers.Base
 {
@@ -23,7 +24,7 @@
             ApiAction response;
             try
             {
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetCodeRuleCache()[action.Data?.ToString() ?? ""]);
+                response = action.GetResponse(Cache.CodeRule[action.Data?.ToString() ?? ""]);
             }
             catch (System.Exception ex)
             {
@@ -44,7 +45,7 @@
             ApiAction response;
             try
             {
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetCodeRuleCache().Rules.Where(q => q.RULE_TYPE == (action.Data?.ToInt32() ?? -1)).ToList());
+                response = action.GetResponse(Cache.CodeRule.Rules.Where(q => q.RULE_TYPE == (action.Data?.ToInt32() ?? -1)).ToList());
             }
             catch (Exception ex)
             {
@@ -65,7 +66,7 @@
             ApiAction response;
             try
             {
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetCodeRuleCache().TryGenerate(action.Data?.RuleCode, action.Data?.Args));
+                response = action.GetResponse(Cache.CodeRule.TryGenerate(action.Data?.RuleCode, action.Data?.Args));
             }
             catch (Exception ex)
             {
@@ -86,7 +87,7 @@
             ApiAction response;
             try
             {
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetCodeRuleCache().Generate(action.Data?.RuleCode, action.Data?.Args));
+                response = action.GetResponse(Cache.CodeRule.Generate(action.Data?.RuleCode, action.Data?.Args));
             }
             catch (Exception ex)
             {
@@ -116,7 +117,7 @@
                 {
                     predicate = predicate.And(q => q.RULE_TYPE == action.Data.RuleType);
                 }
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetCodeRuleCache().Verify(action.Data?.Code, predicate.Compile()));
+                response = action.GetResponse(Cache.CodeRule.Verify(action.Data?.Code, predicate.Compile()));
             }
             catch (Exception ex)
             {
diff --git a/Tiger.Controllers.System/Controllers/Base/CacheController.SysParam.cs b/Tiger.Controllers.System/Controllers/Base/CacheController.SysParam.cs
index f628c39..156a085 100644
--- a/Tiger.Controllers.System/Controllers/Base/CacheController.SysParam.cs
+++ b/Tiger.Controllers.System/Controllers/Base/CacheController.SysParam.cs
@@ -4,6 +4,7 @@
 using Tiger.IBusiness;
 using System.Linq;
 using System.Threading.Tasks;
+using Tiger.Api.DbCache;
 
 namespace Tiger.Api.Controllers.Base
 {
@@ -21,7 +22,7 @@
             ApiAction response;
             try
             {
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetSysParamCache()[action.Data?.ToString() ?? ""]);
+                response = action.GetResponse(Cache.SysParam[action.Data?.ToString() ?? ""]);
             }
             catch (System.Exception ex)
             {
@@ -42,7 +43,7 @@
             ApiAction response;
             try
             {
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetSysParamCache().Groups.FirstOrDefault(q => q.PRMG_CODE == (action.Data?.ToString() ?? "")));
+                response = action.GetResponse(Cache.SysParam.Groups.FirstOrDefault(q => q.PRMG_CODE == (action.Data?.ToString() ?? "")));
             }
             catch (Exception ex)
             {
@@ -63,7 +64,7 @@
             ApiAction response;
             try
             {
-                response = action.GetResponse(DI.Resolve<IDbCacheBus>().GetSysParamCache().Groups.Where(q => q.PRMG_TYPE == (action.Data?.ToString() ?? "")).ToList());
+                response = action.GetResponse(Cache.SysParam.Groups.Where(q => q.PRMG_TYPE == (action.Data?.ToString() ?? "")).ToList());
             }
             catch (Exception ex)
             {
diff --git a/Tiger.IBusiness/DbCache/IDbCacheBus.cs b/Tiger.IBusiness/DbCache/IDbCacheBus.cs
deleted file mode 100644
index 4c4b853..0000000
--- a/Tiger.IBusiness/DbCache/IDbCacheBus.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-锘縰sing Autofac;
-using Rhea.Common;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tiger.IBusiness
-{
-    public interface IDbCacheBus
-    {
-        public void StartAutoUpdate();
-
-        public void StopAutoUpdate();
-        public ISysParamCache GetSysParamCache();
-        public ICodeRuleCache GetCodeRuleCache();
-    }
-}
diff --git a/Tiger.IBusiness/DbCache/IMesDefectCache.cs b/Tiger.IBusiness/DbCache/IMesDefectCache.cs
new file mode 100644
index 0000000..a598a2e
--- /dev/null
+++ b/Tiger.IBusiness/DbCache/IMesDefectCache.cs
@@ -0,0 +1,21 @@
+锘縰sing Autofac;
+using Rhea.Common;
+using Rhea.Common.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+using System.Threading.Tasks;
+using Tiger.Model;
+
+namespace Tiger.IBusiness
+{
+    public interface IMesDefectCache : ITigerCache
+    {
+        public List<BAS_DEFECT_GRP> Groups { get; set; }
+        public List<BAS_DEFECT> Defects { get; set; }
+        public BAS_DEFECT this[string code, string group = null] { get; }
+    }
+}
diff --git a/Tiger.IBusiness/DbCache/IMesPositionCache.cs b/Tiger.IBusiness/DbCache/IMesPositionCache.cs
new file mode 100644
index 0000000..ad7baf7
--- /dev/null
+++ b/Tiger.IBusiness/DbCache/IMesPositionCache.cs
@@ -0,0 +1,21 @@
+锘縰sing Autofac;
+using Rhea.Common;
+using Rhea.Common.Interface;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Tiger.Model;
+
+namespace Tiger.IBusiness
+{
+    public interface IMesPositionCache : ITigerCache
+    {
+        public List<MES_POSITION> Positions { get; set; }
+        public MES_POSITION this[string code] { get; }
+
+    }
+}

--
Gitblit v1.9.3