| | |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Comm.Http; |
| | | using WIDESEA_Common.Log; |
| | | using WIDESEAWCS_Common; |
| | |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_TaskInfoRepository; |
| | | |
| | |
| | | private readonly ITask_HtyRepository _taskHtyRepository; |
| | | private readonly ISys_ConfigService _sys_ConfigService; |
| | | private readonly IMapper _mapper; |
| | | private readonly IDeviceInfoRepository _deviceInfoRepository; |
| | | private readonly IDt_StationManagerRepository _stationManagerRepository; |
| | | |
| | | |
| | |
| | | public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList(); |
| | | public List<int> TaskRelocationboundTypes => typeof(TaskRelocationTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService taskHtyService, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository taskHtyRepository) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService taskHtyService, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository taskHtyRepository, |
| | | IDeviceInfoRepository deviceInfoRepository) : base(BaseDal) |
| | | { |
| | | _routerService = routerService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | |
| | | _taskHtyRepository = taskHtyRepository; |
| | | _mapper = mapper; |
| | | _sys_ConfigService = sys_ConfigService; |
| | | _deviceInfoRepository = deviceInfoRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | // éåä¼ å
¥çWMSTaskDTOå表 |
| | | foreach (var item in taskDTOs) |
| | | { |
| | | |
| | | var task = BaseDal.QueryFirst(x => x.WMSTaskNum == item.TaskId || x.PalletCode == item.TPbarcode); |
| | | if (task != null) |
| | | { |
| | | task.Creater = "WMS"; |
| | | task.Grade = 1; |
| | | task.PalletCode = item.TPbarcode; |
| | | } |
| | | |
| | | // 夿任å¡ç±»åæ¯å¦ä¸ºåºåºä»»å¡ |
| | | if (item.TaskType == "2") |
| | | { |
| | | string[] targetCodes = item.BeginPoint.Split("-"); |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2); |
| | | Dt_Task taskOut = new Dt_Task() |
| | | if (Convert.ToInt32(item.EndPoint) > 1999 && Convert.ToInt32(item.EndPoint) < 3000) |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | Creater = "WMS", |
| | | WMSTaskNum=item.TaskId, |
| | | Grade = 1, |
| | | PalletCode = item.TPbarcode, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | SourceAddress = item.BeginPoint, |
| | | CurrentAddress = item.BeginPoint, |
| | | Roadway = GetScCode(Convert.ToInt32(targetCodes[0])), |
| | | NextAddress = stationManager.stationChildCode, |
| | | TargetAddress = item.EndPoint, |
| | | RGVName = "RGV01" |
| | | }; |
| | | BaseDal.AddData(taskOut); |
| | | Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.EndPoint); |
| | | if (stationManagerStart == null) |
| | | { |
| | | return content.Error("æªæ¾å°åºåºç«å°ä¿¡æ¯"); |
| | | } |
| | | Dt_Task taskIn = new Dt_Task() |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | Creater = "WMS", |
| | | WMSTaskNum = item.TaskId, |
| | | Grade = 1, |
| | | PalletCode = item.TPbarcode, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | SourceAddress = item.BeginPoint, |
| | | CurrentAddress = item.BeginPoint, |
| | | Roadway = stationManagerStart.Roadway, |
| | | NextAddress = item.EndPoint, |
| | | TargetAddress = item.EndPoint, |
| | | Floor = stationManagerStart.stationFloor, |
| | | RGVName = "" |
| | | }; |
| | | BaseDal.AddData(taskIn); |
| | | } |
| | | else |
| | | { |
| | | |
| | | string[] targetCodes = item.BeginPoint.Split("-"); |
| | | |
| | | Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.EndPoint); |
| | | if (stationManagerEnd == null) |
| | | { |
| | | return content.Error("æªæ¾å°åºåºç«å°ä¿¡æ¯"); |
| | | } |
| | | |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2 && x.stationFloor == stationManagerEnd.stationFloor); |
| | | |
| | | var RGVName = string.Empty; |
| | | if (stationManager.stationFloor == "1F") |
| | | { |
| | | var deviceCode = _deviceInfoRepository.Db.Queryable<Dt_DeviceInfo>().Where(x => x.DeviceStatus == "1" && x.DeviceRemark == "1F").Where(x => x.DeviceCode.Contains("RGV")).ToList().Select(x => x.DeviceCode).ToList(); |
| | | if (deviceCode != null && deviceCode.Count() > 0) |
| | | { |
| | | if (deviceCode.Contains("RGV01") && deviceCode.Contains("RGV02")) |
| | | { |
| | | var RGVOne = BaseDal.QueryData(x => x.RGVName == "RGV01").ToList(); |
| | | var RGVTwo = BaseDal.QueryData(x => x.RGVName == "RGV02").ToList(); |
| | | if (RGVOne.Count > RGVTwo.Count) |
| | | { |
| | | RGVName = "RGV01"; |
| | | } |
| | | else |
| | | { |
| | | RGVName = "RGV02"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | RGVName = deviceCode[0]; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | RGVName = "RGV01"; |
| | | } |
| | | } |
| | | Dt_Task taskOut = new Dt_Task() |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | Creater = "WMS", |
| | | WMSTaskNum = item.TaskId, |
| | | Grade = 1, |
| | | PalletCode = item.TPbarcode, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | SourceAddress = item.BeginPoint, |
| | | CurrentAddress = item.BeginPoint, |
| | | Roadway = GetScCode(Convert.ToInt32(targetCodes[0])), |
| | | NextAddress = stationManager.stationChildCode, |
| | | TargetAddress = item.EndPoint, |
| | | RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName, |
| | | Floor = stationManager.stationFloor, |
| | | }; |
| | | BaseDal.AddData(taskOut); |
| | | } |
| | | } |
| | | // 夿任å¡ç±»åæ¯å¦ä¸ºå
¥åºä»»å¡ |
| | | else if (item.TaskType == "1") |
| | | { |
| | | task.TaskType = (int)TaskInboundTypeEnum.Inbound; |
| | | if (Convert.ToInt32(item.BeginPoint) > 1999 && Convert.ToInt32(item.BeginPoint) < 3000) |
| | | { |
| | | Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.BeginPoint); |
| | | if (stationManagerStart == null) |
| | | { |
| | | return content.Error("æªæ¾å°åºåºç«å°ä¿¡æ¯"); |
| | | } |
| | | Dt_Task taskIn = new Dt_Task() |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | Creater = "WMS", |
| | | WMSTaskNum = item.TaskId, |
| | | Grade = 1, |
| | | PalletCode = item.TPbarcode, |
| | | TaskType = (int)TaskInboundTypeEnum.Inbound, |
| | | TaskState = (int)TaskInStatusEnum.Line_InFinish, |
| | | SourceAddress = item.BeginPoint, |
| | | CurrentAddress = stationManagerStart.stationChildCode, |
| | | Roadway = stationManagerStart.Roadway, |
| | | NextAddress = item.EndPoint, |
| | | TargetAddress = item.EndPoint, |
| | | Floor = stationManagerStart.stationFloor, |
| | | RGVName = "" |
| | | }; |
| | | BaseDal.AddData(taskIn); |
| | | } |
| | | else |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == item.TPbarcode); |
| | | if (task != null) |
| | | { |
| | | task.Creater = "WMS"; |
| | | task.Grade = 1; |
| | | task.PalletCode = item.TPbarcode; |
| | | |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish; |
| | | task.TaskType = (int)TaskInboundTypeEnum.Inbound; |
| | | |
| | | task.CurrentAddress = item.BeginPoint; |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish; |
| | | |
| | | task.WMSTaskNum = item.TaskId; |
| | | task.CurrentAddress = item.BeginPoint; |
| | | |
| | | task.TargetAddress = item.EndPoint; |
| | | task.WMSTaskNum = item.TaskId; |
| | | |
| | | string[] targetCodes = item.EndPoint.Split("-"); |
| | | task.TargetAddress = item.EndPoint; |
| | | |
| | | task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0])); |
| | | string[] targetCodes = item.EndPoint.Split("-"); |
| | | |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3); |
| | | task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0])); |
| | | |
| | | task.NextAddress = stationManager.stationChildCode; |
| | | BaseDal.UpdateData(task); |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3 && x.stationFloor == task.Floor); |
| | | |
| | | task.NextAddress = stationManager.stationChildCode; |
| | | BaseDal.UpdateData(task); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"æªæ¾å°è¯¥æçã{item.TPbarcode}ãä»»å¡"); |
| | | } |
| | | } |
| | | } |
| | | else if (item.TaskType == "3") |
| | | { |
| | | task.TaskType = (int)TaskRelocationTypeEnum.Relocation; |
| | | Dt_Task taskRelocation = new Dt_Task() |
| | | { |
| | | TaskType = (int)TaskRelocationTypeEnum.Relocation, |
| | | |
| | | task.TaskState = (int)TaskRelocationStatusEnum.RelocationNew; |
| | | TaskState = (int)TaskRelocationStatusEnum.RelocationNew, |
| | | |
| | | task.SourceAddress = item.BeginPoint; |
| | | SourceAddress = item.BeginPoint, |
| | | |
| | | task.CurrentAddress = item.BeginPoint; |
| | | CurrentAddress = item.BeginPoint, |
| | | |
| | | task.NextAddress = item.EndPoint; |
| | | NextAddress = item.EndPoint, |
| | | |
| | | task.TargetAddress = item.EndPoint; |
| | | TargetAddress = item.EndPoint, |
| | | |
| | | task.Grade = 3; |
| | | Grade = 3, |
| | | |
| | | BaseDal.AddData(tasks); |
| | | }; |
| | | BaseDal.AddData(taskRelocation); |
| | | } |
| | | else |
| | | { |
| | |
| | | /// <param name="deviceNo">设å¤ç¼å·</param> |
| | | /// <param name="currentAddress">å½åå°å</param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryConveyorLineTask(string currentAddress) |
| | | public Dt_Task QueryConveyorLineTask(string currentAddress,int taskNum) |
| | | { |
| | | Dt_Task task= BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.RGV_InExecutingFinish && x.CurrentAddress == currentAddress, TaskOrderBy); |
| | | if (task == null) |
| | |
| | | /// <param name="deviceNo">设å¤ç¼å·</param> |
| | | /// <param name="currentAddress">å½åå°å</param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryConveyorLineFinishTask(string currentAddress) |
| | | public Dt_Task QueryConveyorLineFinishTask(string currentAddress,int taskNum) |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InExecuting && x.NextAddress == currentAddress, TaskOrderBy); |
| | | Dt_Task task = BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InExecuting && x.NextAddress == currentAddress && x.TaskNum == taskNum, TaskOrderBy); |
| | | if (task == null) |
| | | { |
| | | task = BaseDal.QueryFirst(x => TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting && x.NextAddress == currentAddress, TaskOrderBy); |
| | | task = BaseDal.QueryFirst(x => TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting && x.CurrentAddress == currentAddress && x.TaskNum == taskNum, TaskOrderBy); |
| | | } |
| | | return task; |
| | | } |
| | |
| | | BaseDal.DeleteData(task); |
| | | _taskHtyRepository.AddData(task_Hty); |
| | | } |
| | | if (task.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting) |
| | | { |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode == task.NextAddress); |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = task.TargetAddress; |
| | | } |
| | | |
| | | if (task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) |
| | | { |
| | |
| | | { |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | task.TaskState = nextStatus; |
| | | if (task.TaskState == (int)TaskInStatusEnum.Line_InExecuting) |
| | | { |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode== task.NextAddress); |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = stationManager.stationNextChildCode; |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish) |
| | | |
| | | if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish) |
| | | { |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = task.TargetAddress; |
| | |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.RGV_InExecuting) |
| | | { |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress); |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress && x.stationFloor == task.Floor); |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InExecutingFinish; |
| | | task.NextAddress = stationManager.stationNextChildCode; |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = stationManager.stationNextChildCode; |
| | | task.ModifyDate = DateTime.Now; |
| | | BaseDal.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"RGVå
¥åºå®æ"); |
| | |
| | | } |
| | | else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutFinish; |
| | | task.TaskState = (int)TaskOutStatusEnum.OutFinish; |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | |
| | |
| | | |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; |
| | | if (Convert.ToInt32(task.TargetAddress) > 1999 && Convert.ToInt32(task.TargetAddress) < 3000) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.OutFinish; ; |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2); |
| | | Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task); |
| | | task_Hty.TaskId = 0; |
| | | |
| | | task.CurrentAddress = task.NextAddress; |
| | | BaseDal.DeleteData(task); |
| | | _taskHtyRepository.AddData(task_Hty); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"å åæºåºåºå®æ"); |
| | | } |
| | | else |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; |
| | | |
| | | task.NextAddress = stationManager.stationNextChildCode; |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2 && x.stationFloor == task.Floor); |
| | | |
| | | BaseDal.UpdateData(task); |
| | | task.CurrentAddress = task.NextAddress; |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"å åæºåºåºå®æ"); |
| | | task.NextAddress = stationManager.stationNextChildCode; |
| | | |
| | | BaseDal.UpdateData(task); |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"å åæºåºåºå®æ"); |
| | | } |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) |
| | | { |
| | | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting) |
| | | { |
| | | //todo 忥å°WMS |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | task.TaskState = nextStatus; |
| | | task.TaskState = (int)TaskInStatusEnum.InFinish; ; |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent text(int taskNum) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var result = _stationManagerRepository.Db.Queryable<Dt_StationManager>() |
| | | .Where(t => SqlFunc.Abs(t.LevelPointFist - taskNum) <= 10) |
| | | .ToList(); |
| | | |
| | | return content.OK(data: result); |
| | | } |
| | | } |
| | | } |