1、修改重要通知

2、修改舱位保存,增加自动匹配标签功能
master
jianghaiqing 5 months ago
parent 8ef44b6f85
commit 57f7e21452

@ -105,5 +105,56 @@ namespace Myshipping.Application
/// 修改值
/// </summary>
public string NEW_VAL { get; set; }
/// <summary>
/// VGM截止时间原始值
/// </summary>
public string VGM_CUT_OLD_VAL { get; set; }
/// <summary>
/// VGM截止时间修改值
/// </summary>
public string VGM_CUT_NEW_VAL { get; set; }
/// <summary>
/// SI截止时间原始值
/// </summary>
public string SI_CUT_OLD_VAL { get; set; }
/// <summary>
/// SI截止时间修改值
/// </summary>
public string SI_CUT_NEW_VAL { get; set; }
/// <summary>
/// 直达变中转原值
/// </summary>
public string DIRECT_TO_TRANS_OLD_VAL { get; set; }
/// <summary>
/// 直达变中转修改值
/// </summary>
public string DIRECT_TO_TRANS_NEW_VAL { get; set; }
/// <summary>
/// 船名原始值
/// </summary>
public string VESSEL_OLD_VAL { get; set; }
/// <summary>
/// 船名修改值
/// </summary>
public string VESSEL_NEW_VAL { get; set; }
/// <summary>
/// 航次原始值
/// </summary>
public string VOYNO_OLD_VAL { get; set; }
/// <summary>
/// 航次修改值
/// </summary>
public string VOYNO_NEW_VAL { get; set; }
}
}

@ -1,12 +1,20 @@
using System;
using Myshipping.Application.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TaskCautionNoticeWholeShipDetailInfo
/// <summary>
/// 重要任务提醒整船通知单号明细
/// </summary>
[SugarTable("task_caution_notice_whole_ship_detail")]
[Description("重要任务提醒整船通知单号明细")]
public class TaskCautionNoticeWholeShipDetailInfo : TaskManageDbEntity
{
/// <summary>
/// 任务主键
@ -72,5 +80,10 @@ namespace Myshipping.Application
/// 重试次数
/// </summary>
public int RETRY_NUM { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string BATCH_NO { get; set; }
}
}

@ -1,5 +1,8 @@
using System;
using Myshipping.Application.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -9,7 +12,9 @@ namespace Myshipping.Application
/// <summary>
/// 重要任务提醒整船通知
/// </summary>
public class TaskCautionNoticeWholeShipInfo
[SugarTable("task_caution_notice_whole_ship")]
[Description("重要任务提醒整船通知")]
public class TaskCautionNoticeWholeShipInfo : TaskManageDbEntity
{
/// <summary>
/// 任务主键
@ -101,5 +106,10 @@ namespace Myshipping.Application
/// </summary>
public string OLD_VAL_MD5 { get; set; }
/// <summary>
/// 统计日期
/// </summary>
public Nullable<int> STAT_DAY { get; set; }
}
}

@ -149,7 +149,7 @@ namespace Myshipping.Application
[NonAction]
private async Task<List<BookingLabelBaseDto>> Cache()
{
var list = await _rep.AsQueryable().ToListAsync();
var list = await _rep.AsQueryable().Filter(null,true).Where(a=>a.TenantId == UserManager.TENANT_ID).ToListAsync();
var cacheList = list.Adapt<List<BookingLabelBaseDto>>();
await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_BOOKING_LABEL + ":" + UserManager.TENANT_ID, cacheList, TimeSpan.FromDays(3));

@ -29,6 +29,8 @@ namespace Myshipping.Application
equal,
like,
startwith,
notexists
notexists,
notequal,
notstartwith
}
}

@ -19,6 +19,7 @@ using Myshipping.Application.Helper;
using Myshipping.Application.Service.BookingLabel.Dto;
using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Application.Service.BookingSlot.Dto;
using Myshipping.Application.Service.TaskManagePlat.Interface;
using Myshipping.Core;
using Myshipping.Core.Const;
using Myshipping.Core.Entity;
@ -75,6 +76,7 @@ namespace Myshipping.Application
private readonly INamedServiceProvider<IBookingOrderService> _namedBookingOrderServiceProvider;
private readonly INamedServiceProvider<ITaskManageService> _namedTaskManageServiceProvider;
private readonly INamedServiceProvider<IBookingLabelService> _namedBookingLabelServiceProvider;
private readonly INamedServiceProvider<ITaskCautionNoticeService> _namedTaskCautionNoticeServiceProvider;
private readonly IDjyCustomerService _djyCustomerService;
private readonly IBookingValueAddedService _bookingValueAddedService;
@ -120,6 +122,7 @@ namespace Myshipping.Application
SqlSugarRepository<BookingLabelAllocation> repLabelAllocation,
IBookingLabelService bookingLabelService,
INamedServiceProvider<ITaskManageService> namedTaskManageServiceProvider,
INamedServiceProvider<ITaskCautionNoticeService> namedTaskCautionNoticeServiceProvider,
SqlSugarRepository<SysUser> sysUserRepository,
IDjyTenantParamService djyTenantParamService,
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate,
@ -155,6 +158,7 @@ namespace Myshipping.Application
_djyTenantParamService = djyTenantParamService;
_sysDataUserMenuService = sysDataUserMenuService;
_namedBookingLabelServiceProvider = namedBookingLabelServiceProvider;
_namedTaskCautionNoticeServiceProvider = namedTaskCautionNoticeServiceProvider;
}
#region 舱位
@ -361,6 +365,22 @@ namespace Myshipping.Application
TenantId = model.TenantId
}));
var inputDto = new BookingSlotBaseApiDto {
DataObj = new BookingSlotBaseApiSaveDto {
PORTDISCHARGEID = model.PORTDISCHARGEID,
PORTDISCHARGE = model.PORTDISCHARGE,
PORTLOADID = model.PORTLOADID,
PORTLOAD = model.PORTLOAD,
PLACEDELIVERY = model.PLACEDELIVERY,
PLACEDELIVERYID = model.PLACEDELIVERYID,
PLACERECEIPT = model.PLACERECEIPT,
PLACERECEIPTID = model.PLACERECEIPTID,
}
};
//这里自动匹配标签
await GenerateSlotLabel(inputDto, model.Id);
return await Detail(model.Id);
}
@ -3592,18 +3612,21 @@ namespace Myshipping.Application
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID);
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, bookingInfo, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} \r\n计费周变更了 \r\n原{srcWeek} \r\n新{targetWeek}");
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, bookingInfo, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} \r\n计费周变更了 \r\n原{srcWeek} \r\n新{targetWeek}",true);
});
}
else if (slotInfo != null)
{
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, null, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} \r\n计费周变更了 \r\n原{srcWeek} \r\n新{targetWeek}");
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, null, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} \r\n计费周变更了 \r\n原{srcWeek} \r\n新{targetWeek}", true);
}
}
else
{
if (string.IsNullOrWhiteSpace(targetWeek))
{
new EmailNoticeHelper().SendEmailNotice($"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 没有提取到计费周", $"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 没有提取到计费周", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
}
}
string srcPriceDate = bcSrcDto.PriceCalculationDate.HasValue ? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
string targetPriceDate = bcTargetDto.PriceCalculationDate.HasValue ? bcTargetDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
@ -3618,38 +3641,39 @@ namespace Myshipping.Application
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID);
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, bookingInfo, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} \r\n计费日期变更了 \r\n原{srcPriceDate} \r\n新{targetPriceDate}");
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, bookingInfo, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} \r\n计费日期变更了 \r\n原{srcPriceDate} \r\n新{targetPriceDate}", true);
});
}
else if (slotInfo != null)
{
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, null, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} \r\n计费日期变更了 \r\n原{srcPriceDate} \r\n新{targetPriceDate}");
CreateTask(CautionNoticeTaskEnum.PriceCalcDate, bcSrcDto, userList, null, slotInfo, srcPriceDate, targetPriceDate, $"提单号:{bcSrcDto.MBLNo} \r\n计费日期变更了 \r\n原{srcPriceDate} \r\n新{targetPriceDate}", true);
}
}
else
{
if (string.IsNullOrWhiteSpace(targetPriceDate))
{
new EmailNoticeHelper().SendEmailNotice($"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 没有提取到计费日期", $"MBLNO={bcSrcDto.MBLNo} slotId={slotId} 没有提取到计费日期", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
}
}
bool isNeedWholeShip = false;
CautionNoticeTaskWholeShipDto cautionNoticeTaskWholeShipDto = new CautionNoticeTaskWholeShipDto {
Carrier = slotInfo.CARRIERID
};
string srcVesselVoyno = $"{bcSrcDto.Vessel}/{bcSrcDto.VoyNo}";
string targetVesselVoyno = $"{bcTargetDto.Vessel}/{bcTargetDto.VoyNo}";
if (!srcVesselVoyno.Equals(targetVesselVoyno, StringComparison.OrdinalIgnoreCase))
{
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);
cautionNoticeTaskWholeShipDto.VesselOldVal = bcSrcDto.Vessel;
cautionNoticeTaskWholeShipDto.VesselNewVal = bcTargetDto.Vessel;
cautionNoticeTaskWholeShipDto.VoynoOldVal = bcSrcDto.VoyNo;
cautionNoticeTaskWholeShipDto.VoynoNewVal = bcTargetDto.VoyNo;
CreateTask(CautionNoticeTaskEnum.ChangeVesselVoyno, bcSrcDto, userList, bookingInfo, slotInfo, srcVesselVoyno, targetVesselVoyno, $"提单号:{bcSrcDto.MBLNo} \r\n船名航次变更了 \r\n原{srcVesselVoyno} \r\n新{targetVesselVoyno}");
});
}
else if (slotInfo != null)
{
CreateTask(CautionNoticeTaskEnum.ChangeVesselVoyno, bcSrcDto, userList, null, slotInfo, srcVesselVoyno, targetVesselVoyno, $"提单号:{bcSrcDto.MBLNo} \r\n船名航次变更了 \r\n原{srcVesselVoyno} \r\n新{targetVesselVoyno}");
}
isNeedWholeShip = true;
}
@ -3661,20 +3685,10 @@ namespace Myshipping.Application
&& srcCarrierType.Equals("DIRECT_SHIP", StringComparison.OrdinalIgnoreCase)
&& targetCarrierType.Equals("TRANSFER_SHIP", StringComparison.OrdinalIgnoreCase))
{
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);
cautionNoticeTaskWholeShipDto.DirectToTransOldVal = "直达";
cautionNoticeTaskWholeShipDto.DirectToTransNewVal = "中转";
CreateTask(CautionNoticeTaskEnum.ChangeTransfer, bcSrcDto, userList, bookingInfo, slotInfo, "直达", "中转", $"提单号:{bcSrcDto.MBLNo} \r\n直达变成中转了");
});
}
else if (slotInfo != null)
{
CreateTask(CautionNoticeTaskEnum.ChangeTransfer, bcSrcDto, userList, null, slotInfo, "直达", "中转", $"提单号:{bcSrcDto.MBLNo} \r\n直达变成中转了");
}
isNeedWholeShip = true;
}
string srcVGMCut = bcSrcDto.VGMSubmissionCutDate;
@ -3687,20 +3701,10 @@ namespace Myshipping.Application
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);
cautionNoticeTaskWholeShipDto.VGMCutOldVal = srcVGMCutDate.ToString("yyyy-MM-dd HH:mm");
cautionNoticeTaskWholeShipDto.VGMCutNewVal = targeVGMCutDate.ToString("yyyy-MM-dd HH:mm");
CreateTask(CautionNoticeTaskEnum.VGMCutDateAdvanced, bcSrcDto, userList, bookingInfo, slotInfo, srcVGMCut, targeVGMCut, $"提单号:{bcSrcDto.MBLNo} \r\nVGM截单时间提前了 \r\n原{srcVGMCut} \r\n新{targeVGMCut}");
});
}
else if (slotInfo != null)
{
CreateTask(CautionNoticeTaskEnum.VGMCutDateAdvanced, bcSrcDto, userList, null, slotInfo, srcVGMCut, targeVGMCut, $"提单号:{bcSrcDto.MBLNo} \r\nVGM截单时间提前了 \r\n原{srcVGMCut} \r\n新{targeVGMCut}");
}
isNeedWholeShip = true;
}
}
@ -3715,21 +3719,23 @@ namespace Myshipping.Application
//如果新给的SI截止时间需要推送通知
if (srcSICutDate > targeSICutDate)
{
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);
cautionNoticeTaskWholeShipDto.SICutOldVal = srcSICutDate.ToString("yyyy-MM-dd HH:mm");
cautionNoticeTaskWholeShipDto.SICutNewVal = targeSICutDate.ToString("yyyy-MM-dd HH:mm");
CreateTask(CautionNoticeTaskEnum.SICutDateAdvanced, bcSrcDto, userList, bookingInfo, slotInfo, srcSICut, targeSICut, $"提单号:{bcSrcDto.MBLNo} \r\n样单截止时间提前了 \r\n原{srcSICut} \r\n新:{targeSICut}");
});
}
else if (slotInfo != null)
{
CreateTask(CautionNoticeTaskEnum.SICutDateAdvanced, bcSrcDto, userList, null, slotInfo, srcSICut, targeSICut, $"提单号:{bcSrcDto.MBLNo} \r\n样单截止时间提前了 \r\n原{srcSICut} \r\n新:{targeSICut}");
isNeedWholeShip = true;
}
}
//这里如果需要做整船提醒,需要单独走重要通知通道
if (isNeedWholeShip)
{
//触发推送消息
var name = _namedTaskCautionNoticeServiceProvider
.GetService<ITransient>(nameof(TaskCautionNoticeService));
var wholeShipRlt = await name.GenerateWholeShipCaucation(cautionNoticeTaskWholeShipDto, slotInfo);
_logger.LogInformation($"触发整船提醒完成,结果={JSON.Serialize(wholeShipRlt)}");
}
}
}
@ -3838,6 +3844,7 @@ namespace Myshipping.Application
SourceBusiType = dto.sourceBusiType,
SourceBusiTypeName = dto.sourceBusiTypeName,
CreateTime = DateTime.Now,
IsAutoSendNotice = dto.isAutoSendNotice,
NoticeList = new List<TaskManageOrderCautionNoticeDetailInfo>()
};
@ -3878,7 +3885,7 @@ namespace Myshipping.Application
/// <param name="targetVal">变更值</param>
/// <param name="notifyContent">提示信息</param>
private void CreateTask(CautionNoticeTaskEnum cautionNoticeType, TaskBCInfoDto bcSrcDto, List<SysUser> userList, BookingOrder bookingInfo,
BookingSlotBase bookingSlotInfo, string srcVal, string targetVal, string notifyContent)
BookingSlotBase bookingSlotInfo, string srcVal, string targetVal, string notifyContent,bool isAutoSendNotice)
{
List<long> userIdList = new List<long>();
@ -3932,6 +3939,7 @@ namespace Myshipping.Application
vessel = bcSrcDto.Vessel,
voyno = bcSrcDto.VoyNo,
tenentName = UserManager.TENANT_NAME,
isAutoSendNotice = isAutoSendNotice,
notifyContent = notifyContent,
notifyList = new List<CautionNoticeTaskNoitfyDto>()
@ -4293,7 +4301,7 @@ namespace Myshipping.Application
{
if(operEnum == LabelRegexOperEnum.equal)
{
if (dto.DataObj.PORTLOADID.Equals(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOADID) && dto.DataObj.PORTLOADID.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
@ -4303,7 +4311,7 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.startwith)
{
if (dto.DataObj.PORTLOADID.StartsWith(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOADID) && dto.DataObj.PORTLOADID.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4312,7 +4320,7 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.like)
{
if (dto.DataObj.PORTLOADID.Contains(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOADID) && dto.DataObj.PORTLOADID.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4321,7 +4329,25 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.notexists)
{
if (!dto.DataObj.PORTLOADID.Equals(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOADID) && !dto.DataObj.PORTLOADID.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notequal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOADID) && !dto.DataObj.PORTLOADID.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notstartwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOADID) && !dto.DataObj.PORTLOADID.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4333,7 +4359,7 @@ namespace Myshipping.Application
{
if (operEnum == LabelRegexOperEnum.equal)
{
if (dto.DataObj.PLACERECEIPT.Equals(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT) && dto.DataObj.PLACERECEIPT.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4342,7 +4368,7 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.startwith)
{
if (dto.DataObj.PLACERECEIPT.StartsWith(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT) && dto.DataObj.PLACERECEIPT.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4351,7 +4377,7 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.like)
{
if (dto.DataObj.PLACERECEIPT.Contains(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT) && dto.DataObj.PLACERECEIPT.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4360,7 +4386,25 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.notexists)
{
if (!dto.DataObj.PLACERECEIPT.Equals(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT) && !dto.DataObj.PLACERECEIPT.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notequal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT) && !dto.DataObj.PLACERECEIPT.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notstartwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT) && !dto.DataObj.PLACERECEIPT.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4372,7 +4416,64 @@ namespace Myshipping.Application
{
if (operEnum == LabelRegexOperEnum.equal)
{
if (dto.DataObj.PORTLOAD.Equals(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOAD) && dto.DataObj.PORTLOAD.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.startwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOAD) && dto.DataObj.PORTLOAD.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.like)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOAD) && dto.DataObj.PORTLOAD.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notequal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOAD) && !dto.DataObj.PORTLOAD.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notexists)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOAD) && !dto.DataObj.PORTLOAD.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notstartwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTLOAD) && !dto.DataObj.PORTLOAD.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
}
else if (regList[j].name.Equals("PORTDISCHARGEID", StringComparison.OrdinalIgnoreCase))
{
if (operEnum == LabelRegexOperEnum.equal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGEID) && dto.DataObj.PORTDISCHARGEID.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4381,7 +4482,7 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.startwith)
{
if (dto.DataObj.PORTLOAD.StartsWith(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGEID) && dto.DataObj.PORTDISCHARGEID.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4390,7 +4491,16 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.like)
{
if (dto.DataObj.PORTLOAD.Contains(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGEID) && dto.DataObj.PORTDISCHARGEID.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notequal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGEID) && !dto.DataObj.PORTDISCHARGEID.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
@ -4399,7 +4509,130 @@ namespace Myshipping.Application
}
else if (operEnum == LabelRegexOperEnum.notexists)
{
if (!dto.DataObj.PORTLOAD.Equals(regList[j].val))
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGEID) && !dto.DataObj.PORTDISCHARGEID.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notstartwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGEID) && !dto.DataObj.PORTDISCHARGEID.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
}
else if (regList[j].name.Equals("PORTDISCHARGE", StringComparison.OrdinalIgnoreCase))
{
if (operEnum == LabelRegexOperEnum.equal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGE) && dto.DataObj.PORTDISCHARGE.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.startwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGE) && dto.DataObj.PORTDISCHARGE.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.like)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGE) && dto.DataObj.PORTDISCHARGE.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notequal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGE) && !dto.DataObj.PORTDISCHARGE.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notexists)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGE) && !dto.DataObj.PORTDISCHARGE.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notstartwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PORTDISCHARGE) && !dto.DataObj.PORTDISCHARGE.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
}
else if (regList[j].name.Equals("PLACEDELIVERY", StringComparison.OrdinalIgnoreCase))
{
if (operEnum == LabelRegexOperEnum.equal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY) && dto.DataObj.PLACEDELIVERY.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.startwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY) && dto.DataObj.PLACEDELIVERY.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.like)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY) && dto.DataObj.PLACEDELIVERY.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notequal)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY) && !dto.DataObj.PLACEDELIVERY.Equals(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notexists)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY) && !dto.DataObj.PLACEDELIVERY.Contains(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;
break;
}
}
else if (operEnum == LabelRegexOperEnum.notstartwith)
{
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY) && !dto.DataObj.PLACEDELIVERY.StartsWith(regList[j].val))
{
ruleList.Add(labelList[i]);
isSucc = true;

@ -122,6 +122,11 @@ namespace Myshipping.Application
/// 通知人列表
/// </summary>
public List<CautionNoticeTaskNoitfyDto> notifyList { get; set; }
/// <summary>
/// 是否自动转发通知
/// </summary>
public bool isAutoSendNotice { get; set; }
}
/// <summary>

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 重要通知整船提醒
/// </summary>
public class CautionNoticeTaskWholeShipDto
{
/// <summary>
/// 船公司
/// </summary>
public string Carrier { get; set; }
/// <summary>
/// VGM截止时间原始值
/// </summary>
public string VGMCutOldVal { get; set; }
/// <summary>
/// VGM截止时间修改值
/// </summary>
public string VGMCutNewVal { get; set; }
/// <summary>
/// SI截止时间原始值
/// </summary>
public string SICutOldVal { get; set; }
/// <summary>
/// SI截止时间修改值
/// </summary>
public string SICutNewVal { get; set; }
/// <summary>
/// 直达变中转原值
/// </summary>
public string DirectToTransOldVal { get; set; }
/// <summary>
/// 直达变中转修改值
/// </summary>
public string DirectToTransNewVal { get; set; }
/// <summary>
/// 直达变中转原值
/// </summary>
public string VesselOldVal { get; set; }
/// <summary>
/// 直达变中转修改值
/// </summary>
public string VesselNewVal { get; set; }
/// <summary>
/// 直达变中转原值
/// </summary>
public string VoynoOldVal { get; set; }
/// <summary>
/// 直达变中转修改值
/// </summary>
public string VoynoNewVal { get; set; }
/// <summary>
/// 统计日期
/// </summary>
public string StatDay { get; set; }
/// <summary>
/// 原始值MD5
/// </summary>
public string OldMD5 { get; set; }
/// <summary>
/// 主单号
/// </summary>
public string MBLNo { get; set; }
/// <summary>
/// 舱位ID
/// </summary>
public long SlotId { get; set; }
}
}

