|
@@ -12,6 +12,7 @@ import com.persagy.apm.alarmservice.group.management.model.group.vo.GroupTreeDet
|
|
|
import com.persagy.apm.alarmservice.group.management.model.group.vo.GroupTreeInfoVO;
|
|
|
import com.persagy.apm.alarmservice.group.management.model.group.vo.GroupTreeVO;
|
|
|
import com.persagy.apm.alarmservice.group.management.service.GroupManagementService;
|
|
|
+import com.persagy.apm.common.context.poems.PoemsContext;
|
|
|
import com.persagy.apm.common.model.vo.SimpleObjVO;
|
|
|
import com.persagy.apm.common.response.PageList;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -71,6 +72,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
public PageList<GroupManagementVo> equipsQuery(GroupManagementDTO managementDTO) {
|
|
|
List<GroupManagementVo> groupManagementVoList = new ArrayList<>();
|
|
|
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
|
|
|
+ queryBuilder.must(QueryBuilders.matchQuery("group_code", PoemsContext.getContext().getGroupCode()));
|
|
|
queryBuilder.must(QueryBuilders.matchQuery("class_code", managementDTO.getClassCode()));
|
|
|
if (StringUtils.isNotBlank(managementDTO.getCondition())) {
|
|
|
queryBuilder.must(QueryBuilders.matchPhraseQuery("infos", managementDTO.getCondition()));
|
|
@@ -179,13 +181,22 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
|
|
@Override
|
|
|
public Map<String, GroupManagement> queryEquipsByIds(List<String> ids) {
|
|
|
- List<GroupManagement> equipsByIds = findEquipsByIds(ids);
|
|
|
- if (CollectionUtils.isEmpty(equipsByIds)) {
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
- return equipsByIds.stream().collect(Collectors.toMap(
|
|
|
- GroupManagement::getId, equip -> equip, (k1,k2) -> k1
|
|
|
- ));
|
|
|
+ Map<String, GroupManagement> resultMap = new HashMap<>(ids.size());
|
|
|
+ List<List<String>> partitions = Lists.partition(ids, 100);
|
|
|
+ for (List<String> partition : partitions) {
|
|
|
+ List<GroupManagement> equipsByIds = findEquipsByIds(ids);
|
|
|
+ if (CollectionUtils.isEmpty(equipsByIds)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, GroupManagement> partitionMap = equipsByIds.stream().collect(Collectors.toMap(
|
|
|
+ GroupManagement::getId, equip -> equip, (k1, k2) -> k1
|
|
|
+ ));
|
|
|
+ resultMap.putAll(partitionMap);
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -219,15 +230,27 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
|
|
@Override
|
|
|
public Map<String, SimpleObjVO> queryObjGroup(List<String> objIds) {
|
|
|
- List<GroupTreeInfoVO> groupTreeInfoVOS = equipsGroupQuery(objIds);
|
|
|
- if (CollectionUtils.isEmpty(groupTreeInfoVOS)) {
|
|
|
+ if (CollectionUtils.isEmpty(objIds)) {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
- return groupTreeInfoVOS.stream().collect(Collectors.toMap(
|
|
|
- GroupTreeInfoVO::getEquipId,
|
|
|
- groupTreeInfoVO -> new SimpleObjVO(groupTreeInfoVO.getId(), groupTreeInfoVO.getName()),
|
|
|
- (k1,k2) -> k1
|
|
|
- ));
|
|
|
+ Map<String, SimpleObjVO> resultMap = new HashMap<>(objIds.size());
|
|
|
+
|
|
|
+ // 每次查询100条
|
|
|
+ List<List<String>> partitions = Lists.partition(objIds, 100);
|
|
|
+ for (List<String> partition : partitions) {
|
|
|
+ List<GroupTreeInfoVO> groupTreeInfoList = equipsGroupQuery(partition);
|
|
|
+ if (CollectionUtils.isEmpty(groupTreeInfoList)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, SimpleObjVO> partitionMap = groupTreeInfoList.stream().collect(Collectors.toMap(
|
|
|
+ GroupTreeInfoVO::getEquipId,
|
|
|
+ groupTreeInfoVO -> new SimpleObjVO(groupTreeInfoVO.getId(), groupTreeInfoVO.getName()),
|
|
|
+ (k1, k2) -> k1
|
|
|
+ ));
|
|
|
+ resultMap.putAll(partitionMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -270,7 +293,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
*/
|
|
|
public static List<GroupTreeVO> getGroupTree() {
|
|
|
InputStream inputStream = GroupManagementServiceImpl.class.getClassLoader()
|
|
|
- .getResourceAsStream(File.separator + "json" + File.separator + "GroupTree.json");
|
|
|
+ .getResourceAsStream( "json" + File.separator + "GroupTree.json");
|
|
|
if (inputStream == null) {
|
|
|
return null;
|
|
|
}
|