task-reminder/README.md
2025-05-28 10:44:31 +08:00

237 lines
5.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Zeodao任务提醒系统 v2.0
一个基于Spring Boot的多群企业微信任务提醒系统支持多个团队群组、多种任务管理系统和自定义提醒时间。系统可以同时为使用禅道、智能表格、Jira等不同任务管理工具的团队提供个性化的任务状态提醒服务。
## 功能特性
-**多群组支持** - 同时支持多个企业微信群组
-**多任务系统** - 支持禅道、智能表格、Jira、Trello等任务管理系统
-**自定义时间** - 每个群组可配置不同的提醒时间
-**个性化消息** - 根据任务管理系统生成专属操作指引
-**动态调度** - 根据配置文件动态创建定时任务
-**自动排除节假日** - 智能跳过周末和法定节假日
-**企业微信集成** - 支持Webhook消息推送和Markdown格式
-**REST API** - 提供完整的管理和监控接口
-**实时监控** - 任务状态监控和日志记录
## 技术栈
- Java 21
- Spring Boot 2.7.14
- Maven
- 企业微信Webhook API
## 快速开始
### 1. 环境要求
- JDK 21 或更高版本
- Maven 3.6+
### 2. 配置企业微信Webhook
`src/main/resources/application.yml` 中配置您的群组信息:
```yaml
task:
reminder:
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. 编译和运行
```bash
# 编译项目
mvn clean compile
# 运行项目
mvn spring-boot:run
```
或者打包后运行:
```bash
# 打包
mvn clean package
# 运行jar包
java -jar target/task-reminder-1.0.0.jar
```
### 4. 验证系统
系统启动后可以通过以下API进行测试
```bash
# 健康检查
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/morning
# 手动触发所有群组晚上提醒
curl -X POST http://localhost:8080/api/reminder/evening
# 手动触发指定群组的提醒
curl -X POST http://localhost:8080/api/reminder/groups/{groupId}/{scheduleType}
# 重新加载配置
curl -X POST http://localhost:8080/api/reminder/reload
```
## 配置说明
### 多群组配置
系统支持配置多个群组,每个群组可以有不同的设置:
```yaml
task:
reminder:
groups:
# 禅道团队
- id: "zentao-team"
name: "禅道开发团队"
webhook:
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
### 节假日配置
系统内置了2025年的法定节假日可以在 `HolidayUtil.java` 中修改或添加自定义节假日。
## API文档
### 健康检查
- **URL**: `GET /api/reminder/health`
- **描述**: 检查系统运行状态
### 发送测试消息
- **URL**: `POST /api/reminder/test`
- **描述**: 发送一条测试消息到企业微信群
### 手动触发早上提醒
- **URL**: `POST /api/reminder/morning`
- **描述**: 手动触发早上任务提醒
### 手动触发晚上提醒
- **URL**: `POST /api/reminder/evening`
- **描述**: 手动触发晚上任务提醒
### 获取提醒信息
- **URL**: `GET /api/reminder/info`
- **描述**: 获取下次提醒时间和系统状态信息
## 日志
系统会在 `logs/task-reminder.log` 文件中记录详细的运行日志,包括:
- 定时任务执行记录
- 消息发送状态
- 错误信息
- 系统健康检查
## 部署建议
### 生产环境部署
1. 修改 `application.yml` 中的日志级别为 `INFO`
2. 配置合适的JVM参数
3. 使用systemd或其他进程管理工具管理应用
4. 配置日志轮转策略
### Docker部署
可以创建Dockerfile进行容器化部署
```dockerfile
FROM openjdk:21-jre-slim
COPY target/task-reminder-1.0.0.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]
```
## 故障排除
### 常见问题
1. **消息发送失败**
- 检查企业微信Webhook地址是否正确
- 检查网络连接是否正常
- 查看日志文件中的错误信息
2. **定时任务不执行**
- 检查Cron表达式是否正确
- 确认当前时间是否为工作日
- 查看系统日志确认定时任务是否启动
3. **节假日判断错误**
- 检查 `HolidayUtil.java` 中的节假日配置
- 确认系统时间是否正确
## 贡献
欢迎提交Issue和Pull Request来改进这个项目。
## 许可证
MIT License
## 联系方式
如有问题,请联系开发团队。