cjy 3 months ago
commit d5d56b6548

@ -40,8 +40,8 @@ namespace DS.Module.Core
/// <summary> /// <summary>
/// BC对比订单后是否存在差异 /// BC对比订单后是否存在差异
/// </summary> /// </summary>
/// <remarks>类型:CompareResultInfo</remarks> /// <remarks>类型:<see cref="bool" /></remarks>
public const string BcCompareWithSeaExportResult = "BcCompareWithSeaExportResult"; public const string BcCompareBcWithSeaExportIsExistsDiff = "BcCompareBcWithSeaExportIsExistsDiff";
/// <summary> /// <summary>
/// BC文件 /// BC文件

@ -2,7 +2,7 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ActiveDebugProfile>http</ActiveDebugProfile> <ActiveDebugProfile>http</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>D:\Code\DS\ds8-solution-pro\ds-wms-service\DS.WMS.AdminApi\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile> <NameOfLastUsedPublishProfile>D:\Source\Repos\DS8\ds-wms-service\DS.WMS.AdminApi\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor> <DebuggerFlavor>ProjectDebugger</DebuggerFlavor>

@ -490,35 +490,5 @@ namespace DS.WMS.Core.Op.Dtos
/// 还箱场站 /// 还箱场站
/// </summary> /// </summary>
public string ReturnCTNYard { get; set; } public string ReturnCTNYard { get; set; }
/// <summary>
/// 温度单位
/// </summary>
public string TempUnit{ get; set; }
/// <summary>
/// 设置温度
/// </summary>
public string TempSet { get; set; }
/// <summary>
/// 最低温度
/// </summary>
public string TempMin { get; set; }
/// <summary>
/// 最高温度
/// </summary>
public string TempMax { get; set; }
/// <summary>
/// 湿度
/// </summary>
public string Humidity { get; set; }
/// <summary>
/// 冷藏通风量
/// </summary>
public string Reeferf { get; set; }
} }
} }

@ -7,6 +7,9 @@ using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.Op.Interface.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction;
using Masuit.Tools.Systems; using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using DS.WMS.Core.Sys.Interface;
using DS.Module.UserModule;
using DS.WMS.Core.Sys.Entity;
namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease
{ {
@ -15,29 +18,36 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease
/// </summary> /// </summary>
public class SpaceReleaseActionExecutor : DefaultActionExecutor public class SpaceReleaseActionExecutor : DefaultActionExecutor
{ {
/// <summary> ///// <summary>
/// 任务服务 ///// 任务服务
/// </summary> ///// </summary>
protected ISeaExportService OpService; //protected ISeaExportService OpService;
/// <summary> /// <summary>
/// 日志服务 /// 日志服务
/// </summary> /// </summary>
protected ITaskLogService LogService; protected ITaskLogService LogService;
/// <summary>
/// 客户参数服务
/// </summary>
protected IClientParamService ClientParamService;
public override async Task ExecuteAsync(ActionExecutionContext context) public override async Task ExecuteAsync(ActionExecutionContext context)
{ {
OpService = context.ServiceProvider.GetRequiredService<ISeaExportService>(); //OpService = context.ServiceProvider.GetRequiredService<ISeaExportService>();
LogService = context.ServiceProvider.GetRequiredService<ITaskLogService>(); LogService = context.ServiceProvider.GetRequiredService<ITaskLogService>();
ClientParamService = context.ServiceProvider.GetRequiredService<IClientParamService>(); var releaseTypeService = context.ServiceProvider.GetRequiredService<IReleaseTypeService>();
var typeValue = await releaseTypeService.GetReleaseTypeAsync(context.TaskInfo.BusinessId, context.TaskInfo.BusinessType);
switch (typeValue)
{
case SpaceReleaseType.RelayBC:
await RelayBCAsync(context);
break;
case SpaceReleaseType.IncomingNotification:
await SendIncomingNotificationAsync(context);
break;
}
var param2 = await ClientParamService.GetParamAsync<bool?>(context.TaskInfo.BusinessId, "SendXHZ", (x, y) => x.CustomerId == y.YardId); var clientParamService = context.ServiceProvider.GetRequiredService<IClientParamService>();
var param = await clientParamService.GetParamAsync<bool?>(context.TaskInfo.BusinessId, "SendXHZ", (x, y) => x.CustomerId == y.YardId);
if (param.Value.GetValueOrDefault())
await SendShippingOrderAsync(context);
} }
//入货通知 //入货通知
@ -93,9 +103,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease
} }
//转发BC //转发BC
async Task RelayBCAsync(ActionExecutionContext context) async Task RelayBCAsync(ActionExecutionContext context)
{ {
} }
//下货纸 //下货纸
@ -114,5 +124,5 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease
} }
} }

@ -527,7 +527,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (useTransaction) if (useTransaction)
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
//ActionService.Value.TriggerActionAsync(task); ActionService.TriggerActionAsync(task);
return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null); return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null);
} }
catch (Exception ex) catch (Exception ex)

@ -11,11 +11,23 @@ namespace DS.WMS.Core.Sys.Entity
[SugarTable("sys_release_type")] [SugarTable("sys_release_type")]
public class SysReleaseType : BaseModelV2<long> public class SysReleaseType : BaseModelV2<long>
{ {
/// <summary>
/// 委托单位ID
/// </summary>
[SugarColumn(ColumnDescription = "委托单位ID", IsNullable = true)]
public long? CustomerId { get; set; }
/// <summary>
/// 委托单位名称
/// </summary>
[SugarColumn(IsIgnore = true)]
public string? CustomerName { get; set; }
/// <summary> /// <summary>
/// 承运商(船公司/航空公司) /// 承运商(船公司/航空公司)
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "承运商(船公司/航空公司)", Length = 50, IsNullable = false)] [SugarColumn(ColumnDescription = "承运商(船公司/航空公司)", Length = 50, IsNullable = true)]
public string Carrier { get; set; } = string.Empty; public string? Carrier { get; set; }
/// <summary> /// <summary>
/// 起运港代码 /// 起运港代码

@ -1,4 +1,5 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Entity;
namespace DS.WMS.Core.Sys.Interface namespace DS.WMS.Core.Sys.Interface
@ -16,6 +17,14 @@ namespace DS.WMS.Core.Sys.Interface
/// <returns></returns> /// <returns></returns>
Task<DataResult<List<SysReleaseType>>> GetListAsync(PageRequest request, bool isAdmin = false); Task<DataResult<List<SysReleaseType>>> GetListAsync(PageRequest request, bool isAdmin = false);
/// <summary>
/// 根据业务数据匹配放舱方式
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
Task<SpaceReleaseType?> GetReleaseTypeAsync(long businessId, BusinessType businessType);
/// <summary> /// <summary>
/// 详情 /// 详情
/// </summary> /// </summary>

