From 8511f8f826a4e6f9cf19231c39003cf40df3f227 Mon Sep 17 00:00:00 2001 From: longliveh <35585613+longliveh@users.noreply.github.com> Date: Tue, 27 Jul 2021 20:53:19 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#2219=20=E3=80=90=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E3=80=91=20=E6=96=B0=E5=A2=9E=E4=B8=BA?= =?UTF-8?q?=E6=89=93=E5=8D=A1=E4=BA=BA=E5=91=98=E6=8E=92=E7=8F=AD=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/cp/api/WxCpOaService.java | 7 +++ .../weixin/cp/api/impl/WxCpOaServiceImpl.java | 6 ++ .../cp/bean/oa/WxCpSetCheckinSchedule.java | 59 +++++++++++++++++++ .../weixin/cp/constant/WxCpApiPathConsts.java | 1 + .../cp/api/impl/WxCpOaServiceImplTest.java | 14 +++++ 5 files changed, 87 insertions(+) create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpSetCheckinSchedule.java 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 {