Skip to content

Commit 8511f8f

Browse files
authored
🆕 #2219 【企业微信】 新增为打卡人员排班接口
1 parent 5f23a6f commit 8511f8f

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,11 @@ List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset,
180180
List<WxCpCheckinSchedule> getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException;
181181

182182

183+
/**
184+
* 为打卡人员排班
185+
*
186+
* @param wxCpSetCheckinSchedule the wx cp set checkin schedule
187+
* @throws WxErrorException the wx error exception
188+
*/
189+
void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule) throws WxErrorException;
183190
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,10 @@ public List<WxCpCheckinSchedule> getCheckinScheduleList(Date startTime, Date end
336336
}.getType()
337337
);
338338
}
339+
340+
@Override
341+
public void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule) throws WxErrorException {
342+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SET_CHECKIN_SCHEDULE_DATA);
343+
this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpSetCheckinSchedule));
344+
}
339345
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package me.chanjar.weixin.cp.bean.oa;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
import java.util.List;
8+
9+
/**
10+
* The type Wx cp set checkin schedule.
11+
*/
12+
@Data
13+
public class WxCpSetCheckinSchedule implements Serializable {
14+
private static final long serialVersionUID = -7106074373528367075L;
15+
16+
/**
17+
* 打卡规则的规则id,可通过“获取打卡规则”、“获取打卡数据”、“获取打卡人员排班信息”等相关接口获取
18+
*/
19+
@SerializedName("groupid")
20+
private Integer groupId;
21+
22+
/**
23+
* 排班表信息
24+
*/
25+
@SerializedName("items")
26+
private List<Item> items;
27+
28+
/**
29+
* 排班表月份,格式为年月,如202011
30+
*/
31+
@SerializedName("yearmonth")
32+
private Integer yearmonth;
33+
34+
35+
@Data
36+
public static class Item implements Serializable{
37+
38+
private static final long serialVersionUID = -918057757709951513L;
39+
40+
/**
41+
* 打卡人员userid
42+
*/
43+
@SerializedName("userid")
44+
private String userid;
45+
46+
/**
47+
* 要设置的天日期,取值在1-31之间。联合yearmonth组成唯一日期 比如20201205
48+
*/
49+
@SerializedName("day")
50+
private Integer day;
51+
52+
/**
53+
* 对应groupid规则下的班次id,通过预先拉取规则信息获取,0代表休息
54+
*/
55+
@SerializedName("schedule_id")
56+
private Integer scheduleId;
57+
}
58+
59+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ interface Oa {
9797
String GET_CHECKIN_DAY_DATA = "/cgi-bin/checkin/getcheckin_daydata";
9898
String GET_CHECKIN_MONTH_DATA = "/cgi-bin/checkin/getcheckin_monthdata";
9999
String GET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/getcheckinschedulist";
100+
String SET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/setcheckinschedulist";
100101
String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo";
101102
String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail";
102103
String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record";

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.testng.collections.Lists;
1717

1818
import java.text.ParseException;
19+
import java.util.Arrays;
1920
import java.util.Date;
2021
import java.util.List;
2122

@@ -93,6 +94,19 @@ public void testGetCheckinScheduleData() throws ParseException, WxErrorException
9394
System.out.println(gson.toJson(results));
9495
}
9596

97+
@Test
98+
public void testSetCheckinScheduleList() throws WxErrorException {
99+
WxCpSetCheckinSchedule wxCpSetCheckinSchedule = new WxCpSetCheckinSchedule();
100+
wxCpSetCheckinSchedule.setGroupId(3);
101+
wxCpSetCheckinSchedule.setYearmonth(202108);
102+
WxCpSetCheckinSchedule.Item item = new WxCpSetCheckinSchedule.Item();
103+
item.setScheduleId(0);
104+
item.setDay(20);
105+
item.setUserid("12003648");
106+
wxCpSetCheckinSchedule.setItems(Arrays.asList(item));
107+
wxService.getOaService().setCheckinScheduleList(wxCpSetCheckinSchedule);
108+
}
109+
96110
@Test
97111
public void testGetCheckinOption() throws WxErrorException {
98112

0 commit comments

Comments
 (0)