修改BC自动转发,增加拆单自动转发

舱位增加场站,生成订舱时自动对应
master
jianghaiqing 3 months ago
parent c5ea9cb4c7
commit eda36a284e

@ -427,5 +427,11 @@ namespace Myshipping.Application
/// </summary>
[Description("舱保类型名称")]
public string LOAD_GUARANTEE_FLAG_NAME { get; set; }
/// <summary>
/// 提箱场站
/// </summary>
[Description("提箱场站")]
public string TAKE_CTN_YARD { get; set; }
}
}

@ -401,5 +401,10 @@ namespace Myshipping.Application
/// 船公司航次
/// </summary>
public string CARRIER_VOYNO { get; set; }
/// <summary>
/// 提箱场站
/// </summary>
public string TAKE_CTN_YARD { get; set; }
}
}

@ -13672,6 +13672,19 @@ namespace Myshipping.Application
var currOrder = orderList.FirstOrDefault(a => a.MBLNO == mblNo);
//这里如果是拆票记录,则默认用拆票的第一票作为当前票的对应记录
if (currOrder == null && orderList.Any(b => b.SPLIT_OR_MERGE_FLAG.HasValue && b.SPLIT_OR_MERGE_FLAG.Value == 1))
{
var maxChar = orderList.Select(a =>
{
var startIndx = a.CUSTNO.Length;
return a.MBLNO.Substring(startIndx);
}).Min();
var custNo = orderList.FirstOrDefault().CUSTNO;
currOrder = orderList.FirstOrDefault(a => a.MBLNO == $"{custNo}{maxChar}");
}
if (currOrder != null)
{
model.currOrder = currOrder.Adapt<BookingOrderDto>();

@ -3223,6 +3223,18 @@ namespace Myshipping.Application
ctnInputs = new List<BookingCtnDto>()
};
//处理自动对应场站
if (!string.IsNullOrWhiteSpace(bookingSlotBase.TAKE_CTN_YARD))
{
var yardInfo = _cache.GetAllCodeYard().GetAwaiter().GetResult().FirstOrDefault(a => a.Code.Equals(bookingSlotBase.TAKE_CTN_YARD));
if (yardInfo != null)
{
bkModel.YARDID = yardInfo.Code;
bkModel.YARD = yardInfo.Name;
}
}
// 判断是否为拆票的舱位如果为拆票提单号需要加上ABCD...
var selectNum = generateModel.CtnList.Sum(x => x.CTNNUM);
_logger.LogInformation("根据舱位生成订舱selectNum:{selectNum}", selectNum);
@ -3594,6 +3606,7 @@ namespace Myshipping.Application
[NonAction]
public async Task MeasureDiffCautionTask(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId)
{
return;
try
{
if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))

@ -421,6 +421,12 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// </summary>
[Description("舱保类型名称")]
public string LOAD_GUARANTEE_FLAG_NAME { get; set; }
/// <summary>
/// 提箱场站
/// </summary>
[Description("提箱场站")]
public string TAKE_CTN_YARD { get; set; }
}
/// <summary>

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service
{
public class DrawModifyBCConfig
{
/// <summary>
/// 擦除枚举
/// </summary>
public DrawModifyBCConfigTypeEnum[] drawTypeArg { get; set; }
/// <summary>
/// 原箱数量
/// </summary>
public Nullable<int> origCtnNum { get; set; }
/// <summary>
/// 修改箱数量
/// </summary>
public Nullable<int> newCtnNum { get; set; }
/// <summary>
/// 箱类型
/// </summary>
public string ctnAll { get; set; }
/// <summary>
/// 原提单号
/// </summary>
public string origBillNo { get; set; }
/// <summary>
/// 新提单号
/// </summary>
public string newBillNo { get; set; }
}
public enum DrawModifyBCConfigTypeEnum
{
/// <summary>
/// 标准
/// </summary>
[Description("标准")]
Standard,
/// <summary>
/// 擦除更多(展鸿要求)
/// </summary>
[Description("擦除更多")]
EraseMore,
/// <summary>
/// 手工指定截单时间
/// </summary>
[Description("手工指定截单时间")]
DrawManualSIDate,
/// <summary>
/// 分票修改(康乾,主要考虑拆票时箱数量按照拆票显示)
/// </summary>
[Description("分票修改")]
SplitBC,
/// <summary>
/// 改提单号为分票号
/// </summary>
[Description("改提单号为分票号")]
ChangeToSplitBillNo,
}
}

