修改任务

usertest
jianghaiqing 3 months ago
parent a690f76c47
commit 7def2b67ea

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.TaskPlat.Dtos
{
/// <summary>
/// 任务转发消息回执
/// </summary>
public class TaskTransferMsgDto
{
/// <summary>
/// 执行日期
/// </summary>
public DateTime ExcuteDate { get; set; }
/// <summary>
/// 明细
/// </summary>
public List<TaskTransferMsgDataDto> Detail { get; set; }
}
public class TaskTransferMsgDataDto
{
/// <summary>
/// 业务ID
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// 提单号
/// </summary>
public string MBlNo { get; set; }
/// <summary>
/// 状态
/// </summary>
public string Status { get; set; }
/// <summary>
/// 消息
/// </summary>
public string Message { get; set; }
}
}

@ -35,20 +35,20 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <param name="taskPKId">起运港未提箱任务主键</param>
/// <param name="businessTaskMailId">邮件模板主键</param>
/// <returns>返回回执</returns>
Task<DataResult> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId);
Task<DataResult<TaskTransferMsgDto>> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId);
/// <summary>
/// 发送邮件通知给客户(任务自动机调取)
/// </summary>
/// <param name="dataContext">数据上下文</param>
/// <returns>返回回执</returns>
Task<DataResult> SendEmailToCustomerTask(TaskFlowDataContext dataContext);
Task<DataResult<TaskTransferMsgDto>> SendEmailToCustomerTask(TaskFlowDataContext dataContext);
/// <summary>
/// 手工发送邮件通知给客户
/// </summary>
/// <param name="taskPKId">起运港未提箱任务主键</param>
/// <returns>返回回执</returns>
Task<DataResult> ManualSendEmailToCustomer(long taskPKId);
Task<DataResult<TaskTransferMsgDto>> ManualSendEmailToCustomer(long taskPKId);
}
}

