| | |
| | | //#region << ç æ¬ 注 é >> |
| | | ///*---------------------------------------------------------------- |
| | | // * å½å空é´ï¼WIDESEAWCS_Tasks.ConveyorLineJob |
| | | // * å建è
ï¼è¡ç«¥åº |
| | | // * å建æ¶é´ï¼2024/8/2 16:13:36 |
| | | // * çæ¬ï¼V1.0.0 |
| | | // * æè¿°ï¼ |
| | | // * |
| | | // * ---------------------------------------------------------------- |
| | | // * ä¿®æ¹äººï¼ |
| | | // * ä¿®æ¹æ¶é´ï¼ |
| | | // * çæ¬ï¼V1.0.1 |
| | | // * ä¿®æ¹è¯´æï¼ |
| | | // * |
| | | // *----------------------------------------------------------------*/ |
| | | //#endregion << ç æ¬ 注 é >> |
| | | #region << ç æ¬ 注 é >> |
| | | /*---------------------------------------------------------------- |
| | | * å½å空é´ï¼WIDESEAWCS_Tasks.ConveyorLineJob |
| | | * å建è
ï¼è¡ç«¥åº |
| | | * å建æ¶é´ï¼2024/8/2 16:13:36 |
| | | * çæ¬ï¼V1.0.0 |
| | | * æè¿°ï¼ |
| | | * |
| | | * ---------------------------------------------------------------- |
| | | * ä¿®æ¹äººï¼ |
| | | * ä¿®æ¹æ¶é´ï¼ |
| | | * çæ¬ï¼V1.0.1 |
| | | * ä¿®æ¹è¯´æï¼ |
| | | * |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | //using AutoMapper; |
| | | //using Quartz; |
| | | //using System.Text.RegularExpressions; |
| | | //using WIDESEA_Common.Log; |
| | | //using WIDESEAWCS_Common.TaskEnum; |
| | | //using WIDESEAWCS_DTO.Enum; |
| | | //using WIDESEAWCS_ISystemServices; |
| | | //using WIDESEAWCS_ITaskInfoService; |
| | | //using WIDESEAWCS_Model.Models; |
| | | //using WIDESEAWCS_Model.Models.System; |
| | | //using WIDESEAWCS_QuartzJob; |
| | | //using WIDESEAWCS_QuartzJob.Service; |
| | | //using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using Quartz; |
| | | using System; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using WIDESEA_Common.Log; |
| | | using WIDESEAWCS_DTO.BasicInfo; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_Model.Models.System; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | |
| | | //namespace WIDESEAWCS_Tasks |
| | | //{ |
| | | // [DisallowConcurrentExecution] |
| | | // public class CommonConveyorLineJob : IJob |
| | | // { |
| | | // private readonly ITaskService _taskService; |
| | | // private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | // private readonly IRouterService _routerService; |
| | | // private readonly IOrderDetailsService _OrderDetailsService; |
| | | // private readonly IMapper _mapper; |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class CommonConveyorLineJob : JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IOrderDetailsService _OrderDetailsService; |
| | | private readonly IMapper _mapper; |
| | | |
| | | // public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IOrderDetailsService orderDetails, IMapper mapper) |
| | | // { |
| | | // _taskService = taskService; |
| | | // _taskExecuteDetailService = taskExecuteDetailService; |
| | | // _routerService = routerService; |
| | | // _OrderDetailsService = orderDetails; |
| | | // _mapper = mapper; |
| | | // } |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IOrderDetailsService orderDetails, IMapper mapper) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _routerService = routerService; |
| | | _OrderDetailsService = orderDetails; |
| | | _mapper = mapper; |
| | | } |
| | | |
| | | // public Task Execute(IJobExecutionContext context) |
| | | // { |
| | | // try |
| | | // { |
| | | static string barcode = string.Empty; //æ¡ç |
| | | |
| | | // CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); |
| | | if (flag && value != null && value is OtherDevice) |
| | | { |
| | | OtherDevice otherDevice = (OtherDevice)value; |
| | | |
| | | // if (conveyorLine != null) |
| | | // { |
| | | // if (conveyorLine.Communicator.Read<bool>("DB7.3030.0")) //ç³è¯· |
| | | // { |
| | | bool request = otherDevice.Communicator.Read<bool>("DB15.22.0"); //ç³è¯· |
| | | bool response = otherDevice.Communicator.Read<bool>("DB15.22.1"); //åºç |
| | | |
| | | // string Barcodes = conveyorLine.Communicator.Read<string>("DB7.3032"); //读æ¡ç |
| | | // string pattern = @"\d+"; // å¹é
æ°å |
| | | // Match match = Regex.Match(Barcodes, pattern); |
| | | // string barcodeNumber = match.Value; |
| | | // if (barcodeNumber != "") |
| | | // { |
| | | // int toplc = _OrderDetailsService.GetOrderDetails(barcodeNumber); |
| | | // if (toplc != -1) |
| | | // { |
| | | // conveyorLine.Communicator.Write("DB7.3022", (int)toplc); //åå
¥å»å |
| | | // conveyorLine.Communicator.Write("DB7.3028.0", (bool)true); //åå
¥åé¦ |
| | | // WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "æå", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼åå
¥å»å{toplc}" }); |
| | | // if (conveyorLine.Communicator.Read<bool>("DB7.3116")) |
| | | // { |
| | | // conveyorLine.Communicator.Write("DB7.3022", (int)0); //æ¸
é¤åå
¥å»å |
| | | // conveyorLine.Communicator.Write("DB7.3028.0", (bool)false); //æ¸
é¤åå
¥åé¦ |
| | | // WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "æå", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼æ¸
é¤è¾é线å馿å" }); |
| | | // //è°ååé¦MESæçæ¡ç |
| | | bool wcsResponse = otherDevice.Communicator.Read<bool>("DB15.0.0"); //åºç |
| | | |
| | | // var datast= _OrderDetailsService.ToMesBarc(int.Parse(barcodeNumber)); |
| | | // if (datast.code==1) |
| | | // { |
| | | // WriteLog.Write_Log("ToMes", "æ¡ç åé¦Mes", "æå", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼å馿å" }); |
| | | // } |
| | | // else |
| | | // { |
| | | // WriteLog.Write_Log("ToMes", "æ¡ç åé¦Mes", "失败", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼åé¦å¤±è´¥" }); |
| | | // } |
| | | if (request && !response && !wcsResponse) |
| | | { |
| | | bool[] useables = otherDevice.Communicator.Read<bool>("DB15.22.3", 3); |
| | | |
| | | int[] useableArray = GetIndexArray(useables, false); |
| | | |
| | | // } |
| | | // else |
| | | // { |
| | | // WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼æ¸
é¤è¾é线åé¦å¤±è´¥" }); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // conveyorLine.Communicator.Write("DB7.3028.1", (bool)true); |
| | | // WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼æªæ¾å°æ°æ®æç»è¯¦æ
é¿åº¦ï¼åå
¥æ¥è¦ä¿¡æ¯" }); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = $"æªè¯»åå°æçæ¡ç ï¼æ¡ç é误{barcodeNumber}" }); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | List<int> useableStations = useableArray.ToList(); |
| | | for (int i = 0; i < useableStations.Count; i++) |
| | | { |
| | | useableStations[i] += 1; |
| | | } |
| | | |
| | | // WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = "æªè¯»åå°æ«ç æªç³è¯·" }); |
| | | // } |
| | | // } |
| | | barcode = otherDevice.Communicator.Read<string>("DB15.32"); //æ¡ç |
| | | |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // //Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); |
| | | // } |
| | | // return Task.CompletedTask; |
| | | // } |
| | | List<byte> bytes = otherDevice.Communicator.Read("DB15.34", 40).ToList(); |
| | | |
| | | byte[] temp = bytes.ToArray().SelectMiddle(0, bytes.IndexOf(0)); |
| | | |
| | | // } |
| | | //} |
| | | barcode = Encoding.Default.GetString(temp); |
| | | |
| | | string pattern = @"\d+"; // å¹é
æ°å |
| | | Match match = Regex.Match(barcode, pattern); |
| | | string barcodeNumber = match.Value; |
| | | |
| | | if (!string.IsNullOrEmpty(barcodeNumber)) |
| | | { |
| | | // 1. è·åå»å |
| | | int toplc = _OrderDetailsService.GetOrderDetails(barcodeNumber, useableStations, out ProductInfoDTO productInfo); |
| | | |
| | | if (toplc > 0)//è·åå°ææå»å |
| | | { |
| | | otherDevice.Communicator.Write("DB15.10", productInfo.Length); |
| | | otherDevice.Communicator.Write("DB15.14", productInfo.Width); |
| | | otherDevice.Communicator.Write("DB15.18", productInfo.Height); |
| | | |
| | | otherDevice.Communicator.Write("DB15.6", toplc); //åå
¥å»å |
| | | otherDevice.Communicator.Write("DB15.0", true); |
| | | |
| | | var datast = _OrderDetailsService.ToMesBarc(int.Parse(barcode)); |
| | | } |
| | | else if (toplc == -1)//æ¿ææ æ¡ç |
| | | { |
| | | otherDevice.Communicator.Write("DB15.0.3", true); |
| | | } |
| | | else if (toplc == -2) //æ¿æå¤§å°ä¸å¨åºé´ |
| | | { |
| | | otherDevice.Communicator.Write("DB15.0.2", true); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (wcsResponse) |
| | | otherDevice.Communicator.Write("DB15.0", false); //æ¸
é¤ååº |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(nameof(CommonConveyorLineJob), ex.ToString(), ex); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | public int[] GetIndexArray<T>(T[] values, T value) |
| | | { |
| | | List<int> result = new List<int>(); |
| | | for (int i = 0; i < values.Length; i++) |
| | | { |
| | | if (value.Equals(values[i])) |
| | | { |
| | | result.Add(i); |
| | | } |
| | | } |
| | | return result.ToArray(); |
| | | } |
| | | } |
| | | } |