| | |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using SqlSugar.Extensions; |
| | | using WIDESEAWCS_DTO.WMS; |
| | | using WIDESEAWCS_Common.LocationEnum; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | | public partial class TaskService |
| | | { |
| | | /// <summary> |
| | | /// å建å
¥åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateNewInTask(TaskDTO taskDTO) |
| | | #region å¯ä¹å£«ä»»å¡å建 |
| | | /// <summary> |
| | | /// å建å¯ä¹å£«AGVå
¥åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | try |
| | | { |
| | | try |
| | | { |
| | | int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt(); |
| | | //è·åè´§ä½ä¿¡æ¯ |
| | | //List<Dt_KLSLocationInfo> kLSLocationInfos= |
| | | Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.LocationType == containerType); |
| | | if (kLSLocationInfo == null) throw new Exception($"æªæ¾å°ç»ç¹åºåºã{taskDTO.toAreaCode}ãå¯ç¨ç©ºè´§ä½ï¼"); |
| | | 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 = kLSLocationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = kLSLocationInfo.LocationCode, |
| | | 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(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// å建å¯ä¹å£«AGVåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <param name="taskType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateKLSNewOutTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | try |
| | | { |
| | | Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode); |
| | | if (kLSLocationInfo == null) throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãï¼"); |
| | | if (kLSLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | 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 = kLSLocationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = taskDTO.toLocationCode, |
| | | 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(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region RGVä»»å¡å建 |
| | | /// <summary> |
| | | /// å建åå车å
¥åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <param name="taskType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | try |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// å建åå车åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <param name="taskType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | try |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 海康AGVä»»å¡å建 |
| | | /// <summary> |
| | | /// å建海康AGVå
¥åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <param name="taskType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateHKNewInTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | try |
| | | { |
| | | int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();//è¿éæä¸ç¥éæ¯ä»ä¹ç±»å |
| | | //è·åè´§ä½ä¿¡æ¯ |
| | | Dt_HKLocationInfo? kLSLocationInfo = _hKLocationInfoService.Repository.QueryFirst(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.LocationType == containerType); |
| | | if (kLSLocationInfo == null) throw new Exception($"æªæ¾å°ç»ç¹åºåºã{taskDTO.toAreaCode}ãå¯ç¨ç©ºè´§ä½ï¼"); |
| | | 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 = kLSLocationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = kLSLocationInfo.LocationCode, |
| | | TargetAddress = kLSLocationInfo.LocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | kLSLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt(); |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _hKLocationInfoService.Repository.UpdateData(kLSLocationInfo); |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// å建海康AGVåºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskDTO"></param> |
| | | /// <param name="taskType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateHKNewOutTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | try |
| | | { |
| | | Dt_HKLocationInfo? hKLocationInfo = _hKLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode); |
| | | if (hKLocationInfo == null) throw new Exception($"æªæ¾å°èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãï¼"); |
| | | if (hKLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"èµ·ç¹åºä½ã{taskDTO.fromLocationCode}ãå½ååºä½ç¶æä¸å¯åºåºï¼"); |
| | | 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 = hKLocationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = taskType, |
| | | SourceAddress = taskDTO.fromLocationCode, |
| | | CurrentAddress = taskDTO.fromLocationCode, |
| | | NextAddress = taskDTO.toLocationCode, |
| | | TargetAddress = taskDTO.toLocationCode, |
| | | Creater = "WMS", |
| | | }; |
| | | hKLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt(); |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _hKLocationInfoService.Repository.UpdateData(hKLocationInfo); |
| | | Db.Ado.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 5 跨楼å±è¿è¾ä»»å¡å建 |
| | | public WebResponseContent CarryTask(TaskDTO taskDTO, int taskType) |
| | | { |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 6 è£åªéè´§ |
| | | public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType) |
| | | { |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | #endregion |
| | | } |
| | | } |