| | |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IWarehouseService _warehouseService; |
| | | private readonly IRoadWayinfoService _roadWayinfoService; |
| | | private readonly ITask_HtyService _task_HtyService; |
| | | private Timer _timer; |
| | | public IRepository<Dt_Task> Repository => BaseDal; |
| | | |
| | |
| | | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(ILogger<TaskService> logger, IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, ILocationInfoService locationInfoService, |
| | | IWarehouseService warehouseService, IRoadWayinfoService roadWayinfoService) : base(BaseDal) |
| | | IWarehouseService warehouseService, IRoadWayinfoService roadWayinfoService, ITask_HtyService task_HtyService) : base(BaseDal) |
| | | { |
| | | _logger = logger; |
| | | _mapper = mapper; |
| | |
| | | _stockInfoService = stockInfoService; |
| | | _locationInfoService = locationInfoService; |
| | | _warehouseService = warehouseService; |
| | | _roadWayinfoService=roadWayinfoService; |
| | | |
| | | _roadWayinfoService = roadWayinfoService; |
| | | _task_HtyService = task_HtyService; |
| | | } |
| | | public string MES_InReporttask = WIDESEA_Core.Helper.AppSettings.Configuration["MES_InReporttask"]; //å
¥åºåé¦ä¿¡æ¯ |
| | | public string MES_OutReporttask = WIDESEA_Core.Helper.AppSettings.Configuration["MES_OutReporttask"]; //åºåºåé¦ä¿¡æ¯ |
| | |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == wCSTask.TaskNum && x.PalletCode == wCSTask.PalletCode); |
| | | if (task == null) |
| | | return webResponse.Error("æªæ¾å°ä»»å¡ä¿¡æ¯"); |
| | | return webResponse.Error("æªæ¾å°ä»»å¡ä¿¡æ¯", 404); |
| | | return TaskCompletedtask(task, wCSTask.TaskType); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | MES_parameter mES_Parameter = AbnormalStorageLocation(task.PalletCode, task.SourceAddress, task.TargetAddress); |
| | | if (mES_Parameter.Result == "Y") |
| | | { |
| | | Dt_Task dtOutWit=BaseDal.QueryData(x=>x.PalletCode==task.PalletCode && x.TaskStatus== (int)OutTaskStatusEnum.OutWait).FirstOrDefault(); |
| | | |
| | | Dt_LocationInfo OriginalLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.SourceAddress).FirstOrDefault(); |
| | | Dt_LocationInfo NewLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.TargetAddress).FirstOrDefault(); |
| | | Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.LocationCode == task.SourceAddress).FirstOrDefault(); |
| | |
| | | List<Dt_LocationInfo> dt_Locations = new List<Dt_LocationInfo>(); |
| | | |
| | | OriginalLocation.LocationStatus = (int)LocationStatusEnum.Free; |
| | | NewLocation.LocationStatus = (int)LocationStatusEnum.InStock; |
| | | NewLocation.LocationStatus = dtOutWit != null? (int)LocationStatusEnum.Lock:(int)LocationStatusEnum.InStock; |
| | | dt_StockInfo.LocationCode = NewLocation.LocationCode; |
| | | dt_StockInfo.StockStatus = (int)StockStatusEmun.å·²å
¥åº; |
| | | dt_StockInfo.StockStatus = dtOutWit != null? (int)StockStatusEmun.åºåºä¸:(int)StockStatusEmun.å·²å
¥åº; |
| | | task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish; |
| | | |
| | | if(dtOutWit != null) |
| | | { |
| | | dtOutWit.TaskStatus = (int)OutTaskStatusEnum.OutNew; |
| | | dtOutWit.SourceAddress = NewLocation.LocationCode; |
| | | dtOutWit.CurrentAddress = NewLocation.LocationCode; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | dt_Locations.Add(OriginalLocation); |
| | | dt_Locations.Add(NewLocation); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | if(dtOutWit!=null) BaseDal.UpdateData(dtOutWit); |
| | | |
| | | _locationInfoService.UpdateData(dt_Locations); |
| | | _stockInfoService.UpdateData(dt_StockInfo); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | |
| | | //ä»»å¡è·å |
| | | public List<Dt_Task> GetaskQueue(string deviceId) |
| | | { |
| | | return BaseDal.QueryData(x => x.Roadway == deviceId && (x.TaskStatus == (int)InTaskStatusEnum.PLC_InFinish || x.TaskStatus == (int)OutTaskStatusEnum.OutNew) && x.NumberSsuances==0); |
| | | return BaseDal.QueryData(x => x.Roadway == deviceId |
| | | && (x.TaskStatus == (int)InTaskStatusEnum.PLC_InFinish |
| | | || x.TaskStatus == (int)OutTaskStatusEnum.OutNew) |
| | | && x.NumberSsuances == 0) |
| | | .OrderBy(x => x.Remark == null ? 0 : 1) |
| | | .ToList(); |
| | | //return BaseDal.QueryData(x => x.Roadway == deviceId && (x.TaskStatus == (int)InTaskStatusEnum.PLC_InFinish || x.TaskStatus == (int)OutTaskStatusEnum.OutNew) && x.NumberSsuances==0); |
| | | } |
| | | |
| | | //è·åå½åå åæºæ§è¡çä»»å¡ |
| | |
| | | return BaseDal.QueryData(x => x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationNew && x.CurrentAddress == LocationCode).FirstOrDefault(); |
| | | } |
| | | |
| | | public Dt_Task GeOutCuTaskQueue(string LocationCode) |
| | | { |
| | | return BaseDal.QueryData(x => x.TaskStatus == (int)OutTaskStatusEnum.OutNew && x.SourceAddress == LocationCode).FirstOrDefault(); |
| | | } |
| | | |
| | | public bool RelocationTaskProgress(string deviceId) |
| | | { |
| | | int taskcount = BaseDal.QueryData(x => x.Roadway == deviceId && x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationExecuting).Count(); |
| | | int taskcount = BaseDal.QueryData(x => x.Roadway == deviceId && (x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationExecuting || x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationNew) ).Count(); |
| | | if (taskcount == 0) return false; |
| | | return true; |
| | | } |
| | | |
| | | //ä»åºå®¹éç¶æ |
| | | public WebResponseContent GetWarehouseCapacity() |
| | | { |
| | | return _locationInfoService.GetWarehouseCapacity(); |
| | | } |
| | | |
| | | //åºå
¥åºç±»ååå¸ |
| | | public WebResponseContent GetInOutTypeStats() |
| | | { |
| | | return _task_HtyService.GetInOutTypeStats(); |
| | | } |
| | | //æµéæ
åµç»è®¡ |
| | | |
| | | public WebResponseContent GetTodayTrafficStats() |
| | | { |
| | | return _task_HtyService.GetTodayInOutStats(); |
| | | } |
| | | //å½åè¿è¡çä»»å¡ |
| | | public WebResponseContent GetCurrentTasks() |
| | | { |
| | | // æ¥è¯¢æä»¥è¿åTaskNumï¼TaskTypeï¼CreateDateï¼TaskStatusï¼ |
| | | var tasks = BaseDal.QueryData() |
| | | .Select(t => new |
| | | { |
| | | WarehouseId = t.Roadway == "1" || t.Roadway == "2" ? 1 : 2, |
| | | PalletType = t.PalletType, |
| | | TaskNum = t.TaskId, |
| | | TaskType = t.TaskType, |
| | | CreateDate = t.CreateDate, |
| | | TaskStatus = t.TaskStatus, |
| | | TargetAddress = t.TargetAddress |
| | | }) |
| | | .ToList(); |
| | | return WebResponseContent.Instance.OK("æå", tasks); |
| | | } |
| | | //æ»ä½è¿åº¦ |
| | | public WebResponseContent GetWarehouseOperationStatistics() |
| | | { |
| | | /// <summary> |
| | | /// åæä»ï¼æ»åºå
¥åºä»»å¡æ°éï¼ä»æ¥å
¥åºï¼ä»æ¥åºåºï¼ä»æ¥å¾
宿ï¼ä»æ¥å¼å¸¸ä»»å¡ï¼æåä»ï¼æ»åºå
¥åºæ°éï¼ä»æ¥å
¥åºï¼ä»æ¥åºåºï¼ä»æ¥å¾
宿 |
| | | /// </summary> |
| | | return _task_HtyService.GetWarehouseOperationStatistics(); |
| | | } |
| | | |
| | | public WebResponseContent GetTaskDestination(string targetAddress) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | // åæ°æ ¡éª |
| | | if (string.IsNullOrWhiteSpace(targetAddress)) |
| | | { |
| | | return content.Error("ç®æ å°åä¸è½ä¸ºç©º"); |
| | | } |
| | | try |
| | | { |
| | | // æ¥è¯¢æ°æ® |
| | | var queryResult = BaseDal.QueryData(x => x.TargetAddress == targetAddress); |
| | | // 夿æ¥è¯¢ç»æ |
| | | if (queryResult == null || !queryResult.Any()) |
| | | { |
| | | return content.Error($"æªæ¾å°ç®æ å°å为[{targetAddress}]çä»»å¡"); |
| | | } |
| | | return content.OK($"æç®æ å°å为[{targetAddress}]çä»»å¡ï¼è¯·æ¦æª"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error($"è·åä»»å¡ç®çå°å¤±è´¥: {ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | } |