| | |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using Quartz; |
| | | using System; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using WIDESEA_Common.Log; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_DTO.Enum; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_DTO.BasicInfo; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_Model.Models.System; |
| | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class CommonConveyorLineJob : IJob |
| | | public class CommonConveyorLineJob : JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | |
| | | _mapper = mapper; |
| | | } |
| | | |
| | | static string barcode = string.Empty; //æ¡ç |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | |
| | | if (conveyorLine != null) |
| | | bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); |
| | | if (flag && value != null && value is OtherDevice) |
| | | { |
| | | if (conveyorLine.Communicator.Read<bool>("DB7.3030.0")) //ç³è¯· |
| | | OtherDevice otherDevice = (OtherDevice)value; |
| | | |
| | | bool request = otherDevice.Communicator.Read<bool>("DB15.22.0"); //ç³è¯· |
| | | bool response = otherDevice.Communicator.Read<bool>("DB15.22.1"); //åºç |
| | | |
| | | bool wcsResponse = otherDevice.Communicator.Read<bool>("DB15.0.0"); //åºç |
| | | |
| | | if (request && !response && !wcsResponse) |
| | | { |
| | | bool[] useables = otherDevice.Communicator.Read<bool>("DB15.22.3", 3); |
| | | |
| | | string Barcodes = conveyorLine.Communicator.Read<string>("DB7.3032"); //读æ¡ç |
| | | string pattern = @"\d+"; // å¹é
æ°å |
| | | Match match = Regex.Match(Barcodes, pattern); |
| | | string barcodeNumber = match.Value; |
| | | if (barcodeNumber != "") |
| | | int[] useableArray = GetIndexArray(useables, false); |
| | | |
| | | List<int> useableStations = useableArray.ToList(); |
| | | for (int i = 0; i < useableStations.Count; i++) |
| | | { |
| | | 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æçæ¡ç |
| | | |
| | | 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}ï¼åé¦å¤±è´¥" }); |
| | | } |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼æ¸
é¤è¾é线åé¦å¤±è´¥" }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | conveyorLine.Communicator.Write("DB7.3028.1", (bool)true); |
| | | WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = $"æ¡ç ï¼{barcodeNumber}ï¼æªæ¾å°æ°æ®æç»è¯¦æ
é¿åº¦ï¼åå
¥æ¥è¦ä¿¡æ¯" }); |
| | | } |
| | | useableStations[i] += 1; |
| | | } |
| | | else |
| | | |
| | | barcode = otherDevice.Communicator.Read<string>("DB15.32"); //æ¡ç |
| | | |
| | | 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)) |
| | | { |
| | | WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = $"æªè¯»åå°æçæ¡ç ï¼æ¡ç é误{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 |
| | | { |
| | | |
| | | WriteLog.Write_Log("æ«ç æª", "æ«ç ç«å°", "é误", new { ä¿¡æ¯ = "æªè¯»åå°æ«ç æªç³è¯·" }); |
| | | if (wcsResponse && !request) |
| | | otherDevice.Communicator.Write("DB15.0", false); //æ¸
é¤ååº |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); |
| | | 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]) ?? false) |
| | | { |
| | | result.Add(i); |
| | | } |
| | | } |
| | | return result.ToArray(); |
| | | } |
| | | } |
| | | } |