修改舱位差异判断

master
jianghaiqing 6 months ago
parent 48388b60e1
commit a97c46b1a2

@ -66,6 +66,8 @@ namespace Myshipping.Application
private readonly IEventPublisher _publisher;
private readonly INamedServiceProvider<IBookingOrderService> _namedBookingOrderServiceProvider;
private readonly INamedServiceProvider<ITaskManageService> _namedTaskManageServiceProvider;
private readonly IDjyCustomerService _djyCustomerService;
private readonly IBookingValueAddedService _bookingValueAddedService;
private readonly IBookingLabelService _bookingLabelService;
@ -104,6 +106,7 @@ namespace Myshipping.Application
SqlSugarRepository<BookingOrder> repBookingOrder,
SqlSugarRepository<BookingLabelAllocation> repLabelAllocation,
IBookingLabelService bookingLabelService,
INamedServiceProvider<ITaskManageService> namedTaskManageServiceProvider,
SqlSugarRepository<SysUser> sysUserRepository,
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate)
{
@ -132,6 +135,7 @@ namespace Myshipping.Application
_repPrintTemplate = repPrintTemplate;
_sysUserRepository = sysUserRepository;
_namedTaskManageServiceProvider = namedTaskManageServiceProvider;
}
#region 舱位
@ -753,7 +757,7 @@ namespace Myshipping.Application
TaskBCInfoDto bcTargetDto = dto.DataObj.Adapt<TaskBCInfoDto>();
//执行差异重要提醒
//await MeasureDiffCautionTask(bcSrcDto, bcTargetDto, model.Id);
await MeasureDiffCautionTask(bcSrcDto, bcTargetDto, model.Id);
//提取箱信息
var ctnList = _repCtn.AsQueryable().Filter(null, true)
@ -3051,39 +3055,6 @@ namespace Myshipping.Application
}
#endregion
///// <summary>
///// 校验是否可以生成订舱订单
///// </summary>
///// <param name="id">舱位主键</param>
///// <returns></returns>
//[HttpGet("/BookingSlot/ValidateCreateBookingOrder")]
//public async Task<TaskManageOrderResultDto> ValidateCreateBookingOrder(long id)
//{
// TaskManageOrderResultDto result = new TaskManageOrderResultDto();
// var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.Id == id);
// if (slotInfo == null)
// {
// throw Oops.Oh($"获取舱位失败,舱位不存在或已作废");
// }
// //if(so)
// return result;
//}
/// <summary>
/// 批量发送邮件提醒(发送客户)
/// </summary>
/// <param name="model">舱位批量发送邮件请求</param>
/// <returns></returns>
[HttpPost("/BookingSlot/SendEmail")]
public async Task<TaskManageOrderResultDto> SendEmail(BookingSlotSendEmailDto model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
result.succ = true;
return result;
}
#region 估算差异重要提醒
/// <summary>
/// 估算差异重要提醒
@ -3095,439 +3066,107 @@ namespace Myshipping.Application
[NonAction]
public async Task MeasureDiffCautionTask(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId)
{
if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
try
{
var bookingSlotAllocList = _repBase.AsQueryable().Filter(null, true)
if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
{
var bookingSlotAllocList = _repBase.AsQueryable().Filter(null, true)
.LeftJoin<BookingSlotAllocation>((slot, alloc) => slot.Id == alloc.BOOKING_SLOT_ID)
.Where((slot, alloc) => slot.Id == slotId && slot.IsDeleted == false && slot.TenantId == UserManager.TENANT_ID && alloc.IsDeleted == false)
.Select((slot, alloc) => new { Slot = slot, Alloc = alloc }).ToList();
List<BookingOrder> bookingOrderList = new List<BookingOrder>();
List<SysUser> userList = new List<SysUser>();
List<long> userIds = new List<long>();
List<BookingOrder> bookingOrderList = new List<BookingOrder>();
List<SysUser> userList = new List<SysUser>();
List<long> userIds = new List<long>();
if (bookingSlotAllocList.Any(t => t.Alloc != null))
{
var bookingNoList = bookingSlotAllocList.Select(a => a.Alloc.BOOKING_ID).ToList();
bookingOrderList = _repBookingOrder.AsQueryable().Filter(null, true)
.Where(x => bookingNoList.Contains(x.Id) && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
if (bookingOrderList.Count > 0)
if (bookingSlotAllocList.Any(t => t.Alloc != null))
{
bookingOrderList.ForEach(bk =>
{
if (!string.IsNullOrWhiteSpace(bk.OPID))
userIds.Add(long.Parse(bk.OPID));
if (!string.IsNullOrWhiteSpace(bk.SALEID))
userIds.Add(long.Parse(bk.SALEID));
if (!string.IsNullOrWhiteSpace(bk.CUSTSERVICEID))
userIds.Add(long.Parse(bk.CUSTSERVICEID));
userIds.Add(bk.CreatedUserId.Value);
});
}
}
var slotInfo = bookingSlotAllocList.FirstOrDefault().Slot;
if (slotInfo != null)
{
userIds.Add(slotInfo.CreatedUserId.Value);
}
var bookingNoList = bookingSlotAllocList.Select(a => a.Alloc.BOOKING_ID).ToList();
userIds = userIds.Distinct().ToList();
bookingOrderList = _repBookingOrder.AsQueryable().Filter(null, true)
.Where(x => bookingNoList.Contains(x.Id) && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
userList = _sysUserRepository.AsQueryable().Filter(null, true)
.Where(x => userIds.Contains(x.Id) && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
string srcWeek = bcSrcDto.WeekAt ?? "";
string targetWeek = bcTargetDto.WeekAt ?? "";
//如果计费周不一致需要推送推送任务台生成重要提醒
if (!srcWeek.Equals(targetWeek, StringComparison.OrdinalIgnoreCase))
{
if (bookingSlotAllocList.Count > 0)
{
bookingSlotAllocList.ForEach(async ca =>
if (bookingOrderList.Count > 0)
{
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID);
var notice = new CautionNoticeTaskDto
bookingOrderList.ForEach(bk =>
{
cautionNoticeType = CautionNoticeTaskEnum.WeekAt,
bookingId = ca.Alloc.BOOKING_ID,
bookingSlotId = ca.Slot.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
mblNo = bcSrcDto.MBLNo,
notifyContent = $"mblno:{bcSrcDto.MBLNo} 计费周变更了 原:{srcWeek} 新:{targetWeek}",
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (!string.IsNullOrWhiteSpace(bk.OPID))
userIds.Add(long.Parse(bk.OPID));
if (bookingInfo != null)
{
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bk.SALEID))
userIds.Add(long.Parse(bk.SALEID));
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bk.CUSTSERVICEID))
userIds.Add(long.Parse(bk.CUSTSERVICEID));
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
});
}
else
{
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.WeekAt,
bookingSlotId = slotInfo.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
mblNo = bcSrcDto.MBLNo,
notifyContent = $"mblno:{bcSrcDto.MBLNo} 计费周变更了 原:{srcWeek} 新:{targetWeek}",
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (slotInfo != null)
{
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
userIds.Add(bk.CreatedUserId.Value);
});
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
}
}
string srcPriceCalcDate = bcSrcDto.PriceCalculationDate.HasValue ? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
string targePriceCalcDate = bcTargetDto.PriceCalculationDate.HasValue ? bcTargetDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
var slotInfo = bookingSlotAllocList.FirstOrDefault().Slot;
if (!srcPriceCalcDate.Equals(targePriceCalcDate, StringComparison.OrdinalIgnoreCase))
{
if (bookingSlotAllocList.Count > 0)
if (slotInfo != null)
{
bookingSlotAllocList.ForEach(async ca =>
{
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID);
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.PriceCalcDate,
bookingId = ca.Alloc.BOOKING_ID,
bookingSlotId = ca.Slot.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
mblNo = bcSrcDto.MBLNo,
notifyContent = $"mblno:{bcSrcDto.MBLNo} 计费日期变更了 原:{srcPriceCalcDate} 新:{targePriceCalcDate}",
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (bookingInfo != null)
{
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
});
userIds.Add(slotInfo.CreatedUserId.Value);
}
else
{
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.PriceCalcDate,
bookingSlotId = slotInfo.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (slotInfo != null)
{
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
}
userIds = userIds.Distinct().ToList();
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
}
}
string srcVessel = bcSrcDto.Vessel ?? "";
string targetVessel = bcTargetDto.Vessel ?? "";
userList = _sysUserRepository.AsQueryable().Filter(null, true)
.Where(x => userIds.Contains(x.Id) && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
string srcVoyno = bcSrcDto.VoyNo ?? "";
string targetVoyno = bcTargetDto.VoyNo ?? "";
string srcWeek = bcSrcDto.WeekAt ?? "";
string targetWeek = bcTargetDto.WeekAt ?? "";
//船名航次出现变化需要做重要提醒
if (!srcVessel.Equals(targetVessel, StringComparison.OrdinalIgnoreCase) || !srcVoyno.Equals(targetVoyno, StringComparison.OrdinalIgnoreCase))
{
if (bookingSlotAllocList.Count > 0)
if (!srcWeek.Equals(targetWeek, StringComparison.OrdinalIgnoreCase))
{
bookingSlotAllocList.ForEach(async ca =>
if (bookingSlotAllocList.Count > 0)
{
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID);
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.ChangeVesselVoyno,
bookingId = ca.Alloc.BOOKING_ID,
bookingSlotId = ca.Slot.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (bookingInfo != null)
bookingSlotAllocList.ForEach(async ca =>
{
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
});
}
else
{
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.ChangeVesselVoyno,
bookingSlotId = slotInfo.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (slotInfo != null)
{
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
}
}
string srcCarrierType = bcSrcDto.CarriageType ?? "";
string targetCarrierType = bcTargetDto.CarriageType ?? "";
//如果原来是直航现在变成了中转需要做重要提醒
if (!srcVessel.Equals(targetVessel, StringComparison.OrdinalIgnoreCase)
&& srcVessel.Equals("DIRECT_SHIP", StringComparison.OrdinalIgnoreCase)
&& targetCarrierType.Equals("TRANSFER_SHIP", StringComparison.OrdinalIgnoreCase))
{
if (bookingSlotAllocList.Count > 0)
{
bookingSlotAllocList.ForEach(async ca =>
{
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID);
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.ChangeTransfer,
bookingId = ca.Alloc.BOOKING_ID,
bookingSlotId = ca.Slot.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
notifyContent = $"mblno:{bcSrcDto.MBLNo} 直达变中转了",
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (bookingInfo != null)
{
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
});
}
else
{
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.ChangeTransfer,
bookingSlotId = slotInfo.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
notifyContent = $"mblno:{bcSrcDto.MBLNo} 直达变中转了",
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, bookingInfo, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} 计费周变更了 原:{srcWeek} 新:{targetWeek}");
});
}
if (slotInfo != null)
if (slotInfo != null && !userIds.Any(p => p == slotInfo.CreatedUserId.Value))
{
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, null, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} 计费周变更了 原:{srcWeek} 新:{targetWeek}");
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
}
}
string srcVGMCut = bcSrcDto.VGMSubmissionCutDate;
string targeVGMCut = bcTargetDto.VGMSubmissionCutDate;
string srcPriceDate = bcSrcDto.PriceCalculationDate.HasValue? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd"): "";
string targetPriceDate = bcTargetDto.PriceCalculationDate.HasValue ? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
if (!string.IsNullOrWhiteSpace(srcVGMCut) && !string.IsNullOrWhiteSpace(targeVGMCut) && !srcVGMCut.Equals(targeVGMCut))
{
DateTime srcVGMCutDate = DateTime.Parse(srcVGMCut);
DateTime targeVGMCutDate = DateTime.Parse(targeVGMCut);
//如果新给的VGM截止时间需要推送通知
if (srcVGMCutDate > targeVGMCutDate)
if (!srcPriceDate.Equals(targetPriceDate, StringComparison.OrdinalIgnoreCase))
{
if (bookingSlotAllocList.Count > 0)
{
bookingSlotAllocList.ForEach(async ca =>
{
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID);
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.CutDateAdvanced,
bookingId = ca.Alloc.BOOKING_ID,
bookingSlotId = ca.Slot.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
notifyContent = $"VGM截止时间提前了{srcVGMCut} 新:{targeVGMCut}",
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (bookingInfo != null)
{
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
{
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
}
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
&& x.TenantId == UserManager.TENANT_ID);
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, bookingInfo, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} 计费日期变更了 原:{srcPriceDate} 新:{targetPriceDate}");
});
}
else
{
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = CautionNoticeTaskEnum.ChangeVesselVoyno,
bookingSlotId = slotInfo.Id,
createTime = DateTime.Now,
origVal = srcWeek,
newVal = targetWeek,
tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId,
userName = UserManager.Name,
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (slotInfo != null)
{
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
if (slotInfo != null && !userIds.Any(p => p == slotInfo.CreatedUserId.Value))
{
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, null, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} 计费日期变更了 原:{srcPriceDate} 新:{targetPriceDate}");
}
}
}
}
catch (Exception ex)
{
_logger.LogInformation($"提单号:{bcSrcDto.MBLNo} slotId={slotId} 估算差异重要提醒发生异常");
new EmailNoticeHelper().SendEmailNotice($"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 估算差异重要提醒发生异常", $"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 估算差异重要提醒发生异常", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
}
}
#endregion
@ -3576,6 +3215,171 @@ namespace Myshipping.Application
}
}
#endregion
private async Task SendTask(CautionNoticeTaskDto dto)
{
TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo
{
Head = new TaskManageOrderMessageHeadInfo
{
GID = IDGen.NextID().ToString(),
MessageType = "CAUTION_TASK",
SenderId = "CautionNoticeTask",
SenderName = "重要提醒任务生成",
ReceiverId = "TaskManage",
ReceiverName = "任务台",
RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Version = "1.0",
RequestAction = "Add"
},
Main = new TaskManageOrderMessageMainInfo
{
TaskType = TaskBaseTypeEnum.CAUTION_NOTICE,
}
};
messageInfo.Main.TaskTenatId = dto.tenentId;
messageInfo.Main.TaskTenatName = dto.tenentName;
messageInfo.Main.VesselVoyno = $"{dto.vessel}/{dto.voyno}";
messageInfo.Main.TaskUserId = dto.userId.ToString();
messageInfo.Main.TaskUserName = dto.userName;
messageInfo.Main.CarrierId = dto.carrier;
messageInfo.Main.CustomerId = dto.customerId;
messageInfo.Main.CustomerName = dto.customerName;
messageInfo.Main.TaskTitle = $"重要提醒-{dto.cautionNoticeType.GetDescription()} {dto.vessel}/{dto.voyno} {dto.etd} BLNo:{dto.mblNo}";
messageInfo.Main.TaskDesp = $"重要提醒-{dto.cautionNoticeType.GetDescription()} {dto.vessel}/{dto.voyno} {dto.etd} BLNo:{dto.mblNo}";
messageInfo.Main.CautionNoticeInfo = new TaskManageOrderCautionNoticeInfo
{
BookingId = dto.bookingId,
BookingSlotId = dto.bookingSlotId,
CautionNoticeType = dto.cautionNoticeType,
Carrier = dto.carrier,
MBlNo = dto.mblNo,
OrigVal = dto.origVal,
NewVal = dto.newVal,
NotifyContent = dto.notifyContent,
SourceSystem = dto.sourceSystem,
SourceBusiType = dto.sourceBusiType,
SourceBusiTypeName = dto.sourceBusiTypeName,
CreateTime = DateTime.Now,
NoticeList = new List<TaskManageOrderCautionNoticeDetailInfo>()
};
if (dto.notifyList != null && dto.notifyList.Count > 0)
{
dto.notifyList.ForEach(p =>
{
foreach (var item in p.notifyMethod)
{
var notifyInfo = new TaskManageOrderCautionNoticeDetailInfo
{
CautionNoticeType = item,
Email = p.notifyEmail,
UserId = p.notifyUserId,
UserName = p.notifyUserName,
Mobile = p.notifyMobile,
};
messageInfo.Main.CautionNoticeInfo.NoticeList.Add(notifyInfo);
}
});
}
var service = _namedTaskManageServiceProvider.GetService(nameof(TaskManageService));
var rlt = await service.CreateTaskJob(messageInfo);
}
#region 生成重要提醒任务
/// <summary>
/// 生成重要提醒任务
/// </summary>
/// <param name="cautionNoticeType">重要提醒任务类型</param>
/// <param name="bcSrcDto">原数据详情</param>
/// <param name="userList">提取的用户详情列表</param>
/// <param name="bookingInfo">订舱详情</param>
/// <param name="bookingSlotInfo">舱位详情</param>
/// <param name="srcVal">原值</param>
/// <param name="targetVal">变更值</param>
/// <param name="notifyContent">提示信息</param>
private void CreateTask(CautionNoticeTaskEnum cautionNoticeType, TaskBCInfoDto bcSrcDto, List<SysUser> userList, BookingOrder bookingInfo,
BookingSlotBase bookingSlotInfo, string srcVal, string targetVal, string notifyContent)
{
List<long> userIdList = new List<long>();
if (bookingInfo != null)
{
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
{
userIdList.Add(long.Parse(bookingInfo.OPID));
}
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
{
userIdList.Add(long.Parse(bookingInfo.SALEID));
}
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
{
userIdList.Add(long.Parse(bookingInfo.CUSTSERVICEID));
}
userIdList.Add(bookingInfo.CreatedUserId.Value);
}
if (bookingSlotInfo != null)
{
userIdList.Add(bookingSlotInfo.CreatedUserId.Value);
}
userIdList = userIdList.Distinct().ToList();
userIdList.ForEach(x =>
{
var userInfo = userList.FirstOrDefault(p => p.Id == x);
var notice = new CautionNoticeTaskDto
{
cautionNoticeType = cautionNoticeType,
createTime = DateTime.Now,
origVal = srcVal,
newVal = targetVal,
tenentId = userInfo.TenantId.Value,
userId = userInfo.Id,
userName = userInfo.Name,
mblNo = bcSrcDto.MBLNo,
carrier = bcSrcDto.CarrierId,
sourceSystem = "DjyBooking",
sourceBusiType = "BookingSlot",
sourceBusiTypeName = "舱位管理",
vessel = bcSrcDto.Vessel,
voyno = bcSrcDto.VoyNo,
etd = bcSrcDto.ETD,
tenentName = UserManager.TENANT_NAME,
notifyContent = notifyContent,
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if (bookingInfo != null)
{
notice.bookingId = bookingInfo.Id;
notice.customerId = bookingInfo.CUSTOMERID;
notice.customerName = bookingInfo.CUSTOMERNAME;
}
if (bookingSlotInfo != null)
{
notice.bookingSlotId = bookingSlotInfo.Id;
}
CreateContact(notice.notifyList, userList, x, bcSrcDto.MBLNo, notice.cautionNoticeType);
SendTask(notice).GetAwaiter().GetResult();
});
}
#endregion
}

@ -119,20 +119,6 @@ namespace Myshipping.Application
Task<BookingSlotWithOrderDto> SearchBookingSlotWithOrderByNo(string slotBookingNo, long tenantId);
///// <summary>
///// 校验是否可以生成订舱订单
///// </summary>
///// <param name="id">舱位主键</param>
///// <returns>返回回执</returns>
//Task<TaskManageOrderResultDto> ValidateCreateBookingOrder(long id);
/// <summary>
/// 批量发送邮件提醒(发送客户)
/// </summary>
/// <param name="model">舱位批量发送邮件请求</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SendEmail(BookingSlotSendEmailDto model);
/// <summary>
/// 请求BC比对
/// </summary>

Loading…
Cancel
Save