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任务创建
|
/// <summary>
|
/// 创建四向车入库任务
|
/// </summary>
|
/// <param name="taskDTO"></param>
|
/// <param name="taskType"></param>
|
/// <returns></returns>
|
public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType)
|
{
|
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}】可用空货位!");
|
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);
|
}
|
}
|
/// <summary>
|
/// 创建四向车出库任务
|
/// </summary>
|
/// <param name="taskDTO"></param>
|
/// <param name="taskType"></param>
|
/// <returns></returns>
|
public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType)
|
{
|
try
|
{
|
//Dt_Task dt_Task = BaseDal.QueryFirst(x => x.PalletCode == taskDTO.containerCode);
|
//if (dt_Task != null) throw new Exception($"托盘号【{taskDTO.containerCode}】已存在任务");
|
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,
|
//WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
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();
|
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);
|
}
|
}
|
#endregion
|
}
|
}
|