fix 子查询补充过滤

This commit is contained in:
2025-12-17 11:04:56 +08:00
parent b409f6f375
commit 4bca8859ef
4 changed files with 55 additions and 44 deletions

View File

@@ -467,7 +467,8 @@ public class DevicePermissionService : IDevicePermissionService
var departmentNos = RecursionHelper.HandlerDepartmentNextCodes(currentDepartmentNo, departments);
return new
{
tenantId = arr.First(), departmentNos
tenantId = arr.First(),
departmentNos
};
});
@@ -603,8 +604,10 @@ public class DevicePermissionService : IDevicePermissionService
var devicePermissionManuallyUserNos = await _dbContext.Queryable<GainfoEntity>()
.Where(x => SqlFunc.Subqueryable<DevicePermissionManuallyEntity>()
.EnableTableFilter()
.Where(p => p.DeviceCode == device.Code)
.Where(p => p.UserNo == x.No).Any())
.Where(p => p.UserNo == x.No)
.Any())
.Select(x => x.No)
.ToListAsync();
@@ -626,6 +629,7 @@ public class DevicePermissionService : IDevicePermissionService
// 获取与指定设备关联的分组编码
var groupCodes = await _dbContext.Queryable<DeviceGroupEntity>()
.Where(x => SqlFunc.Subqueryable<DeviceGroupRelationshipEntity>()
.EnableTableFilter()
.Where(p => p.GroupCode == x.Code)
.Where(p => p.DeviceCode == deviceCode)
.Any())
@@ -663,8 +667,10 @@ public class DevicePermissionService : IDevicePermissionService
{
return await _dbContext.Queryable<GainfoEntity>()
.Where(x => SqlFunc.Subqueryable<DevicePermissionManuallyEntity>()
.EnableTableFilter()
.Where(p => p.DeviceCode == deviceCode)
.Where(p => p.UserNo == x.No).Any())
.Where(p => p.UserNo == x.No)
.Any())
.Select(x => x.No)
.ToListAsync();
}

View File

@@ -131,7 +131,11 @@ public class GainfoOutsourceService : IGainfoOutsourceService
{
var outsources = await _dbContext.Queryable<GainfoEntity>()
.Where(x => x.Type == GainfoUserTypeEnumType.Outsource)
.Where(x => SqlFunc.Subqueryable<OutsourceWhiteListEntity>().Where(p => p.UserCode == x.Code).NotAny())//不存在白名单中
.Where(x => SqlFunc.Subqueryable<OutsourceWhiteListEntity>()
.Where(p => p.UserCode == x.Code)
.Where(p => p.IsDeleted == false)
.NotAny()
)//不存在白名单中
.Select(x => new { x.Id, x.Code, x.Factory, x.CreateTime })
.ToListAsync();

View File

@@ -50,7 +50,7 @@ public class EFenceService : IEFenceService
Name = x.Name,
Description = x.Description,
DirectionType = x.DirectionType,
DeviceCount = SqlFunc.Subqueryable<EFenceDeviceRelationEntity>().Where(p => p.EFenceCode == x.Code).Count(),
DeviceCount = SqlFunc.Subqueryable<EFenceDeviceRelationEntity>().Where(p => p.EFenceCode == x.Code).Where(p => p.IsDeleted == false).Count(),
})
.ToPageListAsync(request);
@@ -84,6 +84,7 @@ public class EFenceService : IEFenceService
.Where(d => deviceCodes.Contains(d.Code))
.Where(d => SqlFunc.Subqueryable<EFenceDeviceRelationEntity>()
.Where(p => p.DeviceCode == d.Code)
.Where(p => p.IsDeleted == false)
.NotAny() //不可重复分配
)
.ToListAsync();

View File

@@ -23,7 +23,7 @@
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": true,
"Generate": true
"Generate": false
},
"SwaggerOptions": {
"Enable": true,