fix 开放山西人员数据接口
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="MealSupplement\Response\" />
|
||||
<Folder Include="OpenApi\Request\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
29
Src/Dlhis.External/OpenApi/Controllers/GainfosController.cs
Normal file
29
Src/Dlhis.External/OpenApi/Controllers/GainfosController.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Dlhis.External.OpenApi.Response;
|
||||
using Dlhis.External.OpenApi.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.External.OpenApi.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class GainfosController : ControllerBase
|
||||
{
|
||||
private readonly IGainfoService _gainfoService;
|
||||
|
||||
public GainfosController(IGainfoService gainfoService)
|
||||
{
|
||||
_gainfoService = gainfoService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取山西所有人员
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("shanxi/all")]
|
||||
public async Task<List<GainfoOpenResponse>> GetAllGainfosAsync()
|
||||
{
|
||||
return await _gainfoService.GetAllGainfosAsync();
|
||||
}
|
||||
}
|
||||
18
Src/Dlhis.External/OpenApi/Response/GainfoOpenResponse.cs
Normal file
18
Src/Dlhis.External/OpenApi/Response/GainfoOpenResponse.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
|
||||
namespace Dlhis.External.OpenApi.Response;
|
||||
|
||||
public class GainfoOpenResponse
|
||||
{
|
||||
public string Code { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public GenderEnumType Gender { get; set; }
|
||||
|
||||
public string DepartmentNo { get; set; }
|
||||
|
||||
public string DepartmentName { get; set; }
|
||||
|
||||
public GainfoStatusEnumType Status { get; set; }
|
||||
}
|
||||
8
Src/Dlhis.External/OpenApi/Services/IGainfoService.cs
Normal file
8
Src/Dlhis.External/OpenApi/Services/IGainfoService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Dlhis.External.OpenApi.Response;
|
||||
|
||||
namespace Dlhis.External.OpenApi.Services;
|
||||
|
||||
public interface IGainfoService : IScopeDependency
|
||||
{
|
||||
Task<List<GainfoOpenResponse>> GetAllGainfosAsync();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Dlhis.External.OpenApi.Response;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.External.OpenApi.Services.Implements;
|
||||
|
||||
public class GainfoService : IGainfoService
|
||||
{
|
||||
private readonly RedisCache _redisCache;
|
||||
|
||||
public GainfoService(RedisCache redisCache)
|
||||
{
|
||||
_redisCache = redisCache;
|
||||
}
|
||||
|
||||
public async Task<List<GainfoOpenResponse>> GetAllGainfosAsync()
|
||||
{
|
||||
var data = await _redisCache.ListRangeAsync("gainfo:shanxi");
|
||||
return data.Select(x => x.ToString().ToObject<GainfoOpenResponse>()).ToList();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.Startup;
|
||||
using Microsoft.IdentityModel.Logging;
|
||||
@@ -23,6 +24,6 @@ public class Startup : DefaultStartup
|
||||
base.ConfigureServices(services);
|
||||
|
||||
services.AddSqlSugar();
|
||||
//services.AddEventBus();
|
||||
services.AddRedis();
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,28 @@
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"SwaggerOptions": {
|
||||
"Enable": true,
|
||||
"Authority": "https://yikatong.isawesome.cn/oauth2",
|
||||
"ClientId": "4fb184324eac4180",
|
||||
"ClientSecret": "8ac8f235152f1524",
|
||||
"Scopes": {
|
||||
"openid": "openid",
|
||||
"profile": "profile",
|
||||
"yikatong": "yikatong"
|
||||
}
|
||||
},
|
||||
"IdentityServerOptions": {
|
||||
"Authority": "https://yikatong.isawesome.cn/oauth2",
|
||||
"RequireHttpsMetadata": true,
|
||||
"Issuer": "identity.isawesome.cn",
|
||||
"Audience": "",
|
||||
"Pat": {
|
||||
"Enable": false,
|
||||
"Scheme": "token",
|
||||
"ClientId": "reference",
|
||||
"ClientSecret": "123456"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
"SlowSqlTime": 1,
|
||||
"EnableSqlLog": false
|
||||
},
|
||||
"RedisOptions": {
|
||||
"ConnectionString": "192.168.199.30:30115,defaultDatabase=5,password=dlhis123"
|
||||
},
|
||||
"SwaggerOptions": {
|
||||
"Enable": true,
|
||||
"Authority": "http://identity.oauth.svc.cluster.local",
|
||||
|
||||
18
Src/Dlhis.ScheduledTask/Common/Dto/GainfoOpenResponse.cs
Normal file
18
Src/Dlhis.ScheduledTask/Common/Dto/GainfoOpenResponse.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Dto;
|
||||
|
||||
public class GainfoOpenResponse
|
||||
{
|
||||
public string Code { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public GenderEnumType Gender { get; set; }
|
||||
|
||||
public string DepartmentNo { get; set; }
|
||||
|
||||
public string DepartmentName { get; set; }
|
||||
|
||||
public GainfoStatusEnumType Status { get; set; }
|
||||
}
|
||||
66
Src/Dlhis.ScheduledTask/Jobs/SyncShanxiGainfoJob.cs
Normal file
66
Src/Dlhis.ScheduledTask/Jobs/SyncShanxiGainfoJob.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.Scheduled;
|
||||
using Kurisu.Scheduled.Attributes;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存山西档案数据
|
||||
/// </summary>
|
||||
[RecurringJob(nameof(SyncShanxiGainfoJob), "0 0 3 * * ?", Name = "缓存山西档案数据")]
|
||||
public class SyncShanxiGainfoJob : BaseJob
|
||||
{
|
||||
private readonly RedisCache _redisCache;
|
||||
|
||||
public SyncShanxiGainfoJob(IServiceProvider serviceProvider, RedisCache redisCache) : base(serviceProvider)
|
||||
{
|
||||
_redisCache = redisCache;
|
||||
}
|
||||
|
||||
public override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
var key = "gainfo:shanxi";
|
||||
await _redisCache.KeyDeleteAsync(key);
|
||||
|
||||
var gainfos = await DbContext.Queryable<GainfoEntity>()
|
||||
.LeftJoin<DepartmentEntity>((x, d) => x.DepartmentNo == d.No)
|
||||
.Where(x => x.Factory == "2401")
|
||||
.Select((x, d) => new GainfoOpenResponse
|
||||
{
|
||||
Code = x.Code,
|
||||
DepartmentNo = x.DepartmentNo,
|
||||
DepartmentName = d.Name,
|
||||
Name = x.Name,
|
||||
Gender = x.Gender,
|
||||
Status = GainfoStatusEnumType.Working,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var item in gainfos)
|
||||
{
|
||||
await _redisCache.ListLeftPushAsync(key, item);
|
||||
}
|
||||
|
||||
var gainfoLeaves = await DbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
||||
.LeftJoin<DepartmentEntity>((x, d) => x.DepartmentNo == d.No)
|
||||
.Where(x => x.Factory == "2401")
|
||||
.Select((x, d) => new GainfoOpenResponse
|
||||
{
|
||||
Code = x.Code,
|
||||
DepartmentNo = x.DepartmentNo,
|
||||
DepartmentName = d.Name,
|
||||
Name = x.Name,
|
||||
Gender = x.Gender,
|
||||
Status = GainfoStatusEnumType.Leave,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var item in gainfoLeaves)
|
||||
{
|
||||
await _redisCache.ListLeftPushAsync(key, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,6 @@
|
||||
"yikatong": "yikatong"
|
||||
}
|
||||
},
|
||||
"JinkoOptions": {
|
||||
"Jip": {
|
||||
"BaseUrl": "http://172.16.202.34:8000",
|
||||
"Key": "FACE-7409WIBX",
|
||||
"Secret": "be0a4b88-cd80-4509-b9b9-865205d0d3d8"
|
||||
}
|
||||
},
|
||||
"IdentityServerOptions": {
|
||||
"Authority": "https://yikatong.isawesome.cn/oauth2",
|
||||
"RequireHttpsMetadata": true,
|
||||
@@ -42,5 +35,12 @@
|
||||
"ClientId": "reference",
|
||||
"ClientSecret": "123456"
|
||||
}
|
||||
},
|
||||
"JinkoOptions": {
|
||||
"Jip": {
|
||||
"BaseUrl": "http://172.16.202.34:8000",
|
||||
"Key": "FACE-7409WIBX",
|
||||
"Secret": "be0a4b88-cd80-4509-b9b9-865205d0d3d8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
},
|
||||
"RedisOptions": {
|
||||
"ConnectionString": "192.168.199.30:30115,defaultDatabase:1,password=dlhis123"
|
||||
"ConnectionString": "192.168.199.30:30115,defaultDatabase=5,password=dlhis123"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Serilog": {
|
||||
|
||||
Reference in New Issue
Block a user