From 9f7ea6e5a05f55dea693f535faa6a0db009b34b0 Mon Sep 17 00:00:00 2001 From: liuwm Date: Thu, 15 Jul 2021 10:57:05 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E3=80=90=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E3=80=91=20=E8=8E=B7=E5=8F=96=E6=89=93=E5=8D=A1?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=8E=92=E7=8F=AD=E4=BF=A1=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/cp/api/WxCpOaService.java | 2 +- .../weixin/cp/api/impl/WxCpOaServiceImpl.java | 9 +- .../cp/bean/oa/WxCpCheckinSchedule.java | 172 +++++++++--------- .../cp/api/impl/WxCpOaServiceImplTest.java | 2 +- 4 files changed, 86 insertions(+), 99 deletions(-) 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 cf7dfc1f0e..1dc7550597 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 @@ -165,7 +165,7 @@ List getDialRecord(Date startTime, Date endTime, Integer offset, * @return 排班表信息 * @throws WxErrorException the wx error exception */ - WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List userIdList) throws WxErrorException; + List getCheckinScheduleList(Date startTime, Date endTime, List userIdList) 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 94d5d27f75..adb558ded6 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 @@ -285,7 +285,7 @@ public List getCheckinMonthData(Date startTime, Date endTi } @Override - public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List userIdList) throws WxErrorException { + public List getCheckinScheduleList(Date startTime, Date endTime, List userIdList) throws WxErrorException { if (startTime == null || endTime == null) { throw new WxRuntimeException("starttime and endtime can't be null"); } @@ -298,9 +298,6 @@ public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, long endTimestamp = endTime.getTime() / 1000L; long startTimestamp = startTime.getTime() / 1000L; - if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp >= MONTH_SECONDS) { - throw new WxRuntimeException("获取记录时间跨度不超过一个月"); - } JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); @@ -318,8 +315,8 @@ public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, JsonObject tmpJson = GsonParser.parse(responseContent); return WxCpGsonBuilder.create() .fromJson( - tmpJson, - new TypeToken() { + tmpJson.get("schedule_list"), + new TypeToken>() { }.getType() ); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java index 02b55f974f..9517a64d4d 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCheckinSchedule.java @@ -13,132 +13,122 @@ @Data public class WxCpCheckinSchedule implements Serializable { - private static final long serialVersionUID = 5399197385827384108L; + private static final long serialVersionUID = 5515056962298169806L; /** - * schedule_list 排班表信息 + * userid 打卡人员userid */ - @SerializedName("schedule_list") - private List scheduleList; + @SerializedName("userid") + private String userid; - @Data - public class UserScheduleInfo implements Serializable { - private static final long serialVersionUID = 5515056962298169806L; - /** - * userid 打卡人员userid - */ - @SerializedName("userid") - private String userid; + /** + * yearmonth 排班表月份,格式为年月,如202011 + */ + @SerializedName("yearmonth") + private Integer yearmonth; - /** - * yearmonth 排班表月份,格式为年月,如202011 - */ - @SerializedName("yearmonth") - private Integer yearmonth; + /** + * groupid 打卡规则id + */ + @SerializedName("groupid") + private Integer groupid; - /** - * groupid 打卡规则id - */ - @SerializedName("groupid") - private Integer groupid; + /** + * groupname 打卡规则名 + */ + @SerializedName("groupname") + private String groupName; - /** - * groupname 打卡规则名 - */ - @SerializedName("groupname") - private String groupName; + /** + * schedule 个人排班信息 + */ + @SerializedName("schedule") + private UserSchedule schedule; + @Data + public class UserSchedule implements Serializable { + private static final long serialVersionUID = 9138985222324576857L; /** - * schedule 个人排班信息 + * scheduleList 个人排班表信息 */ - @SerializedName("schedule") - private UserSchedule schedule; + @SerializedName("scheduleList") + private List scheduleList; @Data - public class UserSchedule implements Serializable { - private static final long serialVersionUID = 9138985222324576857L; + public class Schedule implements Serializable { + + private static final long serialVersionUID = 8344153237512495728L; + /** - * scheduleList 个人排班表信息 + * day 排班日期,为表示当月第几天的数字 */ - @SerializedName("scheduleList") - private List scheduleList; + @SerializedName("day") + private Integer day; - @Data - public class Schedule implements Serializable{ + /** + * schedule_info 排班日期,为表示当月第几天的数字 + */ + @SerializedName("schedule_info") + private ScheduleInfo scheduleInfo; - private static final long serialVersionUID = 8344153237512495728L; + @Data + public class ScheduleInfo implements Serializable { + private static final long serialVersionUID = 1317096341116256963L; + /** + * schedule_id 当日安排班次id,班次id也可在打卡规则中查询获得 + */ + @SerializedName("schedule_id") + private Integer scheduleId; /** - * day 排班日期,为表示当月第几天的数字 + * schedule_name 排班日期,为表示当月第几天的数字 */ - @SerializedName("day") - private Integer day; + @SerializedName("schedule_name") + private String scheduleName; /** - * schedule_info 排班日期,为表示当月第几天的数字 + * time_section 排班日期,为表示当月第几天的数字 */ - @SerializedName("schedule_info") - private ScheduleInfo scheduleInfo; + @SerializedName("time_section") + private List timeSection; + @Data - public class ScheduleInfo implements Serializable { - private static final long serialVersionUID = 1317096341116256963L; + public class TimeSection implements Serializable { + private static final long serialVersionUID = -3447467962751285748L; /** - * schedule_id 当日安排班次id,班次id也可在打卡规则中查询获得 + * id 时段id,为班次中某一堆上下班时间组合的id */ - @SerializedName("schedule_id") - private Integer scheduleId; + @SerializedName("id") + private Integer id; /** - * schedule_name 排班日期,为表示当月第几天的数字 + * work_sec 上班时间。距当天00:00的秒数 */ - @SerializedName("schedule_name") - private String scheduleName; + @SerializedName("work_sec") + private Integer workSec; /** - * time_section 排班日期,为表示当月第几天的数字 + * off_work_sec 下班时间。距当天00:00的秒数 */ - @SerializedName("time_section") - private List timeSection; - - - @Data - public class TimeSection implements Serializable { - private static final long serialVersionUID = -3447467962751285748L; - /** - * id 时段id,为班次中某一堆上下班时间组合的id - */ - @SerializedName("id") - private Integer id; - - /** - * work_sec 上班时间。距当天00:00的秒数 - */ - @SerializedName("work_sec") - private Integer workSec; - - /** - * off_work_sec 下班时间。距当天00:00的秒数 - */ - @SerializedName("off_work_sec") - private Integer offWorkSec; - - /** - * remind_work_sec 上班提醒时间。距当天00:00的秒数 - */ - @SerializedName("remind_work_sec") - private Integer remindWorkSec; - - /** - * remind_off_work_sec 下班提醒时间。距当天00:00的秒数 - */ - @SerializedName("remind_off_work_sec") - private Integer remindOffWorkSec; - } + @SerializedName("off_work_sec") + private Integer offWorkSec; + + /** + * remind_work_sec 上班提醒时间。距当天00:00的秒数 + */ + @SerializedName("remind_work_sec") + private Integer remindWorkSec; + + /** + * remind_off_work_sec 下班提醒时间。距当天00:00的秒数 + */ + @SerializedName("remind_off_work_sec") + private Integer remindOffWorkSec; } } + } - } } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java index 968109f591..55c773305d 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java @@ -85,7 +85,7 @@ public void testGetCheckinScheduleData() throws ParseException, WxErrorException Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-01"); Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-31"); - WxCpCheckinSchedule results = wxService.getOaService() + List results = wxService.getOaService() .getCheckinScheduleList(startTime, endTime, Lists.newArrayList("12003648")); assertThat(results).isNotNull();