From 415d9d76d0f73f804c7ac9e51591bd15c7d84517 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期二, 16 七月 2024 15:40:26 +0800
Subject: [PATCH] 优化了一些已知问题

---
 Tiger.Business.WMS/Transaction/OutWorkOrder.cs          |   13 +-----
 Tiger.Business.MES/Transaction/CollectNode.cs           |    4 +-
 Tiger.Business.MES/Transaction/PackingNode.cs           |    4 +-
 Tiger.Business.MES/Transaction/Position.cs              |    1 
 Tiger.Business.WMS/Transaction/OutTransfer.cs           |   13 +-----
 Tiger.Business.WMS/Transaction/OutSale.cs               |   14 +-----
 Tiger.Business.MES/Transaction/TestNode.cs              |    4 +-
 Tiger.Business.WMS/Transaction/OutOther.cs              |   13 +-----
 Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs |   15 +------
 Tiger.Model.Net/Entitys/MES/MES_WIP_HIS.cs              |    2 
 Tiger.Business.MES/WorkAction/PrintLabel.cs             |    2 
 Tiger.IBusiness/MES/Transaction/IPosition.cs            |    1 
 Tiger.Model.Net/Entitys/MES/MES_WIP_DATA.cs             |    2 -
 Tiger.Business.WMS/Transaction/ItemQuery.cs             |    5 --
 14 files changed, 22 insertions(+), 71 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/CollectNode.cs b/Tiger.Business.MES/Transaction/CollectNode.cs
index 39339a5..3516926 100644
--- a/Tiger.Business.MES/Transaction/CollectNode.cs
+++ b/Tiger.Business.MES/Transaction/CollectNode.cs
@@ -204,7 +204,7 @@
                     wipSN.DFT_CODE = input.DFT_CODE;
                 }
 
-                var wipSnHis = new MES_WIP_HIS(CurWipSN = wipSN, $"宸ュ崟[{wipSN.WORK_ORDER}]鏉$爜[{wipSN.SN}]鍦ㄥ矖浣峓{wipSN.POST_CODE}]杩囩珯宸ュ簭[{wipSN.NODE_NAME}]鎴愬姛");
+                CurWipSNHis = new MES_WIP_HIS(CurWipSN = wipSN, $"宸ュ崟[{wipSN.WORK_ORDER}]鏉$爜[{wipSN.SN}]鍦ㄥ矖浣峓{wipSN.POST_CODE}]杩囩珯宸ュ簭[{wipSN.NODE_NAME}]鎴愬姛");
 
                 //鍒濆鍖栧伐姝ュ垪琛�
                 Steps.Clear();
@@ -217,7 +217,7 @@
                         var db = GetCommitDB();
                         db.Storageable(woSN, UserCode).ExecuteCommand();
                         db.Storageable(wipSN, UserCode).ExecuteCommand();
-                        db.Storageable(wipSnHis, UserCode).ExecuteCommand();
+                        db.Storageable(CurWipSNHis, UserCode).ExecuteCommand();
                     }
                 };
                 Steps.Add(curStep);
diff --git a/Tiger.Business.MES/Transaction/PackingNode.cs b/Tiger.Business.MES/Transaction/PackingNode.cs
index 67fc824..d257d53 100644
--- a/Tiger.Business.MES/Transaction/PackingNode.cs
+++ b/Tiger.Business.MES/Transaction/PackingNode.cs
@@ -204,7 +204,7 @@
                     wipSN.DFT_CODE = input.DFT_CODE;
                 }
 
-                var wipSnHis = new MES_WIP_HIS(CurWipSN = wipSN, $"宸ュ崟[{wipSN.WORK_ORDER}]鐨勬潯鐮乕{wipSN.SN}]鍦ㄥ矖浣峓{wipSN.POST_CODE}]宸ュ簭[{wipSN.NODE_NAME}]杩囩珯鎴愬姛锛岀姸鎬乕{wipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]");
+                CurWipSNHis = new MES_WIP_HIS(CurWipSN = wipSN, $"宸ュ崟[{wipSN.WORK_ORDER}]鐨勬潯鐮乕{wipSN.SN}]鍦ㄥ矖浣峓{wipSN.POST_CODE}]宸ュ簭[{wipSN.NODE_NAME}]杩囩珯鎴愬姛锛岀姸鎬乕{wipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]");
 
                 //鍒濆鍖栧伐姝ュ垪琛�
                 Steps.Clear();
@@ -216,7 +216,7 @@
                         var db = GetCommitDB();
                         db.Storageable(woSN, UserCode).ExecuteCommand();
                         db.Storageable(wipSN, UserCode).ExecuteCommand();
-                        db.Storageable(wipSnHis, UserCode).ExecuteCommand();
+                        db.Storageable(CurWipSNHis, UserCode).ExecuteCommand();
                     }
                 };
                 Steps.Add(curStep);
diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs
index 0989d3b..4d046eb 100644
--- a/Tiger.Business.MES/Transaction/Position.cs
+++ b/Tiger.Business.MES/Transaction/Position.cs
@@ -54,6 +54,7 @@
         public WorkBatch CurBatch { get; set; }
         public IWorkBatch WorkBatch => CurBatch;
         public MES_WIP_DATA CurWipSN { get; set; }
+        public MES_WIP_HIS CurWipSNHis { get; set; }
         public List<WorkStep> Steps { get; set; } = new();
         public bool IsFinishAllSteps => Steps.Any() && !Steps.Any(q => !q.IsFinished);
         public int CurStep => Steps.Where(q => !q.IsFinished).OrderBy(q => q.Sequence).FirstOrDefault()?.Sequence ?? 0;
diff --git a/Tiger.Business.MES/Transaction/TestNode.cs b/Tiger.Business.MES/Transaction/TestNode.cs
index 1f2d523..e704a65 100644
--- a/Tiger.Business.MES/Transaction/TestNode.cs
+++ b/Tiger.Business.MES/Transaction/TestNode.cs
@@ -203,7 +203,7 @@
                     wipSN.DFT_CODE = input.DFT_CODE;
                 }
 
-                var wipSnHis = new MES_WIP_HIS(CurWipSN = wipSN, $"宸ュ崟[{wipSN.WORK_ORDER}]鏉$爜[{wipSN.SN}]鍦ㄥ矖浣峓{wipSN.POST_CODE}]杩囩珯宸ュ簭[{wipSN.NODE_NAME}]鎴愬姛");
+                CurWipSNHis = new MES_WIP_HIS(CurWipSN = wipSN, $"宸ュ崟[{wipSN.WORK_ORDER}]鏉$爜[{wipSN.SN}]鍦ㄥ矖浣峓{wipSN.POST_CODE}]杩囩珯宸ュ簭[{wipSN.NODE_NAME}]鎴愬姛");
 
                 //鍒濆鍖栧伐姝ュ垪琛�
                 Steps.Clear();
@@ -216,7 +216,7 @@
                         var db = GetCommitDB();
                         db.Storageable(woSN, UserCode).ExecuteCommand();
                         db.Storageable(wipSN, UserCode).ExecuteCommand();
-                        db.Storageable(wipSnHis, UserCode).ExecuteCommand();
+                        db.Storageable(CurWipSNHis, UserCode).ExecuteCommand();
                     }
                 };
                 Steps.Add(curStep);
diff --git a/Tiger.Business.MES/WorkAction/PrintLabel.cs b/Tiger.Business.MES/WorkAction/PrintLabel.cs
index fe2d3ea..95e4ed6 100644
--- a/Tiger.Business.MES/WorkAction/PrintLabel.cs
+++ b/Tiger.Business.MES/WorkAction/PrintLabel.cs
@@ -93,7 +93,7 @@
 
             var wipAct = new MES_WIP_ACT()
             {
-                HIS_ID = CurPosition.CurWipSN.HIS_ID,
+                HIS_ID = CurPosition.CurWipSNHis.ID,
                 SN = CurPosition.CurWipSN.SN,
                 STATUS = CurPosition.CurWipSN.STATUS,
                 ITEM_CODE = CurPosition.CurWipSN.ITEM_CODE,
diff --git a/Tiger.Business.WMS/Transaction/ItemQuery.cs b/Tiger.Business.WMS/Transaction/ItemQuery.cs
index 4102926..89492a2 100644
--- a/Tiger.Business.WMS/Transaction/ItemQuery.cs
+++ b/Tiger.Business.WMS/Transaction/ItemQuery.cs
@@ -172,11 +172,6 @@
         {
             needSaveHistoryLog = true;
             CloseLight().Wait();
-            if (!(req?.BILLCODE ?? "").IsNullOrEmpty())
-            {
-                Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(x => x.TRANS_NO == req.BILLCODE).ExecuteCommand();
-            }
-            Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => CurPoolList.Select(q => q.SN).Contains(q.SN)).ExecuteCommand();
             //淇濆瓨鎿嶄綔鏃ュ織
 
             this.IsFinished = true;
diff --git a/Tiger.Business.WMS/Transaction/OutOther.cs b/Tiger.Business.WMS/Transaction/OutOther.cs
index 86c33bc..4101933 100644
--- a/Tiger.Business.WMS/Transaction/OutOther.cs
+++ b/Tiger.Business.WMS/Transaction/OutOther.cs
@@ -218,7 +218,7 @@
             {
                 if (!input.Code.IsNullOrEmpty())
                 {
-                    Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => CurPoolList.Select(q => q.SN).Contains(q.SN)).ExecuteCommand();
+                    Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand();
                     //濡傛灉涓婁竴娆℃帹鑽愭湁鏁版嵁锛屽垯鍏堢伃鎺変寒鐨勭伅
                     if (Suggests.Any())
                     {
@@ -276,16 +276,7 @@
                     Suggests.RemoveAll(q => q.poolItem.IsNullOrEmpty());
 
                     //淇濆瓨鐗╂枡姹犲埌鏁版嵁搴�
-                    var db = Biz.Db;
-                    var dbTran = db.UseTran(() =>
-                    {
-                        db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand();
-                        db.Insertable(CurPoolList).ExecuteCommand();
-                    });
-                    if (!dbTran.IsSuccess)
-                    {
-                        throw dbTran.ErrorException;
-                    }
+                    Biz.Db.Insertable(CurPoolList).ExecuteCommand();
                     action = await LightAll(new() { AuthOption = input.AuthOption, ReqType = ReqType.IsWhole, Color = LedColor.Blue,ItemCode = input.Code });
                 }
             }
diff --git a/Tiger.Business.WMS/Transaction/OutSale.cs b/Tiger.Business.WMS/Transaction/OutSale.cs
index 15af4f5..90b7056 100644
--- a/Tiger.Business.WMS/Transaction/OutSale.cs
+++ b/Tiger.Business.WMS/Transaction/OutSale.cs
@@ -63,6 +63,8 @@
                     action.LocaleMsg = new("WMS.ProdMReq.SelectOrder.DtlsException", input.ReqNo);
                     return action;
                 }
+
+                Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand();
                 //濡傛灉涓婁竴娆℃帹鑽愭湁鏁版嵁锛屽垯鍏堢伃鎺変寒鐨勭伅
                 if (Suggests.Any())
                 {
@@ -121,17 +123,7 @@
                 Suggests.RemoveAll(q => q.poolItem.IsNullOrEmpty());
 
                 //淇濆瓨鐗╂枡姹犲埌鏁版嵁搴�
-                var db = Biz.Db;
-                var dbTran = db.UseTran(() =>
-                {
-                    db.Insertable(CurPoolList).ExecuteCommand();
-                });
-                if (!dbTran.IsSuccess)
-                {
-                    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
-                    this.Close(!dbTran.IsSuccess);
-                    throw dbTran.ErrorException;
-                }
+                Biz.Db.Insertable(CurPoolList).ExecuteCommand();
                 action = await LightAll(new() { AuthOption = input.AuthOption, Color = LedColor.Blue });
             }
             catch (Exception ex)
diff --git a/Tiger.Business.WMS/Transaction/OutTransfer.cs b/Tiger.Business.WMS/Transaction/OutTransfer.cs
index 2684fab..57d37d7 100644
--- a/Tiger.Business.WMS/Transaction/OutTransfer.cs
+++ b/Tiger.Business.WMS/Transaction/OutTransfer.cs
@@ -73,6 +73,7 @@
                 //濡傛灉鏄墜宸ュ垱寤虹殑璋冩嫧鍗�
                 isManual = req.STATUS == BIZ_WMS_TRANSFER.STATUSs.MANUAL.GetValue();
 
+                Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand();
                 //濡傛灉涓婁竴娆℃帹鑽愭湁鏁版嵁锛屽垯鍏堢伃鎺変寒鐨勭伅
                 if (Suggests.Any())
                 {
@@ -129,17 +130,7 @@
                 Suggests.RemoveAll(q => q.poolItem.IsNullOrEmpty());
 
                 //淇濆瓨鐗╂枡姹犲埌鏁版嵁搴�
-                var db = Biz.Db;
-                var dbTran = db.UseTran(() =>
-                {
-                    db.Insertable(CurPoolList).ExecuteCommand();
-                });
-                if (!dbTran.IsSuccess)
-                {
-                    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
-                    this.Close(!dbTran.IsSuccess);
-                    throw dbTran.ErrorException;
-                }
+                Biz.Db.Insertable(CurPoolList).ExecuteCommand();
                 action = await LightAll(new() { AuthOption = input.AuthOption, ReqType = CurReqType, Color = LedColor.Blue });
             }
             catch (Exception ex)
