|
|
|
@ -80,6 +80,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly IBookingValueAddedService _bookingValueAddedService;
|
|
|
|
|
private readonly IDjyCustomerService _djyCustomerService;
|
|
|
|
|
private readonly INamedServiceProvider<IBookingMSKAPIService> _namedBookingMSKAPIServiceProvider;
|
|
|
|
|
private readonly IDjyTenantParamService _djyTenantParamService;
|
|
|
|
|
|
|
|
|
|
private readonly INamedServiceProvider<IBookingSlotService> _namedBookingSlotServiceProvider;
|
|
|
|
|
|
|
|
|
@ -89,6 +90,17 @@ namespace Myshipping.Application
|
|
|
|
|
const string CONST_BC_NOTICE_FILE_CODE = "bc_notice";
|
|
|
|
|
const string CONST_BC_NOTICE_FILE_NAME = "Booking Confirmation Notice";
|
|
|
|
|
|
|
|
|
|
//租户BC默认转发KEY
|
|
|
|
|
const string CONST_BC_DEFAULT_PARAM = "BC_TASK_AUTO_TRANSMIT";
|
|
|
|
|
//租户AMENDMENT默认转发KEY
|
|
|
|
|
const string CONST_AMENDMENT_DEFAULT_PARAM = "AMENDMENT_TASK_AUTO_TRANSMIT";
|
|
|
|
|
//租户CANCELLATION默认转发KEY
|
|
|
|
|
const string CONST_CANCELLATION_DEFAULT_PARAM = "CANCELLATION_TASK_AUTO_TRANSMIT";
|
|
|
|
|
//租户AMENDMENT默认钉钉消息KEY
|
|
|
|
|
const string CONST_AMENDMENT_DING_DEFAULT_PARAM = "AMENDMENT_TASK_DING_NOTICE";
|
|
|
|
|
//租户CANCELLATION默认钉钉消息KEY
|
|
|
|
|
const string CONST_CANCELLATION_DING_DEFAULT_PARAM = "CANCELLATION_TASK_DING_NOTICE";
|
|
|
|
|
|
|
|
|
|
public TaskManageBCService(SqlSugarRepository<TaskBCInfo> taskBCInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
|
|
|
|
|
SqlSugarRepository<TaskBCCTNInfo> taskBCCTNInfoRepository,
|
|
|
|
@ -104,6 +116,7 @@ namespace Myshipping.Application
|
|
|
|
|
IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService,
|
|
|
|
|
INamedServiceProvider<IBookingSlotService> namedBookingSlotServiceProvider,
|
|
|
|
|
INamedServiceProvider<IBookingMSKAPIService> namedBookingMSKAPIServiceProvider,
|
|
|
|
|
IDjyTenantParamService djyTenantParamService,
|
|
|
|
|
SqlSugarRepository<BookingSlotBase> bookingSlotBaseRepository,
|
|
|
|
|
SqlSugarRepository<BookingSlotCtn> bookingSlotBaseCtnRepository,
|
|
|
|
|
SqlSugarRepository<BookingSlotAllocation> bookingSlotAllocationRepository,
|
|
|
|
@ -135,6 +148,7 @@ namespace Myshipping.Application
|
|
|
|
|
_bookingSlotAllocationCtnRepository = bookingSlotAllocationCtnRepository;
|
|
|
|
|
_namedBookingMSKAPIServiceProvider = namedBookingMSKAPIServiceProvider;
|
|
|
|
|
_namedBookingSlotServiceProvider = namedBookingSlotServiceProvider;
|
|
|
|
|
_djyTenantParamService = djyTenantParamService;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
@ -2308,66 +2322,161 @@ namespace Myshipping.Application
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
1、检索对应舱位,提取比对差异结果
|
|
|
|
|
2、检索舱位对应的订舱信息,如果有则生成用户通知邮件
|
|
|
|
|
3、推送钉钉消息@操作人 通知收到变更
|
|
|
|
|
* Amendment
|
|
|
|
|
1、需要先匹配舱位,如果没有舱位不能执行后续的步骤。
|
|
|
|
|
2、判断当前租户是否配置了自动转发客户邮件。
|
|
|
|
|
3、如果配置了自动转发,需要判断订舱是否已有,没有不能执行自动转发。
|
|
|
|
|
4、转发需要提取差异数据,如果没有差异数据也不能转发邮件。
|
|
|
|
|
5、默认通过钉钉通知操作收到了变更通知。
|
|
|
|
|
* Cancellation
|
|
|
|
|
1、需要先匹配舱位,如果没有舱位不能执行后续的步骤。
|
|
|
|
|
2、判断当前租户是否配置了自动转发客户邮件。
|
|
|
|
|
3、如果配置了自动转发,需要判断订舱是否已有,没有不能执行自动转发。
|
|
|
|
|
4、转发需要提取差异数据,如果没有差异数据也不能转发邮件。
|
|
|
|
|
*/
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var baseTask = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
|
|
|
|
|
if (baseTask == null)
|
|
|
|
|
throw Oops.Oh($"主任务获取失败,不存在或已作废");
|
|
|
|
|
|
|
|
|
|
var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskPKId);
|
|
|
|
|
|
|
|
|
|
if (bcOrder == null)
|
|
|
|
|
throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息");
|
|
|
|
|
throw Oops.Oh($"BC任务获取失败,不存在或已作废");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(bcOrder.BOOKING_SLOT_ID.HasValue && bcOrder.BOOKING_SLOT_ID.Value > 0)
|
|
|
|
|
if (!bcOrder.BOOKING_SLOT_ID.HasValue || bcOrder.BOOKING_SLOT_ID.Value == 0)
|
|
|
|
|
{
|
|
|
|
|
var slotInfo = await _bookingSlotBaseRepository.AsQueryable()
|
|
|
|
|
.FirstAsync(t => t.Id == bcOrder.BOOKING_SLOT_ID.Value);
|
|
|
|
|
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
|
|
|
|
|
var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
if(slotInfo != null)
|
|
|
|
|
if (slotModel != null && slotModel.BookingSlotId > 0)
|
|
|
|
|
{
|
|
|
|
|
//查询对应的订舱信息
|
|
|
|
|
var slotAlloc = await _bookingSlotAllocationRepository.AsQueryable()
|
|
|
|
|
.FirstAsync(a => a.BOOKING_SLOT_ID == slotInfo.Id && a.IsDeleted == false);
|
|
|
|
|
if (slotModel.HasBookingOrder)
|
|
|
|
|
{
|
|
|
|
|
bcOrder.BOOKING_SLOT_ID = slotModel.BookingSlotId;
|
|
|
|
|
bcOrder.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault();
|
|
|
|
|
bcOrder.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcOrder.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcOrder.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
if (slotAlloc != null && slotAlloc.BOOKING_ID > 0)
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//查询订舱记录
|
|
|
|
|
var bookingInfo = _bookingOrderRepository.AsQueryable()
|
|
|
|
|
.FirstAsync(a => a.Id == slotAlloc.BOOKING_ID && a.IsDeleted == false);
|
|
|
|
|
bcOrder.BOOKING_SLOT_ID = slotModel.BookingSlotId;
|
|
|
|
|
bcOrder.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcOrder.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcOrder.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
//如果订舱记录推送客户邮件
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (baseTask != null)
|
|
|
|
|
{
|
|
|
|
|
if (baseTask.IS_PUBLIC == 1)
|
|
|
|
|
{
|
|
|
|
|
baseTask.IS_PUBLIC = 0;
|
|
|
|
|
baseTask.RealUserId = UserManager.UserId;
|
|
|
|
|
baseTask.RealUserName = UserManager.Name;
|
|
|
|
|
baseTask.UpdatedTime = DateTime.Now;
|
|
|
|
|
baseTask.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
baseTask.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
//更新任务台,将当前任务变更为个人任务
|
|
|
|
|
await _taskBaseRepository.AsUpdateable(baseTask).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.IS_PUBLIC,
|
|
|
|
|
it.RealUserId,
|
|
|
|
|
it.RealUserName,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"无法获取舱位信息");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
推送钉钉消息给相关的操作OP
|
|
|
|
|
*/
|
|
|
|
|
DjyTenantParamValueOutput paramConfig = null;
|
|
|
|
|
DjyTenantParamValueOutput dingdingConfig = null;
|
|
|
|
|
|
|
|
|
|
var paramList = _djyTenantParamService.GetParaCodeWithValue(new[] { CONST_AMENDMENT_DEFAULT_PARAM,
|
|
|
|
|
CONST_CANCELLATION_DEFAULT_PARAM,
|
|
|
|
|
CONST_AMENDMENT_DING_DEFAULT_PARAM,
|
|
|
|
|
CONST_CANCELLATION_DING_DEFAULT_PARAM }).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//如果有舱位只能推送钉钉消息
|
|
|
|
|
//var bcCtnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == bcOrder.PK_ID).ToList();
|
|
|
|
|
if (baseTask.TASK_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString())
|
|
|
|
|
{
|
|
|
|
|
if (paramList != null && paramList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_AMENDMENT_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
//var fileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskPKId).ToList();
|
|
|
|
|
dingdingConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_AMENDMENT_DING_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (baseTask.TASK_TYPE == TaskBaseTypeEnum.CANCELLATION.ToString())
|
|
|
|
|
{
|
|
|
|
|
if (paramList != null && paramList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CANCELLATION_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
//推送舱位
|
|
|
|
|
//var bookingSlotId = GenerateBookingSlot(bcOrder, bcCtnList, fileList,"update").GetAwaiter().GetResult();
|
|
|
|
|
dingdingConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CANCELLATION_DING_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 判断是否默认转发邮件 paramConfig={JSON.Serialize(paramConfig)}");
|
|
|
|
|
|
|
|
|
|
//如果值是ENABLE表示可以自动发送
|
|
|
|
|
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
|
|
|
|
|
|
|
|
|
|
var emailRlt = await SendEmail(taskPKId);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dingdingConfig != null && dingdingConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送钉钉消息");
|
|
|
|
|
|
|
|
|
|
var emailRlt = await SendEmail(taskPKId);
|
|
|
|
|
|
|
|
|
|
//检索是否有差异
|
|
|
|
|
//var compareResult = _bookingSlotCompareRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
// .Where(x => x.SLOT_ID == bookingSlotId && x.IsDeleted == false && x.TenantId ==
|
|
|
|
|
// bcOrder.TenantId).OrderByDescending(a=>a.CreatedTime).First();
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 发送钉钉消息完成 结果={JSON.Serialize(emailRlt)}");
|
|
|
|
|
|
|
|
|
|
//if(compareResult != null && compareResult.COMPARE_DIFF_NUM > 0)
|
|
|
|
|
//{
|
|
|
|
|
// //准备推送邮件
|
|
|
|
|
// await GenerateSendEmail(bcOrder);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"未检索到对应的舱位信息");
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "执行成功";
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -2614,6 +2723,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 重新比对
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重新比对
|
|
|
|
|
/// </summary>
|
|
|
|
@ -2693,6 +2803,27 @@ namespace Myshipping.Application
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (baseTask.IS_PUBLIC == 1)
|
|
|
|
|
{
|
|
|
|
|
baseTask.IS_PUBLIC = 0;
|
|
|
|
|
baseTask.RealUserId = UserManager.UserId;
|
|
|
|
|
baseTask.RealUserName = UserManager.Name;
|
|
|
|
|
baseTask.UpdatedTime = DateTime.Now;
|
|
|
|
|
baseTask.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
baseTask.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
//更新任务台,将当前任务变更为个人任务
|
|
|
|
|
await _taskBaseRepository.AsUpdateable(baseTask).UpdateColumns(it => new {
|
|
|
|
|
it.IS_PUBLIC,
|
|
|
|
|
it.RealUserId,
|
|
|
|
|
it.RealUserName,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2739,7 +2870,6 @@ namespace Myshipping.Application
|
|
|
|
|
if (modifyBCReadInfo == null)
|
|
|
|
|
throw Oops.Oh($"重新读取BC变更文件详情失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskBCInfoReadDto BCReadInfo = await GetBCReaderInfo(bcFileFullPath, bcFileName, UserManager.TENANT_ID, taskPKId, App.Configuration["BCReadWebApiUrl"]);
|
|
|
|
|
|
|
|
|
@ -2785,6 +2915,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"触发比对差异结束,reqBatchNo={reqBatchNo}");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读BC详情详情
|
|
|
|
|
/// <summary>
|
|
|
|
@ -2926,7 +3057,6 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|