From e52744716da77be232ac6ecc7573a2ef2294e65c Mon Sep 17 00:00:00 2001
From: czw <selecti@yeah.net>
Date: 星期五, 27 六月 2025 16:18:20 +0800
Subject: [PATCH] 1

---
 2025年6月12日/AuxAllWCS/Build/Project/代码/ViewModel.cs |  755 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 398 insertions(+), 357 deletions(-)

diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs"
index 74fea72..3b6c8bb 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs"
@@ -30,27 +30,27 @@
 using GZ.DB.Entity.OIDATABASE;
 namespace GZ.Projects.AuxAllWCS
 {
-	public partial class ViewModel : System.ComponentModel.INotifyPropertyChanged
-	{
-		#region 绉佹湁鍙橀噺
-		//闆嗘垚浜掕仈
-		private Conn Conn = new Conn();
-		//璁惧閫氫俊
-		private Device Device = new Device();
-		//鍙橀噺鏁版嵁搴�-		private Tag tag = new Tag();
-		public Tag Tag
-		{
-			get { return tag; }
-			set { tag = value; RaisePropertyChanged(nameof(Tag)); }
-		}
-		//绠�寲PLC
-		public EasyPLC EasyPLC = new EasyPLC();
-		#endregion
-		
-		#region 鏋勯�鍑芥暟
-		private static ViewModel _ViewModel = null;
-		private static List<object> _Windows = new List<object>();
+    public partial class ViewModel : System.ComponentModel.INotifyPropertyChanged
+    {
+        #region 绉佹湁鍙橀噺
+        //闆嗘垚浜掕仈
+        private Conn Conn = new Conn();
+        //璁惧閫氫俊
+        private Device Device = new Device();
+        //鍙橀噺鏁版嵁搴�+        private Tag tag = new Tag();
+        public Tag Tag
+        {
+            get { return tag; }
+            set { tag = value; RaisePropertyChanged(nameof(Tag)); }
+        }
+        //绠�寲PLC
+        public EasyPLC EasyPLC = new EasyPLC();
+        #endregion
+
+        #region 鏋勯�鍑芥暟
+        private static ViewModel _ViewModel = null;
+        private static List<object> _Windows = new List<object>();
         public static ViewModel CreateInstance(object obj, Type type)
         {
             if (_ViewModel == null)
@@ -59,47 +59,49 @@
             }
             if (!_Windows.Contains(obj))
             {
-				_Windows.Add(obj);
+                _Windows.Add(obj);
             }
             return _ViewModel;
         }
-		public ViewModel()
-		{
-			
-		}
-		#endregion
-		
-		#region 鑷畾涔夋寚浠�-public void Method1(System.Int32 param1)
-{
-		#region    [鑷畾涔夋寚浠[20250323111354905][Method1]
-
-		#endregion [鑷畾涔夋寚浠[20250323111354905][Method1]
-}
-public void SettingInit()
-{
-		#region    [鑷畾涔夋寚浠[20250323144605974][SettingInit]
-try
-{
-    var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "/Static/config.json";
-    using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile))
-    {
-        using (JsonTextReader reader = new JsonTextReader(file))
+        public ViewModel()
         {
-            JObject o = (JObject)JToken.ReadFrom(reader);
-            foreach (Newtonsoft.Json.Linq.JProperty keyValue in o.Properties())
+
+        }
+        #endregion
+
+        #region 鑷畾涔夋寚浠�+        public void Method1(System.Int32 param1)
+        {
+            #region    [鑷畾涔夋寚浠[20250323111354905][Method1]
+
+            #endregion [鑷畾涔夋寚浠[20250323111354905][Method1]
+        }
+        public void SettingInit()
+        {
+            #region    [鑷畾涔夋寚浠[20250323144605974][SettingInit]
+            try
             {
-                Console.WriteLine(keyValue.Name);
-                if (keyValue.Name == "HostToAgvServerUrl")
+                var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "/Static/config.json";
+                using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile))
                 {
-                    Settings.HostToAgvServerUrl = keyValue.Value.ToString();
-                }
-                if (keyValue.Name == "deviceInfo") {
-                      Settings.deviceInfos = JsonConvert.DeserializeObject<List<deviceInfo>>(keyValue.Value.ToString());
-                }
-                if (keyValue.Name == "HKbaseUrl") {
-                      Settings.HKbaseUrl = keyValue.Value.ToString();
-                }
+                    using (JsonTextReader reader = new JsonTextReader(file))
+                    {
+                        JObject o = (JObject)JToken.ReadFrom(reader);
+                        foreach (Newtonsoft.Json.Linq.JProperty keyValue in o.Properties())
+                        {
+                            Console.WriteLine(keyValue.Name);
+                            if (keyValue.Name == "HostToAgvServerUrl")
+                            {
+                                Settings.HostToAgvServerUrl = keyValue.Value.ToString();
+                            }
+                            if (keyValue.Name == "deviceInfo")
+                            {
+                                Settings.deviceInfos = JsonConvert.DeserializeObject<List<deviceInfo>>(keyValue.Value.ToString());
+                            }
+                            if (keyValue.Name == "HKbaseUrl")
+                            {
+                                Settings.HKbaseUrl = keyValue.Value.ToString();
+                            }
                             if (keyValue.Name == "MESbaseUrl")
                             {
                                 Settings.MESbaseUrl = keyValue.Value.ToString();
@@ -108,22 +110,22 @@
                             {
                                 Settings.WMSbaseUrl = keyValue.Value.ToString();
                             }
+                        }
+                    }
+                }
+                //if(!Settings.FirstG)
+                //LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 瀹屾垚");
             }
+            catch (Exception ex)
+            {
+                LogHelper.Error("鍔犺浇閰嶇疆鏂囦欢澶辫触锛� + ex.Message, ex);
+            }
+            #endregion [鑷畾涔夋寚浠[20250323144605974][SettingInit]
         }
-    }
-    //if(!Settings.FirstG)
-    	//LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 瀹屾垚");
-}
-catch (Exception ex)
-{
-    LogHelper.Error("鍔犺浇閰嶇疆鏂囦欢澶辫触锛� + ex.Message, ex);
-}
-		#endregion [鑷畾涔夋寚浠[20250323144605974][SettingInit]
-}
-public void OperateHKTaskStatus(System.Object param1)
-{
-		#region    [鑷畾涔夋寚浠[20250324165239206][OperateHKTaskStatus]
-HaiKangOrderInfo model = (HaiKangOrderInfo)param1;
+        public void OperateHKTaskStatus(System.Object param1)
+        {
+            #region    [鑷畾涔夋寚浠[20250324165239206][OperateHKTaskStatus]
+            HaiKangOrderInfo model = (HaiKangOrderInfo)param1;
             if (string.IsNullOrEmpty(model.taskCode))
                 return;
             // 鏌ヨ浠诲姟锛氭牴鎹换鍔″彿
@@ -140,6 +142,7 @@
 
                     List<string> cntrs = wcsTask.S_CNTRS.Split(',').ToList();
                     bool bobe = false;
+                    //model.method = model.method?.ToLower();
                     switch (model.method)
                     {
                         case "start":
@@ -152,7 +155,9 @@
                                 bobe = true;
                             }
                             break;
+                        case "outBin":
                         case "outbin":
+                            model.method = model.method?.ToLower();
                             LogHelper.Info($"娴峰悍杞︿换鍔$姸鎬佸彉鏇翠负鍙栬揣瀹屾垚锛屼换鍔″彿涓猴細{model.taskCode}", "agv鏉弶浜や簰鏃ュ織");
                             wcsTask.S_B_STATE = "鍙栬揣瀹屾垚";
 
@@ -173,16 +178,21 @@
                                 {
                                     if (device.deviceName.Contains("缁村笇灏旀姄鑷�))
                                     {  //鍗歌揣杩涜娓呯┖锛岃Е鍙戞壂鐮�-                                       var inde = device.location.ToList().FindIndex(x => x == wcsTask.S_START_LOC) == 0;
-                                       string V = inde ? "R05" : "R06";
-                                       Conn.榛樿Redis.SetValue(device.deviceName + "." + V, "true", device.deviceName + "Queue");
-                                       TcpServer.TrayIps.Remove(device.deviceNo[inde ? 0 : 1]);
+                                        var inde = device.location.ToList().FindIndex(x => x == wcsTask.S_START_LOC) == 0;
+                                        string V = inde ? "R05" : "R06";
+                                        Conn.榛樿Redis.SetValue(device.deviceName + "." + V, "true", device.deviceName + "Queue", false);
+
+                                        TcpServer.TrayIps.Remove(device.deviceNo[inde ? 0 : 1]);
                                     }
                                 }
-                                else if(device.deviceType == 2){
-									var inde = device.location.ToList().FindIndex(x => x == wcsTask.S_START_LOC) == 0;
-									 string V = inde? "D1224" : "D1225";
-									 Conn.榛樿Redis.SetValue(device.deviceName + "." + V, "0", device.deviceName + "Queue");
+                                else if (device.deviceType == 2)
+                                {
+                                    //Task.Run(() =>
+                                    //{
+                                    //    var inde = device.location.ToList().FindIndex(x => x == wcsTask.S_START_LOC) == 0;
+                                    //    string V = inde ? "D1224" : "D1225";
+                                    //    Conn.榛樿Redis.SetValue(device.deviceName + "." + V, "0", device.deviceName + "Queue");
+                                    //});
                                 }
                             }
                             //LocationHelper.UnLockLoc(wcsTask.S_START_LOC);
@@ -215,7 +225,7 @@
                             endLoc.N_CURRENT_NUM = 1;
                             endLoc.T_MODIFY = DateTime.Now;
                             MainMissionService.Update(wcsTask);
-                            if(Settings.deviceInfos.Find(x=>x.deviceType==2 && (/*x.location.Contains(wcsTask.S_END_LOC)||*/x.deviceNo.Contains(wcsTask.S_END_LOC)))!=null)
+                            if (Settings.deviceInfos.Find(x => x.deviceType == 2 && (/*x.location.Contains(wcsTask.S_END_LOC)||*/x.deviceNo.Contains(wcsTask.S_END_LOC))) != null)
                                 locrep.Update(endLoc);
                             //locContainerRepository2.Insert(llls);
 
@@ -233,16 +243,22 @@
                                         //string V = inde ? "R05" : "R06";
                                         //Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "true", device2.deviceName + "Queue");
                                         string V2 = inde ? "R10_LAST" : "R11_LAST";
-                                        Conn.榛樿Redis.SetValue(device2.deviceName + "." + V2, "true", device2.deviceName + "Queue");
+                                        //Conn.榛樿Redis.SetValue(device2.deviceName + "." + V2, "true", device2.deviceName + "Queue");
+
+                                        GZ.Modular.Redis.RedisHelper.Add(device2.deviceName + "." + V2, "true", out string msg1);
                                         TcpServer.TrayIps.Remove(device2.deviceNo[inde ? 0 : 1]);
                                     }
                                 }
                                 else if (device2.deviceType == 2)
+                                {
                                     if (device2.deviceName.Contains("Js鎹烽『"))
                                     {
-                                        var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0;
-                                        string V = inde? "D1224" : "D1225";
-                                        Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "1", device2.deviceName + "Queue");
+                                        Task.Run(() =>
+                                        {
+                                            var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0;
+                                            string V = inde ? "D1224" : "D1225";
+                                            Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "1", device2.deviceName + "Queue");
+                                        });
 
                                         var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/202", JsonConvert.SerializeObject(new
                                         {
@@ -259,6 +275,19 @@
                                         //    else tag.Js2.D1225 = 1;
                                         //}
                                     }
+                                    var ssloc = device2.deviceNo[1];
+                                    var endloc = locrep.FindEntity(x => x.S_LOC_CODE == ssloc);
+                                    LogHelper.Info($"鎹烽『鍗歌揣鍚庯紝 鏌ョ湅缂撳瓨浣�{ssloc}-{endloc?.N_CURRENT_NUM}>0? 鍒欑敵璇穖es鎼蛋銆�);
+                                    if (endloc != null && endloc.N_CURRENT_NUM == 1)
+                                    {
+                                        var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/200", JsonConvert.SerializeObject(new
+                                        {
+                                            requestType = 3,
+                                            startBit = ssloc
+                                        }));
+                                        LogHelper.Info($"{ssloc}鐢宠mes浠诲姟缁撴灉{str}");
+                                    }
+                                }
                             }
 
                             //LocationMethod.JudgeLocation(wcsTask);
