|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
@ -22,12 +24,20 @@ namespace Myshipping.Application
|
|
|
|
|
public class TaskManageService : ITaskManageService, IDynamicApiController
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskSIFeedBackInfo> _taskSIFeedBackInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskSIFeedBackContaInfo> _taskSIFeedBackContaInfoRepository;
|
|
|
|
|
|
|
|
|
|
private readonly ILogger<BookingOrderService> _logger;
|
|
|
|
|
|
|
|
|
|
public TaskManageService(SqlSugarRepository<TaskBaseInfo> taskBaseInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskSIFeedBackInfo> taskSIFeedBackInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskSIFeedBackContaInfo> taskSIFeedBackContaInfoRepository,
|
|
|
|
|
ILogger<BookingOrderService> logger)
|
|
|
|
|
{
|
|
|
|
|
_taskBaseInfoRepository = taskBaseInfoRepository;
|
|
|
|
|
_taskSIFeedBackInfoRepository = taskSIFeedBackInfoRepository;
|
|
|
|
|
_taskSIFeedBackContaInfoRepository = taskSIFeedBackContaInfoRepository;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
@ -35,6 +45,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info">任务详情</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[AllowAnonymous,HttpPost("/TaskManage/CreateTaskJob")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> CreateTaskJob(TaskManageOrderMessageInfo info)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
@ -46,10 +57,7 @@ namespace Myshipping.Application
|
|
|
|
|
1、判断当前任务的主键是否已入库,已入库不允许重复,返回错误提示。
|
|
|
|
|
2、
|
|
|
|
|
*/
|
|
|
|
|
if(info.Main.TaskType == TaskBaseTypeEnum.BC)
|
|
|
|
|
{
|
|
|
|
|
result = await InitTaskJob(info);
|
|
|
|
|
}
|
|
|
|
|
result = await InitTaskJob(info);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -71,8 +79,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.OUT_BUSI_NO == info.Head.GID
|
|
|
|
|
&& t.TASK_TYPE == info.Main.TaskType.ToString());
|
|
|
|
|
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.OUT_BUSI_NO == info.Head.GID);
|
|
|
|
|
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
|
throw Oops.Oh($"任务已经存在不能重复提交");
|
|
|
|
@ -80,6 +87,7 @@ namespace Myshipping.Application
|
|
|
|
|
taskInfo = new TaskBaseInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
TASK_NO = info.Head.GID,
|
|
|
|
|
STATUS = TaskStatusEnum.Create.ToString(),
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
IS_EXCEPT = 0,
|
|
|
|
@ -96,6 +104,9 @@ namespace Myshipping.Application
|
|
|
|
|
TASK_TYPE = info.Main.TaskType.ToString(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
taskInfo.CreatedTime = DateTime.Now;
|
|
|
|
|
taskInfo.UpdatedTime = taskInfo.CreatedTime;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(taskInfo.CARRIER_ID)
|
|
|
|
|
&& taskInfo.CARRIER_ID == "MSC")
|
|
|
|
|
{
|
|
|
|
@ -109,11 +120,45 @@ namespace Myshipping.Application
|
|
|
|
|
//新增
|
|
|
|
|
await _taskBaseInfoRepository.InsertAsync(taskInfo);
|
|
|
|
|
|
|
|
|
|
//SI反馈入库
|
|
|
|
|
if (info.Main.TaskType == TaskBaseTypeEnum.SI_FEEDBACK)
|
|
|
|
|
{
|
|
|
|
|
if(info.Main.SIFeedBack == null)
|
|
|
|
|
throw Oops.Oh($"任务类型={info.Main.TaskType.ToString()} SIFeedBack信息必传");
|
|
|
|
|
|
|
|
|
|
TaskSIFeedBackInfo taskSIFeedBackInfo = info.Main.SIFeedBack.Adapt<TaskSIFeedBackInfo>();
|
|
|
|
|
|
|
|
|
|
taskSIFeedBackInfo.PK_ID = IDGen.NextID().ToString();
|
|
|
|
|
taskSIFeedBackInfo.TASK_PKID = taskInfo.PK_ID;
|
|
|
|
|
|
|
|
|
|
taskSIFeedBackInfo.CreatedTime = taskInfo.CreatedTime;
|
|
|
|
|
taskSIFeedBackInfo.UpdatedTime = taskInfo.CreatedTime;
|
|
|
|
|
|
|
|
|
|
await _taskSIFeedBackInfoRepository.InsertAsync(taskSIFeedBackInfo);
|
|
|
|
|
|
|
|
|
|
//SI反馈箱信息入库
|
|
|
|
|
if(info.Main.SIFeedBack.ContaList != null && info.Main.SIFeedBack.ContaList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
info.Main.SIFeedBack.ContaList.ForEach( async ctn => {
|
|
|
|
|
var contaInfo = ctn.Adapt<TaskSIFeedBackContaInfo>();
|
|
|
|
|
|
|
|
|
|
contaInfo.PK_ID = IDGen.NextID().ToString();
|
|
|
|
|
contaInfo.P_PKID = taskSIFeedBackInfo.PK_ID;
|
|
|
|
|
|
|
|
|
|
contaInfo.CreatedTime = taskInfo.CreatedTime;
|
|
|
|
|
contaInfo.UpdatedTime = taskInfo.CreatedTime;
|
|
|
|
|
|
|
|
|
|
await _taskSIFeedBackContaInfoRepository.InsertAsync(contaInfo);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "新增任务成功";
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"创建任务异常,{ex.Message}";
|
|
|
|
|
throw Oops.Oh($"{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|