optimize
wet 2 years ago
parent 1569ca79b5
commit 4450ece685

@ -241,6 +241,10 @@ namespace Myshipping.Application
MDATA mDATA = new MDATA();
List<CTNDATAItem> CTNDATA = new List<CTNDATAItem>();
mDATA = order.Adapt<MDATA>();
var FORWARDER = mDATA.FORWARDER;
mDATA.FORWARDER = _cache.GetAllMappingForwarder().Result.Where(x => x.Code == FORWARDER && x.Module == "cangdan").Select(x => x.MapCode).FirstOrDefault() == null ?
_cache.GetAllCodeForwarder().Result.Where(x => x.Code == FORWARDER).Select(x => x.Name).FirstOrDefault() :
_cache.GetAllMappingForwarder().Result.Where(x => x.Code == FORWARDER && x.Module == "cangdan").Select(x => x.MapCode).FirstOrDefault();
CTNDATA = ctns.Adapt<List<CTNDATAItem>>();
custEDIDtos.Add(
new CustEDIDto

@ -144,6 +144,10 @@ public class CommonConst
/// </summary>
public const string CACHE_KEY_COMMON_DB_MAPPING_YARD = "CommonDbMappingYard";
/// <summary>
/// 船代映射
/// </summary>
public const string CACHE_KEY_COMMON_DB_MAPPING_FORWARDER = "CommonDbMappingForwarder";
/// <summary>
/// 起始港映射
/// </summary>
public const string CACHE_KEY_COMMON_DB_MAPPING_PORTLOAD = "CommonDbMappingPortLoad";

@ -80,6 +80,9 @@ namespace Myshipping.Core.Job
//签单映射
await App.GetService<ICommonDBService>().GetAllMappingIssueType(true);
//船代映射
await App.GetService<ICommonDBService>().GetAllMappingForwarder(true);
//缓存EDI数据
await App.GetService<IDjyEdiSettingService>().CacheData(true);

@ -982,6 +982,26 @@
备注
</summary>
</member>
<member name="P:Myshipping.Core.Entity.MappingForwarder.Code">
<summary>
代码
</summary>
</member>
<member name="P:Myshipping.Core.Entity.MappingForwarder.Module">
<summary>
模块
</summary>
</member>
<member name="P:Myshipping.Core.Entity.MappingForwarder.MapCode">
<summary>
映射code
</summary>
</member>
<member name="P:Myshipping.Core.Entity.MappingForwarder.Remark">
<summary>
备注
</summary>
</member>
<member name="P:Myshipping.Core.Entity.CodeFrt.Code">
<summary>
代码

@ -145,6 +145,13 @@ public interface ISysCacheService
/// </summary>
/// <returns></returns>
Task<List<MappingYard>> GetAllMappingYard();
/// <summary>
/// 获取公共库 船代映射
/// </summary>
/// <returns></returns>
Task<List<MappingForwarder>> GetAllMappingForwarder();
/// <summary>
/// 设置公共库 船公司
/// </summary>
@ -233,6 +240,11 @@ public interface ISysCacheService
/// </summary>
/// <returns></returns>
Task SetAllMappingYard(List<MappingYard> list);
/// <summary>
/// 设置公共库 船代映射
/// </summary>
/// <returns></returns>
Task SetAllMappingForwarder(List<MappingForwarder> list);
/// <summary>
/// 设置公共库 起始港映射
@ -304,6 +316,9 @@ public interface ISysCacheService
/// <returns></returns>
Task SetAllMappingIssueType(List<MappingIssueType> list);
/// <summary>
/// 设置公共库 航线
/// </summary>

@ -458,7 +458,14 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
{
return _cache.GetAsync<List<MappingYard>>(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD);
}
/// <summary>
/// 获取公共库 船代映射
/// </summary>
/// <returns></returns>
public Task<List<MappingForwarder>> GetAllMappingForwarder()
{
return _cache.GetAsync<List<MappingForwarder>>(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD);
}
/// <summary>
/// 设置公共库 船公司
@ -625,6 +632,15 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
{
return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD, list);
}
/// <summary>
/// 设置公共库 船代映射
/// </summary>
/// <returns></returns>
public Task SetAllMappingForwarder(List<MappingForwarder> list)
{
return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FORWARDER, list);
}
/// <summary>
/// 设置公共库 起始港映射
/// </summary>

