fix 优化子查询问题
This commit is contained in:
@@ -151,7 +151,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
_ => throw new UserFriendlyException("不支持当前设备类型")
|
||||
};
|
||||
|
||||
return await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
var r = await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.LeftJoin<DeviceEntity>((x, device) => x.DeviceUniqueNo == device.UniqueNo)
|
||||
.LeftJoin<GainfoEntity>((x, device, ga) => x.UserUniqueNo == ga.Code)
|
||||
.LeftJoin<OutsourceEntity>((x, device, ga, os) => x.UserUniqueNo == os.Code)
|
||||
@@ -176,7 +176,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
OriginUserUniqueNo = x.UserUniqueNo,
|
||||
OutsourceSupplier = os.Supplier,
|
||||
SapUserCode = os.SapCode,
|
||||
SapUserName = SqlFunc.Subqueryable<GainfoEntity>().Where(p => p.Code == os.SapCode).Select(p => p.Name),
|
||||
//SapUserName = ,
|
||||
DeviceUniqueNo = x.DeviceUniqueNo,
|
||||
RaiseDateTime = x.RaiseDateTime,
|
||||
CreateTime = x.CreateTime,
|
||||
@@ -189,5 +189,20 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
Status = x.Status,
|
||||
})
|
||||
.ToPageListAsync(request);
|
||||
|
||||
|
||||
var sapUserCodes = r.Data.Select(x => x.SapUserCode).Distinct().ToList();
|
||||
|
||||
var gainfos = await _dbContext.Queryable<GainfoEntity>().Where(x => sapUserCodes.Contains(x.Code)).Select(x => new { x.Code, x.Name }).ToListAsync();
|
||||
foreach (var item in r.Data)
|
||||
{
|
||||
var s = gainfos.FirstOrDefault(x => x.Code == item.SapUserCode);
|
||||
if (s != null)
|
||||
{
|
||||
item.SapUserName = s.Name;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user