@ -1,5 +1,9 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface; using DS.WMS.Core.Sys.Interface;
@ -16,6 +20,7 @@ namespace DS.WMS.Core.Sys.Method
/// <param name="provider"></param> /// <param name="provider"></param>
public ReleaseTypeService(IServiceProvider provider) : base(provider) public ReleaseTypeService(IServiceProvider provider) : base(provider)
{ {
TenantDb.QueryFilter.Clear<IOrgId>();
} }
/// <summary> /// <summary>
@ -28,12 +33,73 @@ namespace DS.WMS.Core.Sys.Method
{ {
var whereList = request.GetConditionalModels(Db); var whereList = request.GetConditionalModels(Db);
var tenantId = long.Parse(User.TenantId); var tenantId = long.Parse(User.TenantId);
var data = await Db.Queryable<SysReleaseType>().Where(whereList) var data = await Db.Queryable<SysReleaseType>()
.WhereIF(!isAdmin, x => x.TenantId == tenantId) .Where(whereList).WhereIF(!isAdmin, x => x.TenantId == tenantId)
.ToQueryPageAsync(request.PageCondition); .ToQueryPageAsync(request.PageCondition);
if (data.Data?.Count > 0)
{
var ids = data.Data.Where(x => x.CustomerId.HasValue).Select(x => x.CustomerId.Value);
var list = await TenantDb.Queryable<InfoClient>().Where(x => ids.Contains(x.Id)).Select(x => new { x.Id, x.ShortName }).ToListAsync();
foreach (var item in data.Data)
item.CustomerName = list.Find(x => x.Id == item.CustomerId)?.ShortName;
}
return data; return data;
} }
/// <summary>
/// 根据业务数据匹配放舱方式
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
public async Task<SpaceReleaseType?> GetReleaseTypeAsync(long businessId, BusinessType businessType)
{
SpaceReleaseType? releaseType = null;
switch (businessType)
{
case BusinessType.OceanShippingExport:
var order1 = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == businessId)
.LeftJoin<CodeCarrier>((x, y) => x.CarrierId == y.Id)
.Select((x, y) => new
{
x.CustomerId,
x.LoadPortCode,
CarrierCode = y.Code
}).FirstAsync();
if (order1 == null)
return null;
long tid = long.Parse(User.TenantId);
var list = await Db.Queryable<SysReleaseType>().Where(x => x.TenantId == tid && x.CustomerId == order1.CustomerId && x.LoadingPort == order1.LoadPortCode)
.Select(x => new { x.Carrier, x.ReleaseType }).ToListAsync();
var clientItem = list.Find(x => x.Carrier == order1.CarrierCode);
if (clientItem != null)
return clientItem.ReleaseType;
if (list.Count > 0) //返回默认船公司的配置
return list[0].ReleaseType;
//租户端无匹配的设置,需要从管理端获取全局参数
var list2 = await Db.Queryable<SysReleaseType>().Where(x => x.TenantId == null && x.LoadingPort == order1.LoadPortCode)
.Select(x => new { x.Carrier, x.ReleaseType }).ToListAsync();
var adminItem = list2.Find(x => x.Carrier == order1.CarrierCode);
if (adminItem != null)
return adminItem.ReleaseType;
if (list2.Count > 0)
return list[0].ReleaseType;
break;
case BusinessType.OceanShippingImport:
break;
}
return releaseType;
}
/// <summary> /// <summary>
/// 详情 /// 详情
/// </summary> /// </summary>
@ -61,9 +127,10 @@ namespace DS.WMS.Core.Sys.Method
{ {
rows = await Db.Updateable(entity).UpdateColumns(x => new rows = await Db.Updateable(entity).UpdateColumns(x => new
{ {
x.CustomerId,
x.Carrier, x.Carrier,
x.LoadingPort, x.LoadingPort,
x.ReleaseType, x.ReleaseType
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
} }

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.TaskPlat
{
/// <summary>
///
/// </summary>
public class BCReadResultDto
{
/// <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; }
}
}

@ -47,6 +47,22 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <summary> /// <summary>
/// 对比BC与海运出口订单 /// 对比BC与海运出口订单
/// </summary> /// </summary>
Task<DataResult<CompareResultInfo>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext); Task<DataResult<(bool isExistsDiff, List<CompareResultDetailInfo>)>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext);
/// <summary>
/// 读取BC详情
/// </summary>
/// <param name="carrierCode">船公司代码</param>
/// <param name="file">BC文件</param>
/// <returns>返回解析详情</returns>
Task<DataResult<ParserBCInfoDto>> GetReadBC(string carrierCode, IFormFile file);
/// <summary>
/// 读取BC擦写后文件流
/// </summary>
/// <param name="carrierCode">船公司代码</param>
/// <param name="file">BC文件</param>
/// <returns>返回解析详情</returns>
Task<DataResult<byte[]>> GetModifyBCFile(string carrierCode, IFormFile file);
} }
} }

@ -25,12 +25,16 @@ using DS.WMS.Core.TaskPlat.Interface;
using HtmlAgilityPack; using HtmlAgilityPack;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog; using NLog;
using SqlSugar; using SqlSugar;
using System.Web;
using System.Net.Http.Headers;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Text;
namespace DS.WMS.Core.TaskPlat.Method namespace DS.WMS.Core.TaskPlat.Method
{ {
@ -50,6 +54,11 @@ namespace DS.WMS.Core.TaskPlat.Method
private readonly IWebHostEnvironment _environment; private readonly IWebHostEnvironment _environment;
private readonly ISqlSugarClient db; private readonly ISqlSugarClient db;
private readonly string bcCompareUrl;
private readonly string bcMSKReadUrl;
private readonly string bcMSKModifyFileUrl;
private readonly string bcCMAReadUrl;
// 按需构建 // 按需构建
private Lazy<IBookingSlotService> bookingSlotService; private Lazy<IBookingSlotService> bookingSlotService;
private Lazy<ISeaExportService> seaExportService; private Lazy<ISeaExportService> seaExportService;
@ -65,6 +74,7 @@ namespace DS.WMS.Core.TaskPlat.Method
//自动转发是否默认抄送操作 //自动转发是否默认抄送操作
const string CONST_AUTO_TRANS_EMAIL_OP_CCTO = "AUTO_TRANS_EMAIL_OP_CCTO"; const string CONST_AUTO_TRANS_EMAIL_OP_CCTO = "AUTO_TRANS_EMAIL_OP_CCTO";
public TaskManageBCService(IUser user, public TaskManageBCService(IUser user,
ILogger<TaskManageBCService> logger, ILogger<TaskManageBCService> logger,
@ -97,6 +107,11 @@ namespace DS.WMS.Core.TaskPlat.Method
tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
tenantDb.QueryFilter.Clear<IOrgId>(); tenantDb.QueryFilter.Clear<IOrgId>();
bcCompareUrl = AppSetting.app(new string[] { "BCCompare", "Url" });
bcMSKReadUrl = AppSetting.app(new string[] { "BCCompare", "MSKBCReadUrl" });
bcMSKModifyFileUrl = AppSetting.app(new string[] { "BCCompare", "MSKBCModifyFileUrl" });
bcCMAReadUrl = AppSetting.app(new string[] { "BCCompare", "CMABCReadUrl" });
} }
/// <summary> /// <summary>
@ -1121,12 +1136,12 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <summary> /// <summary>
/// 对比BC与海运出口订单任务台使用 /// 对比BC与海运出口订单任务台使用
/// </summary> /// </summary>
public async Task<DataResult<CompareResultInfo>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext) public async Task<DataResult<(bool isExistsDiff, List<CompareResultDetailInfo>)>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext)
{ {
var taskBcInfo = dataContext.Get<TaskBCInfo?>(TaskFlowDataNameConst.TaskBCInfo) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCInfo)}"); var taskBcInfo = dataContext.Get<TaskBCInfo?>(TaskFlowDataNameConst.TaskBCInfo) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCInfo)}");
var taskBcCtnList = dataContext.Get<List<TaskBCCTNInfo>?>(TaskFlowDataNameConst.TaskBCCtnList) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCCtnList)}"); var taskBcCtnList = dataContext.Get<List<TaskBCCTNInfo>?>(TaskFlowDataNameConst.TaskBCCtnList) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCCtnList)}");
var seaExport = await tenantDb.Queryable<SeaExport>().Where(x => x.ParentId == 0 && taskBcInfo.MBL_NO == x.MBLNO).Select(x => new SeaExport() var seaExport = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID).Select(x => new SeaExport()
{ {
Id = x.Id, Id = x.Id,
MBLNO = x.MBLNO, MBLNO = x.MBLNO,
@ -1159,19 +1174,18 @@ namespace DS.WMS.Core.TaskPlat.Method
SeaExport = seaExport, SeaExport = seaExport,
OpCtnList = seaExportCtnList OpCtnList = seaExportCtnList
}; };
var result = await CompareBcWithSeaExport(compareDto); (bool isExistsDiff, List<CompareResultDetailInfo>) result = await CompareBcWithSeaExport(compareDto);
dataContext.Set(TaskFlowDataNameConst.BcCompareWithSeaExportResult, result); dataContext.Set(TaskFlowDataNameConst.BcCompareBcWithSeaExportIsExistsDiff, result.isExistsDiff);
return DataResult<CompareResultInfo>.Success(result); return DataResult<(bool isExistsDiff, List<CompareResultDetailInfo>)>.Success(result);
} }
/// <summary> /// <summary>
/// 对比BC与海运出口订单 /// 对比BC与海运出口订单
/// </summary> /// </summary>
public async Task<CompareResultInfo> CompareBcWithSeaExport(CompareBcWithSeaExportDto compareDto) public async Task<(bool isExistsDiff, List<CompareResultDetailInfo>)> CompareBcWithSeaExport(CompareBcWithSeaExportDto compareDto)
{ {
var taskBcInfo = compareDto.TaskBCInfo; var taskBcInfo = compareDto.TaskBCInfo;
var taskBcCtnList = compareDto.TaskBCCtnList; var taskBcCtnList = compareDto.TaskBCCtnList;
var seaExport = compareDto.SeaExport; var seaExport = compareDto.SeaExport;
@ -1243,7 +1257,7 @@ namespace DS.WMS.Core.TaskPlat.Method
logger.LogInformation($"批次={batchNo} taskBcInfo.id={taskBcInfo.Id} seaExport.id={seaExport.Id} 请求BC对比订单结果完成耗时{timeDiff}ms是否成功{(compareResult?.succ == true ? "" : "")} "); logger.LogInformation($"批次={batchNo} taskBcInfo.id={taskBcInfo.Id} seaExport.id={seaExport.Id} 请求BC对比订单结果完成耗时{timeDiff}ms是否成功{(compareResult?.succ == true ? "" : "")} ");
if (compareResult != null && compareResult?.succ == true) if (compareResult != null)
{ {
logger.LogInformation($"批次={batchNo} BC对比订单结果={JsonConvert.SerializeObject(compareResult)}"); logger.LogInformation($"批次={batchNo} BC对比订单结果={JsonConvert.SerializeObject(compareResult)}");
DateTime nowDate = DateTime.Now; DateTime nowDate = DateTime.Now;
@ -1289,22 +1303,13 @@ namespace DS.WMS.Core.TaskPlat.Method
it.UpdateUserName it.UpdateUserName
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
} }
return new CompareResultInfo()
{ return (compareResult.extra.IsExistsDiff, compareResult.extra.ShowDetailList);
IsExistsDiff = compareResult.extra.IsExistsDiff,
ShowDetailList = compareResult.extra.ShowDetailList,
DetailList = compareResult.extra.DetailList,
IsSuccess = true
};
//return (compareResult.extra.IsExistsDiff, compareResult.extra.ShowDetailList);
} }
else else
{ {
logger.LogError($"批次={batchNo} BC对比订单结果为空"); logger.LogError($"批次={batchNo} BC对比订单结果为空");
return new CompareResultInfo() throw new Exception($"批次={batchNo} BC对比订单结果为空");
{
IsSuccess = false
};
} }
} }
#region 生成并推送邮件 #region 生成并推送邮件
@ -2251,5 +2256,163 @@ namespace DS.WMS.Core.TaskPlat.Method
return await SyncBookingSlotChange(taskBaseId.Value); return await SyncBookingSlotChange(taskBaseId.Value);
} }
#region 读取BC详情
/// <summary>
/// 读取BC详情
/// </summary>
/// <param name="carrierCode">船公司代码</param>
/// <param name="file">BC文件</param>
/// <returns>返回解析详情</returns>
public async Task<DataResult<ParserBCInfoDto>> GetReadBC(string carrierCode, IFormFile file)
{
DateTime nowDate = DateTime.Now;
string msg = string.Empty;
var messageInfo = new
{
Head = new
{
GID = SnowFlakeSingle.Instance.NextId().ToString(),
MessageType = "BOOKING_GAMENDMENT",
SenderId = AppSetting.app(new string[] { "ExcuteRuleService", "RulesEngineSender" }),
SenderName = AppSetting.app(new string[] { "ExcuteRuleService", "RulesEngineSenderName" }),
ReceiverId = "RulesEngine",
ReceiverName = "大简云规则引擎",
Version = "1.0",
RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"),
RequestAction = "ReadFile",
},
Main = new
{
TenantId = user.TenantId.ToString()
}
};
using (var httpClient = new HttpClient())
{
try
{
using (var reduceAttach = new MultipartFormDataContent())
{
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageInfo)));
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
{
Name = "jsonData"
};
reduceAttach.Add(dataContent);
#region 文件参数
if (file != null)
{
var Content = new ByteArrayContent(file.ToByteArray());
Content.Headers.Add("Content-Type", "application/json");
reduceAttach.Add(Content, "file", HttpUtility.UrlEncode(file.FileName));
}
#endregion
var url = string.Empty;
if (carrierCode.Equals("MSK", StringComparison.OrdinalIgnoreCase))
url = bcMSKReadUrl;
if (carrierCode.Equals("CMA", StringComparison.OrdinalIgnoreCase))
url = bcCMAReadUrl;
//请求
var response = httpClient.PostAsync(url, reduceAttach).Result;
string result = response.Content.ReadAsStringAsync().Result;
var model = JsonConvert.DeserializeObject<BCReadResultDto>(result);
if(model != null && model.succ)
{
var bcInfo = JsonConvert.DeserializeObject<ParserBCInfoDto>(JsonConvert.SerializeObject(model.extra));
return DataResult<ParserBCInfoDto>.Success(bcInfo);
}
else
{
msg = model.msg;
}
}
}
catch (Exception ex)
{
Logger.Log(NLog.LogLevel.Info, "请求BC读取详情异常原因{error}", ex.Message);
msg = $"请求BC读取详情异常原因{ex.Message}";
}
return DataResult<ParserBCInfoDto>.Failed(msg);
}
}
#endregion
#region 读取BC擦写后文件流
/// <summary>
/// 读取BC擦写后文件流
/// </summary>
/// <param name="carrierCode">船公司代码</param>
/// <param name="file">BC文件</param>
/// <returns>返回解析详情</returns>
public async Task<DataResult<byte[]>> GetModifyBCFile(string carrierCode, IFormFile file)
{
byte[] bytes;
var result = string.Empty;
using (var httpClient = new HttpClient())
{
try
{
using (var reduceAttach = new MultipartFormDataContent())
{
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(""));
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
{
Name = "jsonData"
};
reduceAttach.Add(dataContent);
#region 文件参数
if (file != null)
{
var Content = new ByteArrayContent(file.ToByteArray());
Content.Headers.Add("Content-Type", "application/json");
reduceAttach.Add(Content, "file", HttpUtility.UrlEncode(file.FileName));
}
#endregion
//请求
var response = httpClient.PostAsync(bcMSKModifyFileUrl, reduceAttach).Result;
bytes = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
return DataResult<byte[]>.Success(bytes);
}
}
catch (Exception ex)
{
Logger.Log(NLog.LogLevel.Info, "请求自动变更文件内容异常,原因:{error}", ex.Message);
result = $"请求自动变更文件内容异常,原因:{ex.Message}";
}
}
return DataResult<byte[]>.Failed(result);
}
#endregion
} }
} }

