解决redis配置冲突
This commit is contained in:
@@ -20,6 +20,11 @@ public class DeviceGroupPageResponse
|
||||
/// </summary>
|
||||
public DeviceTypeEnumType? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可编辑
|
||||
/// </summary>
|
||||
public bool Editable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组类型描述
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.Device.Response;
|
||||
|
||||
public class DeviceGroupTreeResponse
|
||||
{
|
||||
@@ -17,6 +20,27 @@ public class DeviceGroupTreeResponse
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备组类型
|
||||
/// </summary>
|
||||
public DeviceTypeEnumType? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组类型描述
|
||||
/// </summary>
|
||||
public string TypeDesc
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Type.HasValue)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return Type.Value.GetDescription();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下级
|
||||
/// </summary>
|
||||
|
||||
@@ -56,8 +56,9 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<DeviceGroupEntity>();
|
||||
|
||||
entity.Editable = true;
|
||||
entity.Code = Guid.NewGuid();
|
||||
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
@@ -65,6 +66,8 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
var entity = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity.ThrowIfNull("设备组不存在,无法更新");
|
||||
|
||||
entity.Editable.ThrowIfFalse("不可编辑当前组");
|
||||
|
||||
var nextDevices = await GetDevicesAsync(entity.Code);
|
||||
if (!entity.Type.HasValue)
|
||||
{
|
||||
@@ -75,7 +78,6 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
(request.Type.HasValue && request.Type != entity.Type && nextDevices.Any()).ThrowIfTrue("分组设备类型不匹配,无法修改类型");
|
||||
}
|
||||
|
||||
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,17 @@ public class GainfosController : ControllerBase
|
||||
await _gainfoService.UploadFaceAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量上传人脸照片
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("faces")]
|
||||
public async Task UploadFaceAsync(List<GainfoUploadFaceRequest> request)
|
||||
{
|
||||
await _gainfoService.UploadFacesAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过token获取人脸照片,失效或者找不到返回HttpStatus404状态码
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -22,6 +21,8 @@ public interface IGainfoService : IScopeDependency
|
||||
|
||||
Task UploadFaceAsync(GainfoUploadFaceRequest request);
|
||||
|
||||
Task UploadFacesAsync(List<GainfoUploadFaceRequest> request);
|
||||
|
||||
Task<IActionResult> GetFaceAsync(string token);
|
||||
|
||||
Task<string> GetFaceByUserCodeAsync(string userCode);
|
||||
|
||||
@@ -255,6 +255,54 @@ public class GainfoService : IGainfoService
|
||||
});
|
||||
}
|
||||
|
||||
public async Task UploadFacesAsync(List<GainfoUploadFaceRequest> requests)
|
||||
{
|
||||
foreach (var request in requests)
|
||||
{
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.No == request.UserNo).FirstAsync();
|
||||
gainfo ??= await _gainfoStore.Queryable(GainfoStatusEnumType.External).Where(x => x.No == request.UserNo).FirstAsync();
|
||||
|
||||
gainfo.ThrowIfNull("人员档案信息不存在");
|
||||
|
||||
await Scoped.Request.Value.CreateAsync(async (sp) =>
|
||||
{
|
||||
var configuration = sp.GetService<IConfiguration>();
|
||||
var faceConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value;
|
||||
|
||||
var dbContext = sp.GetService<IDbContext>();
|
||||
//todo 切换连接字符串
|
||||
dbContext.Client.CurrentConnectionConfig.ConnectionString = faceConnectionString;
|
||||
var face = await dbContext.Queryable<GainfoFaceEntity>().Where(x => x.UserCode == gainfo.Code).SingleAsync();
|
||||
|
||||
var taskType = face == null ? DeviceTaskEnumType.Add : DeviceTaskEnumType.Update;
|
||||
if (face == null)
|
||||
{
|
||||
face = new GainfoFaceEntity
|
||||
{
|
||||
UserCode = gainfo.Code,
|
||||
Face = request.Face
|
||||
};
|
||||
|
||||
await dbContext.InsertAsync(face);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (face.Face == request.Face)
|
||||
{
|
||||
_logger.LogWarning("相同的人脸照片更新忽略");
|
||||
return;
|
||||
}
|
||||
|
||||
face.Face = request.Face;
|
||||
await dbContext.UpdateAsync(face);
|
||||
}
|
||||
|
||||
//生成任务
|
||||
await _devicePermissionService.GenerateDeviceTasksAsync(gainfo.No, taskType);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<string> GetFaceByUserCodeAsync(string userCode)
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Startup : DefaultStartup
|
||||
base.ConfigureServices(services);
|
||||
|
||||
//todo
|
||||
var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
|
||||
var redis = ConnectionMultiplexer.Connect($"192.168.199.30:30115,defaultDatabase:1,password=dlhis123");
|
||||
services.AddDataProtection()
|
||||
.SetApplicationName("basic")
|
||||
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using Dlhis.Basic.Summary.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Summary.Response;
|
||||
namespace Dlhis.Basic.Summary.Response;
|
||||
|
||||
public class AttendanceDetailSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// 考勤总人数
|
||||
/// </summary>
|
||||
public int Total => Employed + Unemployed;
|
||||
|
||||
/// <summary>
|
||||
/// 在职人数
|
||||
/// </summary>
|
||||
|
||||
@@ -37,6 +37,13 @@ public class DeviceGroupEntity : SugarBaseEntity, ITenantId, ISoftDeleted
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否可编辑
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否可编辑")]
|
||||
public bool Editable { get; set; }
|
||||
|
||||
|
||||
public string TenantId { get; set; }
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Sys.Api;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.CommonJobs;
|
||||
|
||||
@@ -13,11 +14,13 @@ public class CreateDefinitelyGroupJob
|
||||
private readonly ITenantApi _tenantApi;
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public CreateDefinitelyGroupJob(ILogger<CreateDefinitelyGroupJob> logger, ITenantApi tenantApi, IDbContext dbContext)
|
||||
public CreateDefinitelyGroupJob(ILogger<CreateDefinitelyGroupJob> logger, ITenantApi tenantApi, IDbContext dbContext, ISqlSugarOptionsService sqlSugarOptionsService)
|
||||
{
|
||||
_logger = logger;
|
||||
_tenantApi = tenantApi;
|
||||
_dbContext = dbContext;
|
||||
|
||||
sqlSugarOptionsService.IgnoreTenant = true;
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
@@ -28,11 +31,12 @@ public class CreateDefinitelyGroupJob
|
||||
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantResult.Data;
|
||||
|
||||
_logger.LogInformation("获取基地信息:{json}", JsonConvert.SerializeObject(tenants));
|
||||
|
||||
foreach (var tenant in tenants)
|
||||
{
|
||||
if (!await _dbContext.Queryable<GainfoGroupEntity>().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.IsDefault))
|
||||
{
|
||||
|
||||
var customGroup = new GainfoGroupEntity
|
||||
{
|
||||
PCode = null,
|
||||
@@ -82,6 +86,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Attendance,
|
||||
Name = "*通用考勤设备组",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
@@ -99,6 +104,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Attendance,
|
||||
Name = "*专用考勤设备组",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
@@ -121,6 +127,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Door,
|
||||
Name = "*非公共区域",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
@@ -141,6 +148,7 @@ public class CreateDefinitelyGroupJob
|
||||
Code = Guid.NewGuid(),
|
||||
Type = DeviceTypeEnumType.Door,
|
||||
Name = "*公共区域",
|
||||
Editable = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
|
||||
@@ -26,11 +26,11 @@ public class Startup : DefaultStartup
|
||||
|
||||
services.AddSingleton<IConnectionMultiplexer>(sp =>
|
||||
{
|
||||
return ConnectionMultiplexer.Connect("10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
|
||||
return ConnectionMultiplexer.Connect("192.168.199.30:30115,defaultDatabase:1,password=dlhis123");
|
||||
});
|
||||
|
||||
//todo
|
||||
var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
|
||||
var redis = ConnectionMultiplexer.Connect($"192.168.199.30:30115,defaultDatabase:1,password=dlhis123");
|
||||
services.AddDataProtection()
|
||||
.SetApplicationName("basic")
|
||||
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
|
||||
|
||||
@@ -123,10 +123,10 @@ public class SyncPersonJob
|
||||
//CarNo
|
||||
Remark = item.remark,
|
||||
Werks = item.WERKS,
|
||||
Employed = item.isowner,
|
||||
};
|
||||
await _dbContext.InsertAsync(info);
|
||||
}
|
||||
|
||||
private async Task UpdatePerson(GainfoSapEntity item)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.idno).FirstAsync();
|
||||
@@ -138,7 +138,6 @@ public class SyncPersonJob
|
||||
Position = item.web,
|
||||
Phone = item.phone,
|
||||
DepartmentNo = item.appellation,
|
||||
Employed = item.isowner,
|
||||
Remark = item.remark,
|
||||
Degree = item.email,
|
||||
Werks = item.WERKS
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CreateGetAttendanceJob
|
||||
var b = await _dbContext.Queryable<DeviceTaskEntity>()
|
||||
.Where(x => ds.Contains(x.DeviceUniqueNo))
|
||||
.Where(x => x.Type == DeviceTaskEnumType.UploadRecord)
|
||||
.Where(x => x.Status == DeviceTaskStatusEnumType.Process)
|
||||
.Where(x => x.Status == DeviceTaskStatusEnumType.Process || x.Status == DeviceTaskStatusEnumType.Wait)
|
||||
.AnyAsync();
|
||||
|
||||
if (b)
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"InternalRequest": {
|
||||
"SysRequestUrl": "http://sys"
|
||||
},
|
||||
"SqlSugarOptions": {
|
||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||
"SlaveConnectionString": [],
|
||||
|
||||
Reference in New Issue
Block a user