@@ -273,13 +302,14 @@
                             var tare = taskActRepository.FindList(x => x.S_TASK_NO == wcsTask.S_TASK_NO);
                             if (tare.Any())
                             {
-                                if(tare.Find(x=>x.S_ACTION_CODE=="outbin")==null)
+                                if (tare.Find(x => x.S_ACTION_CODE == "outbin") == null)
                                 {
                                     startloc.S_LOCK_STATE = "鏃�;
                                     endLoc.S_LOCK_STATE = "鏃�;
                                     locrep.Update(startloc);
                                     locrep.Update(endLoc);
-                                }else if (tare.Find(x => x.S_ACTION_CODE == "end") == null)
+                                }
+                                else if (tare.Find(x => x.S_ACTION_CODE == "end") == null)
                                 {
                                     endLoc.S_LOCK_STATE = "鏃�;
                                     locrep.Update(endLoc);
@@ -300,16 +330,16 @@
                     if (!string.IsNullOrEmpty(wcsTask.S_SRC_NO))
                     {
                         var mestask = MainMissionService.FindEntity(x => x.S_TASK_NO == wcsTask.S_SRC_NO);
-                        if (mestask!=null&&bobe)
+                        if (mestask != null && bobe)
                         {
-                            if ( model.method != "end")
+                            if (model.method != "end")
                             {
-                            	if (mestask.S_START_LOC == wcsTask.S_START_LOC&&mestask.S_B_STATE == "MES")
-	                                Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
-	                                {
-	                                    reqCode = wcsTask.S_SRC_NO,
-	                                    model.method
-	                                }));
+                                if (mestask.S_START_LOC == wcsTask.S_START_LOC && mestask.S_B_STATE == "MES")
+                                    Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
+                                    {
+                                        reqCode = wcsTask.S_SRC_NO,
+                                        model.method
+                                    }));
                             }
                             else
                             {
@@ -319,7 +349,7 @@
                                     mestask.N_PRIORITY = -88;
                                     MainMissionService.Update(mestask);
                                 }
