|
@@ -832,50 +832,54 @@ public class ApiController {
|
|
|
// 子级parentId
|
|
|
List<String> id = baseIds.stream().filter(item -> !item.startsWith("p")).collect(Collectors.toList());
|
|
|
|
|
|
- // 记录表中父id的所有子集
|
|
|
- List<WmTaskType> baseTypeList1 = wmTaskTypeService.list(Wrappers.<WmTaskType>query().lambda()
|
|
|
- .eq(WmTaskType::getTaskTypeLevel, "1")
|
|
|
- .in(WmTaskType::getParentId, parentId));
|
|
|
-
|
|
|
- // 按照父id分组
|
|
|
- Map<String, Map<String, List<WmTaskType>>> pTaskTypeMap = baseTypeList1.stream()
|
|
|
- .collect(Collectors.groupingBy(WmTaskType::getParentId, Collectors.groupingBy(WmTaskType::getBaseId)));
|
|
|
-
|
|
|
- // 查询所有子id对应的taskType列表
|
|
|
- List<WmTaskType> baseTypeList2 = wmTaskTypeService.
|
|
|
- list(Wrappers.<WmTaskType>query().lambda().eq(WmTaskType::getTaskTypeLevel, "1").in(WmTaskType::getId, id));
|
|
|
-
|
|
|
- // 所有子id对应的taskType列表 按照父id分组
|
|
|
- Map<String, Map<String, List<WmTaskType>>> cTaskTypeMap = baseTypeList2.stream()
|
|
|
- .collect(Collectors.groupingBy(WmTaskType::getParentId, Collectors.groupingBy(WmTaskType::getBaseId)));
|
|
|
- // 对应的parentId
|
|
|
- Set<String> cPidSet = cTaskTypeMap.keySet();
|
|
|
-
|
|
|
+ // 判断任务类型parentId是否包含'p-x',不包含则直接跳过以下逻辑(解决积分包id9501 没有父类任务报错)
|
|
|
List<WmTaskType> temp = new ArrayList<>();
|
|
|
-
|
|
|
- // 解决页面父级id和数据库存的父级id不一致的问题(如一对一专访在页面父级是p-16,但taskType表中父级id为p-1)
|
|
|
- // 比较baseTypeList1和baseTypeList2中parentId相同的taskTypeId的数据,如果baseId相同,则取baseTypeList2中的taskTypeId
|
|
|
- for (Map.Entry<String, Map<String, List<WmTaskType>>> entry : pTaskTypeMap.entrySet()) {
|
|
|
- // 获取父级id
|
|
|
- String pid = entry.getKey();
|
|
|
- // 判断大类中是否有相同的父类id
|
|
|
- if (cPidSet.contains(pid)) {
|
|
|
- // baseId
|
|
|
- Map<String, List<WmTaskType>> value = entry.getValue();
|
|
|
- Set<String> pBaseIds = value.keySet();
|
|
|
- // small
|
|
|
- Map<String, List<WmTaskType>> cVal = cTaskTypeMap.get(pid);
|
|
|
- Set<String> cBaseIds = cVal.keySet();
|
|
|
- // 求个交集,找出公共的
|
|
|
- Set<String> res = new HashSet<>(pBaseIds);
|
|
|
- res.retainAll(cBaseIds);
|
|
|
- // 找出的存入temp
|
|
|
- for (String bId : res) {
|
|
|
- temp.addAll(cVal.get(bId));
|
|
|
+ if (CollUtil.isNotEmpty(parentId)) {
|
|
|
+ // 记录表中父id的所有子集
|
|
|
+ List<WmTaskType> baseTypeList1 = wmTaskTypeService.list(Wrappers.<WmTaskType>query().lambda()
|
|
|
+ .eq(WmTaskType::getTaskTypeLevel, "1")
|
|
|
+ .in(WmTaskType::getParentId, parentId));
|
|
|
+
|
|
|
+ // 按照父id分组
|
|
|
+ Map<String, Map<String, List<WmTaskType>>> pTaskTypeMap = baseTypeList1.stream()
|
|
|
+ .collect(Collectors.groupingBy(WmTaskType::getParentId, Collectors.groupingBy(WmTaskType::getBaseId)));
|
|
|
+
|
|
|
+ // 查询所有子id对应的taskType列表
|
|
|
+ List<WmTaskType> baseTypeList2 = wmTaskTypeService.
|
|
|
+ list(Wrappers.<WmTaskType>query().lambda().eq(WmTaskType::getTaskTypeLevel, "1").in(WmTaskType::getId, id));
|
|
|
+
|
|
|
+ // 所有子id对应的taskType列表 按照父id分组
|
|
|
+ Map<String, Map<String, List<WmTaskType>>> cTaskTypeMap = baseTypeList2.stream()
|
|
|
+ .collect(Collectors.groupingBy(WmTaskType::getParentId, Collectors.groupingBy(WmTaskType::getBaseId)));
|
|
|
+ // 对应的parentId
|
|
|
+ Set<String> cPidSet = cTaskTypeMap.keySet();
|
|
|
+
|
|
|
+ // 解决页面父级id和数据库存的父级id不一致的问题(如一对一专访在页面父级是p-16,但taskType表中父级id为p-1)
|
|
|
+ // 比较baseTypeList1和baseTypeList2中parentId相同的taskTypeId的数据,如果baseId相同,则取baseTypeList2中的taskTypeId
|
|
|
+ for (Map.Entry<String, Map<String, List<WmTaskType>>> entry : pTaskTypeMap.entrySet()) {
|
|
|
+ // 获取父级id
|
|
|
+ String pid = entry.getKey();
|
|
|
+ // 判断大类中是否有相同的父类id
|
|
|
+ if (cPidSet.contains(pid)) {
|
|
|
+ // baseId
|
|
|
+ Map<String, List<WmTaskType>> value = entry.getValue();
|
|
|
+ Set<String> pBaseIds = value.keySet();
|
|
|
+ // small
|
|
|
+ Map<String, List<WmTaskType>> cVal = cTaskTypeMap.get(pid);
|
|
|
+ Set<String> cBaseIds = cVal.keySet();
|
|
|
+ // 求个交集,找出公共的
|
|
|
+ Set<String> res = new HashSet<>(pBaseIds);
|
|
|
+ res.retainAll(cBaseIds);
|
|
|
+ // 找出的存入temp
|
|
|
+ for (String bId : res) {
|
|
|
+ temp.addAll(cVal.get(bId));
|
|
|
+ }
|
|
|
+ // 取父级中对应baseId是独有的部分
|
|
|
+ pBaseIds.stream().filter(i -> !res.contains(i)).forEach(i -> temp.addAll(value.get(i)));
|
|
|
}
|
|
|
- // 取父级中对应baseId是独有的部分
|
|
|
- pBaseIds.stream().filter(i -> !res.contains(i)).forEach(i -> temp.addAll(value.get(i)));
|
|
|
}
|
|
|
+ } else {
|
|
|
+ temp.addAll(wmTaskTypeService.listByIds(baseIds));
|
|
|
}
|
|
|
|
|
|
List<String> baseNames = temp.stream().
|