From bb56b2b6f21acb7c69c02585e5bc534d2f67715f Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期四, 27 三月 2025 17:13:35 +0800 Subject: [PATCH] WMS首页优化,WCS优化AGV和产线、输送线交互逻辑 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ProductionLineJob/CommonProductionLineJob.cs | 79 ++++++++++++++++++++++++++++++++++----- 1 files changed, 68 insertions(+), 11 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ProductionLineJob/CommonProductionLineJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ProductionLineJob/CommonProductionLineJob.cs" index f656c2f..e29bab2 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ProductionLineJob/CommonProductionLineJob.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ProductionLineJob/CommonProductionLineJob.cs" @@ -1,47 +1,104 @@ -锘縰sing AutoMapper; -using Quartz; +锘縰sing Quartz; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_DTO.WMSInfo; +using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_QuartzJob; +using WIDESEAWCS_QuartzJob.DTO; using WIDESEAWCS_QuartzJob.Service; +using WIDESEAWCS_Tasks.ProductionLineJob; +using WIDESEAWCS_Tasks.StackerCraneJob; +using static System.Collections.Specialized.BitVector32; namespace WIDESEAWCS_Tasks { [DisallowConcurrentExecution] - public class CommonProductionLineJob : JobBase, IJob + public partial class CommonProductionLineJob : JobBase, IJob { private readonly ITaskService _taskService; private readonly ITaskExecuteDetailService _taskExecuteDetailService; + private readonly ITaskRepository _taskRepository; private readonly IRouterService _routerService; - private readonly IMapper _mapper; - public CommonProductionLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper) + public CommonProductionLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService) { _taskService = taskService; _taskExecuteDetailService = taskExecuteDetailService; + _taskRepository = taskRepository; _routerService = routerService; - _mapper = mapper; } + //static int i = 1; public Task Execute(IJobExecutionContext context) { try { - CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); - if (conveyorLine != null) + #region MyRegion + OtherDevice ProductionLine = (OtherDevice)context.JobDetail.JobDataMap.Get("JobParams"); + if (ProductionLine != null) { - Console.Out.WriteLine(nameof(CommonProductionLineJob) + ":" + DateTime.Now); - + //ProductionLineDTO MaterielGroupDTO = new ProductionLineDTO() + //{ + // stationCode = ProductionLine.DeviceCode, + // traytype = 4, + // Barcode = "25000037", + // batchNo = "250325T1", + //}; + //var content = ProductionLineToWMSRequest(MaterielGroupDTO); + #region MyRegion + var request = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.request); + if (request == 1) + { + var traytype = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.trayType); + //var content = Request(ProductionLine, traytype, ProductionLine.DeviceCode); + if (traytype == 4) + { + var Barcode = ProductionLine.GetValue<ProductionLineDBName, string>(ProductionLineDBName.trayBarcode).Replace("\0", ""); + var task = _taskRepository.QueryFirst(x => x.PalletCode == Barcode); + if (task == null) + { + var batchNo = ProductionLine.GetValue<ProductionLineDBName, string>(ProductionLineDBName.batchNo).Replace("\0", ""); + ProductionLineDTO MaterielGroupDTO = new ProductionLineDTO() + { + stationCode = ProductionLine.DeviceCode, + traytype = traytype, + Barcode = Barcode, + batchNo = batchNo, + }; + var content = ProductionLineToWMSRequest(MaterielGroupDTO); + if (content.Status) + ProductionLine.SetValue(ProductionLineDBName.Wrequest, request); + } + } + } + #endregion } + #endregion } catch (Exception ex) { - Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); + Console.Out.WriteLine(nameof(CommonProductionLineJob) + ":" + ex.ToString()); } return Task.CompletedTask; } + + public string GetString<TEnum, TResult>(TEnum value, OtherDevice ProductionLine) where TEnum : Enum + { + TEnum value2 = value; + if (!ProductionLine.IsConnected) + { + throw new Exception("閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�"); + } + DeviceProDTO deviceProDTO = ProductionLine.DeviceProDTOs.FirstOrDefault((DeviceProDTO x) => x.DeviceProParamName == value2.ToString()); + if (deviceProDTO != null) + { + return Encoding.ASCII.GetString(ProductionLine.Communicator.Read(deviceProDTO.DeviceProAddress, deviceProDTO.DeviceProDataLength)).Replace("\0", ""); + //return (TResult)Communicator.ReadAsObj(deviceProDTO.DeviceProAddress, deviceProDTO.DeviceDataType); + } + throw new Exception("璇诲彇鏁版嵁閿欒,鏈湪鍗忚淇℃伅閲岄潰鎵惧埌鍙傛暟" + value2.ToString()); + } } } -- Gitblit v1.9.3