Commit 704398d5 authored by 李腾威's avatar 李腾威

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

parent ee92d854
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -55,9 +29,34 @@ import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TestInfoServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 电梯Api
......@@ -392,10 +391,11 @@ public class ElevatorController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/init", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "电梯信息放入es", notes = "电梯信息放入es")
public void init() {
public void init(Integer num) {
IPage<Elevator> elevatorPage = new Page<>();
Integer count = elevatorService.count();
for(int i = 0; i <= 3 ; i ++ ) {
for(int i = 0; i <= (ValidationUtil.isEmpty(num) ? count : num); i ++ ) {
elevatorPage.setCurrent(i);
elevatorPage.setSize(500);
elevatorPage = elevatorService.page(elevatorPage);
......
......@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
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.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
......@@ -19,11 +18,8 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
*
......@@ -111,26 +107,26 @@ public class ESElevatorServiceImpl {
}
AlertCalled alertCalled = null;
List<AlertCalled> alertCalleds = null;
if(!ValidationUtil.isEmpty(alertId)) {
alertCalled = iAlertCalledService.getById(elevatorDto.getAlertId());
BoolQueryBuilder qb4 = QueryBuilders.boolQuery();
qb4.must(QueryBuilders.termQuery("sequenceNbr", alertCalled.getEquipmentId()));
boolMust.must(qb4);
} else {
if(elevatorDto.getIsToday() != null && elevatorDto.getIsToday()) {
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<>();
for (AlertCalled al: alertCalleds
) {
stringList.add(al.getEquipmentId());
}
List<Long> listL = stringList.stream().distinct().collect(Collectors.toList());
qb0.should(QueryBuilders.termsQuery("sequenceNbr", listL.toArray()));
boolMust.must(qb0);
}
// if(!ValidationUtil.isEmpty(alertId)) {
// alertCalled = iAlertCalledService.getById(elevatorDto.getAlertId());
// BoolQueryBuilder qb4 = QueryBuilders.boolQuery();
// qb4.must(QueryBuilders.termQuery("sequenceNbr", alertCalled.getEquipmentId()));
// boolMust.must(qb4);
// } else {
// if(elevatorDto.getIsToday() != null && elevatorDto.getIsToday()) {
// 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<>();
// for (AlertCalled al: alertCalleds
// ) {
// stringList.add(al.getEquipmentId());
// }
// List<Long> listL = stringList.stream().distinct().collect(Collectors.toList());
// qb0.should(QueryBuilders.termsQuery("sequenceNbr", listL.toArray()));
// boolMust.must(qb0);
// }
if(!ValidationUtil.isEmpty(address)) {
......@@ -165,20 +161,20 @@ public class ESElevatorServiceImpl {
{
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
EsElevatorDto esElevatorDto =JSONObject.toJavaObject(jsonObject, EsElevatorDto.class);
if(null != alertCalleds) {
for (AlertCalled al: alertCalleds
) {
if(al.getEquipmentId().equals(esElevatorDto.getSequenceNbr())) {
esElevatorDto.setHappenTime(al.getCallTime());
esElevatorDto.setAlertId(String.valueOf(al.getSequenceNbr()));
esElevatorDto.setAlarmTypeCode(al.getAlarmTypeCode());
esElevatorDto.setType(al.getAlertStage());
list.add(esElevatorDto);
break;
}
}
}
list.add(esElevatorDto);
// if(null != alertCalleds) {
// for (AlertCalled al: alertCalleds
// ) {
// if(al.getEquipmentId().equals(esElevatorDto.getSequenceNbr())) {
// esElevatorDto.setHappenTime(al.getCallTime());
// esElevatorDto.setAlertId(String.valueOf(al.getSequenceNbr()));
// esElevatorDto.setAlarmTypeCode(al.getAlarmTypeCode());
// esElevatorDto.setType(al.getAlertStage());
// list.add(esElevatorDto);
// break;
// }
// }
// }
}
}
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