From baaa18ee787727779745ebf0de7f2be66353ada2 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 19 十二月 2024 12:09:08 +0800
Subject: [PATCH] 一些更改

---
 Tiger.Business.MES/Transaction/Position.cs |  239 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 178 insertions(+), 61 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs
index 5b1efd0..80df811 100644
--- a/Tiger.Business.MES/Transaction/Position.cs
+++ b/Tiger.Business.MES/Transaction/Position.cs
@@ -15,6 +15,7 @@
 using Tiger.Business.MES.WorkAction;
 using System.Collections;
 using Tiger.IBusiness.MES.WorkAction;
+using Dm.parser;
 
 namespace Tiger.Business.MES.Transaction
 {
@@ -29,22 +30,23 @@
             UserCode = userCode;
             ApiHost = apiHost;
             PostCode = postCode;
+            _MainDB = Biz.Db;
 
-            CurPosition = Biz.Db.Queryable<MES_POSITION>().Where(q => q.POST_CODE == postCode).First();
+            CurPosition = MainDB.Queryable<MES_POSITION>().Where(q => q.POST_CODE == postCode).First();
             //if (CurPosition.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.PositionNotExistsException", new Exception($"{postCode}|"));
             if (CurPosition.IsNullOrEmpty()) throw new InvalidDataException($"宀椾綅[{postCode}]涓嶅瓨鍦紝璇锋彁浜ゆ纭殑宀椾綅浠g爜", new Exception($"{postCode}|"));
-            CurLine = Biz.Db.Queryable<MES_LINE>().Where(q => q.LINE_CODE == CurPosition.LINE_CODE).First();
+            CurLine = MainDB.Queryable<MES_LINE>().Where(q => q.LINE_CODE == CurPosition.LINE_CODE).First();
             //if (CurLine.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.LineNotExistsException", new Exception($"{postCode}|{CurPosition.LINE_CODE}"));
             if (CurLine.IsNullOrEmpty()) throw new InvalidDataException($"宀椾綅[{postCode}]鎵�灞炵殑浜х嚎[{CurPosition.LINE_CODE}]涓嶅瓨鍦紝璇峰厛璁剧疆鎵�灞炰骇绾�", new Exception($"{postCode}|{CurPosition.LINE_CODE}"));
-            CurWorkshop = Biz.Db.Queryable<MES_WORKSHOP>().Where(q => q.WS_CODE == CurLine.WS_CODE).First();
+            CurWorkshop = MainDB.Queryable<MES_WORKSHOP>().Where(q => q.WS_CODE == CurLine.WS_CODE).First();
             //if (CurWorkshop.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.WorkshopNotExistsException", new Exception($"{postCode}|{CurLine.WS_CODE}"));
             if (CurWorkshop.IsNullOrEmpty()) throw new InvalidDataException($"宀椾綅[{postCode}]鎵�灞炵殑杞﹂棿[{CurLine.WS_CODE}]涓嶅瓨鍦紝璇峰厛璁剧疆鎵�灞炶溅闂�", new Exception($"{postCode}|{CurLine.WS_CODE}"));
-            CurFactory = Biz.Db.Queryable<MES_FACTORY>().Where(q => q.FTY_CODE == CurWorkshop.FTY_CODE).First();
+            CurFactory = MainDB.Queryable<MES_FACTORY>().Where(q => q.FTY_CODE == CurWorkshop.FTY_CODE).First();
             //if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.FactoryNotExistsException", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}"));
             if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"宀椾綅[{postCode}]鎵�灞炵殑宸ュ巶[{CurWorkshop.FTY_CODE}]涓嶅瓨鍦紝璇峰厛璁剧疆鎵�灞炲伐鍘�", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}"));
 
             //鍔犺浇褰撳墠浜х嚎鐨勭彮鍒�
