From de7dbe7cf85aa01abb64040aae1c04dfba74c135 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周二, 01 4月 2025 10:48:50 +0800
Subject: [PATCH] 优化 和plc交互问题

---
 CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Inbound/2、DataProcess_BZ39_IssueInboundTask.cs |   63 +++++++++++++++++++++++--------
 1 files changed, 46 insertions(+), 17 deletions(-)

diff --git "a/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Inbound/2\343\200\201DataProcess_BZ39_IssueInboundTask.cs" "b/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Inbound/2\343\200\201DataProcess_BZ39_IssueInboundTask.cs"
index 23f784a..2a85f91 100644
--- "a/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Inbound/2\343\200\201DataProcess_BZ39_IssueInboundTask.cs"
+++ "b/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Inbound/2\343\200\201DataProcess_BZ39_IssueInboundTask.cs"
@@ -67,28 +67,57 @@
 
 
 
-                            //杩欓噷涓嬪彂 鍏ュ簱搴撲换鍔�
-                            using (StationServiceClient client = new StationServiceClient())
-                            {
+                            ////杩欓噷涓嬪彂 鍏ュ簱搴撲换鍔�
+                            //using (StationServiceClient client = new StationServiceClient())
+                            //{
 
-                                var res = await client.WriteInStoreTaskInfoAsync((int)EDevice.Station, rgvLocation, doTask.PlaceCode,
-                                   (short)doTask.Length,
-                                   (short)doTask.Width, (short)doTask.Thk, Convert.ToInt32(doTask.TaskNo));
-                                if (!res.result)
-                                {
-                                    SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 澶辫触,WriteInStoreTaskInfoAsync 杩斿洖:{res.resMsg}";
-                                    continue;
-                                }
-                                else
-                                {
-                                    Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 鎴愬姛,WriteInStoreTaskInfoAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
-                                }
-                            }
+                            //    var res = await client.WriteInStoreTaskInfoAsync((int)EDevice.Station, rgvLocation, doTask.PlaceCode,
+                            //       (short)doTask.Length,
+                            //       (short)doTask.Width, (short)doTask.Thk, Convert.ToInt32(doTask.TaskNo));
+                            //    if (!res.result)
+                            //    {
+                            //        SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 澶辫触,WriteInStoreTaskInfoAsync 杩斿洖:{res.resMsg}";
+                            //        Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-涓嬪彂PLC鍏ュ簱浠诲姟澶辫触 ,WriteInStoreTaskInfoAsync锛岃繑鍥�:{res.resMsg},鍙傛暟: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo}", null);
+                            //        continue;
+                            //    }
+                            //    else
+                            //    {
+                            //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂PLC鍏ュ簱浠诲姟 鎴愬姛,WriteInStoreTaskInfoAsync锛屽弬鏁�: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo}");
+                            //    }
+                            //}
 
                             doTask.TaskStatus = (int)TaskStatusEnum.宸蹭笅鍙�;
                             doTask.IssueTime = DateTime.Now;
 
-                            wmsDB.SaveChanges();
+                            int changeNum = wmsDB.SaveChanges();
+                            if (changeNum > 0)
+                            {
+                                //蹇呴』瑕佺粰PLC涓嬪彂鎴愬姛,瑙e喅鍙兘浼氱粰PLC閲嶅涓嬪彂浠诲姟鐨勬儏鍐�
+                                var isRight = true;
+                                while (isRight)
+                                {
+                                    //杩欓噷涓嬪彂 鍏ュ簱搴撲换鍔�
+                                    using (StationServiceClient client = new StationServiceClient())
+                                    {
+
+                                        var res = await client.WriteInStoreTaskInfoAsync((int)EDevice.Station, rgvLocation, doTask.PlaceCode,
+                                           (short)doTask.Length,
+                                           (short)doTask.Width, (short)doTask.Thk, Convert.ToInt32(doTask.TaskNo));
+                                        if (!res.result)
+                                        {
+                                            SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 澶辫触,WriteInStoreTaskInfoAsync 杩斿洖:{res.resMsg}";
+                                            Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-涓嬪彂PLC鍏ュ簱浠诲姟澶辫触 ,WriteInStoreTaskInfoAsync锛岃繑鍥�:{res.resMsg},鍙傛暟: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},鏉$爜:{doTask.Upi}", null);
+                                            continue;
+                                        }
+                                        else
+                                        {
+                                            Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂PLC鍏ュ簱浠诲姟 鎴愬姛,WriteInStoreTaskInfoAsync锛屽弬鏁�: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},鏉$爜:{doTask.Upi}");
+                                            isRight = false;
+                                        }
+                                    }
+                                    Thread.Sleep(1000);
+                                }
+                            }
                         }
 
                     }

--
Gitblit v1.9.3