| | |
| | | using WIDESEAWCS_DTO.WMS; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using HslCommunication.Core.IMessage; |
| | | using WIDESEAWCS_DTO.RGV.FOURBOT; |
| | | using Newtonsoft.Json; |
| | | using System.Reflection.Metadata; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //List<Dt_RGVLocationInfo>? rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt()); |
| | | //if (rGVLocationInfos.Count < 1) throw new Exception($"æªæ¾å°ç»ç¹åºåºã{taskDTO.toAreaCode}ãå¯ç¨ç©ºè´§ä½ï¼"); |
| | | //var rGVLocationInfo = rGVLocationInfos.OrderBy(x => x.Depth).First(); |
| | | //var rGVLocationInfo = _rGVLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode) ?? throw new Exception($"æªæ¾å°ç»ç¹åºåºã{taskDTO.toAreaCode}ãå¯ç¨ç©ºè´§ä½ï¼"); |
| | | #region ç¹å°ç¹ |
| | | //if (!string.IsNullOrEmpty(taskDTO.toLocationCode)) |
| | | //{ |
| | | // var LocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"æªæ¾å°ç»ç¹è´§ä½ã{taskDTO.toLocationCode}ã"); |
| | | // if (LocationInfo.LocationStatus != LocationStatusEnum.Free.ObjToInt()) throw new Exception($"ç»ç¹è´§ä½ã{taskDTO.toLocationCode}ãè´§ä½ç¶æä¸ä¸ºç©ºè´§ä½"); |
| | | //} |
| | | #endregion |
| | | Dt_StationManger stationManger = _stationMangerService.GetInStationInfo(taskDTO.fromLocationCode) ?? throw new Exception($"æªæ¾å°èµ·ç¹ä½ç½®ã{taskDTO.fromLocationCode}ãç«å°ä¿¡æ¯ï¼"); |
| | | //if (stationManger.IsOccupied == 1) throw new Exception($"èµ·ç¹ä½ç½®ã{taskDTO.fromLocationCode}ãç«å°è¢«å ç¨ï¼è¯·éæ¾ï¼"); |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | WMSTaskNum = taskDTO.taskCode, |
| | | //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = taskDTO.toAreaCode, |
| | |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = stationManger.Remark,//æ¾å
¥åºç«å°å¯¹åºçå¤å½¢æ£æµç¼å· |
| | | NextAddress = stationManger.RGVStationCode, |
| | | TargetAddress = "", |
| | | //Remark = taskDTO.toAreaCode, |
| | | Creater = "WMS", |
| | | }; |
| | | //rGVLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt(); |
| | | //Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | //_rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo); |
| | | //Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | return content.OK(data: new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = "æåï¼" |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | content.Data = new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = $"失败ï¼{ex.Message}" |
| | | }; |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //Dt_Task dt_Task = BaseDal.QueryFirst(x => x.PalletCode == taskDTO.containerCode); |
| | | //if (dt_Task != null) throw new Exception($"æçå·ã{taskDTO.containerCode}ãå·²åå¨ä»»å¡"); |
| | | var stationManger = _stationMangerService.GetOutStationInfo(taskDTO.toLocationCode); |
| | | if (stationManger == null) |
| | | { |
| | | return content.Error($"{taskDTO.toLocationCode}䏿¯åºåºç«å°"); |
| | | } |
| | | Dt_RGVLocationInfo rGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãï¼"); |
| | | if (rGVLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | if (rGVLocationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãç»å®æç®±å·ã{rGVLocationInfo.PalletCode}ãä¸ä»»å¡æç®±å·ã{taskDTO.containerCode}ãä¸å¹é
ï¼"); |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | WMSTaskNum = taskDTO.taskCode, |
| | | //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = rGVLocationInfo.RoadwayNo, |
| | |
| | | Creater = "WMS", |
| | | }; |
| | | rGVLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt(); |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo); |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | try |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo); |
| | | 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(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | content.Data = new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = $"失败ï¼{ex.Message}" |
| | | }; |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | /// <summary> |
| | | /// ç§»åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <param name="taskType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateRGVNewMoveTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | FOURBOTnewMovePodTask fOURBOTnewMovePodTask = new(); |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(taskDTO.fromLocationCode)) throw new Exception($"èµ·ç¹åºä½ä¸è½ä¸ºç©ºï¼"); |
| | | if (string.IsNullOrEmpty(taskDTO.toLocationCode)) throw new Exception($"ç»ç¹åºä½ä¸è½ä¸ºç©ºï¼"); |
| | | Dt_RGVLocationInfo rGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãï¼"); |
| | | if (rGVLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | if (rGVLocationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãç»å®æç®±å·ã{rGVLocationInfo.PalletCode}ãä¸ä»»å¡æç®±å·ã{taskDTO.containerCode}ãä¸å¹é
ï¼"); |
| | | Dt_RGVLocationInfo rGVLocationInfo1 = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"æªæ¾å°ç»ç¹åºä½ã{taskDTO.toLocationCode}ãï¼"); |
| | | if (rGVLocationInfo1.LocationStatus != LocationStatusEnum.Free.ObjToInt()) throw new Exception($"ç»ç¹åºä½ã{taskDTO.toLocationCode}ãå½ååºä½ç¶æä¸ä¸ºç©ºé²ï¼"); |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(FOURBOTnewMovePodTask)) ?? throw new Exception("æªæ¾å°åå车任å¡ä¸åæ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | WMSTaskNum = taskDTO.taskCode, |
| | | Grade = taskDTO.taskPriority, |
| | | PalletCode = taskDTO.containerCode, |
| | | Roadway = rGVLocationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = taskDTO.toLocationCode, |
| | | TargetAddress = taskDTO.toLocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | rGVLocationInfo.LocationStatus = LocationStatusEnum.MoveLock.ObjToInt(); |
| | | rGVLocationInfo1.LocationStatus = LocationStatusEnum.MoveLock.ObjToInt(); |
| | | #region ä¸åååè½¦ä»»å¡ |
| | | fOURBOTnewMovePodTask = new FOURBOTnewMovePodTask |
| | | { |
| | | priority = dt_Task.Grade, |
| | | podID = dt_Task.PalletCode, |
| | | desStorageID = dt_Task.TargetAddress, |
| | | desExt = new { unload = 1 }, // æ¯å¦æ¾ä¸å®¹å¨,0å¦1æ¯ |
| | | desType = 2 |
| | | }; |
| | | fOURBOTnewMovePodTask.taskExt = new |
| | | { |
| | | autoToRest = 1 |
| | | }; |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOTnewMovePodTask.Serialize()); |
| | | var fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>(); |
| | | content.OK(data: fOURBOTReturn); |
| | | if (fOURBOTReturn.returnCode != 0) throw new Exception($"ä¸åæåç§»åºä»»å¡é误ï¼{fOURBOTReturn.returnMsg}"); |
| | | var data = fOURBOTReturn.data.ToString(); |
| | | var fOURBO = data.DeserializeObject<FOURBOTnewMovePodTaskResponseData>(); |
| | | dt_Task.RGVTaskId = fOURBO.taskID; |
| | | dt_Task.TaskState = TaskStatusEnum.RGV_MoveTaskSend.ObjToInt(); |
| | | #endregion |
| | | try |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo); |
| | | _rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo1); |
| | | 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.Data = new |
| | | { |
| | | taskCode = taskDTO.taskCode, |
| | | Message = $"失败ï¼{ex.Message}" |
| | | }; |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |