增加多群通知
This commit is contained in:
parent
d165f2b043
commit
7cc6dc6ba5
89
README.md
89
README.md
@ -30,12 +30,25 @@
|
|||||||
|
|
||||||
### 2. 配置企业微信Webhook
|
### 2. 配置企业微信Webhook
|
||||||
|
|
||||||
在 `src/main/resources/application.yml` 中配置您的企业微信Webhook地址:
|
在 `src/main/resources/application.yml` 中配置您的群组信息:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
wechat:
|
task:
|
||||||
webhook:
|
reminder:
|
||||||
url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_WEBHOOK_KEY
|
groups:
|
||||||
|
- id: "your-team"
|
||||||
|
name: "您的团队名称"
|
||||||
|
webhook:
|
||||||
|
url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_WEBHOOK_KEY"
|
||||||
|
task-system: "zentao" # 或 smartsheet, jira 等
|
||||||
|
schedules:
|
||||||
|
morning:
|
||||||
|
time: "0 0 9 * * MON-FRI"
|
||||||
|
message: "早上提醒消息"
|
||||||
|
evening:
|
||||||
|
time: "0 30 17 * * MON-FRI"
|
||||||
|
message: "晚上提醒消息"
|
||||||
|
enabled: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. 编译和运行
|
### 3. 编译和运行
|
||||||
@ -66,39 +79,81 @@ java -jar target/task-reminder-1.0.0.jar
|
|||||||
# 健康检查
|
# 健康检查
|
||||||
curl http://localhost:8080/api/reminder/health
|
curl http://localhost:8080/api/reminder/health
|
||||||
|
|
||||||
|
# 获取系统信息
|
||||||
|
curl http://localhost:8080/api/reminder/info
|
||||||
|
|
||||||
|
# 查看所有群组配置
|
||||||
|
curl http://localhost:8080/api/reminder/groups
|
||||||
|
|
||||||
# 发送测试消息
|
# 发送测试消息
|
||||||
curl -X POST http://localhost:8080/api/reminder/test
|
curl -X POST http://localhost:8080/api/reminder/test
|
||||||
|
|
||||||
# 手动触发早上提醒
|
# 手动触发所有群组早上提醒
|
||||||
curl -X POST http://localhost:8080/api/reminder/morning
|
curl -X POST http://localhost:8080/api/reminder/morning
|
||||||
|
|
||||||
# 手动触发晚上提醒
|
# 手动触发所有群组晚上提醒
|
||||||
curl -X POST http://localhost:8080/api/reminder/evening
|
curl -X POST http://localhost:8080/api/reminder/evening
|
||||||
|
|
||||||
# 获取提醒信息
|
# 手动触发指定群组的提醒
|
||||||
curl http://localhost:8080/api/reminder/info
|
curl -X POST http://localhost:8080/api/reminder/groups/{groupId}/{scheduleType}
|
||||||
|
|
||||||
|
# 重新加载配置
|
||||||
|
curl -X POST http://localhost:8080/api/reminder/reload
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置说明
|
## 配置说明
|
||||||
|
|
||||||
### 时间配置
|
### 多群组配置
|
||||||
|
|
||||||
在 `application.yml` 中可以自定义提醒时间:
|
系统支持配置多个群组,每个群组可以有不同的设置:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
task:
|
task:
|
||||||
reminder:
|
reminder:
|
||||||
morning:
|
groups:
|
||||||
time: "0 0 9 * * MON-FRI" # Cron表达式:工作日早上9点
|
# 禅道团队
|
||||||
message: "早上好!请及时更新您的任务状态,开始新的一天工作!"
|
- id: "zentao-team"
|
||||||
evening:
|
name: "禅道开发团队"
|
||||||
time: "0 30 17 * * MON-FRI" # Cron表达式:工作日下午5:30
|
webhook:
|
||||||
message: "下班前提醒:请更新今日任务完成状态,为明天做好准备!"
|
url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY_1"
|
||||||
|
task-system: "zentao"
|
||||||
|
schedules:
|
||||||
|
morning:
|
||||||
|
time: "0 0 9 * * MON-FRI" # 早上9点
|
||||||
|
message: "请及时登录禅道系统刷新任务状态"
|
||||||
|
evening:
|
||||||
|
time: "0 30 17 * * MON-FRI" # 下午5:30
|
||||||
|
message: "请更新今日任务完成状态"
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# 智能表格团队
|
||||||
|
- id: "smartsheet-team"
|
||||||
|
name: "智能表格团队"
|
||||||
|
webhook:
|
||||||
|
url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY_2"
|
||||||
|
task-system: "smartsheet"
|
||||||
|
schedules:
|
||||||
|
morning:
|
||||||
|
time: "0 50 8 * * MON-FRI" # 早上8:50
|
||||||
|
message: "请及时更新智能表格中的任务状态"
|
||||||
|
evening:
|
||||||
|
time: "0 20 17 * * MON-FRI" # 下午5:20
|
||||||
|
message: "请在智能表格中更新今日工作完成情况"
|
||||||
|
enabled: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 支持的任务管理系统
|
||||||
|
|
||||||
|
- `zentao` - 禅道
|
||||||
|
- `smartsheet` - 智能表格
|
||||||
|
- `jira` - Jira
|
||||||
|
- `trello` - Trello
|
||||||
|
- `asana` - Asana
|
||||||
|
- `notion` - Notion
|
||||||
|
|
||||||
### 节假日配置
|
### 节假日配置
|
||||||
|
|
||||||
系统内置了2024年和2025年的法定节假日,可以在 `HolidayUtil.java` 中修改或添加自定义节假日。
|
系统内置了2025年的法定节假日,可以在 `HolidayUtil.java` 中修改或添加自定义节假日。
|
||||||
|
|
||||||
## API文档
|
## API文档
|
||||||
|
|
||||||
|
|||||||
4
pom.xml
4
pom.xml
@ -10,8 +10,8 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Zeodao Task Reminder</name>
|
<name>Multi-Group Task Reminder</name>
|
||||||
<description>企业微信任务提醒系统</description>
|
<description>多群企业微信任务提醒系统</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@ -5,20 +5,20 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zeodao任务提醒系统主启动类
|
* 多群任务提醒系统主启动类
|
||||||
*
|
*
|
||||||
* @author Zeodao
|
* @author Zeodao
|
||||||
* @version 1.0.0
|
* @version 2.0.0
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
public class ZeodaoTaskReminderApplication {
|
public class TaskReminderApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ZeodaoTaskReminderApplication.class, args);
|
SpringApplication.run(TaskReminderApplication.class, args);
|
||||||
System.out.println("=================================");
|
System.out.println("=================================");
|
||||||
System.out.println("Zeodao任务提醒系统启动成功!");
|
System.out.println("多群任务提醒系统启动成功!");
|
||||||
System.out.println("系统将在工作日早上9:00和下午17:30发送任务提醒");
|
System.out.println("系统支持多个群组和多种任务管理系统");
|
||||||
System.out.println("=================================");
|
System.out.println("=================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,14 +192,11 @@ public class WechatWebhookService {
|
|||||||
String systemIcon = getTaskSystemIcon(group.getTaskSystem());
|
String systemIcon = getTaskSystemIcon(group.getTaskSystem());
|
||||||
|
|
||||||
message.append("## ").append(systemIcon).append(" ").append(systemName).append("任务状态提醒\n\n");
|
message.append("## ").append(systemIcon).append(" ").append(systemName).append("任务状态提醒\n\n");
|
||||||
message.append("**⏰ 时间:** ").append(timestamp).append(" (").append(dayOfWeek).append(")\n");
|
message.append("⏰ **时间:** ").append(timestamp).append(" (").append(dayOfWeek).append(")\n\n");
|
||||||
message.append("**📝 提醒类型:** ").append(timeType).append("\n\n");
|
message.append("📢 ").append(baseMessage).append("\n\n");
|
||||||
message.append("### 📢 重要提醒\n");
|
message.append("🔗 **操作指引:**\n");
|
||||||
message.append(baseMessage).append("\n\n");
|
|
||||||
message.append("### 🔗 操作指引\n");
|
|
||||||
message.append(getTaskSystemInstructions(group.getTaskSystem()));
|
message.append(getTaskSystemInstructions(group.getTaskSystem()));
|
||||||
message.append("---\n");
|
message.append("💡 及时更新任务状态有助于团队协作和项目管理");
|
||||||
message.append("💡 **温馨提示:** 及时更新任务状态有助于团队协作和项目管理");
|
|
||||||
|
|
||||||
return message.toString();
|
return message.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,54 +22,15 @@ public class HolidayUtil {
|
|||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HolidayUtil.class);
|
private static final Logger logger = LoggerFactory.getLogger(HolidayUtil.class);
|
||||||
|
|
||||||
// 2024年法定节假日(可根据实际情况调整)
|
|
||||||
private static final Set<LocalDate> HOLIDAYS_2024 = new HashSet<>();
|
|
||||||
|
|
||||||
// 2025年法定节假日(可根据实际情况调整)
|
// 2025年法定节假日(可根据实际情况调整)
|
||||||
private static final Set<LocalDate> HOLIDAYS_2025 = new HashSet<>();
|
private static final Set<LocalDate> HOLIDAYS_2025 = new HashSet<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// 初始化2024年节假日
|
|
||||||
initHolidays2024();
|
|
||||||
// 初始化2025年节假日
|
// 初始化2025年节假日
|
||||||
initHolidays2025();
|
initHolidays2025();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化2024年节假日
|
|
||||||
*/
|
|
||||||
private static void initHolidays2024() {
|
|
||||||
// 元旦:1月1日
|
|
||||||
HOLIDAYS_2024.add(LocalDate.of(2024, Month.JANUARY, 1));
|
|
||||||
|
|
||||||
// 春节:2月10日-17日
|
|
||||||
for (int day = 10; day <= 17; day++) {
|
|
||||||
HOLIDAYS_2024.add(LocalDate.of(2024, Month.FEBRUARY, day));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 清明节:4月4日-6日
|
|
||||||
for (int day = 4; day <= 6; day++) {
|
|
||||||
HOLIDAYS_2024.add(LocalDate.of(2024, Month.APRIL, day));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 劳动节:5月1日-5日
|
|
||||||
for (int day = 1; day <= 5; day++) {
|
|
||||||
HOLIDAYS_2024.add(LocalDate.of(2024, Month.MAY, day));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 端午节:6月10日
|
|
||||||
HOLIDAYS_2024.add(LocalDate.of(2024, Month.JUNE, 10));
|
|
||||||
|
|
||||||
// 中秋节:9月15日-17日
|
|
||||||
for (int day = 15; day <= 17; day++) {
|
|
||||||
HOLIDAYS_2024.add(LocalDate.of(2024, Month.SEPTEMBER, day));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 国庆节:10月1日-7日
|
|
||||||
for (int day = 1; day <= 7; day++) {
|
|
||||||
HOLIDAYS_2024.add(LocalDate.of(2024, Month.OCTOBER, day));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化2025年节假日
|
* 初始化2025年节假日
|
||||||
@ -139,9 +100,6 @@ public class HolidayUtil {
|
|||||||
|
|
||||||
int year = date.getYear();
|
int year = date.getYear();
|
||||||
switch (year) {
|
switch (year) {
|
||||||
case 2024:
|
|
||||||
isHoliday = HOLIDAYS_2024.contains(date);
|
|
||||||
break;
|
|
||||||
case 2025:
|
case 2025:
|
||||||
isHoliday = HOLIDAYS_2025.contains(date);
|
isHoliday = HOLIDAYS_2025.contains(date);
|
||||||
break;
|
break;
|
||||||
@ -190,9 +148,6 @@ public class HolidayUtil {
|
|||||||
public void addCustomHoliday(LocalDate date) {
|
public void addCustomHoliday(LocalDate date) {
|
||||||
int year = date.getYear();
|
int year = date.getYear();
|
||||||
switch (year) {
|
switch (year) {
|
||||||
case 2024:
|
|
||||||
HOLIDAYS_2024.add(date);
|
|
||||||
break;
|
|
||||||
case 2025:
|
case 2025:
|
||||||
HOLIDAYS_2025.add(date);
|
HOLIDAYS_2025.add(date);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -37,10 +37,10 @@ task:
|
|||||||
task-system: "smartsheet"
|
task-system: "smartsheet"
|
||||||
schedules:
|
schedules:
|
||||||
morning:
|
morning:
|
||||||
time: "0 0 8 * * MON-FRI" # 工作日早上8点
|
time: "0 50 8 * * MON-FRI" # 工作日早上8点50分
|
||||||
message: "早上好!请大家及时更新智能表格中的任务状态,确保项目进度信息准确无误。"
|
message: "早上好!请大家及时更新智能表格中的任务状态,确保项目进度信息准确无误。"
|
||||||
evening:
|
evening:
|
||||||
time: "0 0 18 * * MON-FRI" # 工作日下午6点
|
time: "0 20 17 * * MON-FRI" # 工作日下午5点20分
|
||||||
message: "下班前提醒:请在智能表格中更新今日工作完成情况,为明天做好准备!"
|
message: "下班前提醒:请在智能表格中更新今日工作完成情况,为明天做好准备!"
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user