From 59f836bf0eb00b7707c74fe8edb8fa7662c871ab Mon Sep 17 00:00:00 2001
From: lss <Lss@HanInfo>
Date: 星期二, 27 五月 2025 17:22:42 +0800
Subject: [PATCH] 合肥佳通优化

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/process/DeviceProcess.cs |   64 +++++++++++++++++++++-----------
 1 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/process/DeviceProcess.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/process/DeviceProcess.cs
index 773a7d6..e5c5e4f 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/process/DeviceProcess.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/process/DeviceProcess.cs
@@ -47,7 +47,7 @@
         /// <summary>
         /// 鍙犵洏鏈虹┖鎵樿繑鍥�         /// </summary>    
-        internal static void Traystacker(string loc, int qty, int type )
+        internal static void Traystacker(string loc, int qty, int type)
         {
             try
             {
@@ -57,7 +57,7 @@
                 HttpHelper httpHelper = new HttpHelper();
                 Result result = new Result();
                 string date = JsonConvert.SerializeObject(result1);
-                var url = Settings.tableUrls.Find(a => a.id == 2);
+                var url = Settings.tableUrls.Find(a => a.id == 3);
                 if (url != null)
                 {
                     LogHelper.Info($"鍙犵洏鏈虹┖鎵樿繑鍥烇細鍦板潃:{url.url}锛屽唴瀹癸細{date}");
@@ -75,13 +75,13 @@
                 }
                 else
                 {
-                    LogHelper.Info($"鍙犵洏鏈虹┖鎵�鏍规嵁id=2锛屾湭鎵惧埌閰嶇疆閾炬帴锛岃妫�煡閰嶇疆鏂囦欢");
+                    LogHelper.Info($"鍙犵洏鏈虹┖鎵�鏍规嵁id=3锛屾湭鎵惧埌閰嶇疆閾炬帴锛岃妫�煡閰嶇疆鏂囦欢");
                 }
 
             }
             catch (Exception ex)
             {
-                LogHelper.Error($"鍙犵洏鏈虹┖鎵樿繑鍥� Error=>{ex.ToString()}",ex);
+                LogHelper.Error($"鍙犵洏鏈虹┖鎵樿繑鍥� Error=>{ex.ToString()}", ex);
             }
         }
 
@@ -160,34 +160,54 @@
         /// </summary>
         internal static void DpjTraffic()
         {
-            string startBti = "CMB17-DP-001";
+            var devices = Settings.deviceInfos.Where(a => a.deviceType == 1).ToList();
+            //var db = new SqlHelper<object>().GetInstance();
+            //var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM > 0  && a.N_LOCK_STATE == 0).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList();
             try
             {
-                var value = S7Helper.ReadDpj(2014, S7.Net.VarType.Int);
-
-                if (value >= 7)
+                if (devices.Count > 0)
                 {
-                    //var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == item.S_CODE).ToList();
-                    //if (cntr.Count > 0)
-                    //{
-                    //    var cntrcodes = cntr.Select(a => a.S_CNTR_CODE).ToArray();
-                    //    cntrcode = string.Join(",", cntrcodes);
-                    //}
-
-                    //鍒涘缓杩囨湭瀹屾垚鐨勪换鍔′笉鍙戣捣璇锋眰
-                    var mst = WCSHelper.GetTaskByStartloc(startBti);
-                    if (mst == null)
+                    foreach (var device in devices)
                     {
-                        Traystacker(startBti, value, 2);
+                        var IsDp = S7Helper.ReadDpj(device.address,2001, S7.Net.VarType.Byte);
+                        var value = S7Helper.ReadDpj(device.address,2014, S7.Net.VarType.Int);
+
+                        if (value >= 1 && IsDp == 1)
+                        {
+                            //var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == item.S_CODE).ToList();
+                            //if (cntr.Count > 0)
+                            //{
+                            //    var cntrcodes = cntr.Select(a => a.S_CNTR_CODE).ToArray();
+                            //    cntrcode = string.Join(",", cntrcodes);
+                            //}
+
+                            //鍒涘缓杩囨湭瀹屾垚鐨勪换鍔′笉鍙戣捣璇锋眰
+                            var mst = WCSHelper.GetTaskByStartloc(device.TN_Location);
+                            if (mst == null)
+                            {
+                                Traystacker(device.TN_Location, value, 2);
+                            }
+                            else
+                            {
+                                LogHelper.Info($"鏈夋墽琛屼腑鐨勫彔鐩樺洖搴撲换鍔mst.S_CODE}锛屼笉瑙﹀彂鍙犵洏浠诲姟");
+                            }
+
+                        }
+                        else
+                        {
+                            LogHelper.Info($"鍙犵洏鏈烘暟閲忥細{value},鍙犵洏淇″彿锛歿IsDp}锛屼笉瑙﹀彂鍙犵洏浠诲姟");
+                        }
+                        Thread.Sleep(8000);
                     }
                 }
+               
             }
             catch (Exception ex)
             {
-                LogHelper.Error($"ReadDpj DpjTraffic:{ex}",ex);
-                
+                LogHelper.Error($"ReadDpj DpjTraffic:{ex}", ex);
+
             }
-         
+
         }
         /// <summary>
         /// 鍘熸潗鏂欏簱鎺ュ彛璁块棶

--
Gitblit v1.9.1