From 84f3b1fc2e8f48bbe7749ed90362793b42e0edc4 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 11 五月 2024 16:37:51 +0800
Subject: [PATCH] 优化入库逻辑,PLC地址读写失败重新连接

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs |    5 +
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs     |    4 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/新文件夹/GetLocation.cs   |  178 +++++++++++++++++++------------------------
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs                      |   13 +-
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Pipeline.cs                    |    2 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/WCSClient/PLCClient.cs                |    2 
 6 files changed, 95 insertions(+), 109 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
index bffb2d7..ed61b2b 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
@@ -473,11 +473,11 @@
                             #endregion
 
                             var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client);
-                            //if (AreaNr == 0)
-                            //{
-                            //    client.WriteByOrder("W_Storage_update", true, name);//璐т綅鐘舵�佹洿鏂�
-                            //    continue;
-                            //}
+                            if (AreaNr == 0)
+                            {
+                                client.WriteByOrder("W_Storage_update", true, name);//璐т綅鐘舵�佹洿鏂�
+                                continue;
+                            }
 
                             #region 鍒ゆ柇鍖哄煙鍙锋槸鍚︿竴鑷�
                             var area = client.ReadByOrder<Int16>("place_prog", name);//鏀炬枡瀹屾垚鐨勫尯鍩熷彿
@@ -547,7 +547,7 @@
 
                                 var count = stationinfoRepository.Update(station, true);
                                 if (count < 1)
-                                    throw new Exception($"涓嬫枡浣嶄俊鎭洿鏂板け璐ワ紒涓嬫枡浣嶇紪鍙凤細{station.stationCode}"); 
+                                    throw new Exception($"涓嬫枡浣嶄俊鎭洿鏂板け璐ワ紒涓嬫枡浣嶇紪鍙凤細{station.stationCode}");
                                 #endregion
 
 
@@ -560,6 +560,7 @@
                                     throw new Exception($"宸ュ崟瀛愯〃淇℃伅鏇存柊澶辫触锛佽溅杞甋N鍙凤細{Detail.SN}");
                                 var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID);
                                 Head.finishNum = Head.finishNum + 1;
+                                if (Head.finishNum == Head.quantity) Head.FinishTime = DateTime.Now;
                                 count = mes_HeadRepository.Update(Head, true);
                                 if (count < 1)
                                     throw new Exception($"宸ュ崟澶磋〃淇℃伅鏇存柊澶辫触锛佸伐鍗曞彿锛歿Head.jobID}");
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Pipeline.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Pipeline.cs"
index 4da1a3d..d64c0cd 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Pipeline.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Pipeline.cs"
@@ -595,7 +595,7 @@
                 if (mes_Head != null)
                 {
                     mes_Head.finishNum = mes_Head.finishNum + 1;
-                    //freeDB.DataBase.Update<dt_mes_head>().SetSource(mes_Head).UpdateColumns(x => new { x.finishNum }).ExecuteAffrows();
+                    if (mes_Head.finishNum == mes_Head.quantity) mes_Head.FinishTime = DateTime.Now;
                     mes_HeadRepository.Update(mes_Head, true);
                 }
             }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
index dc21fdb..0829fa3 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
@@ -62,7 +62,7 @@
             Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
 
 
-            var mes_heads = mes_HeadRepository.Find(x => x.quantity == x.finishNum).ToList();
+            var mes_heads = mes_HeadRepository.Find(x => x.quantity == x.finishNum /*|| x.CreateTime.AddDays(30) < DateTime.Now*/).ToList();
 
             #region 妫�娴嬬嚎宸ュ崟
             var mes_head_jcxs = mes_heads.Where(x => x.processCode == "28").ToList();
@@ -139,7 +139,7 @@
                     quantity = mes_Head.quantity,
                     expectedStartTime = mes_Head.expectedStartTime,
                     finishNum = mes_Head.finishNum,
-                    FinishTime = DateTime.Now,
+                    FinishTime = mes_Head.FinishTime,
                     maxDiameterDiff = mes_Head.maxDiameterDiff,
                     operatetype = operatetype,
                     processCode = mes_Head.processCode,
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
index 72992aa..aac5042 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
@@ -36,135 +36,115 @@
                     if (agvtask.agv_Traytype == "LargeTray")
                         area1 = "4";
 
-                    #region 鏌ユ壘搴撳瓨
-                    dt_inventory inventory = null;
-                    inventory = inventoryRepository.Find(x => x.FigureNumber == agvtask.agv_materielid).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
+                    dt_stationinfo TargetLocation = null;
+
+                    #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
+                    TargetLocation = area1 == "4" ? stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == area1).FirstOrDefault() : stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "2" || x.area == "3")).FirstOrDefault();
+                    if (TargetLocation != null)
+                    {
+                        TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
+                        if (TargetLocation != null)
+                        {
+                            if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+                                return TargetLocation;
+                        }
+                    }
                     #endregion
 
