修改BC任务

optimize
jianghaiqing 10 months ago
parent 3552364950
commit 6a0ebced0f

@ -49,5 +49,12 @@ namespace Myshipping.Application
[SugarColumn(ColumnName = "COMPARE_DIFF_NUM")]
[Description("比对差异项数")]
public Nullable<int> COMPARE_DIFF_NUM { get; set; }
/// <summary>
/// 比对批次号
/// </summary>
[SugarColumn(ColumnName = "COMPARE_BATCHNO")]
[Description("比对批次号")]
public string COMPARE_BATCHNO { get; set; }
}
}

@ -346,5 +346,10 @@ namespace Myshipping.Application
/// 订舱确认时间
/// </summary>
public Nullable<DateTime> BOOKING_COMFIRM_DATE { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string BATCH_NO { get; set; }
}
}

@ -130,6 +130,11 @@ namespace Myshipping.Application
/// Booking Amendment
/// </summary>
[Description("BC变更")]
BC_MODIFY
BC_MODIFY,
/// <summary>
/// 截止时间变更通知
/// </summary>
[Description("截止时间变更")]
CUT_MODIFY
}
}

@ -51,6 +51,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingSlotAllocation> _repAllocation;
private readonly SqlSugarRepository<BookingSlotAllocationCtn> _repAllocationCtn;
private readonly SqlSugarRepository<BookingFile> _bookingFileRepository;
private readonly SqlSugarRepository<BookingSlotCompare> _bookingSlotCompareRepository;
private readonly SqlSugarRepository<BookingLog> _repBookingLog;
private readonly SqlSugarRepository<BookingLogDetail> _repBookingLogDetail;
@ -84,7 +85,8 @@ namespace Myshipping.Application
IEventPublisher publisher,
SqlSugarRepository<BookingSlotAllocation> repAllocation,
SqlSugarRepository<BookingSlotAllocationCtn> repAllocationCtn,
SqlSugarRepository<BookingFile> bookingFileRepository)
SqlSugarRepository<BookingFile> bookingFileRepository,
SqlSugarRepository<BookingSlotCompare> bookingSlotCompareRepository)
{
_repBase = repBase;
_repCtn = repCtn;
@ -101,6 +103,7 @@ namespace Myshipping.Application
_publisher = publisher;
_bookingfile = bookingfile;
_bookingFileRepository = bookingFileRepository;
_bookingSlotCompareRepository = bookingSlotCompareRepository;
}
#region 舱位
@ -455,7 +458,7 @@ namespace Myshipping.Application
}
//一般更新数据指的是Booking Amendment,需要与舱位进行数据比对
await PushCompareBCInfo(bcSrcDto, bcTargetDto,id);
await PushCompareBCInfo(bcSrcDto, bcTargetDto,id, dto.BatchNo);
}
else if (dto.OpType == "del")
{
@ -966,8 +969,16 @@ namespace Myshipping.Application
}
#endregion
private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto,long slotId)
#region 推送BC变更比对
/// <summary>
/// 推送BC变更比对
/// </summary>
/// <param name="bcSrcDto">原舱位详情</param>
/// <param name="bcTargetDto">变更后舱位详情</param>
/// <param name="slotId">舱位主键</param>
/// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param>
/// <returns></returns>
private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto,long slotId,string reqBatchNo)
{
string batchNo = IDGen.NextID().ToString();
@ -984,10 +995,27 @@ namespace Myshipping.Application
if (compareResult == null)
throw Oops.Oh($"舱位主键{slotId}请求BC比对失败返回为空");
DateTime nowDate = DateTime.Now;
BookingSlotCompare entity = new BookingSlotCompare
{
SLOT_ID = slotId,
COMPARE_BATCHNO = reqBatchNo,
COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff? compareResult.extra.ShowDetailList.Count : 0,
CreatedTime = nowDate,
UpdatedTime = nowDate,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name,
UpdatedUserId = UserManager.UserId,
UpdatedUserName = UserManager.Name,
COMPARE_TYPE = "BC_MODIFY",
COMPARE_RLT = JSON.Serialize(compareResult.extra.ShowDetailList),
};
await _bookingSlotCompareRepository.InsertAsync(entity);
}
#endregion
#region 请求BC比对
/// <summary>
@ -1052,6 +1080,32 @@ namespace Myshipping.Application
return model;
}
#endregion
#region 获取舱位变更比对结果
/// <summary>
/// 获取舱位变更比对结果
/// </summary>
/// <param name="id">舱位主键</param>
/// <param name="batchNo">批次号</param>
/// <returns>返回舱位变更比对结果</returns>
public async Task<List<CompareResultDetailInfo>> GetSlotCompareResult(long id,string batchNo)
{
var compareInfo = await _bookingSlotCompareRepository.AsQueryable()
.FirstAsync(t => t.SLOT_ID == id && t.COMPARE_BATCHNO == batchNo);
if (compareInfo == null)
{
throw Oops.Oh($"舱位变更比对结果不存在");
}
if (string.IsNullOrWhiteSpace(compareInfo.COMPARE_RLT))
{
throw Oops.Oh($"获取舱位变更比对结果错误,比对内容不存在");
}
return JSON.Deserialize<List<CompareResultDetailInfo>>(compareInfo.COMPARE_RLT);
}
#endregion
}
public class DynameFileInfo

