From 04dcc3ed97efac23ec778dec4a6afddc6cd9aa65 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期五, 16 八月 2024 00:41:22 +0800
Subject: [PATCH] 包装行为增加称重功能

---
 Tiger.Api/Language.db                                            |    0 
 Tiger.Business.MES/Transaction/CollectNode.cs                    |    1 
 Tiger.Business.MES/Transaction/PackingNode.cs                    |    1 
 Tiger.Business.MES/WorkAction/PackingAction.cs                   |  132 +++++++++++++++++++++++++++++--------------
 Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs |    8 ++
 5 files changed, 97 insertions(+), 45 deletions(-)

diff --git a/Tiger.Api/Language.db b/Tiger.Api/Language.db
index 9d3c9d3..e57407c 100644
--- a/Tiger.Api/Language.db
+++ b/Tiger.Api/Language.db
Binary files differ
diff --git a/Tiger.Business.MES/Transaction/CollectNode.cs b/Tiger.Business.MES/Transaction/CollectNode.cs
index 4856df7..00ec0b6 100644
--- a/Tiger.Business.MES/Transaction/CollectNode.cs
+++ b/Tiger.Business.MES/Transaction/CollectNode.cs
@@ -280,6 +280,7 @@
                             {
                                 AUTH_ORG = wipSN.AUTH_ORG,
                                 AUTH_PROD = wipSN.LINE_CODE,
+                                WIP_ID = wipSN.ID,
                                 SN = wipSN.SN,
                                 STATUS = MES_WIP_DFT.STATUSs.WaitHandle.GetValue(),
                                 ITEM_CODE = wipSN.ITEM_CODE,
diff --git a/Tiger.Business.MES/Transaction/PackingNode.cs b/Tiger.Business.MES/Transaction/PackingNode.cs
index e66574b..af22a2f 100644
--- a/Tiger.Business.MES/Transaction/PackingNode.cs
+++ b/Tiger.Business.MES/Transaction/PackingNode.cs
@@ -311,6 +311,7 @@
                             {
                                 AUTH_ORG = wipSN.AUTH_ORG,
                                 AUTH_PROD = wipSN.LINE_CODE,
+                                WIP_ID = wipSN.ID,
                                 SN = wipSN.SN,
                                 STATUS = MES_WIP_DFT.STATUSs.WaitHandle.GetValue(),
                                 ITEM_CODE = wipSN.ITEM_CODE,
diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs
index 683dc42..4c47c62 100644
--- a/Tiger.Business.MES/WorkAction/PackingAction.cs
+++ b/Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -32,6 +32,7 @@
         public Dictionary<int, BAS_LABEL_TEMP> LabelDic { get; set; }    = new();
         public List<BAS_LABEL_PV> LabelPV { get; set; } = new();
         public int FinishLevel = 0;
+        public bool NeedWeighing { get; set; } = false;
         #endregion Propertys & Variables
 
         #region Functions
@@ -65,6 +66,8 @@
                 LabelDic.Add(code.PKG_LEVEL, label);
             }
             LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList();
+            //鑾峰彇鏄惁鍖呰瀹屽悗闇�瑕佺О閲�
+            NeedWeighing = Setting.OPTION_2 == "Y";
             //濡傛灉宸ュ簭涓婁笅鏂囦腑娌℃湁鍖呰璁板綍鍒欐柊寤轰竴涓紝鏈夊垯鑾峰彇褰撳墠鐨勫寘瑁呰褰�
             if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty())
             {
@@ -267,7 +270,41 @@
                     {
                         CurCmd = null;
                         PrintTimes = 0;
-                        action = End();
+                        if (NeedWeighing)
+                        {
+                            var data = new PackingActionOutput() { PkgInfo = CurPkg };
+                            data.ExecCode = "Weighing";
+                            data.PkgLevel = CurPkgItem.PKG_LEVEL;
+                            CurCmd = data;
+                            action.Data.Data = data;
+                            //action.LocaleMsg = new($"璇锋妸鍖呰[{CurPkgItem.Package.SN}]涓婄О绉伴噸");
+                            action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighing", CurPkgItem.Package.SN);
+                        }
+                        else
+                        {
+                            action = End();
+                        }
+                    }
+                    break;
+                // Complete锛氬畬鎴愶紝瀹屾垚鍏ㄩ儴鍖呰鍚庣粨鏉熻涓�
+                case "Weighing":
+                    if (CurCmd.ExecCode == "Weighing")
+                    {
+                        if (!pInput.WeightInfo.IsNullOrEmpty() && pInput.WeightInfo.Weight > 0)
+                        {
+                            CurCmd = null;
+                            PrintTimes = 0;
+                            CurPkgItem.Package.WEIGHT = pInput.WeightInfo.Weight;
+                            CurPkgItem.Package.WEIGHT_UNIT = pInput.WeightInfo.Unit;
+                            action = End();
+                        }
+                        else
+                        {
+                            action.IsSuccessed = false;
+                            //action.LocaleMsg = new($"鍖呰[{CurPkgItem.Package.SN}]绉伴噸鏁版嵁寮傚父锛岃閲嶆柊涓婄О绉伴噸");
+                            action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighingAgain", CurPkgItem.Package.SN);
+                            return action;
+                        }
                     }
                     break;
                 // 鎵嬪姩缁撴潫鍖呰锛屼繚瀛樻殏瀛樼殑鍖呰鏁版嵁
@@ -529,10 +566,10 @@
             action.LocaleMsg = new("MES.WorkAction.PackingAction.PackageComplete", CurPkg.Item.PKG_LEVEL, CurPkg.Item.PKG_NAME);
 
             //鎵嬪姩缁撴潫鍖呰鍒欐爣璁拌涓哄畬鎴�
-            if (CurStep.IsNullOrEmpty())
-            {
-                IsFinished = true;
-            }
+            //if (CurStep.IsNullOrEmpty())
+            //{
+            //    IsFinished = true;
+            //}
 
             return action;
         }
