optimize
wet 2 years ago
parent 1a199a483f
commit 63f4ffa7a4

@ -32,6 +32,8 @@ using Myshipping.Core.Service;
using System.Reflection.Emit;
using Myshipping.Application.Service.DataSync.Dto;
using Newtonsoft.Json.Linq;
using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Application.Enum;
namespace Myshipping.Application
{
@ -64,6 +66,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<RelaPortCarrierLane> _relaPortLane;
private readonly ICommonDBService _commonDBService;
private readonly SqlSugarRepository<CodeForwarder> _codeForwarder;
private readonly SqlSugarRepository<BookingFile> _bookingfile;
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _accountconfig;
@ -75,7 +78,7 @@ namespace Myshipping.Application
SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline,
SqlSugarRepository<BookingRemark> bookingremark, SqlSugarRepository<MappingCarrier> mapcarrier, SqlSugarRepository<CodeForwarder> codeForwarder,
SqlSugarRepository<CodePort> codePortRep, SqlSugarRepository<CodeLane> codeLaneRep, ICommonDBService commonDBService, SqlSugarRepository<RelaPortCarrierLane> relaPortLane,
SqlSugarRepository<DjyWebsiteAccountConfig> accountconfig)
SqlSugarRepository<DjyWebsiteAccountConfig> accountconfig, SqlSugarRepository<BookingFile> bookingfile)
{
this._logger = logger;
this._rep = rep;
@ -100,7 +103,8 @@ namespace Myshipping.Application
this._commonDBService = commonDBService;
this._relaPortLane = relaPortLane;
this._codeForwarder = codeForwarder;
this._accountconfig= accountconfig;
this._accountconfig = accountconfig;
this._bookingfile = bookingfile;
}
@ -2080,7 +2084,8 @@ namespace Myshipping.Application
accountConfig = await _accountconfig.AsQueryable().InnerJoin<SysUser>((d, t) => d.TenantId == t.TenantId).Where((d, t) => d.TypeCode == TypeCode && t.TenantId == UserManager.TENANT_ID && d.IsTenant == true).FirstAsync();
}
else {
else
{
accountConfig = await _accountconfig.FirstOrDefaultAsync(x => x.TypeCode == TypeCode && x.CreatedUserId == UserId);
}
return accountConfig;
@ -2091,15 +2096,72 @@ namespace Myshipping.Application
/// </summary>
/// <returns></returns>
[HttpGet("/DataSync/GetParamValue"), ApiUser(ApiCode = "GetParamValue")]
public dynamic GetParamValue()
public dynamic GetParamValue()
{
var list = _cache.GetAllTenantParam().Result.Where( x=>x.TenantId == UserManager.TENANT_ID).OrderBy(x => x.Sort).ToList();
var list = _cache.GetAllTenantParam().Result.Where(x => x.TenantId == UserManager.TENANT_ID).OrderBy(x => x.Sort).ToList();
return list;
}
/// <summary>
/// 挂载订舱文件
/// </summary>
/// <param name="file"></param>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/DataSync/AddFile"), ApiUser(ApiCode = "AddFile")]
public async Task AddFile(IFormFile file, [FromForm] BookingFileDto dto)
{
//未上传文件
if (file == null || file.Length == 0)
{
throw Oops.Bah(BookingErrorCode.BOOK200);
}
var opt = App.GetOptions<BookingAttachOptions>();
var originalFilename = file.FileName; // 文件原始名称
var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀
if (!opt.fileType.Contains(fileSuffix))
{
throw Oops.Bah(BookingErrorCode.BOOK114);
}
var dirAbs = string.Empty;
if (string.IsNullOrEmpty(opt.basePath))
{
dirAbs = Path.Combine(App.WebHostEnvironment.WebRootPath, opt.relativePath);
}
else
{
dirAbs = Path.Combine(opt.basePath, opt.relativePath);
}
if (!Directory.Exists(dirAbs))
Directory.CreateDirectory(dirAbs);
// 先存库获取Id
var id = YitIdHelper.NextId();
var fileSaveName = $"{id}{fileSuffix}".ToLower();
var fileRelaPath = Path.Combine(opt.relativePath, fileSaveName).ToLower();
var fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower();
var newFile = new BookingFile
{
Id = id,
FileName = originalFilename,
FilePath = fileRelaPath,
TypeCode = dto.TypeCode,
TypeName = dto.TypeName,
BookingId = dto.BookingId,
};
await _bookingfile.InsertAsync(newFile);
using (var stream = File.Create(fileAbsPath))
{
await file.CopyToAsync(stream);
}
}

Loading…
Cancel
Save