| | |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using AutoMapper; |
| | | using Newtonsoft.Json; |
| | | using SixLabors.ImageSharp.ColorSpaces; |
| | | using SqlSugar; |
| | | using System.Collections.Generic; |
| | |
| | | private readonly IRepository<Dt_TaskExecuteDetail> _taskExecuteDetailRepository; |
| | | private readonly IApiInfoService _apiInfoService; |
| | | private readonly IStationMangerService _stationMangerService; |
| | | private readonly IStationInfoService _stationInfo; |
| | | private readonly ITaskErrorMessageService _taskErrorMessageService; |
| | | private readonly IMapper _mapper; |
| | | |
| | | private Dictionary<string, OrderByType> _taskOrderBy = new() |
| | |
| | | /// </summary> |
| | | public IRepository<Dt_Task> Repository => BaseDal; |
| | | |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService) : base(BaseDal) |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService, IStationInfoService stationInfo, ITaskErrorMessageService taskErrorMessageService) : base(BaseDal) |
| | | { |
| | | _routerService = routerService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | |
| | | _apiInfoService = apiInfoService; |
| | | _trackloginfoService = trackloginfoService; |
| | | _stationMangerService = stationMangerService; |
| | | _stationInfo = stationInfo; |
| | | _taskErrorMessageService = taskErrorMessageService; |
| | | } |
| | | public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs) |
| | | { |
| | |
| | | continue; |
| | | //throw new Exception($"æçå·ã{task.containerCode}ãå·²åå¨ä»»å¡"); |
| | | } |
| | | if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode && x.TaskType == item.taskType) != null) |
| | | if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode && x.TaskType == item.taskType && x.TaskState < TaskStatusEnum.TakeFinish.ObjToInt()) != null) |
| | | { |
| | | objects.Add(new |
| | | { |
| | |
| | | break; |
| | | #endregion |
| | | #region 海康AGV |
| | | case (int)TaskTypeEnum.STURR: |
| | | case (int)TaskTypeEnum.Q1TSJ4: |
| | | content = CreateHKNewInTask(task, item.taskType); |
| | | objects.Add(content.Data); |
| | |
| | | content = CreateHKNewOutTask(task, item.taskType); |
| | | objects.Add(content.Data); |
| | | break; |
| | | case (int)TaskTypeEnum.F01: |
| | | |
| | | case (int)TaskTypeEnum.Q3RK: |
| | | case (int)TaskTypeEnum.Q3CK: |
| | | content = CarryTask(task, item.taskType); |
| | | objects.Add(content.Data); |
| | | break; |
| | | case (int)TaskTypeEnum.F02: |
| | | case (int)TaskTypeEnum.F01: |
| | | content = HKF01Transport(task, item.taskType); |
| | | break; |
| | | case (int)TaskTypeEnum.F04: |
| | | case (int)TaskTypeEnum.RK3F: |
| | | case (int)TaskTypeEnum.F02: |
| | | case (int)TaskTypeEnum.F03: |
| | | case (int)TaskTypeEnum.CK3F: |
| | | content = CJCarryTaske(task, item.taskType); |
| | | objects.Add(content.Data); |
| | |
| | | //åå车 |
| | | bool isAGV = dt_Task.TaskType == (int)TaskTypeEnum.CPInbound || dt_Task.TaskType == (int)TaskTypeEnum.CPOutbound; |
| | | //海康 |
| | | bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK; |
| | | bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK || dt_Task.TaskType == (int)TaskTypeEnum.STURR; |
| | | //è¿éå°ç¶ææ¹åäº198åæ¶ä»»å¡ |
| | | dt_Task.TaskType = TaskStatusEnum.WMSCancel.ObjToInt(); |
| | | #region å¯ä¹å£« |
| | |
| | | cancelHIKROBOTTask = new CancelHIKROBOTTask |
| | | { |
| | | robotTaskCode = dt_Task.WMSTaskNum, |
| | | cancelType = "CANCEL"//åè½¯åæ¶ï¼DROP人工ä»å
¥ï¼åç¡¬åæ¶ï¼ |
| | | cancelType = "DROP"//åè½¯åæ¶ï¼DROP人工ä»å
¥ï¼åç¡¬åæ¶ï¼ |
| | | }; |
| | | var headers = new Dictionary<string, string> |
| | | { |
| | | { "X-lr-request-id", DateTimeOffset.Now.ToUnixTimeSeconds().ToString() + wMSCancelTask.TaskCode } |
| | | }; |
| | | |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(CancelHIKROBOTTask)); |
| | | if (apiInfo == null) throw new Exception("æªæ¾å°åå车AGVä»»å¡ä¸åæ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, cancelHIKROBOTTask.Serialize()); |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, cancelHIKROBOTTask.Serialize(), headers: headers); |
| | | HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>(); |
| | | content.OK(data: hIKROBOTReturn); |
| | | if (hIKROBOTReturn.code == "SUCCESS" && hIKROBOTReturn.message == "æå") |
| | |
| | | { |
| | | LoctionCode = item.LocationCode, |
| | | LocationStatus = item.LocationStatus, |
| | | EnableStatus = item.EnableStatus |
| | | EnableStatus = item.EnableStatus, |
| | | PalletCode = item.PalletCode |
| | | |
| | | }); |
| | | } |
| | | content.OK(data: list); |
| | |
| | | { |
| | | LoctionCode = item.LocationCode, |
| | | LocationStatus = item.LocationStatus, |
| | | EnableStatus = item.EnableStatus |
| | | EnableStatus = item.EnableStatus, |
| | | PalletCode = item.PalletCode |
| | | }); |
| | | } |
| | | content.OK(data: list); |
| | |
| | | var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice; |
| | | if (device == null) throw new Exception("æªæ¾å°æåæºè®¾å¤ä¿¡æ¯"); |
| | | if (!device.IsConnected) throw new Exception("PLC1æåæºè®¾å¤è¿æ¥å¤±è´¥"); |
| | | var value = device.GetValue<HoistEnum, short>(HoistEnum.Outboundmaterialbox, "TSJ"); |
| | | var value = device.GetValue<HoistEnum, short>(HoistEnum.Outboundmaterialbox, "TSJC3F"); |
| | | list.Add(new |
| | | { |
| | | LoctionCode = value, |
| | | LocationStatus = value!=0? 100 : 0, |
| | | LocationStatus = value != 0 ? 100 : 0, |
| | | EnableStatus = 0, |
| | | }); |
| | | content.OK(data: list); |
| | | } |
| | | else if (getLocationInfo.WarehouseId == 4) |
| | | { |
| | | |
| | | List<Dt_HKLocationInfo> rGVLocationInfos = new List<Dt_HKLocationInfo>(); |
| | | if (!string.IsNullOrEmpty(getLocationInfo.AreaCode)) |
| | | rGVLocationInfos = _hKLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt()); |
| | | else |
| | | rGVLocationInfos = _hKLocationInfoService.Repository.QueryData(); |
| | | foreach (var item in rGVLocationInfos) |
| | | { |
| | | list.Add(new |
| | | { |
| | | LoctionCode = item.LocationCode, |
| | | LocationStatus = item.LocationStatus, |
| | | EnableStatus = item.EnableStatus, |
| | | PalletCode = item.PalletCode |
| | | }); |
| | | } |
| | | content.OK(data: list); |
| | | } |
| | | else if (getLocationInfo.WarehouseId == 5) |
| | | { |
| | |
| | | var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "F1") as OtherDevice; |
| | | if (device == null) throw new Exception("æªæ¾å°1楼质æ£é¨è®¾å¤ä¿¡æ¯"); |
| | | if (!device.IsConnected) throw new Exception("PLC1楼质æ£é¨è®¾å¤è¿æ¥å¤±è´¥"); |
| | | var sta = _stationMangerService.Repository.QueryData(x => x.Remark == "æååº"); |
| | | var sta = _stationMangerService.Repository.QueryData(x => x.StationName.Contains("æåä»")); |
| | | foreach (var item in sta) |
| | | { |
| | | bool value = device.GetValue<QualityInspectionCommandEnum, bool>(QualityInspectionCommandEnum.R_StockAvailableSymbol, item.StationCode); |
| | |
| | | { |
| | | throw new NotImplementedException(); |
| | | } |
| | | |
| | | public WebResponseContent InboundElevatorExit(string LocationCode, string containerCode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | inboundElevatorExitDTO inboundElevator=new inboundElevatorExitDTO(); |
| | | try |
| | | { |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(inboundElevatorExitDTO)) ?? throw new Exception("æªæ¾å°4Fæåæºåºå£æçå·ä¸æ¥WMSæ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | inboundElevator.containerCode= containerCode; |
| | | inboundElevator.toLocationCode = LocationCode; |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, inboundElevator.Serialize()); |
| | | content.OK(data: response); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(inboundElevator, content, "4Fæåæºåºå£æçå·ä¸æ¥WMS", "", ""); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æç®±éªè¯ |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent MaterialBoxInspection(string taskCode, string containerCode) |
| | | { |
| | | throw new NotImplementedException(); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | inboundTransportCheckDTO checkDTO = new inboundTransportCheckDTO(); |
| | | try |
| | | { |
| | | checkDTO.containerCode = containerCode; |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(inboundTransportCheckDTO)) ?? throw new Exception("æªæ¾å°è£çå
¥åº3Få°4Fè¿è¾ç®±å·æ ¡éªæ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, checkDTO.Serialize()); |
| | | content.OK(data: response); |
| | | WMSReturn wMSReturn = response.DeserializeObject<WMSReturn>(); |
| | | if (wMSReturn == null) throw new Exception("WMSè¿åç»æè½¬æ¢å¤±è´¥ï¼"); |
| | | if (!wMSReturn.success) throw new Exception(wMSReturn.message); |
| | | string dataJson = wMSReturn.result.ToString(); |
| | | Exists? exists = JsonConvert.DeserializeObject<Exists>(dataJson); |
| | | if (exists == null) throw new Exception($"WMSè¿åç»æçresult转æ¢å¤±è´¥"); |
| | | return WebResponseContent.Instance.OK(exists.errorAreaCode); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(checkDTO, content, "è£çå
¥åº3Få°4Fè¿è¾ç®±å·æ ¡éª", "", ""); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public WebResponseContent ContainerRequest(WMSContainerFlow wMSContainerFlow) |
| | | { |
| | | WebResponseContent content =new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerService.Repository.QueryFirst(x => x.StationCode == wMSContainerFlow.slotCode) ?? throw new Exception($"æªæ¾å°ç«å°ã{wMSContainerFlow.slotCode}ãä¿¡æ¯"); |
| | |
| | | if (wMSContainerFlow.direction == "200") |
| | | { |
| | | stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt(); |
| | | stationManger.Remark = ""; |
| | | FOURBOToccupyStation fOURBOToccupyStation = new FOURBOToccupyStation() |
| | | { |
| | | stationCode = wMSContainerFlow.slotCode, |
| | | }; |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOToccupyStation.Serialize()); |
| | | FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>(); |
| | | content.OK(data:fOURBOTReturn); |
| | | if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg); |
| | | _stationMangerService.UpdateData(stationManger); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | return content.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(wMSContainerFlow, content, "容卿µå¨è¯·æ±", "", ""); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | //task.TaskState = (int)TaskStatusEnum.Execut; |
| | | //BaseDal.UpdateData(task); |
| | | #endregion |
| | | |
| | | #region 䏿¶ä¸éè¦å°ç«å°ç¶ææ¹ä¸ºå ç¨ ç»å®å®¹å¨ç¼ç |
| | | stationManger.IsOccupied = LocationStatusEnum.Lock.ObjToInt(); |
| | | stationManger.Remark = iQC.ContainerCode; |
| | | _stationMangerService.UpdateData(stationManger); |
| | | #endregion |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(iQC, content, "IQCè´¨æ£ç»æåé¦", "", ""); |
| | | } |
| | | } |
| | | |
| | |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public WebResponseContent multiSetNodeStatus(FOURBOTStorageStatusNotify fOURBOTStorageStatusNotify) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var Agvlocation = _rGVLocationInfoService.Repository.QueryData(x => fOURBOTStorageStatusNotify.storageCode.Contains(x.LocationCode)); |
| | |
| | | item.EnableStatus = (int)(fOURBOTStorageStatusNotify.disable == 0 ? EnableStatusEnum.Normal : EnableStatusEnum.Disable); |
| | | } |
| | | _rGVLocationInfoService.UpdateData(Agvlocation); |
| | | return WebResponseContent.Instance.OK(); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(fOURBOTStorageStatusNotify,content, "æ¹éæ´æ°å¨ä½ç¶æ", "", ""); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¡éªä»»å¡ç¸å
³çåºä½ç¶æåç»å®å
³ç³» |
| | | /// </summary> |
| | | /// <param name="taskType">ä»»å¡ç±»å</param> |
| | | /// <param name="taskDTO">ä»»å¡DTO</param> |
| | | /// <returns>è¿åèµ·ç¹åºä½åç»ç¹åºä½ä¿¡æ¯</returns> |
| | | /// <exception cref="Exception">æ ¡éªå¤±è´¥æ¶æåºå¼å¸¸</exception> |
| | | private WebResponseContent ValidateLocationForTask(int taskType, TaskDTO taskDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | #region |
| | | // å
¥åºç±»ä»»å¡ï¼éè¦æ ¡éªç»ç¹åºä½ï¼ |
| | | if (taskType == (int)TaskTypeEnum.CK3F || taskType == (int)TaskTypeEnum.F03) |
| | | { |
| | | var toStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode) |
| | | ?? throw new Exception($"æªæ¾å°ç»ç¹åºä½ã{taskDTO.toLocationCode}ãï¼"); |
| | | |
| | | if (toStation.StationName != LocationStatusEnum.Free.ToString()) |
| | | throw new Exception($"ç»ç¹åºä½ã{taskDTO.toLocationCode}ãåºä½ç¶æä¸å¯å
¥åºï¼"); |
| | | } |
| | | // åºåºç±»ä»»å¡ï¼éè¦æ ¡éªèµ·ç¹åºä½ï¼ |
| | | else if (taskType == (int)TaskTypeEnum.RK3F || taskType == (int)TaskTypeEnum.F04) |
| | | { |
| | | var fromStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode) |
| | | ?? throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãï¼"); |
| | | |
| | | if (fromStation.StationName != LocationStatusEnum.InStock.ToString()) |
| | | throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | |
| | | if (fromStation.PalletCode != taskDTO.containerCode) |
| | | throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãç»å®æç®±å·ã{fromStation.PalletCode}ãä¸ä»»å¡æç®±å·ã{taskDTO.containerCode}ãä¸å¹é
ï¼"); |
| | | } |
| | | // ç§»åºç±»ä»»å¡ï¼éè¦åæ¶æ ¡éªèµ·ç¹åç»ç¹ï¼ |
| | | else if (taskType == (int)TaskTypeEnum.F02) |
| | | { |
| | | // æ ¡éªç»ç¹åºä½ |
| | | var toStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode) |
| | | ?? throw new Exception($"æªæ¾å°ç»ç¹åºä½ã{taskDTO.toLocationCode}ãï¼"); |
| | | |
| | | if (toStation.StationName != LocationStatusEnum.Free.ToString()) |
| | | throw new Exception($"ç»ç¹åºä½ã{taskDTO.toLocationCode}ãåºä½ç¶æä¸å¯å
¥åºï¼"); |
| | | |
| | | // æ ¡éªèµ·ç¹åºä½ |
| | | var fromStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode) |
| | | ?? throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãï¼"); |
| | | |
| | | if (fromStation.StationName != LocationStatusEnum.InStock.ToString()) |
| | | throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | |
| | | if (fromStation.PalletCode != taskDTO.containerCode) |
| | | throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãç»å®æç®±å·ã{fromStation.PalletCode}ãä¸ä»»å¡æç®±å·ã{taskDTO.containerCode}ãä¸å¹é
ï¼"); |
| | | } |
| | | #endregion |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |