feat sap出差信息获取,海宁余额上传tenantId问题
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
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 string BeginDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束日期
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ENDDA")]
|
||||
public string EndDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
[JsonProperty("OV_BEGUZ")]
|
||||
public DateTime BeginDateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ENDUZ")]
|
||||
public DateTime 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 int 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_CCMDDM")]
|
||||
public string DestinationDesc { get; set; }
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Response
|
||||
{
|
||||
public class SapTravelInfoResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 明细数据
|
||||
/// </summary>
|
||||
[JsonProperty("OT_2002")]
|
||||
public List<SapTravelInfoItem> Items { get; set; }
|
||||
}
|
||||
|
||||
public class SapTravelInfoItem
|
||||
{
|
||||
/// <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 string BeginDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束日期
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ENDDA")]
|
||||
public string EndDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
[JsonProperty("OV_BEGUZ")]
|
||||
public DateTime BeginDateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
[JsonProperty("OV_ENDUZ")]
|
||||
public DateTime 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 int 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_CCMDDM")]
|
||||
public string DestinationDesc { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,15 @@ public interface IJinkoJIPService : ISingletonDependency
|
||||
|
||||
Task<string> SyncMealSupplementRecordsAsync(List<SyncMealSupplementRecordRequest> requests);
|
||||
|
||||
public string IssueToken();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取出差信息
|
||||
/// </summary>
|
||||
/// <param name="begin"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="departmentNo"></param>
|
||||
/// <returns></returns>
|
||||
Task<SapBusinessTripInfoResponse> GetTravelInfosAsync(DateTime begin, DateTime end, string departmentNo);
|
||||
|
||||
string IssueToken();
|
||||
}
|
||||
@@ -11,12 +11,4 @@ public interface IJinkoSapService : IScopeDependency
|
||||
Task<SapPersonResponse> GetPersonsByWerkAsync(string werk);
|
||||
|
||||
Task<SapPersonResponse> GetPersonsByCodeAsync(string code);
|
||||
|
||||
/// <summary>
|
||||
/// 获取出差信息
|
||||
/// </summary>
|
||||
/// <param name="begin"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <returns></returns>
|
||||
Task<SapTravelInfoResponse> GetTravelInfosAsync(DateTime begin, DateTime end);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Response;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -85,6 +84,7 @@ public class JinkoJIPService : IJinkoJIPService
|
||||
{
|
||||
true.ThrowIfTrue(exp.Value<string>());
|
||||
}
|
||||
|
||||
if (jobj.TryGetValue("message", out var message) && !jobj.ContainsKey("code"))
|
||||
{
|
||||
true.ThrowIfTrue(message.Value<string>());
|
||||
@@ -95,6 +95,39 @@ public class JinkoJIPService : IJinkoJIPService
|
||||
return responseJson;
|
||||
}
|
||||
|
||||
|
||||
public async Task<SapBusinessTripInfoResponse> GetTravelInfosAsync(DateTime begin, DateTime end, string departmentNo)
|
||||
{
|
||||
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
|
||||
|
||||
var beginDay = begin.ToString("yyyyMMdd");
|
||||
var endDay = end.ToString("yyyyMMdd");
|
||||
|
||||
var obj = new
|
||||
{
|
||||
IV_BEGDA = beginDay,
|
||||
IV_ENDDA = endDay,
|
||||
IT_2002GH = new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
//IV_GONGH = "" 工号,
|
||||
IV_ORGID = departmentNo,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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 string IssueToken()
|
||||
{
|
||||
var jwtKey = _configuration.GetSection("JinkoOptions:Jip:Key").Value;
|
||||
@@ -106,9 +139,9 @@ public class JinkoJIPService : IJinkoJIPService
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new (JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(now).ToUnixTimeSeconds()}"),
|
||||
new (JwtRegisteredClaimNames.Exp,$"{new DateTimeOffset(expires).ToUnixTimeSeconds()}"),
|
||||
new (JwtRegisteredClaimNames.Iss,jwtKey),
|
||||
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));
|
||||
@@ -126,4 +159,4 @@ public class JinkoJIPService : IJinkoJIPService
|
||||
var securityToken = jwtHandler.CreateToken(descriptor);
|
||||
return jwtHandler.WriteToken(securityToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Dlhis.ScheduledTask.Common.Response;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Common.Services.Implements;
|
||||
@@ -153,7 +152,7 @@ public class JinkoSapService : IJinkoSapService
|
||||
persons.AddRange(personResp.Person.Items);
|
||||
}
|
||||
|
||||
return new SapPersonResponse()
|
||||
return new SapPersonResponse
|
||||
{
|
||||
Person = new SapPerson<SapPersonItem>
|
||||
{
|
||||
@@ -161,29 +160,4 @@ public class JinkoSapService : IJinkoSapService
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public async Task<SapTravelInfoResponse> GetTravelInfosAsync(DateTime begin, DateTime end)
|
||||
{
|
||||
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
|
||||
|
||||
var beginDay = begin.ToString("yyyyMMdd");
|
||||
var endDay = end.ToString("yyyyMMdd");
|
||||
|
||||
var obj = new
|
||||
{
|
||||
IV_BEGDA = beginDay,
|
||||
IV_ENDDA = endDay
|
||||
};
|
||||
|
||||
var body = obj.ToJson();
|
||||
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
var response = await GetHttpClient().PostAsync(apiUrl, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
|
||||
return JsonConvert.DeserializeObject<SapTravelInfoResponse>(jsonResponse);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user