Commit 1984a656 authored by wujipeng's avatar wujipeng
Browse files

企业微信运维定时通知

parent 6586bf8f
...@@ -2,6 +2,8 @@ package com.ruzhoukj.sms.task; ...@@ -2,6 +2,8 @@ package com.ruzhoukj.sms.task;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.platform.model.resp.Result;
import com.ruzhoukj.sms.common.WeChatRobotSender;
import com.ruzhoukj.sms.entity.EmailRecordEntity; import com.ruzhoukj.sms.entity.EmailRecordEntity;
import com.ruzhoukj.sms.entity.ScheduleEntity; import com.ruzhoukj.sms.entity.ScheduleEntity;
import com.ruzhoukj.sms.entity.SmsInformEntity; import com.ruzhoukj.sms.entity.SmsInformEntity;
...@@ -14,6 +16,7 @@ import com.ruzhoukj.sms.util.SmsUtil; ...@@ -14,6 +16,7 @@ import com.ruzhoukj.sms.util.SmsUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
...@@ -77,4 +80,23 @@ public class InTheEarlyTask { ...@@ -77,4 +80,23 @@ public class InTheEarlyTask {
.isDelete(1) .isDelete(1)
.build()); .build());
} }
// @Scheduled(cron = "0/10 * * * * ?")
@Scheduled(cron = "0 0 9 1 * ?")
public void inTheEarlyEnterprise() {
Date[] dates = DateUtils.getStartAndEndDateOfCurrentMonth();
//查询本月维护人的信息
ScheduleEntity scheduleEntity = scheduleService.getUser(dates[0], dates[1]);
if (!ObjectUtils.isEmpty(scheduleEntity)) {
String phone = scheduleEntity.getPhone();
String name = scheduleEntity.getName();
String webhookUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=04c5f353-33a7-4cb0-8d00-798dee5df953";
WeChatRobotSender sender = new WeChatRobotSender(webhookUrl);
try {
// 发送文本消息,并@指定手机号的成员
sender.sendTextMessage(name + "你好" + "公司本月运维工作将由你负责,你需要前往oa系统完成运维项目的维护,确保阿里云账户余额不低于1000元", null, new String[]{phone});
} catch (Exception ignored) {
}
}
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment