|
|
|
@ -30,9 +30,11 @@ using SqlSugar;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Security.Principal;
|
|
|
|
@ -78,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;
|
|
|
|
|
|
|
|
|
@ -87,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,
|
|
|
|
@ -102,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,
|
|
|
|
@ -133,6 +148,7 @@ namespace Myshipping.Application
|
|
|
|
|
_bookingSlotAllocationCtnRepository = bookingSlotAllocationCtnRepository;
|
|
|
|
|
_namedBookingMSKAPIServiceProvider = namedBookingMSKAPIServiceProvider;
|
|
|
|
|
_namedBookingSlotServiceProvider = namedBookingSlotServiceProvider;
|
|
|
|
|
_djyTenantParamService = djyTenantParamService;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
@ -1664,7 +1680,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
if (fileInfo == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"提取订舱的Booking Confirmation Notice文件失败,不能发送邮件");
|
|
|
|
|
throw Oops.Oh($"提取变更文件失败,不能发送邮件");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"获取订舱附件地址,结果:{fileInfo.FILE_PATH}");
|
|
|
|
@ -2191,7 +2207,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
emailApiUserDefinedDto.Attaches.Add(new AttachesInfo
|
|
|
|
|
{
|
|
|
|
|
AttachName = Path.GetFileName(filePath),
|
|
|
|
|
AttachName = Path.GetFileName(filePath).Replace("_MODIFY",""),
|
|
|
|
|
AttachContent = base64Str
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -2306,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)
|
|
|
|
|
{
|
|
|
|
|
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
|
|
|
|
|
var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
if(bcOrder.BOOKING_SLOT_ID.HasValue && bcOrder.BOOKING_SLOT_ID.Value > 0)
|
|
|
|
|
if (slotModel != null && slotModel.BookingSlotId > 0)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
var slotInfo = await _bookingSlotBaseRepository.AsQueryable()
|
|
|
|
|
.FirstAsync(t => t.Id == bcOrder.BOOKING_SLOT_ID.Value);
|
|
|
|
|
it.IS_PUBLIC,
|
|
|
|
|
it.RealUserId,
|
|
|
|
|
it.RealUserName,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
if(slotInfo != null)
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//查询对应的订舱信息
|
|
|
|
|
var slotAlloc = await _bookingSlotAllocationRepository.AsQueryable()
|
|
|
|
|
.FirstAsync(a => a.BOOKING_SLOT_ID == slotInfo.Id && a.IsDeleted == false);
|
|
|
|
|
throw Oops.Oh($"无法获取舱位信息");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (slotAlloc != null && slotAlloc.BOOKING_ID > 0)
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
if (baseTask.TASK_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString())
|
|
|
|
|
{
|
|
|
|
|
//查询订舱记录
|
|
|
|
|
var bookingInfo = _bookingOrderRepository.AsQueryable()
|
|
|
|
|
.FirstAsync(a => a.Id == slotAlloc.BOOKING_ID && a.IsDeleted == false);
|
|
|
|
|
if (paramList != null && paramList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_AMENDMENT_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
//如果订舱记录推送客户邮件
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
推送钉钉消息给相关的操作OP
|
|
|
|
|
*/
|
|
|
|
|
dingdingConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CANCELLATION_DING_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如果有舱位只能推送钉钉消息
|
|
|
|
|
//var bcCtnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == bcOrder.PK_ID).ToList();
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 判断是否默认转发邮件 paramConfig={JSON.Serialize(paramConfig)}");
|
|
|
|
|
|
|
|
|
|
//var fileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskPKId).ToList();
|
|
|
|
|
//如果值是ENABLE表示可以自动发送
|
|
|
|
|
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
|
|
|
|
|
|
|
|
|
|
//推送舱位
|
|
|
|
|
//var bookingSlotId = GenerateBookingSlot(bcOrder, bcCtnList, fileList,"update").GetAwaiter().GetResult();
|
|
|
|
|
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)}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dingdingConfig != null && dingdingConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送钉钉消息");
|
|
|
|
|
|
|
|
|
|
var emailRlt = await SendEmail(taskPKId);
|
|
|
|
|
|
|
|
|
|
_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)
|
|
|
|
|
{
|
|
|
|
@ -2611,6 +2722,341 @@ namespace Myshipping.Application
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 重新比对
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重新比对
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskPKId">BC任务主键</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/TaskManageBC/ReCompareResult")]
|
|
|
|
|
public async Task ReCompareResult(string taskPKId)
|
|
|
|
|
{
|
|
|
|
|
List<CompareResultDetailInfo> list = new List<CompareResultDetailInfo>();
|
|
|
|
|
/*
|
|
|
|
|
1、判断舱位是否存在,如果舱位不存在终止重新比对。
|
|
|
|
|
2、获取BookingConfirmation任务,如果不存在终止。
|
|
|
|
|
3、调取BookingConfirmation文件识别结果,与当前任务的文件识别重新比对。
|
|
|
|
|
4、更新到对应的舱位
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var baseTask = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPKId);
|
|
|
|
|
|
|
|
|
|
if (baseTask == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"未提取有效的任务信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (baseTask.TASK_TYPE != TaskBaseTypeEnum.BC_MODIFY.ToString())
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"任务类型不是Amendment不能重新比对");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bcTaskInfo = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskPKId);
|
|
|
|
|
|
|
|
|
|
if (bcTaskInfo == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"未提取有效的BC任务信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long slotId = 0;
|
|
|
|
|
string reqBatchNo = bcTaskInfo.BATCH_NO;
|
|
|
|
|
|
|
|
|
|
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
|
|
|
|
|
|
|
|
|
|
//没有舱位先要匹配舱位,才能比对
|
|
|
|
|
if (!bcTaskInfo.BOOKING_SLOT_ID.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var searchInfo = await server.SearchBookingSlotWithOrderByNo(bcTaskInfo.MBL_NO);
|
|
|
|
|
|
|
|
|
|
if (searchInfo != null)
|
|
|
|
|
{
|
|
|
|
|
if (searchInfo.HasBookingOrder)
|
|
|
|
|
{
|
|
|
|
|
bcTaskInfo.BOOKING_SLOT_ID = searchInfo.BookingSlotId;
|
|
|
|
|
bcTaskInfo.BOOKING_ORDER_ID = searchInfo.BookingOrderList.FirstOrDefault();
|
|
|
|
|
bcTaskInfo.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcTaskInfo.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcTaskInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcTaskInfo).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bcTaskInfo.BOOKING_SLOT_ID = searchInfo.BookingSlotId;
|
|
|
|
|
bcTaskInfo.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcTaskInfo.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcTaskInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcTaskInfo).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bcInfo = _taskBaseRepository.AsQueryable().Filter(null, true).Where(a => a.MBL_NO == bcTaskInfo.MBL_NO && a.CARRIER_ID == bcTaskInfo.CARRIERID
|
|
|
|
|
&& a.TASK_TYPE == TaskBaseTypeEnum.BC.ToString() && a.IsDeleted == false && a.TenantId == UserManager.TENANT_ID).First();
|
|
|
|
|
|
|
|
|
|
if (bcInfo == null)
|
|
|
|
|
throw Oops.Oh($"未检索到对应的BC任务");
|
|
|
|
|
|
|
|
|
|
var modifyFile = _taskFileRepository.AsQueryable().First(a => a.TASK_PKID == taskPKId && a.FILE_CATEGORY == "BC_MODIFY");
|
|
|
|
|
|
|
|
|
|
if(modifyFile == null)
|
|
|
|
|
throw Oops.Oh($"未获取到当前任务的文件信息");
|
|
|
|
|
|
|
|
|
|
var bcFile = _taskFileRepository.AsQueryable().First(a => a.TASK_PKID == bcInfo.PK_ID && a.FILE_CATEGORY == "BC");
|
|
|
|
|
|
|
|
|
|
if (bcFile == null)
|
|
|
|
|
throw Oops.Oh($"未获取到当前任务对应BC的文件信息");
|
|
|
|
|
|
|
|
|
|
var modifyFileName = Path.GetFileName(modifyFile.FILE_PATH);
|
|
|
|
|
var bcFileName = Path.GetFileName(bcFile.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var modifyFileFullPath = Path.Combine(dirAbs, modifyFile.FILE_PATH);
|
|
|
|
|
if (!File.Exists(modifyFileFullPath))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh("Amendment 文件提取失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bcFileFullPath = Path.Combine(dirAbs, bcFile.FILE_PATH);
|
|
|
|
|
if (!File.Exists(bcFileFullPath))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh("BC 文件提取失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskBCInfoReadDto modifyBCReadInfo = await GetBCReaderInfo(modifyFileFullPath, modifyFileName, UserManager.TENANT_ID, taskPKId, App.Configuration["BookingAmendReadWebApiUrl"]);
|
|
|
|
|
|
|
|
|
|
if (modifyBCReadInfo == null)
|
|
|
|
|
throw Oops.Oh($"重新读取BC变更文件详情失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskBCInfoReadDto BCReadInfo = await GetBCReaderInfo(bcFileFullPath, bcFileName, UserManager.TENANT_ID, taskPKId, App.Configuration["BCReadWebApiUrl"]);
|
|
|
|
|
|
|
|
|
|
if (BCReadInfo == null)
|
|
|
|
|
throw Oops.Oh($"重新读取BC文件详情失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskBCInfoDto bcSrcDto = BCReadInfo.Adapt<TaskBCInfoDto>();
|
|
|
|
|
TaskBCInfoDto bcTargetDto = modifyBCReadInfo.Adapt<TaskBCInfoDto>();
|
|
|
|
|
|
|
|
|
|
if (BCReadInfo.CtnList != null && BCReadInfo.CtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
bcSrcDto.CtnList = BCReadInfo.CtnList.GroupBy(x => x.CtnALL)
|
|
|
|
|
.Select(x =>
|
|
|
|
|
{
|
|
|
|
|
return new TaskBCCTNInfoDto
|
|
|
|
|
{
|
|
|
|
|
CtnALL = x.Key,
|
|
|
|
|
CTNNUM = x.ToList()
|
|
|
|
|
.Sum(a => a.CTNNUM)
|
|
|
|
|
};
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (modifyBCReadInfo.CtnList != null && modifyBCReadInfo.CtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
bcTargetDto.CtnList = modifyBCReadInfo.CtnList.GroupBy(x => x.CtnALL)
|
|
|
|
|
.Select(x =>
|
|
|
|
|
{
|
|
|
|
|
return new TaskBCCTNInfoDto
|
|
|
|
|
{
|
|
|
|
|
CtnALL = x.Key,
|
|
|
|
|
CTNNUM = x.ToList()
|
|
|
|
|
.Sum(a => a.CTNNUM)
|
|
|
|
|
};
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"触发比对差异开始,reqBatchNo={reqBatchNo}");
|
|
|
|
|
|
|
|
|
|
//比对差异
|
|
|
|
|
await server.PushCompareBCInfo(bcSrcDto, bcTargetDto, slotId, reqBatchNo);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"触发比对差异结束,reqBatchNo={reqBatchNo}");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读BC详情详情
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读BC详情详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="attachFullName">文件完整路径</param>
|
|
|
|
|
/// <param name="fileName">文件名称</param>
|
|
|
|
|
/// <param name="tenantId">所属租户</param>
|
|
|
|
|
/// <param name="taskPKId">任务ID</param>
|
|
|
|
|
/// <param name="url">请求URL</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task<TaskBCInfoReadDto> GetBCReaderInfo(string attachFullName, string fileName, long tenantId,string taskPKId,string url)
|
|
|
|
|
{
|
|
|
|
|
TaskBCInfoReadDto taskBCInfoReadDto = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
EmailBCReadMessageInfo messageInfo = new EmailBCReadMessageInfo
|
|
|
|
|
{
|
|
|
|
|
Head = new TaskMessageHead
|
|
|
|
|
{
|
|
|
|
|
GID = IDGen.NextID().ToString(),
|
|
|
|
|
MessageType = "BOOKING_AMENDMENT",
|
|
|
|
|
SenderId = "DJY",
|
|
|
|
|
SenderName = "新大简云",
|
|
|
|
|
ReceiverId = "RulesEngine",
|
|
|
|
|
ReceiverName = "大简云规则引擎",
|
|
|
|
|
Version = "1.0",
|
|
|
|
|
RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
|
RequestAction = "ReadFile",
|
|
|
|
|
},
|
|
|
|
|
Main = new EmailBCReadMessageMainInfo
|
|
|
|
|
{
|
|
|
|
|
TenantId = tenantId > 0 ? tenantId.ToString() : ""
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NameValueCollection par = new NameValueCollection();
|
|
|
|
|
par.Add("jsonData", JSON.Serialize(messageInfo));
|
|
|
|
|
|
|
|
|
|
//解析BookingAmendment
|
|
|
|
|
var compareRlt = await ExcuteReadFile(par, url,new
|
|
|
|
|
{
|
|
|
|
|
file = "file",
|
|
|
|
|
fileName = fileName,
|
|
|
|
|
fileBytes = File.ReadAllBytes(attachFullName)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"读取BC附件详情 taskPKId={taskPKId},compareRlt={JSON.Serialize(compareRlt)}");
|
|
|
|
|
|
|
|
|
|
if (compareRlt.succ)
|
|
|
|
|
{
|
|
|
|
|
taskBCInfoReadDto = JSON.Deserialize<TaskBCInfoReadDto>(JSON.Serialize(compareRlt.extra));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"读取BC附件详情异常,原因:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return taskBCInfoReadDto;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 请求BookingAmendment解析
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 请求BookingAmendment解析
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="nameValueCollection">请求参数</param>
|
|
|
|
|
/// <param name="url">请求url</param>
|
|
|
|
|
/// <param name="fileInfo">文件</param>
|
|
|
|
|
/// <param name="contentType">请求类型</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
private async Task<ParserReaderExcuteResultDto> ExcuteReadFile(NameValueCollection nameValueCollection, string url,dynamic fileInfo,
|
|
|
|
|
string contentType = "application/json")
|
|
|
|
|
{
|
|
|
|
|
ParserReaderExcuteResultDto model = null;
|
|
|
|
|
var result = string.Empty;
|
|
|
|
|
|
|
|
|
|
using (var httpClient = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var reduceAttach = new MultipartFormDataContent())
|
|
|
|
|
{
|
|
|
|
|
string[] allKeys = nameValueCollection.AllKeys;
|
|
|
|
|
foreach (string key in allKeys)
|
|
|
|
|
{
|
|
|
|
|
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(nameValueCollection[key]));
|
|
|
|
|
|
|
|
|
|
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
|
|
|
|
|
{
|
|
|
|
|
Name = key
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(dataContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 文件参数
|
|
|
|
|
if (fileInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var Content = new ByteArrayContent(fileInfo.fileBytes);
|
|
|
|
|
|
|
|
|
|
//Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
|
|
|
|
|
//{
|
|
|
|
|
// Name = fileInfo.file.ToString(),
|
|
|
|
|
// FileName = fileInfo.fileName.ToString(),
|
|
|
|
|
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
|
|
Content.Headers.Add("Content-Type", contentType);
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(Content, fileInfo.file.ToString(), HttpUtility.UrlEncode(fileInfo.fileName.ToString()));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//httpClient.DefaultRequestHeaders.Add("USER_KEY", App.Configuration["ApiUserKey"]);
|
|
|
|
|
//httpClient.DefaultRequestHeaders.Add("USER_SECRET", App.Configuration["ApiUserSecret"]);
|
|
|
|
|
//请求
|
|
|
|
|
var response = httpClient.PostAsync(url, reduceAttach).Result;
|
|
|
|
|
result = response.Content.ReadAsStringAsync().Result;
|
|
|
|
|
|
|
|
|
|
model = JSON.Deserialize<ParserReaderExcuteResultDto>(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("请求读取BC附件详情读取详情异常,原因:{error}", ex.Message);
|
|
|
|
|
|
|
|
|
|
throw Oops.Oh($"请求读取BC附件详情读取详情异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|