|
|
|
@ -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>
|
|
|
|
|
/// 估算差异重要提醒
|
|
|
|
@ -3094,6 +3065,8 @@ namespace Myshipping.Application
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task MeasureDiffCautionTask(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
@ -3146,7 +3119,6 @@ namespace Myshipping.Application
|
|
|
|
|
string srcWeek = bcSrcDto.WeekAt ?? "";
|
|
|
|
|
string targetWeek = bcTargetDto.WeekAt ?? "";
|
|
|
|
|
|
|
|
|
|
//如果计费周不一致需要推送推送任务台生成重要提醒
|
|
|
|
|
if (!srcWeek.Equals(targetWeek, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (bookingSlotAllocList.Count > 0)
|
|
|
|
@ -3156,74 +3128,20 @@ namespace Myshipping.Application
|
|
|
|
|
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.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 (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));
|
|
|
|
|
|
|
|
|
|
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, bookingInfo, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} 计费周变更了 原:{srcWeek} 新:{targetWeek}");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
if (slotInfo != null && !userIds.Any(p => p == slotInfo.CreatedUserId.Value))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, null, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} 计费周变更了 原:{srcWeek} 新:{targetWeek}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string srcPriceCalcDate = bcSrcDto.PriceCalculationDate.HasValue ? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
|
|
|
|
|
string targePriceCalcDate = bcTargetDto.PriceCalculationDate.HasValue ? bcTargetDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
|
|
|
|
|
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 (!srcPriceCalcDate.Equals(targePriceCalcDate, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (!srcPriceDate.Equals(targetPriceDate, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (bookingSlotAllocList.Count > 0)
|
|
|
|
|
{
|
|
|
|
@ -3232,348 +3150,234 @@ namespace Myshipping.Application
|
|
|
|
|
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);
|
|
|
|
|
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, bookingInfo, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} 计费日期变更了 原:{srcPriceDate} 新:{targetPriceDate}");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
|
|
|
|
|
if (slotInfo != null && !userIds.Any(p => p == slotInfo.CreatedUserId.Value))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, null, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} 计费日期变更了 原:{srcPriceDate} 新:{targetPriceDate}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.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)
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
_logger.LogInformation($"提单号:{bcSrcDto.MBLNo} slotId={slotId} 估算差异重要提醒发生异常");
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 估算差异重要提醒发生异常", $"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 估算差异重要提醒发生异常", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
string srcVessel = bcSrcDto.Vessel ?? "";
|
|
|
|
|
string targetVessel = bcTargetDto.Vessel ?? "";
|
|
|
|
|
|
|
|
|
|
string srcVoyno = bcSrcDto.VoyNo ?? "";
|
|
|
|
|
string targetVoyno = bcTargetDto.VoyNo ?? "";
|
|
|
|
|
|
|
|
|
|
//船名航次出现变化需要做重要提醒
|
|
|
|
|
if (!srcVessel.Equals(targetVessel, StringComparison.OrdinalIgnoreCase) || !srcVoyno.Equals(targetVoyno, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (bookingSlotAllocList.Count > 0)
|
|
|
|
|
#region 生成联系人
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成联系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="notifyList">联系人列表</param>
|
|
|
|
|
/// <param name="userList">已检索用户详情列表</param>
|
|
|
|
|
/// <param name="contactId">联系用户ID</param>
|
|
|
|
|
/// <param name="mblNo">提单号</param>
|
|
|
|
|
/// <param name="cautionNoticeType">重要通知类型</param>
|
|
|
|
|
private void CreateContact(List<CautionNoticeTaskNoitfyDto> notifyList, List<SysUser> userList, long contactId, string mblNo, CautionNoticeTaskEnum cautionNoticeType)
|
|
|
|
|
{
|
|
|
|
|
bookingSlotAllocList.ForEach(async ca =>
|
|
|
|
|
if (!notifyList.Any(p => p.notifyUserId == contactId))
|
|
|
|
|
{
|
|
|
|
|
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
|
|
|
|
|
&& x.TenantId == UserManager.TENANT_ID);
|
|
|
|
|
var userInfo = userList.FirstOrDefault(x => x.Id == contactId);
|
|
|
|
|
|
|
|
|
|
var notice = new CautionNoticeTaskDto
|
|
|
|
|
if (userInfo != null)
|
|
|
|
|
{
|
|
|
|
|
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>()
|
|
|
|
|
var contact = new CautionNoticeTaskNoitfyDto
|
|
|
|
|
{
|
|
|
|
|
notifyUserId = userInfo.Id,
|
|
|
|
|
notifyUserName = userInfo.Name,
|
|
|
|
|
notifyMethod = new CautionNoticeMethodEnum[] { CautionNoticeMethodEnum.Email, CautionNoticeMethodEnum.DingDing },
|
|
|
|
|
notifyMobile = userInfo.Phone?.Trim(),
|
|
|
|
|
notifyEmail = userInfo.Email?.Trim(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (bookingInfo != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
|
|
|
|
|
if (string.IsNullOrWhiteSpace(userInfo.Phone))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
_logger.LogInformation($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有手机号");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有手机号", $"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有手机号", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
|
|
|
|
|
if (string.IsNullOrWhiteSpace(userInfo.Email))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
_logger.LogInformation($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有邮箱");
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有邮箱", $"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有邮箱", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
notifyList.Add(contact);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
private async Task SendTask(CautionNoticeTaskDto dto)
|
|
|
|
|
{
|
|
|
|
|
if (bookingSlotAllocList.Count > 0)
|
|
|
|
|
TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo
|
|
|
|
|
{
|
|
|
|
|
bookingSlotAllocList.ForEach(async ca =>
|
|
|
|
|
Head = new TaskManageOrderMessageHeadInfo
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
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>()
|
|
|
|
|
TaskType = TaskBaseTypeEnum.CAUTION_NOTICE,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (bookingInfo != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
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 (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
|
|
|
|
|
if (dto.notifyList != null && dto.notifyList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
|
|
|
|
|
dto.notifyList.ForEach(p =>
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
foreach (var item in p.notifyMethod)
|
|
|
|
|
{
|
|
|
|
|
var notice = new CautionNoticeTaskDto
|
|
|
|
|
var notifyInfo = new TaskManageOrderCautionNoticeDetailInfo
|
|
|
|
|
{
|
|
|
|
|
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>()
|
|
|
|
|
CautionNoticeType = item,
|
|
|
|
|
Email = p.notifyEmail,
|
|
|
|
|
UserId = p.notifyUserId,
|
|
|
|
|
UserName = p.notifyUserName,
|
|
|
|
|
Mobile = p.notifyMobile,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (slotInfo != null)
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
messageInfo.Main.CautionNoticeInfo.NoticeList.Add(notifyInfo);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var service = _namedTaskManageServiceProvider.GetService(nameof(TaskManageService));
|
|
|
|
|
var rlt = await service.CreateTaskJob(messageInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string srcVGMCut = bcSrcDto.VGMSubmissionCutDate;
|
|
|
|
|
string targeVGMCut = bcTargetDto.VGMSubmissionCutDate;
|
|
|
|
|
|
|
|
|
|
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 (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>()
|
|
|
|
|
};
|
|
|
|
|
#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))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
userIdList.Add(long.Parse(bookingInfo.OPID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
userIdList.Add(long.Parse(bookingInfo.SALEID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingInfo.CUSTSERVICEID))
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.CUSTSERVICEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
}
|
|
|
|
|
userIdList.Add(long.Parse(bookingInfo.CUSTSERVICEID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
userIdList.Add(bookingInfo.CreatedUserId.Value);
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
if (bookingSlotInfo != null)
|
|
|
|
|
{
|
|
|
|
|
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
userIdList.Add(bookingSlotInfo.CreatedUserId.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
userIdList = userIdList.Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
#region 生成联系人
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成联系人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="notifyList">联系人列表</param>
|
|
|
|
|
/// <param name="userList">已检索用户详情列表</param>
|
|
|
|
|
/// <param name="contactId">联系用户ID</param>
|
|
|
|
|
/// <param name="mblNo">提单号</param>
|
|
|
|
|
/// <param name="cautionNoticeType">重要通知类型</param>
|
|
|
|
|
private void CreateContact(List<CautionNoticeTaskNoitfyDto> notifyList, List<SysUser> userList, long contactId, string mblNo, CautionNoticeTaskEnum cautionNoticeType)
|
|
|
|
|
{
|
|
|
|
|
if (!notifyList.Any(p => p.notifyUserId == contactId))
|
|
|
|
|
userIdList.ForEach(x =>
|
|
|
|
|
{
|
|
|
|
|
var userInfo = userList.FirstOrDefault(x => x.Id == contactId);
|
|
|
|
|
var userInfo = userList.FirstOrDefault(p => p.Id == x);
|
|
|
|
|
|
|
|
|
|
if (userInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var contact = new CautionNoticeTaskNoitfyDto
|
|
|
|
|
var notice = new CautionNoticeTaskDto
|
|
|
|
|
{
|
|
|
|
|
notifyUserId = userInfo.Id,
|
|
|
|
|
notifyUserName = userInfo.Name,
|
|
|
|
|
notifyMethod = new CautionNoticeMethodEnum[] { CautionNoticeMethodEnum.Email, CautionNoticeMethodEnum.DingDing },
|
|
|
|
|
notifyMobile = userInfo.Phone?.Trim(),
|
|
|
|
|
notifyEmail = userInfo.Email?.Trim(),
|
|
|
|
|
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 (string.IsNullOrWhiteSpace(userInfo.Phone))
|
|
|
|
|
if (bookingInfo != null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有手机号");
|
|
|
|
|
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有手机号", $"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有手机号", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
notice.bookingId = bookingInfo.Id;
|
|
|
|
|
notice.customerId = bookingInfo.CUSTOMERID;
|
|
|
|
|
notice.customerName = bookingInfo.CUSTOMERNAME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(userInfo.Email))
|
|
|
|
|
if (bookingSlotInfo != null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有邮箱");
|
|
|
|
|
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有邮箱", $"MBLNO={mblNo} 比对舱位{cautionNoticeType.ToString()} 有变化,通知人{userInfo.Name}没有邮箱", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
notice.bookingSlotId = bookingSlotInfo.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notifyList.Add(contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CreateContact(notice.notifyList, userList, x, bcSrcDto.MBLNo, notice.cautionNoticeType);
|
|
|
|
|
|
|
|
|
|
SendTask(notice).GetAwaiter().GetResult();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|