@ -452,6 +452,11 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// 数据对象
/// </summary>
public BookingSlotBaseApiSaveDto DataObj { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string BatchNo { get; set; }
}
/// <summary>

@ -74,5 +74,13 @@ namespace Myshipping.Application
/// <param name="modifyFile"></param>
/// <returns></returns>
Task<long> InnerApiReceive(BookingSlotBaseApiDto dto, DynameFileInfo file = null, DynameFileInfo modifyFile = null);
/// <summary>
/// 获取舱位变更比对结果
/// </summary>
/// <param name="id">舱位主键</param>
/// <param name="batchNo">批次号</param>
/// <returns>返回舱位变更比对结果</returns>
Task<List<CompareResultDetailInfo>> GetSlotCompareResult(long id, string batchNo);
}
}

@ -106,15 +106,28 @@ namespace Myshipping.Application
/// </summary>
public List<string> ProjectList { get; set; }
/// <summary>
/// 联系人列表
/// </summary>
public List<CustomerContact> CustomerContactList { get; set; }
/// <summary>
/// 是否直接发送邮件给订舱联系人
/// </summary>
public bool IsDirectSend { get; set; } = false;
}
public class CustomerContact
{
/// <summary>
/// 委托单位联系人ID
/// </summary>
public Nullable<long> CustomerContactId { get; set; }
public long CustomerContactId { get; set; }
/// <summary>
/// 委托单位联系人名称
/// </summary>
public string CustomerContactName { get; set; }
}
}

@ -371,6 +371,11 @@ namespace Myshipping.Application
/// 任务状态
/// </summary>
public string taskStatus { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string BatchNo { get; set; }
}
public class TaskBCShowBaseKeywordDto

@ -367,5 +367,9 @@ namespace Myshipping.Application
/// </summary>
public Nullable<DateTime> BookingConfirmDate { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string BatchNo { get; set; }
}
}

@ -683,8 +683,8 @@ namespace Myshipping.Application
.Map(dest => dest.SecondETD, src => src.SECOND_ETD)
.Map(dest => dest.SecondETA, src => src.SECOND_ETA)
.Map(dest => dest.BookingSlotId, src => src.BOOKING_SLOT_ID)
.Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE);
.Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE)
.Map(dest => dest.BatchNo, src => src.BATCH_NO);
config.ForType<TaskBCInfo, TaskBCShowBaseDto>()
.Map(dest => dest.PKId, src => src.PK_ID)
@ -754,7 +754,8 @@ namespace Myshipping.Application
.Map(dest => dest.SecondETD, src => src.SECOND_ETD)
.Map(dest => dest.SecondETA, src => src.SECOND_ETA)
.Map(dest => dest.BookingSlotId, src => src.BOOKING_SLOT_ID)
.Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE);
.Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE)
.Map(dest => dest.BatchNo, src => src.BATCH_NO);
config.ForType<TaskManageOrderBCInfo, TaskBCInfo>()
.Map(dest => dest.BUSI_TYPE, src => src.BusiType)
@ -816,7 +817,8 @@ namespace Myshipping.Application
.Map(dest => dest.SECOND_VOYNO, src => src.SecondVoyno)
.Map(dest => dest.SECOND_ETD, src => src.SecondETD)
.Map(dest => dest.SECOND_ETA, src => src.SecondETA)
.Map(dest => dest.BOOKING_COMFIRM_DATE, src => src.BookingConfirmDate);
.Map(dest => dest.BOOKING_COMFIRM_DATE, src => src.BookingConfirmDate)
.Map(dest => dest.BATCH_NO, src => src.BatchNo);
config.ForType<TaskBCCTNInfo, TaskBCCTNInfoDto>()
.Map(dest => dest.CtnCode, src => src.CTNCODE)

