新增BC的解析方法

新增变更BC文件方法
usertest
jianghaiqing 3 months ago
parent f531f25670
commit f92da75d5b

@ -490,35 +490,5 @@ namespace DS.WMS.Core.Op.Dtos
/// 还箱场站
/// </summary>
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; }
}
}

@ -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; }
}
}

@ -48,5 +48,21 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// 对比BC与海运出口订单
/// </summary>
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,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<IBookingSlotService> bookingSlotService;
private Lazy<ISeaExportService> 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<TaskManageBCService> logger,
@ -96,6 +113,11 @@ namespace DS.WMS.Core.TaskPlat.Method
tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
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>
@ -2231,5 +2253,163 @@ namespace DS.WMS.Core.TaskPlat.Method
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
}
}

@ -68,5 +68,33 @@ namespace DS.WMS.TaskApi.Controllers
return await _taskManageBCService.SyncBookingSlotChange(taskPKId);
}
#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" ]
},
"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",

Loading…
Cancel
Save