| | |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | /// <summary> |
| | | /// è¾éçº¿åºæä½ä¸ç±»ï¼è´è´£å¤çè¾éçº¿åºæç«çPLC请æ±åWCSååºé»è¾ |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// 1. éè¿æ«ææ¡ç è·å订åä¿¡æ¯ <br/> |
| | | /// 2. æ ¹æ®è®¢åå°ºå¯¸å¤ææ¯å¦å¨å
许èå´å
<br/> |
| | | /// 3. çæä»»å¡å¹¶è®¾ç½®PLCç«ç¹çç®æ ä½ç½®åä»»å¡ç¼å· <br/> |
| | | /// 4. å¤çå¼å¸¸æ
åµå¹¶è®°å½é误æ¥å¿ <br/> |
| | | /// 5. 使ç¨[DisallowConcurrentExecution]ç¹æ§ç¡®ä¿ä½ä¸ä¸ä¼å¹¶åæ§è¡ |
| | | /// </remarks> |
| | | [DisallowConcurrentExecution] |
| | | public class CommonConveyorLineOutJob : JobBase, IJob |
| | | { |
| | |
| | | _containerRepository = containerRepository; |
| | | } |
| | | |
| | | |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | if (DischargeContainer == null) |
| | |
| | | } |
| | | |
| | | bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); |
| | | if (flag && value != null && value is OtherDevice) |
| | | if (flag && value != null && value is OtherDevice otherDevice) |
| | | { |
| | | OtherDevice otherDevice = (OtherDevice)value; |
| | | try |
| | | { |
| | | bool request = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.PLCStationRequest); //ç³è¯· |
| | |
| | | { |
| | | string barcode = otherDevice.GetValue<ConveyorLineStationDBName, string>(ConveyorLineStationDBName.PLCStationBarcode); |
| | | |
| | | //List<byte> bytes = otherDevice.Communicator.Read(devicePro.DeviceProAddress, devicePro.DeviceProDataLength).ToList(); |
| | | |
| | | //byte[] temp = bytes.ToArray().SelectMiddle(2, bytes.IndexOf(0) - 2); |
| | | |
| | | //barcode = Encoding.Default.GetString(temp); |
| | | |
| | | if (!string.IsNullOrEmpty(barcode)) |
| | | { |
| | | OrderInfo orderInfo = _orderDetailsService.GetOrderInfoByBarcode(barcode); |
| | | |
| | | _orderDetailsService.ToMes(barcode, 3); |
| | | Task.Run(() => |
| | | { |
| | | _orderDetailsService.ToMes(barcode, 3); |
| | | }); |
| | | |
| | | if (orderInfo.Width >= AppSettings.Get("MinWidth").ObjToInt() && orderInfo.Width <= AppSettings.Get("MaxWidth").ObjToInt() && orderInfo.Length >= AppSettings.Get("MinLength").ObjToInt() && orderInfo.Length <= AppSettings.Get("MaxLength").ObjToInt() || orderInfo.Length >= AppSettings.Get("MinWidth").ObjToInt() && orderInfo.Length <= AppSettings.Get("MaxWidth").ObjToInt() && orderInfo.Width >= AppSettings.Get("MinLength").ObjToInt() && orderInfo.Width <= AppSettings.Get("MaxLength").ObjToInt()) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | //if (message.Contains("10001")) |
| | | //{ |
| | | // otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length)); |
| | | // otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width)); |
| | | // otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness)); |
| | | // otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation); |
| | | // otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 999); |
| | | // otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true); |
| | | //} |
| | | //else if (message.Contains("10002")) |
| | | //{ |
| | | // WriteError($"{otherDevice.DeviceCode}-{otherDevice.DeviceName}", message); |
| | | //} |
| | | //else |
| | | { |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 998); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true); |
| | | |
| | | WriteError(nameof(CommonConveyorLineOutJob), message); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | if (ex.Message.Contains("10001")) |
| | | { |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 999); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true); |
| | | } |
| | | else if (ex.Message.Contains("10002")) |
| | | { |
| | | WriteError($"{otherDevice.DeviceCode}-{otherDevice.DeviceName}", ex.Message, ex); |
| | | } |
| | | else |
| | | { |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness)); |
| | |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 998); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true); |
| | | |
| | | WriteError(nameof(CommonConveyorLineOutJob), ex.Message, ex); |
| | | WriteError(nameof(CommonConveyorLineOutJob), message); |
| | | |
| | | WriteError("æ¿åæåºé误åå è®°å½æ¥å¿", message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 999); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true); |
| | | WriteError("æ¾æ¿é»è¾è¿ç®éè¯¯è®°å½æ¥å¿", ex.Message, ex); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | else |
| | | { |
| | | //todo è¶
宽å¤ç |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Length)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Width)); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, Convert.ToInt32(orderInfo.Thickness)); |
| | |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, dischargeStation); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTaskNum, 997); |
| | | otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true); |
| | | //otherDevice.SetValue(ConveyorLineStationDBName.WCSStationNoBarcode, true); |
| | | } |
| | | } |
| | | |
| | |
| | | WriteError(nameof(CommonConveyorLineOutJob), "åæ°é误,æªä¼ é设å¤åæ°æè®¾å¤ç±»åé误"); |
| | | } |
| | | 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(); |
| | | } |
| | | } |
| | | } |