fix 手动添加isDeleted
This commit is contained in:
@@ -96,15 +96,23 @@ public class DevicePermissionAnalyzeService : IDevicePermissionAnalyzeService
|
||||
|
||||
var enableFactoryPermissions = await _dbContext.Queryable<FactorySettingEntity>().ToListAsync();
|
||||
|
||||
var gainfoGroupRelationships = await _dbContext.Queryable<GainfoGroupRelationshipEntity>().Where(x => userNos.Contains(x.UserNo)).ToListAsync();
|
||||
var gainfoGroupRelationships = await _dbContext.Queryable<GainfoGroupRelationshipEntity>()
|
||||
.Where(x => x.IsDeleted == false)
|
||||
.Where(x => userNos.Contains(x.UserNo))
|
||||
.ToListAsync();
|
||||
var gainfoGroups = await _dbContext.Queryable<GainfoGroupEntity>().ToListAsync();
|
||||
|
||||
var devicePermissions = await _dbContext.Queryable<DevicePermissionEntity>()
|
||||
.Where(x => x.IsDeleted == false)
|
||||
.Select<DevicePermissionDto>()
|
||||
.ToListAsync();
|
||||
|
||||
var deviceGroups = await _dbContext.Queryable<DeviceGroupEntity>().ToListAsync();
|
||||
var deviceRelationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>().ToListAsync();
|
||||
var deviceGroups = await _dbContext.Queryable<DeviceGroupEntity>()
|
||||
.Where(x => x.IsDeleted == false)
|
||||
.ToListAsync();
|
||||
var deviceRelationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||
.Where(x => x.IsDeleted == false)
|
||||
.ToListAsync();
|
||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
||||
|
||||
var result = new ConcurrentDictionary<string, List<TenantAssignTypeDeviceCode>>();
|
||||
|
||||
@@ -22,18 +22,6 @@ public class GainfoPermissionsController : ControllerBase
|
||||
_gainfoPermissions = gainfoPermissions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据档案号 设备组查询设备
|
||||
/// </summary>
|
||||
/// <param name="userNo"></param>
|
||||
/// <param name="deviceGroupCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("devicesUnderGroupByUserNo")]
|
||||
public async Task<List<GetDevicesUnderGroupByUserNoResponse>> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode)
|
||||
{
|
||||
return await _gainfoPermissions.GetDevicesUnderGroupByUserNoAsync(userNo, deviceGroupCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户所有设备权限
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Places.Response;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
@@ -9,12 +8,9 @@ namespace Dlhis.Basic.Organization.Services;
|
||||
|
||||
public interface IGainfoPermissionService : IScopeDependency
|
||||
{
|
||||
Task<List<GetDevicesUnderGroupByUserNoResponse>> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode);
|
||||
|
||||
Task<Pagination<GainfoDevicePermissionResponse>> GetAssignDeviceCodesAsync(DeviceAssRequest request);
|
||||
|
||||
Task<Pagination<GainfoDevicePermissionResponse>> GetAssignDeviceCodesAsync(DeviceAssUserCodeRequest request);
|
||||
|
||||
|
||||
Task<DevicePermissionAssignResponse> ResetPermissionsAsync(string userNo, DeviceTaskEnumType type, List<Guid> deviceCodes, string source);
|
||||
}
|
||||
@@ -24,58 +24,7 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
_devicePermissionAnalyzeService = devicePermissionAnalyzeService;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<GetDevicesUnderGroupByUserNoResponse>> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode)
|
||||
{
|
||||
var deviceGroups = await _dbContext.Queryable<DeviceGroupEntity>().ToListAsync();
|
||||
var currentGroup = deviceGroups.FirstOrDefault(x => x.Code == deviceGroupCode);
|
||||
if (currentGroup == null)
|
||||
{
|
||||
return new List<GetDevicesUnderGroupByUserNoResponse>();
|
||||
}
|
||||
|
||||
var groups = RecursionHelper.HandlerDeviceGroupNextCodes(currentGroup.Code, deviceGroups);
|
||||
|
||||
return groups.Select(groupCode =>
|
||||
{
|
||||
var nos = _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||
.LeftJoin<DeviceEntity>((x, d) => x.DeviceCode == d.Code)
|
||||
.Where(x => groupCode == x.GroupCode)
|
||||
.Select((x, d) => d.UniqueNo)
|
||||
.ToList();
|
||||
|
||||
var page = _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
|
||||
.LeftJoin<DeviceRegistryEntity>((d, dt, dr) => d.UniqueNo == dr.DeviceUniqueNo)
|
||||
.LeftJoin<BusinessPlaceEntity>((d, dt, dr, bp) => dr.BusinessPlaceCode == bp.Code)
|
||||
.Where(d => nos.Contains(d.UniqueNo))
|
||||
.Select((d, dt, dr, bp) => new DevicePageResponse
|
||||
{
|
||||
FuncsStr = d.Funcs.ToString(),
|
||||
Brand = dt.Brand,
|
||||
Type = d.Type,
|
||||
BusinessPlaceCode = bp.Code,
|
||||
BusinessPlaceName = bp.Name,
|
||||
LastHeartbeatTime = dr.LastHeartbeatTime,
|
||||
UniqueNo = d.UniqueNo,
|
||||
Supplier = d.Supplier,
|
||||
DeployPlace = d.DeployPlace,
|
||||
DeployPosition = d.DeployPosition,
|
||||
DeployDirection = d.DeployDirection,
|
||||
TemplateCode = dt.Code,
|
||||
ConnectionInfo = d.ConnectionInfo,
|
||||
Enable = d.Enable,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return new GetDevicesUnderGroupByUserNoResponse
|
||||
{
|
||||
GroupCode = groupCode,
|
||||
Devices = page
|
||||
};
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<Pagination<GainfoDevicePermissionResponse>> GetAssignDeviceCodesAsync(DeviceAssUserCodeRequest request)
|
||||
|
||||
@@ -82,7 +82,6 @@ public class GainfoUpdateService : IGainfoUpdateService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task TodoByCodeAsync(string code)
|
||||
{
|
||||
_logger.LogInformation("SAP根据学工号同步开始:{code}", code);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SapBusinessTripService : ISapBusinessTripService
|
||||
/// <inheritdoc />
|
||||
public async Task HandlerBusinessTripsByFactoryAsync(string factory)
|
||||
{
|
||||
var today =DateTime.Today;
|
||||
var today = DateTime.Today;
|
||||
var yesterday = today.AddDays(-1);
|
||||
|
||||
try
|
||||
@@ -84,7 +84,15 @@ public class SapBusinessTripService : ISapBusinessTripService
|
||||
|
||||
if (deviceCodes.Any())
|
||||
{
|
||||
var userCodes = tripInfos.Select(x => x.Code).Distinct().ToList();
|
||||
//排除当前记录存例外的人员
|
||||
var manuallyUserCodes = await _dbContext.Queryable<DevicePermissionManuallyEntity>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => x.UserNo == ga.No)
|
||||
.Where(x => x.TenantId == factory)
|
||||
.Select((x, ga) => ga.Code)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
var userCodes = tripInfos.Select(x => x.Code).Distinct().Where(x => !manuallyUserCodes.Contains(x)).ToList();
|
||||
var gainfos = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => x.Factory != factory) //排除本基地出差
|
||||
.Where(x => userCodes.Contains(x.Code))
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BusinessPlacePermissionsService : IBusinessPlacePermissionsService
|
||||
var users = await _userApi.GetUserByIdsAsync(new IdsRequest { Ids = page.Data.Select(x => x.UserId).Distinct().ToList() });
|
||||
page.Data.ForEach(item => { item.UserName = users.FirstOrDefault(x => x.Id == item.UserId)?.UserName; });
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user