From 93427767c06fbe2437abb4389af649c0a9bb3546 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期三, 15 五月 2024 16:53:21 +0800
Subject: [PATCH] smt上料更新

---
 Tiger.IBusiness/MES/SMT/ISmtTool.cs               |    2 
 Tiger.Business/MES/Transaction/LoadingMaterial.cs |   84 +++++++++++++++++++++++++++++++++++-------
 Tiger.Business/MES/SMT/Biz.SmtTool.cs             |    2 
 Tiger.Api/Controllers/MES/SMTController.Tool.cs   |    2 
 Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs      |    5 ++
 Tiger.Model.Net/Entitys/MES/SMT_WO_TABLE.cs       |    8 ----
 6 files changed, 78 insertions(+), 25 deletions(-)

diff --git a/Tiger.Api/Controllers/MES/SMTController.Tool.cs b/Tiger.Api/Controllers/MES/SMTController.Tool.cs
index 7f6bcc9..2eefb3e 100644
--- a/Tiger.Api/Controllers/MES/SMTController.Tool.cs
+++ b/Tiger.Api/Controllers/MES/SMTController.Tool.cs
@@ -15,7 +15,7 @@
         /// <returns></returns>
         [HttpPost]
         [Route("api/[controller]/[action]")]
-        public async Task<IActionResult> GetNotLoadingMaterial([FromBody] ApiAction<smtWoTableParams> action)
+        public async Task<IActionResult> GetNotLoadingMaterial([FromBody] ApiAction<SmtLoadingInput> action)
         {
             ApiAction response = new();
             try
diff --git a/Tiger.Business/MES/SMT/Biz.SmtTool.cs b/Tiger.Business/MES/SMT/Biz.SmtTool.cs
index a9cccb2..c40ddbf 100644
--- a/Tiger.Business/MES/SMT/Biz.SmtTool.cs
+++ b/Tiger.Business/MES/SMT/Biz.SmtTool.cs
@@ -28,7 +28,7 @@
             /// </summary>
             /// <param name="paras"></param>
             /// <returns></returns>
-            public async Task<ApiAction<List<SMT_WO_TABLE>>> GetNotLoadingMaterial(smtWoTableParams paras)
+            public async Task<ApiAction<List<SMT_WO_TABLE>>> GetNotLoadingMaterial(SmtLoadingInput paras)
             {
                 var res = new ApiAction<List<SMT_WO_TABLE>>();
                 List<SMT_WO_TABLE> sList = new List<SMT_WO_TABLE>();
diff --git a/Tiger.Business/MES/Transaction/LoadingMaterial.cs b/Tiger.Business/MES/Transaction/LoadingMaterial.cs
index 48331bf..7a66e1c 100644
--- a/Tiger.Business/MES/Transaction/LoadingMaterial.cs
+++ b/Tiger.Business/MES/Transaction/LoadingMaterial.cs
@@ -34,8 +34,8 @@
         public string UserCode { get; set; }
         public long UserId { get; set; }
         public string OrgCode { get; set; }
-        public bool his_isComplete { get; set; }
-        public bool isManual { get; set; }
+        public string CurrSmtCode { get; set; }
+        public string CurrSlotNo { get; set; }
         /// <summary>
         /// 姝ラ绫诲瀷
         /// </summary>
@@ -72,9 +72,9 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public async Task<ApiAction<ProdReqOutput>> ScanItem(SmtLoadingInput input)
+        public async Task<ApiAction> ScanItem(SmtLoadingInput input)
         {
-            var action = new ApiAction<ProdReqOutput>();
+            var action = new ApiAction();
             try
             {
                 if (input.Code.IsNullOrEmpty())
@@ -84,20 +84,56 @@
                     return action;
                 }
 
+                //01鏍规嵁涓婃枡姝ラ鎵ц鐩稿簲鏂规硶
                 switch (EnumHelper.GetEnum<Step_Types>(input.Step))
                 {
                     case Step_Types.SmtCode:
-                        ExecuteSmtCode();
+                        action = ExecuteSmtCode(input);
                         break;
                     case Step_Types.SlotNo:
-                        ExecuteSlotNo();
+                        action = ExecuteSlotNo(input);
                         break;
                     case Step_Types.Feeder:
-                        ExecuteFeeder();
+                        action = ExecuteFeeder(input);
                         break;
                     case Step_Types.SN:
-                        ExecuteSN();
+                        action = ExecuteSN(input);
                         break;
+                }
+
+                //02淇濆瓨涓婃枡鏁版嵁
+
+                //03鏌ョ湅鏈笂鏂欏垪琛�
+                Biz.SmtTool smtTool = new();
+                var actionSmtTool = await smtTool.GetNotLoadingMaterial(input);
+                if (actionSmtTool.IsSuccessed)
+                {
+                    //甯﹀叆鏈哄櫒缂栫爜鏌ヨ锛屽鏋滄病鏈夋湭涓婃枡鐨勯」锛岃鏄庡綋鍓嶆満鍣ㄦ墍鏈夋Ы浣嶅潎宸插畬鎴愪笂鏂欙紒
+                    if (actionSmtTool.Data.Count == 0)
+                    {
+                        var _input = input.Clone();
+                        _input.machineCode = "";
+                        action.LocaleMsg = Biz.L($"褰撳墠鏈哄櫒鎵�鏈夋Ы浣嶅潎宸插畬鎴愪笂鏂欙紒");
+                        var _actionSmtTool = await smtTool.GetNotLoadingMaterial(_input);
+                        if (_actionSmtTool.IsSuccessed)
+                        {
+                            //涓嶅甫鍏ユ満鍣ㄧ紪鐮佹煡璇紝濡傛灉娌℃湁鏈笂鏂欑殑椤癸紝璇存槑褰撳墠绾垮埆鎵�鏈夋満鍣ㄥ潎宸插畬鎴愪笂鏂欙紒
+                            if (_actionSmtTool.Data.Count == 0)
+                            {
+                                action.LocaleMsg = Biz.L($"褰撳墠绾垮埆鎵�鏈夋満鍣ㄥ潎宸插畬鎴愪笂鏂�");
+                            }
+                        }
+                        else
+                        {
+                            action.IsSuccessed = false;
+                            action.LocaleMsg = Biz.L($"鑾峰彇鏈笂鏂欏垪琛ㄥけ璐ワ紒");
+                        }
+                    }
+                }
+                else
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"鑾峰彇鏈笂鏂欏垪琛ㄥけ璐ワ紒");
                 }
 
                 //action.Data = new ProdReqOutput()
@@ -120,11 +156,21 @@
             return action;
         }
 
-        private ApiAction ExecuteSmtCode() {
+        private ApiAction ExecuteSmtCode(SmtLoadingInput input) {
             var action = new ApiAction();
             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())
+                {
+                    CurrSmtCode = input.Code;
+                    action.IsSuccessed = true;
+                    action.LocaleMsg = Biz.L($"鏈哄櫒缂栫爜楠岃瘉閫氳繃锛�");
+                }
+                else
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"鏂欑珯琛ㄤ腑涓嶅瓨鍦ㄦ鏈哄櫒缂栫爜锛岃纭鏂欑珯琛ㄦ槸鍚︽纭笂浼狅紒");
+                }
             }
             catch (Exception ex)
             {
@@ -133,12 +179,22 @@
             return action;
         }
 
-        private ApiAction ExecuteSlotNo()
+        private ApiAction ExecuteSlotNo(SmtLoadingInput input)
         {
             var action = new ApiAction();
             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())
+                {
+                    CurrSlotNo = input.Code;
+                    action.IsSuccessed = true;
+                    action.LocaleMsg = Biz.L($"妲戒綅楠岃瘉閫氳繃锛�");
+                }
+                else
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"姝ゆЫ浣峓{input.Code}]涓嶅瓨鍦ㄦ垨鏂欑珯琛ㄦ湭涓婁紶锛�");
+                }
             }
             catch (Exception ex)
             {
@@ -147,7 +203,7 @@
             return action;
         }
 
-        private ApiAction ExecuteFeeder()
+        private ApiAction ExecuteFeeder(SmtLoadingInput input)
         {
             var action = new ApiAction();
             try
@@ -161,7 +217,7 @@
             return action;
         }
 
-        private ApiAction ExecuteSN()
+        private ApiAction ExecuteSN(SmtLoadingInput input)
         {
             var action = new ApiAction();
             try
diff --git a/Tiger.IBusiness/MES/SMT/ISmtTool.cs b/Tiger.IBusiness/MES/SMT/ISmtTool.cs
index 863ac75..8bbeb64 100644
--- a/Tiger.IBusiness/MES/SMT/ISmtTool.cs
+++ b/Tiger.IBusiness/MES/SMT/ISmtTool.cs
@@ -11,6 +11,6 @@
 {
     public interface ISmtTool
     {
-        public Task<ApiAction<List<SMT_WO_TABLE>>> GetNotLoadingMaterial(smtWoTableParams paras);
+        public Task<ApiAction<List<SMT_WO_TABLE>>> GetNotLoadingMaterial(SmtLoadingInput paras);
     }
 }
diff --git a/Tiger.Model.Net/Entitys/MES/SMT_WO_TABLE.cs b/Tiger.Model.Net/Entitys/MES/SMT_WO_TABLE.cs
index 4af71d0..e976b43 100644
--- a/Tiger.Model.Net/Entitys/MES/SMT_WO_TABLE.cs
+++ b/Tiger.Model.Net/Entitys/MES/SMT_WO_TABLE.cs
@@ -126,12 +126,4 @@
 		#endregion
 
 	}//endClass
-
-	public class smtWoTableParams { 
-		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/Entitys/WMS/Api/BaseInput.cs b/Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs
index a3f62b8..dfcaaee 100644
--- a/Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs
+++ b/Tiger.Model.Net/Entitys/WMS/Api/BaseInput.cs
@@ -54,5 +54,10 @@
     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

--
Gitblit v1.9.3