-                                else if(mestask.S_B_STATE == "MES")
+                                else if (mestask.S_B_STATE == "MES")
                                 {
                                     var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
                                     {
@@ -329,21 +359,22 @@
                                 }
                             }
 
-                        }else if(mestask!=null && model.method== "cancel")
+                        }
+                        else if (mestask != null && model.method == "cancel")
                         {
-                        	 if(mestask.S_B_STATE == "MES")
-	                           Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
-	                            {
-	                                reqCode = wcsTask.S_SRC_NO,
-	                                model.method
-	                            })); 
+                            if (mestask.S_B_STATE == "MES")
+                                Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
+                                {
+                                    reqCode = wcsTask.S_SRC_NO,
+                                    model.method
+                                }));
                             LogHelper.Info($"{wcsTask.S_SRC_NO}-{wcsTask.S_TASK_NO} 涓�樁娈靛彇娑堬紝閲嶇疆鐐癸紝绾跨▼澶勭悊銆�);
                             mestask.N_PRIORITY = -1;
                             mestask.S_B_STATE = "MES_鍙栨秷";
                             MainMissionService.Update(mestask);
                         }
                     }
-                    TaskProcess.AddActionRecord(model.taskCode, model.method, model.eqpCode, model.data,wcsTask.S_START_LOC,wcsTask.S_END_LOC);
+                    TaskProcess.AddActionRecord(model.taskCode, model.method, model.eqpCode, model.data, wcsTask.S_START_LOC, wcsTask.S_END_LOC);
                     //璋冪敤绗笁鏂规帴鍙o紙濡傛灉鏈夛級TaskProcess.ReportStatus
                 }
                 else
