From c598e4bf57de2b4703d6c0e4d0905c9159273d26 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期二, 06 八月 2024 10:16:18 +0800
Subject: [PATCH] 条码增加托盘批量过站逻辑和包装外箱过站逻辑

---
 Tiger.Business.MES/WorkAction/IPQC.cs |  130 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 111 insertions(+), 19 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/IPQC.cs b/Tiger.Business.MES/WorkAction/IPQC.cs
index c2bec36..2468326 100644
--- a/Tiger.Business.MES/WorkAction/IPQC.cs
+++ b/Tiger.Business.MES/WorkAction/IPQC.cs
@@ -6,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,7 +16,7 @@
     {
         #region Propertys & Variables
         public bool IsFinished { get; set; } = false;
-        public string StepID { get; set; }
+        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; }
@@ -23,20 +24,42 @@
 
         #region Functions
         /// <summary>
-        /// 寮�濮嬫墽琛屽伐搴忚涓�
+        /// 鍒濆鍖栧伐搴忚涓�
         /// </summary>
         /// <returns></returns>
-        public ApiAction<SubmitOutput> Begin(string stepID, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting)
+        public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting)
         {
-            StepID = stepID;
+            CurStep = curStep;
             CurPosition = position;
             NodeAct = nodeAct;
             Setting = setting;
-            var action = new ApiAction<SubmitOutput>();
+        }
+
+        /// <summary>
+        /// 鑾峰彇琛屼负寮�濮嬬殑鎻愮ず淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        public Locale GetBeginMsg()
+        {
+            //var msg = new Locale("MES.WorkAction.IPQC.BeginMsg");
+            var msg = new Locale($"璇锋彁浜ゆ祴璇曠粨鏋�");
+            return msg;
+        }
+
+        /// <summary>
+        /// 灏濊瘯寮�濮嬫墽琛屽伐搴忚涓�
+        /// </summary>
+        /// <returns></returns>
+        public ApiAction<SubmitOutput> TryBegin(SubmitInput input)
+        {
+            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
 
 
-            action.LocaleMsg = new($"璇锋寜娴嬭瘯椤规彁浜ゆ祴璇曟暟鎹�");
-            //action.LocaleMsg = new("MES.WorkAction.IPQC.PleaseTest");
+            //action.LocaleMsg = new($"璇锋寜娴嬭瘯椤规彁浜ゆ祴璇曟暟鎹�");
+            action.LocaleMsg = new("MES.WorkAction.IPQC.PleaseTest");
+
+            //濡傛灉鏍规嵁杈撳叆鍙互寮�濮嬫墽琛屽綋鍓嶈涓哄垯鏍囪涓烘垚鍔燂紝鍚﹀垯澶辫触
+            action.IsSuccessed = false;
             return action;
         }
         /// <summary>
@@ -45,7 +68,32 @@
         /// <returns></returns>
         public ApiAction<SubmitOutput> Submit(SubmitInput input)
         {
-            var action = new ApiAction<SubmitOutput>();
+            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
+
+            //鎻愪氦鏁版嵁鎵ц鎴愬姛
+            if (true)
+            {
+                action.IsSuccessed = true;
+                action.LocaleMsg = new($"鎵ц鎴愬姛");
+                //action.LocaleMsg = new("MES.WorkAction.IPQC.Success");
+                //琛屼负鎵ц瀹屾垚
+                if (false)
+                {
+                	action = End();
+                }
+            }
+            //鎻愪氦鏁版嵁鎵ц澶辫触
+            else
+            {
+                action.IsSuccessed = false;
+                //action.LocaleMsg = new($"鎵ц澶辫触");
+                action.LocaleMsg = new("MES.WorkAction.IPQC.Fail");
+                //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
+                if (NodeAct.NEED_RESET == "Y")
+                {
+                    CurPosition.ResetNode();
+                }
+            }
 
             return action;
         }
@@ -55,20 +103,64 @@
         /// <returns></returns>
         public ApiAction<SubmitOutput> End()
         {
-            var action = new ApiAction<SubmitOutput>();
+            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
 
+            //璁板綍琛屼负鎿嶄綔璁板綍
+            var wipActs = new List<MES_WIP_ACT>();
+            foreach (var wipSn in CurPosition.CurWipSNs)
+            {
+                var wipAct = new MES_WIP_ACT()
+                {
+                    AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG,
+                    AUTH_PROD = CurPosition.CurLine.LINE_CODE,
+                    HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID,
+                    SN = wipSn.SN,
+                    STATUS = wipSn.STATUS,
+                    ITEM_CODE = wipSn.ITEM_CODE,
+                    WORK_ORDER = wipSn.WORK_ORDER,
+                    BATCH_NO = wipSn.BATCH_NO,
+                    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,
+                    TRAY_SN = wipSn.TRAY_SN,
+                    OPERATION_TIME = DateTime.Now,
+                    SFTS_CODE = wipSn.SFTS_CODE,
+                    SFT_CODE = wipSn.SFT_CODE,
+                    PRD_CODE = wipSn.PRD_CODE,
+                    ACT_TYPE = NodeAct.ACT_TYPE,
+                    ACT_SN = wipSn.SN,
+                    ACT_VALUE_1 = "",
+                    ACT_VALUE_2 = "",
+                    ACT_VALUE_3 = "",
+                    ACT_VALUE_4 = "",
+                    ACT_VALUE_5 = "",
+                    ACT_RESULT = "Y",
+                    TRACE_INFO = $"鎵ц鎴愬姛",
+                };
+                wipActs.Add(wipAct);
+            }
+
+            //淇濆瓨鏁版嵁
+            CurStep.DBSubmitAction = () =>
+            {
+                var db = CurPosition.GetCommitDB();
+                db.Storageable(wipActs, CurPosition.UserCode).ExecuteCommand();
+            };
+
+            IsFinished = true;
+            action.LocaleMsg = new($"琛屼负缁撴潫");
+            //action.LocaleMsg = new("MES.WorkAction.IPQC.Finish");
             return action;
         }
-        /// <summary>
-        /// 鑾峰彇琛屼负鎻愮ず淇℃伅
-        /// </summary>
-        /// <returns></returns>
-        public ApiAction GetPrompt()
-        {
-            var action = new ApiAction();
-            action.LocaleMsg = new($"寮�濮嬫墦鍗版潯鐮�");
-            return action;
-        }
+
 
         #endregion Functions
     }

--
Gitblit v1.9.3