From 6738bfc4d55d8948e87cd78a2341cf4f988431f8 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期一, 20 五月 2024 15:13:14 +0800
Subject: [PATCH] Smt上料一些更新

---
 Tiger.Business/MES/Transaction/LoadingMaterial.cs               |  111 +++++++++++++++++++++++++++++++++---
 Tiger.Model.Net/Tiger.Model.Net.csproj                          |    2 
 Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs                    |   10 ---
 Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingInput.cs  |   20 ++++++
 Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingReturn.cs |   20 ++++++
 5 files changed, 142 insertions(+), 21 deletions(-)

diff --git a/Tiger.Business/MES/Transaction/LoadingMaterial.cs b/Tiger.Business/MES/Transaction/LoadingMaterial.cs
index 7a66e1c..1eeda4b 100644
--- a/Tiger.Business/MES/Transaction/LoadingMaterial.cs
+++ b/Tiger.Business/MES/Transaction/LoadingMaterial.cs
@@ -63,6 +63,43 @@
             SN,
         }
 
+        /// <summary>
+        /// 瀹屾垚鐘舵��
+        /// </summary>
+        public enum Statuss
+        {
+            /// <summary>
+            /// 鎵弿鏈哄櫒缂栫爜瀹屾垚
+            /// </summary>
+            [Description("鏈哄櫒缂栫爜瀹屾垚")]
+            SmtCodeOK,
+            /// <summary>
+            /// 鎵弿妲戒綅瀹屾垚
+            /// </summary>
+            [Description("妲戒綅瀹屾垚")]
+            SlotNoOK,
+            /// <summary>
+            /// 鎵弿椋炶揪瀹屾垚
+            /// </summary>
+            [Description("Feeder瀹屾垚")]
+            FeederOK,
+            /// <summary>
+            /// 鎵弿鏂欑洏SN瀹屾垚
+            /// </summary>
+            [Description("鏂欑洏鐮佸畬鎴�")]
+            SnOK,
+            /// <summary>
+            /// 褰撳墠鏈哄櫒瀹屾垚
+            /// </summary>
+            [Description("褰撳墠鏈哄櫒瀹屾垚")]
+            CurrCompleted,
+            /// <summary>
+            /// 鍏ㄩ儴瀹屾垚
+            /// </summary>
+            [Description("鍏ㄩ儴瀹屾垚")]
+            Completed,
+        }
+
         #endregion Propertys & Variables
 
         #region Functions
@@ -72,9 +109,9 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public async Task<ApiAction> ScanItem(SmtLoadingInput input)
+        public async Task<ApiAction<SmtLoadingReturn>> ScanItem(SmtLoadingInput input)
         {
-            var action = new ApiAction();
+            var action = new ApiAction<SmtLoadingReturn>();
             try
             {
                 if (input.Code.IsNullOrEmpty())
@@ -100,6 +137,7 @@
                         action = ExecuteSN(input);
                         break;
                 }
+                if (!action.IsSuccessed) { return action; }
 
                 //02淇濆瓨涓婃枡鏁版嵁
 
@@ -156,8 +194,14 @@
             return action;
         }
 
-        private ApiAction ExecuteSmtCode(SmtLoadingInput input) {
-            var action = new ApiAction();
+        /// <summary>
+        /// 鎵弿鏈哄櫒缂栫爜鎿嶄綔
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        private ApiAction<SmtLoadingReturn> ExecuteSmtCode(SmtLoadingInput input) {
+            var action = new ApiAction<SmtLoadingReturn>();
+            SmtLoadingReturn loadingReturn = new();
             try
             {
                 if (Biz.Db.Queryable<SMT_WO_TABLE>().Where(x => x.WORK_ORDER == input.moCode && x.LINE_CODE == input.lineCode && x.PROD_CODE == input.prodCode && x.SMT_CODE == input.Code).Any())
@@ -165,12 +209,16 @@
                     CurrSmtCode = input.Code;
                     action.IsSuccessed = true;
                     action.LocaleMsg = Biz.L($"鏈哄櫒缂栫爜楠岃瘉閫氳繃锛�");
+                    loadingReturn.SmtCode = CurrSmtCode;
+                    loadingReturn.Step = (int)Step_Types.SmtCode;
+                    loadingReturn.Status = (int)Statuss.SmtCodeOK;
                 }
                 else
                 {
                     action.IsSuccessed = false;
                     action.LocaleMsg = Biz.L($"鏂欑珯琛ㄤ腑涓嶅瓨鍦ㄦ鏈哄櫒缂栫爜锛岃纭鏂欑珯琛ㄦ槸鍚︽纭笂浼狅紒");
                 }
+                action.Data = loadingReturn;
             }
             catch (Exception ex)
             {
@@ -179,9 +227,15 @@
             return action;
         }
 
-        private ApiAction ExecuteSlotNo(SmtLoadingInput input)
+        /// <summary>
+        /// 鎵弿妲戒綅鎿嶄綔
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        private ApiAction<SmtLoadingReturn> ExecuteSlotNo(SmtLoadingInput input)
         {
-            var action = new ApiAction();
+            var action = new ApiAction<SmtLoadingReturn>();
+            SmtLoadingReturn loadingReturn = new();
             try
             {
                 if (Biz.Db.Queryable<SMT_WO_TABLE>().Where(x => x.WORK_ORDER == input.moCode && x.LINE_CODE == input.lineCode && x.PROD_CODE == input.prodCode && x.SMT_CODE == CurrSmtCode && x.SLOT_NO == input.Code).Any())
@@ -189,12 +243,18 @@
                     CurrSlotNo = input.Code;
                     action.IsSuccessed = true;
                     action.LocaleMsg = Biz.L($"妲戒綅楠岃瘉閫氳繃锛�");
+                    loadingReturn.SmtCode = CurrSmtCode;
+                    loadingReturn.SlotNo = CurrSlotNo;
+                    loadingReturn.Step = (int)Step_Types.SlotNo;
+                    loadingReturn.Status = (int)Statuss.SlotNoOK;
+                    loadingReturn.LoadingCount = Biz.Db.Queryable<SMT_LOADING>().Where(x=> x.WORK_ORDER == input.moCode && x.LINE_CODE == input.lineCode && x.PROD_CODE == input.prodCode && x.SMT_CODE == CurrSmtCode && x.SLOT_NO == input.Code).Count();
                 }
                 else
                 {
                     action.IsSuccessed = false;
                     action.LocaleMsg = Biz.L($"姝ゆЫ浣峓{input.Code}]涓嶅瓨鍦ㄦ垨鏂欑珯琛ㄦ湭涓婁紶锛�");
                 }
+                action.Data = loadingReturn;
             }
             catch (Exception ex)
             {
@@ -203,12 +263,36 @@
             return action;
         }
 
-        private ApiAction ExecuteFeeder(SmtLoadingInput input)
+        /// <summary>
+        /// 鎵弿椋炶揪鎿嶄綔
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        private ApiAction<SmtLoadingReturn> ExecuteFeeder(SmtLoadingInput input)
         {
-            var action = new ApiAction();
+            var action = new ApiAction<SmtLoadingReturn>();
             try
             {
-
+                var _feeder = Biz.Db.Queryable<SMT_FEEDER>().Where(x => x.FEEDER_CODE == input.Code).First();
+                //妫�鏌ラ杈句繚鍏荤淮鎶ゆ儏鍐�
+                if (_feeder.FEEDER_TYPE.IsNullOrEmpty())
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"姝ら杈綶{input.Code}]鏈淮鎶ょ被鍨嬩俊鎭紒");
+                    return action;
+                }
+                if (_feeder.FEEDER_TYPE != input.feederType)
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"姝ら杈綶{input.Code}]Feeder绫诲瀷涓嶄竴鑷达紒瑕佹眰鐨勭被鍨嬶細[{_feeder.FEEDER_TYPE}]锛涘綋鍓岶eeder鐨勭被鍨嬶細[{input.feederType}]");
+                    return action;
+                }
+                if (_feeder.USED_COUNT >= _feeder.MAX_COUNT)
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"姝ら杈綶{input.Code}]宸茶揪鏈�澶т娇鐢ㄦ鏁帮紝璇蜂繚鍏诲悗鍐嶄娇鐢紒");
+                    return action;
+                }
             }
             catch (Exception ex)
             {
@@ -217,9 +301,14 @@
             return action;
         }
 
