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/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 26282cab..42610deb 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs @@ -48,5 +48,21 @@ namespace DS.WMS.Core.TaskPlat.Interface /// 对比BC与海运出口订单 /// 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 42015045..dbf4a411 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs @@ -25,11 +25,22 @@ 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.Collections.Specialized; +using System.IO; +using System.Text; +using System.Web; +using System.Net.Http.Headers; +using DS.WMS.Core.Invoice.Dtos; +using NPOI.SS.Formula.Functions; +using LanguageExt.Common; +using Microsoft.AspNet.SignalR.Hosting; +using Masuit.Tools; namespace DS.WMS.Core.TaskPlat.Method { @@ -49,6 +60,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; @@ -64,6 +80,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, @@ -96,6 +113,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" }); } /// @@ -2231,5 +2253,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.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",