wet 2 years ago
commit 48621433b5

@ -0,0 +1,34 @@
using Myshipping.Application.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 任务报文表
/// </summary>
[SugarTable("task_store_msg")]
[Description(" 任务报文表")]
public class TaskStoreMsgInfo : TaskManageDbEntity
{
/// <summary>
/// 任务主键(父主键)
/// </summary>
public string TASK_PKID { get; set; }
/// <summary>
/// 报文JSON
/// </summary>
public string MSG_JSON { get; set; }
/// <summary>
/// 报文类型 BC_MSG-订舱确认报文
/// </summary>
public string MSG_TYPE { get; set; }
}
}

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 任务报文类型枚举
/// </summary>
public enum TaskStoreMsgTypeEnum
{
/// <summary>
/// 订舱确认报文
/// </summary>
[Description("订舱确认报文")]
BC_MSG,
}
}

@ -2850,6 +2850,7 @@ namespace Myshipping.Application
} }
#endregion #endregion
[NonAction]
public async Task<string> InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model) public async Task<string> InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model)
{ {
string batchNo = IDGen.NextID().ToString(); string batchNo = IDGen.NextID().ToString();
@ -3221,7 +3222,8 @@ namespace Myshipping.Application
/// <param name="id">订单主键</param> /// <param name="id">订单主键</param>
/// <param name="orderNo">订单号</param> /// <param name="orderNo">订单号</param>
/// <param name="useForwarderCode">是否使用货代代码</param> /// <param name="useForwarderCode">是否使用货代代码</param>
/// <param name="forwarderName">货代代码</param> /// <param name="forwarderCode">货代代码</param>
/// <param name="forwarderName">货代称呼</param>
/// <param name="fileRole">文件功能 (9原始,1 更新,5 退舱 )</param> /// <param name="fileRole">文件功能 (9原始,1 更新,5 退舱 )</param>
/// <param name="sendType">发送类型 B-订舱 E-截单</param> /// <param name="sendType">发送类型 B-订舱 E-截单</param>
/// <returns></returns> /// <returns></returns>

@ -43,5 +43,7 @@ namespace Myshipping.Application
Task<string> SendBookingOrClosingEDI (BookingOrClosingEDIOrderDto model); Task<string> SendBookingOrClosingEDI (BookingOrClosingEDIOrderDto model);
Task BachUpdate(BatchUpdate dto); Task BachUpdate(BatchUpdate dto);
Task<string> InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model);
} }
} }

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
///
/// </summary>
public class CalcLaraPageNumbersDto
{
/// <summary>
/// 请求LARA纸列表
/// </summary>
public List<LaraPaperRegistPostDto> paperList { get; set; }
/// <summary>
/// 当前任务主键
/// </summary>
public string taskPkId { get; set; }
/// <summary>
/// 移动方向 up-向上 down-向下
/// </summary>
public string moveType { get; set; } = "down";
/// <summary>
/// 上次结束编号
/// </summary>
public string numberTo { get; set; }
/// <summary>
/// 原始序号
/// </summary>
public Nullable<int> origIndex { get; set; }
/// <summary>
/// 现序号
/// </summary>
public Nullable<int> currIndex { get; set; }
}
}

@ -55,5 +55,20 @@ namespace Myshipping.Application
/// ///
/// </summary> /// </summary>
public string ISSUETYPE { get; set; } public string ISSUETYPE { get; set; }
/// <summary>
/// 排序值
/// </summary>
public decimal SortNo { get; set; }
/// <summary>
///
/// </summary>
public int DraftNum { get; set; }
/// <summary>
///
/// </summary>
public int LastNumberTo { get; set; }
} }
} }

@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 订舱确认结果
/// </summary>
public class TaskBCStoreResultInfo
{
/// <summary>
/// 单号
/// </summary>
[JsonPropertyName("bno")]
public string BNo { get; set; }
/// <summary>
/// 船名
/// </summary>
[JsonPropertyName("CM")]
public string Vessel { get; set; }
/// <summary>
/// 首程航次
/// </summary>
[JsonPropertyName("HC1")]
public string Voyno { get; set; }
/// <summary>
/// 二程航次
/// </summary>
[JsonPropertyName("HC2")]
public string Voyno2 { get; set; }
/// <summary>
/// 三程航次
/// </summary>
[JsonPropertyName("HC3")]
public string Voyno3 { get; set; }
/// <summary>
/// VGM时间
/// </summary>
[JsonPropertyName("VGMTIME")]
public string VGMTime { get; set; }
/// <summary>
/// ETD
/// </summary>
[JsonPropertyName("YJKHSJ")]
public string ETD { get; set; }
/// <summary>
/// 装货截关时间
/// </summary>
[JsonPropertyName("ZHQGSJ")]
public string ClosingDate { get; set; }
/// <summary>
/// 湿度
/// </summary>
[JsonPropertyName("humidity")]
public string Humidity { get; set; }
/// <summary>
/// 最低温度
/// </summary>
[JsonPropertyName("minimum_temperature")]
public string TempMin { get; set; }
/// <summary>
/// 最高温度
/// </summary>
[JsonPropertyName("maximum_temperature")]
public string TempMax { get; set; }
/// <summary>
/// 中转温度
/// </summary>
[JsonPropertyName("transport_temperature")]
public string TempTransport { get; set; }
/// <summary>
/// 卸货港英文名称
/// </summary>
[JsonPropertyName("XHG")]
public string PortDischargeEName { get; set; }
/// <summary>
/// 集装箱
/// </summary>
[JsonPropertyName("XXXL")]
public string CntrTotal { get; set; }
/// <summary>
/// 报价号
/// </summary>
[JsonPropertyName("BJH")]
public string BJH { get; set; }
/// <summary>
/// 服务合同号
/// </summary>
[JsonPropertyName("FWHT")]
public string FWHT { get; set; }
/// <summary>
/// 通风立方米
/// </summary>
[JsonPropertyName("ventilation_cubic_meter")]
public string VentilationCubicMeter { get; set; }
/// <summary>
/// 客人参考号
/// </summary>
[JsonPropertyName("guest_reference_number")]
public string GuestReferenceNumber { get; set; }
/// <summary>
/// 最终交货地
/// </summary>
[JsonPropertyName("ZZJHD")]
public string ZZJHD { get; set; }
}
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 任务扩展报文
/// </summary>
public class TaskManageOrderExtMessageInfo
{
/// <summary>
/// 序列化报文
/// </summary>
public string SerialMsg { get; set; }
/// <summary>
/// 序列化报文类型 JSON-JSON序列化
/// </summary>
public string SerialType { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public string BusiType { get; set; }
}
}

@ -112,5 +112,10 @@ namespace Myshipping.Application
/// 单票账单 /// 单票账单
/// </summary> /// </summary>
public TaskManageOrderPerBillInfo PerBillInfo { get; set; } public TaskManageOrderPerBillInfo PerBillInfo { get; set; }
/// <summary>
/// 序列化报文详情
/// </summary>
public TaskManageOrderExtMessageInfo SerialMsgInfo { get; set; }
} }
} }

@ -219,5 +219,48 @@ namespace Myshipping.Application
/// <returns>返回结果</returns> /// <returns>返回结果</returns>
Task<TaskChangeShipResultDto> GetAbortChangeShipInfo(string taskPKId); Task<TaskChangeShipResultDto> GetAbortChangeShipInfo(string taskPKId);
/// <summary>
/// 手工批量重新比对BC
/// </summary>
/// <param name="PKIds">任务主键数组</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> ManualReCompareBC(string[] PKIds);
/// <summary>
/// 下载截单EDI
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="orderNo">订单号</param>
/// <param name="useForwarderCode">是否使用货代代码</param>
/// <param name="forwarderCode">货代代码</param>
/// <param name="forwarderName">货代称呼</param>
/// <param name="fileRole">文件功能 (9原始,1 更新,5 退舱 )</param>
/// <param name="sendType">发送类型 B-订舱 E-截单</param>
/// <returns></returns>
Task<IActionResult> DownloadClosingEDI(string taskPKId, string orderNo, bool useForwarderCode,
string forwarderCode, string forwarderName, string fileRole, string sendType);
/// <summary>
/// 发送截单EDI
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="orderNo">订单号</param>
/// <param name="useForwarderCode">是否使用货代代码</param>
/// <param name="forwarderCode">货代代码</param>
/// <param name="forwarderName">货代称呼</param>
/// <param name="fileRole">文件功能 (9原始,1 更新,5 退舱 )</param>
/// <param name="sendType">发送类型 E-截单</param>
/// <returns>返回结果</returns>
Task<string> SendClosingEDI(string taskPKId, string orderNo, bool useForwarderCode,
string forwarderCode, string forwarderName, string fileRole, string sendType);
/// <summary>
/// 计算LARA纸计算页数
/// </summary>
/// <param name="model">请求LARA纸详情</param>
/// <returns>返回结果</returns>
Task<List<LaraPaperRegistPostDto>> CalcLaraPageNumbers(CalcLaraPageNumbersDto model);
} }
} }

