diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/ordercomponent/OrderComponentServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/ordercomponent/OrderComponentServiceImpl.java index 01b67df36..ec8bfdce4 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/ordercomponent/OrderComponentServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/ordercomponent/OrderComponentServiceImpl.java @@ -24,8 +24,11 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId; @@ -66,11 +69,20 @@ public class OrderComponentServiceImpl implements OrderComponentService { } } - // 结果根据topid - resultDOList.sort(Comparator - .comparing(OrderComponentDO::getTopId)); + // 结果根据id去重和排序 + Map uniqueMap = resultDOList.stream() + .collect(Collectors.toMap( + OrderComponentDO::getId, + Function.identity(), + (a, b) -> a, + LinkedHashMap::new + )); - return BeanUtil.copyToList(resultDOList, OrderComponentRespVO.class); + List uniqueList = new ArrayList<>(uniqueMap.values()); + uniqueList.sort(Comparator + .comparing(OrderComponentDO::getId)); + + return BeanUtil.copyToList(uniqueList, OrderComponentRespVO.class); } @Override @@ -109,7 +121,7 @@ public class OrderComponentServiceImpl implements OrderComponentService { } if(CollUtil.isEmpty(componentIds)) { - // 2、把下级部门id做成集合 + // 2、把下级部件id作为查询条件 List orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX() .eq(OrderComponentDO::getTopId, componentDO.getTopId()) .eq(OrderComponentDO::getOrganId, componentDO.getOrganId()) @@ -122,7 +134,7 @@ public class OrderComponentServiceImpl implements OrderComponentService { return new PageResult<>(); } } else { - // 3、使用入参的部件id集合 + // 3、使用入参的部件id作为条件 componentIds = pageReqVO.getComponentIds(); } @@ -147,7 +159,7 @@ public class OrderComponentServiceImpl implements OrderComponentService { Long cadViewFileId = componentDO.getCadViewFileId(); if(CollUtil.isEmpty(componentIds)) { - // 2、把下级部门id做成集合 + // 2、把下级部件id作为查询条件 List orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX() .eq(OrderComponentDO::getTopId, componentDO.getTopId()) .eq(OrderComponentDO::getOrganId, componentDO.getOrganId()) @@ -160,7 +172,7 @@ public class OrderComponentServiceImpl implements OrderComponentService { return Collections.emptyList(); } } else { - // 3、使用入参的部件id集合 + // 3、使用入参的部件id作为条件 componentIds = pageReqVO.getComponentIds(); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/ordercomponent/OrderComponentMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/ordercomponent/OrderComponentMapper.xml index 06695de6b..1955b4d69 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/ordercomponent/OrderComponentMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/ordercomponent/OrderComponentMapper.xml @@ -22,7 +22,7 @@