| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import me.chanjar.weixin.cp.api.WxCpService; |
| | | import me.chanjar.weixin.cp.bean.message.WxCpMessage; |
| | | import me.chanjar.weixin.cp.bean.oa.WxCpCheckinData; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.*; |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void getWeComAttendanceListOfNight(String attendDate, List attUser) throws Exception { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(); |
| | | |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 获取参数日期类 |
| | | Calendar calAttendDate = Calendar.getInstance(); |
| | | // 日期格式化 |
| | |
| | | } |
| | | return attendance; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 请假优先于出差优先于外出 |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 发送企微应用消息 |
| | | * |
| | | * @param userWeComIdList 接收消息用户企微ID |
| | | * @param content 消息内容 |
| | | * @param type 消息类型 |
| | | */ |
| | | public void sendNotice(List<String> userWeComIdList, String title, String content, String type) { |
| | | if (userWeComIdList.size() > 0) { |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 编辑消息 |
| | | WxCpMessage wxCpMessage = new WxCpMessage(); |
| | | wxCpMessage.setToUser(userWeComIdList.stream().collect(Collectors.joining("|"))); |
| | | if (type.equals(Constant.WECOM_MESSAGE_TYPE_TEXT)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXT); |
| | | wxCpMessage.setContent(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_IMAGE)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_IMAGE); |
| | | wxCpMessage.setMediaId(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_VOICE)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_VOICE); |
| | | wxCpMessage.setMediaId(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_VIDEO)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_VIDEO); |
| | | wxCpMessage.setMediaId(content); |
| | | wxCpMessage.setTitle(title); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_FILE)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_FILE); |
| | | wxCpMessage.setMediaId(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_TEXTCARD)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | wxCpMessage.setTitle(title); |
| | | wxCpMessage.setDescription(content); |
| | | wxCpMessage.setUrl(Constant.WECOM_MESSAGE_URL); |
| | | wxCpMessage.setBtnTxt(Constant.WECOM_MESSAGE_BTNTXT); |
| | | } else { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXT); |
| | | wxCpMessage.setContent(content); |
| | | } |
| | | wxCpMessage.setSafe("0"); |
| | | wxCpMessage.setEnableDuplicateCheck(false); |
| | | wxCpMessage.setDuplicateCheckInterval(600); |
| | | |
| | | // 发送消息 |
| | | wxCpService.getMessageService().send(wxCpMessage); |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |