| | |
| | | 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.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.*; |
| | |
| | | /** |
| | | * 发送企微每周报告 |
| | | */ |
| | | public void remindWeeklyReport() { |
| | | // 校验当天 |
| | | LocalDate todayDate = LocalDate.now(); |
| | | SysConfigHoliday todayHolidayConfig = sysConfigHolidayRepository.findByHolidayDate(todayDate.toString()); |
| | | if (isNonWorkingDay(todayDate, todayHolidayConfig)) { |
| | | return; |
| | | } |
| | | |
| | | // 校验第二天 |
| | | LocalDate tomorrowDate = todayDate.plusDays(1); |
| | | SysConfigHoliday tomorrowHolidayConfig = sysConfigHolidayRepository.findByHolidayDate(tomorrowDate.toString()); |
| | | if (isWorkingDay(tomorrowDate, tomorrowHolidayConfig)) { |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | // 获取企微机器人参数 |
| | | Map<String, String> robotParamMap = dictDetailRepository.findByDictName(Constant.WECOM_ROBOT_PARAM).stream().collect(Collectors.toMap(DictDetail::getLabel, DictDetail::getValue)); |
| | | if (robotParamMap.containsKey(Constant.REMIND_REPORT_WEBHOOK_KEY) && robotParamMap.containsKey(Constant.REMIND_REPORT_MSG)) { |
| | | // 发送消息 |
| | | WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl(); |
| | | wxCpDefaultConfig.setWebhookKey(robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY)); |
| | | wxCpService.setWxCpConfigStorage(wxCpDefaultConfig); |
| | | wxCpService.getGroupRobotService().sendText(robotParamMap.get(Constant.REMIND_REPORT_MSG), Arrays.asList("@all"), Arrays.asList()); |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发送企微每周报告 |
| | | */ |
| | | public void toWecomSheetPushReport() { |
| | | // 校验当天 |
| | | LocalDate todayDate = LocalDate.now(); |