@ -48,6 +48,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
private readonly SqlSugarRepository<CodeLane> _codeLaneRep;
private readonly SqlSugarRepository<RelaPortCarrierLane> _relaPortCarrierLaneRep;
private readonly SqlSugarRepository<CodeCountry> _codeCountryRep;
private readonly SqlSugarRepository<MappingForwarder> _mappingForwarder;
public CommonDBService(SqlSugarRepository<CodeCarrier> codeCarrierRep,
SqlSugarRepository<CodeVessel> codeVesselRep,
SqlSugarRepository<CodeForwarder> codeForwarderRep,
@ -74,7 +75,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
SqlSugarRepository<CodeLane> codeLaneRep,
SqlSugarRepository<RelaPortCarrierLane> relaPortCarrierLaneRep,
SqlSugarRepository<MappingIssueType> mappingIssueTypeRep,
SqlSugarRepository<CodeCountry> codeCountryRep)
SqlSugarRepository<CodeCountry> codeCountryRep,
SqlSugarRepository<MappingForwarder> mappingForwarder)
{
_codeCarrierRep = codeCarrierRep;
_codeVesselRep = codeVesselRep;
@ -103,6 +105,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
_relaPortCarrierLaneRep = relaPortCarrierLaneRep;
_codeCountryRep = codeCountryRep;
_mappingIssueTypeRep= mappingIssueTypeRep;
_mappingForwarder = mappingForwarder;
}
#endregion
@ -381,6 +384,66 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await GetAllForwarder();
}
/// <summary>
/// 获取船代映射
/// </summary>
[HttpGet("/commondb/mappingforwarderlist")]
public async Task<dynamic> MappingForwarderList([FromQuery] MappingQueryDto input)
{
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
{
throw Oops.Bah("请传入模块查询");
}
List<MappingForwarder> list = await _sysCacheService.GetAllMappingForwarder();
var queryList = list.Where(x => x.Module == input.Module)
.WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)
|| x.MapCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
if (queryList.Count() > 20)
{
return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList();
}
return queryList.OrderBy(x => x.Sort).ToList();
}
/// <summary>
/// 新增编辑船代映射信息
/// </summary>
[HttpPost("/commondb/addorupdateforwarderlist")]
public async Task AddOrUpdateMappingForwarder([FromBody] MappingForwarderDto dto)
{
var list = await _sysCacheService.GetAllMappingForwarder();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
}
var entity = dto.Adapt<MappingForwarder>();
if (string.IsNullOrWhiteSpace(dto.GID))
{
entity.GID = Guid.NewGuid().ToString();
entity.CreateTime = DateTime.Now;
entity.CreateUser = UserManager.DjyUserId;
await _mappingForwarder.InsertAsync(entity);
}
else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
entity.ModifyTime = DateTime.Now;
entity.ModifyUser = UserManager.DjyUserId;
await _mappingForwarder.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllMappingForwarder();
}
#endregion
#region 场站
@ -2015,6 +2078,26 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _sysCacheService.SetAllMappingIssueType(list);
}
}
[NonAction]
public async Task GetAllMappingForwarder(bool flag = false)
{
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FORWARDER))
{
var list = await _mappingForwarder.AsQueryable().OrderBy(x => x.MapCode).ToListAsync();
await _sysCacheService.SetAllMappingForwarder(list);
}
}
else
{
var list = await _mappingForwarder.AsQueryable().OrderBy(x => x.MapCode).ToListAsync();
await _sysCacheService.SetAllMappingForwarder(list);
}
}
#endregion

@ -36,4 +36,33 @@ namespace Myshipping.Core.Service.CommonDB.Dto
public int Sort { get; set; }
public string ShowCode { get; set; }
}
public class MappingForwarderDto
{
public string GID { get; set; }
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 模块
/// </summary>
public string Module { get; set; }
/// <summary>
/// 映射code
/// </summary>
public string MapCode { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
}
}

@ -142,6 +142,8 @@ public interface ICommonDBService
Task GetAllMappingIssueType(bool flag);
Task GetAllMappingForwarder(bool flag = false);
/// <summary>
/// 保存航线信息
/// </summary>

Loading…
Cancel
Save