From f7f7279a6631ef9929b8087204c7f210e3ec7f5b Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期五, 10 一月 2025 01:04:42 +0800
Subject: [PATCH] 重构输入类型,更新方法和命名空间

---
 Tiger.Business.WMS/ERP/U9C_WMS.cs                              |   81 ++++++++++++++++++++
 Tiger.Business.MES/iERP/U9C_MES.cs                             |   33 +-------
 Tiger.Model.Net/Entitys/MES/YadaU9/mes_MaterialBarCodeByBin.cs |   32 +++++--
 Tiger.Model.Net/Tiger.Model.Net.csproj                         |    2 
 Tiger.Business.WMS/Task/ERP/Jobs.U9C_WMS_GetMaterialSn.cs      |   14 +-
 Tiger.Model.Net/Entitys/MES/ParameterEntity/U9C_Base_Input.cs  |   12 +-
 Tiger.IBusiness.WMS/iERP/IU9C_WMS.cs                           |   21 +++++
 Tiger.IBusiness.MES/iERP/IU9C_MES.cs                           |   11 +-
 Tiger.Model.Net/Entitys/MES/ParameterEntity/TskParameter.cs    |    2 
 9 files changed, 149 insertions(+), 59 deletions(-)

diff --git a/Tiger.Business.MES/iERP/U9C_MES.cs b/Tiger.Business.MES/iERP/U9C_MES.cs
index 6c13121..af8e0f9 100644
--- a/Tiger.Business.MES/iERP/U9C_MES.cs
+++ b/Tiger.Business.MES/iERP/U9C_MES.cs
@@ -28,7 +28,7 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public ApiAction GetBasItem(U9C_MES_Input input)
+        public ApiAction GetBasItem(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"鐗╂枡淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -309,7 +309,7 @@
         /// <param name="input"></param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        public ApiAction GetCustomer(U9C_MES_Input input)
+        public ApiAction GetCustomer(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"瀹㈡埛淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -386,7 +386,7 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public ApiAction GetSupplier(U9C_MES_Input input)
+        public ApiAction GetSupplier(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"渚涘簲鍟嗕俊鎭紑濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -460,7 +460,7 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public ApiAction GetCustBarCode(U9C_MES_Input input)
+        public ApiAction GetCustBarCode(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"瀹㈡埛鏉$爜淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -534,7 +534,7 @@
             return action;
         }
 
-        public ApiAction GetU9CBasWo(U9C_MES_Input input)
+        public ApiAction GetU9CBasWo(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"宸ュ崟淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -687,29 +687,6 @@
                     }
                 });
             }
-            return action;
-        }
-
-        /// <summary>
-        /// 鍚屾鐗╂枡鏉$爜淇℃伅
-        /// </summary>
-        /// <param name="input"></param>
-        /// <returns></returns>
-        public ApiAction GetMaterialBarCode(U9C_MES_Input input)
-        {
-            var action = new ApiAction();
-            Logger.Scheduler.Info($"鐗╂枡鏉$爜淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
-            Logger.Scheduler.Info($"{input.triggerDetail}");
-            DbClient db = Biz.DataSource["YadaU9C"].Client;
-            try
-            {
-                var list = db.Queryable<mes_MaterialBarCodeByBin>().Where("ModifiedOn > @startTime And ModifiedOn < @endTime", new { startTime = input.startTime, endTime = input.endTime }).ToList();
-            }
-            catch (Exception ex)
-            {
-                action.CatchExceptionWithLog(ex, Biz.L(ex.Message));
-            }
-
             return action;
         }
     }
diff --git a/Tiger.Business.WMS/ERP/U9C_WMS.cs b/Tiger.Business.WMS/ERP/U9C_WMS.cs
new file mode 100644
index 0000000..c5abd07
--- /dev/null
+++ b/Tiger.Business.WMS/ERP/U9C_WMS.cs
@@ -0,0 +1,81 @@
+锘縰sing Rhea.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tiger.Model.MES.Yada;
+using Tiger.Model;
+using Tiger.IBusiness;
+using Microsoft.CodeAnalysis.Options;
+using Tiger.Model.Entitys.MES.U9C;
+using SqlSugar;
+using System.Collections;
+using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
+
+namespace Tiger.Business.WMS
+{
+    public partial class U9C_WMS: IU9C_WMS
+    {
+
+
+        /// <summary>
+        /// 鍚屾鐗╂枡鏉$爜淇℃伅
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        public ApiAction In_BySync(U9C_Base_Input input)
+        {
+            var action = new ApiAction();
+            Logger.Scheduler.Info($"鐗╂枡鏉$爜淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
+            Logger.Scheduler.Info($"{input.triggerDetail}");
+            DbClient db = Biz.DataSource["YadaU9C"].Client;
+            string UserCode = "System_In_BySync";
+            var list = db.Ado.SqlQuery<mes_MaterialBarCodeByBin>($"select *,cast('{DateTime.Now.ToString("yyyy-MM-dd")}' as DATETIME) as PROD_DATE,'' as Unit,'' as LotNo from mes_MaterialBarCodeByBin where ModifiedOn > '{input.startTime}' And ModifiedOn < '{input.endTime}'");
+            try
+            {
+                foreach (var item in list)
+                {
+                    Barcode barcode = new Barcode(item.Code);
+                    item.Code = item.Code;
+                    item.Segment5 = barcode.ItemCode;
+                    item.PROD_DATE = barcode.DateCode.ToDateTime();
+                    item.Unit = barcode.Unit;
+                    item.LotNo= barcode.LotNo;
+                }
+
+                //淇濆瓨鍒版暟鎹簱
+                var _db = Business.Biz.Db;
+                var dbTran = db.UseTran(() =>
+                {
+                    //鍏ュ簱
+                    _db.Insertable(list, UserCode).ExecuteCommand();
+                });
+                if (!dbTran.IsSuccess)
+                {
+                    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
+                    throw dbTran.ErrorException;
+                }
+
+                SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { ERR_CODE = 0, ERR_MSG = "" });
+                pars[0].Direction = System.Data.ParameterDirection.Output;
+                pars[1].Direction = System.Data.ParameterDirection.Output;
+                var codeList = Biz.Db.Ado.UseStoredProcedure().SqlQuery<mes_MaterialBarCodeByBin>("SP_WMS_IMPORT_ITEM", pars);//杩斿洖List
+                if (pars[0].Value.ToInt32() == 0)
+                {
+                    Logger.Scheduler.Info($"鍚屾鏉$爜鍏ュ簱锛屾�绘暟锛歔{list.Count}]");
+                    action.Message = $"鍚屾鏉$爜鍏ュ簱锛屾�绘暟锛歔{list.Count}]";
+                }
+                else
+                {
+                    Logger.Scheduler.Error(pars[1].Value.ToString());
+                }
+            }
+            catch (Exception ex)
+            {
+                action.CatchExceptionWithLog(ex, Biz.L(ex.Message));
+            }
+            return action;
+        }
+    }
+}
diff --git a/Tiger.Business.MES/Task/Jobs.U9C_ME_GetMaterialSn.cs b/Tiger.Business.WMS/Task/ERP/Jobs.U9C_WMS_GetMaterialSn.cs
similarity index 85%
rename from Tiger.Business.MES/Task/Jobs.U9C_ME_GetMaterialSn.cs
rename to Tiger.Business.WMS/Task/ERP/Jobs.U9C_WMS_GetMaterialSn.cs
index 562b4e0..2de96e2 100644
--- a/Tiger.Business.MES/Task/Jobs.U9C_ME_GetMaterialSn.cs
+++ b/Tiger.Business.WMS/Task/ERP/Jobs.U9C_WMS_GetMaterialSn.cs
@@ -10,21 +10,21 @@
 using Tiger.Model;
 using Tiger.Model.Minsun;
 