@@ -547,45 +584,49 @@
 
             //璁板綍琛屼负鎿嶄綔璁板綍
             var wipActs = new List<MES_WIP_ACT>();
-            foreach (var wipSn in CurPosition.CurWipSNs)
+            //涓嶆槸鎵嬪姩缁撴潫鍖呰鍒欎繚瀛樿涓烘搷浣滆褰�
+            if (!CurStep.IsNullOrEmpty())
             {
-                var wipAct = new MES_WIP_ACT()
-                {
-                    AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG,
-                    AUTH_PROD = CurPosition.CurLine.LINE_CODE,
-                    WIP_ID = wipSn.ID,
-                    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,
-                    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,
-                    ACT_TYPE = NodeAct.ACT_TYPE,
-                    ACT_SN = wipSn.SN,
-                    ACT_RESULT = "Y",
-                    TRACE_INFO = $"浜у搧鏉$爜[{string.Join("锛�", CurPosition.CurSN)}]鍖呰瀹屾垚",
-                };
-                wipActs.Add(wipAct);
+	            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,
+	                    WIP_ID = wipSn.ID,
+	                    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,
+	                    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,
+	                    ACT_TYPE = NodeAct.ACT_TYPE,
+	                    ACT_SN = wipSn.SN,
+	                    ACT_RESULT = "Y",
+	                    TRACE_INFO = $"浜у搧鏉$爜[{string.Join("锛�", CurPosition.CurSN)}]鍖呰瀹屾垚",
+	                };
+	                wipActs.Add(wipAct);
+	            }
             }
 
             //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊�
@@ -595,7 +636,10 @@
             CurStep.DBSubmitAction = () =>
             {
                 var db = CurPosition.GetCommitDB();
-                db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand();
+                if (_wipActs.Any())
+                {
+                	db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand();
+                }
                 if (_pkgList.Any())
                 {
                     db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand();
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
index 7e85a3f..fb7cf93 100644
--- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
@@ -107,7 +107,8 @@
         /// 鍖呰琛屼负褰撳墠鎵ц鐨勬搷浣滀唬鐮侊紝鍖呮嫭锛�<br/>
         /// Scan锛氭壂鐮侊紝鎵弿褰撳墠鍖呰灞傜骇鐨勬潯鐮�<br/>
         /// Print锛氭墦鍗帮紝鎵撳嵃褰撳墠鍖呰灞傜骇鐨勬爣绛�<br/>
-        /// Complete锛氬畬鎴愶紝瀹屾垚鍏ㄩ儴鍖呰鍚庣粨鏉熻涓�<br/>
+        /// Complete锛氬畬鎴愶紝瀹屾垚鍏ㄩ儴鍖呰<br/>
+        /// Weighing锛氱О閲嶏紝瀹屾垚鍖呰鍚庡鏁翠釜鍖呰鎴愮О閲�<br/>
         /// </summary>
         public string ExecCode { get; set; }
         /// <summary>
@@ -122,6 +123,10 @@
         /// 褰撳墠鎿嶄綔鐨勫寘瑁呭眰绾х殑鏍囩鏉$爜
         /// </summary>
         public string PkgSN { get; set; }
+        /// <summary>
+        /// 褰撳墠鎿嶄綔鐨勫寘瑁呭眰绾х殑閲嶉噺淇℃伅
+        /// </summary>
+        public WeightInfo WeightInfo { get; set; }
     }
 
     public class PackingActionOutput
@@ -132,6 +137,7 @@
         /// Scan锛氭壂鐮侊紝鎵弿褰撳墠鍖呰灞傜骇鐨勬潯鐮�<br/>
         /// Print锛氭墦鍗帮紝鎵撳嵃褰撳墠鍖呰灞傜骇鐨勬爣绛�<br/>
         /// Complete锛氬畬鎴愶紝宸蹭繚瀛樺寘瑁呮暟鎹�<br/>
+        /// Weighing锛氱О閲嶏紝瀹屾垚鍖呰鍚庡鏁翠釜鍖呰鎴愮О閲�<br/>
         /// </summary>
         public string ExecCode { get; set; }
         /// <summary>

--
Gitblit v1.9.3