🐛 #2208【企业微信】 获取打卡人员排班信息接口修复返回结果类结构

This commit is contained in:
longliveh 2021-07-18 23:03:55 +08:00 committed by GitHub
parent 72205bbf16
commit d3730b361d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 101 deletions

View File

@ -165,7 +165,7 @@ public interface WxCpOaService {
* @return 排班表信息 * @return 排班表信息
* @throws WxErrorException the wx error exception * @throws WxErrorException the wx error exception
*/ */
WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException; List<WxCpCheckinSchedule> getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException;
} }

View File

@ -285,7 +285,7 @@ public class WxCpOaServiceImpl implements WxCpOaService {
} }
@Override @Override
public WxCpCheckinSchedule getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException { public List<WxCpCheckinSchedule> getCheckinScheduleList(Date startTime, Date endTime, List<String> userIdList) throws WxErrorException {
if (startTime == null || endTime == null) { if (startTime == null || endTime == null) {
throw new WxRuntimeException("starttime and endtime can't be null"); throw new WxRuntimeException("starttime and endtime can't be null");
} }
@ -298,9 +298,6 @@ public class WxCpOaServiceImpl implements WxCpOaService {
long endTimestamp = endTime.getTime() / 1000L; long endTimestamp = endTime.getTime() / 1000L;
long startTimestamp = startTime.getTime() / 1000L; long startTimestamp = startTime.getTime() / 1000L;
if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp >= MONTH_SECONDS) {
throw new WxRuntimeException("获取记录时间跨度不超过一个月");
}
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray(); JsonArray jsonArray = new JsonArray();
@ -318,8 +315,8 @@ public class WxCpOaServiceImpl implements WxCpOaService {
JsonObject tmpJson = GsonParser.parse(responseContent); JsonObject tmpJson = GsonParser.parse(responseContent);
return WxCpGsonBuilder.create() return WxCpGsonBuilder.create()
.fromJson( .fromJson(
tmpJson, tmpJson.get("schedule_list"),
new TypeToken<WxCpCheckinSchedule>() { new TypeToken<List<WxCpCheckinSchedule>>() {
}.getType() }.getType()
); );
} }

View File

@ -13,132 +13,122 @@ import java.util.List;
@Data @Data
public class WxCpCheckinSchedule implements Serializable { public class WxCpCheckinSchedule implements Serializable {
private static final long serialVersionUID = 5399197385827384108L; private static final long serialVersionUID = 5515056962298169806L;
/** /**
* schedule_list 排班表信息 * userid 打卡人员userid
*/ */
@SerializedName("schedule_list") @SerializedName("userid")
private List<UserScheduleInfo> scheduleList; private String userid;
/**
* yearmonth 排班表月份格式为年月如202011
*/
@SerializedName("yearmonth")
private Integer yearmonth;
/**
* groupid 打卡规则id
*/
@SerializedName("groupid")
private Integer groupid;
/**
* groupname 打卡规则名
*/
@SerializedName("groupname")
private String groupName;
/**
* schedule 个人排班信息
*/
@SerializedName("schedule")
private UserSchedule schedule;
@Data @Data
public class UserScheduleInfo implements Serializable { public class UserSchedule implements Serializable {
private static final long serialVersionUID = 5515056962298169806L; private static final long serialVersionUID = 9138985222324576857L;
/** /**
* userid 打卡人员userid * scheduleList 个人排班表信息
*/ */
@SerializedName("userid") @SerializedName("scheduleList")
private String userid; private List<Schedule> scheduleList;
/**
* yearmonth 排班表月份格式为年月如202011
*/
@SerializedName("yearmonth")
private Integer yearmonth;
/**
* groupid 打卡规则id
*/
@SerializedName("groupid")
private Integer groupid;
/**
* groupname 打卡规则名
*/
@SerializedName("groupname")
private String groupName;
/**
* schedule 个人排班信息
*/
@SerializedName("schedule")
private UserSchedule schedule;
@Data @Data
public class UserSchedule implements Serializable { public class Schedule implements Serializable {
private static final long serialVersionUID = 9138985222324576857L;
private static final long serialVersionUID = 8344153237512495728L;
/** /**
* scheduleList 个人排班表信息 * day 排班日期为表示当月第几天的数字
*/ */
@SerializedName("scheduleList") @SerializedName("day")
private List<Schedule> scheduleList; private Integer day;
/**
* schedule_info 排班日期为表示当月第几天的数字
*/
@SerializedName("schedule_info")
private ScheduleInfo scheduleInfo;
@Data @Data
public class Schedule implements Serializable{ public class ScheduleInfo implements Serializable {
private static final long serialVersionUID = 1317096341116256963L;
private static final long serialVersionUID = 8344153237512495728L; /**
* schedule_id 当日安排班次id班次id也可在打卡规则中查询获得
*/
@SerializedName("schedule_id")
private Integer scheduleId;
/** /**
* day 排班日期为表示当月第几天的数字 * schedule_name 排班日期为表示当月第几天的数字
*/ */
@SerializedName("day") @SerializedName("schedule_name")
private Integer day; private String scheduleName;
/** /**
* schedule_info 排班日期为表示当月第几天的数字 * time_section 排班日期为表示当月第几天的数字
*/ */
@SerializedName("schedule_info") @SerializedName("time_section")
private ScheduleInfo scheduleInfo; private List<TimeSection> timeSection;
@Data @Data
public class ScheduleInfo implements Serializable { public class TimeSection implements Serializable {
private static final long serialVersionUID = 1317096341116256963L; private static final long serialVersionUID = -3447467962751285748L;
/** /**
* schedule_id 当日安排班次id班次id也可在打卡规则中查询获得 * id 时段id为班次中某一堆上下班时间组合的id
*/ */
@SerializedName("schedule_id") @SerializedName("id")
private Integer scheduleId; private Integer id;
/** /**
* schedule_name 排班日期为表示当月第几天的数字 * work_sec 上班时间距当天00:00的秒数
*/ */
@SerializedName("schedule_name") @SerializedName("work_sec")
private String scheduleName; private Integer workSec;
/** /**
* time_section 排班日期为表示当月第几天的数字 * off_work_sec 下班时间距当天00:00的秒数
*/ */
@SerializedName("time_section") @SerializedName("off_work_sec")
private List<TimeSection> timeSection; private Integer offWorkSec;
/**
* remind_work_sec 上班提醒时间距当天00:00的秒数
*/
@SerializedName("remind_work_sec")
private Integer remindWorkSec;
@Data /**
public class TimeSection implements Serializable { * remind_off_work_sec 下班提醒时间距当天00:00的秒数
private static final long serialVersionUID = -3447467962751285748L; */
/** @SerializedName("remind_off_work_sec")
* id 时段id为班次中某一堆上下班时间组合的id private Integer remindOffWorkSec;
*/
@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;
}
} }
} }
} }
} }
} }

View File

@ -85,7 +85,7 @@ public class WxCpOaServiceImplTest {
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-01"); Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-01");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-31"); Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2021-07-31");
WxCpCheckinSchedule results = wxService.getOaService() List<WxCpCheckinSchedule> results = wxService.getOaService()
.getCheckinScheduleList(startTime, endTime, Lists.newArrayList("12003648")); .getCheckinScheduleList(startTime, endTime, Lists.newArrayList("12003648"));
assertThat(results).isNotNull(); assertThat(results).isNotNull();