#region << 版 本 注 释 >>
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEA_TaskInfoService
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
#endregion << 版 本 注 释 >>
|
|
using AutoMapper;
|
using Newtonsoft.Json;
|
using SqlSugar;
|
using WIDESEA_Common.TaskEnum;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_DTO.Task;
|
using WIDESEA_External.ERPService;
|
using WIDESEA_External.MESService;
|
using WIDESEA_IBasicRepository;
|
using WIDESEA_IBasicService;
|
using WIDESEA_ITaskInfoRepository;
|
using WIDESEA_ITaskInfoService;
|
using WIDESEA_Model.Models;
|
|
namespace WIDESEA_TaskInfoService
|
{
|
public partial class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService
|
{
|
private readonly IMapper _mapper;
|
private readonly IUnitOfWorkManage _unitOfWorkManage;
|
private readonly IBasicRepository _basicRepository;
|
private readonly IBasicService _basicService;
|
private readonly IInvokeERPService _invokeERPService;
|
private readonly IInvokeMESService _invokeMESService;
|
private readonly IRepository<Dt_StockInfo> _blankStockInfoRepository;
|
private readonly IApiInfoRepository _apiInfoRepository;
|
public ITaskRepository Repository => BaseDal;
|
|
private Dictionary<string, OrderByType> _taskOrderBy = new()
|
{
|
{nameof(Dt_Task.Grade),OrderByType.Desc },
|
{nameof(Dt_Task.CreateDate),OrderByType.Asc},
|
};
|
|
public List<int> TaskInboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 500 && x < 900).ToList();
|
|
public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList();
|
|
public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IBasicRepository basicRepository, IInvokeERPService invokeERPService, IInvokeMESService invokeMESService, IRepository<Dt_StockInfo> blankStockInfoRepository, IApiInfoRepository _apiInfoRepository) : base(BaseDal)
|
{
|
_mapper = mapper;
|
_unitOfWorkManage = unitOfWorkManage;
|
_basicService = basicService;
|
_basicRepository = basicRepository;
|
_invokeERPService = invokeERPService;
|
_invokeMESService = invokeMESService;
|
_blankStockInfoRepository = blankStockInfoRepository;
|
this._apiInfoRepository = _apiInfoRepository;
|
}
|
|
/// <summary>
|
/// 任务信息推送至WCS
|
/// </summary>
|
/// <returns></returns>
|
public WebResponseContent PushTasksToWCS(List<Dt_Task> tasks, string agvDescription = "")
|
{
|
try
|
{
|
if (tasks == null || tasks.Count == 0)
|
{
|
return WebResponseContent.Instance.Error($"传入任务为空");
|
}
|
List<WMSTaskDTO> taskDTOs = _mapper.Map<List<WMSTaskDTO>>(tasks);
|
taskDTOs.ForEach(x =>
|
{
|
x.AGVArea = agvDescription;
|
});
|
string url = AppSettings.Get("WCS");
|
if (string.IsNullOrEmpty(url))
|
{
|
return WebResponseContent.Instance.Error($"未找到WCSApi地址,请检查配置文件");
|
}
|
string response = HttpHelper.Post($"{url}/api/Task/ReceiveTask", taskDTOs.Serialize());
|
|
return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("返回错误");
|
}
|
catch (Exception ex)
|
{
|
return WebResponseContent.Instance.Error(ex.Message);
|
}
|
}
|
}
|
}
|