zhangxiaofeng 6 months ago
commit 063981dec1

@ -69,79 +69,83 @@ namespace Myshipping.Application.Event
//生成任务 //生成任务
if (dto.cautionNoticeType == CautionNoticeTaskEnum.WeekAt) if (dto.cautionNoticeType == CautionNoticeTaskEnum.WeekAt)
{ {
TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo
}
TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo
{
Head = new TaskManageOrderMessageHeadInfo
{ {
Head = new TaskManageOrderMessageHeadInfo GID = IDGen.NextID().ToString(),
{ MessageType = "CAUTION_TASK",
GID = IDGen.NextID().ToString(), SenderId = "CautionNoticeTask",
MessageType = "CAUTION_TASK", SenderName = "重要提醒任务生成",
SenderId = "CautionNoticeTask", ReceiverId = "TaskManage",
SenderName = "重要提醒任务生成", ReceiverName = "任务台",
ReceiverId = "TaskManage", RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff"),
ReceiverName = "任务台", Version = "1.0",
RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff"), RequestAction = "Add"
Version = "1.0", },
RequestAction = "Add" Main = new TaskManageOrderMessageMainInfo
},
Main = new TaskManageOrderMessageMainInfo
{
TaskType = TaskBaseTypeEnum.CAUTION_NOTICE,
}
};
BookingSlotBase slotInfo = null;
BookingOrder bookingOrder = null;
string mblNo = string.Empty;
string vesselVoyno = string.Empty;
string etd = string.Empty;
if (dto.bookingSlotId > 0)
{ {
slotInfo = bookingSlotRepo.AsQueryable().Filter(null, true).First(x => x.Id == dto.bookingSlotId); TaskType = TaskBaseTypeEnum.CAUTION_NOTICE,
} }
};
if (dto.bookingId > 0) BookingSlotBase slotInfo = null;
{ BookingOrder bookingOrder = null;
bookingOrder = bookingRepo.AsQueryable().Filter(null, true).First(x => x.Id == dto.bookingId);
}
messageInfo.Main.TaskTenatId = slotInfo.TenantId; string mblNo = string.Empty;
messageInfo.Main.TaskTenatName = slotInfo.TenantName; string vesselVoyno = string.Empty;
string etd = string.Empty;
if (slotInfo != null) if (dto.bookingSlotId > 0)
{ {
if (slotInfo.CARRIERID.Equals("MSK", StringComparison.OrdinalIgnoreCase)) slotInfo = bookingSlotRepo.AsQueryable().Filter(null, true).First(x => x.Id == dto.bookingSlotId);
{ }
mblNo = slotInfo.SLOT_BOOKING_NO;
messageInfo.Main.MBlNo = slotInfo.SLOT_BOOKING_NO;
messageInfo.Main.ETD = slotInfo.ETD;
vesselVoyno = $"{(slotInfo.VESSEL ?? "")}/{slotInfo.VOYNO ?? ""}";
messageInfo.Main.VesselVoyno = vesselVoyno;
messageInfo.Main.TaskUserId = dto.userId.ToString();
messageInfo.Main.TaskUserName = dto.userName;
messageInfo.Main.CarrierId = slotInfo.CARRIERID;
}
}
if (bookingOrder != null) if (dto.bookingId > 0)
{ {
messageInfo.Main.CustomerId = bookingOrder.CUSTOMERID; bookingOrder = bookingRepo.AsQueryable().Filter(null, true).First(x => x.Id == dto.bookingId);
messageInfo.Main.CustomerName = bookingOrder.CUSTOMERNAME; }
}
messageInfo.Main.TaskTitle = $"重要提醒-计费周发生变更 {vesselVoyno} {etd} BLNo:{mblNo}"; messageInfo.Main.TaskTenatId = slotInfo.TenantId;
messageInfo.Main.TaskDesp = $"重要提醒-计费周发生变更 {vesselVoyno} {etd} BLNo:{mblNo}"; messageInfo.Main.TaskTenatName = slotInfo.TenantName;
messageInfo.Main.CautionNoticeInfo = new TaskManageOrderCautionNoticeInfo if (slotInfo != null)
{
if (slotInfo.CARRIERID.Equals("MSK", StringComparison.OrdinalIgnoreCase))
{ {
mblNo = slotInfo.SLOT_BOOKING_NO;
messageInfo.Main.MBlNo = slotInfo.SLOT_BOOKING_NO;
messageInfo.Main.ETD = slotInfo.ETD;
}; vesselVoyno = $"{(slotInfo.VESSEL ?? "")}/{slotInfo.VOYNO ?? ""}";
var rlt = await service.CreateTaskJob(messageInfo); messageInfo.Main.VesselVoyno = vesselVoyno;
messageInfo.Main.TaskUserId = dto.userId.ToString();
messageInfo.Main.TaskUserName = dto.userName;
messageInfo.Main.CarrierId = slotInfo.CARRIERID;
}
} }
if (bookingOrder != null)
{
messageInfo.Main.CustomerId = bookingOrder.CUSTOMERID;
messageInfo.Main.CustomerName = bookingOrder.CUSTOMERNAME;
}
messageInfo.Main.TaskTitle = $"重要提醒-计费周发生变更 {vesselVoyno} {etd} BLNo:{mblNo}";
messageInfo.Main.TaskDesp = $"重要提醒-计费周发生变更 {vesselVoyno} {etd} BLNo:{mblNo}";
messageInfo.Main.CautionNoticeInfo = new TaskManageOrderCautionNoticeInfo
{
BookingId = dto.bookingId,
BookingSlotId = dto.bookingSlotId,
CautionNoticeType = dto.cautionNoticeType,
};
var rlt = await service.CreateTaskJob(messageInfo);
} }
private CautionNoticeTaskDto GetInfo(object payload) private CautionNoticeTaskDto GetInfo(object payload)

@ -19,6 +19,7 @@ using Myshipping.Application.Service.BookingLabel.Dto;
using Myshipping.Application.Service.BookingOrder.Dto; using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Application.Service.BookingSlot.Dto; using Myshipping.Application.Service.BookingSlot.Dto;
using Myshipping.Core; using Myshipping.Core;
using Myshipping.Core.Entity;
using Myshipping.Core.Service; using Myshipping.Core.Service;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
using SqlSugar; using SqlSugar;
@ -30,6 +31,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -57,6 +59,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingLogDetail> _repBookingLogDetail; private readonly SqlSugarRepository<BookingLogDetail> _repBookingLogDetail;
private readonly SqlSugarRepository<BookingFile> _bookingfile; private readonly SqlSugarRepository<BookingFile> _bookingfile;
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate; private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate;
private readonly SqlSugarRepository<SysUser> _sysUserRepository;
private readonly ILogger<BookingSlotService> _logger; private readonly ILogger<BookingSlotService> _logger;
private readonly ISysCacheService _cache; private readonly ISysCacheService _cache;
@ -101,6 +104,7 @@ namespace Myshipping.Application
SqlSugarRepository<BookingOrder> repBookingOrder, SqlSugarRepository<BookingOrder> repBookingOrder,
SqlSugarRepository<BookingLabelAllocation> repLabelAllocation, SqlSugarRepository<BookingLabelAllocation> repLabelAllocation,
IBookingLabelService bookingLabelService, IBookingLabelService bookingLabelService,
SqlSugarRepository<SysUser> sysUserRepository,
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate) SqlSugarRepository<BookingPrintTemplate> repPrintTemplate)
{ {
_repBase = repBase; _repBase = repBase;
@ -126,6 +130,8 @@ namespace Myshipping.Application
_repLabelAllocation = repLabelAllocation; _repLabelAllocation = repLabelAllocation;
_bookingLabelService = bookingLabelService; _bookingLabelService = bookingLabelService;
_repPrintTemplate = repPrintTemplate; _repPrintTemplate = repPrintTemplate;
_sysUserRepository = sysUserRepository;
} }
#region 舱位 #region 舱位
@ -3060,8 +3066,51 @@ namespace Myshipping.Application
{ {
if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase)) if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
{ {
var bookingList = _repAllocation.AsQueryable().Filter(null, true) var bookingSlotAllocList = _repBase.AsQueryable().Filter(null, true)
.Where(x => x.BOOKING_SLOT_ID == slotId && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList(); .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>();
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)
{
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);
}
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();
string srcWeek = bcSrcDto.WeekAt ?? ""; string srcWeek = bcSrcDto.WeekAt ?? "";
string targetWeek = bcTargetDto.WeekAt ?? ""; string targetWeek = bcTargetDto.WeekAt ?? "";
@ -3069,40 +3118,74 @@ namespace Myshipping.Application
//如果计费周不一致需要推送推送任务台生成重要提醒 //如果计费周不一致需要推送推送任务台生成重要提醒
if (!srcWeek.Equals(targetWeek, StringComparison.OrdinalIgnoreCase)) if (!srcWeek.Equals(targetWeek, StringComparison.OrdinalIgnoreCase))
{ {
if (bookingList.Count > 0) if (bookingSlotAllocList.Count > 0)
{ {
bookingList.ForEach(async ca => bookingSlotAllocList.ForEach(async ca =>
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
new CautionNoticeTaskDto && 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))
{ {
cautionNoticeType = CautionNoticeTaskEnum.WeekAt, CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
bookingId = ca.BOOKING_ID, }
bookingSlotId = ca.BOOKING_SLOT_ID,
createTime = DateTime.Now, if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
origVal = srcWeek, {
newVal = targetWeek, CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
tenentId = UserManager.TENANT_ID, }
userId = UserManager.UserId,
userName = UserManager.Name, 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 else
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var notice = new CautionNoticeTaskDto
new CautionNoticeTaskDto {
{ cautionNoticeType = CautionNoticeTaskEnum.WeekAt,
cautionNoticeType = CautionNoticeTaskEnum.WeekAt, bookingSlotId = slotInfo.Id,
bookingSlotId = slotId, createTime = DateTime.Now,
createTime = DateTime.Now, origVal = srcWeek,
origVal = srcWeek, newVal = targetWeek,
newVal = targetWeek, tenentId = UserManager.TENANT_ID,
tenentId = UserManager.TENANT_ID, userId = UserManager.UserId,
userId = UserManager.UserId, userName = UserManager.Name,
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);
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
} }
} }
@ -3111,40 +3194,72 @@ namespace Myshipping.Application
if (!srcPriceCalcDate.Equals(targePriceCalcDate, StringComparison.OrdinalIgnoreCase)) if (!srcPriceCalcDate.Equals(targePriceCalcDate, StringComparison.OrdinalIgnoreCase))
{ {
if (bookingList.Count > 0) if (bookingSlotAllocList.Count > 0)
{ {
bookingList.ForEach(async ca => bookingSlotAllocList.ForEach(async ca =>
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
new CautionNoticeTaskDto && 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))
{ {
cautionNoticeType = CautionNoticeTaskEnum.PriceCalcDate, CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
bookingId = ca.BOOKING_ID, }
bookingSlotId = ca.BOOKING_SLOT_ID,
createTime = DateTime.Now, if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
origVal = srcWeek, {
newVal = targetWeek, CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
tenentId = UserManager.TENANT_ID, }
userId = UserManager.UserId,
userName = UserManager.Name, 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 else
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var notice = new CautionNoticeTaskDto
new CautionNoticeTaskDto {
{ cautionNoticeType = CautionNoticeTaskEnum.PriceCalcDate,
cautionNoticeType = CautionNoticeTaskEnum.PriceCalcDate, bookingSlotId = slotInfo.Id,
bookingSlotId = slotId, createTime = DateTime.Now,
createTime = DateTime.Now, origVal = srcWeek,
origVal = srcWeek, newVal = targetWeek,
newVal = targetWeek, tenentId = UserManager.TENANT_ID,
tenentId = UserManager.TENANT_ID, userId = UserManager.UserId,
userId = UserManager.UserId, userName = UserManager.Name,
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));
} }
} }
@ -3157,40 +3272,70 @@ namespace Myshipping.Application
//船名航次出现变化需要做重要提醒 //船名航次出现变化需要做重要提醒
if (!srcVessel.Equals(targetVessel, StringComparison.OrdinalIgnoreCase) || !srcVoyno.Equals(targetVoyno, StringComparison.OrdinalIgnoreCase)) if (!srcVessel.Equals(targetVessel, StringComparison.OrdinalIgnoreCase) || !srcVoyno.Equals(targetVoyno, StringComparison.OrdinalIgnoreCase))
{ {
if (bookingList.Count > 0) if (bookingSlotAllocList.Count > 0)
{ {
bookingList.ForEach(async ca => bookingSlotAllocList.ForEach(async ca =>
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
new CautionNoticeTaskDto && 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)
{
if (!string.IsNullOrWhiteSpace(bookingInfo.OPID))
{ {
cautionNoticeType = CautionNoticeTaskEnum.ChangeVesselVoyno, CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
bookingId = ca.BOOKING_ID, }
bookingSlotId = ca.BOOKING_SLOT_ID,
createTime = DateTime.Now, if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
origVal = $"{srcVessel}/{srcVoyno}", {
newVal = $"{targetVessel}/{targetVoyno}", CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
tenentId = UserManager.TENANT_ID, }
userId = UserManager.UserId,
userName = UserManager.Name, 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 else
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var notice = new CautionNoticeTaskDto
new CautionNoticeTaskDto {
{ cautionNoticeType = CautionNoticeTaskEnum.ChangeVesselVoyno,
cautionNoticeType = CautionNoticeTaskEnum.ChangeVesselVoyno, bookingSlotId = slotInfo.Id,
bookingSlotId = slotId, createTime = DateTime.Now,
createTime = DateTime.Now, origVal = srcWeek,
origVal = srcWeek, newVal = targetWeek,
newVal = targetWeek, tenentId = UserManager.TENANT_ID,
tenentId = UserManager.TENANT_ID, userId = UserManager.UserId,
userId = UserManager.UserId, userName = UserManager.Name,
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));
} }
} }
@ -3202,45 +3347,204 @@ namespace Myshipping.Application
&& srcVessel.Equals("DIRECT_SHIP", StringComparison.OrdinalIgnoreCase) && srcVessel.Equals("DIRECT_SHIP", StringComparison.OrdinalIgnoreCase)
&& targetCarrierType.Equals("TRANSFER_SHIP", StringComparison.OrdinalIgnoreCase)) && targetCarrierType.Equals("TRANSFER_SHIP", StringComparison.OrdinalIgnoreCase))
{ {
if (bookingList.Count > 0) if (bookingSlotAllocList.Count > 0)
{ {
bookingList.ForEach(async ca => bookingSlotAllocList.ForEach(async ca =>
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
new CautionNoticeTaskDto && 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))
{ {
cautionNoticeType = CautionNoticeTaskEnum.ChangeTransfer, CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.OPID), bcSrcDto.MBLNo, notice.cautionNoticeType);
bookingId = ca.BOOKING_ID, }
bookingSlotId = ca.BOOKING_SLOT_ID,
createTime = DateTime.Now, if (!string.IsNullOrWhiteSpace(bookingInfo.SALEID))
origVal = srcCarrierType, {
newVal = targetCarrierType, CreateContact(notice.notifyList, userList, long.Parse(bookingInfo.SALEID), bcSrcDto.MBLNo, notice.cautionNoticeType);
tenentId = UserManager.TENANT_ID, }
userId = UserManager.UserId,
userName = UserManager.Name, 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 else
{ {
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", var notice = new CautionNoticeTaskDto
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>()
};
if (slotInfo != null)
{
CreateContact(notice.notifyList, userList, slotInfo.CreatedUserId.Value, bcSrcDto.MBLNo, notice.cautionNoticeType);
}
await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add", notice));
}
}
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.ChangeTransfer, cautionNoticeType = CautionNoticeTaskEnum.CutDateAdvanced,
bookingSlotId = slotId, bookingId = ca.Alloc.BOOKING_ID,
bookingSlotId = ca.Slot.Id,
createTime = DateTime.Now, createTime = DateTime.Now,
origVal = srcCarrierType, origVal = srcWeek,
newVal = targetCarrierType, newVal = targetWeek,
tenentId = UserManager.TENANT_ID, tenentId = UserManager.TENANT_ID,
userId = UserManager.UserId, userId = UserManager.UserId,
userName = UserManager.Name, 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));
});
}
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));
}
} }
} }
} }
} }
#endregion #endregion
#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))
{
var userInfo = userList.FirstOrDefault(x => x.Id == contactId);
if (userInfo != null)
{
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 (string.IsNullOrWhiteSpace(userInfo.Phone))
{
_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());
}
if (string.IsNullOrWhiteSpace(userInfo.Email))
{
_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());
}
notifyList.Add(contact);
}
}
}
#endregion
} }

