feat: 优化群通知模板,显示完整任务信息

- 添加任务数量、品牌、类目、平台、SPU、子类型
- 添加预估工时、截止时间
- 添加发起人、发起部门信息
- 子任务组通知也添加完整信息
- 使用emoji图标和分隔线美化排版
This commit is contained in:
Your Name 2026-01-03 18:49:37 +08:00
parent 17d3799870
commit 6dcc725b48
2 changed files with 102 additions and 27 deletions

View File

@ -277,24 +277,63 @@ public class TaskApprovalService {
try {
String title = "新任务发布";
StringBuilder content = new StringBuilder();
content.append("--------------------------------\n");
content.append("━━━━━━━━━━━━━━━━━━━━\n");
content.append(" 🎯 新 任 务 发 布 \n");
content.append("--------------------------------\n\n");
content.append("任务:").append(task.getTitle()).append("\n");
content.append("编号:").append(task.getTaskNo()).append("\n");
content.append("积分:").append(task.getScore()).append(" 分\n");
content.append("━━━━━━━━━━━━━━━━━━━━\n\n");
if (task.getBrandName() != null) {
content.append("品牌:").append(task.getBrandName()).append("\n");
}
if (task.getCategoryName() != null) {
content.append("类目:").append(task.getCategoryName()).append("\n");
// 基本信息
content.append("📋 **任务名称**:").append(task.getTitle()).append("\n");
content.append("🔢 **任务编号**:").append(task.getTaskNo()).append("\n");
content.append("⭐ **任务积分**:").append(task.getScore()).append(" 分\n");
// 数量信息
if (task.getQuantity() != null && task.getQuantity() > 0) {
content.append("📦 **任务数量**:").append(task.getQuantity()).append(" 个\n");
}
content.append("状态:待接单\n\n");
content.append("--------------------------------\n");
content.append("\n");
// 任务详情
if (task.getBrandName() != null && !task.getBrandName().isEmpty()) {
content.append("🏷️ **品牌**:").append(task.getBrandName()).append("\n");
}
if (task.getCategoryName() != null && !task.getCategoryName().isEmpty()) {
content.append("📁 **类目**:").append(task.getCategoryName()).append("\n");
}
if (task.getPlatformName() != null && !task.getPlatformName().isEmpty()) {
content.append("💻 **平台**:").append(task.getPlatformName()).append("\n");
}
if (task.getSpuInfo() != null && !task.getSpuInfo().isEmpty()) {
content.append("📦 **SPU**:").append(task.getSpuInfo()).append("\n");
}
if (task.getTaskSubType() != null && !task.getTaskSubType().isEmpty()) {
content.append("📝 **子类型**:").append(task.getTaskSubType()).append("\n");
}
content.append("\n");
// 时间信息
if (task.getEstimatedHours() != null) {
content.append("⏱️ **预估工时**:").append(task.getEstimatedHours().intValue()).append(" 小时\n");
}
if (task.getDeadline() != null) {
content.append("⏰ **截止时间**:").append(task.getDeadline().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))).append("\n");
}
content.append("\n");
// 发起人信息
if (task.getPublisherName() != null && !task.getPublisherName().isEmpty()) {
content.append("👤 **发起人**:").append(task.getPublisherName()).append("\n");
}
if (task.getPublisherDeptName() != null && !task.getPublisherDeptName().isEmpty()) {
content.append("🏢 **发起部门**:").append(task.getPublisherDeptName()).append("\n");
}
content.append("\n");
content.append("━━━━━━━━━━━━━━━━━━━━\n");
content.append(" 💡 请前往任务大厅抢单 \n");
content.append("--------------------------------");
content.append("━━━━━━━━━━━━━━━━━━━━");
log.info("准备调用钉钉机器人发送消息,title={}", title);
boolean success = dingTalkService.sendRobotMessage(title, content.toString());

View File

@ -514,25 +514,61 @@ public class TaskItemService {
// 发送钉钉群机器人通知
try {
String title = "🎯 新子任务组发布";
String title = "新子任务组发布";
StringBuilder content = new StringBuilder();
content.append("--------------------------------\n");
content.append(" 🎯 新 子 任 务 组 \n");
content.append("--------------------------------\n\n");
content.append("━━━━━━━━━━━━━━━━━━━━\n");
content.append(" 🎯 新 子 任 务 组 发 布 \n");
content.append("━━━━━━━━━━━━━━━━━━━━\n\n");
content.append("主任务:").append(mainTask.getTitle()).append("\n");
content.append("任务组:第 ").append(groupNo).append(" 组\n");
content.append("数量:").append(groupItems.size()).append(" 个\n");
// 主任务信息
content.append("📋 **主任务**:").append(mainTask.getTitle()).append("\n");
content.append("🔢 **任务编号**:").append(mainTask.getTaskNo()).append("\n");
content.append("📦 **任务组**:第 ").append(groupNo).append(" 组\n");
content.append("🔢 **子任务数量**:").append(groupItems.size()).append(" 个\n");
// 列出子任务类型
content.append("类型:\n");
for (TaskItem item : groupItems) {
content.append("- ").append(item.getItemNo())
.append(" (").append(item.getTotalScore()).append("分)\n");
// 计算总积分
int totalScore = groupItems.stream().mapToInt(item -> item.getTotalScore() != null ? item.getTotalScore() : 0).sum();
content.append("⭐ **总积分**:").append(totalScore).append(" 分\n");
content.append("\n");
// 任务详情
if (mainTask.getBrandName() != null && !mainTask.getBrandName().isEmpty()) {
content.append("🏷️ **品牌**:").append(mainTask.getBrandName()).append("\n");
}
if (mainTask.getCategoryName() != null && !mainTask.getCategoryName().isEmpty()) {
content.append("📁 **类目**:").append(mainTask.getCategoryName()).append("\n");
}
if (mainTask.getPlatformName() != null && !mainTask.getPlatformName().isEmpty()) {
content.append("💻 **平台**:").append(mainTask.getPlatformName()).append("\n");
}
if (mainTask.getSpuInfo() != null && !mainTask.getSpuInfo().isEmpty()) {
content.append("📦 **SPU**:").append(mainTask.getSpuInfo()).append("\n");
}
content.append("状态:待接单\n");
content.append("\n💡 赶快去任务大厅抢单吧!");
content.append("\n");
// 列出子任务详情
content.append("📝 **子任务列表**:\n");
for (TaskItem item : groupItems) {
content.append(" • ").append(item.getItemNo())
.append("(").append(item.getTotalScore() != null ? item.getTotalScore() : 0).append("分)\n");
}
content.append("\n");
// 发起人信息
if (mainTask.getPublisherName() != null && !mainTask.getPublisherName().isEmpty()) {
content.append("👤 **发起人**:").append(mainTask.getPublisherName()).append("\n");
}
if (mainTask.getPublisherDeptName() != null && !mainTask.getPublisherDeptName().isEmpty()) {
content.append("🏢 **发起部门**:").append(mainTask.getPublisherDeptName()).append("\n");
}
content.append("\n");
content.append("━━━━━━━━━━━━━━━━━━━━\n");
content.append(" 💡 请前往任务大厅抢单 \n");
content.append("━━━━━━━━━━━━━━━━━━━━");
dingTalkService.sendRobotMessage(title, content.toString());
log.info("第 {} 组 {} 个子任务已发布到任务大厅,已发送钉钉群通知", groupNo, groupItems.size());