From e9c608f11d20643ee27cab13e4b7caa0e98024dc Mon Sep 17 00:00:00 2001 From: Colorful Date: Thu, 14 Dec 2023 12:27:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E3=80=91=20=E6=89=B9=E9=87=8F=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E5=8D=95=E5=8F=B7=E6=8E=A5=E5=8F=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E7=9A=84=E5=88=86=E9=A1=B5=E5=AD=97=E6=AE=B5?= =?UTF-8?q?new=5Fcursor=E5=92=8Cnew=5Fnext=5Fcursor=E6=94=AF=E6=8C=81?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=B0=86=E6=97=A7=E7=9A=84=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=A0=87=E6=B3=A8@Deprecated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/cp/api/WxCpOaService.java | 31 +++++++++++++++ .../weixin/cp/api/impl/WxCpOaServiceImpl.java | 38 ++++++++++++++++++- .../weixin/cp/bean/oa/WxCpApprovalInfo.java | 2 + 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java index fec2c08e55..4647e0ed3f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java @@ -93,6 +93,7 @@ List getCheckinData(Integer openCheckinDataType, Date startTime * @return WxCpApprovalInfo approval info * @throws WxErrorException . */ + @Deprecated WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, Integer cursor, Integer size, List filters) throws WxErrorException; @@ -106,9 +107,39 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, * @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo me.chanjar.weixin.cp.api * .WxCpOaService#getApprovalInfome.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo */ + @Deprecated WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException; + /** + *
+   *
+   * 批量获取审批单号
+   *
+   * 审批应用及有权限的自建应用,可通过Secret调用本接口,以获取企业一段时间内企业微信“审批应用”单据的审批编号,支持按模板类型、申请人、部门、申请单审批状态等条件筛选。
+   * 自建应用调用此接口,需在“管理后台-应用管理-审批-API-审批数据权限”中,授权应用允许提交审批单据。
+   *
+   * 一次拉取调用最多拉取100个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。
+   *
+   * API doc : https://work.weixin.qq.com/api/doc/90000/90135/91816
+   *
+   * 1 接口频率限制 600次/分钟
+   * 2 请求的参数endtime需要大于startime, 起始时间跨度不能超过31天;
+   * 3 老的分页游标字段cursor和next_cursor待废弃,请开发者使用新字段new_cursor和new_next_cursor。
+   * 
+ * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param newCursor 分页查询游标,默认为0,后续使用返回的next_cursor进行分页拉取 + * @param size 一次请求拉取审批单数量,默认值为100,上限值为100 + * @param filters 筛选条件,可对批量拉取的审批申请设置约束条件,支持设置多个条件,nullable + * @return WxCpApprovalInfo approval info + * @throws WxErrorException . + */ + WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, String newCursor, Integer size, + List filters) throws WxErrorException; + + /** *
    *   获取审批申请详情
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java
index 43df95f300..53aaa00ca7 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java
@@ -153,7 +153,43 @@ public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date e
 
   @Override
   public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException {
-    return this.getApprovalInfo(startTime, endTime, null, null, null);
+    return this.getApprovalInfo(startTime, endTime, 0, null, null);
+  }
+
+  @Override
+  public WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, String newCursor,
+                                          Integer size, List filters)
+    throws WxErrorException {
+    if (newCursor == null) {
+      newCursor = "";
+    }
+
+    if (size == null) {
+      size = 100;
+    }
+
+    if (size < 0 || size > 100) {
+      throw new IllegalArgumentException("size参数错误,请使用[1-100]填充,默认100");
+    }
+
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.addProperty("starttime", startTime.getTime() / 1000L);
+    jsonObject.addProperty("endtime", endTime.getTime() / 1000L);
+    jsonObject.addProperty("size", size);
+    jsonObject.addProperty("new_cursor", newCursor);
+
+    if (filters != null && !filters.isEmpty()) {
+      JsonArray filterJsonArray = new JsonArray();
+      for (WxCpApprovalInfoQueryFilter filter : filters) {
+        filterJsonArray.add(new JsonParser().parse(filter.toJson()));
+      }
+      jsonObject.add("filters", filterJsonArray);
+    }
+
+    final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_INFO);
+    String responseContent = this.mainService.post(url, jsonObject.toString());
+
+    return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalInfo.class);
   }
 
   @Override
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java
index 70c781df43..dfc8a744a9 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java
@@ -27,4 +27,6 @@ public class WxCpApprovalInfo implements Serializable {
   @SerializedName("next_cursor")
   private Integer nextCursor;
 
+  @SerializedName("new_next_cursor")
+  private Integer newNextCursor;
 }

From 79d05f61383911a35dfc4f08f2df70031e9709d1 Mon Sep 17 00:00:00 2001
From: Colorful 
Date: Thu, 14 Dec 2023 12:35:30 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E4=BC=81=E4=B8=9A=E5=BE=AE?=
 =?UTF-8?q?=E4=BF=A1=E3=80=91=20=E6=89=B9=E9=87=8F=E8=8E=B7=E5=8F=96?=
 =?UTF-8?q?=E5=AE=A1=E6=89=B9=E5=8D=95=E5=8F=B7=E6=8E=A5=E5=8F=A3=E5=A2=9E?=
 =?UTF-8?q?=E5=8A=A0=E6=96=B0=E7=9A=84=E5=88=86=E9=A1=B5=E5=AD=97=E6=AE=B5?=
 =?UTF-8?q?new=5Fcursor=E5=92=8Cnew=5Fnext=5Fcursor=E6=94=AF=E6=8C=81?=
 =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=B0=86=E6=97=A7=E7=9A=84=E6=96=B9=E6=B3=95?=
 =?UTF-8?q?=E6=A0=87=E6=B3=A8@Deprecated?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java
index dfc8a744a9..712e7c4b59 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalInfo.java
@@ -28,5 +28,5 @@ public class WxCpApprovalInfo implements Serializable {
   private Integer nextCursor;
 
   @SerializedName("new_next_cursor")
-  private Integer newNextCursor;
+  private String newNextCursor;
 }