格式化
This commit is contained in:
parent
c5233719cb
commit
65e9dc7b16
@ -20,6 +20,7 @@ import java.util.Map;
|
|||||||
public class TaskReminderConfig {
|
public class TaskReminderConfig {
|
||||||
|
|
||||||
private Global global = new Global();
|
private Global global = new Global();
|
||||||
|
|
||||||
private List<Group> groups = new ArrayList<>();
|
private List<Group> groups = new ArrayList<>();
|
||||||
|
|
||||||
public Global getGlobal() {
|
public Global getGlobal() {
|
||||||
@ -49,7 +50,6 @@ public class TaskReminderConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static class Global {
|
public static class Global {
|
||||||
private int timeout = 5000;
|
private int timeout = 5000;
|
||||||
|
|
||||||
@ -64,12 +64,17 @@ public class TaskReminderConfig {
|
|||||||
|
|
||||||
public static class Group {
|
public static class Group {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Webhook webhook = new Webhook();
|
private Webhook webhook = new Webhook();
|
||||||
|
|
||||||
private TaskSystemType taskSystem;
|
private TaskSystemType taskSystem;
|
||||||
|
|
||||||
private Map<String, Schedule> schedules = new HashMap<>();
|
private Map<String, Schedule> schedules = new HashMap<>();
|
||||||
|
|
||||||
private Zentao zentao = new Zentao();
|
private Zentao zentao = new Zentao();
|
||||||
|
|
||||||
private Map<String, String> userMapping = new HashMap<>();
|
private Map<String, String> userMapping = new HashMap<>();
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@ -127,7 +132,6 @@ public class TaskReminderConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Zentao getZentao() {
|
public Zentao getZentao() {
|
||||||
return zentao;
|
return zentao;
|
||||||
}
|
}
|
||||||
@ -159,7 +163,9 @@ public class TaskReminderConfig {
|
|||||||
|
|
||||||
public static class Schedule {
|
public static class Schedule {
|
||||||
private String time;
|
private String time;
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
private boolean enabled = true; // 默认启用
|
private boolean enabled = true; // 默认启用
|
||||||
|
|
||||||
public String getTime() {
|
public String getTime() {
|
||||||
@ -189,10 +195,15 @@ public class TaskReminderConfig {
|
|||||||
|
|
||||||
public static class Zentao {
|
public static class Zentao {
|
||||||
private String apiUrl;
|
private String apiUrl;
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
private Integer projectId;
|
private Integer projectId;
|
||||||
|
|
||||||
private Integer kanbanId;
|
private Integer kanbanId;
|
||||||
|
|
||||||
public String getApiUrl() {
|
public String getApiUrl() {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ public enum ScheduleType {
|
|||||||
OVERDUE_REMINDER("overdue-reminder", "逾期任务提醒");
|
OVERDUE_REMINDER("overdue-reminder", "逾期任务提醒");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
ScheduleType(String code, String description) {
|
ScheduleType(String code, String description) {
|
||||||
|
|||||||
@ -39,6 +39,7 @@ public enum TaskSystemType {
|
|||||||
NOTION("notion", "Notion");
|
NOTION("notion", "Notion");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
TaskSystemType(String code, String description) {
|
TaskSystemType(String code, String description) {
|
||||||
|
|||||||
@ -16,8 +16,11 @@ import lombok.NoArgsConstructor;
|
|||||||
public class ProjectInfo {
|
public class ProjectInfo {
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
private boolean exists;
|
private boolean exists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,11 +35,16 @@ public class ProjectInfo {
|
|||||||
*/
|
*/
|
||||||
public String getStatusDescription() {
|
public String getStatusDescription() {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "wait": return "未开始";
|
case "wait":
|
||||||
case "doing": return "进行中";
|
return "未开始";
|
||||||
case "suspended": return "已挂起";
|
case "doing":
|
||||||
case "closed": return "已关闭";
|
return "进行中";
|
||||||
default: return "未知状态";
|
case "suspended":
|
||||||
|
return "已挂起";
|
||||||
|
case "closed":
|
||||||
|
return "已关闭";
|
||||||
|
default:
|
||||||
|
return "未知状态";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,37 +13,69 @@ import lombok.Data;
|
|||||||
public class ZentaoTask {
|
public class ZentaoTask {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
private String pri;
|
private String pri;
|
||||||
|
|
||||||
private String assignedTo;
|
private String assignedTo;
|
||||||
|
|
||||||
private String assignedToRealName;
|
private String assignedToRealName;
|
||||||
|
|
||||||
private String assignedDate;
|
private String assignedDate;
|
||||||
|
|
||||||
private String deadline;
|
private String deadline;
|
||||||
|
|
||||||
private String estStarted;
|
private String estStarted;
|
||||||
|
|
||||||
private String realStarted;
|
private String realStarted;
|
||||||
|
|
||||||
private String finishedBy;
|
private String finishedBy;
|
||||||
|
|
||||||
private String finishedDate;
|
private String finishedDate;
|
||||||
|
|
||||||
private String canceledBy;
|
private String canceledBy;
|
||||||
|
|
||||||
private String canceledDate;
|
private String canceledDate;
|
||||||
|
|
||||||
private String closedBy;
|
private String closedBy;
|
||||||
|
|
||||||
private String closedDate;
|
private String closedDate;
|
||||||
|
|
||||||
private String closedReason;
|
private String closedReason;
|
||||||
|
|
||||||
private String lastEditedBy;
|
private String lastEditedBy;
|
||||||
|
|
||||||
private String lastEditedDate;
|
private String lastEditedDate;
|
||||||
|
|
||||||
private String openedBy;
|
private String openedBy;
|
||||||
|
|
||||||
private String openedDate;
|
private String openedDate;
|
||||||
|
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
||||||
private String project;
|
private String project;
|
||||||
|
|
||||||
private String story;
|
private String story;
|
||||||
|
|
||||||
private String storyTitle;
|
private String storyTitle;
|
||||||
|
|
||||||
private String module;
|
private String module;
|
||||||
|
|
||||||
private String estimate;
|
private String estimate;
|
||||||
|
|
||||||
private String consumed;
|
private String consumed;
|
||||||
|
|
||||||
private String left;
|
private String left;
|
||||||
|
|
||||||
private String progress;
|
private String progress;
|
||||||
|
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
private String deleted;
|
private String deleted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,11 +182,16 @@ public class ZentaoTask {
|
|||||||
*/
|
*/
|
||||||
public String getPriorityDesc() {
|
public String getPriorityDesc() {
|
||||||
switch (pri) {
|
switch (pri) {
|
||||||
case "1": return "高";
|
case "1":
|
||||||
case "2": return "中";
|
return "高";
|
||||||
case "3": return "低";
|
case "2":
|
||||||
case "4": return "最低";
|
return "中";
|
||||||
default: return "普通";
|
case "3":
|
||||||
|
return "低";
|
||||||
|
case "4":
|
||||||
|
return "最低";
|
||||||
|
default:
|
||||||
|
return "普通";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,36 +14,68 @@ import lombok.Data;
|
|||||||
public class ZentaoUser {
|
public class ZentaoUser {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
private String realname;
|
private String realname;
|
||||||
|
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
private String birthday;
|
private String birthday;
|
||||||
|
|
||||||
private String gender;
|
private String gender;
|
||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
private String skype;
|
private String skype;
|
||||||
|
|
||||||
private String qq;
|
private String qq;
|
||||||
|
|
||||||
private String yahoo;
|
private String yahoo;
|
||||||
|
|
||||||
private String gtalk;
|
private String gtalk;
|
||||||
|
|
||||||
private String wangwang;
|
private String wangwang;
|
||||||
|
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
private String zipcode;
|
private String zipcode;
|
||||||
|
|
||||||
private String join;
|
private String join;
|
||||||
|
|
||||||
private String visits;
|
private String visits;
|
||||||
|
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
private String last;
|
private String last;
|
||||||
|
|
||||||
private String fails;
|
private String fails;
|
||||||
|
|
||||||
private String locked;
|
private String locked;
|
||||||
|
|
||||||
private String feedback;
|
private String feedback;
|
||||||
|
|
||||||
private String mail;
|
private String mail;
|
||||||
|
|
||||||
private String clientStatus;
|
private String clientStatus;
|
||||||
|
|
||||||
private String clientLang;
|
private String clientLang;
|
||||||
|
|
||||||
private String dept;
|
private String dept;
|
||||||
|
|
||||||
private String role;
|
private String role;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
private String groups;
|
private String groups;
|
||||||
|
|
||||||
private String view;
|
private String view;
|
||||||
|
|
||||||
private String deleted;
|
private String deleted;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -261,7 +261,6 @@ public class WechatWebhookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务管理系统的图标
|
* 获取任务管理系统的图标
|
||||||
*/
|
*/
|
||||||
@ -271,13 +270,20 @@ public class WechatWebhookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (taskSystemType) {
|
switch (taskSystemType) {
|
||||||
case ZENTAO: return "📋";
|
case ZENTAO:
|
||||||
case SMARTSHEET: return "📊";
|
return "📋";
|
||||||
case JIRA: return "🎯";
|
case SMARTSHEET:
|
||||||
case TRELLO: return "📌";
|
return "📊";
|
||||||
case ASANA: return "✅";
|
case JIRA:
|
||||||
case NOTION: return "📝";
|
return "🎯";
|
||||||
default: return "📋";
|
case TRELLO:
|
||||||
|
return "📌";
|
||||||
|
case ASANA:
|
||||||
|
return "✅";
|
||||||
|
case NOTION:
|
||||||
|
return "📝";
|
||||||
|
default:
|
||||||
|
return "📋";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,14 +332,22 @@ public class WechatWebhookService {
|
|||||||
*/
|
*/
|
||||||
private String getDayOfWeekInChinese(int dayOfWeek) {
|
private String getDayOfWeekInChinese(int dayOfWeek) {
|
||||||
switch (dayOfWeek) {
|
switch (dayOfWeek) {
|
||||||
case 1: return "星期一";
|
case 1:
|
||||||
case 2: return "星期二";
|
return "星期一";
|
||||||
case 3: return "星期三";
|
case 2:
|
||||||
case 4: return "星期四";
|
return "星期二";
|
||||||
case 5: return "星期五";
|
case 3:
|
||||||
case 6: return "星期六";
|
return "星期三";
|
||||||
case 7: return "星期日";
|
case 4:
|
||||||
default: return "未知";
|
return "星期四";
|
||||||
|
case 5:
|
||||||
|
return "星期五";
|
||||||
|
case 6:
|
||||||
|
return "星期六";
|
||||||
|
case 7:
|
||||||
|
return "星期日";
|
||||||
|
default:
|
||||||
|
return "未知";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@ public class ZentaoApiService {
|
|||||||
private static final Logger logger = LoggerFactory.getLogger(ZentaoApiService.class);
|
private static final Logger logger = LoggerFactory.getLogger(ZentaoApiService.class);
|
||||||
|
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
private final Map<String, String> sessionCache = new HashMap<>();
|
private final Map<String, String> sessionCache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,7 +212,8 @@ public class ZentaoApiService {
|
|||||||
if (rootNode.has("data")) {
|
if (rootNode.has("data")) {
|
||||||
JsonNode dataNode = rootNode.get("data");
|
JsonNode dataNode = rootNode.get("data");
|
||||||
return objectMapper.convertValue(
|
return objectMapper.convertValue(
|
||||||
dataNode, new TypeReference<List<ZentaoUser>>() {});
|
dataNode, new TypeReference<List<ZentaoUser>>() {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -277,6 +277,7 @@ public class ZentaoTaskReminderService {
|
|||||||
*/
|
*/
|
||||||
private static class ProjectItems {
|
private static class ProjectItems {
|
||||||
List<ZentaoTask> tasks = new ArrayList<>();
|
List<ZentaoTask> tasks = new ArrayList<>();
|
||||||
|
|
||||||
List<ZentaoBug> bugs = new ArrayList<>();
|
List<ZentaoBug> bugs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +459,6 @@ public class ZentaoTaskReminderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务详情(用于测试)
|
* 获取任务详情(用于测试)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -35,11 +35,7 @@ public class TextReminderHandler implements ReminderHandler {
|
|||||||
logger.info("处理文本提醒 - 群组: {}, 类型: {}", group.getName(), scheduleType.getDescription());
|
logger.info("处理文本提醒 - 群组: {}, 类型: {}", group.getName(), scheduleType.getDescription());
|
||||||
|
|
||||||
// 生成带格式的提醒消息
|
// 生成带格式的提醒消息
|
||||||
String message = wechatWebhookService.createTaskReminderMessage(
|
String message = wechatWebhookService.createTaskReminderMessage(group.getId(), schedule.getMessage(), scheduleType.getDescription());
|
||||||
group.getId(),
|
|
||||||
schedule.getMessage(),
|
|
||||||
scheduleType.getDescription()
|
|
||||||
);
|
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
boolean success = wechatWebhookService.sendMarkdownMessage(group.getId(), message);
|
boolean success = wechatWebhookService.sendMarkdownMessage(group.getId(), message);
|
||||||
|
|||||||
@ -31,7 +31,6 @@ public class HolidayUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化2025年节假日
|
* 初始化2025年节假日
|
||||||
* 根据国务院办公厅2024年11月12日发布的《关于2025年部分节假日安排的通知》
|
* 根据国务院办公厅2024年11月12日发布的《关于2025年部分节假日安排的通知》
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user