Skip to content

Commit d3730b3

Browse files
authored
🐛 #2208【企业微信】 获取打卡人员排班信息接口修复返回结果类结构
1 parent 72205bb commit d3730b3

File tree

4 files changed

+86
-99
lines changed

4 files changed

+86
-99
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset,
165165
* @return 排班表信息
166166
* @throws WxErrorException the wx error exception
167167
*/
168-
WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException;
168+
List<WxCpCheckinSchedule> getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException;
169169

170170

171171
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public List<WxCpCheckinMonthData> getCheckinMonthData(Date startTime, Date endTi
285285
}
286286

287287
@Override
288-
public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException {
288+
public List<WxCpCheckinSchedule> getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException {
289289
if (startTime == null || endTime == null) {
290290
throw new WxRuntimeException("starttime and endtime can't be null");
291291
}
@@ -298,9 +298,6 @@ public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime,
298298
long endTimestamp = endTime.getTime() / 1000L;
299299
long startTimestamp = startTime.getTime() / 1000L;
300300

301-
if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp >= MONTH_SECONDS) {
302-
throw new WxRuntimeException("获取记录时间跨度不超过一个月");
303-
}
304301

305302
JsonObject jsonObject = new JsonObject();
306303
JsonArray jsonArray = new JsonArray();
@@ -318,8 +315,8 @@ public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime,
318315
JsonObject tmpJson = GsonParser.parse(responseContent);
319316
return WxCpGsonBuilder.create()
320317
.fromJson(
321-
tmpJson,
322-
new TypeToken<WxCpCheckinSchedule>() {
318+
tmpJson.get("schedule_list"),
319+
new TypeToken<List<WxCpCheckinSchedule>>() {
323320
}.getType()
324321
);
325322
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java

Lines changed: 81 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -13,132 +13,122 @@
1313
@Data
1414
public class WxCpCheckinSchedule implements Serializable {
1515

16-
private static final long serialVersionUID = 5399197385827384108L;
16+
private static final long serialVersionUID = 5515056962298169806L;
1717

1818
/**
19-
* schedule_list 排班表信息
19+
* userid 打卡人员userid
2020
*/
21-
@SerializedName("schedule_list")
22-
private List<UserScheduleInfo> scheduleList;
21+
@SerializedName("userid")
22+
private String userid;
2323

24-
@Data
25-
public class UserScheduleInfo implements Serializable {
26-
private static final long serialVersionUID = 5515056962298169806L;
27-
/**
28-
* userid 打卡人员userid
29-
*/
30-
@SerializedName("userid")
31-
private String userid;
24+
/**
25+
* yearmonth 排班表月份,格式为年月,如202011
26+
*/
27+
@SerializedName("yearmonth")
28+
private Integer yearmonth;
3229

33-
/**
34-
* yearmonth 排班表月份,格式为年月,如202011
35-
*/
36-
@SerializedName("yearmonth")
37-
private Integer yearmonth;
30+
/**
31+
* groupid 打卡规则id
32+
*/
33+
@SerializedName("groupid")
34+
private Integer groupid;
3835

39-
/**
40-
* groupid 打卡规则id
41-
*/
42-
@SerializedName("groupid")
43-
private Integer groupid;
36+
/**
37+
* groupname 打卡规则名
38+
*/
39+
@SerializedName("groupname")
40+
private String groupName;
4441

45-
/**
46-
* groupname 打卡规则名
47-
*/
48-
@SerializedName("groupname")
49-
private String groupName;
42+
/**
43+
* schedule 个人排班信息
44+
*/
45+
@SerializedName("schedule")
46+
private UserSchedule schedule;
5047

48+
@Data
49+
public class UserSchedule implements Serializable {
50+
private static final long serialVersionUID = 9138985222324576857L;
5151
/**
52-
* schedule 个人排班信息
52+
* scheduleList 个人排班表信息
5353
*/
54-
@SerializedName("schedule")
55-
private UserSchedule schedule;
54+
@SerializedName("scheduleList")
55+
private List<Schedule> scheduleList;
5656

5757
@Data
58-
public class UserSchedule implements Serializable {
59-
private static final long serialVersionUID = 9138985222324576857L;
58+
public class Schedule implements Serializable {
59+
60+
private static final long serialVersionUID = 8344153237512495728L;
61+
6062
/**
61-
* scheduleList 个人排班表信息
63+
* day 排班日期,为表示当月第几天的数字
6264
*/
63-
@SerializedName("scheduleList")
64-
private List<Schedule> scheduleList;
65+
@SerializedName("day")
66+
private Integer day;
6567

66-
@Data
67-
public class Schedule implements Serializable{
68+
/**
69+
* schedule_info 排班日期,为表示当月第几天的数字
70+
*/
71+
@SerializedName("schedule_info")
72+
private ScheduleInfo scheduleInfo;
6873

69-
private static final long serialVersionUID = 8344153237512495728L;
74+
@Data
75+
public class ScheduleInfo implements Serializable {
76+
private static final long serialVersionUID = 1317096341116256963L;
77+
/**
78+
* schedule_id 当日安排班次id,班次id也可在打卡规则中查询获得
79+
*/
80+
@SerializedName("schedule_id")
81+
private Integer scheduleId;
7082

7183
/**
72-
* day 排班日期,为表示当月第几天的数字
84+
* schedule_name 排班日期,为表示当月第几天的数字
7385
*/
74-
@SerializedName("day")
75-
private Integer day;
86+
@SerializedName("schedule_name")
87+
private String scheduleName;
7688

7789
/**
78-
* schedule_info 排班日期,为表示当月第几天的数字
90+
* time_section 排班日期,为表示当月第几天的数字
7991
*/
80-
@SerializedName("schedule_info")
81-
private ScheduleInfo scheduleInfo;
92+
@SerializedName("time_section")
93+
private List<TimeSection> timeSection;
94+
8295

8396
@Data
84-
public class ScheduleInfo implements Serializable {
85-
private static final long serialVersionUID = 1317096341116256963L;
97+
public class TimeSection implements Serializable {
98+
private static final long serialVersionUID = -3447467962751285748L;
8699
/**
87-
* schedule_id 当日安排班次id,班次id也可在打卡规则中查询获得
100+
* id 时段id,为班次中某一堆上下班时间组合的id
88101
*/
89-
@SerializedName("schedule_id")
90-
private Integer scheduleId;
102+
@SerializedName("id")
103+
private Integer id;
91104

92105
/**
93-
* schedule_name 排班日期,为表示当月第几天的数字
106+
* work_sec 上班时间。距当天00:00的秒数
94107
*/
95-
@SerializedName("schedule_name")
96-
private String scheduleName;
108+
@SerializedName("work_sec")
109+
private Integer workSec;
97110

98111
/**
99-
* time_section 排班日期,为表示当月第几天的数字
112+
* off_work_sec 下班时间。距当天00:00的秒数
100113
*/
101-
@SerializedName("time_section")
102-
private List<TimeSection> timeSection;
103-
104-
105-
@Data
106-
public class TimeSection implements Serializable {
107-
private static final long serialVersionUID = -3447467962751285748L;
108-
/**
109-
* id 时段id,为班次中某一堆上下班时间组合的id
110-
*/
111-
@SerializedName("id")
112-
private Integer id;
113-
114-
/**
115-
* work_sec 上班时间。距当天00:00的秒数
116-
*/
117-
@SerializedName("work_sec")
118-
private Integer workSec;
119-
120-
/**
121-
* off_work_sec 下班时间。距当天00:00的秒数
122-
*/
123-
@SerializedName("off_work_sec")
124-
private Integer offWorkSec;
125-
126-
/**
127-
* remind_work_sec 上班提醒时间。距当天00:00的秒数
128-
*/
129-
@SerializedName("remind_work_sec")
130-
private Integer remindWorkSec;
131-
132-
/**
133-
* remind_off_work_sec 下班提醒时间。距当天00:00的秒数
134-
*/
135-
@SerializedName("remind_off_work_sec")
136-
private Integer remindOffWorkSec;
137-
}
114+
@SerializedName("off_work_sec")
115+
private Integer offWorkSec;
116+
117+
/**
118+
* remind_work_sec 上班提醒时间。距当天00:00的秒数
119+
*/
120+
@SerializedName("remind_work_sec")
121+
private Integer remindWorkSec;
122+
123+
/**
124+
* remind_off_work_sec 下班提醒时间。距当天00:00的秒数
125+
*/
126+
@SerializedName("remind_off_work_sec")
127+
private Integer remindOffWorkSec;
138128
}
139129
}
130+
}
140131

141132

142-
}
143133
}
144134
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void testGetCheckinScheduleData() throws ParseException, WxErrorException
8585
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-01");
8686
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-31");
8787

88-
WxCpCheckinSchedule results = wxService.getOaService()
88+
List<WxCpCheckinSchedule> results = wxService.getOaService()
8989
.getCheckinScheduleList(startTime, endTime, Lists.newArrayList("12003648"));
9090

9191
assertThat(results).isNotNull();

0 commit comments

Comments
 (0)