-            CurShiftSys = Biz.Db.Queryable<MES_SHIFT_SYS>().Where(q => q.SFTS_CODE == CurLine.SFTS_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Shifts).First();
+            CurShiftSys = MainDB.Queryable<MES_SHIFT_SYS>().Where(q => q.SFTS_CODE == CurLine.SFTS_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Shifts).First();
 
             return this;
         }
@@ -74,6 +76,8 @@
         public bool IsFinishNodeSteps => !Steps.Any(q => q.NodeType == IWorkStep.NodeTypes.Node && !q.IsFinished);
         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;
+        private DbClient _MainDB;
+        public DbClient MainDB => _MainDB;
         private DbClient CommitDB;
         /// <summary>
         /// 鏄惁闇�瑕佷复鏃跺瓨鍌ㄦ暟鎹簱鎻愪氦鎿嶄綔锛屽緟闇�瑕佺殑鏃跺�欏啀鎻愪氦
@@ -106,7 +110,7 @@
             {
                 if (!WoContext.ExistsBatch(input.OrderNo, CurLine.LINE_CODE, batchNo, true))
                 {
-                    var wo = await Biz.Db.Queryable<BIZ_MES_WO>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo).FirstAsync();
+                    var wo = await MainDB.Queryable<BIZ_MES_WO>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo).FirstAsync();
                     //楠岃瘉鏄庣粏鏄惁姝g‘
                     if (wo.IsNullOrEmpty())
                     {
@@ -122,7 +126,7 @@
                         action.LocaleMsg = new("MES.Transaction.Position.SelectOrder.StatusException", input.OrderNo, wo.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>());
                         return action;
                     }
-                    var batch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption)
+                    var batch = await MainDB.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption)
                         .Where(q => q.ORDER_NO == input.OrderNo && q.ACT_LINE == CurLine.LINE_CODE)
                         .WhereIF(!batchNo.IsNullOrEmpty(), q => q.BATCH_NO == batchNo)
                         .OrderBy(q => q.STATUS).FirstAsync();
@@ -140,8 +144,8 @@
                         action.LocaleMsg = new("MES.Transaction.Position.SelectOrder.BatchStatusException", input.OrderNo, batch.BATCH_NO, batch.STATUS.GetEnumDesc<BIZ_MES_WO_BATCH.STATUSs>());
                         return action;
                     }
-                    var wb = new WorkBatch(input.OrderNo).Init(CurLine.LINE_CODE);
-                    WoContext.WoBatchDic.Add(wb.Batch.BATCH_NO, wb);
+                    var wb = WoContext.Add(input.OrderNo, CurLine.LINE_CODE);
+                    batchNo = wb.Batch.BATCH_NO;
                 }
                 CurBatch = WoContext.GetBatch(input.OrderNo, CurLine.LINE_CODE, batchNo);
                 if (!OperInfoDic.ContainsKey(CurBatch.Batch.BATCH_NO))
@@ -240,6 +244,62 @@
                 info.NextNode = "   鈥�   ";
             }
             return info;
+        }
+
+        /// <summary>
+        /// 璁剧疆褰撳墠鏉$爜鐨勫伐搴忎俊鎭�
+        /// </summary>
+        public ApiAction<SubmitOutput> SetOutPutMqttMsg(ApiAction<SubmitOutput> action, string locale = null)
+        {
+            MQTT.Message msg = new()
+            {
+                IsSuccessed = action.IsSuccessed,
+                Content = Biz.T(action.LocaleMsg, locale),
+            };
+            switch (action.Status)
+            {
+                case ApiAction.StatusCodes.Success:
+                    msg.Voice = MQTT.Voice.Success;
+                    msg.Color = "#FF1E90FF";
+                    break;
+                case ApiAction.StatusCodes.Warning:
+                    msg.Voice = MQTT.Voice.Warning;
+                    msg.Color = "#FFB8860B";
+                    break;
+                case ApiAction.StatusCodes.Error:
+                case ApiAction.StatusCodes.Failed:
+                    msg.Voice = MQTT.Voice.Fail;
+                    msg.Color = "#FFFF0000";
+                    break;
+                case ApiAction.StatusCodes.Exception:
+                    msg.Voice = MQTT.Voice.Fail;
+                    msg.Color = "#FF8B0000";
+                    break;
+                case ApiAction.StatusCodes.Normal:
+                case ApiAction.StatusCodes.NeedConfrim:
+                case ApiAction.StatusCodes.Confrimed:
+                default:
+                    msg.Voice = MQTT.Voice.Silent;
+                    msg.Color = "#FF000000";
+                    break;
+            }
+            if (action.Data.IsFinished && action.IsSuccessed)
+            {
+                msg.Voice = MQTT.Voice.Pass;
+                msg.Color = "#FF228B22";
+            }
+            else if (!action.IsSuccessed)
+            {
+                msg.Voice = MQTT.Voice.Fail;
+                msg.Color = "#FFFF0000";
+            }
+            else
+            {
+                msg.Voice = MQTT.Voice.Silent;
+                msg.Color = "#FF000000";
+            }
+            action.Data.MqttMsg = msg;
+            return action;
         }
 
         /// <summary>
@@ -512,6 +572,11 @@
         /// <returns></returns>
         public BAS_LABEL_TEMP SetLabelVariables(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_TEMP label, IWorkAction action)
         {
+            return SetLabelVariables(labelPVs, label, action, null);
+        }
+
+        public BAS_LABEL_TEMP SetLabelVariables(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_TEMP label, IWorkAction action, WipPkg? CurPkg)
+        {
             foreach (var item in label.Variables.OrderBy(q => q.VAR_TYPE == BAS_LABEL_VAR.VAR_TYPEs.BarcodeGenerate.GetValue() ? 0 : 1))
             {
                 switch (item.VAR_TYPE.GetEnum<BAS_LABEL_VAR.VAR_TYPEs>())
@@ -520,7 +585,7 @@
                         item.Value = item.VAR_VALUE;
                         break;
                     case BAS_LABEL_VAR.VAR_TYPEs.ProcessVariable:
-                        item.Value = GetPrintProcessValue(labelPVs, item, label.Variables, action);
+                        item.Value = GetPrintProcessValue(labelPVs, item, label.Variables, action, CurPkg);
                         break;
                     case BAS_LABEL_VAR.VAR_TYPEs.DateVariable:
                         item.Value = DateTime.Now.ToString(item.VAR_VALUE);
@@ -543,7 +608,7 @@
         /// <param name="labelPVs">杩囩▼鍙橀噺鍒楄〃</param>
         /// <param name="lv">鏍囩妯℃澘鍙橀噺</param>
         /// <returns></returns>
-        public string GetPrintProcessValue(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_VAR lv, List<BAS_LABEL_VAR> lvars, IWorkAction curAction)
+        public string GetPrintProcessValue(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_VAR lv, List<BAS_LABEL_VAR> lvars, IWorkAction curAction, WipPkg? CurPkg)
         {
             var pv = labelPVs.FirstOrDefault(q => q.VAR_CODE == lv.VAR_VALUE);
             if (!pv.IsNullOrEmpty())
@@ -556,6 +621,8 @@
                             {
                                 case "GetSN":
                                     return CurSN;
+                                case "GetItemCode":
+                                    return GetLabelVarWo(lv, WorkBatch.Product.ITEM_CODE);
                                 case "GetBAS_ITEM":
                                     return GetLabelVarWo(lv, WorkBatch.Product.CUST_PROD_CODE);
                                 case "GetItemName":
@@ -567,15 +634,26 @@
                                 case "GetPackNumber":
                                     return GetLabelVarWo(lv, WorkBatch.WO.ORDER_NO);
                                 case "GetBoxQR":
-                                    return GetCardOrBoxQR(GetBoxCode(lvars), curAction);
+                                    return GetCardOrBoxQR(GetBoxCode(), curAction, CurPkg);
                                 case "GetCardQR":
-                                    return GetCardOrBoxQR(GetCardCode(lvars), curAction);
+                                    return GetCardOrBoxQR("", curAction, CurPkg);
                                 case "GetCardSN":
                                     List<string> minPkgList = new List<string>();
-                                    var _pkaction = curAction is PackingAction ? curAction as PackingAction : null;
-                                    if (_pkaction != null)
+                                    if (!CurPkg.IsNullOrEmpty())
                                     {
-                                        minPkgList = GetMinPkgList(_pkaction);
+                                        minPkgList = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                    }
+                                    else
+                                    {
+                                        var _pkaction = curAction is PackingAction ? curAction as PackingAction : null;
+                                        if (!_pkaction.IsNullOrEmpty())
+                                        {
+                                            minPkgList = GetMinPkgList(_pkaction);
+                                        }
+                                        if (curAction is PrintInStoreLabel)
+                                        {
+                                            minPkgList = (curAction as PrintInStoreLabel).CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                        }
                                     }
                                     return string.Join("\r\n", minPkgList);
                                 case "GetDescription":
@@ -588,23 +666,41 @@
                                     return GetLabelVarWo(lv, WorkBatch.WO.Customer?.CUST_NAME_CN);
                                 case "GetHWDate":
                                     List<string> list = new List<string>();
-                                    var _action = curAction is PackingAction ? curAction as PackingAction : null;
-                                    if (_action != null)
+                                    if (!CurPkg.IsNullOrEmpty())
                                     {
-                                        list = GetMinPkgList(_action);
+                                        list = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                    }
+                                    else
+                                    {
+                                        var _action = curAction is PackingAction ? curAction as PackingAction : null;
+                                        if (_action != null)
+                                        {
+                                            list = _action.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                        }
+                                        if (curAction is PrintInStoreLabel)
+                                        {
+                                            list = (curAction as PrintInStoreLabel).CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                        }
                                     }
                                     return GetHuaWeiWeek(WorkBatch.Batch.ORDER_NO, list);
                                 case "GetQty":
                                     List<string> qtylist = new List<string>();
-                                    if (curAction is PackingAction)
+                                    if (!CurPkg.IsNullOrEmpty())
                                     {
-                                        qtylist = GetMinPkgList(curAction as PackingAction);
+                                        qtylist = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
                                     }
-                                    if (curAction is PrintInStoreLabel)
+                                    else
                                     {
-                                        qtylist = (curAction as PrintInStoreLabel).CurPkg.Item.GetMinPackageList().Select(q=>q.SN).ToList();
+                                        if (curAction is PackingAction)
+                                        {
+                                            qtylist = (curAction as PackingAction).CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                        }
+                                        if (curAction is PrintInStoreLabel)
+                                        {
+                                            qtylist = (curAction as PrintInStoreLabel).CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                        }
                                     }
-                                    return $"{qtylist.Count}PCS";
+                                    return $"{qtylist.Count}";
                                 case "GetModel":
                                     return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo?.Model);
                                 case "GetInput":
@@ -620,27 +716,39 @@
                                 case "GetLOTNO":
                                     string _lotnos = "";
                                     var _orderAction = curAction is PackingAction ? curAction as PackingAction : null;
-                                    if (_orderAction != null)
+                                    if (!CurPkg.IsNullOrEmpty())
                                     {
-                                        var snList = _orderAction.CurPkg.Item.GetMinPackageList().Select(q => q.FLOW_SN).ToList();
-                                        if (!snList.Any())
+                                        qtylist = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                    }
+                                    else
+                                    {
+                                        if (_orderAction != null)
                                         {
-                                            snList.Add(_orderAction.CurPkg.CustSN.FLOW_SN);
+                                            var snList = _orderAction.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                                            //if (!snList.Any())
+                                            {
+                                                snList.Add(_orderAction.CurPkg.CustSN?.FLOW_SN);
+                                            }
+                                            _lotnos = string.Join(",", MainDB.Queryable<MES_CUST_SN>()
+                                                .Where((q) => snList.Contains(q.FLOW_SN))
+                                                .Select((q) => q.WORK_ORDER).Distinct().ToList());
+                                            return _lotnos;
                                         }
-                                        _lotnos = string.Join(",", Biz.Db.Queryable<MES_CUST_SN>()
-                                            .Where((q) => snList.Contains(q.FLOW_SN))
-                                            .Select((q) => q.WORK_ORDER).Distinct().ToList());
-                                        return _lotnos;
                                     }
                                     return "";
                                 case "GetNOTES":
-                                    return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo?.Remark); 
+                                    return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo?.Remark);
                                 case "GetXH":
-                                    return GetCardCode(lvars);
+                                    return "";
                                 case "GetCardNo":
-                                    return "";
+                                    return $"{Context.GetOrDefault("CurWaitShipmentCarton").ToInt32() + 1}";
                                 case "GetCardTotal":
-                                    return "";
+                                    var total = "";
+                                    var _curaction = curAction is PackingAction ? curAction as PackingAction : null;
+                                    if (!_curaction.IsNullOrEmpty()) {
+                                        total = $"{Math.Ceiling(Context.GetOrDefault("CurShipQty").ToDecimal()/_curaction.PkgRule.GetTotalQty().ToDecimal())}";
+                                    }
+                                    return total;
                                 case "GetModelSpec": //Model+绌烘牸+SPEC,
                                     return GetLabelVarWo(lv, $"{WorkBatch.Product.ExtInfo?.Model} {WorkBatch.Product.SPEC}");
                                 case "GetDATE":
@@ -678,9 +786,9 @@
                             switch (pv.VAR_METHOD)
                             {
                                 case "GetCartonGenerate":
-                                    return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
+                                    return Cache.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
                                 case "GetHW21SNGenerate":
-                                    return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("SN:", "05").Data.ToString() ?? "";
+                                    return Cache.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("SN:", "05").Data.ToString() ?? "";
                                 default:
                                     return "";
                             }
@@ -700,7 +808,7 @@
         private string GetLabelVarWo(BAS_LABEL_VAR lv, string value)
         {
             string result = "";
-            var labelVarwos = Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == lv.LABEL_ID && x.VAR_NAME == lv.VAR_NAME).ToList();
+            var labelVarwos = MainDB.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == lv.LABEL_ID && x.VAR_NAME == lv.VAR_NAME).ToList();
             if (labelVarwos.Any(q => q.WORK_ORDER == WorkBatch.Batch.ORDER_NO))
             {
                 result = labelVarwos.First(q => q.WORK_ORDER == WorkBatch.Batch.ORDER_NO).VAR_VALUE;
@@ -734,22 +842,19 @@
         /// <summary>
         /// 鑾峰彇鐧界洅鏉$爜
         /// </summary>
-        /// <param name="action"></param>
         /// <returns></returns>
-        private string GetBoxCode(List<BAS_LABEL_VAR> lvars)
+        private string GetBoxCode()
         {
-            return Biz.CodeRule["WhiteBoxNo"]?.Generate("W", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
+            return Cache.CodeRule["WhiteBoxNo"]?.Generate("W", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
         }
 
         /// <summary>
         /// 鑾峰彇绠辨潯鐮�
         /// </summary>
-        /// <param name="lvars"></param>
-        /// <param name="action"></param>
         /// <returns></returns>
-        private string GetCardCode(List<BAS_LABEL_VAR> lvars)
+        private string GetCardCode()
         {
-            return Biz.CodeRule["CartonNo"]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
+            return Cache.CodeRule["CartonNo"]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? "";
         }
 
         /// <summary>
@@ -759,27 +864,39 @@
         /// <param name="lvars"></param>
         /// <param name="action"></param>
         /// <returns></returns>
-        private string GetCardOrBoxQR(string code, IWorkAction action)
+        private string GetCardOrBoxQR(string code, IWorkAction action, WipPkg? CurPkg)
         {
             List<string> minPkgList = new List<string>();
             var itemCode = "";
             double weight = 0;
             var unit = "";
-            if (action is PackingAction)
+            if (!CurPkg.IsNullOrEmpty())
             {
-                var pkg = action as PackingAction;
-                minPkgList = pkg.CurPkg.Item.GetMinPackageList().Select(q => q.SN).ToList();
-                itemCode = pkg.CurPkg.CustSN?.ITEM_CODE;
-                weight = pkg.CurPkg.WeightInfo.Weight;
-                unit = pkg.CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg";
+                minPkgList = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                itemCode = CurPkg.CustSN?.ITEM_CODE;
+                weight = CurPkg.WeightInfo.Weight;
+                unit = CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg";
             }
-            if (action is PrintInStoreLabel)
+            else
             {
-                var print = action as PrintInStoreLabel;
-                minPkgList = print.CurPkg.Item.GetMinPackageList().Select(q => q.SN).ToList();
-                itemCode = print.CurPkg.CustSN?.ITEM_CODE;
-                weight = print.CurPkg.WeightInfo.Weight;
-                unit = print.CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg";
+                if (action is PackingAction)
+                {
+                    var pkg = action as PackingAction;
+                    //minPkgList = pkg.CurPkg.Item.GetMinPackageList().Select(q => q.SN).ToList();
+                    minPkgList = pkg.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                    itemCode = pkg.CurPkg.CustSN?.ITEM_CODE;
+                    weight = pkg.CurPkg.WeightInfo.Weight;
+                    unit = pkg.CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg";
+                }
+                if (action is PrintInStoreLabel)
+                {
+                    var print = action as PrintInStoreLabel;
+                    //minPkgList = print.CurPkg.Item.GetMinPackageList().Select(q => q.SN).ToList();
+                    minPkgList = print.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList();
+                    itemCode = print.CurPkg.CustSN?.ITEM_CODE;
+                    weight = print.CurPkg.WeightInfo.Weight;
+                    unit = print.CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg";
+                }
             }
             var wo = WorkBatch.Batch.ORDER_NO;
             var snList = string.Join("\r\n", minPkgList);
@@ -803,7 +920,7 @@
         private string GetHuaWeiWeek(string pkgOrder, List<string> snList)
         {
             Dictionary<string, string> dic = new();
-            var snOrder = Biz.Db.Queryable<MES_CUST_SN, BIZ_MES_WO>((q, w) => new JoinQueryInfos(JoinType.Left, q.WORK_ORDER == w.ORDER_NO))
+            var snOrder = MainDB.Queryable<MES_CUST_SN, BIZ_MES_WO>((q, w) => new JoinQueryInfos(JoinType.Left, q.WORK_ORDER == w.ORDER_NO))
                                             .Where((q, w) => q.PKG_ORDER == pkgOrder && (snList.Contains(q.FLOW_SN) || snList.Contains(q.CUST_SN)))
                                            .Select((q, w) => new { q.PKG_ORDER, q.WORK_ORDER, w.ACT_START_TIME, w.PLAN_START_TIME, q.FLOW_SN, q.CUST_SN }).ToList();
             foreach (var sn in snList)
@@ -847,7 +964,7 @@
         /// <returns></returns>
         public string GenerateSN(string ruleCode, IWorkAction curAction)
         {
-            var rule = Biz.CodeRule[ruleCode ?? ""];
+            var rule = Cache.CodeRule[ruleCode ?? ""];
             if (!rule.IsNullOrEmpty())
             {
                 switch (rule.RULE_CODE)

--
Gitblit v1.9.3