| | |
| | | using Masuit.Tools; |
| | | using Masuit.Tools.Systems; |
| | | using Newtonsoft.Json; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.MOM; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_DTO.WMS; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; |
| | | |
| | |
| | | AbNormalStationBZTask(conveyorLine, command, childDeviceCode); |
| | | break; |
| | | case 1: |
| | | RequestWmsTask(conveyorLine, command, childDeviceCode); |
| | | RequestWmsTask(conveyorLine, command, childDeviceCode, stationManager); |
| | | break; |
| | | } |
| | | } |
| | |
| | | private ConveyorLineTaskCommand_After MapTaskCommand(Dt_Task task, ConveyorLineTaskCommand_After command) |
| | | { |
| | | var comm = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | comm.ResponState = 1; |
| | | comm.InteractiveSignal = command.InteractiveSignal; |
| | | return comm; |
| | | } |
| | |
| | | { |
| | | if (command.ConveyorLineBarcode != "NoRead") |
| | | { |
| | | |
| | | var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode); |
| | | #region |
| | | //var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | //var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue; |
| | | //var ipAddress = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.TrayCellsStatus)?.ConfigValue; |
| | | //if (wmsBase == null || ipAddress == null) |
| | | //{ |
| | | // throw new InvalidOperationException("MOM IP 未配置"); |
| | | //} |
| | | //var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode); |
| | | //TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | //{ |
| | | // Software = "WMS", |
| | | // TrayBarcode = command.ConveyorLineBarcode, |
| | | // EquipmentCode = stationManager.stationEquipMOM, |
| | | // SessionId = Guid.NewGuid().ToString(), |
| | | // EmployeeNo = "MITest", |
| | | // SceneType = "4", |
| | | // RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") |
| | | //}; |
| | | |
| | | if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null) |
| | | //var MOMIpAddress = wmsBase + ipAddress; |
| | | |
| | | //var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.ToJsonString()).Result; |
| | | //WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验请求参数【{trayCells.ToJsonString()}】"); |
| | | //WriteInfo("入站校验", ""); |
| | | //WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验返回参数【{result}】"); |
| | | //ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result); |
| | | |
| | | //if (result1.Success) |
| | | //{ |
| | | // var serialNosError = result1.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList(); |
| | | // if (serialNosError.Count > 0) |
| | | // { |
| | | // if (result1.ProcessCode == "AG01") |
| | | // { |
| | | // var strings = new List<string>() { "2234", "2226", "2218" }; |
| | | // foreach (var item in strings) |
| | | // { |
| | | // var station = _stationManagerRepository.QueryFirst(x => x.productLine == result1.ProductionLine && x.stationChildCode == item); |
| | | // if (station != null) |
| | | // { |
| | | // IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC); |
| | | // if (device != null) |
| | | // { |
| | | // CommonConveyorLine_After CommonConveyorLine_After = (CommonConveyorLine_After)device; |
| | | |
| | | // ConveyorLineTaskCommand_After taskCommand = new ConveyorLineTaskCommand_After() |
| | | // { |
| | | // ConveyorLineTaskNum = Convert.ToInt32(1), |
| | | // ConveyorLineTargetAddress = Convert.ToInt16(2234), |
| | | // ConveyorLineBarcode = command.ConveyorLineBarcode.ToString(), |
| | | // }; |
| | | // CommonConveyorLine_After.SendCommand(taskCommand, station.stationChildCode); |
| | | // CommonConveyorLine_After.SetValue(ConveyorLineDBName_After.ResponState, 1, station.stationChildCode); |
| | | // } |
| | | // //发送到分容 |
| | | // return; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // var strings = new List<string>() { "2142", "2094", "2046" }; |
| | | |
| | | // foreach (var item in strings) |
| | | // { |
| | | // var station = _stationManagerRepository.QueryFirst(x => x.productLine == result1.ProductionLine && x.stationChildCode == item); |
| | | // if (station != null) |
| | | // { |
| | | // IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC); |
| | | // if (device != null) |
| | | // { |
| | | // CommonConveyorLine_After CommonConveyorLine_After = (CommonConveyorLine_After)device; |
| | | // ConveyorLineTaskCommand_After conveyorLineAfter = CommonConveyorLine_After.ReadCustomer<ConveyorLineTaskCommand_After>(Convert.ToInt32(station.stationChildCode).ToString()); |
| | | // if (conveyorLineAfter.InteractiveSignal == 16) |
| | | // { |
| | | // var TaskNum = SnowFlake.LongId; |
| | | // Dt_Task task = new Dt_Task() |
| | | // { |
| | | // TaskNum = _taskRepository.GetTaskNo().Result, |
| | | // Grade = 1, |
| | | // PalletCode = command.ConveyorLineBarcode, |
| | | // Roadway = station.Roadway, |
| | | // SourceAddress = childDeviceCode, |
| | | // TargetAddress = station.stationChildCode, |
| | | // CurrentAddress = childDeviceCode, |
| | | // NextAddress = station.stationChildCode, |
| | | // TaskState = (int)TaskInStatusEnum.InNew, |
| | | // ExceptionMessage = "", |
| | | // TaskId = 0, |
| | | // TaskType = (int)TaskInboundTypeEnum.InTray, |
| | | // ProductionLine = result1.ProductionLine, |
| | | // }; |
| | | // _taskRepository.AddData(task); |
| | | // ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | // conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | // conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | // _taskService.UpdateTaskStatusToNext(task); |
| | | // } |
| | | // } |
| | | // //发送到分容 |
| | | // return; |
| | | // } |
| | | // } |
| | | // var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode); |
| | | |
| | | // if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null) |
| | | // { |
| | | // WriteInfo(conveyorLine.DeviceName, "当前托盘存在任务"); |
| | | // return; |
| | | // } |
| | | |
| | | // var content = CreateAndSendTask(taskDTO); |
| | | // if (content.Status) |
| | | // { |
| | | // var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | // if (task != null) |
| | | // { |
| | | // var taskCommand = MapTaskCommand(task, command); |
| | | // conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | // _taskService.UpdateTaskStatusToNext(task); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | //} |
| | | //else |
| | | //{ |
| | | // ConsoleHelper.WriteErrorLine(result1.MOMMessage); |
| | | //} |
| | | #endregion |
| | | |
| | | if (_taskRepository.QueryFirst(x => x.PalletCode == command.ConveyorLineBarcode) != null) |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, "当前托盘存在任务"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode); |
| | | |
| | | |
| | | var content = CreateAndSendTask(taskDTO); |
| | | if (content.Status) |
| | |
| | | { |
| | | var taskCommand = MapTaskCommand(task, command); |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | //} |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue; |
| | | var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTrayInTask)?.ConfigValue; |
| | | var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue; |
| | | if (wmsBase == null || requestTrayInTask == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP 未配置"); |
| | |
| | | /// <summary> |
| | | /// 请求WMS任务 |
| | | /// </summary> |
| | | private async void RequestWmsTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) |
| | | private async void RequestWmsTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, Dt_StationManager stationManager) |
| | | { |
| | | if (command.ConveyorLineBarcode.IsNullOrEmpty()) return; |
| | | |
| | | var Hastask = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode); |
| | | if (Hastask != null) |
| | | { |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(Hastask); |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | return; |
| | | } |
| | | |
| | | var content = await _taskService.RequestWMSTask(command.ConveyorLineBarcode, childDeviceCode); |
| | | if (content.Status) |
| | | { |
| | |
| | | if (task != null) |
| | | { |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, content.Message); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | ConsoleHelper.WriteErrorLine($"【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】请求点位:【{childDeviceCode}】异常信息【{content.Message}】"); |
| | | } |
| | | } |