| | |
| | | _noticeService = noticeService; |
| | | } |
| | | |
| | | public async Task Execute(IJobExecutionContext context) |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | { |
| | | await ProcessDeviceAsync(conveyorLine, childDeviceCode); |
| | | ProcessDeviceAsync(conveyorLine, childDeviceCode); |
| | | } |
| | | |
| | | List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | |
| | | { |
| | | Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | private async Task ProcessDeviceAsync(CommonConveyorLine conveyorLine, string childDeviceCode) |
| | | private void ProcessDeviceAsync(CommonConveyorLine conveyorLine, string childDeviceCode) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(childDeviceCode, "DeviceCommand"); |
| | | if (command != null && commandWrite != null) |
| | | { |
| | | |
| | | #region 调用事件总线通知前端 |
| | | |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos == null || !tokenInfos.Any()) |
| | | { |
| | | //throw new Exception(conveyorLine.DeviceName + "缓存中未找到Token缓存"); |
| | | return; |
| | | } |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | object obj = new |
| | | { |
| | | command, |
| | | commandWrite |
| | | }; |
| | | _noticeService.LineData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, childDeviceCode, data = obj }); |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | |
| | | var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | |
| | | List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); |
| | |
| | | MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, item.ProtocalDetailValue.ObjToInt() }); |
| | | var numRead = item.ProtocalDetailValue.ObjToInt(); |
| | | var numWrite = item.ProtocalDetailValue.ObjToInt() + 1; |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】【{childDeviceCode}】【{numRead.ToString()}】位输送线读取信号:【{structs[item.ProtocalDetailValue.ObjToInt()]}】 【{numWrite}】位WCS写入信号:【{structs[item.ProtocalDetailValue.ObjToInt() + 1]}】"); |
| | | if (structs[item.ProtocalDetailValue.ObjToInt() + 1] != structs[item.ProtocalDetailValue.ObjToInt()]) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, item.ProtocalDetailValue.ObjToInt() }); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | string[] x = devicePro.DeviceProAddress.Split('.'); |
| | | x[x.Length - 1] = (item.ProtocalDetailValue.ObjToInt() + 1).ToString(); |
| | | string DeviceProAddress = string.Join(".", x); |
| | | var writeRead = conveyorLine.Communicator.Read<bool>(DeviceProAddress); |
| | | if (writeRead) |
| | | { |
| | | conveyorLine.Communicator.Write(DeviceProAddress, false); |
| | | //ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false); |
| | | } |
| | | |
| | | |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false); |
| | | |
| | | //DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | //string[] x = devicePro.DeviceProAddress.Split('.'); |
| | | //x[x.Length - 1] = (item.ProtocalDetailValue.ObjToInt() + 1).ToString(); |
| | | //string DeviceProAddress = string.Join(".", x); |
| | | //var writeRead = conveyorLine.Communicator.Read<bool>(DeviceProAddress); |
| | | //if (writeRead) |
| | | //{ |
| | | // conveyorLine.Communicator.Write(DeviceProAddress, false); |
| | | // //ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false); |
| | | //} |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | #region 调用事件总线通知前端 |
| | | |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos == null || !tokenInfos.Any()) |
| | | { |
| | | //throw new Exception(conveyorLine.DeviceName + "缓存中未找到Token缓存"); |
| | | return; |
| | | } |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | object obj = new |
| | | { |
| | | childDeviceCode, |
| | | command, |
| | | commandWrite |
| | | }; |
| | | _noticeService.LineData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj }); |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | } |
| | | } |
| | | |
| | |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库"); |
| | | |
| | | var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode); |
| | | HandleTaskOut(conveyorLine, command, childDeviceCode, ProtocalDetailValue, task); |
| | | |
| | | if (task == null && command.Barcode != "NoRead" && command.Barcode.IsNotEmptyOrNull()) |
| | | if (task != null) |
| | | { |
| | | HandleNewTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue); |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray || task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | HandleTaskOut(conveyorLine, command, childDeviceCode, ProtocalDetailValue, task); |
| | | } |
| | | else |
| | | { |
| | | var next = task.NextAddress; |
| | | var taskCommand = MapTaskCommand(task, command); |
| | | task.NextAddress = next; |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库,下一目标地址【{taskCommand.TargetAddress}】"); |
| | | |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (task == null && command.Barcode != "NoRead" && command.Barcode.IsNotEmptyOrNull()) |
| | | { |
| | | task = _taskService.QueryBarcodeTask(command.Barcode, childDeviceCode); |
| | | if (task == null) |
| | | HandleNewTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param> |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成"); |
| | | var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish) |
| | | { |
| | |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线请求出库,task{task.ToJsonString()}"); |
| | | if (task != null) |
| | | { |
| | | if (command.Barcode == task.PalletCode) |
| | | //if (command.Barcode == task.PalletCode) |
| | | { |
| | | //task.NextAddress = task.NextAddress.Replace("-1", ""); |
| | | //ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | |
| | | var tasks = _taskRepository.QueryData(x => x.TaskType == (int)taskType && x.TargetAddress == childDeviceCode); |
| | | if (tasks.Count < index) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"【{childDeviceCode}】请求【{taskType.ToString()}】任务,已有【{taskType.ToString()}】任务【{tasks.Count}】,最多拥有【{index - 1}】"); |
| | | //ConsoleHelper.WriteErrorLine($"【{childDeviceCode}】请求【{taskType.ToString()}】任务,已有【{taskType.ToString()}】任务【{tasks.Count}】,最多拥有【{index - 1}】"); |
| | | |
| | | #region 调用WMS获取出库任务 |
| | | |