@ -130,7 +130,7 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <param name="taskPKId">起运港未提箱主键</param>
/// <param name="businessTaskMailId">邮件模板主键</param>
/// <returns>返回回执</returns>
public async Task<DataResult> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId)
public async Task<DataResult<TaskTransferMsgDto>> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId)
{
/*
1
@ -153,23 +153,40 @@ namespace DS.WMS.Core.TaskPlat.Method
{
logger.LogInformation($"匹配订单信息失败 mblno={entity.MBL_NO},原因:{queryRlt.Message}");
return DataResult.Failed($"匹配订单信息失败 mblno={entity.MBL_NO},原因:{queryRlt.Message}");
return DataResult<TaskTransferMsgDto>.Failed($"匹配订单信息失败 mblno={entity.MBL_NO},原因:{queryRlt.Message}");
}
var taskInfo = entity.Adapt<TaskPOLContainerNotPickUpShowDto>();
BusinessTaskMail? mailConfig = _taskMailService.GetAsync(businessTaskMailId).GetAwaiter().GetResult().Data;
if (mailConfig == null)
{
await _logService.WriteLogAsync(new Op.Dtos.TaskInteraction.TaskUpdateRequest
{
BusinessId = taskPKId,
BusinessType = BusinessType.OceanShippingExport,
AutoCreateNext = true,
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
}, $"未能根据任务配置值获取邮件模板设置");
return DataResult<TaskTransferMsgDto>.Failed("未能根据任务配置值获取邮件模板设置");
}
var orderInfo = queryRlt.Data;
logger.LogInformation($"获取订单详情成功 bookid={orderInfo.currOrder.Id}");
DateTime nowDate = DateTime.Now;
List<long> orderIdList = new List<long> { orderInfo.currOrder.Id };
if (orderInfo.otherOrderList.Count > 0)
orderIdList.AddRange(orderInfo.otherOrderList.Select(t => t.Id).ToList());
//如果是拆票需要处理,处理所以分票记录
if (orderInfo.currOrder.SplitOrMergeFlag == 1)
{
List<long> orderIdList = new List<long> { orderInfo.currOrder.Id };
if (orderInfo.otherOrderList.Count > 0)
orderIdList.AddRange(orderInfo.otherOrderList.Select(t => t.Id).ToList());
foreach (var id in orderIdList)
{
var taskAllocList = tenantDb.Queryable<TaskBaseAllocation>().Where(a => a.TaskId == taskPKId).ToList();
@ -236,51 +253,59 @@ namespace DS.WMS.Core.TaskPlat.Method
}
}
TaskTransferMsgDto resultDto = new TaskTransferMsgDto {
ExcuteDate = nowDate,
Detail = new List<TaskTransferMsgDataDto>()
};
BusinessTaskMail? mailConfig = _taskMailService.GetAsync(businessTaskMailId).GetAwaiter().GetResult().Data;
Dictionary<long, Tuple<bool, string, string>> dict = new Dictionary<long, Tuple<bool, string, string>>();
if (mailConfig == null)
foreach (var id in orderIdList)
{
await _logService.WriteLogAsync(new Op.Dtos.TaskInteraction.TaskUpdateRequest
TaskTransferMsgDataDto detail = new TaskTransferMsgDataDto {
BusinessId = id,
};
var model = new MailTemplateModel<TaskPOLContainerNotPickUpShowDto>(taskInfo)
{
BusinessId = taskPKId,
BusinessId = id,
BusinessType = BusinessType.OceanShippingExport,
AutoCreateNext = true,
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
};
}, $"未能根据任务配置值获取邮件模板设置");
MailService mailService = new MailService(serviceProvider);
var result = await mailService.SendAsync(mailConfig, model);
return DataResult.Failed("未能根据任务配置值获取邮件模板设置");
}
var taskInfo = entity.Adapt<TaskPOLContainerNotPickUpShowDto>();
if (!result.Succeeded)
{
await _logService.WriteLogAsync(new Op.Dtos.TaskInteraction.TaskUpdateRequest
{
BusinessId = taskPKId,
BusinessType = BusinessType.OceanShippingExport,
AutoCreateNext = true,
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
var model = new MailTemplateModel<TaskPOLContainerNotPickUpShowDto>(taskInfo)
{
BusinessId = orderInfo.currOrder.Id,
BusinessType = BusinessType.OceanShippingExport,
};
}, result.Message);
MailService mailService = new MailService(serviceProvider);
var result = await mailService.SendAsync(mailConfig, model);
//return DataResult.Failed(result.Message);
}
if (!result.Succeeded)
{
await _logService.WriteLogAsync(new Op.Dtos.TaskInteraction.TaskUpdateRequest
{
BusinessId = taskPKId,
BusinessType = BusinessType.OceanShippingExport,
AutoCreateNext = true,
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
detail.Status = result.Succeeded ? "SUCC" : "FAILURE";
detail.Message = result.Message;
detail.MBlNo = entity.MBL_NO;
}, result.Message);
resultDto.Detail.Add(detail);
return DataResult.Failed(result.Message);
dict.Add(id, new Tuple<bool, string,string>(result.Succeeded, result.Message, entity.MBL_NO));
}
//发送完邮件,自动标记任务状态为完成
await SetTaskStatus(taskPKId, TaskBaseTypeEnum.POL_CTN_NOT_PICKUP, TaskStatusEnum.Complete, DateTime.Now, null);
//如果存在失败记录,不能置完成状态
if (!dict.Any(t => !t.Value.Item1))
{
//发送完邮件,自动标记任务状态为完成
await SetTaskStatus(taskPKId, TaskBaseTypeEnum.POL_CTN_NOT_PICKUP, TaskStatusEnum.Complete, DateTime.Now, null);
}
return DataResult.Successed(result.Message);
return DataResult<TaskTransferMsgDto>.Success(resultDto);
}
#endregion
@ -290,7 +315,7 @@ namespace DS.WMS.Core.TaskPlat.Method
/// </summary>
/// <param name="dataContext">数据上下文</param>
/// <returns>返回回执</returns>
public async Task<DataResult> SendEmailToCustomerTask(TaskFlowDataContext dataContext)
public async Task<DataResult<TaskTransferMsgDto>> SendEmailToCustomerTask(TaskFlowDataContext dataContext)
{
var taskPKId = dataContext.Get<Nullable<long>>(TaskFlowDataNameConst.TaskPKId) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskPKId)}");
var businessTaskMailId = dataContext.Get<Nullable<long>>($"{nameof(BusinessTaskMail)}.{nameof(BusinessTaskMail.Id)}") ?? throw new ArgumentException();
@ -305,7 +330,7 @@ namespace DS.WMS.Core.TaskPlat.Method
}, $"缺少参数:{nameof(BusinessTaskMail)}.{nameof(BusinessTaskMail.Id)}");
return DataResult.Failed($"缺少参数:{nameof(BusinessTaskMail)}.{nameof(BusinessTaskMail.Id)}");
return DataResult<TaskTransferMsgDto>.Failed($"缺少参数:{nameof(BusinessTaskMail)}.{nameof(BusinessTaskMail.Id)}");
}
return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId);
@ -318,7 +343,7 @@ namespace DS.WMS.Core.TaskPlat.Method
/// </summary>
/// <param name="taskPKId">起运港未提箱任务主键</param>
/// <returns>返回回执</returns>
public async Task<DataResult> ManualSendEmailToCustomer(long taskPKId)
public async Task<DataResult<TaskTransferMsgDto>> ManualSendEmailToCustomer(long taskPKId)
{
var paramConfig = _configService.GetConfig("POLContainerNotPickUpEmailTemplateID", long.Parse(user.TenantId), false).GetAwaiter().GetResult()?.Data?.Value;
@ -330,7 +355,7 @@ namespace DS.WMS.Core.TaskPlat.Method
}
else
{
return DataResult.Failed($"缺少系统参数参数:起运港未提箱邮件模板ID-POLContainerNotPickUpEmailTemplateID");
return DataResult<TaskTransferMsgDto>.Failed($"缺少系统参数参数:起运港未提箱邮件模板ID-POLContainerNotPickUpEmailTemplateID");
}
return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId);

Loading…
Cancel
Save