修改预甩邮件,增加模板查看

master
jianghaiqing 6 months ago
parent 8fd88a9c96
commit dc7f3da21b

@ -166,5 +166,10 @@ namespace Myshipping.Application
/// </summary>
[Description("目的港未返空箱")]
POD_GATEOUT_FULL,
/// <summary>
/// 重要提醒
/// </summary>
[Description("重要提醒")]
CAUTION_NOTICE
}
}

@ -30,5 +30,15 @@ namespace Myshipping.Application
/// 手工发送预甩邮件接收人
/// </summary>
public string manualNoticeEmail { get; set; }
/// <summary>
/// 原船主键
/// </summary>
public string fromShipPKId { get; set; }
/// <summary>
/// 换船主键
/// </summary>
public string toShipPKId { get; set; }
}
}

@ -165,6 +165,11 @@ namespace Myshipping.Application
/// 分组KEY(有可能出现多个FROM多个TO的情况)
/// </summary>
public int GroupIndx { get; set; }
/// <summary>
/// 主键
/// </summary>
public string pkId { get; set; }
}

@ -885,6 +885,7 @@ namespace Myshipping.Application
.Map(dest => dest.BATCH_TRANSFER, src => src.BatchTransfer)
.Map(dest => dest.GROUP_INDX, src => src.GroupIndx);
config.ForType<TaskRollingNominationShipDetailDto, TaskRollingNominationDetailInfo>()
.Map(dest => dest.NOM_STATUS_NOTE, src => src.Status)
.Map(dest => dest.BOOKED_BY, src => src.Bookedby)
@ -923,7 +924,8 @@ namespace Myshipping.Application
.Map(dest => dest.VGMCutoffTime, src => src.VGM_CUTOFF_TIME)
.Map(dest => dest.CLPNCLCutDate, src => src.CLOSING_DATE)
.Map(dest => dest.BatchTransfer, src => src.BATCH_TRANSFER)
.Map(dest => dest.GroupIndx, src => src.GROUP_INDX);
.Map(dest => dest.GroupIndx, src => src.GROUP_INDX)
.Map(dest => dest.pkId, src => src.PK_ID);
config.ForType<TaskRollingNominationDetailInfo, TaskRollingNominationShipDetailShowDto>()

@ -1046,7 +1046,7 @@ namespace Myshipping.Application
throw Oops.Bah(BookingErrorCode.BOOK115);
}
if(string.IsNullOrWhiteSpace(printTemplate.CateCode) || !printTemplate.CateCode.Contains("rolling_nomination_notice_template"))
if (string.IsNullOrWhiteSpace(printTemplate.CateCode) || !printTemplate.CateCode.Contains("rolling_nomination_notice_template"))
{
throw Oops.Bah("模板类型分类错误,当前只支持预甩邮件通知");
}
@ -1056,21 +1056,45 @@ namespace Myshipping.Application
var list = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
.InnerJoin<TaskRollingNominationInfo>((detail, norm) => detail.NOM_ID == norm.PK_ID)
.Where((detail, norm) => norm.TASK_ID == model.taskId && detail.IsDeleted == false && norm.IsDeleted == false)
.Select((detail, dispatch) => detail).ToList();
.Select((detail, norm) => detail).ToList();
var shipList = _taskRollingNominationShipInfoRepository.AsQueryable().Filter(null, true).Where(p => (p.PK_ID.Equals(model.fromShipPKId) || p.PK_ID.Equals(model.toShipPKId))
&& p.IsDeleted == false).ToList();
var fromShipInfo = shipList.FirstOrDefault(p => p.PK_ID == model.fromShipPKId);
if (fromShipInfo == null)
throw Oops.Bah("当前预甩原船信息获取失败");
var toShipInfo = shipList.FirstOrDefault(p => p.PK_ID == model.toShipPKId);
if (fromShipInfo == null)
throw Oops.Bah("当前预甩换船信息获取失败");
BookingOrder bookingOrderEntity = null;
//填写预甩详情到模板并返回HTML
if (list.Any(p => p.BOOKING_ID.HasValue))
{
var bookingId = list.FirstOrDefault().BOOKING_ID.Value;
//读取订舱数据
bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == bookingId);
}
//读取订舱数据
var bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == list.FirstOrDefault().BOOKING_ID.Value);
if (bookingOrderEntity == null)
throw Oops.Bah("当前预甩没有对应的订舱信息,请先生成订舱订单才能转发邮件");
SysUser opUserInfo = null;
if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID) && Regex.IsMatch(bookingOrderEntity.OPID, "[0-9]+"))
{
opUserInfo = _sysUserRepository.AsQueryable().Filter(null, true).First(u => u.Id == long.Parse(bookingOrderEntity.OPID));
}
if (opUserInfo == null)
throw Oops.Bah("当前预甩对应的订舱信息未指定操作OP不能转发邮件");
html = GenerateTemplateHtml(printTemplate.FilePath, opUserInfo, UserManager.TENANT_NAME);
html = GenerateTemplateHtml(printTemplate.FilePath, fromShipInfo, toShipInfo, opUserInfo, UserManager.TENANT_NAME);
result.succ = true;
@ -1086,6 +1110,7 @@ namespace Myshipping.Application
}
#endregion
#region 获取换船选择列表
/// <summary>
/// 获取换船选择列表
/// </summary>
@ -1332,8 +1357,20 @@ namespace Myshipping.Application
return result;
}
#endregion
private string GenerateTemplateHtml(string filePath, SysUser opUserInfo, string tenantName)
#region 通过邮件模板生成预甩邮件通知内容
/// <summary>
/// 通过邮件模板生成预甩邮件通知内容
/// </summary>
/// <param name="filePath">文件路径</param>
/// <param name="fromShipInfo">原船详情</param>
/// <param name="toShipInfo">换船详情</param>
/// <param name="opUserInfo">操作OP详情</param>
/// <param name="tenantName">租户名称</param>
/// <returns>返回生成后邮件正文</returns>
private string GenerateTemplateHtml(string filePath, TaskRollingNominationShipInfo fromShipInfo, TaskRollingNominationShipInfo toShipInfo,
SysUser opUserInfo, string tenantName)
{
string result = string.Empty;
@ -1384,9 +1421,65 @@ namespace Myshipping.Application
{
baseHtml = baseHtml.Replace("#optel#", "");
}
//原船
if(fromShipInfo.ETD.HasValue && fromShipInfo.ETD.Value != DateTime.MinValue)
{
baseHtml = baseHtml.Replace("#ETD#", fromShipInfo.ETD.Value.ToString("yyyy-MM-dd"));
}
else
{
baseHtml = baseHtml.Replace("#ETD#", "");
}
//原船
if (!string.IsNullOrWhiteSpace(fromShipInfo.VESSEL) && !string.IsNullOrWhiteSpace(fromShipInfo.VOYNO))
{
baseHtml = baseHtml.Replace("#VesselVoyno#", $"{fromShipInfo.VESSEL} / {fromShipInfo.VOYNO}");
}
else
{
baseHtml = baseHtml.Replace("#VesselVoyno#", "");
}
//换船
if (toShipInfo.ETD.HasValue && toShipInfo.ETD.Value != DateTime.MinValue)
{
baseHtml = baseHtml.Replace("#newETD#", toShipInfo.ETD.Value.ToString("yyyy-MM-dd"));
}
else
{
baseHtml = baseHtml.Replace("#newETD#", "");
}
//换船
if (!string.IsNullOrWhiteSpace(toShipInfo.VESSEL) && !string.IsNullOrWhiteSpace(toShipInfo.VOYNO))
{
baseHtml = baseHtml.Replace("#newVesselVoyno#", $"{toShipInfo.VESSEL} / {toShipInfo.VOYNO}");
}
else
{
baseHtml = baseHtml.Replace("#newVesselVoyno#", "");
}
//换船
if (toShipInfo.SI_CUT_DATE.HasValue && toShipInfo.SI_CUT_DATE.Value != DateTime.MinValue)
{
baseHtml = baseHtml.Replace("#CutSingleTime#", toShipInfo.SI_CUT_DATE.Value.ToString("yyyy-MM-dd"));
}
else
{
baseHtml = baseHtml.Replace("#CutSingleTime#", "");
}
if (!string.IsNullOrWhiteSpace(tenantName))
{
baseHtml = baseHtml.Replace("#TenantCompanyName#", tenantName);
}
else
{
baseHtml = baseHtml.Replace("#TenantCompanyName#", "");
}
result = baseHtml;
return result;
}
#endregion
}
}

Loading…
Cancel
Save