| | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using SqlSugar; |
| | | using StackExchange.Profiling.Internal; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | |
| | | using WIDESEAWCS_Core.Utilities; |
| | | using WIDESEAWCS_DTO.Enum; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using static Microsoft.IO.RecyclableMemoryStreamManager; |
| | | using static System.Net.Mime.MediaTypeNames; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository; |
| | | private readonly ITask_HtyService _task_HtyService; |
| | | private readonly IMapper _mapper; |
| | | private readonly IEquipmentStatusService _equipmentStatus; |
| | | |
| | | |
| | | private Dictionary<string, OrderByType> _taskOrderBy = new() |
| | |
| | | |
| | | public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService task_HtyService, IRouterRepository routerRepository) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService task_HtyService, IRouterRepository routerRepository, IEquipmentStatusService equipmentStatus) : base(BaseDal) |
| | | { |
| | | _routerService = routerService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | |
| | | _task_HtyService = task_HtyService; |
| | | _mapper = mapper; |
| | | _routerRepository = routerRepository; |
| | | _equipmentStatus = equipmentStatus; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
°åWCSè°åæ¥å£ |
| | | /// </summary> |
| | | public string urlLanJianWCSAPI = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlLanJianWCSAPI"]; |
| | | /// <summary> |
| | | /// å
°åæ¥å£åï¼å åæºè¿è¡ç¶æï¼ |
| | | /// </summary> |
| | | public string LanJianStkRunStatus = WIDESEAWCS_Core.Helper.AppSettings.Configuration["LanJianStkRunStatus"]; |
| | | /// <summary> |
| | | /// å
°åä»»å¡å馿¥å£ |
| | | /// </summary> |
| | | public string LanJiantaskResult = WIDESEAWCS_Core.Helper.AppSettings.Configuration["LanJiantaskResult"]; |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶ä»»å¡ä¿¡æ¯ |
| | |
| | | /// <returns>è¿åå¤çç»æ</returns> |
| | | public ExpoReverse TaskInstruction(ExpoTaskDTO expoTask) |
| | | { |
| | | |
| | | |
| | | ExpoReverse content = new ExpoReverse(); |
| | | try |
| | | { |
| | | foreach (var item in expoTask.data) |
| | | { |
| | | //æ¥è¯¢æ°æ®åºï¼æ¥çæ¯å¦æå½åä»»å¡ |
| | | Dt_Task dt_Tasks = BaseDal.QueryFirst(x => x.TaskNum == item.taskNo); |
| | | if (dt_Tasks != null) |
| | | { |
| | | content.code = 1; |
| | | content.msg = $"æåWCSå·²æå½åä»»å¡IDï¼è¯·å¿éæ°ä¸åï¼ä»»å¡å·ï¼{dt_Tasks.TaskNum}"; |
| | | |
| | | WriteLog.Write_Log("任塿¥æ¶", "ä»»å¡éå¤", "å¼å¸¸ä»»å¡", $"ä»»å¡å·ï¼{dt_Tasks.TaskNum}éå¤,å
°åç³»ç»ä¸åéå¤ä»»å¡ï¼ï¼ï¼"); |
| | | return content; |
| | | } |
| | | |
| | | |
| | | if (item.type == 1) //å
¥åº |
| | | { |
| | | Dt_Task dt_Task = new Dt_Task(); |
| | |
| | | dt_Task.SourceAddress = item.startAddress; |
| | | dt_Task.TargetAddress = item.endAddress; |
| | | dt_Task.CurrentAddress = item.startAddress; |
| | | dt_Task.NextAddress = "0"; //ç®åææ |
| | | dt_Task.NextAddress = "1021"; //ç®åææ |
| | | dt_Task.Grade = item.priority; |
| | | dt_Task.WMSId = 0; //ç®åææ |
| | | BaseDal.AddData(dt_Task); |
| | | content.code = 0; |
| | | |
| | | int taskidt= BaseDal.QueryFirst(x=>x.TaskNum== dt_Task.TaskNum).TaskId; |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskidt, $"ç³»ç»èªå¨æµç¨ï¼å建任å¡"); |
| | | } |
| | | else if (item.type == 2) //åºåº |
| | | { |
| | |
| | | dt_Task.WMSId = 0; //ç®åææ |
| | | BaseDal.AddData(dt_Task); |
| | | content.code = 0; |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(dt_Task.TaskId,$"ç³»ç»èªå¨æµç¨ï¼å建任å¡"); |
| | | } |
| | | else |
| | | { |
| | |
| | | content.msg = $"ä»»å¡ç±»åé误ï¼wcsæ¥æ¶å°çç±»å为ï¼{item.type}"; |
| | | } |
| | | } |
| | | WriteLog.Write_Log("任塿¥æ¶", "æ¥æ¶å
°åä¸åä»»å¡", "æå", $"æ¥æ¶å°çæ°æ®ä¸ºï¼{expoTask.ToJson()}"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.code = 1; |
| | | content.msg = $"æ°æ®é误ï¼åå ï¼{ex.Message}"; |
| | | WriteLog.Write_Log("任塿¥æ¶", "æ¥æ¶å
°åä¸åä»»å¡å¼å¸¸", "å¼å¸¸", ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | |
| | | task.ModifyDate = DateTime.Now; |
| | | BaseDal.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, task.ExceptionMessage); |
| | | |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯,ä»»å¡å·:ã{taskNum}ã"); |
| | | if (task == null) |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯,ä»»å¡å·:ã{taskNum}ã"); |
| | | |
| | | int oldState = task.TaskState; |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | |
| | | try |
| | | { |
| | | if (task.TaskState == (int)TaskInStatusEnum.RGV_InPickupExecuting) //ç±åè´§ä¸==ãåè´§å®æ |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InPickupFinish; |
| | | task.CurrentAddress = "1021"; //æ¾è´§çå°å |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; //æ¾è´§ |
| | | HandleInboundTask(task); |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.RGV_InReleaseExecuting) |
| | | else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InReleaseFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; //åè´§ |
| | | task.Roadway = "RGV104"; |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.RGV_InZicheExecuting) |
| | | { |
| | | Dt_Router dt_Router = _routerRepository.QueryFirst(x => x.StartPosi == task.CurrentAddress && x.ChildPosi == task.TargetAddress && x.IsEnd == false); |
| | | if (dt_Router != null) |
| | | { |
| | | if (task.CurrentAddress == "1061") //HCJç«å° |
| | | { |
| | | task.Roadway = "RGV107"; |
| | | } |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InZicheFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; //åè´§ |
| | | task.CurrentAddress = dt_Router.NextPosi; |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (task.TargetAddress == "3" && task.TargetAddress == "4") |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InZicheFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; //åè´§ |
| | | task.CurrentAddress = "1061"; |
| | | } |
| | | } |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.RGV_InZicheReleaseExecuting) |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InZicheReleaseFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.TravelingOnly; |
| | | task.CurrentAddress = "1021"; //æ¤æ¬¡å¾
ä¿®æ¹ï¼éè¦èè2å·åè½¦ç§»å¨ |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.RGV_InZichemoveExecuting) |
| | | { |
| | | Dt_Router dt_Router = _routerRepository.QueryFirst(x => x.IsEnd == true && x.ChildPosi == task.TargetAddress && x.InOutType == 1); |
| | | |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InZichemoveFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.TravelingOnly; |
| | | task.CurrentAddress = dt_Router.NextPosi; //æ¤æ¬¡å¾
ä¿®æ¹ï¼éè¦èè2å·åè½¦ç§»å¨ |
| | | task.Roadway = dt_Router.ChildPosiDeviceCode; |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.RGV_InMothercarExecuting) |
| | | { |
| | | //ææ»ä»»å¡å®æ |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InMothercarFinish; |
| | | } |
| | | } |
| | | else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutMothercarExecuting) |
| | | { |
| | | Dt_Router dt_Router = _routerRepository.QueryFirst(x => x.StartPosi == task.CurrentAddress && x.IsEnd == true && x.InOutType == 2); |
| | | if (dt_Router != null) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutMothercarFinish; |
| | | task.CurrentAddress = dt_Router.NextPosi; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | task.Roadway = dt_Router.ChildPosiDeviceCode; //æ¾è´§çå°å |
| | | } |
| | | else |
| | | { |
| | | Dt_Router dt_Rout = _routerRepository.QueryFirst(x => x.StartPosi == task.CurrentAddress && x.IsEnd == false && x.InOutType == 2); |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutMothercarFinish; |
| | | task.CurrentAddress = dt_Rout.StartPosi; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | task.Roadway = dt_Rout.ChildPosiDeviceCode; |
| | | } |
| | | } |
| | | else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutZicheExecuting) |
| | | { |
| | | if ((task.CurrentAddress == "1101" || task.CurrentAddress == "1121") && task.TaskState == (int)TaskOutStatusEnum.RGV_OutZicheExecuting) |
| | | { |
| | | Dt_Router dt_Router = _routerRepository.QueryFirst(x => x.StartPosi == task.CurrentAddress && x.InOutType == 2); |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutZicheFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; |
| | | task.Roadway = dt_Router.ChildPosiDeviceCode; |
| | | task.CurrentAddress = dt_Router.NextPosi; |
| | | |
| | | } |
| | | else |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutZicheFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; |
| | | task.CurrentAddress = "1171"; |
| | | task.Roadway = "RGV116"; |
| | | } |
| | | |
| | | /*Dt_Router dt_Router = _routerRepository.QueryFirst(x => x.StartPosi == task.CurrentAddress && x.InOutType == 2); |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutZicheFinish; |
| | | task.CurrentAddress = dt_Router.NextPosi; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing;*/ |
| | | } |
| | | else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutZicheReleaseExecuting) |
| | | { |
| | | if (task.CurrentAddress == "1131") |
| | | { |
| | | Dt_Router dt_Router = _routerRepository.QueryFirst(x => x.StartPosi == task.CurrentAddress && x.InOutType == 2); |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutMothercarFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | task.Roadway = dt_Router.ChildPosiDeviceCode; |
| | | } |
| | | else |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutZicheReleaseFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | task.Roadway = "RGV118"; |
| | | } |
| | | } |
| | | else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutPickupExecuting) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutPickupFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; |
| | | task.CurrentAddress = ""; |
| | | } |
| | | else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutReleaseExecuting) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.OutFinish; //ä»»å¡å®æ |
| | | HandleOutboundTask(task); |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error(); |
| | | return WebResponseContent.Instance.Error("æªç¥çä»»å¡ç±»å"); |
| | | } |
| | | |
| | | task.ExceptionMessage = string.Empty; |
| | | BaseDal.UpdateData(task); |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail( |
| | | task.TaskId, |
| | | $"èªå¨ä»»å¡ç¶æä»ã{oldState}ãè¿å
¥å°ã{task.TaskState}ã" |
| | | ); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | task.ExceptionMessage = string.Empty; |
| | | return WebResponseContent.Instance.Error("æ´æ°ä»»å¡ç¶ææ¶åçç³»ç»é误"); |
| | | } |
| | | } |
| | | #region å
¥åº |
| | | |
| | | BaseDal.UpdateData(task); |
| | | private void HandleInboundTask(Dt_Task task) |
| | | { |
| | | switch (task.TaskState) |
| | | { |
| | | case (int)TaskInStatusEnum.RGV_InPickupExecuting: |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InPickupFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; |
| | | break; |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"èªå¨ä»»å¡ç¶æä»ã{oldState}ãè¿å
¥å°ã{task.TaskState}ãï¼"); |
| | | case (int)TaskInStatusEnum.RGV_InReleaseExecuting: |
| | | HandleInboundRelease(task); |
| | | break; |
| | | |
| | | content = WebResponseContent.Instance.OK(); |
| | | case (int)TaskInStatusEnum.RGV_InZicheExecuting: |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InZicheFinish; |
| | | break; |
| | | |
| | | return content; |
| | | case (int)TaskInStatusEnum.RGV_InZicheReleaseExecuting: |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InZicheReleaseFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.TravelingOnly; |
| | | break; |
| | | |
| | | case (int)TaskInStatusEnum.RGV_InZichemoveExecuting: |
| | | HandleInboundZichemove(task); |
| | | break; |
| | | |
| | | case (int)TaskInStatusEnum.RGV_InMothercarExecuting: |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InMothercarFinish; |
| | | break; |
| | | |
| | | default: |
| | | throw new InvalidOperationException($"æªç¥çå
¥åºä»»å¡ç¶æ: {task.TaskState}"); |
| | | } |
| | | } |
| | | |
| | | private void HandleInboundRelease(Dt_Task task) |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InReleaseFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | |
| | | var routes = _routerRepository.QueryData(x => |
| | | x.StartPosi == task.NextAddress && |
| | | x.InOutType == 1 && |
| | | x.IsEnd == false |
| | | ); |
| | | |
| | | foreach (var route in routes) |
| | | { |
| | | if (route.ChildPosi == task.TargetAddress || |
| | | (int.Parse(route.ChildPosi) > 2 && int.Parse(task.TargetAddress) > 2)) |
| | | { |
| | | task.Roadway = route.ChildPosiDeviceCode; |
| | | task.CurrentAddress = route.StartPosi; |
| | | task.NextAddress = route.NextPosi; |
| | | break; // æ¾å°å¹é
è·¯ç±åéåºå¾ªç¯ |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void HandleInboundZichemove(Dt_Task task) |
| | | { |
| | | try |
| | | { |
| | | Dt_Router dt_Router = null; |
| | | task.TaskState = (int)TaskInStatusEnum.RGV_InZichemoveFinish; |
| | | if (task.TargetAddress == "4" || task.TargetAddress == "3") |
| | | { |
| | | dt_Router = _routerRepository.QueryFirst(x => |
| | | x.StartPosi == task.NextAddress && |
| | | x.InOutType == 1); |
| | | if (task.CurrentAddress != "1061") task.TaskState = (int)TaskInStatusEnum.RGV_InReleaseFinish; |
| | | |
| | | } |
| | | else |
| | | { |
| | | dt_Router = _routerRepository.QueryFirst(x => |
| | | x.IsEnd == true && |
| | | x.ChildPosi == task.NextAddress && |
| | | x.InOutType == 1); |
| | | } |
| | | |
| | | |
| | | if (dt_Router == null) |
| | | throw new InvalidOperationException("æªæ¾å°å¯¹åºçç»æè·¯ç±"); |
| | | |
| | | |
| | | |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | task.CurrentAddress = dt_Router.StartPosi; |
| | | task.NextAddress = dt_Router.NextPosi; |
| | | task.Roadway = dt_Router.ChildPosiDeviceCode; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region åºåº |
| | | |
| | | private void HandleOutboundTask(Dt_Task task) |
| | | { |
| | | switch (task.TaskState) |
| | | { |
| | | case (int)TaskOutStatusEnum.RGV_OutMothercarExecuting: |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutMothercarFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | break; |
| | | |
| | | case (int)TaskOutStatusEnum.RGV_OutZicheExecuting: |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutZicheFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; |
| | | break; |
| | | |
| | | case (int)TaskOutStatusEnum.RGV_OutZicheReleaseExecuting: |
| | | HandleOutboundZicheRelease(task); |
| | | break; |
| | | |
| | | case (int)TaskOutStatusEnum.RGV_OutPickupExecuting: |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutPickupFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.Placing; |
| | | break; |
| | | |
| | | case (int)TaskOutStatusEnum.RGV_OutReleaseExecuting: |
| | | task.TaskState = (int)TaskOutStatusEnum.OutFinish; |
| | | break; |
| | | |
| | | default: |
| | | throw new InvalidOperationException($"æªç¥çåºåºä»»å¡ç¶æ: {task.TaskState}"); |
| | | } |
| | | } |
| | | |
| | | private void HandleOutboundZicheRelease(Dt_Task task) |
| | | { |
| | | var route = _routerRepository.QueryFirst(x => |
| | | x.StartPosi == task.CurrentAddress && |
| | | x.InOutType == 2 |
| | | ); |
| | | |
| | | if (route == null) |
| | | throw new InvalidOperationException("æªæ¾å°å¯¹åºçè·¯ç±ä¿¡æ¯"); |
| | | |
| | | if (route.IsEnd) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutZicheReleaseFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | task.Roadway = "RGV118"; |
| | | } |
| | | else |
| | | { |
| | | var nextRoute = _routerRepository.QueryFirst(x => |
| | | x.StartPosi == task.NextAddress && |
| | | x.InOutType == 2 |
| | | ); |
| | | |
| | | if (nextRoute == null) |
| | | throw new InvalidOperationException("æªæ¾å°ä¸ä¸ä¸ªè·¯ç±ä¿¡æ¯"); |
| | | |
| | | task.TaskState = (int)TaskOutStatusEnum.RGV_OutMothercarFinish; |
| | | task.RGVTaskType = (int)RGVTaskTypeEnum.PickingUp; |
| | | task.CurrentAddress = nextRoute.StartPosi; |
| | | task.NextAddress = nextRoute.NextPosi; |
| | | task.Roadway = route.ChildPosiDeviceCode; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region å
°åè°åæ¥å£å
容 |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢RGVç¶æ |
| | |
| | | ExpoReverse expoReverse = new ExpoReverse(); |
| | | try |
| | | { |
| | | if (sCErrorStatus == null) |
| | | { |
| | | expoReverse.code = 1; |
| | | expoReverse.msg = "æåWCSæ¥æ¶å°çåæ°ä¸ºç©ºï¼è¯·æ£æ¥"; |
| | | return expoReverse; |
| | | } |
| | | |
| | | List<EquipmentStatus> equipmentdata = new List<EquipmentStatus>(); |
| | | |
| | | List<EquipmentStatus> equipmentList = _equipmentStatus.GetEquipmentStatus(); |
| | | string msgeetst = ""; |
| | | foreach (var item in sCErrorStatus.data) |
| | | { |
| | | if (sCErrorStatus == null) |
| | | { |
| | | expoReverse.code = 1; |
| | | expoReverse.msg = "æåWCSæ¥æ¶å°çåæ°ä¸ºç©ºï¼è¯·æ£æ¥"; |
| | | return expoReverse; |
| | | } |
| | | expoReverse.code = 0; |
| | | EquipmentStatus equipment = equipmentList.Find(x => x.Equipment_Number == item.stackerName); |
| | | |
| | | msgeetst += $"ã设å¤ï¼{equipment.Equipment_Number}ï¼ä¿®æ¹åç¶æï¼{equipment.Equipment_Status}ï¼"; |
| | | |
| | | equipment.Equipment_Status = item.errorStatus; |
| | | |
| | | msgeetst += $"<ä¿®æ¹åç¶æï¼{equipment.Equipment_Status}>ã................"; |
| | | equipmentdata.Add(equipment); |
| | | } |
| | | |
| | | WriteLog.Write_Log("设å¤ç¶ææ´æ¹", "å åæºç¶ææ´æ¹", "æ£å¸¸", msgeetst); |
| | | _equipmentStatus.UpdateData(equipmentdata); //ä¿®æ¹ç¶æ |
| | | expoReverse.code = 0; |
| | | |
| | | |
| | | return expoReverse; |
| | | } |
| | |
| | | { |
| | | expoReverse.code = 1; |
| | | expoReverse.msg = $"æåWCSæ¥å£é误ï¼{ex.Message}"; |
| | | WriteLog.Write_Log("设å¤ç¶ææ´æ¹", "å åæºç¶ææ´æ¹", "å¼å¸¸", ex.Message); |
| | | return expoReverse; |
| | | } |
| | | } |
| | |
| | | try |
| | | { |
| | | List<Dt_Task> _TaskList = BaseDal.QueryData(x => x.TaskType == (int)TaskInboundTypeEnum.Inbound).ToList(); |
| | | |
| | | |
| | | |
| | | foreach (var item in taskcanceled.data) |
| | | { |
| | | if (taskcanceled == null) |
| | |
| | | _task_HtyService.AddTaskHty(dt_Task); |
| | | BaseDal.DeleteData(dt_Task); |
| | | expoReverse.code = 0; |
| | | WriteLog.Write_Log("ä»»å¡åæ¶ä¿¡æ¯", "ä»»å¡åæ¶", "ä¿¡æ¯", $"ä»»å¡å·ï¼{dt_Task.TaskNum}ï¼å·²åæ¶"); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | return expoReverse; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | return expoReverse; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent StkRunStatus() |
| | | { |
| | | WebResponseContent responseContent=new WebResponseContent(); |
| | | WebResponseContent responseContent = new WebResponseContent(); |
| | | // å建并èµå¼ |
| | | StkRunStatusReception reception = new StkRunStatusReception { data = new List<StkRunStatusData> { new StkRunStatusData { stackerName = "ALL" } } }; |
| | | StkRunStatusReturns LJReturns = HttpHelper.Post<StkRunStatusReturns>(urlLanJianWCSAPI + LanJianStkRunStatus, reception, "æ¥è¯¢å åæºè¿è¡ç¶æ"); |
| | | if (LJReturns.code == 0) |
| | | { |
| | | if (LJReturns.data[0].runStatus == 0) //å
¨é¨å åæºä¸å¨è¿è¡ç¶æ |
| | | { |
| | | return responseContent.OK(); |
| | | } |
| | | else |
| | | { |
| | | return responseContent.Error($"æå åæºå¨è¿è¡ä¸ï¼ä¸å¯éå¶"); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | WriteLog.Write_Log("å åæºè¿è¡ç¶ææ¥è¯¢", "ç¶ææ¥è¯¢å¤±è´¥", "æ¥å£è°å失败", $"è¿åå
容ï¼{LJReturns.msg}"); |
| | | return responseContent.Error($"è°åå
°åWCS失败ï¼ï¼è¿åå
容ï¼{LJReturns.msg}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ä¿¡æ¯ç¶æä¸ä¼ (åºå®å
¥åºæ¥å£) |
| | | /// </summary> |
| | | /// <param name="sCErrorStatus"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent TaskResultIn(string taskNo, string finalAddress, int status, string remark) |
| | | { |
| | | WebResponseContent responseContent = new WebResponseContent(); |
| | | TaskfeedbackResponse reception = new TaskfeedbackResponse { data = new List<TaskfeedbackData> { new TaskfeedbackData { taskNo = taskNo, type = 1, finalAddress = finalAddress, status = status, remark = remark } } }; |
| | | StkRunStatusReturns LJReturns = HttpHelper.Post<StkRunStatusReturns>(urlLanJianWCSAPI + LanJiantaskResult, reception, "ä»»å¡å馿¥å£"); |
| | | if (LJReturns.code == 0) |
| | | { |
| | | responseContent.OK("ä¸ä¼ æå"); |
| | | } |
| | | else |
| | | { |
| | | responseContent.OK("ä¸ä¼ 失败ï¼åå ï¼" + LJReturns.msg); |
| | | } |
| | | // å建并èµå¼ |
| | | return responseContent; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ä¿¡æ¯ç¶æä¸ä¼ (åºå®åºåºæ¥å£) |
| | | /// </summary> |
| | | /// <param name="sCErrorStatus"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent TaskResultOut(string taskNo, string finalAddress, int status, string remark) |
| | | { |
| | | WebResponseContent responseContent = new WebResponseContent(); |
| | | TaskfeedbackResponse reception = new TaskfeedbackResponse { data = new List<TaskfeedbackData> { new TaskfeedbackData { taskNo = taskNo, type = 1, finalAddress = finalAddress, status = status, remark = remark } } }; |
| | | StkRunStatusReturns LJReturns = HttpHelper.Post<StkRunStatusReturns>(urlLanJianWCSAPI + LanJiantaskResult, reception, "ä»»å¡å馿¥å£"); |
| | | if (LJReturns.code == 0) |
| | | { |
| | | responseContent.OK("ä¸ä¼ æå"); |
| | | } |
| | | else |
| | | { |
| | | responseContent.OK("ä¸ä¼ 失败ï¼åå ï¼" + LJReturns.msg); |
| | | } |
| | | // å建并èµå¼ |
| | | return responseContent; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 人工æå¨å®æ |
| | | /// </summary> |
| | | /// <param name="ids"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public WebResponseContent CompletedManually(int id) |
| | | { |
| | | |
| | | var db = BaseDal.Db as SqlSugarClient; |
| | | |
| | | try |
| | | { |
| | | db.Ado.BeginTran(); |
| | | |
| | | |
| | | Dt_Task dt_task = BaseDal.QueryData().Where(x => x.TaskId == id).FirstOrDefault(); |
| | | if (dt_task == null) return WebResponseContent.Instance.Error($"æªæ¥è¯¢å°ä»»å¡"); |
| | | |
| | | var res = _task_HtyService.AddData(new Dt_Task_hty |
| | | { |
| | | TaskNum = dt_task.TaskNum, |
| | | PalletCode = dt_task.PalletCode, |
| | | Roadway = dt_task.Roadway, |
| | | TaskType = dt_task.TaskType, |
| | | TaskState = dt_task.TaskState, |
| | | SourceAddress = dt_task.SourceAddress, |
| | | TargetAddress = dt_task.TargetAddress, |
| | | CurrentAddress = dt_task.CurrentAddress, |
| | | NextAddress = dt_task.NextAddress, |
| | | WMSId = dt_task.WMSId, |
| | | Dispatchertime = dt_task.Dispatchertime, |
| | | Remark = "人工æå¨å®æ", |
| | | Creater = App.User.UserName, |
| | | CreateDate = DateTime.Now, |
| | | RGVTaskType = dt_task.RGVTaskType, |
| | | RGVCurrentexecution = dt_task.RGVCurrentexecution |
| | | }); |
| | | |
| | | int oldState = dt_task.TaskState; |
| | | _taskExecuteDetailService.AddTaskExecuteDetail( |
| | | dt_task.TaskId, |
| | | $"èªå¨ä»»å¡ç¶æä»ã{oldState}ãè¿å
¥å°ã{dt_task.TaskState}ã" |
| | | ); |
| | | |
| | | if (res.Status == false) |
| | | { |
| | | db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error("æå¨å®æå¤±è´¥ï¼"); |
| | | } |
| | | |
| | | var deletetask = BaseDal.DeleteData(dt_task); |
| | | if (deletetask == false) { |
| | | db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error("å é¤ä»»å¡å¤±è´¥æææä½åæ»ï¼"); |
| | | } |
| | | db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK("æå¨å®ææåï¼"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error("æå¨å®æå¤±è´¥ï¼"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 人工æå¨åæ¶ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public WebResponseContent MHWCSTaskCancel(int id) |
| | | { |
| | | var db = BaseDal.Db as SqlSugarClient; |
| | | |
| | | try |
| | | { |
| | | db.Ado.BeginTran(); |
| | | Dt_Task dt_task = BaseDal.QueryData().Where(x => x.TaskId == id).FirstOrDefault(); |
| | | if (dt_task == null) return WebResponseContent.Instance.Error($"æªæ¥è¯¢å°ä»»å¡"); |
| | | //if (dt_task.TaskState > (int)TaskInStatusEnum.RGV_InNew || dt_task.TaskState > (int)TaskOutStatusEnum.OutNew) return WebResponseContent.Instance.Error($"ä»»å¡ç¶æä¸å
è®¸åæ¶"); |
| | | /*if (dt_task.TaskType >= 200 && dt_task.TaskType <= 203) |
| | | { |
| | | if (dt_task.TaskState > (int)TaskInStatusEnum.RGV_InNew) return WebResponseContent.Instance.Error($"ä»»å¡ç¶æä¸å
è®¸åæ¶"); |
| | | } |
| | | else |
| | | { |
| | | if (dt_task.TaskState > (int)TaskOutStatusEnum.OutNew) return WebResponseContent.Instance.Error($"ä»»å¡ç¶æä¸å
è®¸åæ¶"); |
| | | |
| | | }*/ |
| | | |
| | | Dt_Task_hty dt_Task_Hty = new Dt_Task_hty |
| | | { |
| | | TaskNum = dt_task.TaskNum, |
| | | PalletCode = dt_task.PalletCode, |
| | | Roadway = dt_task.Roadway, |
| | | TaskType = dt_task.TaskType, |
| | | TaskState = dt_task.TaskType >= (int)TaskInboundTypeEnum.Inbound ? (int)TaskInStatusEnum.InCancel : (int)TaskOutStatusEnum.OutCancel, |
| | | SourceAddress = dt_task.SourceAddress, |
| | | TargetAddress = dt_task.TargetAddress, |
| | | CurrentAddress = dt_task.CurrentAddress, |
| | | NextAddress = dt_task.NextAddress, |
| | | WMSId = dt_task.WMSId, |
| | | Dispatchertime = dt_task.Dispatchertime, |
| | | Remark = "人工æå¨åæ¶ä»»å¡", |
| | | Creater = App.User.UserName, |
| | | CreateDate = DateTime.Now, |
| | | RGVTaskType = dt_task.RGVTaskType, |
| | | RGVCurrentexecution = dt_task.RGVCurrentexecution |
| | | }; |
| | | var res = _task_HtyService.AddData(dt_Task_Hty); |
| | | if (res.Status == false) { |
| | | db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error("åæ¶ä»»å¡å¤±è´¥ï¼"); |
| | | } |
| | | int oldState = dt_task.TaskState; |
| | | _taskExecuteDetailService.AddTaskExecuteDetail( |
| | | dt_task.TaskId, |
| | | $"èªå¨ä»»å¡ç¶æä»ã{oldState}ãè¿å
¥å°ã{dt_Task_Hty.TaskState}ã" |
| | | ); |
| | | |
| | | bool deletetask = BaseDal.DeleteData(dt_task); |
| | | if (!deletetask) { |
| | | db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error("å é¤ä»»å¡å¤±è´¥æææä½åæ»ï¼"); |
| | | } |
| | | db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK("忶任塿åï¼"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error("åæ¶ä»»å¡å¤±è´¥ï¼"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ä¸ä¸æ¥æ§è¡ |
| | | /// </summary> |
| | | /// <param name="sCErrorStatus"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent NextStepeXecuted(int taskid) |
| | | { |
| | | WebResponseContent responseContent = new WebResponseContent(); |
| | | Dt_Task task = BaseDal.QueryData().Where(x => x.TaskNum == taskid).FirstOrDefault(); |
| | | if (task == null) return WebResponseContent.Instance.Error($"æªæ¥è¯¢å°ä»»å¡"); |
| | | switch (task.TaskState) |
| | | { |
| | | //å
¥åºç¶æ |
| | | case (int)TaskInStatusEnum.RGV_InNew: |
| | | case (int)TaskInStatusEnum.RGV_InPickupFinish: |
| | | case (int)TaskInStatusEnum.RGV_InReleaseFinish: |
| | | case (int)TaskInStatusEnum.RGV_InZicheFinish: |
| | | case (int)TaskInStatusEnum.RGV_InZicheReleaseFinish: |
| | | case (int)TaskInStatusEnum.RGV_InZichemoveFinish: |
| | | //å
¥åºç¶æ |
| | | //åºåºç¶æ |
| | | case (int)TaskOutStatusEnum.OutNew: |
| | | case (int)TaskOutStatusEnum.RGV_OutMothercarFinish: |
| | | case (int)TaskOutStatusEnum.RGV_OutZicheFinish: |
| | | case (int)TaskOutStatusEnum.RGV_OutZicheReleaseFinish: |
| | | case (int)TaskOutStatusEnum.RGV_OutPickupFinish: |
| | | //åºåºç¶æ |
| | | //è°åä¸åçæ¥å£ |
| | | responseContent = UpdateTaskStatusToNext(task); |
| | | break; |
| | | |
| | | |
| | | //å
¥åºç¶æ |
| | | case (int)TaskInStatusEnum.RGV_InPickupExecuting: |
| | | case (int)TaskInStatusEnum.RGV_InReleaseExecuting: |
| | | case (int)TaskInStatusEnum.RGV_InZicheExecuting: |
| | | case (int)TaskInStatusEnum.RGV_InZicheReleaseExecuting: |
| | | case (int)TaskInStatusEnum.RGV_InZichemoveExecuting: |
| | | case (int)TaskInStatusEnum.RGV_InMothercarExecuting: |
| | | //å
¥åºç¶æ |
| | | //åºåºç¶æ |
| | | case (int)TaskOutStatusEnum.RGV_OutMothercarExecuting: |
| | | case (int)TaskOutStatusEnum.RGV_OutZicheExecuting: |
| | | case (int)TaskOutStatusEnum.RGV_OutZicheReleaseExecuting: |
| | | case (int)TaskOutStatusEnum.RGV_OutPickupExecuting: |
| | | case (int)TaskOutStatusEnum.RGV_OutReleaseExecuting: |
| | | //åºåºç¶æ |
| | | //è°å宿æ¥å£ |
| | | responseContent = UpdateTaskStatus(task.TaskNum); |
| | | break; |
| | | default: |
| | | return WebResponseContent.Instance.Error("ä»»å¡ç¶æéè¯¯ï¼æ§è¡ä¸ä¸æ¥å¤±è´¥"); |
| | | } |
| | | // å建并èµå¼ |
| | | return responseContent; |
| | | } |
| | | } |