修改任务

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="taskPKId">起运港未提箱任务主键</param>
/// <param name="businessTaskMailId">邮件模板主键</param> /// <param name="businessTaskMailId">邮件模板主键</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<DataResult> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId); Task<DataResult<TaskTransferMsgDto>> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId);
/// <summary> /// <summary>
/// 发送邮件通知给客户(任务自动机调取) /// 发送邮件通知给客户(任务自动机调取)
/// </summary> /// </summary>
/// <param name="dataContext">数据上下文</param> /// <param name="dataContext">数据上下文</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<DataResult> SendEmailToCustomerTask(TaskFlowDataContext dataContext); Task<DataResult<TaskTransferMsgDto>> SendEmailToCustomerTask(TaskFlowDataContext dataContext);
/// <summary> /// <summary>
/// 手工发送邮件通知给客户 /// 手工发送邮件通知给客户
/// </summary> /// </summary>
/// <param name="taskPKId">起运港未提箱任务主键</param> /// <param name="taskPKId">起运港未提箱任务主键</param>
/// <returns>返回回执</returns> /// <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="taskPKId">起运港未提箱主键</param>
/// <param name="businessTaskMailId">邮件模板主键</param> /// <param name="businessTaskMailId">邮件模板主键</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
public async Task<DataResult> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId) public async Task<DataResult<TaskTransferMsgDto>> InnerSendEmailToCustomer(long taskPKId, long businessTaskMailId)
{ {
/* /*
1 1
@ -153,23 +153,40 @@ namespace DS.WMS.Core.TaskPlat.Method
{ {
logger.LogInformation($"匹配订单信息失败 mblno={entity.MBL_NO},原因:{queryRlt.Message}"); 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; var orderInfo = queryRlt.Data;
logger.LogInformation($"获取订单详情成功 bookid={orderInfo.currOrder.Id}"); logger.LogInformation($"获取订单详情成功 bookid={orderInfo.currOrder.Id}");
DateTime nowDate = DateTime.Now; DateTime nowDate = DateTime.Now;
//如果是拆票需要处理,处理所以分票记录
if (orderInfo.currOrder.SplitOrMergeFlag == 1)
{
List<long> orderIdList = new List<long> { orderInfo.currOrder.Id }; List<long> orderIdList = new List<long> { orderInfo.currOrder.Id };
if (orderInfo.otherOrderList.Count > 0) if (orderInfo.otherOrderList.Count > 0)
orderIdList.AddRange(orderInfo.otherOrderList.Select(t => t.Id).ToList()); orderIdList.AddRange(orderInfo.otherOrderList.Select(t => t.Id).ToList());
//如果是拆票需要处理,处理所以分票记录
if (orderInfo.currOrder.SplitOrMergeFlag == 1)
{
foreach (var id in orderIdList) foreach (var id in orderIdList)
{ {
var taskAllocList = tenantDb.Queryable<TaskBaseAllocation>().Where(a => a.TaskId == taskPKId).ToList(); var taskAllocList = tenantDb.Queryable<TaskBaseAllocation>().Where(a => a.TaskId == taskPKId).ToList();
@ -236,27 +253,22 @@ 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
{ {
BusinessId = taskPKId, TaskTransferMsgDataDto detail = new TaskTransferMsgDataDto {
BusinessType = BusinessType.OceanShippingExport, BusinessId = id,
AutoCreateNext = true, };
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
}, $"未能根据任务配置值获取邮件模板设置");
return DataResult.Failed("未能根据任务配置值获取邮件模板设置");
}
var taskInfo = entity.Adapt<TaskPOLContainerNotPickUpShowDto>();
var model = new MailTemplateModel<TaskPOLContainerNotPickUpShowDto>(taskInfo) var model = new MailTemplateModel<TaskPOLContainerNotPickUpShowDto>(taskInfo)
{ {
BusinessId = orderInfo.currOrder.Id, BusinessId = id,
BusinessType = BusinessType.OceanShippingExport, BusinessType = BusinessType.OceanShippingExport,
}; };
@ -274,13 +286,26 @@ namespace DS.WMS.Core.TaskPlat.Method
}, result.Message); }, result.Message);
return DataResult.Failed(result.Message); //return DataResult.Failed(result.Message);
} }
detail.Status = result.Succeeded ? "SUCC" : "FAILURE";
detail.Message = result.Message;
detail.MBlNo = entity.MBL_NO;
resultDto.Detail.Add(detail);
dict.Add(id, new Tuple<bool, string,string>(result.Succeeded, result.Message, entity.MBL_NO));
}
//如果存在失败记录,不能置完成状态
if (!dict.Any(t => !t.Value.Item1))
{
//发送完邮件,自动标记任务状态为完成 //发送完邮件,自动标记任务状态为完成
await SetTaskStatus(taskPKId, TaskBaseTypeEnum.POL_CTN_NOT_PICKUP, TaskStatusEnum.Complete, DateTime.Now, null); await SetTaskStatus(taskPKId, TaskBaseTypeEnum.POL_CTN_NOT_PICKUP, TaskStatusEnum.Complete, DateTime.Now, null);
}
return DataResult.Successed(result.Message); return DataResult<TaskTransferMsgDto>.Success(resultDto);
} }
#endregion #endregion
@ -290,7 +315,7 @@ namespace DS.WMS.Core.TaskPlat.Method
/// </summary> /// </summary>
/// <param name="dataContext">数据上下文</param> /// <param name="dataContext">数据上下文</param>
/// <returns>返回回执</returns> /// <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 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(); 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)}"); }, $"缺少参数:{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); return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId);
@ -318,7 +343,7 @@ namespace DS.WMS.Core.TaskPlat.Method
/// </summary> /// </summary>
/// <param name="taskPKId">起运港未提箱任务主键</param> /// <param name="taskPKId">起运港未提箱任务主键</param>
/// <returns>返回回执</returns> /// <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; 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 else
{ {
return DataResult.Failed($"缺少系统参数参数:起运港未提箱邮件模板ID-POLContainerNotPickUpEmailTemplateID"); return DataResult<TaskTransferMsgDto>.Failed($"缺少系统参数参数:起运港未提箱邮件模板ID-POLContainerNotPickUpEmailTemplateID");
} }
return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId); return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId);

Loading…
Cancel
Save