fix 手动添加isDeleted

This commit is contained in:
2025-04-02 15:01:09 +08:00
parent cbe0c583b4
commit 2c67fda9a6
7 changed files with 23 additions and 75 deletions

View File

@@ -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>>();

View File

@@ -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>

View File

@@ -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);
}

View File

@@ -26,57 +26,6 @@ public class GainfoPermissionService : IGainfoPermissionService
}
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)
{

View File

@@ -82,7 +82,6 @@ public class GainfoUpdateService : IGainfoUpdateService
}
}
public async Task TodoByCodeAsync(string code)
{
_logger.LogInformation("SAP根据学工号同步开始:{code}", code);

View File

@@ -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))

View File

@@ -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
}