diff --git a/Tiger.Business.WMS/Transaction/OutWorkOrder.cs b/Tiger.Business.WMS/Transaction/OutWorkOrder.cs
index ac6ab1b..b66ddc0 100644
--- a/Tiger.Business.WMS/Transaction/OutWorkOrder.cs
+++ b/Tiger.Business.WMS/Transaction/OutWorkOrder.cs
@@ -240,7 +240,7 @@
             {
                 if (!input.Code.IsNullOrEmpty())
                 {
-                    Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => CurPoolList.Select(q => q.SN).Contains(q.SN)).ExecuteCommand();
+                    Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand();
                     //濡傛灉涓婁竴娆℃帹鑽愭湁鏁版嵁锛屽垯鍏堢伃鎺変寒鐨勭伅
                     if (Suggests.Any())
                     {
@@ -297,16 +297,7 @@
                     Suggests.RemoveAll(q => q.poolItem.IsNullOrEmpty());
 
                     //淇濆瓨鐗╂枡姹犲埌鏁版嵁搴�
-                    var db = Biz.Db;
-                    var dbTran = db.UseTran(() =>
-                    {
-                        db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand();
-                        db.Insertable(CurPoolList).ExecuteCommand();
-                    });
-                    if (!dbTran.IsSuccess)
-                    {
-                        throw dbTran.ErrorException;
-                    }
+                    Biz.Db.Insertable(CurPoolList).ExecuteCommand();
                     action = await LightAll(new() { AuthOption = input.AuthOption, ReqType = ReqType.IsWhole, Color = LedColor.Blue,ItemCode = input.Code });
                 }
             }
diff --git a/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs b/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs
index 84e7d6e..cb6742e 100644
--- a/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs
+++ b/Tiger.Business.WMS/Transaction/ProductionMaterialReq.cs
@@ -120,6 +120,7 @@
                     return action;
                 }
 
+                Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand();
                 //濡傛灉涓婁竴娆℃帹鑽愭湁鏁版嵁锛屽垯鍏堢伃鎺変寒鐨勭伅
                 if (Suggests.Any())
                 {
@@ -265,18 +266,8 @@
                 }
 
                 //淇濆瓨鐗╂枡姹犲埌鏁版嵁搴�
-                var db = Biz.Db;
-                var dbTran = db.UseTran(() =>
-                {
-                    db.Deleteable<WMS_ITEM_POOL>().Where(x => x.TRANS_NO == req.BILLCODE).ExecuteCommand();
-                    db.Insertable(CurPoolList).ExecuteCommand();
-                });
-                if (!dbTran.IsSuccess)
-                {
-                    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
-                    this.Close(!dbTran.IsSuccess);
-                    throw dbTran.ErrorException;
-                }
+                Biz.Db.Insertable(CurPoolList).ExecuteCommand();
+               
                 action = await LightAll(new() { AuthOption = input.AuthOption, ReqType = CurReqType, Color = LedColor.Blue });
             }
             catch (Exception ex)
diff --git a/Tiger.IBusiness/MES/Transaction/IPosition.cs b/Tiger.IBusiness/MES/Transaction/IPosition.cs
index d086695..2233a4e 100644
--- a/Tiger.IBusiness/MES/Transaction/IPosition.cs
+++ b/Tiger.IBusiness/MES/Transaction/IPosition.cs
@@ -19,6 +19,7 @@
         public MES_POSITION CurPosition { get; set; }
         public IWorkBatch WorkBatch { get; }
         public MES_WIP_DATA CurWipSN { get; set; }
+        public MES_WIP_HIS CurWipSNHis { get; set; }
         public IPosition Init(string id, string apiHost, string userCode, string postCode);
         public void ResetSteps();
         #endregion Propertys & Variables
diff --git a/Tiger.Model.Net/Entitys/MES/MES_WIP_DATA.cs b/Tiger.Model.Net/Entitys/MES/MES_WIP_DATA.cs
index 2ac3a63..d8968d8 100644
--- a/Tiger.Model.Net/Entitys/MES/MES_WIP_DATA.cs
+++ b/Tiger.Model.Net/Entitys/MES/MES_WIP_DATA.cs
@@ -220,8 +220,6 @@
 		[SugarColumn(IsIgnore = true)]
 		public string FieldName { get; set; }
 		*/
-        [SugarColumn(IsIgnore = true)]
-        public string HIS_ID { get; set; } = Guid.NewGuid().ToString("N");
         #endregion
 
         #region 澶栭敭灞炴��
diff --git a/Tiger.Model.Net/Entitys/MES/MES_WIP_HIS.cs b/Tiger.Model.Net/Entitys/MES/MES_WIP_HIS.cs
index 8f56f47..b979d76 100644
--- a/Tiger.Model.Net/Entitys/MES/MES_WIP_HIS.cs
+++ b/Tiger.Model.Net/Entitys/MES/MES_WIP_HIS.cs
@@ -28,7 +28,7 @@
         /// <param name="traceInfo">杩芥函淇℃伅</param>
         public MES_WIP_HIS(MES_WIP_DATA data, string traceInfo)
         {
-			ID = data.HIS_ID;
+			ID = Guid.NewGuid().ToString("N");
             CREATE_USER = data.CREATE_USER;
             UPDATE_USER = data.UPDATE_USER;
             AUTH_ORG = data.AUTH_ORG;

--
Gitblit v1.9.3