@@ -356,97 +387,99 @@
             }
             else
             {
-                LogHelper.Info($"褰撳墠浠诲姟鍙蜂换鍔′笉瀛樺湪{model.taskCode}", "agv鏉弶浜や簰鏃ュ織");
+                LogHelper.Info($"褰撳墠浠诲姟鍙蜂换鍔′笉瀛樺湪{model.taskCode} agv鏉弶浜や簰鏃ュ織");
             }
-		#endregion [鑷畾涔夋寚浠[20250324165239206][OperateHKTaskStatus]
-}
-public GZ.DB.Entity.OIDATABASE.TaskEntity Begin(GZ.DB.Entity.OIDATABASE.TaskEntity task)
-{
-		#region    [鑷畾涔夋寚浠[20250324170811305][Begin]
- if (task.S_B_STATE.Trim() == "宸叉帹閫�) {
-     task.S_B_STATE = "鎵ц涓�;
-     task.T_START_TIME = DateTime.Now;
- }
- return task;
-		#endregion [鑷畾涔夋寚浠[20250324170811305][Begin]
-}
-public GZ.DB.Entity.OIDATABASE.TaskEntity End(GZ.DB.Entity.OIDATABASE.TaskEntity task)
-{
-		#region    [鑷畾涔夋寚浠[20250324170922920][End]
- if (task != null) {
-     task.S_B_STATE = "瀹屾垚";
-     task.T_END_TIME = DateTime.Now;
- }
- return task;
-		#endregion [鑷畾涔夋寚浠[20250324170922920][End]
-}
-public GZ.DB.Entity.OIDATABASE.TaskEntity UpdateStatus(GZ.DB.Entity.OIDATABASE.TaskEntity task, System.String status)
-{
-		#region    [鑷畾涔夋寚浠[20250324171118766][UpdateStatus]
-task.S_B_STATE = status;
-return task;
-		#endregion [鑷畾涔夋寚浠[20250324171118766][UpdateStatus]
-}
-public void RunafterMac(System.Object dev, System.Boolean blen)
-{
-		#region    [鑷畾涔夋寚浠[20250325085905222][RunafterMac]
-var device = (deviceInfo)dev;
-if (device.areaPriy.Any() && device.deviceNo.Any())
-{
-    LocRepository locRepository = new LocRepository();
-    LocContainerRepository locContainerRepository = new LocContainerRepository();
-    ContainerRepository containerRepository = new ContainerRepository();
-    LocEntity startLoc = null;
-    string Sign = device.deviceType == 1 ? "F" : "E";
-    foreach (var sloc in device.deviceNo)
-    {
-        ContainerEntity c = null;
-        var Startloc = locRepository.FindEntity(x => x.S_LOC_CODE == sloc);
-        if (Startloc != null && Startloc.N_CURRENT_NUM == 1 && Startloc.S_LOCK_STATE == "鏃�)
-        {
-            var cntr = locContainerRepository.FindEntity(x => x.S_LOC_CODE == sloc);
-            if (cntr != null)
-            {
-                c = containerRepository.FindEntity(x => x.S_CODE == cntr.S_CNTR_CODE);
-                if (c != null && c.S_TYPE == Sign)
-                {
-                    startLoc = Startloc;
-                }
-            }
+            #endregion [鑷畾涔夋寚浠[20250324165239206][OperateHKTaskStatus]
         }
-
-        if (startLoc != null)
+        public GZ.DB.Entity.OIDATABASE.TaskEntity Begin(GZ.DB.Entity.OIDATABASE.TaskEntity task)
         {
-            foreach (var dn in device.areaPriy)
+            #region    [鑷畾涔夋寚浠[20250324170811305][Begin]
+            if (task.S_B_STATE.Trim() == "宸叉帹閫�)
             {
-                LocEntity endLoc = null;
-                var di = Settings.deviceInfos.Find(x => x.deviceName == dn);
-                if (di != null)
+                task.S_B_STATE = "鎵ц涓�;
+                task.T_START_TIME = DateTime.Now;
+            }
+            return task;
+            #endregion [鑷畾涔夋寚浠[20250324170811305][Begin]
+        }
+        public GZ.DB.Entity.OIDATABASE.TaskEntity End(GZ.DB.Entity.OIDATABASE.TaskEntity task)
+        {
+            #region    [鑷畾涔夋寚浠[20250324170922920][End]
+            if (task != null)
+            {
+                task.S_B_STATE = "瀹屾垚";
+                task.T_END_TIME = DateTime.Now;
+            }
+            return task;
+            #endregion [鑷畾涔夋寚浠[20250324170922920][End]
+        }
+        public GZ.DB.Entity.OIDATABASE.TaskEntity UpdateStatus(GZ.DB.Entity.OIDATABASE.TaskEntity task, System.String status)
+        {
+            #region    [鑷畾涔夋寚浠[20250324171118766][UpdateStatus]
+            task.S_B_STATE = status;
+            return task;
+            #endregion [鑷畾涔夋寚浠[20250324171118766][UpdateStatus]
+        }
+        public void RunafterMac(System.Object dev, System.Boolean blen)
+        {
+            #region    [鑷畾涔夋寚浠[20250325085905222][RunafterMac]
+            var device = (deviceInfo)dev;
+            if (device.areaPriy.Any() && device.deviceNo.Any())
+            {
+                LocRepository locRepository = new LocRepository();
+                LocContainerRepository locContainerRepository = new LocContainerRepository();
+                ContainerRepository containerRepository = new ContainerRepository();
+                LocEntity startLoc = null;
+                string Sign = device.deviceType == 1 ? "F" : "E";
+                foreach (var sloc in device.deviceNo)
                 {
-                    foreach (var ssloc in di.deviceNo)
+                    ContainerEntity c = null;
+                    var Startloc = locRepository.FindEntity(x => x.S_LOC_CODE == sloc);
+                    if (Startloc != null && Startloc.N_CURRENT_NUM == 1 && Startloc.S_LOCK_STATE == "鏃�)
                     {
-                        var endloc = locRepository.FindEntity(x => x.S_LOC_CODE == ssloc);
-                        if (endloc != null && endloc.N_CURRENT_NUM == 0 && endloc.S_LOCK_STATE == "鏃�)
+                        var cntr = locContainerRepository.FindEntity(x => x.S_LOC_CODE == sloc);
+                        if (cntr != null)
                         {
-                            endLoc = endloc;
-                            break;
+                            c = containerRepository.FindEntity(x => x.S_CODE == cntr.S_CNTR_CODE);
+                            if (c != null && c.S_TYPE == Sign)
+                            {
+                                startLoc = Startloc;
+                            }
                         }
                     }
-                    if (endLoc != null)
+
+                    if (startLoc != null)
                     {
-                        TaskProcess.CreateTask("", startLoc.S_LOC_CODE, endLoc.S_LOC_CODE, $"鎵樼洏娴佽浆-{Sign}", 5, new List<string> { c.S_CODE });
-                        break;
+                        foreach (var dn in device.areaPriy)
+                        {
+                            LocEntity endLoc = null;
+                            var di = Settings.deviceInfos.Find(x => x.deviceName == dn);
+                            if (di != null)
+                            {
+                                foreach (var ssloc in di.deviceNo)
+                                {
+                                    var endloc = locRepository.FindEntity(x => x.S_LOC_CODE == ssloc);
+                                    if (endloc != null && endloc.N_CURRENT_NUM == 0 && endloc.S_LOCK_STATE == "鏃�)
+                                    {
+                                        endLoc = endloc;
+                                        break;
+                                    }
+                                }
+                                if (endLoc != null)
+                                {
+                                    TaskProcess.CreateTask("", startLoc.S_LOC_CODE, endLoc.S_LOC_CODE, $"鎵樼洏娴佽浆-{Sign}", 5, new List<string> { c.S_CODE });
+                                    break;
+                                }
+                            }
+                        }
                     }
                 }
             }
+            #endregion [鑷畾涔夋寚浠[20250325085905222][RunafterMac]
         }
-    }
-}
-		#endregion [鑷畾涔夋寚浠[20250325085905222][RunafterMac]
-}
-public System.Boolean RunTask(GZ.DB.Entity.OIDATABASE.TaskEntity task)
-{
-		#region    [鑷畾涔夋寚浠[20250325092323531][RunTask]
+        public System.Boolean RunTask(GZ.DB.Entity.OIDATABASE.TaskEntity task)
+        {
+            #region    [鑷畾涔夋寚浠[20250325092323531][RunTask]
 
             ILocRepository locrep = new LocRepository();
             var startloc = locrep.FindEntity(x => x.S_LOC_CODE == task.S_START_LOC);
@@ -476,8 +509,8 @@
             //璋冪涓夋柟鎺ュ彛
             var model = new HaiKangOrderInfo
             {
-                reqCode=task.S_TASK_NO.Trim(),
-                reqTime=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                reqCode = task.S_TASK_NO.Trim(),
+                reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                 taskCode = task.S_TASK_NO.Trim(),
                 ctnrCode = task.S_CNTRS,
                 taskTyp = task.S_INDEX,
@@ -485,199 +518,207 @@
             };
 
             return CreateOrder(model);
-		#endregion [鑷畾涔夋寚浠[20250325092323531][RunTask]
-}
-public System.Boolean CreateOrder(System.Object m)
-{
-		#region    [鑷畾涔夋寚浠[20250325095053549][CreateOrder]
-var model = (HaiKangOrderInfo)m;
+            #endregion [鑷畾涔夋寚浠[20250325092323531][RunTask]
+        }
+        public System.Boolean CreateOrder(System.Object m)
+        {
+            #region    [鑷畾涔夋寚浠[20250325095053549][CreateOrder]
+            var model = (HaiKangOrderInfo)m;
             var msg = "";
             var result = false;
             var request = JsonConvert.SerializeObject(model);
             var response = Settings.apiHelper.Post(Settings.HKbaseUrl + "rcms/services/rest/hikRpcService/genAgvSchedulingTask", request);
             msg = $"[haikang-CreateOrder] request={request} response={response}";
-            
+
             LogHelper.Info(msg);
-            if (response != "") {
-                try {
+            if (response != "")
+            {
+                try
+                {
                     var dataResult = JsonConvert.DeserializeObject<HKResult>(response);
-                    if (dataResult.code == "0") {
+                    if (dataResult.code == "0")
+                    {
                         result = true;
                     }
                 }
-                catch (Exception ex) {
+                catch (Exception ex)
+                {
                     Console.WriteLine(ex.Message);
-                    LogHelper.Info(msg,"娴峰悍");
+                    LogHelper.Info(msg, "娴峰悍");
                 }
             }
-            else {
+            else
+            {
                 msg = "[haikang-CreateOrder]鍒涘缓璁㈠崟澶辫触";
                 Console.WriteLine(msg);
             }
 
-            LogHelper.Info(msg,"娴峰悍");
+            LogHelper.Info(msg, "娴峰悍");
             return result;
-		#endregion [鑷畾涔夋寚浠[20250325095053549][CreateOrder]
-}
-public void TaskisOk(GZ.DB.Entity.OIDATABASE.TaskEntity task)
-{
-		#region    [鑷畾涔夋寚浠[20250325100336909][TaskisOk]
-// 杞﹁締鍙栨斁鐢宠銆�- if ("鍙栬揣鐢宠" != "")
- {
-     var device1 = Settings.deviceInfos.Find(x => x.location.Contains(task.S_START_LOC));
-     if (device1 != null)
-     {
-         var left = device1.location.ToList().FindIndex(x => x == task.S_START_LOC) == 0;
-         if (device1.deviceType == 1)
-         {
-             if (device1.deviceName.Contains("缁村笇灏旀姄鑷�))
-             {
-                 if ("IN_BEFORE" == "IN_BEFORE"|| "out_BEFORE" == "out_BEFORE")
-                 {
-                     string V = left ? "R01" : "R03";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("IN_after" == "IN_after"|| "out_after" == "out_after")
-                 {
-                     string V = left ? "R02" : "R04";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-             }
-             else if(device1.deviceName.Contains("Js鎹烽『"))
-             {
-                 if ("IN_BEFORE" == "IN_BEFORE")
-                 {
-                     string V = left ? "M0" : "M1";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("out_BEFORE" == "out_BEFORE")
-                 {
-                     //string V = left ? "R01" : "R03";
-                     //Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("IN_after" == "IN_after")
-                 {
-                     string V = left ? "M2" : "M3";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("out_after" == "out_after")
-                 {
-                     string V = left ? "M6" : "M7";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-             }
-         }
-     }
- }
- if ("鏀捐揣鐢宠" != "")
- {
-     var device1 = Settings.deviceInfos.Find(x => x.location.Contains(task.S_END_LOC));
-     if (device1 != null)
-     {
-         var left = device1.location.ToList().FindIndex(x => x == task.S_END_LOC) == 0;
-         if (device1.deviceType == 1)
-         {
-             if (device1.deviceName.Contains("缁村笇灏旀姄鑷�))
-             {
-                 if ("IN_BEFORE" == "IN_BEFORE" || "out_BEFORE" == "out_BEFORE")
-                 {
-                     string V = left ? "R01" : "R03";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("IN_after" == "IN_after" || "out_after" == "out_after")
-                 {
-                     string V = left ? "R02" : "R04";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-             }
-             else if (device1.deviceName.Contains("Js鎹烽『"))
-             {
-                 if ("IN_BEFORE" == "IN_BEFORE")
-                 {
-                     string V = left ? "M0" : "M1";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("out_BEFORE" == "out_BEFORE")
-                 {
-                     string V = left ? "M4" : "M5";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("IN_after" == "IN_after")
-                 {
-                     string V = left ? "M2" : "M3";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-                 if ("out_after" == "out_after")
-                 {
-                     string V = left ? "M6" : "M7";
-                     Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
-                 }
-             }
-         }
-     }
- }
-		#endregion [鑷畾涔夋寚浠[20250325100336909][TaskisOk]
-}
-public System.Boolean continueTask(System.Object m)
-{
-		#region    [鑷畾涔夋寚浠[20250325100607380][continueTask]
-var model = (HaiKangOrderInfo)m;
-bool result = false;
-string msg = "";
-var request = JsonConvert.SerializeObject(model);
-var response = Settings.apiHelper.Post(Settings.HKbaseUrl + "rcms/services/rest/hikRpcService/continueTask", request);
-msg = $"[haikang-CancelOrder] request={request};response={response}";
-Console.WriteLine(msg);
-if (response != "")
-{
-    var dataResult = JsonConvert.DeserializeObject<HKResult>(response);
-    if (dataResult.code == "0")
-    {
-        result = true;
+            #endregion [鑷畾涔夋寚浠[20250325095053549][CreateOrder]
+        }
+        public void TaskisOk(GZ.DB.Entity.OIDATABASE.TaskEntity task)
+        {
+            #region    [鑷畾涔夋寚浠[20250325100336909][TaskisOk]
+            // 杞﹁締鍙栨斁鐢宠銆�+            if ("鍙栬揣鐢宠" != "")
+            {
+                var device1 = Settings.deviceInfos.Find(x => x.location.Contains(task.S_START_LOC));
+                if (device1 != null)
+                {
+                    var left = device1.location.ToList().FindIndex(x => x == task.S_START_LOC) == 0;
+                    if (device1.deviceType == 1)
+                    {
+                        if (device1.deviceName.Contains("缁村笇灏旀姄鑷�))
+                        {
+                            if ("IN_BEFORE" == "IN_BEFORE" || "out_BEFORE" == "out_BEFORE")
+                            {
+                                string V = left ? "R01" : "R03";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("IN_after" == "IN_after" || "out_after" == "out_after")
+                            {
+                                string V = left ? "R02" : "R04";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                        }
+                        else if (device1.deviceName.Contains("Js鎹烽『"))
+                        {
+                            if ("IN_BEFORE" == "IN_BEFORE")
+                            {
+                                string V = left ? "M0" : "M1";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("out_BEFORE" == "out_BEFORE")
+                            {
+                                //string V = left ? "R01" : "R03";
+                                //Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("IN_after" == "IN_after")
+                            {
+                                string V = left ? "M2" : "M3";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("out_after" == "out_after")
+                            {
+                                string V = left ? "M6" : "M7";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                        }
+                    }
+                }
+            }
+            if ("鏀捐揣鐢宠" != "")
+            {
+                var device1 = Settings.deviceInfos.Find(x => x.location.Contains(task.S_END_LOC));
+                if (device1 != null)
+                {
+                    var left = device1.location.ToList().FindIndex(x => x == task.S_END_LOC) == 0;
+                    if (device1.deviceType == 1)
+                    {
+                        if (device1.deviceName.Contains("缁村笇灏旀姄鑷�))
+                        {
+                            if ("IN_BEFORE" == "IN_BEFORE" || "out_BEFORE" == "out_BEFORE")
+                            {
+                                string V = left ? "R01" : "R03";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("IN_after" == "IN_after" || "out_after" == "out_after")
+                            {
+                                string V = left ? "R02" : "R04";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                        }
+                        else if (device1.deviceName.Contains("Js鎹烽『"))
+                        {
+                            if ("IN_BEFORE" == "IN_BEFORE")
+                            {
+                                string V = left ? "M0" : "M1";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("out_BEFORE" == "out_BEFORE")
+                            {
+                                string V = left ? "M4" : "M5";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("IN_after" == "IN_after")
+                            {
+                                string V = left ? "M2" : "M3";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                            if ("out_after" == "out_after")
+                            {
+                                string V = left ? "M6" : "M7";
+                                Conn.榛樿Redis.SetValue(device1.deviceName + "." + V, "true", device1.deviceName + "Queue");
+                            }
+                        }
+                    }
+                }
+            }
+            #endregion [鑷畾涔夋寚浠[20250325100336909][TaskisOk]
+        }
+        public System.Boolean continueTask(System.Object m)
+        {
+            #region    [鑷畾涔夋寚浠[20250325100607380][continueTask]
+            var model = (HaiKangOrderInfo)m;
+            bool result = false;
+            string msg = "";
+            var request = JsonConvert.SerializeObject(model);
+            var response = Settings.apiHelper.Post(Settings.HKbaseUrl + "rcms/services/rest/hikRpcService/continueTask", request);
+            msg = $"[haikang-CancelOrder] request={request};response={response}";
+            Console.WriteLine(msg);
+            if (response != "")
+            {
+                var dataResult = JsonConvert.DeserializeObject<HKResult>(response);
+                if (dataResult.code == "0")
+                {
+                    result = true;
+                }
+            }
+            else
+            {
+                msg = "[haikang-CancelOrder]鑾峰彇浠诲姟鐘舵�澶辫触";
+                Console.WriteLine(msg);
+            }
+            LogHelper.Info(msg, "娴峰悍");
+            return result;
+            #endregion [鑷畾涔夋寚浠[20250325100607380][continueTask]
+        }
+        public System.Boolean CancelOrder(System.Object m)
+        {
+            #region    [鑷畾涔夋寚浠[20250325100705351][CancelOrder]
+            var model = (HaiKangOrderInfo)m;
+            bool result = false;
+            string msg = "";
+            var request = JsonConvert.SerializeObject(model);
+            var response = Settings.apiHelper.Post(Settings.HKbaseUrl + "rcms/services/rest/hikRpcService/continueTask", request);
+            msg = $"[haikang-CancelOrder] request={request};response={response}";
+            Console.WriteLine(msg);
+            if (response != "")
+            {
+                var dataResult = JsonConvert.DeserializeObject<HKResult>(response);
+                if (dataResult.code == "0")
+                {
+                    result = true;
+                }
+            }
+            else
+            {
+                msg = "[haikang-CancelOrder]鍙栨秷璁㈠崟澶辫触";
+                Console.WriteLine(msg);
+            }
+            LogHelper.Info(msg, "娴峰悍");
+            return result;
+            #endregion [鑷畾涔夋寚浠[20250325100705351][CancelOrder]
+        }
+        public System.String GetSerialNumber(System.String snType, System.String prefix)
+        {
+            #region    [鑷畾涔夋寚浠[20250325131530407][GetSerialNumber]
+            int result = 0;
+            return "";
+            #endregion [鑷畾涔夋寚浠[20250325131530407][GetSerialNumber]
+        }
+        #endregion
     }
 }
-else
-{
-    msg = "[haikang-CancelOrder]鑾峰彇浠诲姟鐘舵�澶辫触";
-    Console.WriteLine(msg);
-}
-LogHelper.Info(msg, "娴峰悍");
-return result;
-		#endregion [鑷畾涔夋寚浠[20250325100607380][continueTask]
-}
-public System.Boolean CancelOrder(System.Object m)
-{
-		#region    [鑷畾涔夋寚浠[20250325100705351][CancelOrder]
-var model = (HaiKangOrderInfo)m;
-bool result = false;
-string msg = "";
-var request = JsonConvert.SerializeObject(model);
-var response = Settings.apiHelper.Post(Settings.HKbaseUrl + "rcms/services/rest/hikRpcService/continueTask", request);
-msg = $"[haikang-CancelOrder] request={request};response={response}";
-Console.WriteLine(msg);
-if (response != "") {
-    var dataResult = JsonConvert.DeserializeObject<HKResult>(response);
-    if (dataResult.code == "0") {
-        result = true;
-    }
-}
-else {
-    msg = "[haikang-CancelOrder]鍙栨秷璁㈠崟澶辫触";
-    Console.WriteLine(msg);
-}
-LogHelper.Info(msg, "娴峰悍");
-return result;
-		#endregion [鑷畾涔夋寚浠[20250325100705351][CancelOrder]
-}
-public System.String GetSerialNumber(System.String snType, System.String prefix)
-{
-		#region    [鑷畾涔夋寚浠[20250325131530407][GetSerialNumber]
-int result = 0;
-return "";
-		#endregion [鑷畾涔夋寚浠[20250325131530407][GetSerialNumber]
-}
-		#endregion
-	}
-}
-    
+

--
Gitblit v1.9.1