|
|
@@ -1,8 +1,9 @@
|
|
|
-using EyeSoft.Extensions;
|
|
|
+using EyeSoft.Extensions;
|
|
|
using OASystem.Domain.Dtos.QiYeWeChat;
|
|
|
using OASystem.Domain.ViewModels.QiYeWeChat;
|
|
|
using System.Diagnostics;
|
|
|
using System.Text.Json;
|
|
|
+using System.Text.Json.Serialization;
|
|
|
|
|
|
namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
{
|
|
|
@@ -24,6 +25,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
private readonly string AddressBook_Corpsecret = "Y1tnjh7j-BvbqAytAoXZPUbmDR6dqLTL6mXtc6PZ7fo"; //通讯录同步 凭证密钥
|
|
|
private readonly string Approve_Corpsecret = "k_Jo69Jw9Hqg_in-Rypbs30PNbxOYa1t4e-dxYuT-kw"; //审批 凭证密钥
|
|
|
private readonly string GroupStatus_Corpsecret = "7J_ST3jTPzbZpFwl7ttToTVufjEx6O2wuApvKHxt2Ak"; //OA通知Secret
|
|
|
+ private readonly string Journal_Corpsecret = "l2lZbyLfyickVLdgi2bwVTevE-0UuZWpbNPrCbNhst0"; //汇报 凭证密钥
|
|
|
|
|
|
private readonly DateTime _1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
|
|
private readonly JobPostRepository _jobPostRep;
|
|
|
@@ -49,6 +51,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
/// 4:通讯录同步
|
|
|
/// 5:审批
|
|
|
/// 6:团组状态通知
|
|
|
+ /// 7:汇报
|
|
|
/// </param>
|
|
|
/// <returns></returns>
|
|
|
private async Task<Access_TokenView> GetTokenAsync(int applicationType)
|
|
|
@@ -87,6 +90,11 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
access_Token.corpsecret = GroupStatus_Corpsecret;
|
|
|
cacheName = "GroupStatus_Access_Token";
|
|
|
}
|
|
|
+ else if (applicationType == 7) //汇报
|
|
|
+ {
|
|
|
+ access_Token.corpsecret = Journal_Corpsecret;
|
|
|
+ cacheName = "Journal_Access_Token";
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
tokenResult.errmsg = "未识别应用类型Id!";
|
|
|
@@ -1525,6 +1533,98 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ #region 汇报
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 批量获取汇报记录单号
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="starttime"></param>
|
|
|
+ /// <param name="endtime"></param>
|
|
|
+ /// <param name="cursor"></param>
|
|
|
+ /// <param name="limit"></param>
|
|
|
+ /// <param name="filters"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JournalRecordListView> GetJournalRecordListAsync(long starttime, long endtime, int cursor = 0, int limit = 10, List<JournalFilter> filters = null)
|
|
|
+ {
|
|
|
+ JournalRecordListView result = new JournalRecordListView();
|
|
|
+
|
|
|
+ //获取汇报数据 token (Type = 7)
|
|
|
+ Access_TokenView access_Token = await GetTokenAsync(7);
|
|
|
+ if (access_Token.errcode != 0)
|
|
|
+ {
|
|
|
+ result.errcode = access_Token.errcode;
|
|
|
+ result.errmsg = string.Format("【企业微信】【获取汇报记录单号】【Token】【Msg】{0}", access_Token.errmsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ string url = string.Format("/cgi-bin/oa/journal/get_record_list?access_token={0}", access_Token.access_token);
|
|
|
+
|
|
|
+ JournalRecordList_Request req = new JournalRecordList_Request()
|
|
|
+ {
|
|
|
+ starttime = starttime,
|
|
|
+ endtime = endtime,
|
|
|
+ cursor = cursor,
|
|
|
+ limit = limit,
|
|
|
+ filters = filters
|
|
|
+ };
|
|
|
+
|
|
|
+ var options = new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
|
|
|
+ options.Converters.Add(new JsonStringEnumConverter());
|
|
|
+ var json = System.Text.Json.JsonSerializer.Serialize(req, options);
|
|
|
+ var content = new StringContent(json, Encoding.UTF8, "application/json");
|
|
|
+ var create_Req = await _httpClient.PostAsync(url, content);
|
|
|
+ var stringResponse = await create_Req.Content.ReadAsStringAsync();
|
|
|
+
|
|
|
+ result = System.Text.Json.JsonSerializer.Deserialize<JournalRecordListView>(stringResponse,
|
|
|
+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取汇报记录详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="journaluuid"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JournalDetailView> GetJournalRecordDetailAsync(string journaluuid)
|
|
|
+ {
|
|
|
+ JournalDetailView result = new JournalDetailView();
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(journaluuid))
|
|
|
+ {
|
|
|
+ result.errmsg = "journaluuid为空!";
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取汇报数据 token (Type = 7)
|
|
|
+ Access_TokenView access_Token = await GetTokenAsync(7);
|
|
|
+ if (access_Token.errcode != 0)
|
|
|
+ {
|
|
|
+ result.errcode = access_Token.errcode;
|
|
|
+ result.errmsg = string.Format("【企业微信】【获取汇报详情】【Token】【Msg】{0}", access_Token.errmsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ string url = string.Format("/cgi-bin/oa/journal/get_record_detail?access_token={0}", access_Token.access_token);
|
|
|
+
|
|
|
+ var req = new
|
|
|
+ {
|
|
|
+ journaluuid = journaluuid
|
|
|
+ };
|
|
|
+
|
|
|
+ var json = System.Text.Json.JsonSerializer.Serialize(req);
|
|
|
+ var content = new StringContent(json, Encoding.UTF8, "application/json");
|
|
|
+ var create_Req = await _httpClient.PostAsync(url, content);
|
|
|
+ var stringResponse = await create_Req.Content.ReadAsStringAsync();
|
|
|
+
|
|
|
+ result = System.Text.Json.JsonSerializer.Deserialize<JournalDetailView>(stringResponse,
|
|
|
+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region hook机器人
|
|
|
|
|
|
|