|
|
|
@ -1,12 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
@ -14,7 +11,6 @@ using System.Collections.Generic;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 公共库
|
|
|
|
|
/// </summary>
|
|
|
|
@ -23,6 +19,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<CodeCarrier> _codeCarrierRep;
|
|
|
|
|
private readonly SqlSugarRepository<MappingCarrier> _mappingCarrierRep;
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<CodeVessel> _codeVesselRep;
|
|
|
|
|
private readonly SqlSugarRepository<CodeForwarder> _codeForwarderRep;
|
|
|
|
|
private readonly SqlSugarRepository<CodeYard> _codeYardRep;
|
|
|
|
@ -44,7 +42,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
|
|
|
|
|
SqlSugarRepository<CodeService> codeServiceRep,
|
|
|
|
|
SqlSugarRepository<CodeCtn> codeCtnRep,
|
|
|
|
|
SqlSugarRepository<CodeFrt> codeFrtRep,
|
|
|
|
|
|
|
|
|
|
SqlSugarRepository<MappingCarrier> mappingCarrierRep,
|
|
|
|
|
ISysCacheService sysCacheService)
|
|
|
|
|
{
|
|
|
|
|
_codeCarrierRep = codeCarrierRep;
|
|
|
|
@ -57,11 +55,13 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
|
|
|
|
|
_codeServiceRep = codeServiceRep;
|
|
|
|
|
_codeCtnRep = codeCtnRep;
|
|
|
|
|
_codeFrtRep = codeFrtRep;
|
|
|
|
|
|
|
|
|
|
_mappingCarrierRep = mappingCarrierRep;
|
|
|
|
|
_sysCacheService = sysCacheService;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 船公司
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取船公司列表信息
|
|
|
|
|
/// </summary>
|
|
|
|
@ -69,14 +69,63 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
|
|
|
|
|
public async Task<dynamic> CarrierList([FromQuery] CodeCnEnQueryDto input)
|
|
|
|
|
{
|
|
|
|
|
var list = await GetAllCarrier();
|
|
|
|
|
|
|
|
|
|
var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CnName), x => x.Code.Contains(input.CnName))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.EnName), x => x.Code.Contains(input.EnName, System.StringComparison.CurrentCultureIgnoreCase));
|
|
|
|
|
return queryList.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增船公司信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("/commondb/addcarrier")]
|
|
|
|
|
public async Task AddCarrier(CodeCarrier dto)
|
|
|
|
|
{
|
|
|
|
|
var entity = dto.Adapt<CodeCarrier>();
|
|
|
|
|
await _codeCarrierRep.InsertAsync(entity);
|
|
|
|
|
await GetAllCarrier();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取船公司映射列表信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("/commondb/mappingcarrierlist")]
|
|
|
|
|
public async Task<dynamic> MappingCarrierList([FromQuery] MappingQueryDto input)
|
|
|
|
|
{
|
|
|
|
|
var list = await GetAllMappingCarrier();
|
|
|
|
|
|
|
|
|
|
var queryList = list
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.Code.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
|
|
|
|
|
return queryList.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增编辑船公司映射信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("/commondb/addorupdatecarrier")]
|
|
|
|
|
public async Task AddOrUpdateCarrier(MappingCarrier dto)
|
|
|
|
|
{
|
|
|
|
|
var entity = dto.Adapt<MappingCarrier>();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(dto.GID))
|
|
|
|
|
{
|
|
|
|
|
await _mappingCarrierRep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
await _mappingCarrierRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
await GetAllMappingCarrier();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 船名
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取船名列表信息
|
|
|
|
|
/// </summary>
|
|
|
|
@ -96,6 +145,25 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
|
|
|
|
|
return queryList.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增船名信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("/commondb/addvessel")]
|
|
|
|
|
public async Task AddVessel(CodeVessel dto)
|
|
|
|
|
{
|
|
|
|
|
var entity = dto.Adapt<CodeVessel>();
|
|
|
|
|
await _codeVesselRep.InsertAsync(entity);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取船代列表信息
|
|
|
|
|
/// </summary>
|
|
|
|
@ -206,23 +274,38 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
|
|
|
|
|
return queryList.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 实现接口,获取公共数据并缓存
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task<List<CodeCarrier>> GetAllCarrier()
|
|
|
|
|
{
|
|
|
|
|
var list = await _sysCacheService.GetAllCodeCarrier();
|
|
|
|
|
if (list != null && list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list = await _codeCarrierRep.ToListAsync();
|
|
|
|
|
await _sysCacheService.SetAllCodeCarrier(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
var list = await _codeCarrierRep.ToListAsync();
|
|
|
|
|
await _sysCacheService.SetAllCodeCarrier(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task<List<MappingCarrier>> GetAllMappingCarrier()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var list = await _mappingCarrierRep.ToListAsync();
|
|
|
|
|
await _sysCacheService.SetAllMappingCarrier(list);
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task CacheMappingCarrier()
|
|
|
|
|
{
|
|
|
|
|
var list = await _mappingCarrierRep.ToListAsync();
|
|
|
|
|
await _sysCacheService.SetAllMappingCarrier(list);
|
|
|
|
|
}
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task<List<CodeVessel>> GetAllVessel()
|
|
|
|
|
{
|
|
|
|
@ -238,7 +321,11 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task CacheVessel()
|
|
|
|
|
{
|
|
|
|
|
var list = await _codeVesselRep.ToListAsync();
|
|
|
|
|
await _sysCacheService.SetAllCodeVessel(list);
|
|
|
|
|
}
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task<List<CodeForwarder>> GetAllForwarder()
|
|
|
|
|
{
|
|
|
|
|