Commit b55520ab authored by chenzhao's avatar chenzhao

修改代码

parent d769d545
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -14,22 +15,33 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; ...@@ -14,22 +15,33 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData; import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.metrics.ParsedSum; import org.elasticsearch.search.aggregations.metrics.ParsedSum;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -61,6 +73,8 @@ public class MonitorFanIdxController extends BaseController { ...@@ -61,6 +73,8 @@ public class MonitorFanIdxController extends BaseController {
@Autowired @Autowired
MonitorFanIndicatorImpl monitorFanIndicator; MonitorFanIndicatorImpl monitorFanIndicator;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired @Autowired
StationBasicMapper stationBasicMapper; StationBasicMapper stationBasicMapper;
...@@ -390,7 +404,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -390,7 +404,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "集电线路图左侧 集电线列表") @ApiOperation(value = "集电线路图左侧 集电线列表")
@GetMapping("/jdTree") @GetMapping("/jdTree")
@Scheduled(cron = "0/10 * * * * ? ") // @Scheduled(cron = "0/10 * * * * ? ")
public ResponseModel<IPage<Map<String, Object>>> getStatusJDX() { public ResponseModel<IPage<Map<String, Object>>> getStatusJDX() {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper); List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
...@@ -410,7 +424,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -410,7 +424,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "集电线路图右侧 风机列表") @ApiOperation(value = "集电线路图右侧 风机列表")
@GetMapping("/fjList") @GetMapping("/fjList")
@Scheduled(cron = "0/10 * * * * ? ") // @Scheduled(cron = "0/10 * * * * ? ")
public ResponseModel getListByFJ() { public ResponseModel getListByFJ() {
...@@ -743,7 +757,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -743,7 +757,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "箱变实时开关状态") @ApiOperation(value = "箱变实时开关状态")
@GetMapping("/equipSwitchStatus") @GetMapping("/equipSwitchStatus")
@Scheduled(cron = "0/10 * * * * ? ") // @Scheduled(cron = "0/10 * * * * ? ")
public ResponseModel<Map<String,Object>> getEquipSwitchStatus() { public ResponseModel<Map<String,Object>> getEquipSwitchStatus() {
...@@ -805,7 +819,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -805,7 +819,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "集电线路图右侧 光伏列表") @ApiOperation(value = "集电线路图右侧 光伏列表")
@GetMapping("/gfList") @GetMapping("/gfList")
@Scheduled(cron = "0/10 * * * * ? ") // @Scheduled(cron = "0/10 * * * * ? ")
public ResponseModel getListByNbq() { public ResponseModel getListByNbq() {
...@@ -830,7 +844,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -830,7 +844,7 @@ public class MonitorFanIdxController extends BaseController {
} }
@ApiOperation(value = "电站排名") @ApiOperation(value = "电站排名")
@Scheduled(cron = "0/10 * * * * ? ") // @Scheduled(cron = "0/10 * * * * ? ")
@GetMapping("/stationRanking") @GetMapping("/stationRanking")
public ResponseModel stationRanking() { public ResponseModel stationRanking() {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
...@@ -948,6 +962,82 @@ public class MonitorFanIdxController extends BaseController { ...@@ -948,6 +962,82 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(commonService.getSocialContributionDtoList(num)); return ResponseHelper.buildResponse(commonService.getSocialContributionDtoList(num));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "设备发电量 ")
@GetMapping("/equipGeneratingCapacity")
public ResponseModel<ResultsData> equipGeneratingCapacity(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "stationId") String stationId) {
Page<ESEquipments> result = new Page<ESEquipments>(current, size);
BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
//警情状态
BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
String[] keys = new String[] {"日发电量","月发电量","年发电量"};
List<String> list = Arrays.asList(keys);
qb0.must((QueryBuilders.termsQuery("equipmentIndexName.keyword", list)));
boolMustAll.must(qb0);
BoolQueryBuilder qb1 = QueryBuilders.boolQuery();
qb1.must(QueryBuilders.matchQuery("gatewayId.keyword","1668801435891929089"));
boolMustAll.must(qb1);
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 分页
.withPageable(PageRequest.of(current, size))
//过滤条件
.withQuery(boolMustAll);
List<ESEquipments> equipments = new LinkedList<>();
long totle = 0;
try
{
SearchHits<ESEquipments> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESEquipments.class);
for (SearchHit searchHit : searchHits.getSearchHits())
{
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
ESEquipments eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESEquipments.class);
equipments.add(eSAlertCalled);
}
totle =searchHits.getTotalHits();
}
catch (Exception e)
{
// TODO: handle exception
}
List<Map<String,Object>> esEquipmentsMap = new ArrayList<>();
Map<String, List<ESEquipments>> resultMap = equipments.stream().collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
for (String key : resultMap.keySet()) {
Map<String,Object> map = new HashMap<>();
map.put("name",key);
for (ESEquipments equip : resultMap.get(key)) {
switch(equip.getEquipmentIndexName()){
case "日发电量":
map.put("dayNum",equip.getValueDouble());
break;
case "月发电量":
map.put("monthNum",equip.getValueDouble());
break;
case "年发电量":
map.put("yearNum",equip.getValueDouble());
break;
}
}
esEquipmentsMap.add(map);
}
//构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, esEquipmentsMap.size(), false, current, esEquipmentsMap);
ColModel colModelEquipmentNumber = new ColModel("name", "name", "设备名称", "设备名称", "dataGrid", "name");
ColModel colModelPower = new ColModel("dayNum", "dayNum", "日发电量", "日发电量", "dataGrid", "dayNum");
ColModel colModelWindSpeed = new ColModel("monthNum", "monthNum", "月发电量", "月发电量", "dataGrid", "monthNum");
ColModel colModelWind = new ColModel("yearNum", "yearNum", "年发电量", "年发电量", "dataGrid", "yearNum");
List<ColModel> listColModel = Arrays.asList(colModelEquipmentNumber, colModelPower, colModelWindSpeed, colModelWind);
ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return ResponseHelper.buildResponse(resultsData);
}
} }
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit; import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit;
...@@ -195,5 +196,18 @@ public class CommonServiceImpl { ...@@ -195,5 +196,18 @@ public class CommonServiceImpl {
} }
return listdata; return listdata;
} }
public Integer getCount(List<QueryDto> queryDto, String keysum, Class clas){
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
for (QueryDto dto : queryDto) {
queryBuilder.must( QueryBuilders.matchPhraseQuery(dto.getKey(), dto.getValue()));
}
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.withPageable(PageRequest.of(0, 10000))
.build();
query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query,clas);
return search.getSearchHits().size();
}
} }
...@@ -616,7 +616,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -616,7 +616,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Scheduled(cron = "0 */5 * * * ?") // @Scheduled(cron = "0 */5 * * * ?")
private void schedTaskData(){ private void schedTaskData(){
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
...@@ -632,7 +632,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -632,7 +632,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
} }
@Scheduled(cron = "0 59 23 * * ?") // @Scheduled(cron = "0 59 23 * * ?")
private void deleteSchedData(){ private void deleteSchedData(){
QueryWrapper<TemporaryData> wrapper = new QueryWrapper<>(); QueryWrapper<TemporaryData> wrapper = new QueryWrapper<>();
temporaryDataMapper.delete(wrapper); temporaryDataMapper.delete(wrapper);
...@@ -643,7 +643,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -643,7 +643,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
@Scheduled(cron = "0 */5 * * * ?") // @Scheduled(cron = "0 */5 * * * ?")
private void schedAlarmEventData(){ private void schedAlarmEventData(){
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BaseEntity::getIsDelete,false); wrapper.eq(BaseEntity::getIsDelete,false);
......
## DB properties: ## DB properties:
## db1-production database ## db1-production database
spring.db1.datasource.type: com.alibaba.druid.pool.DruidDataSource spring.db1.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db1.datasource.url=jdbc:mysql://139.9.173.44:3306/production?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8 spring.db1.datasource.url=jdbc:mysql://39.98.224.23:3306/production?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db1.datasource.username=root spring.db1.datasource.username=root
spring.db1.datasource.password=Yeejoin@2020 spring.db1.datasource.password=Yeejoin@2020
spring.db1.datasource.driver-class-name: com.mysql.cj.jdbc.Driver spring.db1.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db2-sync_data ## db2-sync_data
spring.db2.datasource.type: com.alibaba.druid.pool.DruidDataSource spring.db2.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db2.datasource.url=jdbc:mysql://139.9.173.44:3306/jxiop_sync_data?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8 spring.db2.datasource.url=jdbc:mysql://39.98.224.23:3306/jxiop_sync_data?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.username=root spring.db2.datasource.username=root
spring.db2.datasource.password=Yeejoin@2020 spring.db2.datasource.password=Yeejoin@2020
spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## eureka properties: ## eureka properties:
eureka.instance.hostname=172.16.10.220 eureka.instance.hostname=172.16.10.253
eureka.client.serviceUrl.defaultZone=http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/ eureka.client.serviceUrl.defaultZone=http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
## redis properties: ## redis properties:
spring.redis.database=1 spring.redis.database=1
spring.redis.host=172.16.10.220 spring.redis.host=172.16.10.253
spring.redis.port=6379 spring.redis.port=6379
spring.redis.password=yeejoin@2020 spring.redis.password=yeejoin@2020
...@@ -53,10 +53,10 @@ lettuce.timeout=10000 ...@@ -53,10 +53,10 @@ lettuce.timeout=10000
emqx.clean-session=true emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]} emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.220:1883 emqx.broker=tcp://172.16.10.253:1883
emqx.user-name=admin emqx.user-name=admin
emqx.password=public emqx.password=public
mqtt.scene.host=mqtt://172.16.10.220:8083/mqtt mqtt.scene.host=mqtt://172.16.10.253:8083/mqtt
mqtt.client.product.id=mqtt mqtt.client.product.id=mqtt
mqtt.topic=topic_mqtt mqtt.topic=topic_mqtt
spring.mqtt.completionTimeout=3000 spring.mqtt.completionTimeout=3000
...@@ -84,9 +84,9 @@ emqx.max-inflight=1000 ...@@ -84,9 +84,9 @@ emqx.max-inflight=1000
#spring.influx.bufferLimit=20000 #spring.influx.bufferLimit=20000
spring.influx.url=http://139.9.173.44:18086 spring.influx.url=http://172.16.10.220:8086
spring.influx.password=Yeejoin@2020 spring.influx.password=Yeejoin@2020
spring.influx.user=root spring.influx.user=Yeejoin@2020
spring.influx.database=iot_platform spring.influx.database=iot_platform
spring.influx.retention_policy=default spring.influx.retention_policy=default
spring.influx.retention_policy_time=30d spring.influx.retention_policy_time=30d
...@@ -114,7 +114,7 @@ amos.secret.key=qaz ...@@ -114,7 +114,7 @@ amos.secret.key=qaz
#eureka.instance.ip-address=172.16.3.122 #eureka.instance.ip-address=172.16.3.122
spring.activemq.broker-url=tcp://139.9.173.44:61616 spring.activemq.broker-url=tcp://172.16.10.253:61616
spring.activemq.user=admin spring.activemq.user=admin
spring.activemq.password=admin spring.activemq.password=admin
spring.jms.pub-sub-domain=false spring.jms.pub-sub-domain=false
......
...@@ -73,4 +73,10 @@ station.isok=false ...@@ -73,4 +73,10 @@ station.isok=false
station.section=10 station.section=10
gl.sum.column=日发电量,月发电量,年发电量 gl.sum.column=日发电量,月发电量,年发电量
gl.avg.column=有功功率,日利用小时,瞬时风速 gl.avg.column=有功功率,日利用小时,瞬时风速
\ No newline at end of file
spring.elasticsearch.rest.uris=http://39.98.224.23:9200
spring.elasticsearch.rest.connection-timeout=30000
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=123456
spring.elasticsearch.rest.read-timeout=30000
...@@ -12,7 +12,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType; ...@@ -12,7 +12,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
@Document(indexName = "wind_speed") @Document(indexName = "wind_speed")
public class ESWindSpeed { public class ESWindSpeed {
@Id @Id
private Long sequenceNumber; private Long id;
@Field(type = FieldType.Text, index = false) @Field(type = FieldType.Text, index = false)
private String createdTime; private String createdTime;
@Field(type = FieldType.Text, index = false) @Field(type = FieldType.Text, index = false)
......
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