fix: 修复待审核任务卡片和详情显示问题

1. 为 Task 实体添加 typeDetails 字段(非持久化)
2. getAllPendingApprovalTasks 方法添加品牌、类目、平台名称填充
3. 从子任务聚合 typeDetails 到主任务
This commit is contained in:
Your Name 2026-01-07 11:29:56 +08:00
parent d5364ed814
commit e4451c7eb4
2 changed files with 60 additions and 0 deletions

View File

@ -376,6 +376,12 @@ public class Task implements Serializable {
@TableField(exist = false)
private java.util.List<String> allDeliveryPaths;
/**
* 任务类型明细 JSON(非数据库字段,从子任务聚合)
*/
@TableField(exist = false)
private String typeDetails;
// ==================== Getters and Setters (手动添加以解决Lombok编译问题) ====================
public Long getId() { return id; }
@ -593,5 +599,8 @@ public class Task implements Serializable {
public java.util.List<String> getAllDeliveryPaths() { return allDeliveryPaths; }
public void setAllDeliveryPaths(java.util.List<String> allDeliveryPaths) { this.allDeliveryPaths = allDeliveryPaths; }
public String getTypeDetails() { return typeDetails; }
public void setTypeDetails(String typeDetails) { this.typeDetails = typeDetails; }
}

View File

@ -621,6 +621,57 @@ public class TaskService {
task.setCurrentApproverName(approver.getRealName() != null ? approver.getRealName() : approver.getUsername());
}
}
// 填充品牌名称
if (task.getBrandId() != null) {
Brand brand = brandMapper.selectById(task.getBrandId());
if (brand != null) {
task.setBrandName(brand.getName());
}
}
// 填充类目名称
if (task.getCategoryId() != null) {
Category category = categoryMapper.selectById(task.getCategoryId());
if (category != null) {
task.setCategoryName(category.getName());
}
}
// 填充平台名称
if (task.getPlatformId() != null) {
Platform platform = platformMapper.selectById(task.getPlatformId());
if (platform != null) {
task.setPlatformName(platform.getName());
}
}
// 从子任务聚合任务类型明细
if (task.getIsPipeline() != null && task.getIsPipeline() == 1) {
java.util.List<TaskItem> items = taskItemMapper.selectByTaskId(task.getId());
if (items != null && !items.isEmpty()) {
// 聚合所有子任务的 typeDetails
java.util.List<java.util.Map<String, Object>> allDetails = new java.util.ArrayList<>();
for (TaskItem item : items) {
if (item.getTypeDetails() != null && !item.getTypeDetails().isEmpty()) {
try {
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
java.util.List<java.util.Map<String, Object>> itemDetails = objectMapper.readValue(
item.getTypeDetails(),
new com.fasterxml.jackson.core.type.TypeReference<java.util.List<java.util.Map<String, Object>>>() {}
);
allDetails.addAll(itemDetails);
} catch (Exception e) {
log.warn("解析子任务 {} 的 typeDetails 失败: {}", item.getId(), e.getMessage());
}
}
}
if (!allDetails.isEmpty()) {
try {
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
task.setTypeDetails(objectMapper.writeValueAsString(allDetails));
} catch (Exception e) {
log.warn("序列化任务 {} 的 typeDetails 失败: {}", task.getId(), e.getMessage());
}
}
}
}
}
return result;