-namespace Tiger.Business.MES
+namespace Tiger.Business.WMS
 {
     /// <summary>
     /// 浠嶶9C鑾峰彇鐗╂枡鏉$爜淇℃伅
     /// </summary>
-    public class U9C_ME_GetMaterialSn : TigerJobBase, ITJob
+    public class U9C_WMS_GetMaterialSn : TigerJobBase, ITJob
     {
         public string Id { get; set; } = Guid.NewGuid().ToString("N");
         public string Tag { get; set; }
         public string Name { get; set; }
-        public U9C_ME_GetMaterialSn()
+        public U9C_WMS_GetMaterialSn()
         {
             Id = Guid.NewGuid().ToString("N");
-            Tag = "U9C_ME_GetMaterialSn Interface Job";
-            GetJob(typeof(U9C_ME_GetMaterialSn).Name);
+            Tag = "U9C_WMS_GetMaterialSn Interface Job";
+            GetJob(typeof(U9C_WMS_GetMaterialSn).Name);
             Name = Job.JobName;
         }
 
@@ -39,11 +39,11 @@
             {
                 string msg = "";
                 string status = "Successed";
-                GetJob(typeof(U9C_ME_GetMaterialSn).Name);
+                GetJob(typeof(U9C_WMS_GetMaterialSn).Name);
                 TskJobInput tskJobInput = CheckIFCanGo();
                 if (tskJobInput.result)
                 {
-                    var result = DI.Resolve<IU9C_MES>().GetMaterialBarCode(tskJobInput.input);
+                    var result = DI.Resolve<IU9C_WMS>().In_BySync(tskJobInput.input);
                     if (!result.IsSuccessed)
                     {
                         msg = $"鑾峰彇鐗╂枡鏉$爜淇℃伅寮傚父:{result.Message}";
diff --git a/Tiger.IBusiness.MES/iERP/IU9C_MES.cs b/Tiger.IBusiness.MES/iERP/IU9C_MES.cs
index 99d6455..5417c7b 100644
--- a/Tiger.IBusiness.MES/iERP/IU9C_MES.cs
+++ b/Tiger.IBusiness.MES/iERP/IU9C_MES.cs
@@ -11,12 +11,11 @@
 {
     public interface IU9C_MES
     {
-        public ApiAction GetBasItem(U9C_MES_Input input);
-        public ApiAction GetCustomer(U9C_MES_Input input);
-        public ApiAction GetSupplier(U9C_MES_Input input);
+        public ApiAction GetBasItem(U9C_Base_Input input);
+        public ApiAction GetCustomer(U9C_Base_Input input);
+        public ApiAction GetSupplier(U9C_Base_Input input);
         public Task<ApiAction> GetBasWo(GetWoInput input);
-        public ApiAction GetCustBarCode(U9C_MES_Input input);
-        public ApiAction GetMaterialBarCode(U9C_MES_Input input);
-        public ApiAction GetU9CBasWo(U9C_MES_Input input);
+        public ApiAction GetCustBarCode(U9C_Base_Input input);
+        public ApiAction GetU9CBasWo(U9C_Base_Input input);
     }
 }
diff --git a/Tiger.IBusiness.WMS/iERP/IU9C_WMS.cs b/Tiger.IBusiness.WMS/iERP/IU9C_WMS.cs
new file mode 100644
index 0000000..49ff208
--- /dev/null
+++ b/Tiger.IBusiness.WMS/iERP/IU9C_WMS.cs
@@ -0,0 +1,21 @@
+锘縰sing Rhea.Common;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tiger.Model;
+
+namespace Tiger.IBusiness
+{
+    public interface IU9C_WMS
+    {
+        /// <summary>
+        /// 鍚屾涓婃灦鐗╂枡鏉$爜
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        public ApiAction In_BySync(U9C_Base_Input input);
+    }
+}
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/TskParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/TskParameter.cs
index 56b9e5d..dc31170 100644
--- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/TskParameter.cs
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/TskParameter.cs
@@ -31,6 +31,6 @@
     public class TskJobInput
     {
         public bool result { get; set; }
-        public U9C_MES_Input input { get; set; }
+        public U9C_Base_Input input { get; set; }
     }
 }
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9C_MES_Input.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9C_Base_Input.cs
similarity index 61%
rename from Tiger.Model.Net/Entitys/MES/ParameterEntity/U9C_MES_Input.cs
rename to Tiger.Model.Net/Entitys/MES/ParameterEntity/U9C_Base_Input.cs
index 7f7ebf4..ded77f6 100644
--- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9C_MES_Input.cs
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/U9C_Base_Input.cs
@@ -6,7 +6,7 @@
 
 namespace Tiger.Model
 {
-    public class U9C_MES_Input
+    public class U9C_Base_Input
     {
         public string startTime { get; set; }
         public string endTime { get; set; }
@@ -14,23 +14,23 @@
         public DateTime LastRunTime { get; set; }
     }
 
-    public class GetBasItemInput : U9C_MES_Input
+    public class GetBasItemInput : U9C_Base_Input
     {
         public string isProd { get; set; }
     }
 
-    public class GetCustomerInput : U9C_MES_Input
+    public class GetCustomerInput : U9C_Base_Input
     {
     }
 
-    public class GetSupplierInput : U9C_MES_Input
+    public class GetSupplierInput : U9C_Base_Input
     {
     }
 
-    public class GetWoInput : U9C_MES_Input
+    public class GetWoInput : U9C_Base_Input
     {
     }
-    public class GetCustBarcodeInput : U9C_MES_Input
+    public class GetCustBarcodeInput : U9C_Base_Input
     {
     }
 }
diff --git a/Tiger.Model.Net/Entitys/MES/YadaU9/mes_MaterialBarCodeByBin.cs b/Tiger.Model.Net/Entitys/MES/YadaU9/mes_MaterialBarCodeByBin.cs
index e404cee..e530d03 100644
--- a/Tiger.Model.Net/Entitys/MES/YadaU9/mes_MaterialBarCodeByBin.cs
+++ b/Tiger.Model.Net/Entitys/MES/YadaU9/mes_MaterialBarCodeByBin.cs
@@ -66,17 +66,29 @@
 		/// 
 		/// </summary>
 		public string BinInfo_Code { get; set; }
-		#endregion
+        /// <summary>
+        /// 
+        /// </summary>
+        public DateTime PROD_DATE { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Unit { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string LotNo { get; set; }
+        #endregion
 
-		#region 虚拟属性
-		/*例子
+        #region 虚拟属性
+        /*例子
 		[SugarColumn(IsIgnore = true)]
 		public string FieldName { get; set; }
 		*/
-		#endregion
+        #endregion
 
-		#region 枚举变量
-		/*例子
+        #region 枚举变量
+        /*例子
 		public enum FieldNames
 		{
 			[Description("枚举描述0")]
@@ -85,11 +97,11 @@
 			Enum1,
 		}
 		*/
-		#endregion
+        #endregion
 
-		#region 公共方法
+        #region 公共方法
 
-		#endregion
+        #endregion
 
-	}//endClass
+    }//endClass
 }
\ 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 ecf1921..539fd4b 100644
--- a/Tiger.Model.Net/Tiger.Model.Net.csproj
+++ b/Tiger.Model.Net/Tiger.Model.Net.csproj
@@ -187,7 +187,7 @@
     <Compile Include="Entitys\MES\ParameterEntity\PositionParameter.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\RouteInput.cs" />
     <Compile Include="Entitys\MES\ParameterEntity\TskParameter.cs" />
-    <Compile Include="Entitys\MES\ParameterEntity\U9C_MES_Input.cs" />
+    <Compile Include="Entitys\MES\ParameterEntity\U9C_Base_Input.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