格式化

This commit is contained in:
dengqichen 2025-05-30 13:06:45 +08:00
parent c5233719cb
commit 65e9dc7b16
17 changed files with 197 additions and 96 deletions

View File

@ -20,6 +20,7 @@ import java.util.Map;
public class TaskReminderConfig {
private Global global = new Global();
private List<Group> groups = new ArrayList<>();
public Global getGlobal() {
@ -49,7 +50,6 @@ public class TaskReminderConfig {
}
public static class Global {
private int timeout = 5000;
@ -64,12 +64,17 @@ public class TaskReminderConfig {
public static class Group {
private String id;
private String name;
private Webhook webhook = new Webhook();
private TaskSystemType taskSystem;
private Map<String, Schedule> schedules = new HashMap<>();
private Zentao zentao = new Zentao();
private Map<String, String> userMapping = new HashMap<>();
public String getId() {
@ -127,7 +132,6 @@ public class TaskReminderConfig {
}
public Zentao getZentao() {
return zentao;
}
@ -159,7 +163,9 @@ public class TaskReminderConfig {
public static class Schedule {
private String time;
private String message;
private boolean enabled = true; // 默认启用
public String getTime() {
@ -189,10 +195,15 @@ public class TaskReminderConfig {
public static class Zentao {
private String apiUrl;
private String token;
private String username;
private String password;
private Integer projectId;
private Integer kanbanId;
public String getApiUrl() {

View File

@ -24,6 +24,7 @@ public enum ScheduleType {
OVERDUE_REMINDER("overdue-reminder", "逾期任务提醒");
private final String code;
private final String description;
ScheduleType(String code, String description) {

View File

@ -39,6 +39,7 @@ public enum TaskSystemType {
NOTION("notion", "Notion");
private final String code;
private final String description;
TaskSystemType(String code, String description) {

View File

@ -16,8 +16,11 @@ import lombok.NoArgsConstructor;
public class ProjectInfo {
private Integer id;
private String name;
private String status;
private boolean exists;
/**
@ -32,11 +35,16 @@ public class ProjectInfo {
*/
public String getStatusDescription() {
switch (status) {
case "wait": return "未开始";
case "doing": return "进行中";
case "suspended": return "已挂起";
case "closed": return "已关闭";
default: return "未知状态";
case "wait":
return "未开始";
case "doing":
return "进行中";
case "suspended":
return "已挂起";
case "closed":
return "已关闭";
default:
return "未知状态";
}
}

View File

@ -13,37 +13,69 @@ import lombok.Data;
public class ZentaoTask {
private String id;
private String name;
private String type;
private String status;
private String pri;
private String assignedTo;
private String assignedToRealName;
private String assignedDate;
private String deadline;
private String estStarted;
private String realStarted;
private String finishedBy;
private String finishedDate;
private String canceledBy;
private String canceledDate;
private String closedBy;
private String closedDate;
private String closedReason;
private String lastEditedBy;
private String lastEditedDate;
private String openedBy;
private String openedDate;
private String desc;
private String project;
private String story;
private String storyTitle;
private String module;
private String estimate;
private String consumed;
private String left;
private String progress;
private String color;
private String deleted;
/**
@ -150,11 +182,16 @@ public class ZentaoTask {
*/
public String getPriorityDesc() {
switch (pri) {
case "1": return "";
case "2": return "";
case "3": return "";
case "4": return "最低";
default: return "普通";
case "1":
return "";
case "2":
return "";
case "3":
return "";
case "4":
return "最低";
default:
return "普通";
}
}
}

View File

@ -14,36 +14,68 @@ import lombok.Data;
public class ZentaoUser {
private String id;
private String account;
private String realname;
private String nickname;
private String avatar;
private String birthday;
private String gender;
private String email;
private String skype;
private String qq;
private String yahoo;
private String gtalk;
private String wangwang;
private String mobile;
private String phone;
private String address;
private String zipcode;
private String join;
private String visits;
private String ip;
private String last;
private String fails;
private String locked;
private String feedback;
private String mail;
private String clientStatus;
private String clientLang;
private String dept;
private String role;
private String type;
private String groups;
private String view;
private String deleted;
}

View File

@ -261,7 +261,6 @@ public class WechatWebhookService {
}
/**
* 获取任务管理系统的图标
*/
@ -271,13 +270,20 @@ public class WechatWebhookService {
}
switch (taskSystemType) {
case ZENTAO: return "📋";
case SMARTSHEET: return "📊";
case JIRA: return "🎯";
case TRELLO: return "📌";
case ASANA: return "";
case NOTION: return "📝";
default: return "📋";
case ZENTAO:
return "📋";
case SMARTSHEET:
return "📊";
case JIRA:
return "🎯";
case TRELLO:
return "📌";
case ASANA:
return "";
case NOTION:
return "📝";
default:
return "📋";
}
}
@ -326,14 +332,22 @@ public class WechatWebhookService {
*/
private String getDayOfWeekInChinese(int dayOfWeek) {
switch (dayOfWeek) {
case 1: return "星期一";
case 2: return "星期二";
case 3: return "星期三";
case 4: return "星期四";
case 5: return "星期五";
case 6: return "星期六";
case 7: return "星期日";
default: return "未知";
case 1:
return "星期一";
case 2:
return "星期二";
case 3:
return "星期三";
case 4:
return "星期四";
case 5:
return "星期五";
case 6:
return "星期六";
case 7:
return "星期日";
default:
return "未知";
}
}
}

View File

@ -39,6 +39,7 @@ public class ZentaoApiService {
private static final Logger logger = LoggerFactory.getLogger(ZentaoApiService.class);
private final ObjectMapper objectMapper = new ObjectMapper();
private final Map<String, String> sessionCache = new HashMap<>();
/**
@ -211,7 +212,8 @@ public class ZentaoApiService {
if (rootNode.has("data")) {
JsonNode dataNode = rootNode.get("data");
return objectMapper.convertValue(
dataNode, new TypeReference<List<ZentaoUser>>() {});
dataNode, new TypeReference<List<ZentaoUser>>() {
});
}
}
}

View File

@ -277,6 +277,7 @@ public class ZentaoTaskReminderService {
*/
private static class ProjectItems {
List<ZentaoTask> tasks = new ArrayList<>();
List<ZentaoBug> bugs = new ArrayList<>();
}
@ -458,7 +459,6 @@ public class ZentaoTaskReminderService {
}
/**
* 获取任务详情用于测试
*/

View File

@ -35,11 +35,7 @@ public class TextReminderHandler implements ReminderHandler {
logger.info("处理文本提醒 - 群组: {}, 类型: {}", group.getName(), scheduleType.getDescription());
// 生成带格式的提醒消息
String message = wechatWebhookService.createTaskReminderMessage(
group.getId(),
schedule.getMessage(),
scheduleType.getDescription()
);
String message = wechatWebhookService.createTaskReminderMessage(group.getId(), schedule.getMessage(), scheduleType.getDescription());
// 发送消息
boolean success = wechatWebhookService.sendMarkdownMessage(group.getId(), message);

View File

@ -31,7 +31,6 @@ public class HolidayUtil {
}
/**
* 初始化2025年节假日
* 根据国务院办公厅2024年11月12日发布的关于2025年部分节假日安排的通知