@ -396,6 +396,11 @@ namespace Myshipping.Application
/// 货物标志
/// </summary>
public string CARGOID { get; set; }
/// <summary>
/// 提箱场站
/// </summary>
public string TakeCTNYard { get; set; }
}

@ -80,9 +80,10 @@ namespace Myshipping.Application
/// 发送邮件
/// </summary>
/// <param name="taskPKId">BC任务主键</param>
/// <param name="mandatoryBookingId">强制订单主键(非必填)</param>
/// <param name="usePersonalEmailSend">是否默认使用用户个人邮箱发送</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SendEmail(string taskPKId, bool usePersonalEmailSend = false);
Task<TaskManageOrderResultDto> SendEmail(string taskPKId, Nullable<long> mandatoryBookingId = null, bool usePersonalEmailSend = false);
/// <summary>
/// 获取当前比对结果

@ -15,7 +15,9 @@ using Myshipping.Application.ConfigOption;
using Myshipping.Application.Entity;
using Myshipping.Application.Enum;
using Myshipping.Application.Helper;
using Myshipping.Application.Service;
using Myshipping.Application.Service.BookingOrder;
using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Application.Service.BookingSlot.Dto;
using Myshipping.Core;
using Myshipping.Core.Entity;
@ -27,6 +29,7 @@ using NPOI.SS.Formula.Functions;
using NPOI.Util;
using NPOI.XWPF.UserModel;
using Org.BouncyCastle.Asn1.Tsp;
using Org.BouncyCastle.Utilities;
using RabbitMQ.Client;
using SqlSugar;
using StackExchange.Profiling.Internal;
@ -890,7 +893,7 @@ namespace Myshipping.Application
if (currBCOrder != null && model.IsDirectSend)
{
//异步推送邮件
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend);
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo,null, model.usePersonalEmailSend);
if (!mailRlt.succ)
{
@ -1036,7 +1039,7 @@ namespace Myshipping.Application
if (currBCOrder != null && model.IsDirectSend)
{
//异步推送邮件
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend);
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo,null, model.usePersonalEmailSend);
if (!mailRlt.succ)
{
@ -1204,7 +1207,7 @@ namespace Myshipping.Application
if (currBCOrder != null && model.IsDirectSend)
{
//异步推送邮件
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend);
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, null, model.usePersonalEmailSend);
if (!mailRlt.succ)
{
@ -1426,6 +1429,19 @@ namespace Myshipping.Application
bkModel.VOYNOINNER = taskBCInfo.CARRIER_VOYNO;
}
}
//处理自动对应场站
if (!string.IsNullOrWhiteSpace(taskBCInfo.TAKE_CTN_YARD))
{
var yardInfo = _cache.GetAllCodeYard().GetAwaiter().GetResult().FirstOrDefault(a => a.Code.Equals(taskBCInfo.TAKE_CTN_YARD));
if (yardInfo != null)
{
bkModel.YARDID = yardInfo.Code;
bkModel.YARD = yardInfo.Name;
}
}
//增加装货港、卸货港的对应
// 解析收货地,得到装货港名称及五字码
if (!string.IsNullOrWhiteSpace(taskBCInfo.PLACERECEIPT))
@ -1831,7 +1847,7 @@ namespace Myshipping.Application
/// <param name="bcTaskInfo">主任务详情</param>
/// <param name="usePersonalEmailSend">是否默认使用用户个人邮箱发送</param>
/// <returns>返回回执</returns>
private async Task<TaskManageOrderResultDto> GenerateSendEmail(TaskBCInfo taskBCInfo, TaskBaseInfo bcTaskInfo, bool usePersonalEmailSend = false)
private async Task<TaskManageOrderResultDto> GenerateSendEmail(TaskBCInfo taskBCInfo, TaskBaseInfo bcTaskInfo, Nullable<long> mandatoryBookingId = null, bool usePersonalEmailSend = false)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -1846,9 +1862,21 @@ namespace Myshipping.Application
*/
//读取订舱数据
var bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
BookingOrder bookingOrderEntity = null;
if(mandatoryBookingId.HasValue && mandatoryBookingId.Value> 0)
{
bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == mandatoryBookingId.Value);
}
else
{
bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == taskBCInfo.BOOKING_ORDER_ID);
}
var ctnList = _bookingCtnRepository.AsQueryable().Filter(null, true)
.Where(a => a.BILLID == mandatoryBookingId.Value).ToList();
if (bookingOrderEntity == null)
{
@ -1892,7 +1920,7 @@ namespace Myshipping.Application
string opEmail = string.Empty;
var bookingContactList = _bookingOrderContactRepository.AsQueryable().Filter(null, true)
.Where(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID).ToList();
.Where(a => a.BookingId == bookingOrderEntity.Id).ToList();
if (bookingContactList == null || bookingContactList.Count == 0)
{
@ -1956,7 +1984,15 @@ namespace Myshipping.Application
if (taskBCInfo.BUSI_TYPE == "BookingAmendment")
{
emailHtml = GenerateSendEmailHtmlAmendment(taskBCInfo, opUserInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult();
if (mandatoryBookingId.HasValue)
{
emailHtml = GenerateSendEmailHtmlAmendment(taskBCInfo, opUserInfo, UserManager.TENANT_NAME, bookingOrderEntity, ctnList).GetAwaiter().GetResult();
}
else
{
emailHtml = GenerateSendEmailHtmlAmendment(taskBCInfo, opUserInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult();
}
}
else
{
@ -1975,18 +2011,19 @@ namespace Myshipping.Application
else if (bcTaskInfo.TASK_BASE_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString())
{
//CMA没有变更附件所以转发邮件时默认用原文件转发
if(bcTaskInfo.CARRIER_ID.Equals("CMA",StringComparison.OrdinalIgnoreCase))
if (bcTaskInfo.CARRIER_ID.Equals("CMA", StringComparison.OrdinalIgnoreCase))
{
fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY"))
.OrderByDescending(a => a.CreatedTime).First();
}
else
{
fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY_NOTICE"))
.OrderByDescending(a => a.CreatedTime).First();
}
}
}
if (fileInfo == null)
{
@ -2004,6 +2041,22 @@ namespace Myshipping.Application
filePath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
if (mandatoryBookingId.HasValue)
{
//重新取BC文件
fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY"))
.OrderByDescending(a => a.CreatedTime).First();
filePath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
var newFilePath = await ReGenerateBAFile(bookingOrderEntity, ctnList, filePath);
if (!string.IsNullOrWhiteSpace(newFilePath))
filePath = Path.Combine(dirAbs, newFilePath);
SaveEDIFile(bookingOrderEntity.Id, filePath, new System.IO.FileInfo(filePath).Name, taskBCInfo.TenantId.Value,
"splitfile", "Booking Confirmation Split").GetAwaiter();
}
EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto
{
@ -2226,8 +2279,11 @@ namespace Myshipping.Application
/// <param name="taskBCInfo">BC任务详情</param>
/// <param name="opUserInfo">订舱OP详情</param>
/// <param name="tenantName">当前租户全称</param>
/// <param name="bookingOrder">相关订单详情</param>
/// <param name="ctnList">相关订单的集装箱列表</param>
/// <returns>返回生成的HTML</returns>
public async Task<string> GenerateSendEmailHtmlAmendment(TaskBCInfo taskBCInfo, SysUser opUserInfo, string tenantName)
public async Task<string> GenerateSendEmailHtmlAmendment(TaskBCInfo taskBCInfo, SysUser opUserInfo, string tenantName,
BookingOrder bookingOrder = null,List<BookingCtn> ctnList = null)
{
string result = string.Empty;
@ -2315,11 +2371,56 @@ namespace Myshipping.Application
{
if (baseTd.Attributes["class"].Value == "billno-val")
{
baseTd.InnerHtml = taskBCInfo.MBL_NO;
if (bookingOrder != null)
{
//如果是外港这里需要填正式的提单号
if (!bookingOrder.CUSTNO.Equals(bookingOrder.HBLNO))
{
if (!string.IsNullOrWhiteSpace(bookingOrder.PORTLOADID) && bookingOrder.PORTLOADID.Equals("CNTAO", StringComparison.OrdinalIgnoreCase))
{
baseTd.InnerHtml = bookingOrder.MBLNO;
}
else
{
baseTd.InnerHtml = bookingOrder.HBLNO;
}
}
else
{
baseTd.InnerHtml = bookingOrder.MBLNO;
}
}
else
{
baseTd.InnerHtml = taskBCInfo.MBL_NO;
}
}
else if (baseTd.Attributes["class"].Value == "takebillno-val")
{
baseTd.InnerHtml = taskBCInfo.MBL_NO;
if (bookingOrder != null)
{
//如果是外港这里需要填正式的提单号
if (!bookingOrder.CUSTNO.Equals(bookingOrder.HBLNO))
{
if (!string.IsNullOrWhiteSpace(bookingOrder.PORTLOADID) && bookingOrder.PORTLOADID.Equals("CNTAO", StringComparison.OrdinalIgnoreCase))
{
baseTd.InnerHtml = bookingOrder.HBLNO;
}
else
{
baseTd.InnerHtml = bookingOrder.MBLNO;
}
}
else
{
baseTd.InnerHtml = bookingOrder.MBLNO;
}
}
else
{
baseTd.InnerHtml = taskBCInfo.MBL_NO;
}
//baseTd.InnerHtml = taskBCInfo.MBL_NO;
}
else if (baseTd.Attributes["class"].Value == "pol-val")
{
@ -2331,7 +2432,14 @@ namespace Myshipping.Application
}
else if (baseTd.Attributes["class"].Value == "ctn-val")
{
baseTd.InnerHtml = taskBCInfo.CTN_STAT;
if (ctnList != null && ctnList.Count > 0)
{
baseTd.InnerHtml = string.Join(",", ctnList.GroupBy(a => a.CTNALL).Select(a => $"{a.Key}*{a.Sum(b => b.CTNNUM.HasValue ? b.CTNNUM.Value : 0)}").ToArray());
}
else
{
baseTd.InnerHtml = taskBCInfo.CTN_STAT;
}
}
/*
else if (baseTd.Attributes["class"].Value == "etd-val")
@ -2597,7 +2705,7 @@ namespace Myshipping.Application
/// <param name="usePersonalEmailSend">是否默认使用用户个人邮箱发送</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageBC/SendEmail")]
public async Task<TaskManageOrderResultDto> SendEmail(string taskPKId, bool usePersonalEmailSend = false)
public async Task<TaskManageOrderResultDto> SendEmail(string taskPKId, Nullable<long> mandatoryBookingId = null, bool usePersonalEmailSend = false )
{
if (string.IsNullOrWhiteSpace(taskPKId))
throw Oops.Oh($"BC任务主键不能为空");
@ -2613,7 +2721,7 @@ namespace Myshipping.Application
if (bcOrder == null)
throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息");
return await GenerateSendEmail(bcOrder, bcTaskInfo);
return await GenerateSendEmail(bcOrder, bcTaskInfo, mandatoryBookingId);
}
#endregion
@ -2715,6 +2823,9 @@ namespace Myshipping.Application
}
}
//这个先取一下与订单的关系
var searchOrder = await _bookingOrderService.SearchOrderInfo(bcOrder.MBL_NO);
_logger.LogInformation($"taskPKId={taskPKId} 判断是否默认转发邮件 paramConfig={JSON.Serialize(paramConfig)}");
if (!bcOrder.BOOKING_SLOT_ID.HasValue || bcOrder.BOOKING_SLOT_ID.Value == 0)
@ -2790,66 +2901,101 @@ namespace Myshipping.Application
}
}
//去关联的订舱ID
if(bcOrder.BOOKING_ORDER_ID == null || bcOrder.BOOKING_ORDER_ID.Value == 0)
//如果是拆票需要更新所有的拆票订单并根据修改BA文件的单号和箱型自动转发给客户
if (searchOrder.splitOrMergeFlag == 1)
{
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO, bcOrder.TenantId.Value).GetAwaiter().GetResult();
var orderIdList = new List<long> { searchOrder.currOrder.Id };
if (slotModel.HasBookingOrder)
if (searchOrder.otherOrderList.Count > 0)
orderIdList.AddRange(searchOrder.otherOrderList.Select(b => b.Id).ToList());
foreach (var bkid in orderIdList)
{
bcOrder.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault();
bcOrder.UpdatedTime = DateTime.Now;
bcOrder.UpdatedUserId = UserManager.UserId;
bcOrder.UpdatedUserName = UserManager.Name;
var currBCOrder = bcOrder.Adapt<TaskBCInfo>();
currBCOrder.BOOKING_ORDER_ID = bkid;
await UpdateBookingOrder(currBCOrder, taskPKId, true);
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
//如果值是ENABLE表示可以自动发送
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
{
it.BOOKING_ORDER_ID,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
}
}
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
if (bcOrder.BOOKING_ORDER_ID != null && bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value > 0)
{
await UpdateBookingOrder(bcOrder, taskPKId);
var emailRlt = await SendEmail(taskPKId, bkid);
_logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}");
}
else
{
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
}
}
}
else
{
_logger.LogInformation($"taskPKId={taskPKId} 更新订舱详情失败没有对应舱位ID");
}
//去关联的订舱ID
if (bcOrder.BOOKING_ORDER_ID == null || bcOrder.BOOKING_ORDER_ID.Value == 0)
{
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO, bcOrder.TenantId.Value).GetAwaiter().GetResult();
//如果值是ENABLE表示可以自动发送
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
{
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
if (slotModel.HasBookingOrder)
{
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_ORDER_ID,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
}
}
if (bcOrder.BOOKING_ORDER_ID != null && bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value > 0)
{
await UpdateBookingOrder(bcOrder, taskPKId);
}
else
{
_logger.LogInformation($"taskPKId={taskPKId} 更新订舱详情失败没有对应舱位ID");
}
var emailRlt = await SendEmail(taskPKId);
//如果值是ENABLE表示可以自动发送
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
{
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
_logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}");
var emailRlt = await SendEmail(taskPKId);
}
else
{
_logger.LogInformation($"taskPKId={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} 准备发送钉钉消息");
//if (dingdingConfig != null && dingdingConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
//{
// _logger.LogInformation($"taskPKId={taskPKId} 准备发送钉钉消息");
var emailRlt = await SendEmail(taskPKId);
// var emailRlt = await SendEmail(taskPKId);
_logger.LogInformation($"taskPKId={taskPKId} 发送钉钉消息完成 结果={JSON.Serialize(emailRlt)}");
// _logger.LogInformation($"taskPKId={taskPKId} 发送钉钉消息完成 结果={JSON.Serialize(emailRlt)}");
}
else
{
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
}
//}
//else
//{
// _logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
//}
result.succ = true;
result.msg = "执行成功";
@ -2871,7 +3017,7 @@ namespace Myshipping.Application
}
#endregion
private async Task UpdateBookingOrder(TaskBCInfo bcOrder,string taskPKId)
private async Task UpdateBookingOrder(TaskBCInfo bcOrder, string taskPKId, bool isAvoidUpdateCtn = false)
{
try
{
@ -3053,26 +3199,35 @@ namespace Myshipping.Application
bkModel.ChangedFields.Add(nameof(SaveBookingOrderInput.PLACERECEIPT));
bkModel.ChangedFields.Add(nameof(SaveBookingOrderInput.PLACERECEIPTID));
var taskBCCtnList = _taskBCCTNInfoRepository.AsQueryable().Filter(null, true).Where(a => a.P_ID == bcOrder.PK_ID && a.TenantId == UserManager.TENANT_ID).ToList();
if (!isAvoidUpdateCtn)
{
var taskBCCtnList = _taskBCCTNInfoRepository.AsQueryable().Filter(null, true).Where(a => a.P_ID == bcOrder.PK_ID && a.TenantId == UserManager.TENANT_ID).ToList();
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
if (taskBCCtnList.Count > 0)
{
taskBCCtnList.ForEach(t =>
if (taskBCCtnList.Count > 0)
{
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
BookingCtnDto ctn = new BookingCtnDto
taskBCCtnList.ForEach(t =>
{
CTNCODE = ctnCode?.Code,
CTNALL = t.CTNALL,
CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1
};
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
bkModel.ctnInputs.Add(ctn);
});
BookingCtnDto ctn = new BookingCtnDto
{
CTNCODE = ctnCode?.Code,
CTNALL = t.CTNALL,
CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1
};
bkModel.ctnInputs.Add(ctn);
});
}
}
else
{
var ctnList = _bookingCtnRepository.AsQueryable().Filter(null, true).Where(a => a.BILLID == bcOrder.BOOKING_ORDER_ID.Value).ToList();
bkModel.ctnInputs = ctnList.Select(b => b.Adapt<BookingCtnDto>()).ToList();
}
var bkRlt = await _bookingOrderService.Save(bkModel);
@ -4099,6 +4254,159 @@ namespace Myshipping.Application
return result;
}
#endregion
#region 重新获取生成BookingAmendment文件
/// <summary>
/// 重新获取生成BookingAmendment文件
/// </summary>
/// <param name="bookingOrder"></param>
/// <param name="ctnList"></param>
/// <param name="origFilePath"></param>
/// <returns></returns>
private async Task<string> ReGenerateBAFile(BookingOrder bookingOrder,List<BookingCtn> ctnList,string origFilePath)
{
DrawModifyBCConfig mConfig = new DrawModifyBCConfig {
drawTypeArg = new DrawModifyBCConfigTypeEnum[] { DrawModifyBCConfigTypeEnum.ChangeToSplitBillNo,DrawModifyBCConfigTypeEnum.SplitBC },
origBillNo = bookingOrder.CUSTNO,
newBillNo = bookingOrder.MBLNO,
newCtnNum = ctnList.Sum(a=> a.CTNNUM),
ctnAll = ctnList.FirstOrDefault().CTNALL
};
NameValueCollection modifyPar = new NameValueCollection();
modifyPar.Add("jsonMessage", JSON.Serialize(mConfig));
DynameFileInfo dynameFile = null;
var fileName = Path.GetFileName(origFilePath);
var fileBytes = File.ReadAllBytes(origFilePath);
if (fileBytes.Length > 0)
{
dynameFile = new DynameFileInfo
{
FileName = fileName,
FileBytes = fileBytes
};
}
string batchNo = IDGen.NextID().ToString();
byte[] modifyBytes = ModifyFile(modifyPar, dynameFile).GetAwaiter().GetResult();
var noExtensionFileName = Path.GetFileNameWithoutExtension(fileName);
return await FileAttachHelper.SaveFile(bookingOrder.Id.ToString(), modifyBytes, batchNo, noExtensionFileName,
GetFileType(origFilePath), "bcsplitnoticefiles");
}
#endregion
#region 获取文件类型
/// <summary>
/// 获取文件类型
/// </summary>
/// <param name="fileName">文件完成路径</param>
/// <returns>返回文件类型枚举</returns>
private PrintFileTypeEnum GetFileType(string fileName)
{
PrintFileTypeEnum fileType = PrintFileTypeEnum.PDF;
switch (Path.GetExtension(fileName).ToLower())
{
case ".pdf":
fileType = PrintFileTypeEnum.PDF;
break;
case ".xlsx":
fileType = PrintFileTypeEnum.XLSX;
break;
case ".docx":
fileType = PrintFileTypeEnum.DOCX;
break;
case ".xls":
fileType = PrintFileTypeEnum.XLS;
break;
case ".doc":
fileType = PrintFileTypeEnum.DOC;
break;
}
return fileType;
}
#endregion
#region 请求变更BookingAmendment后的文件
/// <summary>
/// 请求变更BookingAmendment后的文件
/// </summary>
/// <param name="nameValueCollection">请求参数</param>
/// <param name="fileInfo">文件</param>
/// <param name="contentType">请求类型</param>
/// <returns>返回回执</returns>
[NonAction]
private async Task<byte[]> ModifyFile(NameValueCollection nameValueCollection, dynamic fileInfo,
string contentType = "application/json")
{
//Stream ms = null;
byte[] bytes;
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, "file", 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(App.Configuration["BookingAmendModifyWebApiUrl"], reduceAttach).Result;
bytes = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
}
}
catch (Exception ex)
{
_logger.LogInformation("请求自动变更BookingAmendment文件内容异常原因{error}", ex.Message);
throw Oops.Oh($"请求自动变更BookingAmendment文件内容异常原因{ex.Message}");
}
}
return bytes;
}
#endregion
}
/// <summary>

@ -141,5 +141,6 @@
"BookingAmendReadWebApiUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentRead",
"SICompareUrl": "http://localhost:5110/api/TaskDraftCompare/ExcuteSISubmittedCompare",
"EmailNoticeUrl": "http://47.104.73.97:8801/mail/send",
"EmailNoticeDefaultUser": "jianghaiqing@myshipping.net"
"EmailNoticeDefaultUser": "jianghaiqing@myshipping.net",
"BookingAmendModifyWebApiUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ModifyBookingAmendmentFile"
}

@ -6,6 +6,7 @@ using Furion.FriendlyException;
using Furion.JsonSerialization;
using Furion.RemoteRequest.Extensions;
using HtmlAgilityPack;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.DependencyInjection;
@ -21,7 +22,11 @@ using System.Net.Http.Headers;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using RabbitMQ.Client;
using static System.Net.Mime.MediaTypeNames;
using RabbitMQ.Client.Events;
using Org.BouncyCastle.Utilities.Bzip2;
using ICSharpCode.SharpZipLib.BZip2;
Serve.RunGeneric(additional: services =>
{
@ -36,7 +41,7 @@ Console.WriteLine("开始准备同步历史服务状态数据");
var service1 = App.GetService<ISyncHisRecord>();
//service1.SyncServiceProjectRecord();
//service1.SyncServiceProjectRecord5();
service1.SyncServiceProjectRecord6();
service1.SyncServiceProjectRecord7();
Console.ReadKey();
public interface ISyncHisRecord
@ -45,7 +50,7 @@ public interface ISyncHisRecord
void SyncServiceProjectRecord5();
void SyncServiceProjectRecord6();
void SyncServiceProjectRecord7();
//void SyncServiceProjectRecord2();
//void SyncServiceProjectRecord3();
@ -1299,6 +1304,31 @@ public class SyncHisRecord: ISyncHisRecord,ITransient
}
public void SyncServiceProjectRecord7()
{
var factory = new ConnectionFactory
{
Uri = new Uri("amqp://hechuan_booking:hechuan_booking123@47.104.207.5:12567/hechuan_booking"),
};
var connection = factory.CreateConnection();
var channel = connection.CreateModel();
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
var message = System.Text.Encoding.UTF8.GetString(body);
var rf = SharpZipLib.Decompress(message);
Console.WriteLine(" [x] Received {0}", message);
};
channel.BasicConsume(queue: "djy.output.dingcang.ds6.529899258892357",
autoAck: true,
consumer: consumer);
}
public class ForInformationShipmentNotice
{
/// <summary>
@ -2739,4 +2769,51 @@ public static class StringUtilsExtension
return inputVal;
}
}
public class SharpZipLib
{
/// <summary>
/// 数据压缩
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string Compress(string input)
{
string result = string.Empty;
byte[] buffer = Encoding.UTF8.GetBytes(input);
using (MemoryStream outputStream = new MemoryStream())
{
using (BZip2OutputStream zipStream = new BZip2OutputStream(outputStream))
{
zipStream.Write(buffer, 0, buffer.Length);
zipStream.Close();
}
return Convert.ToBase64String(outputStream.ToArray());
}
}
/// <summary>
/// 数据解压缩
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string Decompress(string input)
{
string result = string.Empty;
byte[] buffer = Convert.FromBase64String(input);
using (Stream inputStream = new MemoryStream(buffer))
{
BZip2InputStream zipStream = new BZip2InputStream(inputStream);
using (StreamReader reader = new StreamReader(zipStream, Encoding.UTF8))
{
//输出
result = reader.ReadToEnd();
}
}
return result;
}
}

@ -10,7 +10,9 @@
<ItemGroup>
<PackageReference Include="Furion" Version="4.8.8.40" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="ICSharpCode.SharpZipLib.dll" Version="0.85.4.369" />
<PackageReference Include="MailKit" Version="4.1.0" />
<PackageReference Include="RabbitMQ.Client" Version="6.8.1" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.102" />
</ItemGroup>

Loading…
Cancel
Save