feat 外包人员,框架升级
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
using Dlhis.Basic.BusinessPlace.Response;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Places.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
@@ -33,8 +33,8 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
public async Task<Pagination<BusinessPlaceResponse>> GetPlaceByGainfoAsync(DeviceAssRequest request)
|
||||
{
|
||||
var gainfo = await _gainfoStore.Queryable()
|
||||
.Where(x => x.No == request.UserNo)
|
||||
.FirstAsync();
|
||||
.Where(x => x.No == request.UserNo)
|
||||
.FirstAsync();
|
||||
|
||||
if (gainfo == null)
|
||||
{
|
||||
@@ -53,26 +53,26 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
.Where(x => deviceCodes.Contains(x.Code))
|
||||
.Where((x, dr) => dr.BusinessPlaceCode.HasValue)
|
||||
.Select((x, dr, place, ps, s) => new BusinessPlaceResponse
|
||||
{
|
||||
Id = place.Id,
|
||||
Code = place.Code,
|
||||
Status = place.Status,
|
||||
Name = place.Name,
|
||||
Catalog = place.Catalog,
|
||||
CustomCode = place.CustomCode,
|
||||
Source = place.Source,
|
||||
{
|
||||
Id = place.Id,
|
||||
Code = place.Code,
|
||||
Status = place.Status,
|
||||
Name = place.Name,
|
||||
Catalog = place.Catalog,
|
||||
CustomCode = place.CustomCode,
|
||||
Source = place.Source,
|
||||
|
||||
ShiftCode = s.Code,
|
||||
ShiftName = s.Name
|
||||
})
|
||||
.Distinct()
|
||||
.ToPageListAsync(request);
|
||||
ShiftCode = s.Code,
|
||||
ShiftName = s.Name
|
||||
})
|
||||
.Distinct()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
public async Task<List<GetDevicesUnderGroupByUserNoResponse>> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode)
|
||||
{
|
||||
var deviceGroups = await _dbContext.Queryable<DeviceGroupEntity>().ToListAsync();
|
||||
var currentGroup = deviceGroups.Where(x => x.Code == deviceGroupCode).FirstOrDefault();
|
||||
var currentGroup = deviceGroups.FirstOrDefault(x => x.Code == deviceGroupCode);
|
||||
if (currentGroup == null)
|
||||
{
|
||||
return new List<GetDevicesUnderGroupByUserNoResponse>();
|
||||
@@ -87,46 +87,46 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
foreach (var groupcode in groups)
|
||||
{
|
||||
var nos = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||
.LeftJoin<DeviceEntity>((x, d) => x.DeviceCode == d.Code)
|
||||
.Where(x => groupcode == x.GroupCode)
|
||||
.Select((x, d) => d.UniqueNo)
|
||||
.ToListAsync();
|
||||
.LeftJoin<DeviceEntity>((x, d) => x.DeviceCode == d.Code)
|
||||
.Where(x => groupcode == x.GroupCode)
|
||||
.Select((x, d) => d.UniqueNo)
|
||||
.ToListAsync();
|
||||
|
||||
var page = await _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,
|
||||
})
|
||||
.ToListAsync();
|
||||
.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,
|
||||
})
|
||||
.ToListAsync();
|
||||
var deviceUniqueNos = page.Select(x => x.UniqueNo).ToList();
|
||||
|
||||
var balanceInfos = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.Type == BalanceRecordTypeEnumType.Out)
|
||||
.Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
|
||||
.Select(x => new
|
||||
{
|
||||
x.DeviceUniqueNo,
|
||||
Amount = SqlFunc.AggregateSum(x.Amount),
|
||||
UserCount = SqlFunc.AggregateDistinctCount(x.UserCode)
|
||||
})
|
||||
.GroupBy(x => x.DeviceUniqueNo)
|
||||
.ToListAsync();
|
||||
.Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
|
||||
.Select(x => new
|
||||
{
|
||||
x.DeviceUniqueNo,
|
||||
Amount = SqlFunc.AggregateSum(x.Amount),
|
||||
UserCount = SqlFunc.AggregateDistinctCount(x.UserCode)
|
||||
})
|
||||
.GroupBy(x => x.DeviceUniqueNo)
|
||||
.ToListAsync();
|
||||
|
||||
page.ForEach(device =>
|
||||
{
|
||||
@@ -145,6 +145,7 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
};
|
||||
lst.Add(res);
|
||||
}
|
||||
|
||||
return lst;
|
||||
}
|
||||
|
||||
@@ -153,21 +154,21 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
var ids = await _devicePermissionService.GetAssignDeviceCodesAsync(request.UserNo);
|
||||
|
||||
var page = await _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)
|
||||
.WhereIF(request.DeviceType.HasValue, d => d.Type == request.DeviceType)
|
||||
.Where(d => ids.Contains(d.Code))
|
||||
.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
|
||||
}, true)
|
||||
.ToPageListAsync(request);
|
||||
.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)
|
||||
.WhereIF(request.DeviceType.HasValue, d => d.Type == request.DeviceType)
|
||||
.Where(d => ids.Contains(d.Code))
|
||||
.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
|
||||
}, true)
|
||||
.ToPageListAsync(request);
|
||||
|
||||
var deviceUniqueNos = page.Data.Select(x => x.UniqueNo).ToList();
|
||||
|
||||
@@ -193,7 +194,6 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
});
|
||||
|
||||
return page;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -206,8 +206,8 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
if (gainfo == null && request.IsLeave)
|
||||
{
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
||||
.Where(x => x.No == request.UserNo)
|
||||
.SingleAsync();
|
||||
.Where(x => x.No == request.UserNo)
|
||||
.SingleAsync();
|
||||
|
||||
if (gainfo != null)
|
||||
{
|
||||
@@ -217,23 +217,24 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
|
||||
gainfo.ThrowIfNull("档案数据不存在");
|
||||
|
||||
//获取人员的设备权限
|
||||
var deviceCodes = await _devicePermissionService.GetAssignDeviceCodesAsync(request.UserNo);
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceCodes.Contains(x.Code)).ToListAsync();
|
||||
|
||||
var tasks = devices.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
UserId = gainfo.Id,
|
||||
CancellationId = 0,
|
||||
Version = 0,
|
||||
UserId = gainfo!.Id,
|
||||
Source = null,
|
||||
DeviceUniqueNo = x.UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
UserNo = request.UserNo,
|
||||
Type = request.IsLeave ? DeviceTaskEnumType.Delete : DeviceTaskEnumType.Add,
|
||||
Type = request.IsLeave
|
||||
? DeviceTaskEnumType.Delete
|
||||
: DeviceTaskEnumType.Add,
|
||||
DeviceType = x.Type,
|
||||
TenantId = gainfo.Factory,
|
||||
Priority = 10
|
||||
})
|
||||
.ToList();
|
||||
}).ToList();
|
||||
|
||||
await _dbContext.InsertAsync(tasks);
|
||||
}
|
||||
@@ -258,4 +259,4 @@ public class GainfoPermissionService : IGainfoPermissionService
|
||||
|
||||
yield return current.Code;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user