From 4de417b106a062452f5ac86e626e7e225b753eab Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期二, 23 九月 2025 08:03:11 +0800
Subject: [PATCH] 优化问题

---
 Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
index 7975829..ce85dbb 100644
--- a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
@@ -506,7 +506,7 @@
                         BitPalletMark = "0",
                         InspectStatus = "1",
                     };
-                    Db.Insertable(stockDetailNew).ExecuteCommand();
+                    Db.Updateable(stockDetailNew).ExecuteCommand();
                 }
                 else
                 {
@@ -588,7 +588,7 @@
                     {
                         logTaskEntry.IsSuccess = 0;
                         logTaskEntry.Information = agvMsg;
-                        Db.Insertable(logTaskEntry).ExecuteCommand();
+                        Db.Updateable(logTaskEntry).ExecuteCommand();
                     }
 
                 }
@@ -596,7 +596,7 @@
                 {
                     logTaskEntry.IsSuccess = 0;
                     logTaskEntry.Information = "璐ф灦涓庤揣浣嶇粦瀹氬け璐ワ紝鍘熷洜锛�"+agvBindMsg;
-                    Db.Insertable(logTaskEntry).ExecuteCommand();
+                    Db.Updateable(logTaskEntry).ExecuteCommand();
                 }
                 
 
@@ -1125,7 +1125,7 @@
                                 //logTaskEntry.IsCancel = 0;
                                 logTaskEntry.BackDate = DateTime.Now;
                                 logTaskEntry.Status = "1";//姝e湪鎵ц
-                                Db.Insertable(logTaskEntry).ExecuteCommand();
+                                Db.Updateable(logTaskEntry).ExecuteCommand();
 
                                 //淇敼绉诲嚭鍌ㄤ綅鐘舵��
                                 locatInfo.Status = "5";//绉诲嚭涓�
@@ -1139,7 +1139,7 @@
                             {
                                 logTaskEntry.IsSuccess = 0;
                                 logTaskEntry.Information = agvMsg;
-                                Db.Insertable(logTaskEntry).ExecuteCommand();
+                                Db.Updateable(logTaskEntry).ExecuteCommand();
 
                                 throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
                             }
@@ -1148,7 +1148,7 @@
                         {
                             logTaskEntry.IsSuccess = 0;
                             logTaskEntry.Information = agvBindMsg;
-                            Db.Insertable(logTaskEntry).ExecuteCommand();
+                            Db.Updateable(logTaskEntry).ExecuteCommand();
 
                             throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
                         }
@@ -1239,7 +1239,7 @@
                             //logTaskEntry.IsCancel = 0;
                             logTaskInfoZ.BackDate = DateTime.Now;
                             logTaskInfoZ.Status = "1";//姝e湪鎵ц
-                            Db.Insertable(logTaskInfoZ).ExecuteCommand();
+                            Db.Updateable(logTaskInfoZ).ExecuteCommand();
 
                             //淇敼绉诲嚭鍌ㄤ綅鐘舵��
                             startLocatInfoZ.Status = "5";//绉诲嚭涓�
@@ -1253,7 +1253,7 @@
                         {
                             logTaskInfoZ.IsSuccess = 0;
                             logTaskInfoZ.Information = agvMsg;
-                            Db.Insertable(logTaskInfoZ).ExecuteCommand();
+                            Db.Updateable(logTaskInfoZ).ExecuteCommand();
 
                             throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿logTaskInfoZ.PalletNo}");
                         }
@@ -1262,7 +1262,7 @@
                     {
                         logTaskInfoZ.IsSuccess = 0;
                         logTaskInfoZ.Information = agvBindMsg;
-                        Db.Insertable(logTaskInfoZ).ExecuteCommand();
+                        Db.Updateable(logTaskInfoZ).ExecuteCommand();
 
                         throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿logTaskInfoZ.PalletNo}");
                     }
@@ -1371,7 +1371,7 @@
                                 //logTaskEntry.IsCancel = 0;
                                 logTaskEntry.BackDate = DateTime.Now;
                                 logTaskEntry.Status = "1";//姝e湪鎵ц
-                                Db.Insertable(logTaskEntry).ExecuteCommand();
+                                Db.Updateable(logTaskEntry).ExecuteCommand();
 
                                 //淇敼绉诲嚭鍌ㄤ綅鐘舵��
                                 locatModel.Status = "5";//绉诲嚭涓�
@@ -1385,7 +1385,7 @@
                             {
                                 logTaskEntry.IsSuccess = 0;
                                 logTaskEntry.Information = agvMsg;
-                                Db.Insertable(logTaskEntry).ExecuteCommand();
+                                Db.Updateable(logTaskEntry).ExecuteCommand();
 
                                 throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿detailInfo.PalletNo}");
                             }
@@ -1394,7 +1394,7 @@
                         {
                             logTaskEntry.IsSuccess = 0;
                             logTaskEntry.Information = agvBindMsg;
-                            Db.Insertable(logTaskEntry).ExecuteCommand();
+                            Db.Updateable(logTaskEntry).ExecuteCommand();
 
                             throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿detailInfo.PalletNo}");
                         }
@@ -1442,15 +1442,15 @@
                         if (zonghong == "M12" || zonghong == "M13")
                         {
                             //鍏堟煡鍒板悓鐗╂枡鐨勭粍
-                            string sql = $@"select Row from SysStorageLocat where LocatNo in(
+                            string sql = $@"select Row,AreaNo from SysStorageLocat where LocatNo in(
 	                                                select LocatNo from DataStockDetail where SkuNo='{skuNo}' and LotNo = '{lotNo}' and Standard='{standard}' 
                                                     and AreaNo in ('C02','C25')
-                                                ) group by Row";
+                                                ) group by Row,AreaNo";
+                            var RowList = Db.Ado.SqlQuery<TableMan>(sql).ToList();
 
-                            List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList();
                             foreach (var rowItem in RowList)
                             {
-                                endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.Row == rowItem)
+                                endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.Row == rowItem.Row && w.AreaNo == rowItem.AreaNo  && (w.WareHouseNo == "M01"||w.WareHouseNo == "M16"))
                                                .OrderByDescending(o => o.Column).First();
                                 if (endLocatInfo.LocatNo != null)
                                 {
@@ -1472,15 +1472,15 @@
                             areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "1").Select(s => s.AreaNo).First();
                             //鍒嗛厤鍌ㄤ綅
                             //鍏堟煡鍒板悓鐗╂枡鐨勭粍
-                            string sql = $@"select Row from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and Status = '0' and LocatNo in(
+                            string sql = $@"select Row,AreaNo from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and Status = '0' and LocatNo in(
 	                                                select LocatNo from DataStockDetail where SkuNo='{skuNo}' and LotNo = '{lotNo}' and Standard='{standard}' and WareHouseNo='{houseNo}' and AreaNo='{areaNo}' 
-                                                ) group by Row";
+                                                ) group by Row,AreaNo";
 
-                            List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList();
+                            var RowList = Db.Ado.SqlQuery<TableMan>(sql).ToList();
                             foreach (var rowItem in RowList)
                             {
                                 endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
-                                               && w.WareHouseNo == houseNo && w.AreaNo == areaNo && w.Row == rowItem)
+                                               && w.WareHouseNo == houseNo && w.AreaNo == areaNo && w.Row == rowItem.Row && w.AreaNo == rowItem.AreaNo && (w.WareHouseNo == "M01" || w.WareHouseNo == "M16"))
                                                .OrderByDescending(o => o.Column).First();
 
                                 if (endLocatInfo.LocatNo != null)
@@ -1508,13 +1508,13 @@
                         //鍒嗛厤鍌ㄤ綅
                         //鏂欐枟娓呮礂鏆傚瓨闂�
                         endLocatInfo = ztLocat.Where(w => w.AreaNo == "C54").FirstOrDefault();
-                        if (string.IsNullOrEmpty(endLocatInfo.LocatNo))
+                        if (endLocatInfo == null)
                         {
                             endLocatInfo = ztLocat.Where(w => w.AreaNo == "C26").FirstOrDefault();
-                            if (string.IsNullOrEmpty(endLocatInfo.LocatNo))
+                            if (endLocatInfo == null)
                             {
                                 endLocatInfo = ztLocat.Where(w => w.AreaNo == "C03").FirstOrDefault();
-                                if (string.IsNullOrEmpty(endLocatInfo.LocatNo))
+                                if (endLocatInfo == null)
                                 {
                                     throw new Exception("鏃犲彲鐢ㄨ剰妗跺簱浣�");
                                 }

--
Gitblit v1.8.0