feat 照片上传sap

This commit is contained in:
2024-07-17 16:48:30 +08:00
parent aeda215b38
commit a5a6c7a515
13 changed files with 160 additions and 87 deletions

View File

@@ -0,0 +1,11 @@
namespace Dlhis.ScheduledTask.Common.Response;
public class SapFaceSyncResponse
{
/// <summary>
/// S 成功
/// </summary>
public string OLX { get; set; }
public string OMS { get; set; }
}

View File

@@ -1,5 +1,6 @@
using Dlhis.Basic.Api.Request;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.TaskAssignment.Request;
namespace Dlhis.ScheduledTask.Common.Services;
@@ -22,6 +23,6 @@ public interface IHangfireService : IScopeDependency
/// <returns></returns>
Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request);
void GeneratePermissions(GeneratePermissionIdRequest request);
Task FaceUploadToSapAsync(FaceUploadToSapRequest request);
}

View File

@@ -19,8 +19,18 @@ public interface IJinkoJIPService : ISingletonDependency
/// <returns></returns>
Task<SapBusinessTripInfoResponse> GetTravelInfosByDepartmentsAsync(DateTime begin, DateTime end, List<string> departmentNos);
/// <summary>
/// 获取出差信息
/// </summary>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <param name="userCode"></param>
/// <returns></returns>
Task<SapBusinessTripInfoResponse> GetTravelInfosByUserCodeAsync(DateTime begin, DateTime end, string userCode);
Task<SapFaceSyncResponse> SyncFaceToSapAsync(string userCode, string base64);
string IssueToken();
}

View File

@@ -1,7 +1,6 @@
using Dlhis.Basic.Api;
using Dlhis.Basic.Api.Request;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Entity;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.TaskAssignment.Request;
using Hangfire;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Kurisu.AspNetCore.Utils;
@@ -13,11 +12,13 @@ public class HangfireService : IHangfireService
{
private readonly RedisCache _redisCache;
private readonly IDbContext _dbContext;
private readonly IJinkoJIPService _jinkoJipService;
public HangfireService(RedisCache redisCache, IDbContext dbContext)
public HangfireService(RedisCache redisCache, IDbContext dbContext, IJinkoJIPService jinkoJipService)
{
_redisCache = redisCache;
_dbContext = dbContext;
_jinkoJipService = jinkoJipService;
}
public async Task CreateSapPersonSyncBackgroundJobAsync(SapNoRequest request)
@@ -47,9 +48,8 @@ public class HangfireService : IHangfireService
}
}
/// <inheritdoc />
public void GeneratePermissions(GeneratePermissionIdRequest request)
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
{
BackgroundJob.Enqueue<IDevicePermissionApi>(x => x.GeneratePermissionsAsync(request));
await _jinkoJipService.SyncFaceToSapAsync(request.UserCode, request.Base64);
}
}

View File

@@ -158,6 +158,25 @@ public class JinkoJIPService : IJinkoJIPService
return jsonResponse.ToObject<SapBusinessTripInfoResponse>();
}
public async Task<SapFaceSyncResponse> SyncFaceToSapAsync(string userCode, string base64)
{
const string apiUrl = "/JIP/HCM/HCM_I_PHOTO";
var obj = new
{
I_WORKCODE = userCode,
I_PHOTO_STR = base64
};
var body = obj.ToJson();
var content = new StringContent(body, Encoding.UTF8, "application/json");
var response = await GetHttpClient().PostAsync(apiUrl, content);
response.EnsureSuccessStatusCode();
var jsonResponse = await response.Content.ReadAsStringAsync();
return jsonResponse.ToObject<SapFaceSyncResponse>();
}
public string IssueToken()
{