fix 获取档案失败自动发起同步任务

This commit is contained in:
2024-04-15 17:01:09 +08:00
parent 380c86aae2
commit 48bb170272
12 changed files with 87 additions and 16 deletions

View File

@@ -5,7 +5,7 @@ VisualStudioVersion = 17.7.34302.85
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Basic", "Basic", "{4EBCE46B-CE3A-4A47-9432-82A1854CA58A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RechargeAndSpend", "RechargeAndSpend", "{3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Canteen", "Canteen", "{3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Entity", "Src\Dlhis.Entity\Dlhis.Entity.csproj", "{53884925-C9B9-4965-8B0D-100076CA0F43}"
EndProject
@@ -37,7 +37,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{48
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.External", "Src\Dlhis.External\Dlhis.External.csproj", "{8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Canteen.Api", "Src\Dlhis.Canteen.Api\Dlhis.Canteen.Api.csproj", "{961523DE-51BF-42A0-A294-708752C5718D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Canteen.Api", "Src\Dlhis.Canteen.Api\Dlhis.Canteen.Api.csproj", "{961523DE-51BF-42A0-A294-708752C5718D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Scheduled.Api", "Src\Dlhis.Scheduled.Api\Dlhis.Scheduled.Api.csproj", "{9EA85FB2-F320-4F97-B278-00652CF35BD8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -97,6 +99,10 @@ Global
{961523DE-51BF-42A0-A294-708752C5718D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{961523DE-51BF-42A0-A294-708752C5718D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{961523DE-51BF-42A0-A294-708752C5718D}.Release|Any CPU.Build.0 = Release|Any CPU
{9EA85FB2-F320-4F97-B278-00652CF35BD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EA85FB2-F320-4F97-B278-00652CF35BD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EA85FB2-F320-4F97-B278-00652CF35BD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EA85FB2-F320-4F97-B278-00652CF35BD8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -113,6 +119,7 @@ Global
{1F337648-8A22-4601-A842-0F634FBA2825} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
{8472596E-0DE7-4A17-93D6-F0FC7D44FDF5} = {489252FB-A44B-46EE-B065-21CDCB724441}
{961523DE-51BF-42A0-A294-708752C5718D} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}
{9EA85FB2-F320-4F97-B278-00652CF35BD8} = {AA987BDF-EF63-467B-AD04-59F9B10D9000}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0}

View File

@@ -18,11 +18,13 @@
<ItemGroup>
<PackageReference Include="Kurisu.AspNetCore" Version="0.8.5" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dlhis.Common.Api\Dlhis.Common.Api.csproj" />
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
<ProjectReference Include="..\Dlhis.Scheduled.Api\Dlhis.Scheduled.Api.csproj" />
<ProjectReference Include="..\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj" />
</ItemGroup>

View File

@@ -5,18 +5,21 @@ WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Src/Dlhis.Basic/Dlhis.Basic.csproj", "Src/Dlhis.Basic/"]
COPY ["Src/Dlhis.Common.Api/Dlhis.Common.Api.csproj", "Src/Dlhis.Common.Api/"]
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
COPY ["Src/Dlhis.Scheduled.Api/Dlhis.Scheduled.Api.csproj", "Src/Dlhis.Scheduled.Api/"]
COPY ["Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj", "Src/Dlhis.Sys.Api/"]
RUN dotnet restore "Src/Dlhis.Basic/Dlhis.Basic.csproj"
RUN dotnet restore "./Src/Dlhis.Basic/./Dlhis.Basic.csproj"
COPY . .
WORKDIR "/src/Src/Dlhis.Basic"
RUN dotnet build "Dlhis.Basic.csproj" -c Release -o /app/build
RUN dotnet build "./Dlhis.Basic.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
RUN dotnet publish "Dlhis.Basic.csproj" -c Release -o /app/publish /p:UseAppHost=false
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Dlhis.Basic.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app

View File

@@ -4,6 +4,8 @@ using Dlhis.Basic.Organization.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Dlhis.Entity.Device.Enums;
using Dlhis.Scheduled.Api;
using Dlhis.Scheduled.Api.Request;
using Dlhis.Sys.Api;
using Kurisu.AspNetCore.Utils;
using Kurisu.AspNetCore.Utils.Extensions;
@@ -27,6 +29,7 @@ public class GainfoService : IGainfoService
private readonly IServiceProvider _serviceProvider;
private readonly IConfiguration _configuration;
private readonly ITenantApi _tenantApi;
private readonly IHangfireApi _hangfireApi;
private readonly ILogger<GainfoService> _logger;
public GainfoService(IGainfoStore gainfoStore,
@@ -37,6 +40,7 @@ public class GainfoService : IGainfoService
IServiceProvider serviceProvider,
IConfiguration configuration,
ITenantApi tenantApi,
IHangfireApi hangfireApi,
ILogger<GainfoService> logger)
{
_gainfoStore = gainfoStore;
@@ -47,6 +51,7 @@ public class GainfoService : IGainfoService
_serviceProvider = serviceProvider;
_configuration = configuration;
_tenantApi = tenantApi;
_hangfireApi = hangfireApi;
_logger = logger;
}
@@ -92,7 +97,6 @@ public class GainfoService : IGainfoService
.Select<GainfoAllPageResponse>()
.ToPageListAsync(new PageDto { PageIndex = 1, PageSize = 1 });
var tenantsResult = await _tenantApi.GetTenantsInternalAsync();
var tenants = tenantsResult.Data;
@@ -179,13 +183,18 @@ 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();
if (code.IsEmpty())
{
_logger.LogWarning("工号为空尝试获取人员信息");
return null;
}
var gainfo = await _gainfoStore.Queryable().Where(x => x.Code == code).SingleAsync();
if (gainfo == null)
{
//开启同步处理
await _hangfireApi.SyncSapPersonAsync(new SapNoRequest { Code = "1231313" });
return null;
}
@@ -266,12 +275,9 @@ public class GainfoService : IGainfoService
public async Task UploadFaceAsync(GainfoUploadFaceRequest request)
{
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();
var gainfo = await _gainfoStore.Queryable().Where(x => x.No == request.UserNo).FirstAsync();
gainfo.ThrowIfNull("人员档案信息不存在");
var userId = _currentUser.GetIntSubjectId();
var faceContext = _dbContext.ChangeDb("face");

View File

@@ -8,6 +8,14 @@
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5002"
},
"Docker": {
"commandName": "Docker",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger/index.html",
"environmentVariables": {
"ASPNETCORE_URLS": "http://+:80"
},
"publishAllPorts": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json"

View File

@@ -8,7 +8,8 @@
"EightThirtyPM": "20:30:00",
"InternalRequest": {
"CommonRequestUrl": "http://localhost:5001",
"SysRequestUrl": "http://localhost:5003"
"SysRequestUrl": "http://localhost:5003",
"ScheduledRequestUrl": "http://localhost:5010"
},
"FaceUrlOptions": {
"Url": "http://localhost:5002/api/gainfos/face?token=",

View File

@@ -8,7 +8,8 @@
"AllowedHosts": "*",
"InternalRequest": {
"CommonRequestUrl": "http://common",
"SysRequestUrl": "http://sys"
"SysRequestUrl": "http://sys",
"ScheduledRequestUrl": "http://Scheduled"
},
"FaceUrlOptions": {
"Url": "https://yikatong.isawesome.cn/api/basic/gainfos/face?token=",

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Kurisu.RemoteCall" Version="0.2.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,17 @@
using Dlhis.Scheduled.Api.Request;
using Kurisu.Core.Result;
using Kurisu.RemoteCall.Attributes;
namespace Dlhis.Scheduled.Api;
[EnableRemoteClient(Name = "hangfire-service", BaseUrl = "${InternalRequest:ScheduledRequestUrl}")]
public interface IHangfireApi
{
/// <summary>
/// 同步人员
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Post("api/hangfire/sap/person/no")]
Task<DefaultApiResult> SyncSapPersonAsync(SapNoRequest request);
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace Dlhis.Scheduled.Api.Request;
public class SapNoRequest
{
/// <summary>
/// Code
/// </summary>
[Required(ErrorMessage = "编号不能为空")]
public string Code { get; set; }
}

View File

@@ -25,6 +25,7 @@ public class HangfireController : ControllerBase
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[AllowAnonymous]
[HttpPost("sap/person/no")]
public async Task PersonManuallySync(SapNoRequest request)
{