|
|
|
@ -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("当前预甩原船信息获取失败");
|
|
|
|
|
|
|
|
|
|
//填写预甩详情到模板,并返回HTML
|
|
|
|
|
var toShipInfo = shipList.FirstOrDefault(p => p.PK_ID == model.toShipPKId);
|
|
|
|
|
|
|
|
|
|
if (fromShipInfo == null)
|
|
|
|
|
throw Oops.Bah("当前预甩换船信息获取失败");
|
|
|
|
|
|
|
|
|
|
BookingOrder bookingOrderEntity = null;
|
|
|
|
|
|
|
|
|
|
if (list.Any(p => p.BOOKING_ID.HasValue))
|
|
|
|
|
{
|
|
|
|
|
var bookingId = list.FirstOrDefault().BOOKING_ID.Value;
|
|
|
|
|
//读取订舱数据
|
|
|
|
|
var bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.First(a => a.Id == list.FirstOrDefault().BOOKING_ID.Value);
|
|
|
|
|
bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.First(a => a.Id == bookingId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|