@ -58,6 +58,50 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public string userName { get; set; } public string userName { get; set; }
/// <summary>
/// 提单号
/// </summary>
public string mblNo { get; set; }
/// <summary>
/// 通知内容
/// </summary>
public string notifyContent { get; set; }
/// <summary>
/// 通知人列表
/// </summary>
public List<CautionNoticeTaskNoitfyDto> notifyList { get; set; }
}
/// <summary>
/// 通知人详情
/// </summary>
public class CautionNoticeTaskNoitfyDto
{
/// <summary>
/// 通知人ID
/// </summary>
public long notifyUserId { get; set; }
/// <summary>
/// 通知人名称
/// </summary>
public string notifyUserName { get; set; }
/// <summary>
/// 通知方式
/// </summary>
public CautionNoticeMethodEnum[] notifyMethod { get; set; }
/// <summary>
/// 通知人手机
/// </summary>
public string notifyMobile { get; set; }
/// <summary>
/// 通知人邮箱
/// </summary>
public string notifyEmail { get; set; }
} }
} }

@ -7296,6 +7296,22 @@
<param name="changeTo"></param> <param name="changeTo"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Core.Service.AuthService.GetAuthorizationKey(Myshipping.Core.Service.GetAuthorizationKeyInput)">
<summary>
获取跨站点登录授权key
</summary>
<param name="input"></param>
<remarks>默认用户名/密码admin/admin</remarks>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.AuthService.GetTokenByAuthorizationKey(Myshipping.Core.Service.GetTokenByAuthorizationKeyInput)">
<summary>
授权key换取token
</summary>
<param name="input"></param>
<remarks>默认用户名/密码admin/admin</remarks>
<returns></returns>
</member>
<member name="T:Myshipping.Core.Service.LoginInput"> <member name="T:Myshipping.Core.Service.LoginInput">
<summary> <summary>
登录输入参数 登录输入参数
@ -7319,6 +7335,16 @@
</summary> </summary>
<example>123456</example> <example>123456</example>
</member> </member>
<member name="P:Myshipping.Core.Service.GetAuthorizationKeyInput.UserId">
<summary>
用户Id
</summary>
</member>
<member name="T:Myshipping.Core.Service.GetTokenByAuthorizationKeyInput">
<summary>
根据授权key 换取token
</summary>
</member>
<member name="T:Myshipping.Core.Service.LoginOutput"> <member name="T:Myshipping.Core.Service.LoginOutput">
<summary> <summary>
用户登录输出参数 用户登录输出参数

