diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/FormCoreServiceImpl.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/FormCoreServiceImpl.java index 7abfb0cc5..557885d13 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/FormCoreServiceImpl.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/FormCoreServiceImpl.java @@ -38,8 +38,10 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -79,11 +81,14 @@ public class FormCoreServiceImpl implements FormCoreService { @Override public List pageForm(BpmnFormRelationSearchDTO searchDTO) { List list = bpmnFormRelationService.keyQuery(searchDTO); + + Set uniqueKeys = new HashSet<>(); + List uniqueRecords = list.stream() + .filter(record -> uniqueKeys.add(record.getKey() + record.getTenantId())) + .collect(Collectors.toList()); List keys = list.stream().map(ExtAxBpmnFormRelation::getKey).distinct().collect(Collectors.toList()); Map categoryMap = categoryService.listByValue(BPM_MODEL_CATEGORY, keys).stream().collect(Collectors.toMap(CategoryItemVO::getValue, Function.identity(), (s, t) -> s)); - return list.stream() - .collect(Collectors.collectingAndThen(Collectors.toMap(ExtAxBpmnFormRelation::getKey, Function.identity(), (s, t) -> s), x -> new ArrayList<>(x.values()))) - .stream() + return uniqueRecords.stream() .map(e -> FormVO.builder() .key(e.getKey()) .name(categoryMap.getOrDefault(e.getKey(), new CategoryItemVO()).getLabel())