Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development

This commit is contained in:
cheche
2024-03-05 15:45:24 +08:00
9 changed files with 158 additions and 136 deletions

View File

@@ -59,14 +59,11 @@ public class GainfoService : IGainfoService
{
request.DepartmentNos = await GetRecursionDepartmentNosAsync(request.DepartmentNos);
var tenant = _currentUser.GetStringTenantId();
var page = await _gainfoStore.Queryable(request.Status)
.WhereIF(request.DepartmentNos.IsPresent(), gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
.WhereIF(request.Search.IsPresent(), gainfo =>
gainfo.Name.Contains(request.Search)
|| gainfo.Code.Contains(request.Search))
.Where(gainfo => gainfo.Werks == tenant)
.Select<GainfoPageResponse>()
.ToPageListAsync(request);
@@ -148,11 +145,19 @@ public class GainfoService : IGainfoService
public async Task<GainfoCurrentResponse> CurrentUserInfoAsync()
{
var identityId = _currentUser.GetIntSubjectId();
var code = _currentUser.GetUserClaim("jinko-code");
var gainfo = await _gainfoStore.Queryable().Where(x => x.Code == code).FirstAsync()
?? await _gainfoStore.Queryable().Where(x => x.IdentityUserId == identityId).FirstAsync();
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
if (gainfo == null)
{
return null;
}
var info = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
.LeftJoin<DepartmentEntity>((ga, department) => ga.DepartmentNo == department.No)
.LeftJoin<CanteenUserEntity>((ga, department, mealUser) => ga.No == mealUser.UserNo)
.Where((ga, department) => ga.IdentityUserId == identityId)
.Where((ga, department) => ga.Id == gainfo.Id)
.Select((ga, department, mealUser) => new GainfoCurrentResponse
{
UserNo = ga.No,
@@ -169,7 +174,7 @@ public class GainfoService : IGainfoService
})
.FirstAsync();
return gainfo;
return info;
}
public async Task<IActionResult> GetFaceAsync(string token)
@@ -368,9 +373,9 @@ public class GainfoService : IGainfoService
.LeftJoin<PositionEntity>((ga, de, type, posi) => ga.Position == posi.Name)
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3,type4) => ga.IdClass == type4.Code && type4.Type == "cls")
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3, type4) => ga.IdClass == type4.Code && type4.Type == "cls")
.Where(ga => ga.No == request.No)
.Select((ga, de, type, posi, type2, type3,type4) => new GainfoDetailResponse
.Select((ga, de, type, posi, type2, type3, type4) => new GainfoDetailResponse
{
No = ga.No,
SapNo = ga.SapNo,
@@ -389,7 +394,7 @@ public class GainfoService : IGainfoService
Degree = ga.Degree,
Werks = ga.Werks,
CostId = ga.CostId,
Marital = ga.Marital== "Single" ? "未婚":"已婚",
Marital = ga.Marital == "Single" ? "未婚" : "已婚",
CountryName = type2.Display,
NationName = type3.Display,
ClassName = type4.Display,

View File

@@ -25,7 +25,7 @@
"LogConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=log;charset=utf8mb4;",
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": false
"EnableSqlLog": true
},
"SwaggerOptions": {
"Enable": true,

View File

@@ -509,7 +509,7 @@ public class BalanceService : IBalanceService
No = record.No,
BusinessPlaceName = bplace.Name,
BusinessShiftName = type.Display,
CostDateTime = record.CreateTime // todo
CostDateTime = record.CostDateTime
})
.ToPageListAsync(request);
@@ -774,7 +774,7 @@ public class BalanceService : IBalanceService
var codeBreakfast = "Breakfast";
if (breakfast != null)
{
codeBreakfast = breakfast.Code.ToString();
codeBreakfast = breakfast.Code.ToString();
}
//午餐
var lunch = shifts.Where(x => x.CustomCode == "shift-lunch").FirstOrDefault();

View File

@@ -143,15 +143,27 @@ public class GainfoEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "人事范围")]
public string Werks { get; set; }
/// <summary>
/// 工作地
/// </summary>
[SugarColumn(ColumnDescription = "工作地")]
public string Workplace { get; set; }
/// <summary>
/// 厂区
/// </summary>
[SugarColumn(ColumnDescription = "厂区")]
public string Factory { get; set; }
/// <summary>
/// 成本中心
/// </summary>
public string CostId { get; set; }
/// <summary>
/// 身份认证用户Id
/// 身份认证用户Id(如果为空匹配code)
/// </summary>
[SugarColumn(ColumnDescription = "身份认证用户Id", IndexGroupNameList = new[] { "idx_Gainfo_IdentityUserId" })]
[SugarColumn(ColumnDescription = "身份认证用户Id", IsNullable = true)]
public int IdentityUserId { get; set; }
}

View File

