修改BC 引入

optimize
jianghaiqing 2 years ago
parent 5f02453267
commit 78bf6f08e6

@ -1,6 +1,7 @@
using Furion;
using Furion.Logging;
using Furion.RemoteRequest.Extensions;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Myshipping.Application.ConfigOption;
using Myshipping.Application.Entity;
@ -29,7 +30,7 @@ namespace Myshipping.Application
/// <param name="batchNo">批次号</param>
/// <param name="isLocalTempFile">是否生成本地文件</param>
/// <param name="attachFileType">附件类型 bcfiles-BC文件</param>
/// <returns>返新的文件路径</returns>
/// <returns>返新的文件路径</returns>
public static async Task<string> MoveFile(string fileDictKey,string sourceFilePath,string batchNo,
bool isLocalTempFile = false,string attachFileType = "bcfiles")
{
@ -140,5 +141,56 @@ namespace Myshipping.Application
return bookFilePath;
}
#endregion
#region 暂存Web请求文件暂存
/// <summary>
/// 暂存Web请求文件暂存
/// </summary>
/// <param name="fileDictKey">文件目录KEY</param>
/// <param name="file">文件</param>
/// <param name="batchNo">批次号</param>
/// <param name="attachFileType">附件类型 bcfiles-BC文件</param>
/// <returns>返回暂存文件路径</returns>
public static async Task<string> TempSaveWebFile(string fileDictKey, IFormFile file, string batchNo,
string attachFileType = "bcfiles")
{
var logger = Log.CreateLogger(nameof(FileAttachHelper));
var opt = App.GetOptions<TempFileOptions>().Path;
string filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);
if (!string.IsNullOrWhiteSpace(attachFileType))
filePath += $"\\{attachFileType}";
if (!string.IsNullOrWhiteSpace(fileDictKey))
filePath += $"\\{fileDictKey}";
string fileFullName = $"{filePath}\\{file.FileName}";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
filePath = filePath.Replace("\\", "/");
fileFullName = fileFullName.Replace("\\", "/");
}
logger.LogInformation("批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, filePath,
RuntimeInformation.OSDescription);
//预先创建目录
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
using (var fileStream = File.Create(fileFullName))
{
await file.CopyToAsync(fileStream);
}
return fileFullName;
}
#endregion
}
}

@ -1295,30 +1295,7 @@ namespace Myshipping.Application
*/
//读取文件配置
var opt = App.GetOptions<TempFileOptions>().Path;
string filePath = $"{Path.Combine(App.WebHostEnvironment.WebRootPath, opt)}\\bcfilestemp\\{bookingOrder.Id}";
string fileFullName = $"{filePath}\\{file.FileName}";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
filePath = filePath.Replace("\\", "/");
fileFullName = fileFullName.Replace("\\", "/");
}
_logger.LogInformation("批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, filePath, RuntimeInformation.OSDescription);
//预先创建目录
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
using (var fileStream = File.Create(fileFullName))
{
await file.CopyToAsync(fileStream);
}
var fileFullName = await FileAttachHelper.TempSaveWebFile(bookingOrder.Id.ToString(), file, batchNo);
_logger.LogInformation("批次={no} 完成文件保存 filepath={path}", batchNo, fileFullName);
@ -1388,6 +1365,7 @@ namespace Myshipping.Application
}
#endregion
#region 单票BC更新订舱
/// <summary>
/// 单票BC更新订舱
/// </summary>
@ -1569,6 +1547,7 @@ namespace Myshipping.Application
return result;
}
#endregion
}
public class DateTimeJsonConverter : System.Text.Json.Serialization.JsonConverter<DateTime>

Loading…
Cancel
Save