-                    dt_stationinfo TargetLocation = null;
+                    #region 鏌ユ壘搴撳瓨
+                    dt_inventory inventory = null;
+                    inventory = area1 == "4" ? inventoryRepository.Find(x => x.FigureNumber == agvtask.agv_materielid && x.area == area1).OrderByDescending(x => x.OnlineTime).FirstOrDefault()
+                        : inventoryRepository.Find(x => x.FigureNumber == agvtask.agv_materielid && (x.area == "2" || x.area == "3")).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
+                    #endregion
+
 
                     #region 鏍规嵁搴撳瓨鏌ユ壘鍙叆搴撶┖璐т綅
                     if (inventory != null)
                     {
                         var station = stationinfoRepository.FindFirst(x => x.stationCode == inventory.stationCode);
 
-                        #region 鍏ュぇ鎵樼洏搴撳尯
-                        //if (!string.IsNullOrEmpty(area1) && station.area != area1)
-                        if (area1 == "4")
-                        {
-                            #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
-                            TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == area1).FirstOrDefault();
-                            if (TargetLocation != null)
-                            {
-                                TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
-                                if (TargetLocation != null)
-                                {
-                                    if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
-                                        return TargetLocation;
-                                }
-                            }
-                            #endregion
+                        #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
+                        //TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == station.area).FirstOrDefault();
+                        //if (TargetLocation != null)
+                        //{
+                        //    TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
+                        //    if (TargetLocation != null)
+                        //    {
+                        //        if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+                        //            return TargetLocation;
+                        //    }
+                        //}
+                        #endregion
 
-                            #region 瀵绘壘绌鸿揣浣�
-                            var TargetLocations1 = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == area1).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
-                            foreach (var Location in TargetLocations1)
-                            {
-                                if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location;
-                            }
-                            #endregion
+                        #region 鍒ゆ柇褰撳墠琛屾槸鍚﹁繕鏈夌┖璐т綅
+                        TargetLocation = stationinfoRepository.Find(x => x.line == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == station.area).OrderBy(x => x.column).FirstOrDefault();
+                        if (TargetLocation != null)
+                        {
+                            if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+                                return TargetLocation;
                         }
                         #endregion
 
-                        if (station.area == "1")
-                        {
-                            TargetLocation = stationinfoRepository.Find(x => x.line == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == station.area).OrderBy(x => x.column).FirstOrDefault();//鎸夎瀛樻斁
+                        #region 瀵绘壘绌鸿揣浣�
+                        //var TargetLocations1 = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == station.area).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
+                        //foreach (var Location in TargetLocations1)
+                        //{
+                        //    if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == agvtask.agv_materielid).Any())
+                        //        if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location;
+                        //}
+                        #endregion
 
-                            if (TargetLocation != null)
-                            {
-                                if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
-                                    return TargetLocation;
-                            }
-                        }
-                        else
-                        {
-                            TargetLocation = stationinfoRepository.Find(x => x.line == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.area).OrderBy(x => x.column).FirstOrDefault();
-                            if (TargetLocation != null)
-                            {
-                                if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
-                                    return TargetLocation;
-                            }
-                        }
                     }
                     #endregion
 
                     #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
-                    TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).FirstOrDefault();
-                    if (TargetLocation != null)
-                    {
-                        if (TargetLocation.area == "1")
-                        {
-                            TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();//鎸夎瀛樻斁
+                    //TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).FirstOrDefault();
+                    //if (TargetLocation != null)
+                    //{
+                    //    if (TargetLocation.area == "1")
+                    //    {
+                    //        TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();//鎸夎瀛樻斁
 
-                            if (TargetLocation != null)
-                            {
-                                if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
-                                    return TargetLocation;
-                            }
-                        }
-                        else
-                        {
-                            TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
-                            if (TargetLocation != null)
-                            {
-                                if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
-                                    return TargetLocation;
-                            }
-                        }
-                    }
+                    //        if (TargetLocation != null)
+                    //        {
+                    //            if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+                    //                return TargetLocation;
+                    //        }
+                    //    }
+                    //    else
+                    //    {
+                    //        TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
+                    //        if (TargetLocation != null)
+                    //        {
+                    //            if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+                    //                return TargetLocation;
+                    //        }
+                    //    }
+                    //}
                     #endregion
 