@ -467,4 +467,46 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
// 生成Token令牌 // 生成Token令牌
return await GetLoginToken(user, tenant); return await GetLoginToken(user, tenant);
} }
/// <summary>
/// 获取跨站点登录授权key
/// </summary>
/// <param name="input"></param>
/// <remarks>默认用户名/密码admin/admin</remarks>
/// <returns></returns>
[HttpPost("/GetAuthorizationKey")]
[AllowAnonymous]
public async Task<string> GetAuthorizationKey([Required] GetAuthorizationKeyInput input)
{
//将key写入到redis 并指定五秒过期
string key = Guid.NewGuid().ToString();
await _cache.SetTimeoutAsync( key, input.UserId, TimeSpan.FromSeconds(5));
//将key返回
return key;
}
/// <summary>
/// 授权key换取token
/// </summary>
/// <param name="input"></param>
/// <remarks>默认用户名/密码admin/admin</remarks>
/// <returns></returns>
[HttpPost("/GetTokenByAuthorizationKey")]
[AllowAnonymous]
public async Task<string> GetTokenByAuthorizationKey([Required] GetTokenByAuthorizationKeyInput input)
{
//判断key有效性
if (!_cache.Exists(input.Key))
{
throw Oops.Bah("授权码无效");
}
//获取用户信息
var user = _sysUserRep.AsQueryable().Filter(null, true).First(u => u.DjyUserId == _cache.Get(input.Key));
//获取对应租户
var tenant = _sysTenantRep.Single(user.TenantId);
//颁发token
return await GetLoginToken(user, tenant);
}
} }

@ -28,3 +28,19 @@ public class LoginInput
[Required(ErrorMessage = "密码不能为空")] [Required(ErrorMessage = "密码不能为空")]
public string Password { get; set; } public string Password { get; set; }
} }
public class GetAuthorizationKeyInput
{
/// <summary>
/// 用户Id
/// </summary>
public string UserId { get; set; }
}
/// <summary>
/// 根据授权key 换取token
/// </summary>
public class GetTokenByAuthorizationKeyInput
{
public string Key { get; set; }
}
Loading…
Cancel
Save