1、修改BC变更任务

2、增加INTTRA的订舱、截单功能
master
jianghaiqing 8 months ago
parent 51b00f2201
commit 032a6f75f6

File diff suppressed because it is too large Load Diff

@ -47,6 +47,10 @@ namespace Myshipping.Application
/// <summary>
/// 沃尔塔航运
/// </summary>
VOL
VOL,
/// <summary>
/// INTTRA
/// </summary>
INTTRA
}
}

@ -8626,6 +8626,38 @@ namespace Myshipping.Application
result.extra = currRlt.succ ? currRlt.extra.ToString() : "";
result.extra2 = currRlt.succ ? currRlt.extra2.ToString() : "";
}
else if (ediRouteEnum == EDIRouteEnum.INTTRA)
{
#region INTTRA
string strCheck = InttraEdiHelper.IsCreateINTTR(ediModel);
_logger.LogInformation($"调用SO(SI),校验:{strCheck},数据对象:{JsonConvert.SerializeObject(ediModel)}");
if (!string.IsNullOrWhiteSpace(strCheck))
{
if (Regex.IsMatch(strCheck, "\\<br\\s{1,}/\\>"))
{
strCheck = Regex.Replace(strCheck, "\\<br\\s{1,}/\\>", "\n");
}
throw Oops.Bah($"发送{EDIRouteEnum.ESL.ToString()}校验失败,{strCheck}");
}
CommonWebApiResult currRlt = new CommonWebApiResult();
if (model.sendType == "B")
{
currRlt = InttraEdiHelper.CreateEdiINTTR(ediModel);
}
else if (model.sendType == "E")
{
currRlt = InttraEdiHelper.CreateEdiINTTRSI(ediModel);
}
#endregion
result.succ = currRlt.succ;
result.extra = currRlt.succ ? currRlt.extra.ToString() : "";
}
}
catch (Exception ex)
{

@ -1042,7 +1042,8 @@ namespace Myshipping.Application
/// <param name="slotId">舱位主键</param>
/// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param>
/// <returns></returns>
private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
[NonAction]
public async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
{
string batchNo = IDGen.NextID().ToString();
@ -1061,22 +1062,46 @@ namespace Myshipping.Application
DateTime nowDate = DateTime.Now;
BookingSlotCompare entity = new BookingSlotCompare
var hisInfo = _bookingSlotCompareRepository.AsQueryable().First(a => a.COMPARE_BATCHNO == reqBatchNo);
if (hisInfo == null)
{
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),
};
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);
await _bookingSlotCompareRepository.InsertAsync(entity);
}
else
{
hisInfo.COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0;
hisInfo.UpdatedTime = nowDate;
hisInfo.UpdatedUserId = UserManager.UserId;
hisInfo.UpdatedUserName = UserManager.Name;
hisInfo.COMPARE_RLT = JSON.Serialize(compareResult.extra.ShowDetailList);
await _bookingSlotCompareRepository.AsUpdateable(hisInfo).UpdateColumns(it =>
new
{
it.COMPARE_DIFF_NUM,
it.COMPARE_RLT,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
}
}
#endregion
@ -1089,7 +1114,7 @@ namespace Myshipping.Application
/// <param name="bcTargetDto">BC变更后详情</param>
/// <returns>返回回执</returns>
[NonAction]
private async Task<TaskManageExcuteResultDto> ExcuteCompare(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto)
public async Task<TaskManageExcuteResultDto> ExcuteCompare(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto)
{
TaskManageExcuteResultDto model = null;
/*

@ -73,7 +73,35 @@ namespace Myshipping.Application
.Map(dest => dest.TransferPort1, src => src.TRANSFER_PORT_1)
.Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2);
config.ForType<TaskBCInfoReadDto, TaskBCInfoDto>()
.Map(dest => dest.CarrierId, src => src.CarrierId)
.Map(dest => dest.Carrier, src => src.Carrier)
.Map(dest => dest.MBLNo, src => src.MBLNo)
.Map(dest => dest.BookingSlotType, src => src.BookingSlotType)
.Map(dest => dest.BookingSlotTypeName, src => src.BookingSlotTypeName)
.Map(dest => dest.Vessel, src => src.Vessel)
.Map(dest => dest.VoyNo, src => src.VoyNo)
.Map(dest => dest.VGMSubmissionCutDate, src => src.VGMCutoffTime.HasValue ? src.VGMCutoffTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.WeekAt, src => src.WeekAt)
.Map(dest => dest.CarriageType, src => src.CarriageType)
.Map(dest => dest.CarriageTypeName, src => src.CarriageTypeName)
.Map(dest => dest.ContractNo, src => src.ContractNo)
.Map(dest => dest.CtnStat, src => src.CtnStat)
.Map(dest => dest.CYCutoffTime, src => src.CYCutoffTime.HasValue ? src.CYCutoffTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.DetensionFreeDays, src => src.DetensionFreeDays)
.Map(dest => dest.ETD, src => src.ETD.HasValue ? src.ETD.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.ETA, src => src.ETA.HasValue ? src.ETA.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.LaneCode, src => src.LaneCode)
.Map(dest => dest.LaneName, src => src.LaneName)
.Map(dest => dest.ManifestCutDate, src => src.ManifestCutDate.HasValue ? src.ManifestCutDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.MDGFCutDate, src => src.MDGFCutDate.HasValue ? src.MDGFCutDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.SICutDate, src => src.SICutDate.HasValue ? src.SICutDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")
.Map(dest => dest.PlaceDelivery, src => src.PlaceDelivery)
.Map(dest => dest.PlaceReceipt, src => src.PlaceReceipt)
.Map(dest => dest.PortDischarge, src => src.PortDischarge)
.Map(dest => dest.Portload, src => src.Portload)
.Map(dest => dest.TransferPort1, src => src.TransferPort1)
.Map(dest => dest.TransferPort2, src => src.TransferPort2);
}
}
}

@ -128,5 +128,22 @@ namespace Myshipping.Application
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SendEmail(BookingSlotSendEmailDto model);
/// <summary>
/// 请求BC比对
/// </summary>
/// <param name="bcSrcDto">BC详情</param>
/// <param name="bcTargetDto">BC变更后详情</param>
/// <returns>返回回执</returns>
Task<TaskManageExcuteResultDto> ExcuteCompare(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto);
/// <summary>
/// 推送BC变更比对
/// </summary>
/// <param name="bcSrcDto">原舱位详情</param>
/// <param name="bcTargetDto">变更后舱位详情</param>
/// <param name="slotId">舱位主键</param>
/// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param>
/// <returns></returns>
Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo);
}
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class EmailBCReadMessageInfo
{
/// <summary>
/// 表头
/// </summary>
public TaskMessageHead Head { get; set; }
/// <summary>
/// 表体
/// </summary>
public EmailBCReadMessageMainInfo Main { get; set; }
}
public class EmailBCReadMessageMainInfo
{
/// <summary>
/// 所属租户ID
/// </summary>
public string TenantId { get; set; }
}
}

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class ParserReaderExcuteResultDto
{
/// <summary>
/// 是否成功 true=成功 false=失败
/// </summary>
public bool succ { get; set; } = false;
/// <summary>
/// 状态 0-成功
/// </summary>
public int status { get; set; } = 0;
/// <summary>
/// 返回消息
/// </summary>
public string msg { get; set; }
/// <summary>
/// 总记录数
/// </summary>
public int total { get; set; }
/// <summary>
/// 当前页列表数据
/// </summary>
public object rows { get; set; }
/// <summary>
/// 合计信息
/// </summary>
public object summary { get; set; }
/// <summary>
/// 扩展信息
/// </summary>
public object extra { get; set; }
/// <summary>
/// 扩展信息2
/// </summary>
public object extra2 { get; set; }
/// <summary>
/// 扩展信息场站统计
/// </summary>
public object yardStatInfo { get; set; }
/// <summary>
/// 是否异常
/// </summary>
public bool exceptionflag { get; set; }
/// <summary>
/// 生成HTML
/// </summary>
public string ResultHtml { get; set; }
}
}

@ -0,0 +1,417 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
///
/// </summary>
public class TaskBCInfoReadDto
{
/// <summary>
/// 订舱单位
/// </summary>
public string BookingParty { get; set; }
/// <summary>
/// 发货人
/// </summary>
public string Shipper { get; set; }
/// <summary>
/// 收货人
/// </summary>
public string Consignee { get; set; }
/// <summary>
/// 通知人
/// </summary>
public string NotifyParty { get; set; }
/// <summary>
/// BC更新次数
/// </summary>
public Nullable<int> BCModifyTimes { get; set; }
/// <summary>
/// BC更新时间
/// </summary>
public Nullable<DateTime> BCModifyDate { get; set; }
/// <summary>
/// 主单号
/// </summary>
public string MBLNo { get; set; }
/// <summary>
/// 船名
/// </summary>
public string Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string VoyNo { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string Carrier { get; set; }
/// <summary>
/// 收货地
/// </summary>
public string PlaceReceipt { get; set; }
/// <summary>
/// 装货港
/// </summary>
public string Portload { get; set; }
/// <summary>
/// 截关时间
/// </summary>
public Nullable<DateTime> ClosingDate { get; set; }
/// <summary>
/// 截VGM时间
/// </summary>
public Nullable<DateTime> VGMCutoffTime { get; set; }
/// <summary>
/// ETA(预计到港时间)
/// </summary>
public Nullable<DateTime> ETA { get; set; }
/// <summary>
/// ETD(预计离港时间)
/// </summary>
public Nullable<DateTime> ETD { get; set; }
/// <summary>
/// 目的港ETA
/// </summary>
public Nullable<DateTime> PODETA { get; set; }
/// <summary>
/// 截单时间
/// </summary>
public Nullable<DateTime> CutSingleTime { get; set; }
/// <summary>
/// 卸货港
/// </summary>
public string PortDischarge { get; set; }
/// <summary>
/// 交货地
/// </summary>
public string PlaceDelivery { get; set; }
/// <summary>
/// 装运方式
/// </summary>
public string ShippingMethod { get; set; }
/// <summary>
/// 运输条款
/// </summary>
public string Service { get; set; }
/// <summary>
/// 港前运输形态
/// </summary>
public string PreTransMode { get; set; }
/// <summary>
/// 品名
/// </summary>
public string Description { get; set; }
/// <summary>
/// 签单地点
/// </summary>
public string IssuePlace { get; set; }
/// <summary>
/// 集港码头
/// </summary>
public string CollectionTerminal { get; set; }
/// <summary>
/// 约号
/// </summary>
public string ContractNo { get; set; }
/// <summary>
/// 预付地点
/// </summary>
public string PrepardAT { get; set; }
/// <summary>
/// 船代
/// </summary>
public string ShipAgent { get; set; }
/// <summary>
/// 场站
/// </summary>
public string Yard { get; set; }
/// <summary>
/// 场站联系人
/// </summary>
public string YardContactUserName { get; set; }
/// <summary>
/// 场站联系电话
/// </summary>
public string YardContactTel { get; set; }
/// <summary>
/// 一代客服姓名
/// </summary>
public string FstCustomerSerUserName { get; set; }
/// <summary>
/// 一代客服电话
/// </summary>
public string FstCustomerSerUserTel { get; set; }
/// <summary>
/// 一代客服邮箱
/// </summary>
public string FstCustomerSerUserEmail { get; set; }
/// <summary>
/// 备注1
/// </summary>
public string Remark1 { get; set; }
/// <summary>
/// 截港时间
/// </summary>
public Nullable<DateTime> CYCutoffTime { get; set; }
/// <summary>
/// 状态 TEMP-暂存 SUCC-已对应 ERROR-异常
/// </summary>
public string Status { get; set; }
/// <summary>
/// 文件MD5
/// </summary>
public string FileMD5 { get; set; }
/// <summary>
/// 最后对应时间,最后关联到订舱日期
/// </summary>
public Nullable<DateTime> LastToBookingDate { get; set; }
/// <summary>
/// 来源邮箱
/// </summary>
public string FromEmail { get; set; }
/// <summary>
/// 接收邮箱
/// </summary>
public string RecvEmail { get; set; }
/// <summary>
/// 订舱ID对应成功后订舱ID写入
/// </summary>
public Nullable<long> BookingOrderId { get; set; }
/// <summary>
/// 集装箱列表
/// </summary>
public List<TaskBCInfoReadCtnDto> CtnList { get; set; }
/// <summary>
/// 顺序号
/// </summary>
public int Indx { get; set; }
/// <summary>
/// 对应订舱序号
/// </summary>
public int BKOrderIndx { get; set; }
/// <summary>
/// 舱位主键
/// </summary>
public Nullable<long> BookingSlotId { get; set; }
/// <summary>
/// 船公司代号
/// </summary>
public string CarrierId { get; set; }
/// <summary>
/// 航线代码(船公司)
/// </summary>
public string LaneCode { get; set; }
/// <summary>
/// 航线名称(船公司)
/// </summary>
public string LaneName { get; set; }
/// <summary>
/// 承运方式 DIRECT_SHIP-直达TRANSFER_SHIP-中转
/// </summary>
public string CarriageType { get; set; }
/// <summary>
/// 承运方式名称 DIRECT_SHIP-直达TRANSFER_SHIP-中转
/// </summary>
public string CarriageTypeName { get; set; }
/// <summary>
/// 订舱方式 CONTRACT_ORDER-合约订舱SPOT_ORDER-SPOT订舱
/// </summary>
public string BookingSlotType { get; set; }
/// <summary>
/// 订舱方式名称 CONTRACT_ORDER-合约订舱SPOT_ORDER-SPOT订舱
/// </summary>
public string BookingSlotTypeName { get; set; }
/// <summary>
/// 箱型箱量
/// </summary>
public string CtnStat { get; set; }
/// <summary>
/// 所在周数
/// </summary>
public string WeekAt { get; set; }
/// <summary>
/// 箱使天数
/// </summary>
public int DetensionFreeDays { get; set; }
/// <summary>
/// 样单截止日期
/// </summary>
public Nullable<DateTime> SICutDate { get; set; }
/// <summary>
/// 舱单截止时间
/// </summary>
public Nullable<DateTime> ManifestCutDate { get; set; }
/// <summary>
/// MDGF提交截止时间
/// </summary>
public Nullable<DateTime> MDGFCutDate { get; set; }
/// <summary>
/// 中转港1
/// </summary>
public string TransferPort1 { get; set; }
/// <summary>
/// 中转港2
/// </summary>
public string TransferPort2 { get; set; }
/// <summary>
/// 二程船名
/// </summary>
public string SecondVessel { get; set; }
/// <summary>
/// 二程航次
/// </summary>
public string SecondVoyno { get; set; }
/// <summary>
/// 二程ETD
/// </summary>
public Nullable<DateTime> SecondETD { get; set; }
/// <summary>
/// 二程ETA
/// </summary>
public Nullable<DateTime> SecondETA { get; set; }
/// <summary>
/// 订舱确认时间
/// </summary>
public Nullable<DateTime> BookingConfirmDate { get; set; }
}
/// <summary>
/// 任务BC集装箱
/// </summary>
public class TaskBCInfoReadCtnDto
{
/// <summary>
/// 箱型代码
/// </summary>
public string CtnCode { get; set; }
/// <summary>
/// 箱型
/// </summary>
public string CtnALL { get; set; }
/// <summary>
/// 箱量
/// </summary>
public Nullable<int> CTNNUM { get; set; }
/// <summary>
/// 件数
/// </summary>
public Nullable<int> PKGS { get; set; }
/// <summary>
/// 尺码
/// </summary>
public Nullable<decimal> CBM { get; set; }
/// <summary>
/// 毛重
/// </summary>
public Nullable<decimal> KGS { get; set; }
/// <summary>
/// 皮重
/// </summary>
public Nullable<decimal> TareWeight { get; set; }
/// <summary>
/// 危品票标示
/// </summary>
public string IODGT { get; set; }
/// <summary>
/// 特殊装载需求
/// </summary>
public string SpecialLoadingRequire { get; set; }
/// <summary>
/// 提箱场站
/// </summary>
public string TakeCTNYard { get; set; }
/// <summary>
/// 提箱时间
/// </summary>
public Nullable<DateTime> TakeCTNTime { get; set; }
/// <summary>
/// 还箱场站
/// </summary>
public string ReturnCTNYard { get; set; }
}
}

@ -105,5 +105,12 @@ namespace Myshipping.Application
/// <param name="taskPkId">BC任务主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SearchAndConnectBookingInfo(string taskPkId);
/// <summary>
/// 重新比对
/// </summary>
/// <param name="taskPKId">BC任务主键</param>
/// <returns></returns>
Task ReCompareResult(string taskPKId);
}
}

@ -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;
@ -1664,7 +1666,7 @@ namespace Myshipping.Application
if (fileInfo == null)
{
throw Oops.Oh($"提取订舱的Booking Confirmation Notice文件失败,不能发送邮件");
throw Oops.Oh($"提取变更文件失败,不能发送邮件");
}
_logger.LogInformation($"获取订舱附件地址,结果:{fileInfo.FILE_PATH}");
@ -2611,6 +2613,320 @@ namespace Myshipping.Application
return result;
}
#endregion
/// <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
2BookingConfirmation
3BookingConfirmation
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();
}
}
}
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}");
}
#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>

@ -136,5 +136,7 @@
"BCCompareUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare",
"MSKAPIDjyUserKey": "wu",
"MSKAPIDjyUserSecret": "123456",
"MSKAPIOPEnvironment": "TEST"
"MSKAPIOPEnvironment": "TEST",
"BCReadWebApiUrl": "http://localhost:5110/api/TaskBCParser/ExcuteBCFileRead",
"BookingAmendReadWebApiUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentRead"
}
Loading…
Cancel
Save