-                    #region 瀵绘壘绌鸿揣浣�
-                    var TargetLocations = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
-                    foreach (var Location in TargetLocations)
-                    {
-                        if (Location.area == "1")
-                        {
-                            if (stationinfoRepository.Find(x => x.column == Location.column && x.area == Location.area && x.stationType == agvtask.agv_materielid && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
-                        }
-                        else
-                        {
-                            if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location;
-                        }
-                    }
+                    #region 瀵绘壘瀵瑰簲搴撳尯绌鸿揣浣�
+                    //var TargetLocations = area1 == "4" ? stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "4").OrderBy(x => x.line).ThenBy(x => x.column).ToList()
+                    //    : stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && (x.area == "2" || x.area == "3")).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
+                    //foreach (var Location in TargetLocations)
+                    //{
+                    //    if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == agvtask.agv_materielid).Any())
+                    //        if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location;
+                    //}
                     #endregion
 
                     #region 鏈壘鍒板簱瀛樻垨褰撳墠搴撳瓨琛屽凡婊�,瀵绘壘鏂扮殑涓�琛�
                     var area = GetArea(mesinfo.quantity, agvtask.agv_Traytype);
-                    TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
+                    TargetLocation = stationinfoRepository.Find(x => x.column == (area == "2" ? 1 : 2) && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
                     if (TargetLocation == null && area != "4")
                     {
-                        if (area == "2")
-                            area = "3";
-                        else if (area == "3")
-                            area = "2";
-                        TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
-                        if (TargetLocation == null)
-                            TargetLocation = stationinfoRepository.Find(x => x.line == 2 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).FirstOrDefault();
+                        area = area == "2" ? "3" : "2";
+                        TargetLocation = stationinfoRepository.Find(x => x.column == (area == "2" ? 1 : 2) && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
                     }
 
                     #region 鏌ョ湅褰撳墠绌鸿揣浣嶅悗鏄惁瀛樺湪鏈夋枡
                     if (TargetLocation != null)
-                    {
-                        if (TargetLocation.area == "1")
-                        {
-                            //绗竴琛屼笉涓虹┖璐т綅鍒欎笉鑳芥斁缃浜岃
-                            if (stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area && x.location_state != LocationStateEnum.Empty.ToString() && x.line == 1).Any()) TargetLocation = null;
-                        }
-                        else
-                        {
-                            if (stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state != LocationStateEnum.Empty.ToString()).Any()) TargetLocation = null;
-                        }
-                    }
+                        if (stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state != LocationStateEnum.Empty.ToString()).Any()) TargetLocation = null;
                     #endregion
 
                     #endregion
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/PLCClient.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/PLCClient.cs"
index 1ddf692..496e55e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/PLCClient.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/PLCClient.cs"
@@ -155,6 +155,7 @@
         {
             if (!operateResult.IsSuccess)
             {
+                IsConnected = false;
                 throw new Exception($"銆怑rror銆戞暟鎹鍙栧け璐�,鎸囦护{item.name}锛孌B鍦板潃{item.dbAddress}\n閿欒淇℃伅:{operateResult.Message}");
             }
             return operateResult.Content;
@@ -171,6 +172,7 @@
         {
             if (!operateResult.IsSuccess)
             {
+                IsConnected = false;
                 throw new Exception($"銆怑rror銆戞暟鎹鍙栧け璐�,DB鍦板潃{dbAddress}\n閿欒淇℃伅:{operateResult.Message}");
             }
             return operateResult.Content;
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs"
index 23f524d..4b6f78a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs"
@@ -51,6 +51,7 @@
             siemensPLCClient.Port = Port;
             siemensPLCClient.Slot = (byte)Slot;
             siemensPLCClient.ConnectTimeOut = 1000 * 3;//瓒呮椂鏃堕棿
+            siemensPLCClient.ReceiveTimeOut = 1000 * 3;
             siemensPLCClient.ConnectClose();
             var coonRes = siemensPLCClient.ConnectServer();
             IsConnected = coonRes.IsSuccess;
@@ -192,7 +193,7 @@
             else if (typeof(DataType) == typeof(string))//瀛楃涓�
             {
                 var str = GetContent(siemensPLCClient.ReadString(item.dbAddress, (ushort)item.dataLen), item).ToString();
-                str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", "")?.Replace("\n","")?.Replace("?", "")?.Trim();
+                str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", "")?.Replace("\n", "")?.Replace("?", "")?.Trim();
                 return (DataType)(str as object);
             }
             else
@@ -256,6 +257,7 @@
 
                 if (!result.IsSuccess)
                 {
+                    IsConnected = false;
                     WriteLog.Write_Log(PLCName, $"{PLCName}_Write", $"{dbAddress}鍐欏叆澶辫触," + result.Message);
                     throw new Exception($"{dbAddress}鍐欏叆澶辫触," + result.Message);
                 }
@@ -325,6 +327,7 @@
 
                 if (!result.IsSuccess)
                 {
+                    IsConnected = false;
                     WriteLog.Write_Log(PLCName, $"{PLCName}_Write", $"{orderName}鍐欏叆澶辫触," + result.Message, item);
                     throw new Exception($"{PLCName},{orderName}鍐欏叆澶辫触," + result.Message);
                 }

--
Gitblit v1.9.3