diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
index b6c09d43..33e9307f 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
@@ -2,12 +2,10 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
using Dlhis.Basic.Organization.Services;
-using Dlhis.Entity.Basic.Entity;
using Kurisu.AspNetCore.MVC;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Basic.MealUser.Controllers;
@@ -142,7 +140,7 @@ public class GainfosController : ControllerBase
///
///
///
- [HttpGet("gainfolist")]
+ [HttpGet("list")]
public async Task> GetGainfoListTaskAsync([FromQuery]GainfoListRequest request)
{
return await _gainfoService.GetGainfoListTaskAsync(request);
@@ -152,7 +150,7 @@ public class GainfosController : ControllerBase
///
///
///
- [HttpGet("gainfodetail")]
+ [HttpGet("detail")]
public async Task GetGainfoDetailTaskAsync([FromQuery] GainfoDetailRequest request)
{
return await _gainfoService.GetGainfoDetailTaskAsync(request);
diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
index df112cee..cb3c563c 100644
--- a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
+++ b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
@@ -1,4 +1,7 @@
-namespace Dlhis.Basic.Organization.Response;
+using Dlhis.Entity.Basic.Enums;
+using Kurisu.AspNetCore.Utils.Extensions;
+
+namespace Dlhis.Basic.Organization.Response;
public class GainfoPageResponse
{
@@ -52,7 +55,8 @@ public class GainfoPageResponse
///
/// 性别
///
- public string Gender { get; set; }
+ public GenderEnumType Gender { get; set; }
+ public string GenderDesc => Gender.GetDescription();
///
/// 生日
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index ce14552e..78753d46 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -53,9 +53,9 @@ public class GainfoService : IGainfoService
var tenant = _currentUser.GetStringTenantId();
var page = await _gainfoStore.Queryable(request.Status)
- .WhereIF(request.DepartmentNos?.Any() == true, gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
+ .WhereIF(request.DepartmentNos.IsPresent(), gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
.WhereIF(request.Search.IsPresent(), gainfo =>
- gainfo.Name.Contains(request.Search)
+ gainfo.Name.Contains(request.Search)
|| gainfo.Code.Contains(request.Search))
.Where(gainfo => gainfo.Werks == tenant)
.Select()
@@ -561,7 +561,7 @@ public class GainfoService : IGainfoService
///
private async Task> GetRecursionDepartmentNosAsync(List departmentNos)
{
- if (departmentNos == null || departmentNos.Count == 0)
+ if (departmentNos.IsEmpty())
{
return new List();
}
diff --git a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
index f481ce85..d4467cae 100644
--- a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
+++ b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
@@ -17,14 +17,14 @@ public class SqlSugarPack : BaseAppPack
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
- //using var scope = app.ApplicationServices.CreateScope();
- //var db = scope.ServiceProvider.GetService();
- //var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false))
- // .Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
- // .ToArray();
+ using var scope = app.ApplicationServices.CreateScope();
+ var db = scope.ServiceProvider.GetService();
+ var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false))
+ .Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
+ .ToArray();
- //db.DbMaintenance.CreateDatabase();
- //db.CodeFirst.InitTables(tables);
+ db.DbMaintenance.CreateDatabase();
+ db.CodeFirst.InitTables(tables);
//using var scopeFace = app.ApplicationServices.CreateScope();
//var dbFace = scopeFace.ServiceProvider.GetService();
diff --git a/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs b/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs
index 2243b9e5..b7e533c0 100644
--- a/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs
@@ -1,4 +1,5 @@
-using Kurisu.SqlSugar;
+using Kurisu.Core.DataAccess.Entity;
+using Kurisu.SqlSugar;
using SqlSugar;
namespace Dlhis.Entity.Basic.Entity;
@@ -7,8 +8,13 @@ namespace Dlhis.Entity.Basic.Entity;
/// 档案组
///
[SugarTable(TableName = "GainfoGroup", TableDescription = "档案组")]
-public class GainfoGroupEntity : SugarBaseEntity
+public class GainfoGroupEntity : SugarBaseEntity, ITenantId
{
+ ///
+ /// 父级Code
+ ///
+ public Guid? PCode { get; set; }
+
///
/// 分组code
///
@@ -26,4 +32,19 @@ public class GainfoGroupEntity : SugarBaseEntity
///
[SugarColumn(ColumnDescription = "备注")]
public string Remark { get; set; }
+
+ ///
+ /// 是否默认分组
+ ///
+ [SugarColumn(ColumnDescription = "是否默认分组")]
+ public bool IsDefault { get; set; }
+
+ ///
+ /// 是否可编辑
+ ///
+ [SugarColumn(ColumnDescription = "是否可编辑")]
+ public bool Editable { get; set; }
+
+
+ public string TenantId { get; set; }
}
diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
index 3c06d72e..6d037b6a 100644
--- a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
+++ b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
@@ -12,7 +12,6 @@ namespace Dlhis.Entity.Device.Entities;
[SugarTable(TableName = "DeviceGroup", TableDescription = "设备组")]
public class DeviceGroupEntity : SugarBaseEntity, ITenantId, ISoftDeleted
{
-
///
/// 设备组功能类型
///
diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
new file mode 100644
index 00000000..9390c884
--- /dev/null
+++ b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
@@ -0,0 +1,163 @@
+using Dlhis.Entity.Basic.Entity;
+using Dlhis.Entity.Device.Entities;
+using Dlhis.Entity.Device.Enums;
+using Dlhis.Sys.Api;
+using Kurisu.Core.DataAccess.Entity;
+using Kurisu.SqlSugar.Services;
+
+namespace Dlhis.ScheduledTask.CommonJobs;
+
+public class CreateDefinitelyGroupJob
+{
+ private readonly ILogger _logger;
+ private readonly ITenantApi _tenantApi;
+ private readonly IDbContext _dbContext;
+
+ public CreateDefinitelyGroupJob(ILogger logger, ITenantApi tenantApi, IDbContext dbContext)
+ {
+ _logger = logger;
+ _tenantApi = tenantApi;
+ _dbContext = dbContext;
+ }
+
+ public async Task RunAsync()
+ {
+ _dbContext.Client.QueryFilter.ClearAndBackup();
+ try
+ {
+ var tenantResult = await _tenantApi.GetTenantsInternalAsync();
+ var tenants = tenantResult.Data;
+
+ foreach (var tenant in tenants)
+ {
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.IsDefault))
+ {
+
+ var customGroup = new GainfoGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Name = "*自定义人员分组",
+ IsDefault = true,
+ Editable = false,
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code
+ };
+ await _dbContext.InsertAsync(customGroup);
+
+
+ var groups = new[] { "*督查组", "*X3及以上领导组", "*外派人员组" };
+ foreach (var group in groups)
+ {
+ var grp = new GainfoGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Name = group,
+ IsDefault = false,
+ Editable = false,
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code
+ };
+
+ await _dbContext.InsertAsync(grp);
+ }
+ }
+
+ //**************************************************************************************************************/
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.Name == "*通用考勤设备组"))
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Attendance,
+ Name = "*通用考勤设备组",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.Name == "*专用考勤设备组"))
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Attendance,
+ Name = "*专用考勤设备组",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+
+ //**************************************************************************************************************/
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code)
+ .Where(x => x.Type == DeviceTypeEnumType.Door)
+ .AnyAsync(x => x.Name == "*通用考勤设备组")
+ )
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Door,
+ Name = "*非公共区域",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code)
+ .Where(x => x.Type == DeviceTypeEnumType.Door)
+ .AnyAsync(x => x.Name == "*专用考勤设备组")
+ )
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Door,
+ Name = "*公共区域",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "自动创建系统分组失败:{message}", ex.Message);
+ }
+ finally
+ {
+ _dbContext.Client.QueryFilter.Restore();
+ }
+ }
+}
diff --git a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
index 49f75fff..ec5b214d 100644
--- a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
+++ b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
@@ -1,4 +1,5 @@
-using Dlhis.ScheduledTask.SyncSapInfo.Job;
+using Dlhis.ScheduledTask.CommonJobs;
+using Dlhis.ScheduledTask.SyncSapInfo.Job;
using Dlhis.ScheduledTask.TaskAssignment.Job;
using Hangfire;
using Kurisu.AspNetCore.Startup;
@@ -32,5 +33,11 @@ public class JobPack : BaseAppPack
{
TimeZone = TimeZoneInfo.Local
});
+
+ //创建系统默认分组
+ RecurringJob.AddOrUpdate("CreateDefinitelyGroup", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions
+ {
+ TimeZone = TimeZoneInfo.Local
+ });
}
}