|  |  |  | 
|---|
|  |  |  | using AutoMapper; | 
|---|
|  |  |  | using HslCommunication; | 
|---|
|  |  |  | using Mapster; | 
|---|
|  |  |  | using Microsoft.AspNetCore.Components.Routing; | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using SqlSugar; | 
|---|
|  |  |  | using System.Diagnostics.CodeAnalysis; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEAWCS_BasicInfoRepository; | 
|---|
|  |  |  | using WIDESEAWCS_BasicInfoService; | 
|---|
|  |  |  | using WIDESEAWCS_Common; | 
|---|
|  |  |  | 
|---|
|  |  |  | using WIDESEAWCS_ITaskInfoRepository; | 
|---|
|  |  |  | using WIDESEAWCS_ITaskInfoService; | 
|---|
|  |  |  | using WIDESEAWCS_Model.Models; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.DeviceBase; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Models; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Repository; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 判断任务目标地址和路径是否满足特定条件 | 
|---|
|  |  |  | if (task.TargetAddress == "002-021-001" && task.Roadway.Contains("JZ") && task.TaskType == (int)TaskOutboundTypeEnum.OutTray) | 
|---|
|  |  |  | if ((task.TargetAddress == "002-021-001" || task.TargetAddress == "001-021-001") && task.Roadway.Contains("JZ")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 设置任务状态为出库新建 | 
|---|
|  |  |  | task.TaskState = (int)TaskOutStatusEnum.OutNew; | 
|---|
|  |  |  | 
|---|
|  |  |  | // 判断任务类型是否为入库任务 | 
|---|
|  |  |  | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue; | 
|---|
|  |  |  | var valueList = value.Split(',').ToList(); | 
|---|
|  |  |  | // 判断源地址是否不等于"1359-4" | 
|---|
|  |  |  | if (task.SourceAddress != "1359-4") | 
|---|
|  |  |  | //if (task.SourceAddress != "1359-4" && task.SourceAddress != "1357-4") | 
|---|
|  |  |  | if (!valueList.Contains(task.SourceAddress)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 查询从源地址到目标地址的路由 | 
|---|
|  |  |  | List<Dt_Router> routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 设置当前地址为"002-021-001" | 
|---|
|  |  |  | task.CurrentAddress = "002-021-001"; | 
|---|
|  |  |  | task.CurrentAddress = string.Empty; | 
|---|
|  |  |  | if (task.SourceAddress == "1325-6") | 
|---|
|  |  |  | // 设置当前地址为"001-021-001" | 
|---|
|  |  |  | task.CurrentAddress = "001-021-001"; | 
|---|
|  |  |  | else | 
|---|
|  |  |  | // 设置当前地址为"002-021-001" | 
|---|
|  |  |  | task.CurrentAddress = "002-021-001"; | 
|---|
|  |  |  | // 设置下一个地址为目标地址 | 
|---|
|  |  |  | task.NextAddress = item.TargetAddress; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | wmsIpAddrss = GetIpAddress(SysConfigKeyConst.WMSIP_BASE, SysConfigKeyConst.RequestTask); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = sourceAddress, PalletCode = palletCode }.ToJsonString()); | 
|---|
|  |  |  | var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = sourceAddress, PalletCode = palletCode, stationManager.productLine }.ToJsonString()); | 
|---|
|  |  |  | content = JsonConvert.DeserializeObject<WebResponseContent>(result); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!content.Status) | 
|---|
|  |  |  | 
|---|
|  |  |  | _Task.TaskState = (int)TaskInStatusEnum.InNew; | 
|---|
|  |  |  | _Task.CurrentAddress = task.SourceAddress; | 
|---|
|  |  |  | _Task.NextAddress = station.stationNGChildCode; | 
|---|
|  |  |  | _Task.TargetAddress = station.stationNGLocation; | 
|---|
|  |  |  | _Task.Roadway = station.Roadway; | 
|---|
|  |  |  | _Task.TargetAddress = task.TargetAddress; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BaseDal.AddData(_Task); | 
|---|
|  |  |  | _taskExecuteDetailService.AddTaskExecuteDetail(_Task.TaskNum, "接收WMS任务"); | 
|---|
|  |  |  | 
|---|
|  |  |  | BaseDal.DeleteData(task); | 
|---|
|  |  |  | _taskHtyRepository.AddData(task_Hty); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | content = StackCraneTaskCompleted(task.TaskNum); | 
|---|
|  |  |  | return content; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (task.TaskState == (int)TaskInStatusEnum.SC_InFinish) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (App.User.UserId > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | content = StackCraneTaskCompleted(task.TaskNum); | 
|---|
|  |  |  | return content; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | task.ModifyDate = DateTime.Now; | 
|---|
|  |  |  | task.Modifier = "System"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return wcsBasez + address; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 重写方法 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override WebResponseContent DeleteData(object[] key) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | foreach (var item in key) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(item)); | 
|---|
|  |  |  | var taskHty = task.Adapt<Dt_Task_Hty>(); | 
|---|
|  |  |  | taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System"; | 
|---|
|  |  |  | _taskHtyRepository.AddData(taskHty); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return base.DeleteData(key); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion 重写方法 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|