zhangxiaofeng 6 months ago
commit 063981dec1

@ -69,6 +69,9 @@ namespace Myshipping.Application.Event
//生成任务
if (dto.cautionNoticeType == CautionNoticeTaskEnum.WeekAt)
{
}
TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo
{
Head = new TaskManageOrderMessageHeadInfo
@ -137,12 +140,13 @@ namespace Myshipping.Application.Event
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)
{

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

@ -58,6 +58,50 @@ namespace Myshipping.Application
/// </summary>
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>
<returns></returns>
</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">
<summary>
登录输入参数
@ -7319,6 +7335,16 @@
</summary>
<example>123456</example>
</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">
<summary>
用户登录输出参数

@ -467,4 +467,46 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
// 生成Token令牌
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 = "密码不能为空")]
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