@ -341,5 +341,10 @@ namespace Myshipping.Application
/// 舱位主键
/// </summary>
public Nullable<long> BookingSlotId { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string BatchNo { get; set; }
}
}

@ -82,5 +82,12 @@ namespace Myshipping.Application
/// <param name="taskPKId">BC任务主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SendEmail(string taskPKId);
/// <summary>
/// 获取当前比对结果
/// </summary>
/// <param name="taskPKId">BC任务主键</param>
/// <returns>返回回执</returns>
Task<List<CompareResultDetailInfo>> GetCompareResult(string taskPKId);
}
}

@ -708,9 +708,19 @@ namespace Myshipping.Application
if (bookingOrderId > 0)
{
List<BookingSlotBaseWithCtnDto> slots = new List<BookingSlotBaseWithCtnDto>();
var slotInfo = _bookingSlotService.Detail(bookingSlotId).GetAwaiter().GetResult();
BookingSlotBaseWithCtnDto baseInfo = slotInfo.Adapt<BookingSlotBaseWithCtnDto>();
baseInfo.Id = bookingSlotId;
baseInfo.CtnList = slotInfo.CtnList.Adapt<List<BookingSlotCtnDto>>();
slots.Add(baseInfo);
//对应订舱和舱位关系
var allocRlt = _bookingSlotService.ImportSlots(slots, bookingOrderId, false);
//更新库存
//_bookingSlotService.
var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcOrder.PK_ID);
if (bcEntity != null)
@ -737,8 +747,11 @@ namespace Myshipping.Application
var currBCOrder = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcEntity.PK_ID);
if (currBCOrder != null)
if (currBCOrder != null && model.IsDirectSend)
{
//异步推送邮件
await GenerateSendEmail(currBCOrder);
}
var taskEntity = _taskBaseRepository.AsQueryable().First(u => u.PK_ID == bcEntity.TASK_ID);
@ -778,9 +791,12 @@ namespace Myshipping.Application
var bookingOrderId = GenerateBookingOrder(bcOrder, bcCtnList, fileList, model).GetAwaiter().GetResult();
if (bookingOrderId > 0)
{
if (model.IsDirectSend)
{
//异步推送邮件
await GenerateSendEmail(bcOrder);
}
var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcTaskInfo.PK_ID);
@ -1112,26 +1128,34 @@ namespace Myshipping.Application
if (id > 0)
{
//这里如果指定了委托单位的邮件联系人,则推送订舱联系人
if (generateModel.CustomerContactId.HasValue && generateModel.CustomerContactId.Value > 0)
if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0)
{
var bookingContact = _bookingOrderContactRepository.AsQueryable()
.Where(a => a.BookingId == id && !a.IsDeleted).First();
var bookingContactList = _bookingOrderContactRepository.AsQueryable()
.Where(a => a.BookingId == id && !a.IsDeleted).ToList();
var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = generateModel.CustomerId.Value })
.GetAwaiter().GetResult();
generateModel.CustomerContactList.ForEach(contact =>
{
DjyCustomerContactOutput djyCustomerContactMan = null;
if (djyCustomerInfo.Contacts != null && djyCustomerInfo.Contacts.Count > 0)
{
djyCustomerContactMan = djyCustomerInfo.Contacts.FirstOrDefault(a =>
a.Remark.Equals("BCNotice", StringComparison.OrdinalIgnoreCase));
a.Id == contact.CustomerContactId);
}
if (djyCustomerContactMan != null)
{
var bookingContact = bookingContactList
.FirstOrDefault(x => x.Email.Equals(djyCustomerContactMan.Email, StringComparison.OrdinalIgnoreCase));
if (bookingContact == null)
{
bookingContact = new BookingOrderContact {
Name = generateModel.CustomerContactName,
bookingContact = new BookingOrderContact
{
Name = djyCustomerContactMan.Name,
BookingId = id,
Email = djyCustomerContactMan.Email,
Remark = djyCustomerContactMan.Remark,
@ -1140,11 +1164,11 @@ namespace Myshipping.Application
CreatedUserName = UserManager.Name
};
await _bookingOrderContactRepository.InsertAsync(bookingContact);
_bookingOrderContactRepository.Insert(bookingContact);
}
else
{
bookingContact.Name = generateModel.CustomerContactName;
bookingContact.Name = djyCustomerContactMan.Name;
bookingContact.Email = djyCustomerContactMan.Email;
bookingContact.Remark = djyCustomerContactMan.Remark;
bookingContact.UpdatedTime = DateTime.Now;
@ -1163,6 +1187,9 @@ namespace Myshipping.Application
}).ExecuteCommand();
}
}
});
}
if (generateModel.ProjectList != null && generateModel.ProjectList.Count > 0)
{
@ -1383,15 +1410,15 @@ namespace Myshipping.Application
//订舱OP的邮箱
string opEmail = string.Empty;
var bookingContact = _bookingOrderContactRepository.AsQueryable()
.First(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID);
var bookingContactList = _bookingOrderContactRepository.AsQueryable()
.Where(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID).ToList();
if (bookingContact == null && string.IsNullOrWhiteSpace(bookingContact.Email))
if (bookingContactList == null || bookingContactList.Count == 0)
{
_logger.LogInformation($"当前订舱未指定的联系人toEmail={toEmail}");
}
toEmail = bookingContact.Email.Trim();
toEmail = string.Join(";", bookingContactList.Select(x => x.Email.Trim()).Distinct().ToArray());
//获取操作OP的邮箱
if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID))
@ -1419,6 +1446,12 @@ namespace Myshipping.Application
_logger.LogInformation($"提取当前公共邮箱的配置完成id={publicMailAccount.Id}");
string emailTitle = $"Booking Confirmation : {taskBCInfo.MBL_NO}";
if (taskBCInfo.BUSI_TYPE == "BookingAmendment")
{
emailTitle = $"【变更】Booking Amendment : {taskBCInfo.MBL_NO}";
}
string filePath = string.Empty;
//读取邮件模板并填充数据
@ -1716,6 +1749,31 @@ namespace Myshipping.Application
return await GenerateSendEmail(bcOrder);
}
#endregion
/// <summary>
/// 获取当前比对结果
/// </summary>
/// <param name="taskPKId">BC任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageBC/GetCompareResult")]
public async Task<List<CompareResultDetailInfo>> GetCompareResult(string taskPKId)
{
if (string.IsNullOrWhiteSpace(taskPKId))
throw Oops.Oh($"BC任务主键不能为空");
var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
if (bcTaskInfo == null)
{
throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
}
var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == bcTaskInfo.PK_ID);
if (bcOrder == null)
throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息");
return await _bookingSlotService.GetSlotCompareResult(bcOrder.BOOKING_SLOT_ID.Value, bcOrder.BATCH_NO);
}
}
/// <summary>

@ -397,7 +397,7 @@ namespace Myshipping.Application
fileCategory = TaskFileCategoryEnum.BC_NOTICE.ToString();
}
else if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE)
else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_BASE_TYPE)
{
attachFileType = "bcmodifynoticefiles";
@ -688,7 +688,8 @@ namespace Myshipping.Application
#endregion
#region BC 任务
if (info.Main.TaskType == TaskBaseTypeEnum.BC || info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY)
if (info.Main.TaskType == TaskBaseTypeEnum.BC || info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY
|| info.Main.TaskType == TaskBaseTypeEnum.CANCELLATION)
{
//异步写入
var bcInfo = info.Main.BCInfo.Adapt<TaskBCInfo>();

Loading…
Cancel
Save