@ -76,6 +76,62 @@ namespace Myshipping.Application
/// </summary>
public string NotifyContent { get; set; }
/// <summary>
/// VGM截止时间原始值
/// </summary>
public string VGMCutOldVal { get; set; }
/// <summary>
/// VGM截止时间修改值
/// </summary>
public string VGMCutNewVal { get; set; }
/// <summary>
/// SI截止时间原始值
/// </summary>
public string SICutOldVal { get; set; }
/// <summary>
/// SI截止时间修改值
/// </summary>
public string SICutNewVal { get; set; }
/// <summary>
/// 直达变中转原值
/// </summary>
public string DirectToTransOldVal { get; set; }
/// <summary>
/// 直达变中转修改值
/// </summary>
public string DirectToTransNewVal { get; set; }
/// <summary>
/// 船名原始值
/// </summary>
public string VesselOldVal { get; set; }
/// <summary>
/// 船名修改值
/// </summary>
public string VesselNewVal { get; set; }
/// <summary>
/// 航次原始值
/// </summary>
public string VoynoOldVal { get; set; }
/// <summary>
/// 航次修改值
/// </summary>
public string VoynoNewVal { get; set; }
/// <summary>
/// 是否自动转发通知
/// </summary>
public bool IsAutoSendNotice { get; set; }
/// <summary>
/// 消息列表
/// </summary>

@ -26,5 +26,14 @@ namespace Myshipping.Application.Service.TaskManagePlat.Interface
/// <param name="tenantId">租户ID</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> TriggerSendNotice(string taskPKId, long tenantId);
/// <summary>
/// 生成重要提醒整船通知
/// </summary>
/// <param name="model">请求详情</param>
/// <param name="slotBaseInfo">舱位详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GenerateWholeShipCaucation(CautionNoticeTaskWholeShipDto model, BookingSlotBase slotBaseInfo);
}
}

@ -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
{
/*
1SIVGM
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)
{
}
}
}
}

Loading…
Cancel
Save