GetMultiClientList接口优化

dev
cjy 1 month ago
parent ce0d9bbfaf
commit 66c0bb40a9

@ -596,410 +596,333 @@ public class ClientCommonService : IClientCommonService
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = new List<ClientSelectMultiRes>();
var parList = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
var carrier = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsCarrier == true)
.Select((a, b) => new ClientSelectRes
var clientList = tenantDb.Queryable<InfoClient>()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt());
var carrier = await clientList.Where(a=> SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsCarrier == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("carrier", carrier));
var yard = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsYard == true)
.Select((a, b) => new ClientSelectRes
var yard = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsYard == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
)
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("yard", yard));
var booking = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsBooking == true)
.Select((a, b) => new ClientSelectRes
var booking = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsBooking == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("booking", booking));
var truck = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsTruck == true)
.Select((a, b) => new ClientSelectRes
var truck = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsTruck == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("truck", truck));
var controller = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsController == true)
.Select((a, b) => new ClientSelectRes
var controller = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsController == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("controller", controller));
var custom = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsCustom == true)
.Select((a, b) => new ClientSelectRes
var custom = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsCustom == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("custom", custom));
var agent = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsAgent == true)
.Select((a, b) => new ClientSelectRes
var agent = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsAgent == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("agent", agent));
var agentcn = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsAgentCn == true)
.Select((a, b) => new ClientSelectRes
var agentcn = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsAgentCn == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("agentcn", agentcn));
var express = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsExpress == true)
.Select((a, b) => new ClientSelectRes
var express = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsExpress == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("express", express));
var airlines = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsAirLines == true)
.Select((a, b) => new ClientSelectRes
var airlines = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsAirLines == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("airlines", airlines));
var shipper = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsShipper == true)
.Select((a, b) => new ClientSelectRes
var shipper = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsShipper == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("shipper", shipper));
var shippercn = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsShipperCn == true)
.Select((a, b) => new ClientSelectRes
var shippercn = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsShipperCn == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("shippercn", shippercn));
var notifyparty = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsNotifyParty == true)
.Select((a, b) => new ClientSelectRes
var notifyparty = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsNotifyParty == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("notifyparty", notifyparty));
var warehouse = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsWareHouse == true)
.Select((a, b) => new ClientSelectRes
var warehouse = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsWareHouse == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("warehouse", warehouse));
var wharf = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsWharf == true)
.Select((a, b) => new ClientSelectRes
var wharf = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsWharf == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("wharf", wharf));
var insurer = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsInsurer == true)
.Select((a, b) => new ClientSelectRes
var insurer = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsInsurer == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("insurer", insurer));
var leasing = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsLeasing == true)
.Select((a, b) => new ClientSelectRes
var leasing = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsLeasing == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("leasing", leasing));
var tradingagency = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsTradingAgency == true)
.Select((a, b) => new ClientSelectRes
var tradingagency = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsTradingAgency == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("tradingagency", tradingagency));
var shipagency = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsShipAgency == true)
.Select((a, b) => new ClientSelectRes
var shipagency = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsShipAgency == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
data.Add(new ClientSelectMultiRes("shipagency", shipagency));
var enterprise = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsEnterprise == true)
.Select((a, b) => new ClientSelectRes
var enterprise = await clientList.Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsEnterprise == true).Any())
.Select(a => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent
}
).Mapper(it =>
BLContent = a.BLContent,
})
.Mapper(it =>
{
it.ClientParams = tenantDb.Queryable<InfoClientParam>()
.Where(x => x.CustomerId == it.Id && x.Status == StatusEnum.Enable)
.Select<ClientParamRes>()
.ToList();
}).ToListAsync();
data.Add(new ClientSelectMultiRes("enterprise", enterprise));
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
})
.ToListAsync();
return await Task.FromResult(DataResult<List<ClientSelectMultiRes>>.Success(data));
}

Loading…
Cancel
Save