From 0fdd0687f116ac43f7432227dfaa2ebc2f696575 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期日, 04 八月 2024 17:21:11 +0800
Subject: [PATCH] 增加扩展信息绑定工序

---
 Tiger.Business.MES/WorkAction/PrintLabel.cs |   73 +++++++-----------------------------
 1 files changed, 14 insertions(+), 59 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PrintLabel.cs b/Tiger.Business.MES/WorkAction/PrintLabel.cs
index 9d869bf..8f33876 100644
--- a/Tiger.Business.MES/WorkAction/PrintLabel.cs
+++ b/Tiger.Business.MES/WorkAction/PrintLabel.cs
@@ -1,5 +1,4 @@
-锘縰sing MailKit.Search;
-using Rhea.Common;
+锘縰sing Rhea.Common;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -7,6 +6,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using Tiger.IBusiness;
+using Tiger.IBusiness.MES.WorkAction;
 using Tiger.Model;
 using Tiger.Model.Entitys.MES.Position;
 
@@ -15,11 +15,13 @@
     public class PrintLabel : IPrintLabel
     {
         #region Propertys & Variables
+        #region 鍥哄畾鍐欐硶锛屽伐搴忎腑鐨勫繀瑕佷俊鎭�
         public bool IsFinished { get; set; } = false;
         public IWorkStep CurStep { get; set; }
         public IPosition CurPosition { get; set; }
         public MES_WO_NODE_ACT NodeAct { get; set; }
         public MES_WO_ACTION Setting { get; set; }
+        #endregion
         public BAS_LABEL_TEMP Label { get; set; }
         public List<BAS_LABEL_PV> LabelPV { get; set; }
         #endregion Propertys & Variables
@@ -31,10 +33,12 @@
         /// <returns></returns>
         public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting)
         {
+            #region 鍥哄畾鍐欐硶锛岀粰榛樿鍙橀噺璧嬪��
             CurStep = curStep;
             CurPosition = position;
             NodeAct = nodeAct;
             Setting = setting;
+            #endregion
 
             Label = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First();
             LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList();
@@ -57,30 +61,13 @@
         /// <returns></returns>
         public ApiAction<SubmitOutput> TryBegin(SubmitInput input)
         {
-            var action = new ApiAction<SubmitOutput>();
-            
-            foreach (var item in Label.Variables)
-            {
-                switch (item.VAR_TYPE.GetEnum<BAS_LABEL_VAR.VAR_TYPEs>())
-                {
-                    case BAS_LABEL_VAR.VAR_TYPEs.Constant:
-                        item.Value = item.VAR_VALUE;
-                        break;
-                    case BAS_LABEL_VAR.VAR_TYPEs.ProcessVariable:
-                        item.Value = GetProcessValue(item);
-                        break;
-                    case BAS_LABEL_VAR.VAR_TYPEs.DateVariable:
-                        item.Value = DateTime.Now.ToString(item.VAR_VALUE);
-                        break;
-                    case BAS_LABEL_VAR.VAR_TYPEs.CustomVariable:
-                    default:
-                        item.Value = "";
-                        break;
-                }
-            }
+            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
+
+            //璁剧疆鎵撳嵃鍙橀噺鍊�
+            Label = CurPosition.SetLabelVariables(LabelPV, Label);
             action.Data.Data = Label;
 
-            //濡傛灉鏍规嵁杈撳叆鍙互寮�濮嬫墽琛屽綋鍓嶈涓哄垯鏍囪涓烘垚鍔燂紝鍚﹀垯澶辫触
+            //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
             action.IsSuccessed = true;
             return action;
         }
@@ -91,7 +78,7 @@
         /// <returns></returns>
         public ApiAction<SubmitOutput> Submit(SubmitInput input)
         {
-            var action = new ApiAction<SubmitOutput>();
+            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
             //鎻愪氦鏁版嵁鎵ц鎴愬姛
             if (input.Data.ToBoolean())
             {
@@ -106,7 +93,7 @@
                 //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
                 if (NodeAct.NEED_RESET == "Y")
                 {
-                    CurPosition.ResetSteps();
+                    CurPosition.ResetNode();
                 }
             }
             return action;
@@ -117,7 +104,7 @@
         /// <returns></returns>
         public ApiAction<SubmitOutput> End()
         {
-            var action = new ApiAction<SubmitOutput>();
+            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
 
             //璁板綍琛屼负鎿嶄綔璁板綍
             var wipAct = new MES_WIP_ACT()
@@ -165,38 +152,6 @@
             //action.LocaleMsg = new($"鏍囩{Label.LABEL_NAME}[{Label.LABEL_CODE}]鎵撳嵃鎴愬姛", Label.LABEL_NAME);
             action.LocaleMsg = new("MES.WorkAction.PrintLabel.PrintSuccess", Label.LABEL_NAME, Label.LABEL_CODE);
             return action;
-        }
-
-        public string GetProcessValue(BAS_LABEL_VAR lv)
-        {
-            var pv = LabelPV.FirstOrDefault(q => q.VAR_CODE == lv.VAR_VALUE);
-            if (!pv.IsNullOrEmpty())
-            {
-                switch (pv.VAR_TYPE.GetEnum<BAS_LABEL_PV.VAR_TYPEs>())
-                {
-                    case BAS_LABEL_PV.VAR_TYPEs.ServerMethod:
-                        {
-                            switch (pv.VAR_METHOD)
-                            {
-                                case "GetSN":
-                                    return CurPosition.CurWipSN.SN;
-                                case "GetBAS_ITEM":
-                                    return CurPosition.WorkBatch.Product.ToJson();
-                                case "GetCustomer":
-                                    return CurPosition.WorkBatch.Batch.ToJson();
-                                default:
-                                    return "";
-                            }
-                        }
-                    case BAS_LABEL_PV.VAR_TYPEs.WebApiWebApi:
-                        break;
-                    case BAS_LABEL_PV.VAR_TYPEs.StoredProcedure:
-                        break;
-                    default:
-                        break;
-                }
-            }
-            return "action";
         }
 
         #endregion Functions

--
Gitblit v1.9.3