-        private ApiAction ExecuteSN(SmtLoadingInput input)
+        /// <summary>
+        /// 鎵弿鐗╂枡鏉$爜鎿嶄綔
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        private ApiAction<SmtLoadingReturn> ExecuteSN(SmtLoadingInput input)
         {
-            var action = new ApiAction();
+            var action = new ApiAction<SmtLoadingReturn>();
             try
             {
 
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingInput.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingInput.cs
new file mode 100644
index 0000000..680d8c5
--- /dev/null
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingInput.cs
@@ -0,0 +1,20 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tiger.Model
+{
+
+    public class SmtLoadingInput : BaseCodeInput
+    {
+        public int Step { get; set; }
+        public string prodCode { get; set; }
+        public string lineCode { get; set; }
+        public string pcbSurface { get; set; }
+        public string moCode { get; set; }
+        public string machineCode { get; set; }
+        public string feederType { get; set; }
+    }
+}
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingReturn.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingReturn.cs
new file mode 100644
index 0000000..bf5b5f5
--- /dev/null
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/SmtLoadingReturn.cs
@@ -0,0 +1,20 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tiger.Model
+{
+
+    public class SmtLoadingReturn
+    {
+        public int Step { get; set; }
+        public string SmtCode { get; set; }
+        public string SlotNo { get; set; }
+        public List<string> ItemCodes { get; set; }
+        public int LoadingCount { get; set; }
+        public string FeederType { get; set; }
+        public int Status { get; set; }
+    }
+}
diff --git a/Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs b/Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs
index dfcaaee..8742361 100644
--- a/Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs
+++ b/Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs
@@ -50,14 +50,4 @@
     {
         public bool IsItemCodeList { get; set; }
     }
-
-    public class SmtLoadingInput : BaseCodeInput
-    {
-        public int Step { get; set; }
-        public string prodCode { get; set; }
-        public string lineCode { get; set; }
-        public string pcbSurface { get; set; }
-        public string moCode { get; set; }
-        public string machineCode { get; set; }
-    }
 }
\ No newline at end of file
diff --git a/Tiger.Model.Net/Tiger.Model.Net.csproj b/Tiger.Model.Net/Tiger.Model.Net.csproj
index 9805eb6..4caf9bb 100644
--- a/Tiger.Model.Net/Tiger.Model.Net.csproj
+++ b/Tiger.Model.Net/Tiger.Model.Net.csproj
@@ -109,6 +109,8 @@
     <Compile Include="Entitys\MES\MES_WIP_DATA.cs" />
     <Compile Include="Entitys\MES\MES_WIP_HIS.cs" />
     <Compile Include="Entitys\MES\node.cs" />
+    <Compile Include="Entitys\MES\ParameterEntity\SmtLoadingReturn.cs" />
+    <Compile Include="Entitys\MES\ParameterEntity\SmtLoadingInput.cs" />
     <Compile Include="Entitys\MES\R_Wip_Tracking_T.cs" />
     <Compile Include="Entitys\MES\SMT_FEEDER.cs" />
     <Compile Include="Entitys\MES\SMT_FEEDER_TYPE.cs" />

--
Gitblit v1.9.3