| | |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using AutoMapper; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using SqlSugar; |
| | | using System; |
| | |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_DTO.WMSInfo; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | | public class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService |
| | | public partial class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService |
| | | { |
| | | private readonly IRouterService _routerService; |
| | | private readonly IRouterRepository _routerRepository; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository; |
| | | private readonly ITaskHtyService _taskHtyService; |
| | | private readonly IMapper _mapper; |
| | | |
| | | 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) : base(BaseDal) |
| | | public List<int> TaskRelocationTypes => typeof(TaskRelocationTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IRouterService routerService, IRouterRepository routerRepository, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, ITaskHtyService taskHtyService, IMapper mapper) : base(BaseDal) |
| | | { |
| | | _routerService = routerService; |
| | | _routerRepository = routerRepository; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskExecuteDetailRepository = taskExecuteDetailRepository; |
| | | _taskHtyService = taskHtyService; |
| | | _mapper = mapper; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶WMSä»»å¡ä¿¡æ¯ |
| | | /// </summary> |
| | |
| | | { |
| | | if (BaseDal.QueryFirst(x => x.TaskNum == item.TaskNum || x.PalletCode == item.PalletCode) != null) |
| | | { |
| | | continue; |
| | | throw new Exception($"ä»»å¡å·ã{item.TaskNum}å·²åå¨ä»»å¡ã"); |
| | | } |
| | | Dt_Task task = _mapper.Map<Dt_Task>(item); |
| | | task.Creater = "WMS"; |
| | |
| | | //æä¸èèå¤è·¯å¾ |
| | | if (routers.Count > 0) |
| | | { |
| | | task.TaskState = (int)TaskOutStatusEnum.OutNew; |
| | | |
| | | task.TaskState = item.SourceIsPickPlace ? TaskOutStatusEnum.Car_OutFinish.ObjToInt() : TaskOutStatusEnum.OutNew.ObjToInt(); |
| | | task.CurrentAddress = item.SourceAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | |
| | | //æä¸èèå¤è·¯å¾ |
| | | if (routers.Count > 0) |
| | | { |
| | | task.TaskState = (int)TaskInStatusEnum.InNew; |
| | | if (task.TaskType != TaskInboundTypeEnum.PalletInbound.ObjToInt()) |
| | | task.TaskState = (int)TaskInStatusEnum.InNew; |
| | | task.CurrentAddress = item.SourceAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | |
| | | return content; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®æçå·ãèµ·å§å°ååWMS请æ±ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="palletCode">æçå·</param> |
| | | /// <param name="sourceAddress">èµ·å§å°å</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | PalletCode = palletCode, |
| | | RoadWay = "SC01", |
| | | SourceAddress = sourceAddress, |
| | | TargetAddress = "SC01", |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskInboundTypeEnum.Inbound |
| | | }; |
| | | |
| | | content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤ç¼å·ãå½åå°åæ¥è¯¢è¾éçº¿æªæ§è¡çä»»å¡ |
| | | /// </summary> |
| | | /// <param name="deviceNo">设å¤ç¼å·</param> |
| | | /// <param name="currentAddress">å½åå°å</param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryConveyorLineTask(string deviceNo, string currentAddress) |
| | | public Dt_Task QueryConveyorLineTask(string deviceNo, string currentAddress, string Barcode) |
| | | { |
| | | return BaseDal.QueryFirst(x => (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) && x.CurrentAddress == currentAddress, TaskOrderBy); |
| | | return BaseDal.QueryFirst(x => (TaskInboundTypes.Contains(x.TaskType) && x.NextAddress == currentAddress && x.PalletCode == Barcode && x.TaskState == (int)TaskInStatusEnum.AGV_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish && x.CurrentAddress == currentAddress), TaskOrderBy); |
| | | } |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤ç¼å·ãå½åå°åæ¥è¯¢è¾éçº¿æªæ§è¡çä»»å¡ |
| | | /// </summary> |
| | | /// <param name="deviceNo">设å¤ç¼å·</param> |
| | | /// <param name="currentAddress">å½åå°å</param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryConveyorLineTaskNum(string deviceNo, string currentAddress, int TaskNum) |
| | | { |
| | | return BaseDal.QueryFirst(x => (TaskInboundTypes.Contains(x.TaskType) && x.NextAddress == currentAddress && x.TaskNum == TaskNum && x.TaskState == (int)TaskInStatusEnum.AGV_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish && x.CurrentAddress == currentAddress), TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public Dt_Task QueryExecutingConveyorLineTask(int taskNum, string nextAddress) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.NextAddress == nextAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting), TaskOrderBy); |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.NextAddress == nextAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish), TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®æçå·ãä¸ä¸å°åæ¥è¯¢è¾é线æ§è¡ä¸çä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <param name="nextAddress">ä¸ä¸å°å</param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryExecutingConveyorLineTask(string Barcode, string nextAddress) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.PalletCode == Barcode && x.NextAddress == nextAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting), TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <param name="currentAddress">å½åå°å</param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryCompletedConveyorLineTask(int taskNum, string currentAddress) |
| | | public Dt_Task QueryCompletedConveyorLineTask(string Barcode, string currentAddress) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InFinish || x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish), TaskOrderBy); |
| | | return BaseDal.QueryFirst(x => x.PalletCode == Barcode && x.CurrentAddress == currentAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InFinish || x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish), TaskOrderBy); |
| | | } |
| | | |
| | | public Dt_Task QuertOutProductionLineTask(bool NextAddIsNull) |
| | | { |
| | | if (NextAddIsNull) |
| | | return BaseDal.QueryFirst(x => x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish && string.IsNullOrEmpty(x.NextAddress), TaskOrderBy); |
| | | else |
| | | return BaseDal.QueryFirst(x => x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish, TaskOrderBy); |
| | | } |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤ç¼å·ãä»»å¡ç±»ååç»(å¯é)æç
§ä¼å
级以åå建æ¶é´æåºæ¥è¯¢ä»»å¡æ± æ°å¢çä»»å¡ |
| | | /// </summary> |
| | |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew, TaskOrderBy); |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢åºå
ç§»åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="deviceNo"></param> |
| | | /// <param name="currentAddress"></param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryStackerCraneRelocationTask(string deviceNo, string currentAddress = "") |
| | | { |
| | | Dt_Task task = null; |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | tasks = BaseDal.QueryData(x => x.Roadway == deviceNo && TaskRelocationTypes.Contains(x.TaskType) && x.TaskState < TaskRelocationStatusEnum.SC_RelocationFinish.ObjToInt()).OrderBy(x => x.TaskNum).ToList(); |
| | | else |
| | | tasks = BaseDal.QueryData(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && TaskRelocationTypes.Contains(x.TaskType) && x.TaskState < TaskRelocationStatusEnum.SC_RelocationFinish.ObjToInt()).OrderBy(x => x.TaskNum).ToList(); |
| | | if (tasks != null && tasks.Count > 0) |
| | | { |
| | | task = tasks.First(); |
| | | } |
| | | return task; |
| | | } |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤ç¼å·ãå½åå°åæç
§ä¼å
级以åå建æ¶é´æåºæ¥è¯¢ä»»å¡æ± æ°å¢çä»»å¡ |
| | | /// </summary> |
| | |
| | | public Dt_Task QueryStackerCraneTask(string deviceNo, string currentAddress = "") |
| | | { |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Car_OutFinish), TaskOrderBy); |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && !string.IsNullOrEmpty(x.NextAddress) || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Car_OutFinish), TaskOrderBy); |
| | | else |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Car_OutFinish), TaskOrderBy); |
| | | } |
| | |
| | | public Dt_Task QueryStackerCraneInTask(string deviceNo, string currentAddress = "") |
| | | { |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish, TaskOrderBy); |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && !string.IsNullOrEmpty(x.NextAddress), TaskOrderBy); |
| | | else |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && x.CurrentAddress == currentAddress, TaskOrderBy); |
| | | return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && !string.IsNullOrEmpty(x.NextAddress) && x.CurrentAddress == currentAddress, TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>(); |
| | | |
| | | task.TaskState = nextStatus; |
| | | if (task.SourceIsPickPlace && task.TaskState == TaskOutStatusEnum.OutNew.ObjToInt()) |
| | | task.TaskState = TaskOutStatusEnum.SC_OutExecuting.ObjToInt(); |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) |
| | | { |
| | |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = string.Empty;// $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}"; |
| | | task.TargetAddress = task.NextAddress; |
| | | } |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)//åºå
ç§»åº |
| | | { |
| | | if (task.TaskState >= (int)TaskRelocationStatusEnum.RelocationFinish) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"该任å¡ç¶æä¸å¯è·³è½¬å°ä¸ä¸æ¥,ä»»å¡å·:ã{task.TaskNum}ã,ä»»å¡ç¶æ:ã{task.TaskState}ã"); |
| | | } |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskRelocationStatusEnum>(); |
| | | if (task.SourceIsPickPlace && task.TaskState == TaskRelocationStatusEnum.RelocationNew.ObjToInt()) |
| | | task.TaskState = TaskRelocationStatusEnum.SC_RelocationExecuting.ObjToInt(); |
| | | else |
| | | task.TaskState = nextStatus; |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup)//åºå
移车 |
| | | { |
| | | if (task.TaskType == TaskOtherTypeEnum.RelocationCar.ObjToInt()) |
| | | { |
| | | if (task.TaskState >= (int)TaskCarStatusEnum.RelocationCarFinish) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"该任å¡ç¶æä¸å¯è·³è½¬å°ä¸ä¸æ¥,ä»»å¡å·:ã{task.TaskNum}ã,ä»»å¡ç¶æ:ã{task.TaskState}ã"); |
| | | } |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskCarStatusEnum>(); |
| | | task.TaskState = nextStatus; |
| | | } |
| | | else if (task.TaskType == TaskOtherTypeEnum.RelocationCarCharging.ObjToInt()) |
| | | { |
| | | if (task.TaskState >= (int)CarChargingTaskEnum.RelocationCarFinish) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"该任å¡ç¶æä¸å¯è·³è½¬å°ä¸ä¸æ¥,ä»»å¡å·:ã{task.TaskNum}ã,ä»»å¡ç¶æ:ã{task.TaskState}ã"); |
| | | } |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<CarChargingTaskEnum>(); |
| | | task.TaskState = nextStatus; |
| | | } |
| | | } |
| | | else |
| | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡ç¼å·</param> |
| | | /// <returns>è¿åå¤çç»æ</returns> |
| | | public WebResponseContent StackCraneTaskCompleted(int taskNum) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯,ä»»å¡å·:ã{taskNum}ã"); |
| | | |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting) |
| | | { |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress); |
| | | if (!routers.Any()) return WebResponseContent.Instance.Error($"æªæ¾å°è®¾å¤è·¯ç±ä¿¡æ¯"); |
| | | |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>(); |
| | | task.TaskState = nextStatus; |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | BaseDal.UpdateData(task); |
| | | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"å åæºåºåºå®æ"); |
| | | //todo 忥å°WMS |
| | | |
| | | //æä¸èèå¤ä¸ªåºåºå£ |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting) |
| | | { |
| | | //todo |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | task.TaskState = nextStatus; |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | BaseDal.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"å åæºå
¥åºå®æ"); |
| | | |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | PalletCode = task.PalletCode + "S", |
| | | RoadWay = "SC01", |
| | | SourceAddress = task.TargetAddress, |
| | | TargetAddress = "CLOutAreaA", |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound |
| | | }; |
| | | |
| | | content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | { |
| | | //todo è°ç¨WMSç§»åºå®æ |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | throw new Exception($"ä»»å¡ç±»åé误,æªæ¾å°è¯¥ä»»å¡ç±»å,ä»»å¡å·:ã{taskNum}ã,ä»»å¡ç±»å:ã{task.TaskType}ã"); |
| | | } |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error($"ä»»å¡å®æå¼å¸¸,ä»»å¡å·:ã{taskNum}ã"); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¢å¤æèµ·ä»»å¡ |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public Dt_Task GetTaskInfo(int taskNum) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®ä»»å¡å·åä»»å¡ç¶ææ¥è¯¢ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | public Dt_Task GetTaskInfo(int taskNum, int taskState) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.TaskState == taskState); |
| | | } |
| | | /// <summary> |
| | | /// æ ¹æ®ä»»å¡ç¶æãç±»åæ¥è¯¢ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="TaskState"></param> |
| | | /// <param name="TaskType"></param> |
| | | /// <returns></returns> |
| | | public Dt_Task GetTaskState(int TaskState, int TaskType) |
| | | { |
| | | Dt_Task task = null; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢ç©¿æ¢è½¦åºå
¥åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="deviceNo"></param> |
| | | /// <param name="currentAddress"></param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryShuttleCarTask(string deviceNo, string currentAddress = "") |
| | | { |
| | | if (string.IsNullOrEmpty(currentAddress)) |
| | | return BaseDal.QueryFirst(x => x.ShuttleCarCode == deviceNo && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.SC_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew), TaskOrderBy); |
| | | else |
| | | return BaseDal.QueryFirst(x => x.ShuttleCarCode == deviceNo && x.CurrentAddress == currentAddress && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.SC_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew), TaskOrderBy); |
| | | } |
| | | /// <summary> |
| | | /// æ·»å ç§»è½¦ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="SourceAddress">èµ·ç¹</param> |
| | |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public WebResponseContent AddRelocationCarTask(string SourceAddress, string TargetAddress, string ShuttleCarCode = "", string remark = "") |
| | | { |
| | | if (!string.IsNullOrEmpty(SourceAddress) && SourceAddress != "") |
| | | { |
| | | Dt_Task? task = BaseDal.QueryFirst(x => x.SourceAddress == SourceAddress && x.TaskType == TaskOtherTypeEnum.RelocationCar.ObjToInt()); |
| | | if (task != null) return WebResponseContent.Instance.Error(); |
| | | } |
| | | if (!string.IsNullOrEmpty(TargetAddress) && TargetAddress != "") |
| | | { |
| | | Dt_Task? task = BaseDal.QueryFirst(x => x.SourceAddress == TargetAddress && x.TaskType == TaskOtherTypeEnum.RelocationCar.ObjToInt()); |
| | | if (task != null) return WebResponseContent.Instance.Error(); |
| | | } |
| | | #region å建å åæºç§»è½¦ä»»å¡ |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 2, |
| | | Roadway = "SC01", |
| | | TaskType = (int)TaskOtherTypeEnum.RelocationCar, |
| | | TaskType = string.IsNullOrEmpty(remark) ? (int)TaskOtherTypeEnum.RelocationCar : (int)TaskOtherTypeEnum.RelocationCarCharging, |
| | | SourceAddress = SourceAddress, |
| | | TargetAddress = TargetAddress, |
| | | CurrentAddress = "", |
| | | CurrentAddress = SourceAddress, |
| | | NextAddress = TargetAddress, |
| | | CreateDate = DateTime.Now, |
| | | Creater = "WCS", |