@ -21,6 +21,7 @@ using Myshipping.Core.Entity;
using Myshipping.Core.Helper; using Myshipping.Core.Helper;
using Myshipping.Core.Service; using Myshipping.Core.Service;
using MySqlX.XDevAPI.Common; using MySqlX.XDevAPI.Common;
using NetTaste;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Npoi.Mapper; using Npoi.Mapper;
@ -34,7 +35,9 @@ using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.Util; using NPOI.Util;
using NPOI.XSSF.Model; using NPOI.XSSF.Model;
using Org.BouncyCastle.Asn1.Tsp;
using Org.BouncyCastle.Asn1.X500; using Org.BouncyCastle.Asn1.X500;
using Org.BouncyCastle.Asn1.X9;
using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Processing.Processors.Transforms;
using SqlSugar; using SqlSugar;
using StackExchange.Profiling.Internal; using StackExchange.Profiling.Internal;
@ -76,6 +79,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<TaskChargesHisInfo> _taskChargesHisInfoRepository; private readonly SqlSugarRepository<TaskChargesHisInfo> _taskChargesHisInfoRepository;
private readonly SqlSugarRepository<TaskLARAPaperInfo> _taskLARAPaperInfoRepository; private readonly SqlSugarRepository<TaskLARAPaperInfo> _taskLARAPaperInfoRepository;
private readonly SqlSugarRepository<TaskPerBillBaseInfo> _taskPerBillBaseInfoRepository; private readonly SqlSugarRepository<TaskPerBillBaseInfo> _taskPerBillBaseInfoRepository;
private readonly SqlSugarRepository<TaskStoreMsgInfo> _taskStoreMsgInfoRepository;
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository; private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository; private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository;
@ -88,6 +92,7 @@ namespace Myshipping.Application
private readonly ISysCacheService _cache; private readonly ISysCacheService _cache;
private readonly ILogger<BookingOrderService> _logger; private readonly ILogger<BookingOrderService> _logger;
private readonly INamedServiceProvider<IBookingOrderService> _namedBookingOrderServiceProvider;
const string CONST_WEB_ACCOUNT_TYPE = "CmaWeb"; const string CONST_WEB_ACCOUNT_TYPE = "CmaWeb";
const string CONST_BOOK_ORIGINAL_DOWN_URL_CODE = "bookOriginalDownUrl"; const string CONST_BOOK_ORIGINAL_DOWN_URL_CODE = "bookOriginalDownUrl";
@ -95,6 +100,11 @@ namespace Myshipping.Application
const string CONST_WEB_LARA_ACCOUNT_TYPE = "LaraWeb"; const string CONST_WEB_LARA_ACCOUNT_TYPE = "LaraWeb";
const string CONST_LARA_DOWN_URL_CODE = "LaraPaperPostUrl"; const string CONST_LARA_DOWN_URL_CODE = "LaraPaperPostUrl";
const string CONST_MAPPING_MODULE = "YunJia";
//LARA纸计算常量
const int LARA_PARER_DRAFT_VAR = 3;
public TaskManageService(SqlSugarRepository<TaskBaseInfo> taskBaseInfoRepository, public TaskManageService(SqlSugarRepository<TaskBaseInfo> taskBaseInfoRepository,
SqlSugarRepository<TaskSIFeedBackInfo> taskSIFeedBackInfoRepository, SqlSugarRepository<TaskSIFeedBackInfo> taskSIFeedBackInfoRepository,
SqlSugarRepository<TaskSIFeedBackContaInfo> taskSIFeedBackContaInfoRepository, SqlSugarRepository<TaskSIFeedBackContaInfo> taskSIFeedBackContaInfoRepository,
@ -113,6 +123,8 @@ namespace Myshipping.Application
SqlSugarRepository<BookingStatus> bookingStatusRepository, SqlSugarRepository<BookingStatus> bookingStatusRepository,
SqlSugarRepository<DjyUserMailAccount> djyUserMailAccountRepository, SqlSugarRepository<DjyUserMailAccount> djyUserMailAccountRepository,
SqlSugarRepository<TaskPerBillBaseInfo> taskPerBillBaseInfoRepository, SqlSugarRepository<TaskPerBillBaseInfo> taskPerBillBaseInfoRepository,
SqlSugarRepository<TaskStoreMsgInfo> taskStoreMsgInfoRepository,
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
IDjyWebsiteAccountConfigService webAccountConfig, IDjyWebsiteAccountConfigService webAccountConfig,
ISysCacheService cache, ISysCacheService cache,
ILogger<BookingOrderService> logger) ILogger<BookingOrderService> logger)
@ -135,6 +147,9 @@ namespace Myshipping.Application
_bookingStatusRepository = bookingStatusRepository; _bookingStatusRepository = bookingStatusRepository;
_djyUserMailAccountRepository = djyUserMailAccountRepository; _djyUserMailAccountRepository = djyUserMailAccountRepository;
_taskPerBillBaseInfoRepository = taskPerBillBaseInfoRepository; _taskPerBillBaseInfoRepository = taskPerBillBaseInfoRepository;
_taskStoreMsgInfoRepository = taskStoreMsgInfoRepository;
_namedBookingOrderServiceProvider = namedBookingOrderServiceProvider;
_webAccountConfig = webAccountConfig; _webAccountConfig = webAccountConfig;
_cache = cache; _cache = cache;
@ -367,6 +382,21 @@ namespace Myshipping.Application
}); });
} }
if (info.Main.SerialMsgInfo != null)
{
var storeInfo = new TaskStoreMsgInfo
{
PK_ID = IDGen.NextID().ToString(),
TASK_PKID = taskInfo.PK_ID,
MSG_JSON = info.Main.SerialMsgInfo.SerialMsg,
MSG_TYPE = info.Main.SerialMsgInfo.SerialType,
CreatedTime = taskInfo.CreatedTime,
UpdatedTime = taskInfo.CreatedTime,
};
await _taskStoreMsgInfoRepository.InsertAsync(storeInfo);
}
result.succ = true; result.succ = true;
result.msg = "新增任务成功"; result.msg = "新增任务成功";
} }
@ -3025,33 +3055,35 @@ namespace Myshipping.Application
TaskVgmCompareDto md = l.Adapt<TaskVgmCompareDto>(); TaskVgmCompareDto md = l.Adapt<TaskVgmCompareDto>();
md.compareDiffList = new List<string>();
if (currInfo != null) if (currInfo != null)
{ {
if(!l.SEALNO.Equals(currInfo.SEAL_NO)) if(l.SEALNO != currInfo.SEAL_NO)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo));
} }
if (!l.CTNCODE.Equals(currInfo.CONTA_TYPE)) if (l.CTNCODE != currInfo.CONTA_TYPE)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType));
} }
if (!l.CTNALL.Equals(currInfo.CONTA_TYPE_NAME)) if (l.CTNALL != currInfo.CONTA_TYPE_NAME)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName));
} }
if (!l.KGS.Equals(currInfo.KGS)) if (l.KGS != currInfo.KGS)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS));
} }
if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT)) if (l.TAREWEIGHT != currInfo.TAREWEIGHT)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight));
} }
if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS)) if (l.WEIGHKGS != currInfo.WEIGHKGS)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs));
} }
if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE)) if (l.WEIGHTYPE != currInfo.WEIGHTYPE)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType));
} }
@ -3079,33 +3111,35 @@ namespace Myshipping.Application
TaskVgmCompareDto md = l.Adapt<TaskVgmCompareDto>(); TaskVgmCompareDto md = l.Adapt<TaskVgmCompareDto>();
md.compareDiffList = new List<string>();
if (currInfo != null) if (currInfo != null)
{ {
if (!l.SEAL_NO.Equals(currInfo.SEALNO)) if (l.SEAL_NO != currInfo.SEALNO)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo));
} }
if (!l.CONTA_TYPE.Equals(currInfo.CTNCODE)) if (l.CONTA_TYPE != currInfo.CTNCODE)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType));
} }
if (!l.CONTA_TYPE_NAME.Equals(currInfo.CTNALL)) if (l.CONTA_TYPE_NAME != currInfo.CTNALL)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName));
} }
if (!l.KGS.Equals(currInfo.KGS)) if (l.KGS != currInfo.KGS)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS));
} }
if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT)) if (l.TAREWEIGHT != currInfo.TAREWEIGHT)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight));
} }
if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS)) if (l.WEIGHKGS != currInfo.WEIGHKGS)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs));
} }
if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE)) if (l.WEIGHTYPE != currInfo.WEIGHTYPE)
{ {
md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType)); md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType));
} }
@ -3404,6 +3438,683 @@ namespace Myshipping.Application
return model; return model;
} }
#endregion #endregion
#region 手工批量重新比对BC
/// <summary>
/// 手工批量重新比对BC
/// </summary>
/// <param name="PKIds">任务主键数组</param>
/// <returns>返回结果</returns>
[HttpPost("/TaskManage/ManualReCompareBC")]
public async Task<TaskManageOrderResultDto> ManualReCompareBC(string[] PKIds)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString();
_logger.LogInformation("批次={no} ids={ids} 手工批量重新比对BC开始", batchNo, string.Join(",", PKIds));
try
{
var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => PKIds.Contains(t.PK_ID)).ToList();
_logger.LogInformation("批次={no} 获取任务完成Num={Num}", batchNo, taskList.Count);
var list = new List<TaskManageOrderResultDto>();
taskList.ForEach(async tsk =>
{
var rlt = await InnerSingleManualReCompareBC(tsk);
list.Add(rlt);
});
if (list.Any(t => !t.succ))
{
result.msg = "失败";
result.succ = false;
}
else
{
result.msg = "成功";
result.succ = true;
}
}
catch (Exception ex)
{
throw Oops.Bah("手工批量重新比对BC异常,{0}", ex.Message);
}
return result;
}
#endregion
#region 手工单票重新比对BC
/// <summary>
/// 手工单票重新比对BC
/// </summary>
/// <param name="model">任务详情</param>
/// <returns>返回结果</returns>
private async Task<TaskManageOrderResultDto> InnerSingleManualReCompareBC(TaskBaseInfo model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
/*
1BC
*/
try
{
var storeInfo = await _taskStoreMsgInfoRepository.AsQueryable()
.Where(t => t.TASK_PKID == model.PK_ID && t.MSG_TYPE == TaskStoreMsgTypeEnum.BC_MSG.ToString()).FirstAsync();
if(storeInfo == null)
throw Oops.Oh("MBL_NO={0},获取{1}报文失败", model.MBL_NO,TaskStoreMsgTypeEnum.BC_MSG.GetDescription());
var rtl = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(storeInfo.MSG_JSON);
string msg = string.Empty;
//2023-02-02 测试过程中发现JSON数据格式有了变化这里增加兼容
if(rtl.mesage != null)
{
msg = JSON.Serialize(rtl.mesage);
}
else
{
msg = storeInfo.MSG_JSON;
}
if (string.IsNullOrWhiteSpace(msg))
throw Oops.Oh("MBL_NO={0},解析{1}报文详情异常", model.MBL_NO, TaskStoreMsgTypeEnum.BC_MSG.GetDescription());
var bookOrderList = _bookingOrderRepository.EntityContext.Queryable<BookingOrder>()
.InnerJoin<BookingCtn>((bk, ctn) => bk.Id == ctn.BILLID)
.Where((bk, ctn) => bk.Id == long.Parse(model.BOOK_ORDER_NO) && bk.TenantId == UserManager.TENANT_ID)
.Select((bk, ctn) => new { bk = bk, ctn = ctn }).ToList();
//获取订舱详情与BC进行比对
var orderInfo = bookOrderList.FirstOrDefault().bk;
List<BookingCtn> ctnList = new List<BookingCtn>();
if (bookOrderList.Any(t => t.ctn != null))
ctnList = bookOrderList.Select(t => t.ctn).ToList();
if (orderInfo == null)
throw Oops.Oh("MBL_NO={0},获取订舱详情失败", model.MBL_NO);
TaskBCStoreResultInfo bcStoreInfo = JSON.Deserialize<TaskBCStoreResultInfo>(msg);
//BC比较
var compareResult = InnerCompareBC(bcStoreInfo,orderInfo, ctnList);
if(!compareResult.succ)
{
//更新任务的反馈结果
model.RESULT_NOTE = compareResult.msg;
model.UpdatedTime = DateTime.Now;
model.UpdatedUserId = UserManager.UserId;
model.UpdatedUserName = UserManager.Name;
await _taskBaseInfoRepository.AsUpdateable(model).UpdateColumns(it => new
{
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName,
it.RESULT_NOTE,
}).ExecuteCommandAsync();
}
else
{
//置任务状态为完成
model.STATUS = TaskStatusEnum.Complete.ToString();
model.STATUS_NAME = TaskStatusEnum.Complete.GetDescription();
model.COMPLETE_DATE = DateTime.Now;
model.COMPLETE_DEAL = TaskCompleteDealEnum.MANUAL.ToString();
model.COMPLETE_DEAL_NAME = TaskCompleteDealEnum.MANUAL.GetDescription();
model.UpdatedTime = DateTime.Now;
model.UpdatedUserId = UserManager.UserId;
model.UpdatedUserName = UserManager.Name;
await _taskBaseInfoRepository.AsUpdateable(model).UpdateColumns(it => new
{
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName,
it.STATUS,
it.STATUS_NAME,
it.COMPLETE_DATE,
it.COMPLETE_DEAL,
it.COMPLETE_DEAL_NAME
}).ExecuteCommandAsync();
//更新订舱的ETD(记个日志)
if (!string.IsNullOrWhiteSpace(bcStoreInfo.ETD))
{
DateTime etd = DateTime.MinValue;
if(DateTime.TryParse(bcStoreInfo.ETD,out etd))
{
orderInfo.ETD = etd;
orderInfo.UpdatedTime = DateTime.Now;
orderInfo.UpdatedUserId = UserManager.UserId;
orderInfo.UpdatedUserName = UserManager.Name;
await _bookingOrderRepository.AsUpdateable(orderInfo).UpdateColumns(it => new
{
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName,
it.ETD
}).ExecuteCommandAsync();
}
}
//【预留】异步推送后台任务(订舱自动放舱-BookingFangCang
//【预留】异步推送后台任务(下货纸-Xiahuozhi
}
result.succ = true;
result.msg = "处理成功";
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"手工重新比对BC异常,{ex.Message}";
//throw Oops.Bah("手工重新比对BC异常,{0}", ex.Message);
}
return result;
}
#endregion
#region 单票比对BC
/// <summary>
/// 单票比对BC
/// </summary>
/// <param name="bcStoreInfo">BC回执详情</param>
/// <param name="orderInfo">订舱详情</param>
/// <param name="ctnList">订舱集装箱列表</param>
/// <returns>返回结果</returns>
private TaskManageOrderResultDto InnerCompareBC(TaskBCStoreResultInfo bcStoreInfo,BookingOrder orderInfo,List<BookingCtn> ctnList)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto { succ = true};
try
{
List<Tuple<bool, string>> rltTupleList = new List<Tuple<bool, string>>();
/*
2021-9-28BC
2021-7-19 BC
*/
//约号
if (!string.IsNullOrWhiteSpace(orderInfo.CONTRACTNO))
{
if ((string.IsNullOrWhiteSpace(bcStoreInfo.BJH) || !Regex.IsMatch(orderInfo.CONTRACTNO, $"\\b{bcStoreInfo.BJH.Trim()}\\b"))
&& (string.IsNullOrWhiteSpace(bcStoreInfo.FWHT) || !Regex.IsMatch(orderInfo.CONTRACTNO, $"\\b{bcStoreInfo.FWHT.Trim()}\\b")))
{
rltTupleList.Add(new Tuple<bool, string>(false, "约号不一致"));
}
}
else
{
if (!string.IsNullOrWhiteSpace(bcStoreInfo.BJH) || !string.IsNullOrWhiteSpace(bcStoreInfo.FWHT))
{
rltTupleList.Add(new Tuple<bool, string>(false, "约号不一致"));
}
}
#region 集装箱
//集装箱
if (bcStoreInfo.CntrTotal != orderInfo.CNTRTOTAL)
{
//集装箱型
var ediCtnList = _cache.GetAllMappingCtn().GetAwaiter().GetResult()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
&& !string.IsNullOrWhiteSpace(t.CarrierCode) && t.CarrierCode.Equals(orderInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)).ToList();
var storeCtnList = bcStoreInfo.CntrTotal.Split(new char[] { ';' }).Select(t =>
{
var currArg = t.Split(new char[] { 'x' });
return new { Code = currArg[1]?.Trim(), Num = int.Parse(currArg[0]?.Trim()) };
}).GroupBy(t => t.Code)
.Select(t =>
{
return new { Code = t.Key, Num = t.Sum(x => x.Num) };
}).ToList();
var orderCtnListctnList = ctnList.Select(t =>
{
var mapCtn = ediCtnList.FirstOrDefault(x => x.Code.Equals(t.CTNCODE));
if (mapCtn != null && !string.IsNullOrWhiteSpace(mapCtn.MapCode))
return new { Code = mapCtn.MapCode, Num = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1 };
return new { Code = t.CTNCODE, Num = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1 };
}).GroupBy(t => t.Code)
.Select(t =>
{
return new { Code = t.Key, Num = t.Sum(x => x.Num) };
}).ToList();
if (storeCtnList.Count != orderCtnListctnList.Count)
{
rltTupleList.Add(new Tuple<bool, string>(false, "箱型箱量不一致"));
}
else
{
var totalList = storeCtnList.GroupJoin(orderCtnListctnList, l => l.Code, r => r.Code, (l, r) =>
{
var rModel = r.FirstOrDefault();
if (rModel == null)
{
return false;
}
else
{
if (l.Num != rModel.Num)
return false;
}
return true;
}).ToList();
if (totalList.Any(t => !t))
{
rltTupleList.Add(new Tuple<bool, string>(false, "箱型箱量不一致"));
}
}
}
#endregion
//船名
if (bcStoreInfo.Vessel != orderInfo.VESSEL?.Trim())
{
rltTupleList.Add(new Tuple<bool, string>(false, "船名不一致"));
}
//航次
if (bcStoreInfo.Voyno?.Replace("1MA", "") != orderInfo.VOYNO?.Trim()
&& bcStoreInfo.Voyno2 != orderInfo.VOYNO?.Trim() && bcStoreInfo.Voyno3 != orderInfo.VOYNO?.Trim())
{
rltTupleList.Add(new Tuple<bool, string>(false, "航次不一致"));
}
/*
//2021-10-12增加最小、最大、运输温度湿度通风 的比较
//2021-11-23备注中含有NOR不比较温度湿度等信息
2023-02-02 EDIREMARKNORNOR()
*/
if (orderInfo.CARGOID == "R" && (string.IsNullOrWhiteSpace(orderInfo.SOREMARK) || !Regex.IsMatch(orderInfo.SOREMARK, "\\bNOR\\b")))
{
//最低温度
var compareReult = CompareTemperatureNum(orderInfo.TEMPMIN, bcStoreInfo.TempMin, "temp");
if (!compareReult.Item1)
rltTupleList.Add(compareReult);
//最高温度
compareReult = CompareTemperatureNum(orderInfo.TEMPMAX, bcStoreInfo.TempMax, "temp", "最高温度");
if (!compareReult.Item1)
rltTupleList.Add(compareReult);
//运输温度
compareReult = CompareTemperatureNum(orderInfo.TEMPSET, bcStoreInfo.TempTransport, "temp", "运输温度");
if (!compareReult.Item1)
rltTupleList.Add(compareReult);
//湿度
compareReult = CompareTemperatureNum(orderInfo.HUMIDITY, bcStoreInfo.Humidity, "humidity", "湿度");
if (!compareReult.Item1)
rltTupleList.Add(compareReult);
//通风
compareReult = CompareTemperatureNum(orderInfo.REEFERF, bcStoreInfo.VentilationCubicMeter, "vent", "通风");
if (!compareReult.Item1)
rltTupleList.Add(compareReult);
}
/*
* 2021-12-3
* ABC
* 1.
* 2.
* Bbc
*/
string orderPortDischarge = orderInfo.PORTDISCHARGE.Split(new char[] { ',' }).FirstOrDefault()?.Trim();
string storePortDischarge = bcStoreInfo.PortDischargeEName.Split(new char[] { ',' }).FirstOrDefault()?.Trim();
if (orderPortDischarge != storePortDischarge)
rltTupleList.Add(new Tuple<bool, string>(false, "卸货港不一致"));
string orderDest = orderInfo.DESTINATION.Split(new char[] { ',' }).FirstOrDefault()?.Trim();
string storeDest = bcStoreInfo.ZZJHD.Split(new char[] { ',' }).FirstOrDefault()?.Trim();
if (orderDest != storeDest)
rltTupleList.Add(new Tuple<bool, string>(false, "目的地不一致"));
if (rltTupleList.Any(t => !t.Item1))
{
result.succ = false;
result.msg = string.Join(";", rltTupleList.Select(t => t.Item2).ToArray());
}
}
catch(Exception ex)
{
throw Oops.Bah("{0}单票比对BC异常,{1}",nameof(InnerCompareBC), ex.Message);
}
return result;
}
#endregion
#region 对比温度
/// <summary>
/// 对比温度
/// </summary>
/// <param name="orderTemperature">订舱数值</param>
/// <param name="storeTemperature">回执数值</param>
/// <param name="operType">操作类型 temp-温度 humidity-湿度 vent-通风</param>
/// <param name="showName">显示名称</param>
/// <returns>返回结果</returns>
private Tuple<bool, string> CompareTemperatureNum(string orderTemperature,string storeTemperature,string operType = "temp",string showName = "最低温度")
{
decimal orderTemp = int.MaxValue;
decimal storeTemp = int.MaxValue;
decimal.TryParse(orderTemperature, out orderTemp);
if (!string.IsNullOrWhiteSpace(storeTemperature))
{
if (operType == "temp")
{
decimal.TryParse(Regex.Match(storeTemperature, "(\\-?([0-9]?|[0-9]+)\\.?[0-9]+)(?=C)").Value, out storeTemp);
}
else if (operType == "humidity")
{
decimal.TryParse(Regex.Match(storeTemperature, "\\[0-9]+").Value, out storeTemp);
}
else if (operType == "vent")
{
decimal.TryParse(storeTemperature, out storeTemp);
}
}
if (storeTemp != int.MaxValue && orderTemp != int.MaxValue)
{
if (storeTemp != orderTemp)
return new Tuple<bool, string>(false, $"{showName}不一致");
}
else
{
if (storeTemp != int.MaxValue || orderTemp != int.MaxValue)
return new Tuple<bool, string>(false, $"{showName}不一致");
}
return new Tuple<bool, string>(true, "");
}
#endregion
#region 下载截单EDI
/// <summary>
/// 下载截单EDI
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="orderNo">订单号</param>
/// <param name="useForwarderCode">是否使用货代代码</param>
/// <param name="forwarderCode">货代代码</param>
/// <param name="forwarderName">货代称呼</param>
/// <param name="fileRole">文件功能 (9原始,1 更新,5 退舱 )</param>
/// <param name="sendType">发送类型 E-截单</param>
/// <returns>返回结果</returns>
[HttpGet("/TaskManage/DownloadClosingEDI")]
public async Task<IActionResult> DownloadClosingEDI([FromQuery] string taskPKId, [FromQuery] string orderNo, [FromQuery] bool useForwarderCode,
[FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType)
{
if (sendType?.ToUpper() != "E")
throw Oops.Oh($"sendType只接收E-截单");
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId);
if (taskInfo == null)
throw Oops.Oh($"任务信息获取失败");
if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO))
throw Oops.Oh($"任务信息的订舱主键不存在");
if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString())
throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}");
BookingOrder bookingOrder = null;
if (!string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO))
bookingOrder = _bookingOrderRepository.AsQueryable().First(t => t.Id == long.Parse(taskInfo.BOOK_ORDER_NO));
if (bookingOrder == null)
throw Oops.Oh($"订舱信息获取失败MBLNO={taskInfo.MBL_NO}");
var model = new BookingOrClosingEDIOrderDto
{
Id = bookingOrder.Id,
orderNo = orderNo,
useForwarderCode = useForwarderCode,
forwarderCode = forwarderCode,
forwarderName = forwarderName,
fileRole = fileRole,
send = false,
sendType = sendType
};
var bookingOrderService = _namedBookingOrderServiceProvider.GetService<ITransient>(nameof(BookingOrderService));
var filePath = await bookingOrderService.InnerBookingOrClosingEDI(model);
var fileInfo = new FileInfo(filePath);
var result = new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileInfo.Name };
return result;
}
#endregion
#region 发送截单EDI
/// <summary>
/// 发送截单EDI
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="orderNo">订单号</param>
/// <param name="useForwarderCode">是否使用货代代码</param>
/// <param name="forwarderCode">货代代码</param>
/// <param name="forwarderName">货代称呼</param>
/// <param name="fileRole">文件功能 (9原始,1 更新,5 退舱 )</param>
/// <param name="sendType">发送类型 E-截单</param>
/// <returns>返回结果</returns>
[HttpGet("/TaskManage/SendClosingEDI")]
public async Task<string> SendClosingEDI([FromQuery] string taskPKId, [FromQuery] string orderNo, [FromQuery] bool useForwarderCode,
[FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType)
{
if (sendType?.ToUpper() != "E")
throw Oops.Oh($"sendType只接收E-截单");
var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId);
if (taskInfo == null)
throw Oops.Oh($"任务信息获取失败");
if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO))
throw Oops.Oh($"任务信息的订舱主键不存在");
if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString())
throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}");
BookingOrder bookingOrder = null;
if (!string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO))
bookingOrder = _bookingOrderRepository.AsQueryable().First(t => t.Id == long.Parse(taskInfo.BOOK_ORDER_NO));
if (bookingOrder == null)
throw Oops.Oh($"订舱信息获取失败MBLNO={taskInfo.MBL_NO}");
var model = new BookingOrClosingEDIOrderDto
{
Id = bookingOrder.Id,
orderNo = orderNo,
useForwarderCode = useForwarderCode,
forwarderCode = forwarderCode,
forwarderName = forwarderName,
fileRole = fileRole,
send = true,
sendType = sendType
};
var bookingOrderService = _namedBookingOrderServiceProvider.GetService<ITransient>(nameof(BookingOrderService));
return await bookingOrderService.InnerBookingOrClosingEDI(model);
}
#endregion
#region 计算LARA纸计算页数
/// <summary>
/// 计算LARA纸计算页数
/// </summary>
/// <param name="model">请求LARA纸详情</param>
/// <returns>返回结果</returns>
[HttpPost("/TaskManage/CalcLaraPageNumbers")]
public async Task<List<LaraPaperRegistPostDto>> CalcLaraPageNumbers(CalcLaraPageNumbersDto model)
{
List<LaraPaperRegistPostDto> list = new List<LaraPaperRegistPostDto>();
/*
LARA
1model.moveTypeInitCalcLaraPageNumbers
2 model.moveType
*/
try
{
if(string.IsNullOrWhiteSpace(model.moveType))
{
list = InnerCalcLaraPageNumbers(model,true);
}
else
{
list = InnerCalcLaraPageNumbers(model);
}
}
catch (Exception ex)
{
throw Oops.Bah("计算LARA纸计算页数异常,{0}", ex.Message);
}
return list;
}
#endregion
#region 计算LARA纸
/// <summary>
/// 计算LARA纸
/// </summary>
/// <param name="model">请求LARA纸详情</param>
/// <param name="isInit">是否初始化 true-初始化</param>
/// <returns></returns>
private List<LaraPaperRegistPostDto> InnerCalcLaraPageNumbers(CalcLaraPageNumbersDto model,bool isInit = false)
{
List<LaraPaperRegistPostDto> list = new List<LaraPaperRegistPostDto>();
//如果判断不是首次加载,需要将移动的行从列表移动到指定位置后,重新计算。
if(!isInit)
{
model.paperList = model.paperList.Select(t =>
{
if (t.SortNo == model.origIndex.Value)
{
//up
if(model.currIndex < model.origIndex)
{
t.SortNo = (decimal)model.currIndex.Value - 0.1m;
}
else
{
t.SortNo = (decimal)model.currIndex.Value + 0.1m;
}
}
return t;
}).OrderBy(t => t.SortNo)
.Select((t, idx) =>
{
t.SortNo = (decimal)idx + 1;
return t;
}).ToList();
}
var mNumberTo = int.Parse(model.numberTo.TrimStart('0'));
if (mNumberTo > 0)
{
int lastNumberTo = 0;
int lastNumberFrom = 0;
model.paperList.OrderBy(t => t.SortNo).ToList().ForEach(t =>
{
LaraPaperRegistPostDto info = new LaraPaperRegistPostDto();
info.SortNo = t.SortNo;
info.DraftNum = t.DraftNum;
info.TaskId = t.TaskId;
info.ORDNO = t.ORDNO;
info.MBLNO = t.MBLNO;
info.ISSUETYPE = t.ISSUETYPE;
if (t.SortNo == 1)
{
lastNumberFrom = mNumberTo + 1;
info.NumberFrom = (lastNumberFrom).ToString().PadLeft(9, '0');
var currNumberTo = (t.DraftNum * LARA_PARER_DRAFT_VAR) + mNumberTo;
info.NumberTo = currNumberTo.ToString().PadLeft(9, '0');
info.PageSum = currNumberTo - lastNumberFrom + 1;
lastNumberTo = currNumberTo;
}
else
{
lastNumberFrom = lastNumberTo + 1;
info.NumberFrom = (lastNumberFrom).ToString().PadLeft(9, '0');
var currNumberTo = (t.DraftNum * LARA_PARER_DRAFT_VAR) + lastNumberTo;
info.NumberTo = currNumberTo.ToString().PadLeft(9, '0');
info.PageSum = currNumberTo - lastNumberFrom + 1;
lastNumberTo = currNumberTo;
}
list.Add(info);
});
}
return list;
}
#endregion
} }
#region 样本业务提取帮助类 #region 样本业务提取帮助类

Loading…
Cancel
Save