| | |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using System.Drawing; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using Mapster; |
| | | using AngleSharp.Io; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | return content.Error("当前托盘存在任务"); |
| | | } |
| | | |
| | | if (stationManager.stationType == 7) |
| | | { |
| | | var Station = await _stationManagerRepository.QueryFirstAsync(x => x.stationType == 6 && x.productLine == stationManager.productLine && x.stationArea == stationManager.stationArea); |
| | | var runTask = await BaseDal.QueryFirstAsync(x => x.SourceAddress == Station.stationChildCode && x.TaskState == (int)TaskInStatusEnum.InNew && x.TaskType == (int)TaskInboundTypeEnum.InTray); |
| | | if (runTask != null) |
| | | { |
| | | runTask.TargetAddress = stationManager.stationLocation; |
| | | runTask.NextAddress = stationManager.stationChildCode; |
| | | runTask.Grade = 3; |
| | | runTask.TaskType = (int)TaskOutboundTypeEnum.InToOut; |
| | | |
| | | var config1 = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wmsBase1 = config1.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue; |
| | | var requestTask1 = config1.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.SetEmptyOutbyInToOutAsync)?.ConfigValue; |
| | | if (wmsBase1 == null || requestTask1 == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP 未配置"); |
| | | } |
| | | var wmsIpAddrss1 = wmsBase1 + requestTask1; |
| | | |
| | | var result1 = await HttpHelper.PostAsync(wmsIpAddrss1, new { palletCode = runTask.PalletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString()); |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(result1); |
| | | if (content.Status) |
| | | { |
| | | await BaseDal.UpdateDataAsync(runTask); |
| | | return content.OK("成功"); |
| | | } |
| | | else |
| | | ConsoleHelper.WriteErrorLine(content.Message); |
| | | } |
| | | else |
| | | ConsoleHelper.WriteErrorLine("未找到空托盘入库任务"); |
| | | } |
| | | |
| | | var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue; |
| | | var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestInTask)?.ConfigValue; |
| | |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = palletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString()); |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | ConsoleHelper.WriteErrorLine($"{stationManager.stationChildCode}站台请求响应信息:{content.ToJsonString()}"); |
| | | if (!content.Status) |
| | | { |
| | | // wms失败返回去NG口任务 |
| | | |
| | | |
| | | //if (stationManager.stationChildCode != stationManager.stationNGChildCode) |
| | | //{ |
| | | // WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | // { |
| | | // Grade = 8, |
| | | // PalletCode = palletCode, |
| | | // SourceAddress = stationManager.stationLocation, |
| | | // TargetAddress = stationManager.stationNGLocation, |
| | | // RoadWay = stationManager.Roadway, |
| | | // TaskNum = 1000, |
| | | // TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | // TaskType = (int)TaskOutboundTypeEnum.InToOut |
| | | // }; |
| | | //} |
| | | return content; |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public async Task<WebResponseContent> RequestOutTaskToBZAsync(Dt_StationManager stationManager) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue; |
| | | var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestOutTaskToBZ)?.ConfigValue; |
| | | if (wmsBase == null || requestTask == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP 未配置"); |
| | | } |
| | | var wmsIpAddrss = wmsBase + requestTask; |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = stationManager.stationChildCode }.ToJsonString()); |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | if (!content.Status) |
| | | { |
| | | //无满足条件可出库至包装的库存 |
| | | return content; |
| | | } |
| | | |
| | | var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); |
| | | ConsoleHelper.WriteSuccessLine(content.Data.ToString()); |
| | | //_taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO })‘ |
| | | content = ReceiveWMSTask(new List<WMSTaskDTO> { task }); |
| | | //content = ReceiveByBZOtuTask(task); |
| | | //if (content.Status) |
| | | //{ |
| | | // //相应的在途数据+1 |
| | | // // _taskNeedBarcodeRepository.UpdateData(); |
| | | //} |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 接收WMS任务信息 |
| | | /// </summary> |
| | | /// <param name="taskDTOs">WMS任务对象集合</param> |
| | | /// <returns>返回处理结果</returns> |
| | | public WebResponseContent ReceiveByBZOtuTask([NotNull] WMSTaskDTO taskDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (BaseDal.QueryFirst(x => x.TaskNum == taskDTO.TaskNum || x.PalletCode == taskDTO.PalletCode) != null) |
| | | { |
| | | return content.OK(); |
| | | } |
| | | Dt_Task task = _mapper.Map<Dt_Task>(taskDTO); |
| | | task.Creater = "WMS"; |
| | | |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay); |
| | | task.TaskState = (int)TaskOutStatusEnum.OutNew; |
| | | task.CurrentAddress = stationinfo.stationChildCode; |
| | | task.NextAddress = stationinfo.stationChildCode; |
| | | task.SourceAddress = taskDTO.SourceAddress; |
| | | task.TargetAddress = taskDTO.TargetAddress; |
| | | } |
| | | BaseDal.AddData(task); |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.WMSId, "接收WMS任务"); |
| | | |
| | | content = WebResponseContent.Instance.OK("成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error($"任务接收错误,错误信息:{ex.Message}"); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 高温出库 |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据托盘号和设备号查询入库任务 |
| | | /// 根据托盘号和设备号查询任务 |
| | | /// </summary> |
| | | /// <param name="taskNum">任务号</param> |
| | | /// <param name="currentAddress">当前地址</param> |
| | |
| | | if (content.Status) |
| | | { |
| | | task.TaskState = 1; //任务完成 |
| | | var taskHty = task.Adapt<Dt_Task_Hty>(); |
| | | _taskHtyRepository.AddData(taskHty); |
| | | BaseDal.DeleteData(task); |
| | | } |
| | | |