| | |
| | | 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_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 == "OneFloor").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, |
| | |
| | | Roadway = GetScCode(Convert.ToInt32(targetCodes[0])), |
| | | NextAddress = stationManager.stationChildCode, |
| | | TargetAddress = item.EndPoint, |
| | | RGVName = "RGV01" |
| | | RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName, |
| | | Floor= stationManager.stationFloor, |
| | | }; |
| | | BaseDal.AddData(taskOut); |
| | | } |
| | | // 夿任å¡ç±»åæ¯å¦ä¸ºå
¥åºä»»å¡ |
| | | else if (item.TaskType == "1") |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == item.TPbarcode); |
| | | if (task != null) |
| | | { |
| | | task.Creater = "WMS"; |
| | | task.Grade = 1; |
| | | task.PalletCode = item.TPbarcode; |
| | | |
| | | task.TaskType = (int)TaskInboundTypeEnum.Inbound; |
| | | |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish; |
| | |
| | | |
| | | 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"; |
| | | |
| | |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; |
| | | |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2); |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2 && x.stationFloor == task.Floor); |
| | | |
| | | task.CurrentAddress = task.NextAddress; |
| | | |
| | |
| | | } |
| | | 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"; |
| | | |