From 7bf8f292234bea48fd9318eee9267c6ef19e19ed Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 01 一月 2025 21:57:41 +0800
Subject: [PATCH] 工步增加行为变量字典

---
 Tiger.Business.MES/WorkAction/PackingAction.cs |  162 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 106 insertions(+), 56 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs
index 87df59d..25fd102 100644
--- a/Tiger.Business.MES/WorkAction/PackingAction.cs
+++ b/Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -18,6 +18,7 @@
     {
         #region Propertys & Variables
         #region 鍥哄畾鍐欐硶锛屽伐搴忎腑鐨勫繀瑕佷俊鎭�
+        public DbClient MainDB { get; set; }
         public bool IsFinished { get; set; } = false;
         public IWorkStep CurStep { get; set; }
         public IPosition CurPosition { get; set; }
@@ -48,19 +49,20 @@
             CurPosition = position;
             NodeAct = nodeAct;
             Setting = setting;
+            MainDB = position.MainDB;
             #endregion
 
             //姝e父鏉$爜杩囩珯鎵ц鍖呰琛屼负
-            PkgRule = Biz.Db.Queryable<BAS_PKG_RULE>().Where(q => q.RULE_CODE == setting.PKG_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Details).First();
+            PkgRule = MainDB.Queryable<BAS_PKG_RULE>().Where(q => q.RULE_CODE == setting.PKG_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Details).First();
 
             //鏍规嵁琛屼负璁剧疆鑾峰彇澶氬眰鍖呰鐨勬爣绛炬墦鍗版ā鏉垮瓧鍏�
             var codes = (Setting.OPTION_1 ?? "").JsonToObject<List<WipPkgItem>>() ?? new List<WipPkgItem>();
             foreach (var code in codes)
             {
-                var label = code.LABEL_CODE.IsNullOrEmpty() ? null : Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == code.LABEL_CODE).IncludesAllFirstLayer().First();
+                var label = code.LABEL_CODE.IsNullOrEmpty() ? null : MainDB.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == code.LABEL_CODE).IncludesAllFirstLayer().First();
                 LabelDic.Add(code.PKG_LEVEL, label);
             }
-            LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList();
+            LabelPV = MainDB.Queryable<BAS_LABEL_PV>().ToList();
 
             //濡傛灉宸ュ簭涓婁笅鏂囦腑娌℃湁鍖呰璁板綍鍒欐柊寤轰竴涓紝鏈変笖鏈寘瑁呭畬鎴愬垯鑾峰彇褰撳墠鐨勫寘瑁呰褰�
             if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty() && !(CurPosition.Context["CurPackage"] as WipPkg).IsFinished)
@@ -76,7 +78,7 @@
                     RULE_CODE = PkgRule.RULE_CODE,
                     RULE_NAME = PkgRule.RULE_NAME,
                     PROD_CODE = CurPosition.WorkBatch.WO.ITEM_CODE,
-                    CustSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == CurPosition.CurWipSNs.First().FLOW_SN).First(),
+                    CustSN = MainDB.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == CurPosition.CurWipSNs.First().FLOW_SN).First(),
                     Item = new WipPkgItem()
                     {
                         PKG_CODE = max.PKG_CODE,
@@ -84,7 +86,7 @@
                         IS_MIN_PKG = max.PkgType.IS_MIN_PKG,
                         PKG_LEVEL = max.PKG_LEVEL,
                         PKG_QTY = max.PKG_QTY,
-                        LABEL_CODE = LabelDic.Count > max.PKG_LEVEL ? LabelDic[max.PKG_LEVEL]?.LABEL_CODE : null,
+                        LABEL_CODE = LabelDic?.GetValueOrDefault(max.PKG_LEVEL, null)?.LABEL_CODE,//LabelDic.Count >= max.PKG_LEVEL ? LabelDic[max.PKG_LEVEL]?.LABEL_CODE : null,
                         SN = CurPosition.GenerateSN(max.SN_RULE, this),
                     }
                 };
