From c40ce123424183b2fce3bf9dfb24d859f3eacb52 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 09 一月 2025 17:00:03 +0800 Subject: [PATCH] 新增获取物料条码信息的功能 --- Tiger.Business.MES/iERP/U9C_MES.cs | 24 ++++++++++++ Tiger.Business.MES/Task/Jobs.U9C_ME_GetMaterialSn.cs | 72 ++++++++++++++++++++++++++++++++++++ Tiger.Business/Services/Base/InterfaceServiceNew.cs | 15 +++---- Tiger.IBusiness.MES/iERP/IU9C_MES.cs | 1 4 files changed, 103 insertions(+), 9 deletions(-) diff --git a/Tiger.Business.MES/Task/Jobs.U9C_ME_GetMaterialSn.cs b/Tiger.Business.MES/Task/Jobs.U9C_ME_GetMaterialSn.cs new file mode 100644 index 0000000..562b4e0 --- /dev/null +++ b/Tiger.Business.MES/Task/Jobs.U9C_ME_GetMaterialSn.cs @@ -0,0 +1,72 @@ +锘縰sing Rhea.Common; +using FluentScheduler; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; +using Tiger.Model.Minsun; + +namespace Tiger.Business.MES +{ + /// <summary> + /// 浠嶶9C鑾峰彇鐗╂枡鏉$爜淇℃伅 + /// </summary> + public class U9C_ME_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() + { + Id = Guid.NewGuid().ToString("N"); + Tag = "U9C_ME_GetMaterialSn Interface Job"; + GetJob(typeof(U9C_ME_GetMaterialSn).Name); + Name = Job.JobName; + } + + public void Execute() + { + #region 鍥哄畾鍐欐硶 + Logger.Scheduler.Info($"/**\r\n *杩涘叆璁″垝璋冨害(鍚嶇О: {Name} )....\r\n */\r\n"); //鍥哄畾鍐欐硶 + Schedule = JobManager.GetSchedule(Name); //鍥哄畾鍐欐硶 + StartTime = DateTime.Now; //鍥哄畾鍐欐硶 + #endregion + try + { + string msg = ""; + string status = "Successed"; + GetJob(typeof(U9C_ME_GetMaterialSn).Name); + TskJobInput tskJobInput = CheckIFCanGo(); + if (tskJobInput.result) + { + var result = DI.Resolve<IU9C_MES>().GetMaterialBarCode(tskJobInput.input); + if (!result.IsSuccessed) + { + msg = $"鑾峰彇鐗╂枡鏉$爜淇℃伅寮傚父:{result.Message}"; + Logger.Scheduler.Error(msg); + status = "Failed"; + } + else + { + msg = $"浠嶶9C鑾峰彇鐗╂枡鏉$爜淇℃伅鎴愬姛:{result.Message}"; + //鍥哄畾鍐欐硶 + Trig.LastRunTime = Args.ByInterval == "Y" ? tskJobInput.input.endTime.ToDateTime().AddHours(Args.Interval) : tskJobInput.input.endTime.ToDateTime(); + Trig.NextRunTime = Schedule.NextRun; + } + } + SaveFluentSchedulerLog(status, $"{msg}"); + Logger.Scheduler.Info($"璁″垝璋冨害(鍚嶇О:{Name})瀹屾垚锛岃繑鍥炰俊鎭�:{msg}\r\n"); + } + catch (System.Exception ex) + { + Logger.Scheduler.Fatal(ex, "鑾峰彇鐗╂枡鏉$爜淇℃伅寮傚父"); + SaveFluentSchedulerLog("Failed", ex.Message); + } + Logger.Scheduler.Info($"/* 璁″垝璋冨害(鍚嶇О:{Name})缁撴潫 */\r\n"); //鍥哄畾鍐欐硶 + } + } +} diff --git a/Tiger.Business.MES/iERP/U9C_MES.cs b/Tiger.Business.MES/iERP/U9C_MES.cs index dfe8d48..15d031f 100644 --- a/Tiger.Business.MES/iERP/U9C_MES.cs +++ b/Tiger.Business.MES/iERP/U9C_MES.cs @@ -17,6 +17,7 @@ using Apache.NMS.ActiveMQ.Commands; using System.Security.Cryptography; using System.Diagnostics; +using Tiger.Model.MES.Yada; namespace Tiger.Business.MES { @@ -688,5 +689,28 @@ } 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_MaterialBarCode>().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/Services/Base/InterfaceServiceNew.cs b/Tiger.Business/Services/Base/InterfaceServiceNew.cs index bec31f0..527f07a 100644 --- a/Tiger.Business/Services/Base/InterfaceServiceNew.cs +++ b/Tiger.Business/Services/Base/InterfaceServiceNew.cs @@ -418,15 +418,12 @@ var jobs = Biz.Db.Queryable<TSK_JOB>().IncludesAllFirstLayer().ToList(); foreach (var job in jobs) { - //if (job.JobName == "fU9C_MES_GetWo" || job.JobName == "fTest") - { - Type type = Type.GetType($"{job.AssemblyName}.{job.JobType},{job.AssemblyName}", throwOnError: true); - dynamic _type = Activator.CreateInstance(type); - TrigArgs args = JsonConvert.DeserializeObject<TrigArgs>(job.Triggers[0].Args); - Schedule schedule = Schedule(_type, job.JobName, registry); - //鐢熸垚璁″垝 - GenerateSchedule(args, schedule); - } + Type type = Type.GetType($"{job.AssemblyName}.{job.JobType},{job.AssemblyName}", throwOnError: true); + dynamic _type = Activator.CreateInstance(type); + TrigArgs args = JsonConvert.DeserializeObject<TrigArgs>(job.Triggers[0].Args); + Schedule schedule = Schedule(_type, job.JobName, registry); + //鐢熸垚璁″垝 + GenerateSchedule(args, schedule); } } catch (System.Exception ex) diff --git a/Tiger.IBusiness.MES/iERP/IU9C_MES.cs b/Tiger.IBusiness.MES/iERP/IU9C_MES.cs index 7591b50..99d6455 100644 --- a/Tiger.IBusiness.MES/iERP/IU9C_MES.cs +++ b/Tiger.IBusiness.MES/iERP/IU9C_MES.cs @@ -16,6 +16,7 @@ public ApiAction GetSupplier(U9C_MES_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); } } -- Gitblit v1.9.3