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;
namespace WIDESEAWCS_TaskInfoService
{
public partial class TaskService
{
#region RGV任务创建
///
/// 创建四向车入库任务
///
///
///
///
public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType)
{
try
{
//List? 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}】可用空货位!");
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,
TaskState = TaskStatusEnum.New.ObjToInt(),
TaskType = taskType,
SourceAddress = taskDTO.fromLocationCode,
CurrentAddress = taskDTO.fromLocationCode,
NextAddress = stationManger.Remark,//找入库站台对应的外形检测编号
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();
}
catch (Exception ex)
{
Db.Ado.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
}
}
///
/// 创建四向车出库任务
///
///
///
///
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
}
}