@ -59,6 +59,9 @@ namespace DS.WMS.MainApi.Controllers
if (entity == null) if (entity == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.IllegalRequest)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.IllegalRequest));
if (entity.CustomerId == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.IllegalRequest) + " " + nameof(entity.CustomerId));
entity.TenantId = long.Parse(user.TenantId); entity.TenantId = long.Parse(user.TenantId);
entity.TenantName = user.TenantName; entity.TenantName = user.TenantName;

@ -68,5 +68,33 @@ namespace DS.WMS.TaskApi.Controllers
return await _taskManageBCService.SyncBookingSlotChange(taskPKId); return await _taskManageBCService.SyncBookingSlotChange(taskPKId);
} }
#endregion #endregion
#region 读取BC详情
/// <summary>
/// 读取BC详情
/// </summary>
/// <param name="carrierCode">船公司代码</param>
/// <param name="file">BC文件</param>
/// <returns>返回解析详情</returns>
[HttpPost("GetReadBC")]
public async Task<DataResult<ParserBCInfoDto>> GetReadBC(string carrierCode, IFormFile file)
{
return await _taskManageBCService.GetReadBC(carrierCode, file);
}
#endregion
#region 读取BC擦写后文件流
/// <summary>
/// 读取BC擦写后文件流
/// </summary>
/// <param name="carrierCode">船公司代码</param>
/// <param name="file">BC文件</param>
/// <returns>返回解析详情</returns>
[HttpPost("GetModifyBCFile")]
public async Task<DataResult<byte[]>> GetModifyBCFile(string carrierCode, IFormFile file)
{
return await _taskManageBCService.GetModifyBCFile(carrierCode, file);
}
#endregion
} }
} }

@ -66,7 +66,10 @@
"FileType": [ ".xls", ".xlsx", ".pdf", ".txt", ".pms" ] "FileType": [ ".xls", ".xlsx", ".pdf", ".txt", ".pms" ]
}, },
"BCCompare": { "BCCompare": {
"Url": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare" "Url": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare",
"MSKBCReadUrl": "http://47.104.73.97:7115/api/TaskBCParser/ExcuteBCFileRead",
"MSKBCModifyFileUrl": "http://47.104.73.97:7115/api/TaskBCParser/ModifyBCFile",
"CMABCReadUrl": "http://47.104.73.97:7115/api/TaskBCCMAParser/ExcuteBCFileRead"
}, },
"ShippingOrderCompare": { "ShippingOrderCompare": {
"Url": "http://47.104.73.97:7115/api/TaskShippingOrderCompare/ExcuteShippingOrderCompare", "Url": "http://47.104.73.97:7115/api/TaskShippingOrderCompare/ExcuteShippingOrderCompare",

Loading…
Cancel
Save