using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Common.LocationEnum; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Common; using WIDESEAWCS_Core; 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 { public partial class TaskService { #region RGV任务创建 /// /// 创建四向车入库任务 /// /// /// /// public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType) { WebResponseContent content = new WebResponseContent(); try { #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}】站台信息!"); Dt_Task dt_Task = new() { TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), WMSTaskNum = taskDTO.taskCode, Grade = taskDTO.taskPriority, PalletCode = taskDTO.containerCode, Roadway = taskDTO.toAreaCode, TaskState = TaskStatusEnum.New.ObjToInt(), TaskType = taskType, SourceAddress = taskDTO.fromLocationCode, CurrentAddress = taskDTO.fromLocationCode, NextAddress = stationManger.RGVStationCode, TargetAddress = "", Creater = "WMS", }; BaseDal.AddData(dt_Task); 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); } } /// /// 创建四向车出库任务 /// /// /// /// public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType) { WebResponseContent content = new WebResponseContent(); try { 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}】当前库位状态不可出库!"); 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.OutLock.ObjToInt(); 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) { content.Data = new { taskCode = taskDTO.taskCode, Message = $"失败!{ex.Message}" }; return content.Error(ex.Message); } } #endregion } }