服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-10-29 83d595aad854a42d6b28f8651ee7ef774dfd4e04
Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
@@ -25,7 +25,8 @@
        #endregion
        public BAS_LABEL_TEMP Label { get; set; }
        public List<BAS_LABEL_PV> LabelPV { get; set; }
        public bool NoNeedPrint { get; set; }
        public WipPkg CurPkg { get; set; }
        public bool NoNeedInStorePrint { get; set; }
        #endregion Propertys & Variables
        #region Functions
@@ -55,7 +56,7 @@
        /// <returns></returns>
        public Locale GetBeginMsg()
        {
            var msg = new Locale("MES.WorkAction.PrintInStoreLabel.BeginMsg", CurPosition.CurSN, Label.LABEL_CODE, Label.LABEL_NAME);
            var msg = new Locale("MES.WorkAction.PrintInStoreLabel.BeginMsg", CurPosition.CurSN, Label?.LABEL_CODE, Label?.LABEL_NAME);
            //var msg = new Locale($"开始打印条码[{CurPosition.CurWipSN.SN}]的入库标签[{Label.LABEL_CODE}: {Label.LABEL_NAME}]");
            return msg;
        }
@@ -67,10 +68,9 @@
        public ApiAction<SubmitOutput> TryBegin(SubmitInput input)
        {
            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
            CurPkg = CurPosition.Context.ContainsKey("CurPackage") ? CurPosition.Context["CurPackage"] as WipPkg : null;
            NoNeedPrint = (!CurPosition.Context.ContainsKey("CurPackage") || !(CurPosition.Context["CurPackage"] as WipPkg).IsFinished)
                                    || (CurPosition is YadaPacking && (CurPosition as YadaPacking).IsPrintCustomerLabel);
            if (NoNeedPrint)
            if (Label.IsNullOrEmpty())
            {
                action = End(input);
            } 
@@ -78,13 +78,29 @@
            {
               //设置打印变量值
               Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
               action.Data.Data = Label;
               if (!CurPkg.IsNullOrEmpty())
               {
                    CurPkg.InStoreActID = NodeAct.ID;
                    CurPkg.InStoreLabel = Label;
               }
   
               //如果返回成功则认为当前行为可以开始执行,否则返回失败
               CurStep.Message = Biz.L("打印开始");
               CurStep.Status = StepStatus.Normal;
               action.IsSuccessed = true;
               action.Data.ShortMsg = new("打印开始", ShortMessage.Types.Success);
               //判断是否需要打印入库标签
               NoNeedInStorePrint = (CurPkg.IsNullOrEmpty() || !CurPkg.IsFinished)
                                       || (CurPosition is YadaPacking && (CurPosition as YadaPacking).IsPrintCustomerLabel);
               if (NoNeedInStorePrint)
               {
                   action = End(input);
               }
               else
               {
                  action.Data.Data = Label;
                  //如果返回成功则认为当前行为可以开始执行,否则返回失败
                  CurStep.Message = Biz.L("打印开始");
                  CurStep.Status = StepStatus.Normal;
                  action.IsSuccessed = true;
                  action.Data.ShortMsg = new("打印开始", ShortMessage.Types.Success);
               }
            }
            return action;
        }
@@ -109,7 +125,7 @@
                action.Data.ShortMsg = new("打印失败", ShortMessage.Types.Failed);
                action.IsSuccessed = false;
                //action.LocaleMsg = new($"入库标签{Label.LABEL_NAME}[{Label.LABEL_CODE}]打印失败", Label.LABEL_NAME);
                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintFail", Label.LABEL_NAME, Label.LABEL_CODE);
                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintFail", Label?.LABEL_NAME, Label?.LABEL_CODE);
                //如果行为设置为出错需要重置工序操作
                if (NodeAct.NEED_RESET == "Y")
                {
@@ -163,11 +179,13 @@
                    PRD_CODE = wipSn.PRD_CODE,
                    ACT_TYPE = NodeAct.ACT_TYPE,
                    ACT_SN = wipSn.SN,
                    ACT_VALUE_1 = Label.LABEL_CODE,
                    ACT_VALUE_2 = Label.Variables.ToJson(),
                    ACT_VALUE_1 = CurPkg?.IsFinished == true ? "Y" : "N",
                    ACT_VALUE_2 = CurPkg?.ToJson(),
                    ACT_VALUE_3 = Label?.ToJson(),
                    ACT_VALUE_4 = "InStroe",
                    ACT_RESULT = "Y",
                    ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
                    TRACE_INFO = NoNeedPrint ? $"无需打印入库标签" : $"标签{Label.LABEL_NAME}[{Label.LABEL_CODE}]打印成功",
                    TRACE_INFO = NoNeedInStorePrint ? $"无需打印入库标签" : $"标签{Label?.LABEL_NAME}[{Label?.LABEL_CODE}]打印成功",
                };
                wipActs.Add(wipAct);
            }
@@ -182,13 +200,13 @@
            };
            IsFinished = true;
            if (NoNeedPrint)
            if (NoNeedInStorePrint)
            {
                CurStep.Message = Biz.L("无需打印");
                CurStep.Status = StepStatus.Finished;
                action.Data.ShortMsg = new("无需打印", ShortMessage.Types.Success);
                //action.LocaleMsg = new($"无需打印入库标签{0}[{1}]");
                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.NoNeedPrint", Label.LABEL_NAME, Label.LABEL_CODE);
                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.NoNeedPrint", Label?.LABEL_NAME, Label?.LABEL_CODE);
            } 
            else
            {
@@ -196,7 +214,7 @@
               CurStep.Status = StepStatus.Finished;
               action.Data.ShortMsg = new("打印完成", ShortMessage.Types.Success);
                //action.LocaleMsg = new($"入库标签{0}[{1}打印成功");
                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintSuccess", Label.LABEL_NAME, Label.LABEL_CODE);
                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintSuccess", Label?.LABEL_NAME, Label?.LABEL_CODE);
            }
            return action;
        }