@@ -100,7 +102,7 @@
                             IS_MIN_PKG = dtl.PkgType.IS_MIN_PKG,
                             PKG_LEVEL = dtl.PKG_LEVEL,
                             PKG_QTY = dtl.PKG_QTY,
-                            LABEL_CODE = LabelDic.Count > dtl.PKG_LEVEL ? LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE : null,
+                            LABEL_CODE = LabelDic.Count >= dtl.PKG_LEVEL ? LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE : null,
                             SN = CurPosition.GenerateSN(dtl.SN_RULE, this),
                         };
                         if (!child.IsNullOrEmpty())
@@ -125,7 +127,7 @@
             //鑾峰彇鏄惁鍖呰瀹屽悗闇�瑕佺О閲�
             CurPkg.NeedWeighing = Setting.OPTION_2 == "Y";
             //鑾峰彇鍖呰瑙勫垯鐨勭О閲嶈寖鍥�
-            PkgProd = Biz.Db.Queryable<BAS_PKG_PROD>().Where(q => q.PKG_RULE_ID == PkgRule.ID && q.ITEM_CODE == CurPosition.WorkBatch.WO.ITEM_CODE).First();
+            PkgProd = MainDB.Queryable<BAS_PKG_PROD>().Where(q => q.PKG_RULE_ID == PkgRule.ID && q.ITEM_CODE == CurPosition.WorkBatch.WO.ITEM_CODE).First();
 
             CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("璁板綍鍖呰鏁版嵁"));
         }
@@ -141,6 +143,7 @@
             CurPosition = position;
             NodeAct = null;
             Setting = null;
+            MainDB = position.MainDB;
             #endregion
             //鑾峰彇褰撳墠鐨勫寘瑁呰褰�
             if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty())
@@ -152,13 +155,13 @@
                 throw new Exception("鎵句笉鍒板寘瑁呮暟鎹紝璇烽噸鏂版壂鎻忛渶瑕佸寘瑁呯殑浜у搧");
             }
             //鎵嬪姩缁撴潫鍖呰涓撶敤锛屼复鏃舵墽琛岃涓�
-            PkgRule = Biz.Db.Queryable<BAS_PKG_RULE>().Where(q => q.RULE_CODE == CurPkg.RULE_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Details).First();
+            PkgRule = MainDB.Queryable<BAS_PKG_RULE>().Where(q => q.RULE_CODE == CurPkg.RULE_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Details).First();
 
             //鏍规嵁琛屼负璁剧疆鑾峰彇澶氬眰鍖呰鐨勬爣绛炬墦鍗版ā鏉垮瓧鍏�
             LabelDic = CurPosition.Context["CurLabelDic"] as Dictionary<int, BAS_LABEL_TEMP>;
-            LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList();
+            LabelPV = MainDB.Queryable<BAS_LABEL_PV>().ToList();
             //鑾峰彇鍖呰瑙勫垯鐨勭О閲嶈寖鍥�
-            PkgProd = Biz.Db.Queryable<BAS_PKG_PROD>().Where(q => q.PKG_RULE_ID == PkgRule.ID && q.ITEM_CODE == CurPkg.PROD_CODE).First();
+            PkgProd = MainDB.Queryable<BAS_PKG_PROD>().Where(q => q.PKG_RULE_ID == PkgRule.ID && q.ITEM_CODE == CurPkg.PROD_CODE).First();
             //鎶�
 
             CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("璁板綍鍖呰鏁版嵁"));
@@ -196,6 +199,10 @@
             action.LocaleMsg = GetBeginMsg();
 
             var min = PkgRule.Details.OrderBy(q => q.PKG_LEVEL).First();
+            if (min.PKG_LEVEL == CurPkg.Item.PKG_LEVEL)
+            {
+                CurPkg.Item.WipSNs = CurPosition.CurWipSNs.ToDictionary(k => k.ID, v => v.SN);
+            }
             if (min.PKG_LEVEL == CurPkg.Item.PKG_LEVEL && CurPkg.NeedWeighing)
             {
                 var data = new PackingActionOutput() { PkgInfo = CurPkg };
@@ -377,6 +384,7 @@
                             //鏈�澶栧眰鍖呰宸插鐞嗗畬鎴愬垯鐩存帴缁撴潫琛屼负
                             if (CurPkg.Item.PKG_LEVEL == FinishLevel)
                             {
+                                CurPkg.Item.WipSNs = CurPosition.CurWipSNs.ToDictionary(k => k.ID, v => v.SN);
                                 action = End(input);
                             }
                             //鏈�澶栧眰鍖呰鏈墦鍗版壂鎻忓垯缁х画
@@ -561,7 +569,7 @@
                         IsFinished = true,
                     };
 
-                    CurPkgItem.Package = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == CurPkgItem.SN && q.AUTH_ORG == CurPosition.WorkBatch.WO.AUTH_ORG).First() ?? new()
+                    CurPkgItem.Package = MainDB.Queryable<MES_WIP_PKG>().Where(q => q.SN == CurPkgItem.SN && q.AUTH_ORG == CurPosition.WorkBatch.WO.AUTH_ORG).First() ?? new()
                     {
                         AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG,
                         AUTH_PROD = CurPosition.CurLine.LINE_CODE,
@@ -570,7 +578,7 @@
                     CurPkgItem.Package.WIP_ID = CurPosition.CurWipSNs.Count == 1 ? CurPosition.CurWipSNs.First().ID : null;
                     CurPkgItem.Package.PKG_TYPE = dtl.PkgType.PKG_NAME;
                     CurPkgItem.Package.ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE;
-                    CurPkgItem.Package.QTY = CurPosition.CurWipSNs.First().QTY;
+                    CurPkgItem.Package.QTY = CurPosition.CurWipSNs.Sum(q => q.QTY);
                     CurPkgItem.Package.UNIT = dtl.PkgType.PKG_NAME;
                     CurPkgItem.Package.WORK_ORDER = CurPosition.CurWipSNs.First().WORK_ORDER;
                     CurPkgItem.Package.BATCH_NO = CurPosition.CurWipSNs.First().BATCH_NO;
@@ -586,6 +594,9 @@
                     CurPkgItem.Package.ACT_ID = NodeAct.ID;
                     CurPkgItem.Package.ACT_NAME = NodeAct.ACT_NAME;
                     CurPkgItem.Package.FLOW_SN = CurPosition.CurWipSNs.First().FLOW_SN;
+
+                    CurPkgItem.WipSNs = CurPosition.CurWipSNs.ToDictionary(k => k.ID, v => v.SN);
+
                     FinishLevel++;
                     //瀹屾垚鍖呰鐨勫眰绾у皬浜庢渶澶栧眰鍖呰灞傜骇
                     if (FinishLevel < PkgRule.Details.Max(q => q.PKG_LEVEL))
@@ -627,6 +638,8 @@
                             POST_CODE = CurPkgItem.Items.First().Package.POST_CODE,
                             OPER_CODE = CurPkgItem.Items.First().Package.OPER_CODE,
                             SEGMENT = CurPkgItem.Items.First().Package.SEGMENT,
+                            ACT_ID = CurPkgItem.Items.First().Package.ACT_ID,
+                            ACT_NAME = CurPkgItem.Items.First().Package.ACT_NAME,
                         } : new()
                         {
                             AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG,
@@ -786,27 +799,6 @@
             return action;
         }
 
-        public List<MES_WIP_PKG> GetMinPackageList(WipPkgItem parent)
-        {
-            List<MES_WIP_PKG> list = new();
-            if (parent.Items.Any())
-            {
-                foreach (var item in parent.Items)
-                {
-                    item.Package.PARENT_SN = parent.Package?.SN;
-                    list.AddRange(GetMinPackageList(item));
-                }
-            }
-            else
-            {
-                if (!parent.Package.IsNullOrEmpty())
-                {
-                    list.Add(parent.Package);
-                }
-            }
-            return list;
-        }
-
         public ApiAction<SubmitOutput> CompletePkg()
         {
             var action = new ApiAction<SubmitOutput>(new SubmitOutput());
@@ -850,6 +842,7 @@
             {
                 //璁板綍琛屼负鎿嶄綔璁板綍
                 var wipActs = new List<MES_WIP_ACT>();
+                var wipVars = new List<MES_WIP_ACT_VAR>();
                 foreach (var wipSn in CurPosition.CurWipSNs)
                 {
 
@@ -890,15 +883,61 @@
                         ACT_VALUE_1 = CurPkg.IsFinished ? "Y" : "N",
                         ACT_VALUE_2 = CurPkg.ToJson(),
                         ACT_VALUE_3 = CurPkg.IsFinished ? LabelDic[CurPkg.Item.PKG_LEVEL].ToJson() : "",
+                        ACT_VALUE_4 = "Customer",
+                        ACT_VAR_DIC = CurStep.ActionDic.ToJson(),
                         ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
                         TRACE_INFO = $"浜у搧鏉$爜[{string.Join("锛�", CurPosition.CurSN)}]鍖呰瀹屾垚",
                     };
                     wipActs.Add(wipAct);
+                    foreach (var item in NodeAct.Variables)
+                    {
+                        var wipVar = new MES_WIP_ACT_VAR()
+                        {
+                            AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG,
+                            AUTH_PROD = CurPosition.CurLine.LINE_CODE,
+                            HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID,
+                            WIP_ID = wipSn.ID,
+                            SN = wipSn.SN,
+                            ITEM_CODE = wipSn.ITEM_CODE,
+                            WORK_ORDER = wipSn.WORK_ORDER,
+                            BATCH_NO = wipSn.BATCH_NO,
+                            CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE,
+                            ROT_CODE = wipSn.ROT_CODE,
+                            NODE_ID = wipSn.NODE_ID,
+                            NODE_NAME = wipSn.NODE_NAME,
+                            ACT_ID = NodeAct.ID,
+                            ACT_NAME = NodeAct.ACT_NAME,
+                            FTY_CODE = wipSn.FTY_CODE,
+                            WS_CODE = wipSn.WS_CODE,
+                            LINE_CODE = wipSn.LINE_CODE,
+                            POST_CODE = wipSn.POST_CODE,
+                            OPER_CODE = wipSn.OPER_CODE,
+                            SEGMENT = wipSn.SEGMENT,
+                            FLOW_SN = wipSn.FLOW_SN,
+                            TRAY_SN = wipSn.TRAY_SN,
+                            INNER_SN = wipSn.INNER_SN,
+                            CARTON_SN = wipSn.CARTON_SN,
+                            PALLET_SN = wipSn.PALLET_SN,
+                            OPERATION_TIME = DateTime.Now,
+                            SFTS_CODE = wipSn.SFTS_CODE,
+                            SFT_CODE = wipSn.SFT_CODE,
+                            PRD_CODE = wipSn.PRD_CODE,
+                            VAR_CODE = item.VAR_CODE,
+                            VAR_NAME = item.VAR_NAME,
+                            VAR_CONTROL = item.VAR_CONTROL,
+                            VALUE_TYPE = item.VALUE_TYPE,
+                            INPUT_VALUE = CurStep.ActionDic.GetOrDefault(item.VAR_CODE),
+                            TRACE_INFO = CurStep.ActionDic.ToJson(),
+                        };
+                        wipVars.Add(wipVar);
+                    }
                 }
 
                 //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊�
                 var _wipActs = wipActs.Clone();
-                var _pkgList = CurPkg.IsFinished ? CurPosition.GetPackageList(CurPkg.Item) : new();
+                var _wipVars = wipVars.Clone();
+                var _pkgList = CurPkg.IsFinished ? CurPosition.GetPackageList(CurPkg.Item).Clone() : new();
+                var _wipIDs = CurPkg.IsFinished ? CurPkg.Item.GetWipSnList().Select(q => q.Key).ToList().Clone() : new();
                 //淇濆瓨鏁版嵁
                 CurStep.DBSubmitAction = () =>
                 {
@@ -906,40 +945,41 @@
                     if (_wipActs.Any())
                     {
                         db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand();
+                        db.Storageable(_wipVars, CurPosition.UserCode).ExecuteCommand();
                     }
                     if (_pkgList.Any())
                     {
                         db.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand();
-                        var wipIDs = _pkgList.Where(q => !q.WIP_ID.IsNullOrEmpty()).Select(q => q.WIP_ID).ToList();
+                        //var wipIDs = _pkgList.Where(q => !q.WIP_ID.IsNullOrEmpty()).Select(q => q.WIP_ID).ToList();
                         var nodeID = _pkgList.First().NODE_ID;
                         var actID = _pkgList.First().ACT_ID;
                         var wo = _pkgList.First().WORK_ORDER;
                         //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛�
-                        db.Updateable<MES_WIP_DATA>()
+                        db.Updateable<MES_WIP_DATA>(CurPosition.UserCode)
                             .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                             .SetColumns(q => q.INNER_SN == q.CARTON_SN)
                             .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                            .Where(q => q.WORK_ORDER == wo && wipIDs.Contains(q.ID))
+                            .Where(q => q.WORK_ORDER == wo && _wipIDs.Contains(q.ID))
                             .ExecuteCommand();
                         //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц繃绋嬭褰�
-                        db.Updateable<MES_WIP_HIS>()
+                        db.Updateable<MES_WIP_HIS>(CurPosition.UserCode)
                             .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                             .SetColumns(q => q.INNER_SN == q.CARTON_SN)
                             .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                            .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && wipIDs.Contains(q.WIP_ID))
+                            .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && _wipIDs.Contains(q.WIP_ID))
                             .ExecuteCommand();
                         //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц涓鸿褰�
-                        db.Updateable<MES_WIP_ACT>()
+                        db.Updateable<MES_WIP_ACT>(CurPosition.UserCode)
                             .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                             .SetColumns(q => q.INNER_SN == q.CARTON_SN)
                             .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                            .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == actID && wipIDs.Contains(q.WIP_ID))
+                            .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == actID && _wipIDs.Contains(q.WIP_ID))
                             .ExecuteCommand();
                         //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃
-                        db.Updateable<BIZ_MES_WO_SN>()
+                        db.Updateable<BIZ_MES_WO_SN>(CurPosition.UserCode)
                             .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                             .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN)
-                            .Where(q => q.WORK_ORDER == wo && wipIDs.Contains(q.WIP_ID))
+                            .Where(q => q.WORK_ORDER == wo && _wipIDs.Contains(q.WIP_ID))
                             .ExecuteCommand();
                     }
                 };
@@ -949,6 +989,7 @@
                 if (CurPkg.IsFinished)
                 {
                     var _pkgList = CurPosition.GetPackageList(CurPkg.Item).Clone();
+                    var _wipIDs = CurPkg.Item.GetWipSnList().Select(q => q.Key).ToList().Clone();
                     var _lastWipID = CurPosition.LastWipSNs?.FirstOrDefault()?.ID;
 
                     //鏈�澶栧眰鍖呰宸茬粡瀹屾垚鍖呰锛屽垯鎶婂伐搴忎腑鏆傚瓨鏍囪璁句负false锛岀粺涓�鎻愪氦鍖呰鍐呬骇鍝佺殑杩囩珯璁板綍
@@ -960,43 +1001,52 @@
                         if (_pkgList.Any())
                         {
                             db.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand();
-                            var wipIDs = _pkgList.Where(q => !q.WIP_ID.IsNullOrEmpty()).Select(q => q.WIP_ID).ToList();
-                            var nodeID = _pkgList.First(q => !q.WIP_ID.IsNullOrEmpty()).NODE_ID;
-                            var actID = _pkgList.First(q => !q.WIP_ID.IsNullOrEmpty()).ACT_ID;
-                            var wo = _pkgList.First(q => !q.WIP_ID.IsNullOrEmpty()).WORK_ORDER;
+                            //var wipIDs = _pkgList.Where(q => !q.WIP_ID.IsNullOrEmpty()).Select(q => q.WIP_ID).ToList();
+                            var nodeID = _pkgList.First(q => !q.NODE_ID.IsNullOrEmpty()).NODE_ID;
+                            var actID = _pkgList.First(q => !q.ACT_ID.IsNullOrEmpty()).ACT_ID;
+                            var wo = _pkgList.First(q => !q.WORK_ORDER.IsNullOrEmpty()).WORK_ORDER;
                             //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛�
-                            db.Updateable<MES_WIP_DATA>()
+                            db.Updateable<MES_WIP_DATA>(CurPosition.UserCode)
                                 .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                                 .SetColumns(q => q.INNER_SN == q.CARTON_SN)
                                 .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == wo && wipIDs.Contains(q.ID))
+                                .Where(q => q.WORK_ORDER == wo && _wipIDs.Contains(q.ID))
                                 .ExecuteCommand();
                             //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц繃绋嬭褰�
                             var endOperCode = CurPkg.IsReachedEndNode ? "EndNode" : "NotReachedEndNode";
-                            db.Updateable<MES_WIP_HIS>()
+                            db.Updateable<MES_WIP_HIS>(CurPosition.UserCode)
                                 .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                                 .SetColumns(q => q.INNER_SN == q.CARTON_SN)
                                 .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == wo && (q.NODE_ID == nodeID || q.OPER_CODE == endOperCode) && wipIDs.Contains(q.WIP_ID))
