diff --git a/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs b/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs index b2a4e7c8..543faac8 100644 --- a/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs @@ -40,8 +40,8 @@ namespace DS.Module.Core /// /// BC对比订单后是否存在差异 /// - /// 类型:CompareResultInfo - public const string BcCompareWithSeaExportResult = "BcCompareWithSeaExportResult"; + /// 类型: + public const string BcCompareBcWithSeaExportIsExistsDiff = "BcCompareBcWithSeaExportIsExistsDiff"; /// /// BC文件 diff --git a/ds-wms-service/DS.WMS.AdminApi/DS.WMS.AdminApi.csproj.user b/ds-wms-service/DS.WMS.AdminApi/DS.WMS.AdminApi.csproj.user index 93bef62e..4341ebc7 100644 --- a/ds-wms-service/DS.WMS.AdminApi/DS.WMS.AdminApi.csproj.user +++ b/ds-wms-service/DS.WMS.AdminApi/DS.WMS.AdminApi.csproj.user @@ -2,7 +2,7 @@ http - D:\Code\DS\ds8-solution-pro\ds-wms-service\DS.WMS.AdminApi\Properties\PublishProfiles\FolderProfile.pubxml + D:\Source\Repos\DS8\ds-wms-service\DS.WMS.AdminApi\Properties\PublishProfiles\FolderProfile.pubxml ProjectDebugger diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs index 2568640a..0d14e657 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs @@ -490,35 +490,5 @@ namespace DS.WMS.Core.Op.Dtos /// 还箱场站 /// public string ReturnCTNYard { get; set; } - - /// - /// 温度单位 - /// - public string TempUnit{ get; set; } - - /// - /// 设置温度 - /// - public string TempSet { get; set; } - - /// - /// 最低温度 - /// - public string TempMin { get; set; } - - /// - /// 最高温度 - /// - public string TempMax { get; set; } - - /// - /// 湿度 - /// - public string Humidity { get; set; } - - /// - /// 冷藏通风量 - /// - public string Reeferf { get; set; } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs index 7676c1ab..bb488c0b 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs @@ -7,6 +7,9 @@ using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Op.Interface.TaskInteraction; using Masuit.Tools.Systems; 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 { @@ -15,29 +18,36 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease /// public class SpaceReleaseActionExecutor : DefaultActionExecutor { - /// - /// 任务服务 - /// - protected ISeaExportService OpService; + ///// + ///// 任务服务 + ///// + //protected ISeaExportService OpService; /// /// 日志服务 /// protected ITaskLogService LogService; - /// - /// 客户参数服务 - /// - protected IClientParamService ClientParamService; - public override async Task ExecuteAsync(ActionExecutionContext context) { - OpService = context.ServiceProvider.GetRequiredService(); + //OpService = context.ServiceProvider.GetRequiredService(); LogService = context.ServiceProvider.GetRequiredService(); - ClientParamService = context.ServiceProvider.GetRequiredService(); - + var releaseTypeService = context.ServiceProvider.GetRequiredService(); + 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(context.TaskInfo.BusinessId, "SendXHZ", (x, y) => x.CustomerId == y.YardId); + var clientParamService = context.ServiceProvider.GetRequiredService(); + var param = await clientParamService.GetParamAsync(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 - async Task RelayBCAsync(ActionExecutionContext context) + async Task RelayBCAsync(ActionExecutionContext context) { - + } //下货纸 @@ -114,5 +124,5 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease } - + } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs index 0dc5dad8..98ee11ab 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs @@ -527,7 +527,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (useTransaction) await TenantDb.Ado.CommitTranAsync(); - //ActionService.Value.TriggerActionAsync(task); + ActionService.TriggerActionAsync(task); return DataResult.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null); } catch (Exception ex) diff --git a/ds-wms-service/DS.WMS.Core/Sys/Entity/SysReleaseType.cs b/ds-wms-service/DS.WMS.Core/Sys/Entity/SysReleaseType.cs index 0e4118ab..93aa7ef3 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Entity/SysReleaseType.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Entity/SysReleaseType.cs @@ -11,11 +11,23 @@ namespace DS.WMS.Core.Sys.Entity [SugarTable("sys_release_type")] public class SysReleaseType : BaseModelV2 { + /// + /// 委托单位ID + /// + [SugarColumn(ColumnDescription = "委托单位ID", IsNullable = true)] + public long? CustomerId { get; set; } + + /// + /// 委托单位名称 + /// + [SugarColumn(IsIgnore = true)] + public string? CustomerName { get; set; } + /// /// 承运商(船公司/航空公司) /// - [SugarColumn(ColumnDescription = "承运商(船公司/航空公司)", Length = 50, IsNullable = false)] - public string Carrier { get; set; } = string.Empty; + [SugarColumn(ColumnDescription = "承运商(船公司/航空公司)", Length = 50, IsNullable = true)] + public string? Carrier { get; set; } /// /// 起运港代码 diff --git a/ds-wms-service/DS.WMS.Core/Sys/Interface/IReleaseTypeService.cs b/ds-wms-service/DS.WMS.Core/Sys/Interface/IReleaseTypeService.cs index 95637dca..ac53108e 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Interface/IReleaseTypeService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Interface/IReleaseTypeService.cs @@ -1,4 +1,5 @@ using DS.Module.Core; +using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Sys.Entity; namespace DS.WMS.Core.Sys.Interface @@ -16,6 +17,14 @@ namespace DS.WMS.Core.Sys.Interface /// Task>> GetListAsync(PageRequest request, bool isAdmin = false); + /// + /// 根据业务数据匹配放舱方式 + /// + /// 业务ID + /// 业务类型 + /// + Task GetReleaseTypeAsync(long businessId, BusinessType businessType); + /// /// 详情 /// diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/ReleaseTypeService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/ReleaseTypeService.cs index f4d8a75e..b94f9ab3 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Method/ReleaseTypeService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/ReleaseTypeService.cs @@ -1,5 +1,9 @@ using DS.Module.Core; +using DS.Module.Core.Data; 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.Interface; @@ -16,6 +20,7 @@ namespace DS.WMS.Core.Sys.Method /// public ReleaseTypeService(IServiceProvider provider) : base(provider) { + TenantDb.QueryFilter.Clear(); } /// @@ -28,12 +33,73 @@ namespace DS.WMS.Core.Sys.Method { var whereList = request.GetConditionalModels(Db); var tenantId = long.Parse(User.TenantId); - var data = await Db.Queryable().Where(whereList) - .WhereIF(!isAdmin, x => x.TenantId == tenantId) + var data = await Db.Queryable() + .Where(whereList).WhereIF(!isAdmin, x => x.TenantId == tenantId) .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().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; } + /// + /// 根据业务数据匹配放舱方式 + /// + /// 业务ID + /// 业务类型 + /// + public async Task GetReleaseTypeAsync(long businessId, BusinessType businessType) + { + SpaceReleaseType? releaseType = null; + switch (businessType) + { + case BusinessType.OceanShippingExport: + var order1 = await TenantDb.Queryable().Where(x => x.Id == businessId) + .LeftJoin((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().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().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; + } + /// /// 详情 /// @@ -61,9 +127,10 @@ namespace DS.WMS.Core.Sys.Method { rows = await Db.Updateable(entity).UpdateColumns(x => new { + x.CustomerId, x.Carrier, x.LoadingPort, - x.ReleaseType, + x.ReleaseType }).ExecuteCommandAsync(); } diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/BC/BCReadResultDto.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/BC/BCReadResultDto.cs new file mode 100644 index 00000000..dcaedaa5 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/BC/BCReadResultDto.cs @@ -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 +{ + /// + /// + /// + public class BCReadResultDto + { + /// + /// 是否成功 true=成功 false=失败 + /// + public bool succ { get; set; } = false; + + /// + /// 状态 0-成功 + /// + public int status { get; set; } = 0; + + /// + /// 返回消息 + /// + public string msg { get; set; } + + /// + /// 总记录数 + /// + public int total { get; set; } + + /// + /// 当前页列表数据 + /// + public object rows { get; set; } + + /// + /// 合计信息 + /// + public object summary { get; set; } + + /// + /// 扩展信息 + /// + public object extra { get; set; } + + /// + /// 扩展信息2 + /// + public object extra2 { get; set; } + + /// + /// 扩展信息场站统计 + /// + public object yardStatInfo { get; set; } + + /// + /// 是否异常 + /// + public bool exceptionflag { get; set; } + + /// + /// 生成HTML + /// + public string ResultHtml { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs index d707387c..42610deb 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs @@ -47,6 +47,22 @@ namespace DS.WMS.Core.TaskPlat.Interface /// /// 对比BC与海运出口订单 /// - Task> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext); + Task)>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext); + + /// + /// 读取BC详情 + /// + /// 船公司代码 + /// BC文件 + /// 返回解析详情 + Task> GetReadBC(string carrierCode, IFormFile file); + + /// + /// 读取BC擦写后文件流 + /// + /// 船公司代码 + /// BC文件 + /// 返回解析详情 + Task> GetModifyBCFile(string carrierCode, IFormFile file); } } diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs index 0c4fb9a8..9fae4037 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs @@ -25,12 +25,16 @@ using DS.WMS.Core.TaskPlat.Interface; using HtmlAgilityPack; using Mapster; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using NLog; using SqlSugar; +using System.Web; +using System.Net.Http.Headers; using System.Text.RegularExpressions; +using System.Text; namespace DS.WMS.Core.TaskPlat.Method { @@ -50,6 +54,11 @@ namespace DS.WMS.Core.TaskPlat.Method private readonly IWebHostEnvironment _environment; private readonly ISqlSugarClient db; + private readonly string bcCompareUrl; + private readonly string bcMSKReadUrl; + private readonly string bcMSKModifyFileUrl; + private readonly string bcCMAReadUrl; + // 按需构建 private Lazy bookingSlotService; private Lazy seaExportService; @@ -65,6 +74,7 @@ namespace DS.WMS.Core.TaskPlat.Method //自动转发是否默认抄送操作 const string CONST_AUTO_TRANS_EMAIL_OP_CCTO = "AUTO_TRANS_EMAIL_OP_CCTO"; + public TaskManageBCService(IUser user, ILogger logger, @@ -97,6 +107,11 @@ namespace DS.WMS.Core.TaskPlat.Method tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); tenantDb.QueryFilter.Clear(); + + 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" }); } /// @@ -1121,12 +1136,12 @@ namespace DS.WMS.Core.TaskPlat.Method /// /// 对比BC与海运出口订单(任务台使用) /// - public async Task> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext) + public async Task)>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext) { var taskBcInfo = dataContext.Get(TaskFlowDataNameConst.TaskBCInfo) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCInfo)}"); var taskBcCtnList = dataContext.Get?>(TaskFlowDataNameConst.TaskBCCtnList) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCCtnList)}"); - var seaExport = await tenantDb.Queryable().Where(x => x.ParentId == 0 && taskBcInfo.MBL_NO == x.MBLNO).Select(x => new SeaExport() + var seaExport = await tenantDb.Queryable().Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID).Select(x => new SeaExport() { Id = x.Id, MBLNO = x.MBLNO, @@ -1159,19 +1174,18 @@ namespace DS.WMS.Core.TaskPlat.Method SeaExport = seaExport, OpCtnList = seaExportCtnList }; - var result = await CompareBcWithSeaExport(compareDto); + (bool isExistsDiff, List) result = await CompareBcWithSeaExport(compareDto); - dataContext.Set(TaskFlowDataNameConst.BcCompareWithSeaExportResult, result); + dataContext.Set(TaskFlowDataNameConst.BcCompareBcWithSeaExportIsExistsDiff, result.isExistsDiff); - return DataResult.Success(result); + return DataResult<(bool isExistsDiff, List)>.Success(result); } /// /// 对比BC与海运出口订单 /// - public async Task CompareBcWithSeaExport(CompareBcWithSeaExportDto compareDto) + public async Task<(bool isExistsDiff, List)> CompareBcWithSeaExport(CompareBcWithSeaExportDto compareDto) { - var taskBcInfo = compareDto.TaskBCInfo; var taskBcCtnList = compareDto.TaskBCCtnList; 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 ? "成功" : "失败")} "); - if (compareResult != null && compareResult?.succ == true) + if (compareResult != null) { logger.LogInformation($"批次={batchNo} BC对比订单结果={JsonConvert.SerializeObject(compareResult)}"); DateTime nowDate = DateTime.Now; @@ -1289,22 +1303,13 @@ namespace DS.WMS.Core.TaskPlat.Method it.UpdateUserName }).ExecuteCommandAsync(); } - return new CompareResultInfo() - { - IsExistsDiff = compareResult.extra.IsExistsDiff, - ShowDetailList = compareResult.extra.ShowDetailList, - DetailList = compareResult.extra.DetailList, - IsSuccess = true - }; - //return (compareResult.extra.IsExistsDiff, compareResult.extra.ShowDetailList); + + return (compareResult.extra.IsExistsDiff, compareResult.extra.ShowDetailList); } else { logger.LogError($"批次={batchNo} BC对比订单结果为空"); - return new CompareResultInfo() - { - IsSuccess = false - }; + throw new Exception($"批次={batchNo} BC对比订单结果为空"); } } #region 生成并推送邮件 @@ -2251,5 +2256,163 @@ namespace DS.WMS.Core.TaskPlat.Method return await SyncBookingSlotChange(taskBaseId.Value); } + + #region 读取BC详情 + /// + /// 读取BC详情 + /// + /// 船公司代码 + /// BC文件 + /// 返回解析详情 + public async Task> 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(result); + + if(model != null && model.succ) + { + var bcInfo = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(model.extra)); + + return DataResult.Success(bcInfo); + } + else + { + msg = model.msg; + } + } + } + catch (Exception ex) + { + Logger.Log(NLog.LogLevel.Info, "请求BC读取详情异常,原因:{error}", ex.Message); + + msg = $"请求BC读取详情异常,原因:{ex.Message}"; + + } + + + return DataResult.Failed(msg); + } + } + #endregion + + #region 读取BC擦写后文件流 + /// + /// 读取BC擦写后文件流 + /// + /// 船公司代码 + /// BC文件 + /// 返回解析详情 + public async Task> 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.Success(bytes); + } + } + catch (Exception ex) + { + Logger.Log(NLog.LogLevel.Info, "请求自动变更文件内容异常,原因:{error}", ex.Message); + + result = $"请求自动变更文件内容异常,原因:{ex.Message}"; + + } + + } + + return DataResult.Failed(result); + } + #endregion } } diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/ReleaseTypeController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/ReleaseTypeController.cs index a9b92111..06456293 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/ReleaseTypeController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/ReleaseTypeController.cs @@ -59,6 +59,9 @@ namespace DS.WMS.MainApi.Controllers if (entity == null) 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.TenantName = user.TenantName; diff --git a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs index 01c99e63..8a3159ce 100644 --- a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs +++ b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs @@ -68,5 +68,33 @@ namespace DS.WMS.TaskApi.Controllers return await _taskManageBCService.SyncBookingSlotChange(taskPKId); } #endregion + + #region 读取BC详情 + /// + /// 读取BC详情 + /// + /// 船公司代码 + /// BC文件 + /// 返回解析详情 + [HttpPost("GetReadBC")] + public async Task> GetReadBC(string carrierCode, IFormFile file) + { + return await _taskManageBCService.GetReadBC(carrierCode, file); + } + #endregion + + #region 读取BC擦写后文件流 + /// + /// 读取BC擦写后文件流 + /// + /// 船公司代码 + /// BC文件 + /// 返回解析详情 + [HttpPost("GetModifyBCFile")] + public async Task> GetModifyBCFile(string carrierCode, IFormFile file) + { + return await _taskManageBCService.GetModifyBCFile(carrierCode, file); + } + #endregion } } diff --git a/ds-wms-service/DS.WMS.TaskApi/appsettings.json b/ds-wms-service/DS.WMS.TaskApi/appsettings.json index e0abbc7a..48c463f4 100644 --- a/ds-wms-service/DS.WMS.TaskApi/appsettings.json +++ b/ds-wms-service/DS.WMS.TaskApi/appsettings.json @@ -66,7 +66,10 @@ "FileType": [ ".xls", ".xlsx", ".pdf", ".txt", ".pms" ] }, "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": { "Url": "http://47.104.73.97:7115/api/TaskShippingOrderCompare/ExcuteShippingOrderCompare",