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