+                                .Where(q => q.WORK_ORDER == wo && (q.NODE_ID == nodeID || q.OPER_CODE == endOperCode) && _wipIDs.Contains(q.WIP_ID))
                                 .ExecuteCommand();
                             //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц涓鸿褰�
-                            db.Updateable<MES_WIP_ACT>()
+                            db.Updateable<MES_WIP_ACT>(CurPosition.UserCode)
                                 .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                                 .SetColumns(q => q.INNER_SN == q.CARTON_SN)
                                 .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == actID && wipIDs.Contains(q.WIP_ID))
+                                .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == actID && _wipIDs.Contains(q.WIP_ID))
                                 .ExecuteCommand();
-                            db.Updateable<MES_WIP_ACT>()
+                            db.Updateable<MES_WIP_ACT>(CurPosition.UserCode)
                                 .SetColumns(q => q.ACT_VALUE_1 == (CurPkg.IsFinished ? "Y" : "N"))
                                 .SetColumns(q => q.ACT_VALUE_2 == CurPkg.ToJson())
                                 .SetColumns(q => q.ACT_VALUE_3 == (CurPkg.IsFinished ? LabelDic[CurPkg.Item.PKG_LEVEL].ToJson() : ""))
+                                .SetColumns(q => q.ACT_VALUE_4 == "Customer")
                                 .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == actID && q.WIP_ID == _lastWipID)
                                 .ExecuteCommand();
+                            var InStoreLabel = CurPkg.IsFinished ? CurPkg.InStoreLabel?.ToJson() : "";
+                            db.Updateable<MES_WIP_ACT>(CurPosition.UserCode)
+                                .SetColumns(q => q.ACT_VALUE_1 == (CurPkg.IsFinished ? "Y" : "N"))
+                                .SetColumns(q => q.ACT_VALUE_2 == CurPkg.ToJson())
+                                .SetColumns(q => q.ACT_VALUE_3 == InStoreLabel)
+                                .SetColumns(q => q.ACT_VALUE_4 == "InStore")
+                                .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == CurPkg.InStoreActID && q.WIP_ID == _lastWipID)
+                                .ExecuteCommand();
                             //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃
-                            db.Updateable<BIZ_MES_WO_SN>()
+                            db.Updateable<BIZ_MES_WO_SN>(CurPosition.UserCode)
                                 .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                                 .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == wo && wipIDs.Contains(q.WIP_ID))
+                                .Where(q => q.WORK_ORDER == wo && _wipIDs.Contains(q.WIP_ID))
                                 .ExecuteCommand();
                         }
                     });

--
Gitblit v1.9.3