|
|
|
@ -23,6 +23,7 @@ using NPOI.SS.Formula.Functions;
|
|
|
|
|
using System.Reflection.Metadata;
|
|
|
|
|
using Furion;
|
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -38,13 +39,27 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<TaskCautionNoticeInfo> _taskCautionNoticeInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskCautionNoticeDetailInfo> _taskCautionNoticeDetailInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<DjyUserMailAccount> _djyUserMailAccount;
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<TaskCautionNoticeWholeShipInfo> _taskCautionNoticeWholeShipInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskCautionNoticeWholeShipDetailInfo> _taskCautionNoticeWholeShipDetailInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotBase> _repBase;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotCtn> _repCtn;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotAllocation> _repAllocation;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotAllocationCtn> _repAllocationCtn;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _repBookingOrder;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _sysUserRepository;
|
|
|
|
|
|
|
|
|
|
public TaskCautionNoticeService(ISysCacheService cache, ILogger<TaskCautionNoticeService> logger,
|
|
|
|
|
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
|
|
|
|
|
SqlSugarRepository<TaskCautionNoticeInfo> taskCautionNoticeInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskCautionNoticeDetailInfo> taskCautionNoticeDetailInfoRepository,
|
|
|
|
|
SqlSugarRepository<DjyUserMailAccount> djyUserMailAccount)
|
|
|
|
|
SqlSugarRepository<TaskCautionNoticeWholeShipInfo> taskCautionNoticeWholeShipInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskCautionNoticeWholeShipDetailInfo> taskCautionNoticeWholeShipDetailInfoRepository,
|
|
|
|
|
SqlSugarRepository<DjyUserMailAccount> djyUserMailAccount,
|
|
|
|
|
SqlSugarRepository<BookingSlotBase> repBase,
|
|
|
|
|
SqlSugarRepository<BookingSlotCtn> repCtn, SqlSugarRepository<BookingSlotAllocation> repAllocation,
|
|
|
|
|
SqlSugarRepository<BookingSlotAllocationCtn> repAllocationCtn,
|
|
|
|
|
SqlSugarRepository<BookingOrder> repBookingOrder,
|
|
|
|
|
SqlSugarRepository<SysUser> sysUserRepository)
|
|
|
|
|
{
|
|
|
|
|
_cache = cache;
|
|
|
|
|
_logger = logger;
|
|
|
|
@ -53,7 +68,14 @@ namespace Myshipping.Application
|
|
|
|
|
_taskCautionNoticeInfoRepository = taskCautionNoticeInfoRepository;
|
|
|
|
|
_taskCautionNoticeDetailInfoRepository = taskCautionNoticeDetailInfoRepository;
|
|
|
|
|
_djyUserMailAccount = djyUserMailAccount;
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipInfoRepository = taskCautionNoticeWholeShipInfoRepository;
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository = taskCautionNoticeWholeShipDetailInfoRepository;
|
|
|
|
|
_repBase = repBase;
|
|
|
|
|
_repCtn = repCtn;
|
|
|
|
|
_repAllocation = repAllocation;
|
|
|
|
|
_repAllocationCtn = repAllocationCtn;
|
|
|
|
|
_repBookingOrder = repBookingOrder;
|
|
|
|
|
_sysUserRepository = sysUserRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 获取重要提醒任务详情
|
|
|
|
@ -270,5 +292,552 @@ namespace Myshipping.Application
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 生成重要提醒整船通知
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成重要提醒整船通知
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">请求详情</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> GenerateWholeShipCaucation(CautionNoticeTaskWholeShipDto model, BookingSlotBase slotBaseInfo)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto rlt = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
1、优先匹配是否已经有了整船的通知(船名、航次、SI截止时间、VGM截止时间、直达变中转、统计日期必须是当日的,注新值和旧值提交的都一致)
|
|
|
|
|
2、如果能匹配到,并且明细里有此单号,不做处理;没有单号记录需要写入单号,并且重新发起当票的邮件和钉钉通知
|
|
|
|
|
3、如果没有匹配到,重新获取整船的单号,生成明细记录。发起邮件和钉钉通知
|
|
|
|
|
*/
|
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
int statDay = int.Parse(nowDate.ToString("yyyyMMdd"));
|
|
|
|
|
|
|
|
|
|
var shipInfo = await _taskCautionNoticeWholeShipInfoRepository.AsQueryable().Filter(null, true).FirstAsync(a =>
|
|
|
|
|
a.VESSEL_OLD_VAL == model.VesselOldVal && a.VESSEL_NEW_VAL == model.VesselNewVal
|
|
|
|
|
&& a.VOYNO_OLD_VAL == model.VoynoOldVal && a.VOYNO_NEW_VAL == model.VoynoNewVal
|
|
|
|
|
&& a.SI_CUT_OLD_VAL == model.SICutOldVal && a.SI_CUT_NEW_VAL == model.SICutNewVal
|
|
|
|
|
&& a.VGM_CUT_OLD_VAL == model.VGMCutOldVal && a.VGM_CUT_NEW_VAL == model.VGMCutNewVal
|
|
|
|
|
&& a.DIRECT_TO_TRANS_OLD_VAL == model.DirectToTransOldVal && a.DIRECT_TO_TRANS_NEW_VAL == model.DirectToTransNewVal && a.STAT_DAY != null && a.STAT_DAY.Value == statDay);
|
|
|
|
|
|
|
|
|
|
var detailRecordList = new List<TaskCautionNoticeWholeShipDetailInfo>();
|
|
|
|
|
|
|
|
|
|
if (shipInfo == null)
|
|
|
|
|
{
|
|
|
|
|
TaskCautionNoticeWholeShipInfo shipEntity = new TaskCautionNoticeWholeShipInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
CARRIER = model.Carrier,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
VESSEL_OLD_VAL = model.VesselOldVal,
|
|
|
|
|
VESSEL_NEW_VAL = model.VesselNewVal,
|
|
|
|
|
VOYNO_OLD_VAL = model.VoynoOldVal,
|
|
|
|
|
VOYNO_NEW_VAL = model.VoynoNewVal,
|
|
|
|
|
VGM_CUT_OLD_VAL = model.VGMCutOldVal,
|
|
|
|
|
VGM_CUT_NEW_VAL = model.VGMCutNewVal,
|
|
|
|
|
SI_CUT_OLD_VAL = model.SICutOldVal,
|
|
|
|
|
SI_CUT_NEW_VAL = model.SICutNewVal,
|
|
|
|
|
DIRECT_TO_TRANS_OLD_VAL = model.DirectToTransOldVal,
|
|
|
|
|
DIRECT_TO_TRANS_NEW_VAL = model.DirectToTransNewVal,
|
|
|
|
|
IS_CUT_DATE_ADVANCED = !string.IsNullOrWhiteSpace(model.SICutNewVal),
|
|
|
|
|
IS_VESSEL_CHANGE = !string.IsNullOrWhiteSpace(model.VesselNewVal),
|
|
|
|
|
IS_TRANSFER = !string.IsNullOrWhiteSpace(model.DirectToTransNewVal),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
STAT_DAY = statDay,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _taskCautionNoticeWholeShipInfoRepository.InsertAsync(shipEntity);
|
|
|
|
|
|
|
|
|
|
//检索所有订舱记录
|
|
|
|
|
var bookingSlotAllocList = _repBase.AsQueryable().Filter(null, true)
|
|
|
|
|
.LeftJoin<BookingSlotAllocation>((slot, alloc) => slot.Id == alloc.BOOKING_SLOT_ID)
|
|
|
|
|
.Where((slot, alloc) => slot.VESSEL == model.VesselOldVal && slot.VOYNO == model.VoynoOldVal
|
|
|
|
|
&& slot.CARRIERID == model.Carrier
|
|
|
|
|
&& slot.IsDeleted == false && slot.TenantId == UserManager.TENANT_ID && (alloc == null || alloc.IsDeleted == false))
|
|
|
|
|
.Select((slot, alloc) => new { Slot = slot, Alloc = alloc }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BookingOrder> bookingOrderList = new List<BookingOrder>();
|
|
|
|
|
|
|
|
|
|
//先批量取一遍关联的订舱记录
|
|
|
|
|
if (bookingSlotAllocList.Any(t => t.Alloc != null))
|
|
|
|
|
{
|
|
|
|
|
var bookingNoList = bookingSlotAllocList.Where(a => a.Alloc != null)
|
|
|
|
|
.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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//生成完记录
|
|
|
|
|
bookingSlotAllocList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
//舱位分配表不为空表示有对应的订舱记录
|
|
|
|
|
if (t.Alloc != null)
|
|
|
|
|
{
|
|
|
|
|
var bookingOrder = bookingOrderList.FirstOrDefault(b => b.Id == t.Alloc.BOOKING_ID);
|
|
|
|
|
List<long> userIds = new List<long>();
|
|
|
|
|
List<SysUser> userList = new List<SysUser>();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.OPID))
|
|
|
|
|
userIds.Add(long.Parse(bookingOrder.OPID));
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.CUSTSERVICEID))
|
|
|
|
|
userIds.Add(long.Parse(bookingOrder.CUSTSERVICEID));
|
|
|
|
|
|
|
|
|
|
userIds.Add(bookingOrder.CreatedUserId.Value);
|
|
|
|
|
|
|
|
|
|
userIds = userIds.Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
userList = _sysUserRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => userIds.Contains(x.Id) && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
|
|
|
|
|
|
|
|
|
|
userList.ForEach(user =>
|
|
|
|
|
{
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var detailInfo = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipEntity.PK_ID,
|
|
|
|
|
BOOKING_ID = t.Alloc.BOOKING_ID,
|
|
|
|
|
BOOKING_SLOT_ID = t.Slot.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = bookingOrder.MBLNO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.Email.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detailInfo);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detailInfo);
|
|
|
|
|
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var detail2Info = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipEntity.PK_ID,
|
|
|
|
|
BOOKING_ID = t.Alloc.BOOKING_ID,
|
|
|
|
|
BOOKING_SLOT_ID = t.Slot.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = bookingOrder.MBLNO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.DingDing.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detail2Info);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detail2Info);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//表示只有舱位
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var createUserId = t.Slot.CreatedUserId.Value;
|
|
|
|
|
|
|
|
|
|
var user = _sysUserRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.First(x => x.Id == createUserId && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID);
|
|
|
|
|
|
|
|
|
|
var detailInfo = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipEntity.PK_ID,
|
|
|
|
|
BOOKING_SLOT_ID = t.Slot.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = t.Slot.SLOT_BOOKING_NO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.Email.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detailInfo);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detailInfo);
|
|
|
|
|
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var detail2Info = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipEntity.PK_ID,
|
|
|
|
|
BOOKING_SLOT_ID = t.Slot.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = t.Slot.SLOT_BOOKING_NO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.DingDing.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detail2Info);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detail2Info);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var detailList = _taskCautionNoticeWholeShipDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(a => a.P_ID == shipInfo.PK_ID).ToList();
|
|
|
|
|
|
|
|
|
|
var bookingSlotAllocList = _repBase.AsQueryable().Filter(null, true)
|
|
|
|
|
.LeftJoin<BookingSlotAllocation>((slot, alloc) => slot.Id == alloc.BOOKING_SLOT_ID)
|
|
|
|
|
.Where((slot, alloc) => slot.SLOT_BOOKING_NO == model.MBLNo
|
|
|
|
|
&& slot.CARRIERID == model.Carrier
|
|
|
|
|
&& slot.IsDeleted == false && slot.TenantId == UserManager.TENANT_ID && (alloc == null || alloc.IsDeleted == false))
|
|
|
|
|
.Select((slot, alloc) => new { Slot = slot, Alloc = alloc }).ToList();
|
|
|
|
|
|
|
|
|
|
if (bookingSlotAllocList.Any(t => t.Alloc != null))
|
|
|
|
|
{
|
|
|
|
|
var bookingNoList = bookingSlotAllocList.Where(a => a.Alloc != null)
|
|
|
|
|
.Select(a => a.Alloc.BOOKING_ID).ToList();
|
|
|
|
|
|
|
|
|
|
var lostList = bookingNoList.GroupJoin(detailList.Where(p => p.BOOKING_ID > 0).ToList(), l => l,
|
|
|
|
|
r => r.BOOKING_ID, (l, r) =>
|
|
|
|
|
{
|
|
|
|
|
var currList = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (currList.Count == 0)
|
|
|
|
|
return new { Succ = false, obj = l };
|
|
|
|
|
|
|
|
|
|
return new { Succ = true, obj = l };
|
|
|
|
|
}).Where(p => p.Succ == false).ToList();
|
|
|
|
|
|
|
|
|
|
if (lostList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var bookingOrderList = _repBookingOrder.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => bookingNoList.Contains(x.Id) && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"提单号:{model.MBLNo} 检索通知消息没有发送过,需要补发通知");
|
|
|
|
|
|
|
|
|
|
foreach (var md in lostList)
|
|
|
|
|
{
|
|
|
|
|
var bookingOrder = bookingOrderList.FirstOrDefault(p => p.Id == md.obj);
|
|
|
|
|
|
|
|
|
|
List<long> userIds = new List<long>();
|
|
|
|
|
List<SysUser> userList = new List<SysUser>();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.OPID))
|
|
|
|
|
userIds.Add(long.Parse(bookingOrder.OPID));
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.CUSTSERVICEID))
|
|
|
|
|
userIds.Add(long.Parse(bookingOrder.CUSTSERVICEID));
|
|
|
|
|
|
|
|
|
|
userIds.Add(bookingOrder.CreatedUserId.Value);
|
|
|
|
|
|
|
|
|
|
userIds = userIds.Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
userList = _sysUserRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => userIds.Contains(x.Id) && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
|
|
|
|
|
|
|
|
|
|
var slotInfo = bookingSlotAllocList
|
|
|
|
|
.FirstOrDefault(x => x.Alloc != null && x.Alloc.BOOKING_ID == bookingOrder.Id).Slot;
|
|
|
|
|
|
|
|
|
|
userList.ForEach(user =>
|
|
|
|
|
{
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var detailInfo = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipInfo.PK_ID,
|
|
|
|
|
BOOKING_ID = bookingOrder.Id,
|
|
|
|
|
BOOKING_SLOT_ID = slotInfo.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = bookingOrder.MBLNO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.Email.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detailInfo);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detailInfo);
|
|
|
|
|
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var detail2Info = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipInfo.PK_ID,
|
|
|
|
|
BOOKING_ID = bookingOrder.Id,
|
|
|
|
|
BOOKING_SLOT_ID = slotInfo.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = bookingOrder.MBLNO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.DingDing.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detail2Info);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detail2Info);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bookingSlotAllocList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
var slotInfo = detailList.FirstOrDefault(p => p.BOOKING_SLOT_ID == t.Slot.Id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (slotInfo == null)
|
|
|
|
|
{
|
|
|
|
|
//表示只有舱位
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var createUserId = t.Slot.CreatedUserId.Value;
|
|
|
|
|
|
|
|
|
|
var user = _sysUserRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.First(x => x.Id == createUserId && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID);
|
|
|
|
|
|
|
|
|
|
var detailInfo = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipInfo.PK_ID,
|
|
|
|
|
BOOKING_SLOT_ID = t.Slot.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = t.Slot.SLOT_BOOKING_NO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.Email.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detailInfo);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detailInfo);
|
|
|
|
|
|
|
|
|
|
//表示即有舱位也有订舱记录
|
|
|
|
|
var detail2Info = new TaskCautionNoticeWholeShipDetailInfo
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
P_ID = shipInfo.PK_ID,
|
|
|
|
|
BOOKING_SLOT_ID = t.Slot.Id,
|
|
|
|
|
BATCH_NO = batchNo,
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
MBL_NO = t.Slot.SLOT_BOOKING_NO,
|
|
|
|
|
STATUS = "TEMP",
|
|
|
|
|
STATUS_NAME = "暂存",
|
|
|
|
|
NOTIFY_METHOD = CautionNoticeMethodEnum.DingDing.ToString(),
|
|
|
|
|
NOTIFY_USER_ID = user.Id.ToString(),
|
|
|
|
|
NOTIFY_USER_NAME = user.Name,
|
|
|
|
|
NOTIFY_MOBILE = user.Phone?.Trim(),
|
|
|
|
|
NOTIFY_EMAIL = user.Email?.Trim(),
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
detailRecordList.Add(detail2Info);
|
|
|
|
|
|
|
|
|
|
_taskCautionNoticeWholeShipDetailInfoRepository.InsertAsync(detail2Info);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(detailRecordList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//推送邮件
|
|
|
|
|
await PushDingdingNotice(detailRecordList, shipInfo, slotBaseInfo);
|
|
|
|
|
|
|
|
|
|
//推送钉钉
|
|
|
|
|
await PushEmailNotice(detailRecordList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"slotid={model.SlotId} 推送重要提醒整船通知异常", $"slotid={model.SlotId} 推送重要提醒整船通知异常 原因:{ex.Message}", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rlt;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private async Task PushDingdingNotice(List<TaskCautionNoticeWholeShipDetailInfo> detailList, TaskCautionNoticeWholeShipInfo shipInfo, BookingSlotBase slotInfo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var tenantId = detailList.FirstOrDefault().TenantId;
|
|
|
|
|
|
|
|
|
|
StringBuilder contentBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
contentBuilder.AppendLine("起运港:"+ slotInfo.PLACERECEIPT);
|
|
|
|
|
contentBuilder.AppendLine("目的港:" + slotInfo.PLACEDELIVERY);
|
|
|
|
|
contentBuilder.AppendLine("船名/航次:" + $"{slotInfo.VESSEL}/{slotInfo.VOYNO}");
|
|
|
|
|
contentBuilder.AppendLine("ETD:" + (slotInfo.ETD.HasValue ? slotInfo.ETD.Value.ToString("yyyy-MM-dd") : ""));
|
|
|
|
|
contentBuilder.AppendLine("=================");
|
|
|
|
|
|
|
|
|
|
//截止时间提前
|
|
|
|
|
if (shipInfo.IS_CUT_DATE_ADVANCED)
|
|
|
|
|
{
|
|
|
|
|
if (shipInfo.VGM_CUT_OLD_VAL.Equals(shipInfo.VGM_CUT_NEW_VAL, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
contentBuilder.AppendLine("VGM截止时间提前");
|
|
|
|
|
contentBuilder.AppendLine("原:"+ shipInfo.VGM_CUT_OLD_VAL);
|
|
|
|
|
contentBuilder.AppendLine("新:" + shipInfo.VGM_CUT_OLD_VAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (shipInfo.SI_CUT_OLD_VAL.Equals(shipInfo.SI_CUT_NEW_VAL, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
contentBuilder.AppendLine("SI截止时间提前");
|
|
|
|
|
contentBuilder.AppendLine("原:" + shipInfo.VGM_CUT_OLD_VAL);
|
|
|
|
|
contentBuilder.AppendLine("新:" + shipInfo.VGM_CUT_OLD_VAL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//船名航次变更
|
|
|
|
|
if (shipInfo.IS_VESSEL_CHANGE)
|
|
|
|
|
{
|
|
|
|
|
if (shipInfo.VESSEL_OLD_VAL.Equals(shipInfo.VESSEL_NEW_VAL, StringComparison.OrdinalIgnoreCase) || shipInfo.VOYNO_OLD_VAL.Equals(shipInfo.VOYNO_NEW_VAL, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
contentBuilder.AppendLine("船名航次变更");
|
|
|
|
|
contentBuilder.AppendLine("原:" + $"{shipInfo.VESSEL_OLD_VAL}/{shipInfo.VOYNO_OLD_VAL}");
|
|
|
|
|
contentBuilder.AppendLine("新:" + $"{shipInfo.VESSEL_NEW_VAL}/{shipInfo.VOYNO_NEW_VAL}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//直达变中转
|
|
|
|
|
if (shipInfo.IS_TRANSFER)
|
|
|
|
|
{
|
|
|
|
|
contentBuilder.AppendLine("直达变中转");
|
|
|
|
|
contentBuilder.AppendLine("原:" + shipInfo.DIRECT_TO_TRANS_OLD_VAL);
|
|
|
|
|
contentBuilder.AppendLine("新:" + shipInfo.DIRECT_TO_TRANS_NEW_VAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contentBuilder.AppendLine("提单号 |对应操作 ");
|
|
|
|
|
|
|
|
|
|
detailList.GroupBy(a => a.MBL_NO).Select(p =>
|
|
|
|
|
{
|
|
|
|
|
return new { Key = p.Key, userList = p.ToList() };
|
|
|
|
|
|
|
|
|
|
}).ToList().ForEach(p =>
|
|
|
|
|
{
|
|
|
|
|
if (!p.userList.FirstOrDefault().BOOKING_ID.HasValue)
|
|
|
|
|
{
|
|
|
|
|
contentBuilder.AppendLine($"{p.Key.PadRight(20, ' ')}|未分配操作");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
contentBuilder.AppendLine($"{p.Key.PadRight(20, ' ')}|{(string.Join(",", p.userList.Select(x => x.NOTIFY_USER_NAME).ToArray()).PadRight(40, ' '))}");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mobileArg = detailList.Select(p => p.NOTIFY_MOBILE).Distinct().ToArray();
|
|
|
|
|
|
|
|
|
|
//_logger.LogInformation($"准备钉钉通知给 uid={a.NOTIFY_USER_NAME} name={a.NOTIFY_USER_NAME},内容:\r\n{noticeInfo.NOTIFY_CONTENT}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DingTalkGroupHelper.SendDingTalkGroupMessage($"{tenantId}_Notify", "重要通知提醒", $"{contentBuilder.ToString()}", false, mobileArg, null);
|
|
|
|
|
|
|
|
|
|
//_logger.LogInformation($"钉钉通知完毕给 uid={a.NOTIFY_USER_NAME} name={a.NOTIFY_USER_NAME},内容:\r\n{noticeInfo.NOTIFY_CONTENT}");
|
|
|
|
|
|
|
|
|
|
//a.STATUS = "SUCC";
|
|
|
|
|
//a.STATUS_NAME = "成功";
|
|
|
|
|
|
|
|
|
|
//_taskCautionNoticeDetailInfoRepository.AsUpdateable(a).UpdateColumns(p => new
|
|
|
|
|
//{
|
|
|
|
|
// p.STATUS,
|
|
|
|
|
// p.STATUS_NAME
|
|
|
|
|
//}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task PushEmailNotice(List<TaskCautionNoticeWholeShipDetailInfo> detailList)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|