fix 临时调整代码
This commit is contained in:
@@ -8,9 +8,4 @@ internal static class GetHashCodeExtensions
|
|||||||
if(string.IsNullOrEmpty(o.ToString())) return 0;
|
if(string.IsNullOrEmpty(o.ToString())) return 0;
|
||||||
return o.GetHashCode();
|
return o.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int SafeGetHashCode(this int o)
|
|
||||||
{
|
|
||||||
return o.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
namespace Dlhis.ScheduledTask.Common.Response
|
namespace Dlhis.ScheduledTask.Common.Response;
|
||||||
{
|
|
||||||
public class UploadAttendanceResponse
|
public class UploadAttendanceResponse
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -9,4 +9,3 @@
|
|||||||
|
|
||||||
public string OMS { get; set; }
|
public string OMS { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ namespace Dlhis.ScheduledTask.Common.Services;
|
|||||||
|
|
||||||
public interface IJinkoJipService : ISingletonDependency
|
public interface IJinkoJipService : ISingletonDependency
|
||||||
{
|
{
|
||||||
Task<UploadAttendanceResponse> UploadAttendancesAsync(List<UploadAttendanceRequest> requests);
|
/// <summary>
|
||||||
|
/// 同步餐补处理结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requests"></param>
|
||||||
|
/// <returns></returns>
|
||||||
Task<string> SyncMealSupplementRecordsAsync(List<SyncMealSupplementRecordRequest> requests);
|
Task<string> SyncMealSupplementRecordsAsync(List<SyncMealSupplementRecordRequest> requests);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取出差信息
|
/// 获取出差信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -28,9 +30,11 @@ public interface IJinkoJipService : ISingletonDependency
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<SapBusinessTripInfoResponse> GetTravelInfosByUserCodeAsync(DateTime begin, DateTime end, string userCode);
|
Task<SapBusinessTripInfoResponse> GetTravelInfosByUserCodeAsync(DateTime begin, DateTime end, string userCode);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步人脸数据到SAP
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userCode"></param>
|
||||||
|
/// <param name="base64"></param>
|
||||||
|
/// <returns></returns>
|
||||||
Task<SapFaceSyncResponse> SyncFaceToSapAsync(string userCode, string base64);
|
Task<SapFaceSyncResponse> SyncFaceToSapAsync(string userCode, string base64);
|
||||||
|
|
||||||
|
|
||||||
string IssueToken();
|
|
||||||
}
|
}
|
||||||
@@ -23,41 +23,41 @@ public class HangfireService : IHangfireService
|
|||||||
|
|
||||||
public async Task CreateSapPersonSyncBackgroundJobAsync(SapNoRequest request)
|
public async Task CreateSapPersonSyncBackgroundJobAsync(SapNoRequest request)
|
||||||
{
|
{
|
||||||
var jobKey = $"hangfire:background:person:{request.Code}";
|
// var jobKey = $"hangfire:background:person:{request.Code}";
|
||||||
|
//
|
||||||
using var handler = await _redisCache.LockAsync(jobKey);
|
// using var handler = await _redisCache.LockAsync(jobKey);
|
||||||
if (handler.Acquired)
|
// if (handler.Acquired)
|
||||||
{
|
// {
|
||||||
BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByCodeAsync(request.Code));
|
// BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByCodeAsync(request.Code));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request)
|
public async Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request)
|
||||||
{
|
{
|
||||||
var jobKey = $"hangfire:background:werk:{request.Code}";
|
// var jobKey = $"hangfire:background:werk:{request.Code}";
|
||||||
|
//
|
||||||
await using var handler = await _redisCache.LockAsync(jobKey);
|
// await using var handler = await _redisCache.LockAsync(jobKey);
|
||||||
if (handler.Acquired)
|
// if (handler.Acquired)
|
||||||
{
|
// {
|
||||||
var werkInfo = await _dbContext.Queryable<WerkEntity>().Where(x => x.Werk == request.Code).SingleAsync();
|
// var werkInfo = await _dbContext.Queryable<WerkEntity>().Where(x => x.Werk == request.Code).SingleAsync();
|
||||||
werkInfo.ThrowIfNull("人事范围不存在");
|
// werkInfo.ThrowIfNull("人事范围不存在");
|
||||||
|
//
|
||||||
werkInfo.BackgroundJobKey.IsPresent().ThrowIfTrue("任务进行中,无法再次发起同步");
|
// werkInfo.BackgroundJobKey.IsPresent().ThrowIfTrue("任务进行中,无法再次发起同步");
|
||||||
|
//
|
||||||
BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(request.Code));
|
// BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(request.Code));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
|
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
|
||||||
{
|
{
|
||||||
var response = await _jinkoJipService.SyncFaceToSapAsync(request.UserCode, request.Base64);
|
// var response = await _jinkoJipService.SyncFaceToSapAsync(request.UserCode, request.Base64);
|
||||||
if (response.OLX == "S")
|
// if (response.OLX == "S")
|
||||||
{
|
// {
|
||||||
var faceDbContext = _dbContext.ChangeDb("face");
|
// var faceDbContext = _dbContext.ChangeDb("face");
|
||||||
await faceDbContext.Updateable<GainfoFaceEntity>()
|
// await faceDbContext.Updateable<GainfoFaceEntity>()
|
||||||
.SetColumns(x => x.IsSync == true)
|
// .SetColumns(x => x.IsSync == true)
|
||||||
.Where(x => x.UserCode == request.UserCode)
|
// .Where(x => x.UserCode == request.UserCode)
|
||||||
.ExecuteCommandAsync();
|
// .ExecuteCommandAsync();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Dlhis.Jip.Api.Requests;
|
||||||
using Dlhis.ScheduledTask.Common.Request;
|
using Dlhis.ScheduledTask.Common.Request;
|
||||||
using Dlhis.ScheduledTask.Common.Response;
|
using Dlhis.ScheduledTask.Common.Response;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.ScheduledTask.Common.Dto;
|
using Dlhis.ScheduledTask.Common.Dto;
|
||||||
@@ -22,24 +21,11 @@ public class JinkoSapService : IJinkoSapService
|
|||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpClient GetHttpClient()
|
|
||||||
{
|
|
||||||
var httpClient = _httpClientFactory.CreateClient("jinko:sap");
|
|
||||||
httpClient.BaseAddress = new Uri("http://sappipap01.jinkosolar.cn:50100");
|
|
||||||
httpClient.Timeout = TimeSpan.FromMinutes(10);
|
|
||||||
|
|
||||||
const string credentials = $"{"EHS_USER"}:{"y3R1hd2h*RICAC"}";
|
|
||||||
var headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));
|
|
||||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", headerValue);
|
|
||||||
|
|
||||||
return httpClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<SapOrganizationResponse> GetSapOrganizationsAsync()
|
public async Task<SapOrganizationResponse> GetSapOrganizationsAsync()
|
||||||
{
|
{
|
||||||
const string apiUrl = "/RESTAdapter/Rest/EHR_ORGANIZATION/";
|
const string apiUrl = "/RESTAdapter/Rest/EHR_ORGANIZATION/";
|
||||||
|
|
||||||
var response = await GetHttpClient().PostAsync(apiUrl, new StringContent("{}", Encoding.UTF8, "application/json"));
|
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, new StringContent("{}", Encoding.UTF8, "application/json"));
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
string responseJson = await response.Content.ReadAsStringAsync();
|
string responseJson = await response.Content.ReadAsStringAsync();
|
||||||
@@ -52,7 +38,7 @@ public class JinkoSapService : IJinkoSapService
|
|||||||
{
|
{
|
||||||
const string apiUrl = "/RESTAdapter/Rest/EHR_POSITION/";
|
const string apiUrl = "/RESTAdapter/Rest/EHR_POSITION/";
|
||||||
|
|
||||||
var response = await GetHttpClient().PostAsync(apiUrl, new StringContent("{}", Encoding.UTF8, "application/json"));
|
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, new StringContent("{}", Encoding.UTF8, "application/json"));
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
string responseJson = await response.Content.ReadAsStringAsync();
|
string responseJson = await response.Content.ReadAsStringAsync();
|
||||||
@@ -89,7 +75,7 @@ public class JinkoSapService : IJinkoSapService
|
|||||||
};
|
};
|
||||||
|
|
||||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||||
var response = await GetHttpClient().PostAsync(apiUrl, content);
|
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, content);
|
||||||
if (response.StatusCode != HttpStatusCode.OK)
|
if (response.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
_logger.LogError("获取{Werk}人事范围数据异常:{error}", werk, await response.Content.ReadAsStringAsync());
|
_logger.LogError("获取{Werk}人事范围数据异常:{error}", werk, await response.Content.ReadAsStringAsync());
|
||||||
@@ -138,7 +124,7 @@ public class JinkoSapService : IJinkoSapService
|
|||||||
};
|
};
|
||||||
|
|
||||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||||
var response = await GetHttpClient().PostAsync(apiUrl, content);
|
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, content);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj" />
|
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj" />
|
||||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||||
|
<ProjectReference Include="..\Dlhis.Jip.Api\Dlhis.Jip.Api.csproj" />
|
||||||
<ProjectReference Include="..\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj" />
|
<ProjectReference Include="..\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ public class MealSupplementHandlerJob : BaseJob
|
|||||||
.Where(x => x.UniqueId == item.UniqueId)
|
.Where(x => x.UniqueId == item.UniqueId)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
//后台任务获取人员
|
//后台任务获取人员 todo
|
||||||
BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByCodeAsync(item.Code));
|
//BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByCodeAsync(item.Code));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ public class SyncBusinessTripJob : BaseJob
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
var sapBusinessTripService = serviceProvider.GetService<ISapBusinessTripService>();
|
// var sapBusinessTripService = serviceProvider.GetService<ISapBusinessTripService>();
|
||||||
|
//
|
||||||
var identityDbContext = DbContext.ChangeDb("identity");
|
// var identityDbContext = DbContext.ChangeDb("identity");
|
||||||
var factories = await identityDbContext.Queryable<TenantEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.PCode)).ToListAsync();
|
// var factories = await identityDbContext.Queryable<TenantEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.PCode)).ToListAsync();
|
||||||
|
//
|
||||||
foreach (var factory in factories)
|
// foreach (var factory in factories)
|
||||||
{
|
// {
|
||||||
await sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(factory.Code);
|
// await sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(factory.Code);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Device.Entities;
|
using Dlhis.Entity.Device.Entities;
|
||||||
using Dlhis.Entity.Device.Enums;
|
using Dlhis.Entity.Device.Enums;
|
||||||
|
using Dlhis.Jip.Api;
|
||||||
|
using Dlhis.Jip.Api.Requests;
|
||||||
using Dlhis.ScheduledTask.Attributes;
|
using Dlhis.ScheduledTask.Attributes;
|
||||||
using Dlhis.ScheduledTask.Common.Request;
|
|
||||||
using Dlhis.ScheduledTask.Common.Services;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace Dlhis.ScheduledTask.Jobs;
|
namespace Dlhis.ScheduledTask.Jobs;
|
||||||
@@ -14,11 +14,11 @@ namespace Dlhis.ScheduledTask.Jobs;
|
|||||||
[RecurringJob(nameof(SyncOriginCardInfoJob), "0 0/1 * * * ?", Name = "上传考勤记录")]
|
[RecurringJob(nameof(SyncOriginCardInfoJob), "0 0/1 * * * ?", Name = "上传考勤记录")]
|
||||||
public class SyncOriginCardInfoJob : BaseJob
|
public class SyncOriginCardInfoJob : BaseJob
|
||||||
{
|
{
|
||||||
private readonly IJinkoJipService _jinkoJIPService;
|
private readonly IJinkoJipApi _jinkoJipApi;
|
||||||
|
|
||||||
public SyncOriginCardInfoJob(IJinkoJipService jinkoJIPService, IServiceProvider serviceProvider) : base(serviceProvider)
|
public SyncOriginCardInfoJob(IJinkoJipApi jinkoJipApi, IServiceProvider serviceProvider) : base(serviceProvider)
|
||||||
{
|
{
|
||||||
_jinkoJIPService = jinkoJIPService;
|
_jinkoJipApi = jinkoJipApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||||
@@ -34,7 +34,7 @@ public class SyncOriginCardInfoJob : BaseJob
|
|||||||
.Where(x => SqlFunc.Subqueryable<DeviceEntity>()
|
.Where(x => SqlFunc.Subqueryable<DeviceEntity>()
|
||||||
.Where(p => p.UniqueNo == x.DeviceUniqueNo)
|
.Where(p => p.UniqueNo == x.DeviceUniqueNo)
|
||||||
.Where(p => p.Type == DeviceTypeEnumType.Attendance || (p.Type == DeviceTypeEnumType.Door && p.AsAttendance)).Any())
|
.Where(p => p.Type == DeviceTypeEnumType.Attendance || (p.Type == DeviceTypeEnumType.Door && p.AsAttendance)).Any())
|
||||||
.Select((x, device) => new UploadAttendanceRequest
|
.Select((x, device) => new UploadAttendanceRequestItem
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
RaiseDateTime = x.RaiseDateTime,
|
RaiseDateTime = x.RaiseDateTime,
|
||||||
@@ -52,7 +52,7 @@ public class SyncOriginCardInfoJob : BaseJob
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var ids = items.Select(x => x.Id).ToList();
|
var ids = items.Select(x => x.Id).ToList();
|
||||||
var r = await _jinkoJIPService.UploadAttendancesAsync(items.ToList());
|
var r = await _jinkoJipApi.UploadAttendancesAsync(new UploadAttendanceRequest { Data = items.ToList() });
|
||||||
if (r.OLX == "0")
|
if (r.OLX == "0")
|
||||||
{
|
{
|
||||||
await DbContext.Updateable<DeviceUploadLogEntity>()
|
await DbContext.Updateable<DeviceUploadLogEntity>()
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ public class SyncPersonJob : BaseJob
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var jobKey = BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(werk.Werk));
|
//todo
|
||||||
werk.BackgroundJobKey = jobKey;
|
// var jobKey = BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(werk.Werk));
|
||||||
await DbContext.UpdateAsync(werk);
|
// werk.BackgroundJobKey = jobKey;
|
||||||
|
// await DbContext.UpdateAsync(werk);
|
||||||
|
|
||||||
Logger.LogInformation("SAP创建人事范围{werk}后台调度任务", werk.Werk);
|
Logger.LogInformation("SAP创建人事范围{werk}后台调度任务", werk.Werk);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ namespace Dlhis.ScheduledTask.Packs;
|
|||||||
|
|
||||||
public class JinkoSapHttpClientPack : BaseAppPack
|
public class JinkoSapHttpClientPack : BaseAppPack
|
||||||
{
|
{
|
||||||
|
|
||||||
public override void ConfigureServices(IServiceCollection services)
|
public override void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddHttpClient("jinko:sap", (sp, httpClient) =>
|
services.AddHttpClient("jinko:sap", (_, httpClient) =>
|
||||||
{
|
{
|
||||||
|
httpClient.BaseAddress = new Uri($"http://sappipap01.jinkosolar.cn:50100");
|
||||||
httpClient.Timeout = TimeSpan.FromMinutes(10);
|
httpClient.Timeout = TimeSpan.FromMinutes(10);
|
||||||
|
|
||||||
var credentials = $"{"EHS_USER"}:{"y3R1hd2h*RICAC"}";
|
const string credentials = "EHS_USER:y3R1hd2h*RICAC";
|
||||||
var headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));
|
var headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));
|
||||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", headerValue);
|
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", headerValue);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Dlhis.ScheduledTask.Common.Services;
|
|
||||||
using Kurisu.AspNetCore.Startup;
|
using Kurisu.AspNetCore.Startup;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
|
||||||
@@ -21,11 +20,4 @@ public class Startup : DefaultStartup
|
|||||||
base.ConfigureServices(services);
|
base.ConfigureServices(services);
|
||||||
services.AddRedis();
|
services.AddRedis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
||||||
{
|
|
||||||
base.Configure(app, env);
|
|
||||||
|
|
||||||
var token = app.ApplicationServices.GetService<IJinkoJipService>().IssueToken();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user