fix 优化档案详情查询

This commit is contained in:
2024-03-26 11:43:13 +08:00
parent d71f080cd3
commit f9ea61ba49

View File

@@ -424,13 +424,9 @@ public class GainfoService : IGainfoService
{ {
var info = await _gainfoStore.Queryable(request.Status) var info = await _gainfoStore.Queryable(request.Status)
.LeftJoin<DepartmentEntity>((ga, de) => ga.DepartmentNo == de.No) .LeftJoin<DepartmentEntity>((ga, de) => ga.DepartmentNo == de.No)
.LeftJoin<BasicTypeEntity>((ga, de, type) => ga.Native == type.Code && type.Type == "native") .LeftJoin<PositionEntity>((ga, de, pos) => ga.Position == pos.Name)
.LeftJoin<PositionEntity>((ga, de, type, posi) => ga.Position == posi.Name)
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3, type4) => ga.IdClass == type4.Code && type4.Type == "cls")
.Where(ga => ga.No == request.No) .Where(ga => ga.No == request.No)
.Select((ga, de, type, posi, type2, type3, type4) => new GainfoDetailResponse .Select((ga, de, pos) => new GainfoDetailResponse
{ {
No = ga.No, No = ga.No,
SapNo = ga.SapNo, SapNo = ga.SapNo,
@@ -440,26 +436,34 @@ public class GainfoService : IGainfoService
IdClass = ga.IdClass, IdClass = ga.IdClass,
IdNo = ga.IdNo, IdNo = ga.IdNo,
Gender = ga.Gender, Gender = ga.Gender,
NativeName = type.Display,
Address = ga.Address, Address = ga.Address,
Birthday = ga.Birthday, Birthday = ga.Birthday,
Phone = ga.Phone, Phone = ga.Phone,
Position = ga.Position, Position = ga.Position,
Grade = posi.Grade, Grade = pos.Grade,
Degree = ga.Degree, Degree = ga.Degree,
Werks = ga.Werks, Werks = ga.Werks,
CostId = ga.CostId, CostId = ga.CostId,
Marital = ga.Marital == "Single" ? "未婚" : "已婚", Marital = ga.Marital == "Single" ? "未婚" : "已婚",
CountryName = type2.Display, NativeName = ga.Native,
NationName = type3.Display, CountryName = ga.CountryNo,
ClassName = type4.Display, NationName = ga.Nation,
ClassName = ga.IdClass,
Factory = ga.Factory, Factory = ga.Factory,
OnboardingDate = ga.CreateTime, OnboardingDate = ga.CreateTime,
}) })
.FirstAsync(); .SingleAsync();
if (info != null) if (info != null)
{ {
var searchTypes = new List<string>() { "native", "country", "nation", "cls" };
var types = await _dbContext.Queryable<BasicTypeEntity>().Where(x => searchTypes.Contains(x.Type)).ToListAsync();
info.NativeName = types.Where(x => x.Type == "native").FirstOrDefault(x => x.Code == info.NativeName)?.Display;
info.CountryName = types.Where(x => x.Type == "country").FirstOrDefault(x => x.Code == info.CountryName)?.Display;
info.NationName = types.Where(x => x.Type == "nation").FirstOrDefault(x => x.Code == info.NationName)?.Display;
info.ClassName = types.Where(x => x.Type == "cls").FirstOrDefault(x => x.Code == info.ClassName)?.Display;
if (request.WithFace) if (request.WithFace)
{ {
info.Face = await _dbContext.ChangeDb("face").Queryable<GainfoFaceEntity>().Where(x => x.UserCode == info.Code).Select(x => x.Face).SingleAsync(); info.Face = await _dbContext.ChangeDb("face").Queryable<GainfoFaceEntity>().Where(x => x.UserCode == info.Code).Select(x => x.Face).SingleAsync();