|
@@ -9,11 +9,13 @@ import com.persagy.apm.alarmservice.group.management.model.vo.GroupTreeInfoVO;
|
|
|
import com.persagy.apm.alarmservice.group.management.model.vo.GroupTreeVO;
|
|
|
import com.persagy.apm.alarmservice.group.management.service.GroupManagementService;
|
|
|
import com.persagy.apm.alarmservice.group.management.service.GroupManagementService;
|
|
|
+import com.persagy.apm.common.response.PageList;
|
|
|
import com.persagy.apm.model.dto.GroupManagementDTO;
|
|
|
import com.persagy.apm.model.vo.GroupManagementVo;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.elasticsearch.action.get.GetRequest;
|
|
|
import org.elasticsearch.action.get.GetResponse;
|
|
|
import org.elasticsearch.action.search.SearchRequest;
|
|
@@ -41,9 +43,10 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static cn.hutool.core.util.StrUtil.COMMA;
|
|
|
+import static cn.hutool.core.util.StrUtil.*;
|
|
|
import static com.persagy.apm.constants.ElasticStrConstant.INDEX_NAME;
|
|
|
import static org.apache.commons.lang3.math.NumberUtils.INTEGER_ONE;
|
|
|
+import static org.apache.commons.lang3.math.NumberUtils.INTEGER_ZERO;
|
|
|
|
|
|
/**
|
|
|
* @author 易涛
|
|
@@ -57,19 +60,20 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
private RestHighLevelClient client;
|
|
|
|
|
|
@Override
|
|
|
- public List<GroupManagementVo> equipsQuery(GroupManagementDTO managementDTO) {
|
|
|
+ public PageList<GroupManagementVo> equipsQuery(GroupManagementDTO managementDTO) {
|
|
|
List<GroupManagementVo> groupManagementVoList = new ArrayList<>();
|
|
|
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
|
|
|
queryBuilder.must(QueryBuilders.matchQuery("class_code",managementDTO.getClassCode()));
|
|
|
queryBuilder.must(QueryBuilders.matchPhraseQuery("infos",managementDTO.getCondition()));
|
|
|
//模糊查询使用
|
|
|
if(StringUtils.isNotEmpty(managementDTO.getLocalName())) {
|
|
|
- queryBuilder.must(QueryBuilders.fuzzyQuery("local_name", managementDTO.getLocalName()));
|
|
|
+ queryBuilder.must(QueryBuilders.matchPhraseQuery("local_name", managementDTO.getLocalName()));
|
|
|
}
|
|
|
- queryBuilder.must(QueryBuilders.termQuery("valid",1));
|
|
|
+ queryBuilder.must(QueryBuilders.termQuery("valid",INTEGER_ONE));
|
|
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
|
|
sourceBuilder.query(queryBuilder);
|
|
|
- sourceBuilder.from(Math.max(managementDTO.getCurrent(), INTEGER_ONE));
|
|
|
+ sourceBuilder.from((Math.max(managementDTO.getCurrent(), INTEGER_ONE)-INTEGER_ONE)
|
|
|
+ *managementDTO.getSize());
|
|
|
sourceBuilder.size(managementDTO.getSize());
|
|
|
sourceBuilder.sort("create_time", SortOrder.DESC);
|
|
|
SearchRequest rq = new SearchRequest(INDEX_NAME);
|
|
@@ -85,10 +89,10 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
groupManagementVoList.add(managementVo);
|
|
|
}
|
|
|
}
|
|
|
+ return new PageList<>(groupManagementVoList,searchResponse.getHits().getTotalHits().value);
|
|
|
}catch (IOException e){
|
|
|
throw new RuntimeException("es查询出错",e);
|
|
|
}
|
|
|
- return groupManagementVoList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -126,10 +130,10 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
}
|
|
|
List<GroupManagement> managementList = new ArrayList<>();
|
|
|
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
|
|
|
- queryBuilder.must(QueryBuilders.termsQuery("id",ids));
|
|
|
+ queryBuilder.must(QueryBuilders.termsQuery("id.keyword",ids));
|
|
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
|
|
sourceBuilder.query(queryBuilder);
|
|
|
- sourceBuilder.from(INTEGER_ONE);
|
|
|
+ sourceBuilder.from(INTEGER_ZERO);
|
|
|
sourceBuilder.size(ids.size());
|
|
|
sourceBuilder.sort("create_time",SortOrder.DESC);
|
|
|
SearchRequest rq = new SearchRequest(INDEX_NAME);
|
|
@@ -155,7 +159,10 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
List<GroupTreeInfoVO> groupTreeInfoVOList = Lists.newArrayList();
|
|
|
List<GroupManagement> groupManagementList = findEquipsByIds(ids);
|
|
|
for(GroupManagement management:groupManagementList) {
|
|
|
- String infos = management.getInfos();
|
|
|
+ String infos = management.getInfos().replace(DELIM_START,"")
|
|
|
+ .replace(DELIM_END,"").replace("\"","")
|
|
|
+ .replace(BACKSLASH,"").replace(" ","")
|
|
|
+ .trim();
|
|
|
if (StringUtils.isEmpty(infos)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -184,7 +191,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
if(StringUtils.isNotEmpty(infoVO.getId())){
|
|
|
return infoVO;
|
|
|
}
|
|
|
- if(infoMap.containsKey(groupTreeVO.getCondition())){
|
|
|
+ if(infoMap.containsKey(groupTreeVO.getCondition().replace(" ",""))){
|
|
|
BeanUtils.copyProperties(groupTreeVO,infoVO);
|
|
|
infoVO.setEquipId(equipId);
|
|
|
return infoVO;
|