Skip to content

Commit 2d2cf39

Browse files
authored
🆕 #2201【企业微信】 增加获取打卡记录日报、获取打卡记录月报、获取打卡人员排班信息接口
1 parent 69b9ec0 commit 2d2cf39

File tree

7 files changed

+927
-9
lines changed

7 files changed

+927
-9
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface WxCpOaService {
2626
* </pre>
2727
*
2828
* @param request 请求
29-
* @return 表单提交成功后,返回的表单编号
29+
* @return 表单提交成功后 ,返回的表单编号
3030
* @throws WxErrorException .
3131
*/
3232
String apply(WxCpOaApplyEventRequest request) throws WxErrorException;
@@ -41,7 +41,7 @@ public interface WxCpOaService {
4141
* @param startTime 获取打卡记录的开始时间
4242
* @param endTime 获取打卡记录的结束时间
4343
* @param userIdList 需要获取打卡记录的用户列表
44-
* @return 打卡数据列表
44+
* @return 打卡数据列表 checkin data
4545
* @throws WxErrorException 异常
4646
*/
4747
List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime, Date endTime,
@@ -55,7 +55,7 @@ List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime
5555
*
5656
* @param datetime 需要获取规则的当天日期
5757
* @param userIdList 需要获取打卡规则的用户列表
58-
* @return 打卡规则列表
58+
* @return 打卡规则列表 checkin option
5959
* @throws WxErrorException .
6060
*/
6161
List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException;
@@ -78,7 +78,7 @@ List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime
7878
* @param cursor 分页查询游标,默认为0,后续使用返回的next_cursor进行分页拉取
7979
* @param size 一次请求拉取审批单数量,默认值为100,上限值为100
8080
* @param filters 筛选条件,可对批量拉取的审批申请设置约束条件,支持设置多个条件,nullable
81-
* @return WxCpApprovalInfo
81+
* @return WxCpApprovalInfo approval info
8282
* @throws WxErrorException .
8383
*/
8484
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, Integer cursor, Integer size,
@@ -89,9 +89,9 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime,
8989
*
9090
* @param startTime 开始时间
9191
* @param endTime 结束时间
92-
* @return WxCpApprovalInfo
92+
* @return WxCpApprovalInfo approval info
9393
* @throws WxErrorException .
94-
* @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo
94+
* @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo
9595
*/
9696
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException;
9797

@@ -105,7 +105,7 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime,
105105
* </pre>
106106
*
107107
* @param spNo 审批单编号。
108-
* @return WxCpApprovaldetail
108+
* @return WxCpApprovaldetail approval detail
109109
* @throws WxErrorException .
110110
*/
111111
WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws WxErrorException;
@@ -117,7 +117,7 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime,
117117
* @param endTime 查询的结束时间戳
118118
* @param offset 分页查询的偏移量
119119
* @param limit 分页查询的每页大小,默认为100条,如该参数大于100则按100处理
120-
* @return .
120+
* @return . dial record
121121
* @throws WxErrorException .
122122
*/
123123
List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset,
@@ -127,9 +127,45 @@ List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset,
127127
* 获取审批模板详情
128128
*
129129
* @param templateId 模板ID
130-
* @return .
130+
* @return . template detail
131131
* @throws WxErrorException .
132132
*/
133133
WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException;
134134

135+
136+
/**
137+
* 获取打卡日报数据
138+
*
139+
* @param startTime 获取日报的开始时间
140+
* @param endTime 获取日报的结束时间
141+
* @param userIdList 获取日报的userid列表
142+
* @return 日报数据列表 checkin day data
143+
* @throws WxErrorException the wx error exception
144+
*/
145+
List<WxCpCheckinDayData> getCheckinDayData(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException;
146+
147+
148+
/**
149+
* 获取打卡月报数据
150+
*
151+
* @param startTime 获取月报的开始时间
152+
* @param endTime 获取月报的结束时间
153+
* @param userIdList 获取月报的userid列表
154+
* @return 月报数据列表
155+
* @throws WxErrorException the wx error exception
156+
*/
157+
List<WxCpCheckinMonthData> getCheckinMonthData(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException;
158+
159+
/**
160+
* 获取打卡人员排班信息
161+
*
162+
* @param startTime 获取排班信息的开始时间。Unix时间戳
163+
* @param endTime 获取排班信息的结束时间。Unix时间戳(与starttime跨度不超过一个月)
164+
* @param userIdList 需要获取排班信息的用户列表(不超过100个)
165+
* @return 排班表信息
166+
* @throws WxErrorException the wx error exception
167+
*/
168+
WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException;
169+
170+
135171
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,115 @@ public WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws W
212212
String responseContent = this.mainService.post(url, jsonObject.toString());
213213
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpTemplateResult.class);
214214
}
215+
216+
@Override
217+
public List<WxCpCheckinDayData> getCheckinDayData(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException {
218+
219+
if (startTime == null || endTime == null) {
220+
throw new WxRuntimeException("starttime and endtime can't be null");
221+
}
222+
223+
if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) {
224+
throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取");
225+
}
226+
227+
long endTimestamp = endTime.getTime() / 1000L;
228+
long startTimestamp = startTime.getTime() / 1000L;
229+
230+
JsonObject jsonObject = new JsonObject();
231+
JsonArray jsonArray = new JsonArray();
232+
233+
jsonObject.addProperty("starttime", startTimestamp);
234+
jsonObject.addProperty("endtime", endTimestamp);
235+
236+
for (String userid : userIdList) {
237+
jsonArray.add(userid);
238+
}
239+
jsonObject.add("useridlist", jsonArray);
240+
241+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DAY_DATA);
242+
String responseContent = this.mainService.post(url, jsonObject.toString());
243+
JsonObject tmpJson = GsonParser.parse(responseContent);
244+
return WxCpGsonBuilder.create()
245+
.fromJson(
246+
tmpJson.get("datas"),
247+
new TypeToken<List<WxCpCheckinDayData>>() {
248+
}.getType()
249+
);
250+
}
251+
252+
@Override
253+
public List<WxCpCheckinMonthData> getCheckinMonthData(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException {
254+
if (startTime == null || endTime == null) {
255+
throw new WxRuntimeException("starttime and endtime can't be null");
256+
}
257+
258+
if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) {
259+
throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取");
260+
}
261+
262+
long endTimestamp = endTime.getTime() / 1000L;
263+
long startTimestamp = startTime.getTime() / 1000L;
264+
265+
JsonObject jsonObject = new JsonObject();
266+
JsonArray jsonArray = new JsonArray();
267+
268+
jsonObject.addProperty("starttime", startTimestamp);
269+
jsonObject.addProperty("endtime", endTimestamp);
270+
271+
for (String userid : userIdList) {
272+
jsonArray.add(userid);
273+
}
274+
jsonObject.add("useridlist", jsonArray);
275+
276+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_MONTH_DATA);
277+
String responseContent = this.mainService.post(url, jsonObject.toString());
278+
JsonObject tmpJson = GsonParser.parse(responseContent);
279+
return WxCpGsonBuilder.create()
280+
.fromJson(
281+
tmpJson.get("datas"),
282+
new TypeToken<List<WxCpCheckinMonthData>>() {
283+
}.getType()
284+
);
285+
}
286+
287+
@Override
288+
public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException {
289+
if (startTime == null || endTime == null) {
290+
throw new WxRuntimeException("starttime and endtime can't be null");
291+
}
292+
293+
if (userIdList == null || userIdList.size() > USER_IDS_LIMIT) {
294+
throw new WxRuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取");
295+
}
296+
297+
298+
long endTimestamp = endTime.getTime() / 1000L;
299+
long startTimestamp = startTime.getTime() / 1000L;
300+
301+
if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp >= MONTH_SECONDS) {
302+
throw new WxRuntimeException("获取记录时间跨度不超过一个月");
303+
}
304+
305+
JsonObject jsonObject = new JsonObject();
306+
JsonArray jsonArray = new JsonArray();
307+
308+
jsonObject.addProperty("starttime", startTimestamp);
309+
jsonObject.addProperty("endtime", endTimestamp);
310+
311+
for (String userid : userIdList) {
312+
jsonArray.add(userid);
313+
}
314+
jsonObject.add("useridlist", jsonArray);
315+
316+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_SCHEDULE_DATA);
317+
String responseContent = this.mainService.post(url, jsonObject.toString());
318+
JsonObject tmpJson = GsonParser.parse(responseContent);
319+
return WxCpGsonBuilder.create()
320+
.fromJson(
321+
tmpJson,
322+
new TypeToken<WxCpCheckinSchedule>() {
323+
}.getType()
324+
);
325+
}
215326
}

0 commit comments

Comments
 (0)