#region << 版 本 注 释 >>
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEA_TaskInfoService
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
#endregion << 版 本 注 释 >>
|
|
using AutoMapper;
|
using SqlSugar;
|
using WIDESEA_Common.TaskEnum;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_DTO.Task;
|
using WIDESEA_IBasicService;
|
using WIDESEA_IInboundService;
|
using WIDESEA_IOutboundService;
|
using WIDESEA_IRecordService;
|
using WIDESEA_IStockService;
|
using WIDESEA_ITaskInfoService;
|
using WIDESEA_Model.Models;
|
|
namespace WIDESEA_TaskInfoService
|
{
|
public partial class TaskService : ServiceBase<Dt_Task, IRepository<Dt_Task>>, ITaskService
|
{
|
private readonly IMapper _mapper;
|
private readonly IUnitOfWorkManage _unitOfWorkManage;
|
|
public IRepository<Dt_Task> Repository => BaseDal;
|
|
private Dictionary<string, OrderByType> _taskOrderBy = new()
|
{
|
{nameof(Dt_Task.Grade),OrderByType.Desc },
|
{nameof(Dt_Task.CreateDate),OrderByType.Asc},
|
};
|
|
public List<int> TaskTypes => typeof(TaskTypeEnum).GetEnumIndexList();
|
|
public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
|
|
public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
|
{
|
_mapper = mapper;
|
_unitOfWorkManage = unitOfWorkManage;
|
}
|
|
/// <summary>
|
/// 创建任务(组盘入库任务、空托盘回库任务)
|
/// </summary>
|
/// <param name="palletCode">托盘号</param>
|
/// <param name="sourceAddress">起始地址</param>
|
/// <param name="targetAddress">目标地址</param>
|
/// <param name="roadway">巷道号</param>
|
/// <param name="warehouseId">仓库主键</param>
|
/// <param name="palletType">托盘类型</param>
|
/// <param name="taskType">任务类型</param>
|
/// <returns>是否成功</returns>
|
public async Task<Dt_Task?> CreateTaskInboundAsync(CreateTaskDto taskDto)
|
{
|
if (string.IsNullOrWhiteSpace(taskDto.PalletCode) || string.IsNullOrWhiteSpace(taskDto.SourceAddress) || string.IsNullOrWhiteSpace(taskDto.TargetAddress) || string.IsNullOrWhiteSpace(taskDto.Roadway))
|
{
|
return null;
|
}
|
|
if (taskDto.TaskType != TaskTypeEnum.Inbound || taskDto.TaskType != TaskTypeEnum.InEmpty)
|
{
|
return null;
|
}
|
|
var task = new Dt_Task
|
{
|
TaskNum = 0,
|
PalletCode = taskDto.PalletCode,
|
PalletType = taskDto.PalletType,
|
Roadway = taskDto.Roadway,
|
TaskType = taskDto.TaskType.GetHashCode(),
|
TaskStatus = TaskStatusEnum.New.GetHashCode(),
|
SourceAddress = taskDto.SourceAddress,
|
TargetAddress = taskDto.TargetAddress,
|
CurrentAddress = taskDto.SourceAddress,
|
NextAddress = taskDto.TargetAddress,
|
WarehouseId = taskDto.WarehouseId,
|
Grade = 1,
|
Creater = "system"
|
};
|
|
return await Repository.AddDataAsync(task) > 0 ? task : null;
|
}
|
|
}
|
}
|