| | |
| | | using AutoMapper; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_DTO.WMS; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | |
| | | { |
| | | private readonly IRouterService _routerService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IHKLocationInfoService _hKLocationInfoService; |
| | | private readonly IKLSLocationInfoService _kLSLocationInfoService; |
| | | private readonly IRGVLocationInfoService _rGVLocationInfoService; |
| | | private readonly IRepository<Dt_TaskExecuteDetail> _taskExecuteDetailRepository; |
| | | private readonly IMapper _mapper; |
| | | |
| | |
| | | /// </summary> |
| | | public IRepository<Dt_Task> Repository => BaseDal; |
| | | |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper) : base(BaseDal) |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService) : base(BaseDal) |
| | | { |
| | | _routerService = routerService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskExecuteDetailRepository = taskExecuteDetailRepository; |
| | | _mapper = mapper; |
| | | _kLSLocationInfoService = kLSLocationInfoService; |
| | | _rGVLocationInfoService = rGVLocationInfoService; |
| | | _hKLocationInfoService = hKLocationInfoService; |
| | | } |
| | | public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs) |
| | | { |
| | |
| | | { |
| | | foreach (var item in taskDTOs) |
| | | { |
| | | if (item.taskType == TaskTypeEnum.MLInbound.ObjToInt()) |
| | | foreach (var task in item.tasks) |
| | | { |
| | | foreach (var task in item.tasks) |
| | | content = TaskHelpMethods.isOkTaskInfo(task, true, true); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode || x.PalletCode == task.containerCode) != null) |
| | | { |
| | | content = TaskHelpMethods.isOkTaskInfo(task, true, true); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode || x.PalletCode == task.containerCode) != null) |
| | | { |
| | | continue; |
| | | } |
| | | CreateNewInTask(task); |
| | | continue; |
| | | } |
| | | if (item.taskType == TaskTypeEnum.MLInbound.ObjToInt()) |
| | | CreateKLSNewInTask(task, item.taskType); |
| | | else if (item.taskType == TaskTypeEnum.MLOutbound.ObjToInt()) |
| | | CreateKLSNewOutTask(task, item.taskType); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åæ¶ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskCode">ä»»å¡å·</param> |
| | | /// <param name="containerCode">æç®±æ¡ç </param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CancelWMSTask(WMSCancelTask wMSCancelTask) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task dt_Task = BaseDal.QueryFirst(x => x.WMSTaskNum == wMSCancelTask.TaskCode); |
| | | if (dt_Task == null) throw new Exception("æªæ¥è¯¢å°ä»»å¡å·ç¸å
³ä»»å¡"); |
| | | if (dt_Task.TaskType == TaskTypeEnum.MLInbound.ObjToInt() || dt_Task.TaskType == TaskTypeEnum.CPInbound.ObjToInt() || dt_Task.TaskType == TaskTypeEnum.CJInbound.ObjToInt()) |
| | | dt_Task.TaskType = TaskInStatusEnum.InCancel.ObjToInt(); |
| | | else if (dt_Task.TaskType == TaskTypeEnum.MLOutbound.ObjToInt() || dt_Task.TaskType == TaskTypeEnum.CPOutbound.ObjToInt() || dt_Task.TaskType == TaskTypeEnum.CJOutbound.ObjToInt()) |
| | | dt_Task.TaskType = TaskOutStatusEnum.OutCancel.ObjToInt(); |
| | | BaseDal.UpdateData(dt_Task); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹ä»»å¡ä¼å
级 |
| | | /// </summary> |
| | | /// <param name="updateTaskPriority"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent UpdateWMSTaskPriority(WMSUpdateTaskPriority updateTaskPriority) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task dt_Task = BaseDal.QueryFirst(x => x.WMSTaskNum == updateTaskPriority.taskCode); |
| | | if (dt_Task == null) throw new Exception("æªæ¥è¯¢å°ä»»å¡å·ç¸å
³ä»»å¡"); |
| | | dt_Task.Grade = updateTaskPriority.taskPriority; |
| | | BaseDal.UpdateData(dt_Task); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹åºä½ååº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent ModifyWMSLayoutZone(WMSUpdateLocationArea wMSUpdateLocationArea) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if(wMSUpdateLocationArea.WarehouseId == 1) |
| | | { |
| | | foreach (var LocationCode in wMSUpdateLocationArea.LocationCodes) |
| | | { |
| | | Dt_RGVLocationInfo dt_RGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode); |
| | | UpdateLocationCode(dt_RGVLocationInfo,wMSUpdateLocationArea.UpdateAreaCode); |
| | | |
| | | } |
| | | } |
| | | |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | private void UpdateLocationCode(object LocationInfo, string updateAreaCode) |
| | | { |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶WMSä»»å¡ä¿¡æ¯ |
| | | /// </summary> |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | static object lock_taskNum = new object(); |
| | | public int GetTaskNum(string sequenceName) |
| | | { |
| | | lock (lock_taskNum) |
| | | { |
| | | return Db.Ado.GetScalar($"SELECT NEXT VALUE FOR {sequenceName}").ObjToInt(); |
| | | } |
| | | } |
| | | } |
| | | } |