Commit 0dd2d621 authored by 李腾威's avatar 李腾威

地图ES搜索电梯修改,ES初始化电梯信息修改

parent 1bcfacc5
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.tzs.biz.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.EsElevatorDto; import com.yeejoin.amos.boot.module.tzs.api.dto.EsElevatorDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled; import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator; import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
...@@ -18,8 +19,11 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde ...@@ -18,8 +19,11 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* *
...@@ -93,6 +97,7 @@ public class ESElevatorServiceImpl { ...@@ -93,6 +97,7 @@ public class ESElevatorServiceImpl {
String address = elevatorDto.getAddress(); String address = elevatorDto.getAddress();
String regionCode = elevatorDto.getRegionCode(); String regionCode = elevatorDto.getRegionCode();
String alertId = elevatorDto.getAlertId(); String alertId = elevatorDto.getAlertId();
Long equipmentId = elevatorDto.getSequenceNbr();
/** /**
* 通用匹配规则,条件构建 * 通用匹配规则,条件构建
...@@ -102,31 +107,33 @@ public class ESElevatorServiceImpl { ...@@ -102,31 +107,33 @@ public class ESElevatorServiceImpl {
BoolQueryBuilder qb0 = QueryBuilders.boolQuery(); BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
LambdaQueryWrapper<AlertCalled> queryWrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<AlertCalled> queryWrapper = new LambdaQueryWrapper();
if(!ValidationUtil.isEmpty(alarmTypeCode)) { if(!ValidationUtil.isEmpty(alarmTypeCode) && !"all".equals(alarmTypeCode)) {
queryWrapper.eq(AlertCalled::getAlarmTypeCode,alarmTypeCode); queryWrapper.eq(AlertCalled::getAlarmTypeCode,alarmTypeCode);
} }
AlertCalled alertCalled = null; AlertCalled alertCalled = null;
List<AlertCalled> alertCalleds = null; List<AlertCalled> alertCalleds = null;
// if(!ValidationUtil.isEmpty(alertId)) { if(!ValidationUtil.isEmpty(alertId)) {
// alertCalled = iAlertCalledService.getById(elevatorDto.getAlertId()); alertCalled = iAlertCalledService.getById(elevatorDto.getAlertId());
// BoolQueryBuilder qb4 = QueryBuilders.boolQuery(); BoolQueryBuilder qb4 = QueryBuilders.boolQuery();
// qb4.must(QueryBuilders.termQuery("sequenceNbr", alertCalled.getEquipmentId())); qb4.must(QueryBuilders.termQuery("sequenceNbr", alertCalled.getEquipmentId()));
// boolMust.must(qb4); boolMust.must(qb4);
// } else { } else {
// if(elevatorDto.getIsToday() != null && elevatorDto.getIsToday()) { if(!ValidationUtil.isEmpty(alarmTypeCode)) {
// queryWrapper.ge(AlertCalled::getCallTime, DateUtils.stampToDate(System.currentTimeMillis(),DateUtils.DATE_PATTERN)); if(elevatorDto.getIsToday() != null && elevatorDto.getIsToday()) {
// queryWrapper.le(AlertCalled::getCallTime, DateUtils.stampToDate(DateUtils.dateAddDays(new Date(),1).getTime(),DateUtils.DATE_PATTERN)); queryWrapper.ge(AlertCalled::getCallTime, DateUtils.stampToDate(System.currentTimeMillis(),DateUtils.DATE_PATTERN));
// } queryWrapper.le(AlertCalled::getCallTime, DateUtils.stampToDate(DateUtils.dateAddDays(new Date(),1).getTime(),DateUtils.DATE_PATTERN));
// alertCalleds = iAlertCalledService.list(queryWrapper); }
// List<Long> stringList = new ArrayList<>(); alertCalleds = iAlertCalledService.list(queryWrapper);
// for (AlertCalled al: alertCalleds List<Long> stringList = new ArrayList<>();
// ) { for (AlertCalled al: alertCalleds
// stringList.add(al.getEquipmentId()); ) {
// } stringList.add(al.getEquipmentId());
// List<Long> listL = stringList.stream().distinct().collect(Collectors.toList()); }
// qb0.should(QueryBuilders.termsQuery("sequenceNbr", listL.toArray())); List<Long> listL = stringList.stream().distinct().collect(Collectors.toList());
// boolMust.must(qb0); qb0.should(QueryBuilders.termsQuery("sequenceNbr", listL.toArray()));
// } boolMust.must(qb0);
}
}
if(!ValidationUtil.isEmpty(address)) { if(!ValidationUtil.isEmpty(address)) {
...@@ -143,6 +150,12 @@ public class ESElevatorServiceImpl { ...@@ -143,6 +150,12 @@ public class ESElevatorServiceImpl {
boolMust.must(qb2); boolMust.must(qb2);
} }
if(!ValidationUtil.isEmpty(equipmentId)) {
BoolQueryBuilder qb3= QueryBuilders.boolQuery().
filter(QueryBuilders. termQuery("sequenceNbr", equipmentId));
boolMust.must(qb3);
}
// 创建查询构造器 // 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder() NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 分页 // 分页
...@@ -161,20 +174,21 @@ public class ESElevatorServiceImpl { ...@@ -161,20 +174,21 @@ public class ESElevatorServiceImpl {
{ {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent()); JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
EsElevatorDto esElevatorDto =JSONObject.toJavaObject(jsonObject, EsElevatorDto.class); EsElevatorDto esElevatorDto =JSONObject.toJavaObject(jsonObject, EsElevatorDto.class);
list.add(esElevatorDto); if(null != alertCalleds) {
// if(null != alertCalleds) { for (AlertCalled al: alertCalleds
// for (AlertCalled al: alertCalleds ) {
// ) { if(al.getEquipmentId().equals(esElevatorDto.getSequenceNbr())) {
// if(al.getEquipmentId().equals(esElevatorDto.getSequenceNbr())) { esElevatorDto.setHappenTime(al.getCallTime());
// esElevatorDto.setHappenTime(al.getCallTime()); esElevatorDto.setAlertId(String.valueOf(al.getSequenceNbr()));
// esElevatorDto.setAlertId(String.valueOf(al.getSequenceNbr())); esElevatorDto.setAlarmTypeCode(al.getAlarmTypeCode());
// esElevatorDto.setAlarmTypeCode(al.getAlarmTypeCode()); esElevatorDto.setType(al.getAlertStage());
// esElevatorDto.setType(al.getAlertStage()); list.add(esElevatorDto);
// list.add(esElevatorDto); break;
// break; }
// } }
// } } else {
// } list.add(esElevatorDto);
}
} }
} }
catch (Exception e) catch (Exception e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment