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; using System.Collections.Generic; using System; using Myshipping.Core.Entity.CommonDB; using Microsoft.Extensions.Logging; using Myshipping.Core.Service.CommonDB.Dto; namespace Myshipping.Core.Service; /// /// 公共库分页处理 /// [ApiDescriptionSettings(Name = "CommonDBPage", Order = 1000)] public class CommonDBPageService : IDynamicApiController, ITransient { #region private readonly SqlSugarRepository _codeCarrierRep; private readonly SqlSugarRepository _mappingCarrierRep; private readonly SqlSugarRepository _codeVesselRep; private readonly SqlSugarRepository _mappingVesselRep; private readonly SqlSugarRepository _codeForwarderRep; private readonly SqlSugarRepository _codeYardRep; private readonly SqlSugarRepository _mappingYardRep; private readonly SqlSugarRepository _codePortLoadrRep; private readonly SqlSugarRepository _codePortRep; private readonly SqlSugarRepository _codePackageRep; private readonly SqlSugarRepository _codeServiceRep; private readonly SqlSugarRepository _codeCtnRep; private readonly SqlSugarRepository _mappingCtnRep; private readonly SqlSugarRepository _codeFrtRep; private readonly SqlSugarRepository _mappingFrtRep; private readonly SqlSugarRepository _mappingPortLoadRep; private readonly SqlSugarRepository _mappingPortRep; private readonly SqlSugarRepository _mappingPackageRep; private readonly SqlSugarRepository _mappingServiceRep; private readonly ISysCacheService _sysCacheService; private readonly SqlSugarRepository _codeIssueTypeRep; private readonly SqlSugarRepository _commonModuleRep; private readonly ILogger _logger; private readonly SqlSugarRepository _codeLaneRep; private readonly SqlSugarRepository _relaPortCarrierLaneRep; private readonly SqlSugarRepository _codeCountryRep; public CommonDBPageService(SqlSugarRepository codeCarrierRep, SqlSugarRepository codeVesselRep, SqlSugarRepository codeForwarderRep, SqlSugarRepository codeYardRep, SqlSugarRepository codePortLoadrRep, SqlSugarRepository codePortRep, SqlSugarRepository codePackageRep, SqlSugarRepository codeServiceRep, SqlSugarRepository codeCtnRep, SqlSugarRepository codeFrtRep, SqlSugarRepository mappingCarrierRep, SqlSugarRepository mappingVesselRep, SqlSugarRepository mappingCtnRep, SqlSugarRepository mappingFrtRep, SqlSugarRepository mappingYardRep, SqlSugarRepository mappingPortLoadRep, SqlSugarRepository mappingPortRep, SqlSugarRepository mappingPackageRep, SqlSugarRepository mappingServiceRep, SqlSugarRepository codeIssueTypeRep, SqlSugarRepository commonModuleRep, ILogger logger, ISysCacheService sysCacheService, SqlSugarRepository codeLaneRep, SqlSugarRepository relaPortCarrierLaneRep, SqlSugarRepository codeCountryRep) { _codeCarrierRep = codeCarrierRep; _codeVesselRep = codeVesselRep; _codeForwarderRep = codeForwarderRep; _codeYardRep = codeYardRep; _codePortLoadrRep = codePortLoadrRep; _codePortRep = codePortRep; _codePackageRep = codePackageRep; _codeServiceRep = codeServiceRep; _codeCtnRep = codeCtnRep; _codeFrtRep = codeFrtRep; _mappingCarrierRep = mappingCarrierRep; _mappingVesselRep = mappingVesselRep; _mappingCtnRep = mappingCtnRep; _mappingFrtRep = mappingFrtRep; _mappingYardRep = mappingYardRep; _sysCacheService = sysCacheService; _mappingPortLoadRep = mappingPortLoadRep; _mappingPortRep = mappingPortRep; _mappingPackageRep = mappingPackageRep; _mappingServiceRep = mappingServiceRep; _codeIssueTypeRep = codeIssueTypeRep; _commonModuleRep = commonModuleRep; _logger = logger; _codeLaneRep = codeLaneRep; _relaPortCarrierLaneRep = relaPortCarrierLaneRep; _codeCountryRep = codeCountryRep; } #endregion #region 船公司 /// /// 获取船公司列表信息 /// [HttpGet("/commondbpage/carrierlist")] public async Task CarrierList([FromQuery] NameQueryDto input) { return await _codeCarrierRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取船公司映射列表信息 /// [HttpGet("/commondbpage/mappingcarrierlist")] public async Task MappingCarrierList([FromQuery] MappingQueryDto input) { return await _mappingCarrierRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 船名 /// /// 获取船名列表信息 /// [HttpGet("/commondbpage/vessellist")] public async Task VesselList([FromQuery] NameQueryDto input) { return await _codeVesselRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取船名映射 /// [HttpGet("/commondbpage/mappingvessellist")] public async Task MappingVesselList([FromQuery] MappingQueryDto input) { return await _mappingVesselRep.AsQueryable().Where(x => x.Module == input.Module) .WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 船代 /// /// 获取船代列表信息 /// [HttpGet("/commondbpage/forwarderlist")] public async Task ForwarderList([FromQuery] NameQueryDto input) { return await _codeForwarderRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 场站 /// /// 获取场站列表信息 /// [HttpGet("/commondbpage/yardlist")] public async Task YardList([FromQuery] NameQueryDto input) { return await _codeYardRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.ShowCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取场站映射 /// [HttpGet("/commondbpage/mappingyardlist")] public async Task MappingYardList([FromQuery] MappingQueryDto input) { return await _mappingYardRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 起始港 /// /// 获取起始港信息 /// [HttpGet("/commondbpage/portloadlist")] public async Task PortloadList([FromQuery] NameQueryDto input) { return await _codePortLoadrRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取起始港映射 /// [HttpGet("/commondbpage/mappingportloadlist")] public async Task PortloadList([FromQuery] MappingQueryDto input) { return await _mappingPortLoadRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 目的港 /// /// 获取目的港信息 /// [HttpGet("/commondbpage/portlist")] public async Task PortList([FromQuery] NameQueryDto input) { return await _codePortRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取目的港映射 /// [HttpGet("/commondbpage/mappingportlist")] public async Task PortList([FromQuery] MappingQueryDto input) { return await _mappingPortRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 包装 /// /// 获取包装信息 /// [HttpGet("/commondbpage/package")] public async Task PackageList([FromQuery] NameQueryDto input) { return await _codePackageRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取包装映射 /// [HttpGet("/commondbpage/mappingpackage")] public async Task MappingPackageList([FromQuery] MappingQueryDto input) { return await _mappingPackageRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 运输条款 /// /// 获取运输条款信息 /// [HttpGet("/commondbpage/service")] public async Task ServiceList([FromQuery] NameQueryDto input) { return await _codeServiceRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取运输条款映射 /// [HttpGet("/commondbpage/mappingservice")] public async Task MappingServiceList([FromQuery] MappingQueryDto input) { return await _mappingServiceRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 箱型 /// /// 获取箱型信息 /// [HttpGet("/commondbpage/ctn")] public async Task CtnList([FromQuery] NameQueryDto input) { return await _codeCtnRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderByDescending(x=>x.CreateTime).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取箱型映射列表信息 /// [HttpGet("/commondbpage/mappingctnlist")] public async Task MappingCtnList([FromQuery] MappingQueryDto input) { return await _mappingCtnRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 付费方式 /// /// 付费方式 /// [HttpGet("/commondbpage/frt")] public async Task FrtList([FromQuery] NameQueryDto input) { return await _codeFrtRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } /// /// 获取付费映射列表信息 /// [HttpGet("/commondbpage/mappingfrtlist")] public async Task MappingFrtList([FromQuery] MappingQueryDto input) { return await _mappingFrtRep.AsQueryable().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) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 签单方式 /// /// 获取签单方式信息 /// [HttpGet("/commondbpage/codeissuetypelist")] public async Task CodeIssueTypeList([FromQuery] NameQueryDto input) { return await _codeIssueTypeRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 模块列表 /// /// 获取模块信息 /// [HttpGet("/commondbpage/modules")] public async Task ModuleList([FromQuery] NameQueryDto input) { return await _commonModuleRep.AsQueryable().Select(x => new { x.Code, x.Name, x.Sort }).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 航线信息 [HttpGet("/commondbpage/CodeLaneList")] public async Task CodeLaneList([FromQuery] NameQueryDto input) { return await _codeLaneRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => (!string.IsNullOrWhiteSpace(x.Code) && x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrWhiteSpace(x.EnName) && x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrWhiteSpace(x.CnName) && x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrWhiteSpace(x.LaneType) && x.LaneType.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) ).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion #region 查询国家 [HttpGet("/commondbpage/CodeCountryList")] public async Task CodeCountryList([FromQuery] NameQueryDto input) { return await _codeCountryRep.AsQueryable().WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => (!string.IsNullOrWhiteSpace(x.Code) && x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrWhiteSpace(x.EnName) && x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrWhiteSpace(x.CnName) && x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrWhiteSpace(x.Capital) && x.Capital.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) || (!string.IsNullOrWhiteSpace(x.Continent) && x.Continent.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) ).OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.descSort)).ToPagedListAsync(input.PageNo, input.PageSize); } #endregion }