refactor 优化代码
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using System.Text;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Comparers;
|
||||
|
||||
/// <summary>
|
||||
/// 人员信息比较器
|
||||
/// </summary>
|
||||
public class SapPersonComparer : IEqualityComparer<SapPersonItem>
|
||||
{
|
||||
public bool Equals(SapPersonItem x, SapPersonItem y)
|
||||
{
|
||||
if (ReferenceEquals(x, y)) return true;
|
||||
if (ReferenceEquals(x, null)) return false;
|
||||
if (ReferenceEquals(y, null)) return false;
|
||||
|
||||
return x.PERNR == y.PERNR
|
||||
&& x.WERKS == y.WERKS
|
||||
&& x.ORGEH == y.ORGEH
|
||||
&& x.NAME == y.NAME
|
||||
&& x.GBDAT == y.GBDAT
|
||||
&& (x.ZZ_SFZH ?? string.Empty) == (y.ZZ_SFZH ?? string.Empty)
|
||||
&& x.ZWORKCODE == y.ZWORKCODE
|
||||
&& (x.ZMOBILE ?? string.Empty) == (y.ZMOBILE ?? string.Empty)
|
||||
&& (x.ZSTATUS ?? string.Empty) == (y.ZSTATUS ?? string.Empty)
|
||||
&& (x.KOSTL ?? string.Empty) == (y.KOSTL ?? string.Empty)
|
||||
&& (x.ZZ_ZD ?? string.Empty) == (y.ZZ_ZD ?? string.Empty)
|
||||
&& (x.Z_ZJ ?? string.Empty) == (y.Z_ZJ ?? string.Empty)
|
||||
&& x.ZRZRQ == y.ZRZRQ
|
||||
&& x.ZLZRQ == y.ZLZRQ
|
||||
&& (x.STELL ?? string.Empty) == (y.STELL ?? string.Empty)
|
||||
&& (x.STELL_NM ?? string.Empty) == (y.STELL_NM ?? string.Empty)
|
||||
&& (x.MASSN ?? string.Empty) == (y.MASSN ?? string.Empty)
|
||||
&& (x.MNTXT ?? string.Empty) == (y.MNTXT ?? string.Empty)
|
||||
&& (x.ZXUELI ?? string.Empty).Trim() == (y.ZXUELI ?? string.Empty).Trim()
|
||||
&& (x.ZZ_KLX ?? string.Empty) == (y.ZZ_KLX ?? string.Empty)
|
||||
&& (x.ZZ_GZDJDNM ?? string.Empty) == (y.ZZ_GZDJDNM ?? string.Empty)
|
||||
&& (x.ZZ_GZDCQNM ?? string.Empty) == (y.ZZ_GZDCQNM ?? string.Empty)
|
||||
;
|
||||
}
|
||||
|
||||
public int GetHashCode(SapPersonItem obj)
|
||||
{
|
||||
var r = obj.PERNR.SafeGetHashCode()
|
||||
^ obj.WERKS.SafeGetHashCode()
|
||||
^ obj.ORGEH.SafeGetHashCode()
|
||||
^ obj.NAME.SafeGetHashCode()
|
||||
^ obj.GBDAT.SafeGetHashCode()
|
||||
^ obj.ZZ_SFZH.SafeGetHashCode()
|
||||
^ obj.ZWORKCODE.SafeGetHashCode()
|
||||
^ obj.ZMOBILE.SafeGetHashCode()
|
||||
^ obj.ZSTATUS.SafeGetHashCode()
|
||||
^ obj.KOSTL.SafeGetHashCode()
|
||||
^ obj.ZZ_ZD.SafeGetHashCode()
|
||||
^ obj.Z_ZJ.SafeGetHashCode()
|
||||
^ obj.ZRZRQ.SafeGetHashCode()
|
||||
^ obj.ZLZRQ.SafeGetHashCode()
|
||||
^ obj.STELL.SafeGetHashCode()
|
||||
^ obj.STELL_NM.SafeGetHashCode()
|
||||
^ obj.MASSN.SafeGetHashCode()
|
||||
^ obj.MNTXT.SafeGetHashCode()
|
||||
^ obj.ZXUELI.SafeGetHashCode()
|
||||
^ obj.ZZ_KLX.SafeGetHashCode()
|
||||
^ obj.ZZ_GZDJDNM.SafeGetHashCode()
|
||||
^ obj.ZZ_GZDCQNM.SafeGetHashCode()
|
||||
;
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
namespace Dlhis.ScheduledTask.Common.Dto;
|
||||
|
||||
public class SapPersonItem
|
||||
{
|
||||
public string KOSTL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 离职日期
|
||||
/// </summary>
|
||||
public DateTime? ZLZRQ { get; set; }
|
||||
|
||||
public string ZZ_SFZH { get; set; }
|
||||
|
||||
public string STELL { get; set; }
|
||||
|
||||
public string STELL_NM { get; set; }
|
||||
|
||||
public string ZZ_KLX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string PERNR { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZWORKCODE { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string MASSN { get; set; }
|
||||
/// <summary>
|
||||
/// 数据变更
|
||||
/// </summary>
|
||||
public string MNTXT { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string MASSG { get; set; }
|
||||
/// <summary>
|
||||
/// 数据变更
|
||||
/// </summary>
|
||||
public string MGTXT { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZSTATUS { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string STAT2 { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BEGDA { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ENDDA { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string WERKS { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string PERSG { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string PERSK { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BTRTL { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ANSVH { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string MOABW { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ORGEH { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string PLANS { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_ZYSF { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_AQJB { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_ZD { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_SJGH { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_BGZT { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Z_ZJ { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_XSQY { get; set; }
|
||||
/// <summary>
|
||||
/// 上海
|
||||
/// </summary>
|
||||
public string ZZ_LOC { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_COUN { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_CITY { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string NACHN { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string VORNA { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string NAME { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string GESCH { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime GBDAT { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string NATIO { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_QFRQ { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZMOBILE { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZEMAIL { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZADZH { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime ZRZRQ { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DAT01 { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZCJRQ { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZZRQ { get; set; }
|
||||
/// <summary>
|
||||
/// 本科
|
||||
/// </summary>
|
||||
public string ZXUELI { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZ_ZPQD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 国家
|
||||
/// </summary>
|
||||
public string ZZ_COUNNM { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 基地
|
||||
/// </summary>
|
||||
public string ZZ_GZDJDNM { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 厂区
|
||||
/// </summary>
|
||||
public string ZZ_GZDCQNM { get; set; }
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// namespace Dlhis.ScheduledTask.Common.Dto
|
||||
// {
|
||||
// public class SapPersonJobStatus
|
||||
// {
|
||||
// public string ZWORKCODE { get; set; }
|
||||
//
|
||||
// public DateTime BEGDA { get; set; }
|
||||
//
|
||||
// public DateTime ENDDA { get; set; }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 0离职
|
||||
// /// </summary>
|
||||
// public string STAT2 { get; set; }
|
||||
// }
|
||||
// }
|
||||
@@ -1,10 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Dto;
|
||||
|
||||
public class SapPosition
|
||||
{
|
||||
|
||||
[JsonProperty("item")]
|
||||
public List<SapPositionItem> Items { get; set; }
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
namespace Dlhis.ScheduledTask.Common.Dto
|
||||
{
|
||||
public class SapPositionItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 开始日期
|
||||
/// </summary>
|
||||
public string BEGDA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束日期
|
||||
/// </summary>
|
||||
public string ENDDA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 语言代码
|
||||
/// </summary>
|
||||
public string LANGU { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 岗位编码
|
||||
/// </summary>
|
||||
public string ZJOBID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 岗位名称
|
||||
/// </summary>
|
||||
public string ZJOBNAME { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ZZWID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属部门ID
|
||||
/// </summary>
|
||||
public string ZDEPID { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Dlhis.ScheduledTask.Common;
|
||||
|
||||
internal static class GetHashCodeExtensions
|
||||
{
|
||||
public static int SafeGetHashCode(this object o)
|
||||
{
|
||||
if (o == null) return 0;
|
||||
if(string.IsNullOrEmpty(o.ToString())) return 0;
|
||||
return o.GetHashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Request;
|
||||
|
||||
public class SapNoRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Code
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "编号不能为空")]
|
||||
public string Code { get; set; }
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace Dlhis.ScheduledTask.Common.Request;
|
||||
|
||||
public class SyncMealSupplementRecordRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 唯一id
|
||||
/// </summary>
|
||||
public string UniqueId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// FAIL SUCCESS
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
|
||||
|
||||
public string Msg { get; set; }
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Request
|
||||
{
|
||||
public class UploadAttendanceRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 考勤数据包
|
||||
/// </summary>
|
||||
[JsonProperty("T_DATA")]
|
||||
public List<UploadAttendanceRequestItem> Data { get; set; }
|
||||
}
|
||||
|
||||
public class UploadAttendanceRequestItem
|
||||
{
|
||||
[JsonIgnore]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// item.CardNo.TrimEnd('\0')
|
||||
/// </summary>
|
||||
public string ZWORKCODE { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime RaiseDateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// yyyy-MM-dd
|
||||
/// </summary>
|
||||
public string ZDATE => RaiseDateTime.ToString("yyyy-MM-dd");
|
||||
|
||||
/// <summary>
|
||||
/// HH:mm:ss
|
||||
/// </summary>
|
||||
public string ZTIME => RaiseDateTime.ToString("HH:mm:ss");
|
||||
|
||||
/// <summary>
|
||||
/// 设备位置
|
||||
/// </summary>
|
||||
public string ZNOTE { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Response;
|
||||
|
||||
public class SapBusinessTripInfoResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 明细数据
|
||||
/// </summary>
|
||||
[JsonProperty("OT_2002")]
|
||||
public List<SapBusinessTripInfoItem> Items { get; set; }
|
||||
}
|
||||
|
||||
public class SapBusinessTripInfoItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
[JsonProperty("OV_GONGH")]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 姓名
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ENAME")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始日期
|
||||
/// </summary>
|
||||
[JsonProperty("OV_BEGDA")]
|
||||
public DateTime BeginDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束日期
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ENDDA")]
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
[JsonProperty("OV_BEGUZ")]
|
||||
public TimeOnly? BeginDateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ENDUZ")]
|
||||
public TimeOnly? EndDateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出差类型
|
||||
/// </summary>
|
||||
[JsonProperty("OV_AWART")]
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出差类型描述
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ATEXT")]
|
||||
public string TypeDesc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出差时数
|
||||
/// </summary>
|
||||
[JsonProperty("OV_STDAZ")]
|
||||
public double Hour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出差天数
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ABWTG")]
|
||||
public double Day { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出差目的地
|
||||
/// </summary>
|
||||
[JsonProperty("OV_CCMDD")]
|
||||
public string Destination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出差目的地描述
|
||||
/// </summary>
|
||||
[JsonProperty("OV_CCMDDMS")]
|
||||
public string DestinationDesc { get; set; }
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Response;
|
||||
|
||||
public class SapPersonResponse
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("T_PERSON")]
|
||||
public SapPerson<SapPersonItem> Person { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// 离职状态
|
||||
// /// </summary>
|
||||
// [JsonProperty("T_0000")]
|
||||
// public SapPerson<SapPersonJobStatus> JobStatusInfo { get; set; }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 部门变更信息
|
||||
// /// </summary>
|
||||
// [JsonProperty("T_0001")]
|
||||
// public SapPerson<SapPersonDepartmentStatus> DepartmentInfo { get; set; }
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Response;
|
||||
|
||||
public class SapPositionResponse
|
||||
{
|
||||
[JsonProperty("T_POST")]
|
||||
public SapPosition Position { get; set; }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Dlhis.ScheduledTask.Common.Response;
|
||||
|
||||
public class UploadAttendanceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 0 成功
|
||||
/// </summary>
|
||||
public string OLX { get; set; }
|
||||
|
||||
public string OMS { get; set; }
|
||||
}
|
||||
@@ -1,28 +1,25 @@
|
||||
using Dlhis.Basic.Api.Request;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
/// <summary>
|
||||
/// hangfire调度服务
|
||||
/// </summary>
|
||||
public interface IHangfireService : IScopeDependency
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建sap人员同步后台任务
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task CreateSapPersonSyncBackgroundJobAsync(SapNoRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 创建sap人事范围同步后台任务
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request);
|
||||
|
||||
|
||||
Task FaceUploadToSapAsync(FaceUploadToSapRequest request);
|
||||
}
|
||||
// using Dlhis.Basic.Api.Request;
|
||||
// using Dlhis.ScheduledTask.Common.Request;
|
||||
// using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
//
|
||||
// namespace Dlhis.ScheduledTask.Common.Services;
|
||||
//
|
||||
// /// <summary>
|
||||
// /// hangfire调度服务
|
||||
// /// </summary>
|
||||
// public interface IHangfireService : IScopeDependency
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 创建sap人员同步后台任务
|
||||
// /// </summary>
|
||||
// /// <param name="request"></param>
|
||||
// /// <returns></returns>
|
||||
// Task CreateSapPersonSyncBackgroundJobAsync(SapNoRequest request);
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 创建sap人事范围同步后台任务
|
||||
// /// </summary>
|
||||
// /// <param name="request"></param>
|
||||
// /// <returns></returns>
|
||||
// Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request);
|
||||
// }
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
public interface IIdentityUserSyncService : IScopeDependency
|
||||
{
|
||||
Task SyncAccountAsync(string userName, string name, string idNo, string tenant);
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Response;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
public interface IJinkoJipService : ISingletonDependency
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步餐补处理结果
|
||||
/// </summary>
|
||||
/// <param name="requests"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> SyncMealSupplementRecordsAsync(List<SyncMealSupplementRecordRequest> requests);
|
||||
|
||||
/// <summary>
|
||||
/// 获取出差信息
|
||||
/// </summary>
|
||||
/// <param name="begin"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="fatory"></param>
|
||||
/// <returns></returns>
|
||||
Task<SapBusinessTripInfoResponse> GetTravelInfosByFactoryAsync(DateTime begin, DateTime end, string fatory);
|
||||
|
||||
/// <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);
|
||||
|
||||
/// <summary>
|
||||
/// 同步人脸数据到SAP
|
||||
/// </summary>
|
||||
/// <param name="userCode"></param>
|
||||
/// <param name="base64"></param>
|
||||
/// <returns></returns>
|
||||
Task<SapFaceSyncResponse> SyncFaceToSapAsync(string userCode, string base64);
|
||||
|
||||
|
||||
Task<UploadAttendanceResponse> UploadAttendancesAsync(UploadAttendanceRequest request);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Dlhis.ScheduledTask.Common.Response;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
public interface IJinkoSapService : IScopeDependency
|
||||
{
|
||||
Task<SapOrganizationResponse> GetSapOrganizationsAsync();
|
||||
|
||||
Task<SapPositionResponse> GetPositionsAsync();
|
||||
|
||||
Task<SapPersonResponse> GetPersonsByWerkAsync(string werk);
|
||||
|
||||
Task<SapPersonResponse> GetPersonsByCodeAsync(string code);
|
||||
}
|
||||
@@ -1,63 +1,50 @@
|
||||
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;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
|
||||
public class HangfireService : IHangfireService
|
||||
{
|
||||
private readonly RedisCache _redisCache;
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IJinkoJipService _jinkoJipService;
|
||||
|
||||
public HangfireService(RedisCache redisCache, IDbContext dbContext, IJinkoJipService jinkoJipService)
|
||||
{
|
||||
_redisCache = redisCache;
|
||||
_dbContext = dbContext;
|
||||
_jinkoJipService = jinkoJipService;
|
||||
}
|
||||
|
||||
public async Task CreateSapPersonSyncBackgroundJobAsync(SapNoRequest request)
|
||||
{
|
||||
// var jobKey = $"hangfire:background:person:{request.Code}";
|
||||
//
|
||||
// using var handler = await _redisCache.LockAsync(jobKey);
|
||||
// if (handler.Acquired)
|
||||
// {
|
||||
// BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByCodeAsync(request.Code));
|
||||
// }
|
||||
}
|
||||
|
||||
public async Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request)
|
||||
{
|
||||
// var jobKey = $"hangfire:background:werk:{request.Code}";
|
||||
//
|
||||
// await using var handler = await _redisCache.LockAsync(jobKey);
|
||||
// if (handler.Acquired)
|
||||
// {
|
||||
// var werkInfo = await _dbContext.Queryable<WerkEntity>().Where(x => x.Werk == request.Code).SingleAsync();
|
||||
// werkInfo.ThrowIfNull("人事范围不存在");
|
||||
//
|
||||
// werkInfo.BackgroundJobKey.IsPresent().ThrowIfTrue("任务进行中,无法再次发起同步");
|
||||
//
|
||||
// BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(request.Code));
|
||||
// }
|
||||
}
|
||||
|
||||
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
|
||||
{
|
||||
// var response = await _jinkoJipService.SyncFaceToSapAsync(request.UserCode, request.Base64);
|
||||
// if (response.OLX == "S")
|
||||
// {
|
||||
// var faceDbContext = _dbContext.ChangeDb("face");
|
||||
// await faceDbContext.Updateable<GainfoFaceEntity>()
|
||||
// .SetColumns(x => x.IsSync == true)
|
||||
// .Where(x => x.UserCode == request.UserCode)
|
||||
// .ExecuteCommandAsync();
|
||||
// }
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
// using Kurisu.AspNetCore.Utils.Extensions;
|
||||
//
|
||||
// namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
//
|
||||
// public class HangfireService : IHangfireService
|
||||
// {
|
||||
// private readonly RedisCache _redisCache;
|
||||
// private readonly IDbContext _dbContext;
|
||||
// private readonly IJinkoJipService _jinkoJipService;
|
||||
//
|
||||
// public HangfireService(RedisCache redisCache, IDbContext dbContext, IJinkoJipService jinkoJipService)
|
||||
// {
|
||||
// _redisCache = redisCache;
|
||||
// _dbContext = dbContext;
|
||||
// _jinkoJipService = jinkoJipService;
|
||||
// }
|
||||
//
|
||||
// public async Task CreateSapPersonSyncBackgroundJobAsync(SapNoRequest request)
|
||||
// {
|
||||
// // var jobKey = $"hangfire:background:person:{request.Code}";
|
||||
// //
|
||||
// // using var handler = await _redisCache.LockAsync(jobKey);
|
||||
// // if (handler.Acquired)
|
||||
// // {
|
||||
// // BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByCodeAsync(request.Code));
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// public async Task CreateSapWerkSyncBackgroundJobAsync(SapNoRequest request)
|
||||
// {
|
||||
// // var jobKey = $"hangfire:background:werk:{request.Code}";
|
||||
// //
|
||||
// // await using var handler = await _redisCache.LockAsync(jobKey);
|
||||
// // if (handler.Acquired)
|
||||
// // {
|
||||
// // var werkInfo = await _dbContext.Queryable<WerkEntity>().Where(x => x.Werk == request.Code).SingleAsync();
|
||||
// // werkInfo.ThrowIfNull("人事范围不存在");
|
||||
// //
|
||||
// // werkInfo.BackgroundJobKey.IsPresent().ThrowIfTrue("任务进行中,无法再次发起同步");
|
||||
// //
|
||||
// // BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(request.Code));
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
@@ -1,96 +0,0 @@
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
|
||||
public class IdentityUserSyncService : IIdentityUserSyncService
|
||||
{
|
||||
private readonly IDbContext _identityDbContext;
|
||||
|
||||
public IdentityUserSyncService(IDbContext dbContext)
|
||||
{
|
||||
_identityDbContext = dbContext.ChangeDb("identity");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SyncAccountAsync(string userName, string name, string idNo, string tenant)
|
||||
{
|
||||
if (tenant.IsEmpty()) return;
|
||||
|
||||
try
|
||||
{
|
||||
var password = idNo.TakeLast(6).Join("");
|
||||
|
||||
var user = await _identityDbContext.Queryable<UserEntity>().SingleAsync(x => x.UserName == userName);
|
||||
if (user == null)
|
||||
{
|
||||
var hasher = new PasswordHasher<UserEntity>();
|
||||
|
||||
user = new UserEntity
|
||||
{
|
||||
UserName = userName,
|
||||
NormalizedUserName = userName.ToUpper(),
|
||||
ConcurrencyStamp = Guid.NewGuid().ToString(),
|
||||
SecurityStamp = Guid.NewGuid().ToString(),
|
||||
};
|
||||
password = hasher.HashPassword(user, password);
|
||||
user.PasswordHash = password;
|
||||
|
||||
var id = (int)await _identityDbContext.InsertReturnIdentityAsync(user);
|
||||
user.Id = id;
|
||||
await AddUserClaim(_identityDbContext, id, "jinko-code", userName);
|
||||
await AddUserClaim(_identityDbContext, id, "name", name);
|
||||
}
|
||||
|
||||
|
||||
//todo 考虑角色?
|
||||
var userTenants = await _identityDbContext.Queryable<UserTenantEntity>().Where(x => x.UserId == user.Id).ToListAsync();
|
||||
if (userTenants.Count is 0 or 1)
|
||||
{
|
||||
var userTenant = userTenants.FirstOrDefault();
|
||||
if (userTenant == null)
|
||||
{
|
||||
userTenant = new UserTenantEntity
|
||||
{
|
||||
UserId = user.Id,
|
||||
TenantCode = tenant
|
||||
};
|
||||
await _identityDbContext.InsertAsync(userTenant);
|
||||
}
|
||||
else
|
||||
{
|
||||
userTenant.TenantCode = tenant;
|
||||
await _identityDbContext.UpdateAsync(userTenant);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
||||
//************************************************************************** help method **************************************************************************************
|
||||
|
||||
private async Task AddUserClaim(IDbContext dbContext, int userId, string type, string value)
|
||||
{
|
||||
var claim = await _identityDbContext.Queryable<UserClaimEntity>().Where(x => x.UserId == userId).FirstAsync(x => x.ClaimType == type);
|
||||
if (claim == null)
|
||||
{
|
||||
claim = new UserClaimEntity()
|
||||
{
|
||||
UserId = userId,
|
||||
ClaimType = type,
|
||||
ClaimValue = value
|
||||
};
|
||||
await dbContext.InsertAsync(claim);
|
||||
}
|
||||
else
|
||||
{
|
||||
claim.ClaimValue = value;
|
||||
await dbContext.UpdateAsync(claim);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
|
||||
public class JinkoJipService : IJinkoJipService
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILogger<JinkoJipService> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public JinkoJipService(IHttpClientFactory httpClientFactory, ILogger<JinkoJipService> logger, IConfiguration configuration)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
private HttpClient GetHttpClient()
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient();
|
||||
httpClient.BaseAddress = new Uri(_configuration.GetSection("JinkoOptions:Jip:BaseUrl").Value);
|
||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", IssueToken());
|
||||
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public async Task<UploadAttendanceResponse> UploadAttendancesAsync(UploadAttendanceRequest request)
|
||||
{
|
||||
var requestUrl = "/JIP/HCM/HCM_SWIPE_DATA_SAVE";
|
||||
|
||||
var json = request.ToJson();
|
||||
|
||||
//_logger.LogInformation("上传考勤记录请求:{json}", json);
|
||||
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await GetHttpClient().PostAsync(requestUrl, content);
|
||||
var responseJson = await response.Content.ReadAsStringAsync();
|
||||
|
||||
_logger.LogInformation("上传考勤记录响应:{json}", responseJson);
|
||||
|
||||
try
|
||||
{
|
||||
return responseJson.ToObject<UploadAttendanceResponse>();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new UploadAttendanceResponse
|
||||
{
|
||||
OLX = "99",
|
||||
OMS = "接口响应数据异常,无法反序列化"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> SyncMealSupplementRecordsAsync(List<SyncMealSupplementRecordRequest> requests)
|
||||
{
|
||||
var requestUrl = "/JIP/DHR/DHR_DL_CALLBACK";
|
||||
|
||||
var json = requests.ToJson(Kurisu.AspNetCore.Utils.Extensions.JsonExtensions.DefaultSetting);
|
||||
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await GetHttpClient().PostAsync(requestUrl, content);
|
||||
var responseJson = await response.Content.ReadAsStringAsync();
|
||||
|
||||
_logger.LogInformation("餐补状态同步响应:{json}", responseJson);
|
||||
|
||||
var jobj = JObject.Parse(responseJson);
|
||||
if (jobj.TryGetValue("exp", out var exp))
|
||||
{
|
||||
true.ThrowIfTrue(exp.Value<string>());
|
||||
}
|
||||
|
||||
if (jobj.TryGetValue("message", out var message) && !jobj.ContainsKey("code"))
|
||||
{
|
||||
true.ThrowIfTrue(message.Value<string>());
|
||||
}
|
||||
|
||||
(jobj.GetValue("code").Value<int>() != 200).ThrowIfTrue(jobj.GetValue("message").Value<string>());
|
||||
|
||||
return responseJson;
|
||||
}
|
||||
|
||||
|
||||
public async Task<SapBusinessTripInfoResponse> GetTravelInfosByFactoryAsync(DateTime begin, DateTime end, string factory)
|
||||
{
|
||||
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
|
||||
|
||||
var beginDay = begin.ToString("yyyyMMdd");
|
||||
var endDay = end.ToString("yyyyMMdd");
|
||||
|
||||
var obj = new
|
||||
{
|
||||
I_PAGE = 1,
|
||||
I_LINE = 500,
|
||||
IV_BEGDA = beginDay,
|
||||
IV_ENDDA = endDay,
|
||||
IT_CCMDD = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
IV_CCMDD = factory
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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<SapBusinessTripInfoResponse>();
|
||||
}
|
||||
|
||||
public async Task<SapBusinessTripInfoResponse> GetTravelInfosByUserCodeAsync(DateTime begin, DateTime end, string userCode)
|
||||
{
|
||||
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
|
||||
|
||||
var beginDay = begin.ToString("yyyyMMdd");
|
||||
var endDay = end.ToString("yyyyMMdd");
|
||||
|
||||
//IV_GONGH IV_ORGID
|
||||
//IT_2002GH
|
||||
var obj = new
|
||||
{
|
||||
IV_BEGDA = beginDay,
|
||||
IV_ENDDA = endDay,
|
||||
IT_2002GH = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
IV_GONGH = userCode
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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<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()
|
||||
{
|
||||
var jwtKey = _configuration.GetSection("JinkoOptions:Jip:Key").Value;
|
||||
var jwtSecret = _configuration.GetSection("JinkoOptions:Jip:Secret").Value;
|
||||
const int min = 5;
|
||||
|
||||
var now = DateTime.Now.AddMinutes(-min);
|
||||
var expires = DateTime.Now.AddMinutes(min);
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new(JwtRegisteredClaimNames.Nbf, $"{new DateTimeOffset(now).ToUnixTimeSeconds()}"),
|
||||
new(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(expires).ToUnixTimeSeconds()}"),
|
||||
new(JwtRegisteredClaimNames.Iss, jwtKey),
|
||||
};
|
||||
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSecret));
|
||||
var descriptor = new SecurityTokenDescriptor
|
||||
{
|
||||
Subject = new ClaimsIdentity(claims),
|
||||
Issuer = jwtKey,
|
||||
IssuedAt = now,
|
||||
NotBefore = now,
|
||||
Expires = expires,
|
||||
SigningCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256)
|
||||
};
|
||||
|
||||
var jwtHandler = new JwtSecurityTokenHandler();
|
||||
var securityToken = jwtHandler.CreateToken(descriptor);
|
||||
return jwtHandler.WriteToken(securityToken);
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
|
||||
public class JinkoJipService : IJinkoJipService
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILogger<JinkoJipService> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public JinkoJipService(IHttpClientFactory httpClientFactory, ILogger<JinkoJipService> logger, IConfiguration configuration)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
private HttpClient GetHttpClient()
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient();
|
||||
httpClient.BaseAddress = new Uri(_configuration.GetSection("JinkoOptions:Jip:BaseUrl").Value);
|
||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", IssueToken());
|
||||
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public async Task<UploadAttendanceResponse> UploadAttendancesAsync(UploadAttendanceRequest request)
|
||||
{
|
||||
var requestUrl = "/JIP/HCM/HCM_SWIPE_DATA_SAVE";
|
||||
|
||||
var json = request.ToJson();
|
||||
|
||||
//_logger.LogInformation("上传考勤记录请求:{json}", json);
|
||||
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await GetHttpClient().PostAsync(requestUrl, content);
|
||||
var responseJson = await response.Content.ReadAsStringAsync();
|
||||
|
||||
_logger.LogInformation("上传考勤记录响应:{json}", responseJson);
|
||||
|
||||
try
|
||||
{
|
||||
return responseJson.ToObject<UploadAttendanceResponse>();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new UploadAttendanceResponse
|
||||
{
|
||||
OLX = "99",
|
||||
OMS = "接口响应数据异常,无法反序列化"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> SyncMealSupplementRecordsAsync(List<SyncMealSupplementRecordRequest> requests)
|
||||
{
|
||||
var requestUrl = "/JIP/DHR/DHR_DL_CALLBACK";
|
||||
|
||||
var json = requests.ToJson(Kurisu.AspNetCore.Utils.Extensions.JsonExtensions.DefaultSetting);
|
||||
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await GetHttpClient().PostAsync(requestUrl, content);
|
||||
var responseJson = await response.Content.ReadAsStringAsync();
|
||||
|
||||
_logger.LogInformation("餐补状态同步响应:{json}", responseJson);
|
||||
|
||||
var jobj = JObject.Parse(responseJson);
|
||||
if (jobj.TryGetValue("exp", out var exp))
|
||||
{
|
||||
true.ThrowIfTrue(exp.Value<string>());
|
||||
}
|
||||
|
||||
if (jobj.TryGetValue("message", out var message) && !jobj.ContainsKey("code"))
|
||||
{
|
||||
true.ThrowIfTrue(message.Value<string>());
|
||||
}
|
||||
|
||||
(jobj.GetValue("code").Value<int>() != 200).ThrowIfTrue(jobj.GetValue("message").Value<string>());
|
||||
|
||||
return responseJson;
|
||||
}
|
||||
|
||||
|
||||
public async Task<SapBusinessTripInfoResponse> GetTravelInfosByFactoryAsync(DateTime begin, DateTime end, string factory)
|
||||
{
|
||||
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
|
||||
|
||||
var beginDay = begin.ToString("yyyyMMdd");
|
||||
var endDay = end.ToString("yyyyMMdd");
|
||||
|
||||
var obj = new
|
||||
{
|
||||
I_PAGE = 1,
|
||||
I_LINE = 500,
|
||||
IV_BEGDA = beginDay,
|
||||
IV_ENDDA = endDay,
|
||||
IT_CCMDD = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
IV_CCMDD = factory
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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<SapBusinessTripInfoResponse>();
|
||||
}
|
||||
|
||||
public async Task<SapBusinessTripInfoResponse> GetTravelInfosByUserCodeAsync(DateTime begin, DateTime end, string userCode)
|
||||
{
|
||||
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
|
||||
|
||||
var beginDay = begin.ToString("yyyyMMdd");
|
||||
var endDay = end.ToString("yyyyMMdd");
|
||||
|
||||
//IV_GONGH IV_ORGID
|
||||
//IT_2002GH
|
||||
var obj = new
|
||||
{
|
||||
IV_BEGDA = beginDay,
|
||||
IV_ENDDA = endDay,
|
||||
IT_2002GH = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
IV_GONGH = userCode
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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<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()
|
||||
{
|
||||
var jwtKey = _configuration.GetSection("JinkoOptions:Jip:Key").Value;
|
||||
var jwtSecret = _configuration.GetSection("JinkoOptions:Jip:Secret").Value;
|
||||
const int min = 5;
|
||||
|
||||
var now = DateTime.Now.AddMinutes(-min);
|
||||
var expires = DateTime.Now.AddMinutes(min);
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new(JwtRegisteredClaimNames.Nbf, $"{new DateTimeOffset(now).ToUnixTimeSeconds()}"),
|
||||
new(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(expires).ToUnixTimeSeconds()}"),
|
||||
new(JwtRegisteredClaimNames.Iss, jwtKey),
|
||||
};
|
||||
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSecret));
|
||||
var descriptor = new SecurityTokenDescriptor
|
||||
{
|
||||
Subject = new ClaimsIdentity(claims),
|
||||
Issuer = jwtKey,
|
||||
IssuedAt = now,
|
||||
NotBefore = now,
|
||||
Expires = expires,
|
||||
SigningCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256)
|
||||
};
|
||||
|
||||
var jwtHandler = new JwtSecurityTokenHandler();
|
||||
var securityToken = jwtHandler.CreateToken(descriptor);
|
||||
return jwtHandler.WriteToken(securityToken);
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Dlhis.ScheduledTask.Common.Response;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
|
||||
public class JinkoSapService : IJinkoSapService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ILogger<JinkoSapService> _logger;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
public JinkoSapService(IHttpClientFactory httpClientFactory, IDbContext dbContext, ILogger<JinkoSapService> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
_httpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public async Task<SapOrganizationResponse> GetSapOrganizationsAsync()
|
||||
{
|
||||
const string apiUrl = "/RESTAdapter/Rest/EHR_ORGANIZATION/";
|
||||
|
||||
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, new StringContent("{}", Encoding.UTF8, "application/json"));
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string responseJson = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonConvert.DeserializeObject<SapOrganizationResponse>(responseJson);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<SapPositionResponse> GetPositionsAsync()
|
||||
{
|
||||
const string apiUrl = "/RESTAdapter/Rest/EHR_POSITION/";
|
||||
|
||||
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, new StringContent("{}", Encoding.UTF8, "application/json"));
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string responseJson = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var result = JsonConvert.DeserializeObject<SapPositionResponse>(responseJson);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<SapPersonResponse> GetPersonsByWerkAsync(string werk)
|
||||
{
|
||||
const string apiUrl = "/RESTAdapter/Rest/EHR_PERSONNEL/";
|
||||
|
||||
var werkInfo = await _dbContext.Queryable<WerkEntity>()
|
||||
.Where(x => x.Enable)
|
||||
.Where(x => x.Werk == werk)
|
||||
.SingleAsync();
|
||||
|
||||
var body = new
|
||||
{
|
||||
//I_ALLINFO = "X",
|
||||
T_WERKS = new
|
||||
{
|
||||
item = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
WERKS = werkInfo.Werk
|
||||
}
|
||||
}
|
||||
},
|
||||
T_PERSON = Array.Empty<string>(),
|
||||
T_PNO = Array.Empty<string>(),
|
||||
};
|
||||
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, content);
|
||||
if (response.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
_logger.LogError("获取{Werk}人事范围数据异常:{error}", werk, await response.Content.ReadAsStringAsync());
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var personResp = JsonConvert.DeserializeObject<SapPersonResponse>(jsonResponse);
|
||||
|
||||
List<SapPersonItem> persons = new();
|
||||
|
||||
if (personResp?.Person?.Items?.Any() == true)
|
||||
{
|
||||
persons.AddRange(personResp.Person.Items);
|
||||
}
|
||||
|
||||
return new SapPersonResponse()
|
||||
{
|
||||
Person = new SapPerson<SapPersonItem>
|
||||
{
|
||||
Items = persons
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<SapPersonResponse> GetPersonsByCodeAsync(string code)
|
||||
{
|
||||
const string apiUrl = "/RESTAdapter/Rest/EHR_PERSONNEL/";
|
||||
|
||||
var body = new
|
||||
{
|
||||
//I_ALLINFO = "X",
|
||||
T_WERKS = Array.Empty<string>(),
|
||||
T_PERSON = Array.Empty<string>(),
|
||||
T_PNO = new
|
||||
{
|
||||
item = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
ZWORKCODE = code
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
var response = await _httpClientFactory.CreateClient("jinko:sap").PostAsync(apiUrl, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var personResp = JsonConvert.DeserializeObject<SapPersonResponse>(jsonResponse);
|
||||
|
||||
List<SapPersonItem> persons = new();
|
||||
|
||||
if (personResp?.Person?.Items?.Any() == true)
|
||||
{
|
||||
persons.AddRange(personResp.Person.Items);
|
||||
}
|
||||
|
||||
return new SapPersonResponse
|
||||
{
|
||||
Person = new SapPerson<SapPersonItem>
|
||||
{
|
||||
Items = persons
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.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" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ public class CreateDefinitelyGroupJob : BaseJob
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
//获取所有基地信息
|
||||
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantResult.Data;
|
||||
var tenants = await _tenantApi.GetTenantsInternalAsync();
|
||||
|
||||
Logger.LogInformation("获取基地信息:{json}", JsonConvert.SerializeObject(tenants));
|
||||
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Jip.Api;
|
||||
using Dlhis.Jip.Api.Request;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using Hangfire;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
|
||||
@@ -17,12 +16,12 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(MealSupplementHandlerJob), "0 0/30 * * * ?", Name = "餐补核算")]
|
||||
public class MealSupplementHandlerJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoJipService _jinkoJIPService;
|
||||
private readonly IJinkoJipApi _jinkoJipApi;
|
||||
|
||||
public MealSupplementHandlerJob(IServiceProvider serviceProvider,
|
||||
IJinkoJipService jinkoJIPService) : base(serviceProvider)
|
||||
IJinkoJipApi jinkoJipApi) : base(serviceProvider)
|
||||
{
|
||||
_jinkoJIPService = jinkoJIPService;
|
||||
_jinkoJipApi = jinkoJipApi;
|
||||
}
|
||||
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
@@ -59,7 +58,7 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
{
|
||||
try
|
||||
{
|
||||
var r = await _jinkoJIPService.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
var r = await _jinkoJipApi.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
{
|
||||
new()
|
||||
{
|
||||
@@ -79,6 +78,7 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
}
|
||||
catch
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -121,8 +121,8 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
|
||||
IsDeleted = false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (!await DbContext.Queryable<UserBalanceEntity>().Where(x => x.UserCode == gainfo.Code).AnyAsync())
|
||||
{
|
||||
await DbContext.InsertAsync(new UserBalanceEntity
|
||||
@@ -153,8 +153,8 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
.Where(x => x.UserCode == gainfo.Code && x.Version == version)
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
}, 5);
|
||||
|
||||
var r = await _jinkoJIPService.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
|
||||
var r = await _jinkoJipApi.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
{
|
||||
new()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
@@ -8,23 +8,23 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncBusinessTripJob), "0 0 1 1/1 * ? ", Name = "SAP同步出差信息")]
|
||||
public class SyncBusinessTripJob : BaseJob
|
||||
{
|
||||
private readonly ISyncApi _syncApi;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SyncBusinessTripJob(IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
public SyncBusinessTripJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
|
||||
{
|
||||
_syncApi = syncApi;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
// var sapBusinessTripService = serviceProvider.GetService<ISapBusinessTripService>();
|
||||
//
|
||||
// var identityDbContext = DbContext.ChangeDb("identity");
|
||||
// var factories = await identityDbContext.Queryable<TenantEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.PCode)).ToListAsync();
|
||||
//
|
||||
// foreach (var factory in factories)
|
||||
// {
|
||||
// await sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(factory.Code);
|
||||
// }
|
||||
var identityDbContext = DbContext.ChangeDb("identity");
|
||||
var factories = await identityDbContext.Queryable<TenantEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.PCode)).ToListAsync();
|
||||
|
||||
foreach (var factory in factories)
|
||||
{
|
||||
await _syncApi.HandlerBusinessTripsAsync(factory.Code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Basic.Api.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncOrganizationJob), "0 0 0 * * ?", Name = "SAP组织架构数据同步")]
|
||||
public class SyncOrganizationJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private readonly ISyncApi _syncApi;
|
||||
|
||||
public SyncOrganizationJob(IServiceProvider serviceProvider, IJinkoSapService jinkoSapService) : base(serviceProvider)
|
||||
public SyncOrganizationJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
|
||||
{
|
||||
_jinkoSapService = jinkoSapService;
|
||||
_syncApi = syncApi;
|
||||
}
|
||||
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
var orgResult = await _jinkoSapService.GetSapOrganizationsAsync();
|
||||
var orgResult = await _syncApi.SyncOrganizationsAsync();
|
||||
|
||||
if (orgResult.Org != null && orgResult.Org.Items.Count > 0)
|
||||
{
|
||||
@@ -53,4 +53,4 @@ public class SyncOrganizationJob : BaseJob
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Jip.Api;
|
||||
using Dlhis.Jip.Api.Requests;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
@@ -14,11 +14,11 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncOriginCardInfoJob), "0 0/1 * * * ?", Name = "上传考勤记录")]
|
||||
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)
|
||||
@@ -52,7 +52,7 @@ public class SyncOriginCardInfoJob : BaseJob
|
||||
try
|
||||
{
|
||||
var ids = items.Select(x => x.Id).ToList();
|
||||
var r = await _jinkoJipService.UploadAttendancesAsync(new UploadAttendanceRequest { Data = items.ToList() });
|
||||
var r = await _jinkoJipApi.UploadAttendancesAsync(new UploadAttendanceRequest { Data = items.ToList() });
|
||||
if (r.OLX == "0")
|
||||
{
|
||||
await DbContext.Updateable<DeviceUploadLogEntity>()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using Hangfire;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Basic.Api.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncPositionJob), "0 0 0 * * ?", Name = "SAP岗位信息同步")]
|
||||
public class SyncPositionJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private readonly ISyncApi _syncApi;
|
||||
|
||||
public SyncPositionJob(IServiceProvider serviceProvider, IJinkoSapService jinkoSapService) : base(serviceProvider)
|
||||
public SyncPositionJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
|
||||
{
|
||||
_jinkoSapService = jinkoSapService;
|
||||
_syncApi = syncApi;
|
||||
}
|
||||
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
var positionResult = await _jinkoSapService.GetPositionsAsync();
|
||||
var positionResult = await _syncApi.GetPositionsAsync();
|
||||
|
||||
if (positionResult.Position != null && positionResult.Position.Items.Count > 0)
|
||||
{
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Packs;
|
||||
|
||||
public class JinkoSapHttpClientPack : BaseAppPack
|
||||
{
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddHttpClient("jinko:sap", (_, httpClient) =>
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Dlhis.Jip.Api;
|
||||
using Dlhis.Jip.Api.Request;
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
@@ -20,4 +22,20 @@ public class Startup : DefaultStartup
|
||||
base.ConfigureServices(services);
|
||||
services.AddRedis();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
base.Configure(app, env);
|
||||
|
||||
// var a = app.ApplicationServices.GetService<IJinkoJipApi>().SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>()
|
||||
// {
|
||||
// new SyncMealSupplementRecordRequest
|
||||
// {
|
||||
// UniqueId = null,
|
||||
// Status = null,
|
||||
// Msg = null
|
||||
// }
|
||||
// }).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Jip.Api.Request;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -10,18 +8,16 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Controllers;
|
||||
/// <summary>
|
||||
/// 调度任务
|
||||
/// </summary>
|
||||
[Authorize(Roles = "admin")]
|
||||
[AllowAnonymous]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class HangfireController : ControllerBase
|
||||
{
|
||||
private readonly IHangfireService _hangfireService;
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ISyncApi _gainfoSyncApi;
|
||||
|
||||
public HangfireController(IHangfireService hangfireService, IDbContext dbContext)
|
||||
public HangfireController(ISyncApi gainfoSyncApi)
|
||||
{
|
||||
_hangfireService = hangfireService;
|
||||
_dbContext = dbContext;
|
||||
_gainfoSyncApi = gainfoSyncApi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -29,11 +25,10 @@ public class HangfireController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("sap/person/no")]
|
||||
public async Task PersonManuallySync(SapNoRequest request)
|
||||
{
|
||||
await _hangfireService.CreateSapPersonSyncBackgroundJobAsync(request);
|
||||
await _gainfoSyncApi.SyncGainfoByUserCodeAsync(request.Code);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,13 +39,6 @@ public class HangfireController : ControllerBase
|
||||
[HttpPost("sap/werk/no")]
|
||||
public async Task WerkManuallySync(SapNoRequest request)
|
||||
{
|
||||
await _hangfireService.CreateSapWerkSyncBackgroundJobAsync(request);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("sap/face")]
|
||||
public async Task FaceUploadToSapAsync(FaceUploadToSapRequest request)
|
||||
{
|
||||
await _hangfireService.FaceUploadToSapAsync(request);
|
||||
await _gainfoSyncApi.SyncGainfoByWerkAsync(request.Code);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
|
||||
public class FaceUploadToSapRequest
|
||||
{
|
||||
public string UserCode { get; set; }
|
||||
public string Base64 { get; set; }
|
||||
}
|
||||
@@ -71,9 +71,7 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
|
||||
|
||||
try
|
||||
{
|
||||
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantResult.Data;
|
||||
|
||||
var tenants = await _tenantApi.GetTenantsInternalAsync();
|
||||
page.Data.ForEach(item => { item.TenantName = tenants.FirstOrDefault(x => x.Code == item.TenantId)?.Name; });
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
Reference in New Issue
Block a user