| | |
| | | using WIDESEAWCS_Common.LocationEnum; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_DTO; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_QuartzJob; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_KLSLocationInfo? kLSLocationInfo = null; |
| | | try |
| | | { |
| | | int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt(); |
| | | int containerType = taskDTO.containerCode.Contains("LLM") ? (int)LocationTypeEnum.LargePallet : (int)LocationTypeEnum.SmallPallet; |
| | | #region ç¹å°ç¹ |
| | | if (!string.IsNullOrEmpty(taskDTO.toLocationCode)) |
| | | { |
| | | kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"æªæ¾å°ç»ç¹è´§ä½ã{taskDTO.toLocationCode}ã"); |
| | | if (kLSLocationInfo.LocationStatus != (int)LocationStatusEnum.Free) throw new Exception($"ç»ç¹è´§ä½ã{taskDTO.toLocationCode}ãè´§ä½ç¶æä¸ä¸ºç©ºè´§ä½"); |
| | | } |
| | | #endregion |
| | | //è·åè´§ä½ä¿¡æ¯ |
| | | Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode, containerType) ?? throw new Exception($"æªæ¾å°ç»ç¹åºåºã{taskDTO.toAreaCode}ãå¯ç¨ç©ºè´§ä½ï¼"); |
| | | else |
| | | kLSLocationInfo = _kLSLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode, containerType) ?? throw new Exception($"æªæ¾å°ç»ç¹åºåºã{taskDTO.toAreaCode}ãå¯ç¨ç©ºè´§ä½ï¼"); |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = kLSLocationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.New.ObjToInt(), |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | |
| | | TargetAddress = kLSLocationInfo.LocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | kLSLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt(); |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo); |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | kLSLocationInfo.LocationStatus = (int)LocationStatusEnum.InLock; |
| | | #region ä¸åå¯ä¹å£«ä»»å¡ |
| | | content = SendKLSTask(dt_Task); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Execut; |
| | | dt_Task.Dispatchertime = DateTime.Now; |
| | | #endregion |
| | | try |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo); |
| | | Db.Ado.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | |
| | | return content.OK(data: new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = "æåï¼" |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | content.Data = new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = $"失败ï¼{ex.Message}" |
| | | }; |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateKLSNewOutTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãï¼"); |
| | | if (kLSLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | if (kLSLocationInfo.LocationStatus != (int)LocationStatusEnum.InStock) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | if (kLSLocationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãç»å®æç®±å·ã{kLSLocationInfo.PalletCode}ãä¸ä»»å¡æç®±å·ã{taskDTO.containerCode}ãä¸å¹é
ï¼"); |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = kLSLocationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.New.ObjToInt(), |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | |
| | | TargetAddress = taskDTO.toLocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | kLSLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt(); |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo); |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | kLSLocationInfo.LocationStatus = (int)LocationStatusEnum.OutLock; |
| | | #region ä¸åå¯ä¹å£«ä»»å¡ |
| | | content = SendKLSTask(dt_Task); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Execut; |
| | | dt_Task.Dispatchertime = DateTime.Now; |
| | | #endregion |
| | | try |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo); |
| | | Db.Ado.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | return content.OK(data: new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = "æåï¼" |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | content.Data = new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = $"失败ï¼{ex.Message}" |
| | | }; |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 5 跨楼å±è¿è¾ä»»å¡å建 |
| | | #region ä¸åå¯ä¹å£«ä»»å¡ |
| | | public WebResponseContent SendKLSTask(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | GALAXISTaskInfo gALAXISTaskInfo = new(); |
| | | GALAXISReturn agvContent = new(); |
| | | try |
| | | { |
| | | gALAXISTaskInfo.groupId = DateTime.Now.ToString("yyMMddHHmmss") + task.TaskNum; |
| | | gALAXISTaskInfo.msgTime = DateTime.Now.ToString(); |
| | | GALAXISTask gALAXISTask = new GALAXISTask() |
| | | { |
| | | taskId = task.WMSTaskNum, |
| | | taskType = task.TaskType == (int)TaskTypeEnum.MLInbound ? 0 : 1, |
| | | barCode = task.PalletCode, |
| | | endNode = task.TargetAddress, |
| | | startNode = task.SourceAddress, |
| | | priorityCode = task.Grade |
| | | }; |
| | | gALAXISTaskInfo.tasks.Add(gALAXISTask); |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(GALAXISTaskInfo)) ?? throw new Exception("æªæ¾å°å¯ä¹å£«AGVä»»å¡ä¸åæ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, gALAXISTaskInfo.Serialize()); |
| | | agvContent = response.DeserializeObject<GALAXISReturn>(); |
| | | content.OK(data: agvContent); |
| | | if (agvContent.success) |
| | | { |
| | | if (agvContent.data.returnStatus != 0) throw new Exception(agvContent.data.returnInfo); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(gALAXISTaskInfo, content, "ä¸åå¯ä¹å£«AGVä»»å¡", "", agvContent.data.returnInfo); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | #region 5 跨楼å±è¿è¾ä»»å¡å建 ï¼é½æ¯ç¹å°ç¹ï¼ |
| | | public WebResponseContent CarryTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | return WebResponseContent.Instance.OK(); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_HKLocationInfo? hKLocationInfo = null; |
| | | Dt_StationInfo? stationInfo = null; |
| | | Dt_Task dt_Task = null; |
| | | //å
¥åº å°ä¸æ¥¼ä¸ä¸ªç«å°çä½ç½® |
| | | if (taskType == (int)TaskTypeEnum.Q3RK) |
| | | { |
| | | //读åå
çµä¿¡å· |
| | | 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楼质æ£é¨è®¾å¤è¿æ¥å¤±è´¥"); |
| | | bool value = device.GetValue<QualityInspectionCommandEnum, bool>(QualityInspectionCommandEnum.R_StockAvailableSymbol, taskDTO.toLocationCode); |
| | | if (value) |
| | | { |
| | | content.Error($"{taskDTO.toLocationCode}ç«å°æè´§ï¼æ æ³å
¥åº"); |
| | | } |
| | | dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | WMSTaskNum = taskDTO.taskCode, |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = hKLocationInfo.RoadwayNo, |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = taskDTO.toLocationCode, |
| | | TargetAddress = taskDTO.toLocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | |
| | | } |
| | | //åºåº |
| | | if (taskType == (int)TaskTypeEnum.Q3CK) |
| | | { |
| | | stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode) ?? throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.toLocationCode}ãï¼"); |
| | | if (stationInfo.StationName != LocationStatusEnum.InStock.ToString()) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.toLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | if (stationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.toLocationCode}ãç»å®æç®±å·ã{stationInfo.PalletCode}ãä¸ä»»å¡æç®±å·ã{taskDTO.containerCode}ãä¸å¹é
ï¼"); |
| | | dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | WMSTaskNum = taskDTO.taskCode, |
| | | //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = hKLocationInfo.RoadwayNo, |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = taskDTO.toLocationCode, |
| | | TargetAddress = taskDTO.toLocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | } |
| | | try |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _hKLocationInfoService.Repository.UpdateData(hKLocationInfo); |
| | | _stationInfo.Repository.UpdateData(stationInfo); |
| | | Db.Ado.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | return content.OK(data: new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = "æåï¼" |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | #region 6 è£åªéè´§ |
| | | public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType) |
| | | { |
| | | return WebResponseContent.Instance.OK(); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | WMSTaskNum = taskDTO.taskCode, |
| | | //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = "", |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = taskDTO.toLocationCode, |
| | | TargetAddress = taskDTO.toLocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | content = SendHIKROBOTTask(dt_Task); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Execut; |
| | | dt_Task.Dispatchertime = DateTime.Now; |
| | | BaseDal.AddData(dt_Task); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | } |