#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>, ITaskService { private readonly IMapper _mapper; private readonly IUnitOfWorkManage _unitOfWorkManage; public IRepository Repository => BaseDal; private Dictionary _taskOrderBy = new() { {nameof(Dt_Task.Grade),OrderByType.Desc }, {nameof(Dt_Task.CreateDate),OrderByType.Asc}, }; public List TaskTypes => typeof(TaskTypeEnum).GetEnumIndexList(); public List TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); public TaskService(IRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) { _mapper = mapper; _unitOfWorkManage = unitOfWorkManage; } /// /// 创建任务(组盘入库任务、空托盘回库任务) /// /// 托盘号 /// 起始地址 /// 目标地址 /// 巷道号 /// 仓库主键 /// 托盘类型 /// 任务类型 /// 是否成功 public async 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; } } }