Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development
This commit is contained in:
@@ -27,23 +27,23 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
|
||||
public async Task AssignAsync(DevicePermissionSaveReuqest reuqest)
|
||||
{
|
||||
var tenantId = reuqest.AssignType == AssignTypeEnumType.Department ? reuqest.TenantId : _currentUser.GetStringTenantId();
|
||||
|
||||
//删除当前匹配的基地权限
|
||||
var p = await _dbContext.Queryable<DevicePermissionEntity>()
|
||||
.Where(x => x.AssignType == reuqest.AssignType)
|
||||
.Where(x => x.AssignValue == reuqest.AssignValue)
|
||||
.Where(x => x.UniqueType == reuqest.UniqueType)
|
||||
.Where(x => x.TenantId == tenantId)
|
||||
.ToListAsync();
|
||||
|
||||
await _dbContext.DeleteReallyAsync(p);
|
||||
|
||||
await GenerateDeviceTasksAsync(async () =>
|
||||
{
|
||||
//删除当前匹配的基地权限
|
||||
var p = await _dbContext.Queryable<DevicePermissionEntity>()
|
||||
.Where(x => x.AssignType == reuqest.AssignType)
|
||||
.Where(x => x.AssignValue == reuqest.AssignValue)
|
||||
.Where(x => x.UniqueType == reuqest.UniqueType)
|
||||
.WhereIF(reuqest.AssignType == AssignTypeEnumType.Department, x => x.TenantId == reuqest.TenantId)
|
||||
.ToListAsync();
|
||||
|
||||
await _dbContext.DeleteReallyAsync(p);
|
||||
|
||||
//保存配置的权限
|
||||
if (reuqest.Codes.IsPresent())
|
||||
{
|
||||
var tenantId = reuqest.AssignType == AssignTypeEnumType.Department ? reuqest.TenantId : _currentUser.GetStringSubjectId();
|
||||
|
||||
var devicePermissions = reuqest.Codes.Select(code => new DevicePermissionEntity
|
||||
{
|
||||
AssignType = reuqest.AssignType,
|
||||
|
||||
@@ -13,7 +13,7 @@ public class GainfoPageRequest : PageDto
|
||||
public GainfoStatusEnumType? Status { get; set; } = GainfoStatusEnumType.Working;
|
||||
|
||||
/// <summary>
|
||||
/// 部门号(部门树传入)
|
||||
/// 部门选择
|
||||
/// </summary>
|
||||
public List<string> DepartmentNos { get; set; }
|
||||
public List<TenantDepartmentRequest> DepartmentSelections { get; set; } = new List<TenantDepartmentRequest>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Request;
|
||||
|
||||
public class TenantDepartmentRequest
|
||||
{
|
||||
[Required]
|
||||
public string Tenant { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门号(部门树传入)
|
||||
/// </summary>
|
||||
public List<string> DepartmentNos { get; set; }
|
||||
}
|
||||
@@ -4,19 +4,17 @@ using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Scope;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Options;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
@@ -57,10 +55,22 @@ public class GainfoService : IGainfoService
|
||||
/// <returns></returns>
|
||||
public async Task<Pagination<GainfoPageResponse>> GetPageAsync(GainfoPageRequest request)
|
||||
{
|
||||
request.DepartmentNos = await GetRecursionDepartmentNosAsync(request.DepartmentNos);
|
||||
var currentTenantId = _currentUser.GetStringTenantId();
|
||||
|
||||
//根据组织架构搜索档案
|
||||
Expression<Func<GainfoEntity, bool>> where = LinqExpressionExtension.False<GainfoEntity>();
|
||||
foreach (var item in request.DepartmentSelections)
|
||||
{
|
||||
var depts = await GetRecursionDepartmentNosAsync(item.DepartmentNos);
|
||||
if (depts.Any())
|
||||
where = where.Or(gainfo => gainfo.Factory == item.Tenant && depts.Contains(gainfo.DepartmentNo));
|
||||
else
|
||||
where = where.Or(gainfo => gainfo.Factory == item.Tenant);
|
||||
}
|
||||
|
||||
var page = await _gainfoStore.Queryable(request.Status)
|
||||
.WhereIF(request.DepartmentNos.IsPresent(), gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
|
||||
.WhereIF(request.DepartmentSelections.IsPresent(), where)
|
||||
.WhereIF(request.DepartmentSelections.IsEmpty(), gainfo => gainfo.Factory == currentTenantId)
|
||||
.WhereIF(request.Search.IsPresent(), gainfo =>
|
||||
gainfo.Name.Contains(request.Search)
|
||||
|| gainfo.Code.Contains(request.Search)
|
||||
@@ -574,13 +584,10 @@ public class GainfoService : IGainfoService
|
||||
void RecursionGetNext(string currentCode, List<DepartmentEntity> departments, List<string> result)
|
||||
{
|
||||
var next = departments.Where(x => x.PNo == currentCode).ToList();
|
||||
foreach (var item in next)
|
||||
{
|
||||
result.Add(item.No);
|
||||
}
|
||||
|
||||
foreach (var item in next)
|
||||
{
|
||||
result.Add(item.No);
|
||||
RecursionGetNext(item.No, departments, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DeviceUploadLogPageRequest : PageDto, IValidatableObject
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var today = DateTime.Today;
|
||||
if (SearchDateTimeDimension.HasValue)
|
||||
{
|
||||
//重新赋值
|
||||
@@ -28,37 +28,37 @@ public class DeviceUploadLogPageRequest : PageDto, IValidatableObject
|
||||
|
||||
if (SearchDateTimeDimension == DateTimeSearchEnumType.Day)
|
||||
{
|
||||
SearchDateTimePeriod.Start = new DateTime(now.Year, now.Month, now.Day, 0, 0, 1);
|
||||
SearchDateTimePeriod.End = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
|
||||
SearchDateTimePeriod.Start = today;
|
||||
SearchDateTimePeriod.End = today.AddDays(1).AddSeconds(-1);
|
||||
}
|
||||
else if (SearchDateTimeDimension == DateTimeSearchEnumType.Week)
|
||||
{
|
||||
SearchDateTimePeriod.Start = now.AddDays(1 - (int)now.DayOfWeek);
|
||||
SearchDateTimePeriod.Start = today.AddDays(1 - (int)today.DayOfWeek);
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.Start.Value.AddDays(6);
|
||||
}
|
||||
else if (SearchDateTimeDimension == DateTimeSearchEnumType.Month)
|
||||
{
|
||||
SearchDateTimePeriod.Start = new DateTime(now.Year, now.Month, 1);
|
||||
SearchDateTimePeriod.Start = new DateTime(today.Year, today.Month, 1);
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.Start.Value.AddMonths(1).AddDays(-1);
|
||||
}
|
||||
else if (SearchDateTimeDimension == DateTimeSearchEnumType.Season)
|
||||
{
|
||||
SearchDateTimePeriod.Start = now.AddMonths(0 - ((now.Month - 1) % 3));
|
||||
SearchDateTimePeriod.End = now.AddMonths(3 - ((now.Month - 1) % 3)).AddMonths(1).AddDays(-1);
|
||||
SearchDateTimePeriod.Start = new DateTime(today.Year, today.Month, 1).AddMonths(2 - ((today.Month - 1) % 3));
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.Start.Value.AddMonths(2);
|
||||
}
|
||||
else if (SearchDateTimeDimension == DateTimeSearchEnumType.HalfOfYear)
|
||||
{
|
||||
SearchDateTimePeriod.Start = now.AddDays(-180);
|
||||
SearchDateTimePeriod.End = now;
|
||||
SearchDateTimePeriod.Start = today.AddDays(-180);
|
||||
SearchDateTimePeriod.End = today;
|
||||
}
|
||||
else if (SearchDateTimeDimension == DateTimeSearchEnumType.Year)
|
||||
{
|
||||
SearchDateTimePeriod.Start = new DateTime(now.Year, 1, 1);
|
||||
SearchDateTimePeriod.Start = new DateTime(today.Year, 1, 1);
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.Start.Value.AddYears(1).AddDays(-1);
|
||||
}
|
||||
|
||||
SearchDateTimePeriod.Start = SearchDateTimePeriod.Start.Value.Date;
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.End.Value.Date;
|
||||
SearchDateTimePeriod.Start = SearchDateTimePeriod.Start.Value;
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.End.Value;
|
||||
}
|
||||
|
||||
yield break;
|
||||
|
||||
@@ -6,11 +6,18 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
|
||||
public class DeviceTaskAssignmentRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备类型
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(DeviceTypeEnumType))]
|
||||
public DeviceTypeEnumType? Type { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(DeviceTaskEnumType))]
|
||||
public DeviceTaskEnumType? Type { get; set; }
|
||||
public DeviceTaskEnumType? TaskType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务下发状态
|
||||
|
||||
@@ -27,13 +27,19 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
|
||||
{
|
||||
var page = await _dbContext.Queryable<DeviceTaskEntity>()
|
||||
.LeftJoin<GainfoEntity>((deviceTask, ga) => deviceTask.UserNo == ga.No)
|
||||
.LeftJoin<DeviceEntity>((deviceTask, ga,device) => deviceTask.DeviceUniqueNo == device.UniqueNo)
|
||||
.WhereIF(!request.Search.IsEmpty(), (deviceTask, ga,device) => deviceTask.UserNo == request.Search || ga.Name.Contains(request.Search) || ga.Code == request.Search || deviceTask.DeviceUniqueNo == request.Search || deviceTask.ModifiedTime.ToString("yyyy-MM-dd").Contains(request.Search))
|
||||
.WhereIF(request.Type.HasValue, deviceTask => deviceTask.Type == request.Type)
|
||||
.LeftJoin<DeviceEntity>((deviceTask, ga, device) => deviceTask.DeviceUniqueNo == device.UniqueNo)
|
||||
.WhereIF(!request.Search.IsEmpty(), (deviceTask, ga, device) =>
|
||||
deviceTask.UserNo == request.Search
|
||||
|| ga.Name.Contains(request.Search)
|
||||
|| ga.Code == request.Search
|
||||
|| deviceTask.DeviceUniqueNo == request.Search
|
||||
)
|
||||
.WhereIF(request.TaskType.HasValue, deviceTask => deviceTask.Type == request.TaskType)
|
||||
.WhereIF(request.Type.HasValue, (deviceTask, ga, device) => device.Type == request.Type)
|
||||
.WhereIF(request.Status.HasValue, deviceTask => deviceTask.Status == request.Status)
|
||||
.Where(deviceTask => 1 == 1)
|
||||
.OrderBy(deviceTask => deviceTask.CreateTime, OrderByType.Desc)
|
||||
.Select((deviceTask, ga,device) => new DeviceTaskAssignmentResponse
|
||||
.Select((deviceTask, ga, device) => new DeviceTaskAssignmentResponse
|
||||
{
|
||||
Id = deviceTask.Id,
|
||||
DeviceUniqueNo = deviceTask.DeviceUniqueNo,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Sys.Identity.Request;
|
||||
using Dlhis.Sys.Identity.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
@@ -71,23 +70,26 @@ public class TenantService : ITenantService
|
||||
public async Task<List<TenantResponse>> GetMyTenantsAsync()
|
||||
{
|
||||
var userId = _currentUser.GetIntSubjectId();
|
||||
var tenantId = _currentUser.GetStringTenantId();
|
||||
|
||||
var myTenants = await _dbContext.Queryable<UserTenantEntity>()
|
||||
.LeftJoin<TenantEntity>((ut, t) => ut.TenantCode == t.Code)
|
||||
.Where(ut => ut.UserId == userId)
|
||||
.Select((ut, t) => new TenantResponse
|
||||
{
|
||||
Id = t.Id,
|
||||
PCode = t.PCode,
|
||||
Code = t.Code,
|
||||
Name = t.Name,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (myTenants.IsEmpty())
|
||||
{
|
||||
myTenants = await GetListAsync();
|
||||
}
|
||||
var currentTenant = myTenants.First(x => x.Code == tenantId);
|
||||
var otherTenants = myTenants.Where(x => x.Code != tenantId);
|
||||
|
||||
return myTenants;
|
||||
var result = new List<TenantResponse> { currentTenant };
|
||||
result.AddRange(otherTenants);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<TenantTreeResponse>> GetTreeAsync()
|
||||
|
||||
Reference in New Issue
Block a user