@@ -12,6 +12,11 @@ public class TenantEntity
{
public int Id { get; set; }
/// <summary>
/// 上级租户
/// </summary>
public string PCode { get; set; }
/// <summary>
/// 基地code
/// </summary>

View File

@@ -1,10 +1,14 @@
using Dlhis.Entity.Basic.Entity;
using System.Collections.Generic;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Dlhis.Sys.Api;
using Dlhis.User.Api.Response;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Entity;
using Kurisu.SqlSugar.Services;
using Newtonsoft.Json;
using SqlSugar;
namespace Dlhis.ScheduledTask.CommonJobs;
@@ -14,7 +18,10 @@ public class CreateDefinitelyGroupJob
private readonly ITenantApi _tenantApi;
private readonly IDbContext _dbContext;
public CreateDefinitelyGroupJob(ILogger<CreateDefinitelyGroupJob> logger, ITenantApi tenantApi, IDbContext dbContext, ISqlSugarOptionsService sqlSugarOptionsService)
public CreateDefinitelyGroupJob(ILogger<CreateDefinitelyGroupJob> logger,
ITenantApi tenantApi,
IDbContext dbContext,
ISqlSugarOptionsService sqlSugarOptionsService)
{
_logger = logger;
_tenantApi = tenantApi;
@@ -28,136 +35,23 @@ public class CreateDefinitelyGroupJob
_dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
try
{
//获取所有基地信息
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,
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);
await CreateGainfoGroupsAsync(tenants);
//*****************************************************考勤设备组*********************************************************/
var groups = new[] { "*督查组", "*X3及以上领导组", "*外派人员组" };
foreach (var group in groups)
{
var grp = new GainfoGroupEntity
{
PCode = null,
Code = Guid.NewGuid(),
Name = group,
IsDefault = false,
Editable = false,
await CreateDeviceGroupAsync(DeviceTypeEnumType.Attendance, new List<string> { "*通用考勤设备组", "*专用考勤设备组" }, tenants);
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = tenant.Code
};
//*****************************************************门禁设备组********************************************************/
await _dbContext.InsertAsync(grp);
}
}
//**************************************************************************************************************/
if (!await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.Name == "*通用考勤设备组"))
{
await _dbContext.InsertAsync(new DeviceGroupEntity
{
PCode = null,
Code = Guid.NewGuid(),
Type = DeviceTypeEnumType.Attendance,
Name = "*通用考勤设备组",
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = tenant.Code,
});
}
if (!await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.Name == "*专用考勤设备组"))
{
await _dbContext.InsertAsync(new DeviceGroupEntity
{
PCode = null,
Code = Guid.NewGuid(),
Type = DeviceTypeEnumType.Attendance,
Name = "*专用考勤设备组",
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = tenant.Code,
});
}
//**************************************************************************************************************/
if (!await _dbContext.Queryable<DeviceGroupEntity>().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 = "*非公共区域",
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = tenant.Code,
});
}
if (!await _dbContext.Queryable<DeviceGroupEntity>().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 = "*公共区域",
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = tenant.Code,
});
}
}
await CreateDeviceGroupAsync(DeviceTypeEnumType.Door, new List<string> { "*共用区域", "*非共用区域" }, tenants);
}
catch (Exception ex)
{
@@ -168,4 +62,103 @@ public class CreateDefinitelyGroupJob
_dbContext.Client.QueryFilter.Restore();
}
}
private async Task CreateGainfoGroupsAsync(List<TenantResponse> tenants)
{
var grps = new List<string> { "*自定义人员分组", "*督查组", "*X3及以上领导组" };
var searchGrps = await _dbContext.Queryable<GainfoGroupEntity>().Where(x => grps.Contains(x.Name)).ToListAsync();
foreach (var grp in grps)
{
if (!searchGrps.Any(x => x.Name == grp))
{
await _dbContext.InsertAsync(new GainfoGroupEntity
{
PCode = null,
Code = Guid.NewGuid(),
Name = grp,
IsDefault = grp.Equals("*自定义人员分组"),
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = null
});
}
}
}
private async Task CreateDeviceGroupAsync(DeviceTypeEnumType type, List<string> topGroups, List<TenantResponse> tenants)
{
foreach (var grp in topGroups)
{
var topGrp = await _dbContext.Queryable<DeviceGroupEntity>().FirstAsync(x => x.Name == grp);
if (topGrp == null)
{
topGrp = new DeviceGroupEntity
{
PCode = null,
Code = Guid.NewGuid(),
Type = type,
Name = grp,
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = null,
};
await _dbContext.InsertAsync(topGrp);
}
foreach (var workplace in tenants.Where(x => x.PCode.IsEmpty()))
{
var workplaceName = $"*{type.GetDescription()}工作地系统组({workplace.Name})";
var workplaceGrp = await _dbContext.Queryable<DeviceGroupEntity>().FirstAsync(x => x.Name == workplaceName);
if (workplaceGrp == null)
{
workplaceGrp = new DeviceGroupEntity
{
PCode = topGrp.Code,
Code = Guid.NewGuid(),
Type = type,
Name = workplaceName,
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = null,
};
await _dbContext.InsertAsync(workplaceGrp);
}
foreach (var factory in tenants.Where(x => x.PCode == workplace.Code))
{
var factoryName = $"*{type.GetDescription()}厂区系统组({factory.Name})";
if (!await _dbContext.Queryable<DeviceGroupEntity>().AnyAsync(x => x.Name == factoryName))
{
await _dbContext.InsertAsync(new DeviceGroupEntity
{
PCode = workplaceGrp.Code,
Code = Guid.NewGuid(),
Type = type,
Name = factoryName,
Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
ModifiedBy = 1,
ModifiedTime = DateTime.Now,
TenantId = factory.Code,
});
}
}
}
}
}
}

View File

@@ -5,6 +5,9 @@
"Microsoft.AspNetCore": "Warning"
}
},
"InternalRequest": {
"SysRequestUrl": "http://localhost:5003"
},
"FaceUrlOptions": {
"Url": "http://localhost:5002/api/gainfos/face?token=",
"Limit": 7200

View File

@@ -4,6 +4,8 @@ public class TenantResponse
{
public int Id { get; set; }
public string PCode { get; set; }
public string Code { get; set; }
public string Name { get; set; }

View File

@@ -4,6 +4,8 @@ public class TenantResponse
{
public int Id { get; set; }
public string PCode { get; set; }
public string Code { get; set; }
public string Name { get; set; }