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 606155ec3..7eb986dbb 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 @@ -180,4 +180,11 @@ public interface WxCpOaService { List getCheckinScheduleList(Date startTime, Date endTime, List userIdList) throws WxErrorException; + /** + * 为打卡人员排班 + * + * @param wxCpSetCheckinSchedule the wx cp set checkin schedule + * @throws WxErrorException the wx error exception + */ + void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule) 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 3ba874401..c6c9d60f1 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 @@ -336,4 +336,10 @@ public class WxCpOaServiceImpl implements WxCpOaService { }.getType() ); } + + @Override + public void setCheckinScheduleList(WxCpSetCheckinSchedule wxCpSetCheckinSchedule) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SET_CHECKIN_SCHEDULE_DATA); + this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpSetCheckinSchedule)); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java new file mode 100644 index 000000000..3d0d1f87f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java @@ -0,0 +1,59 @@ +package me.chanjar.weixin.cp.bean.oa; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * The type Wx cp set checkin schedule. + */ +@Data +public class WxCpSetCheckinSchedule implements Serializable { + private static final long serialVersionUID = -7106074373528367075L; + + /** + * 打卡规则的规则id,可通过“获取打卡规则”、“获取打卡数据”、“获取打卡人员排班信息”等相关接口获取 + */ + @SerializedName("groupid") + private Integer groupId; + + /** + * 排班表信息 + */ + @SerializedName("items") + private List items; + + /** + * 排班表月份,格式为年月,如202011 + */ + @SerializedName("yearmonth") + private Integer yearmonth; + + + @Data + public static class Item implements Serializable{ + + private static final long serialVersionUID = -918057757709951513L; + + /** + * 打卡人员userid + */ + @SerializedName("userid") + private String userid; + + /** + * 要设置的天日期,取值在1-31之间。联合yearmonth组成唯一日期 比如20201205 + */ + @SerializedName("day") + private Integer day; + + /** + * 对应groupid规则下的班次id,通过预先拉取规则信息获取,0代表休息 + */ + @SerializedName("schedule_id") + private Integer scheduleId; + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index f577fcb21..98bd7425c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -97,6 +97,7 @@ public interface WxCpApiPathConsts { String GET_CHECKIN_DAY_DATA = "/cgi-bin/checkin/getcheckin_daydata"; String GET_CHECKIN_MONTH_DATA = "/cgi-bin/checkin/getcheckin_monthdata"; String GET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/getcheckinschedulist"; + String SET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/setcheckinschedulist"; String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo"; String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail"; String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record"; 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 f838837b0..4370bb3d8 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 @@ -16,6 +16,7 @@ import org.testng.annotations.Test; import org.testng.collections.Lists; import java.text.ParseException; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -93,6 +94,19 @@ public class WxCpOaServiceImplTest { System.out.println(gson.toJson(results)); } + @Test + public void testSetCheckinScheduleList() throws WxErrorException { + WxCpSetCheckinSchedule wxCpSetCheckinSchedule = new WxCpSetCheckinSchedule(); + wxCpSetCheckinSchedule.setGroupId(3); + wxCpSetCheckinSchedule.setYearmonth(202108); + WxCpSetCheckinSchedule.Item item = new WxCpSetCheckinSchedule.Item(); + item.setScheduleId(0); + item.setDay(20); + item.setUserid("12003648"); + wxCpSetCheckinSchedule.setItems(Arrays.asList(item)); + wxService.getOaService().setCheckinScheduleList(wxCpSetCheckinSchedule); + } + @Test public void testGetCheckinOption() throws WxErrorException {