Commit 410a604e authored by chenzhao's avatar chenzhao

增加大屏接口

parent 7ba4a966
package com.yeejoin.amos.boot.module.jxiop.api.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum StationType {
FJC("风电场","FJC"),
JZGFC("集中光伏场","JZGFC"),
FBSGFC("分布式光伏场","FBSGFC");
private String name;
private String code;
public static String getCode(String name) {
for (StationType stationType : StationType.values())
{
if (stationType.getName().equals(name))
{
return stationType.getCode();
}
}
return null;
}
}
......@@ -7,21 +7,29 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.api.Enum.GeneratingCapacity;
import com.yeejoin.amos.boot.module.jxiop.api.Enum.StationType;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
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.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
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.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.MonitorFanIndicatorImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.metrics.ParsedSum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -31,6 +39,8 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -61,6 +71,8 @@ public class MonitorFanIdxController extends BaseController {
@Autowired
EmqKeeper emqKeeper;
private final String NFDL= "年发电量";
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据设备编号、场站id、前段展示模块、系统类型查询表数据")
@GetMapping("/getFanIdxInfoByPage")
......@@ -210,30 +222,70 @@ public class MonitorFanIdxController extends BaseController {
List<Map<String,Object>> objects = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("title",columnMap.get("装机容量").toString());
data.put("title2",columnMap.get("装机容量").toString());
data.put("title1","装机容量(MW)");
data.put("url","upload/jxiop/amos_studio/2F378EF430F788CA71E876359B46C4E.png");
objects.add(data);
Map<String, Object> data1 = new HashMap<>();
data1.put("title",columnMap.get("日发电量").toString());
data1.put("title2",columnMap.get("日发电量").toString());
data1.put("title1","日发电量(万kWh)");
data1.put("url","upload/jxiop/amos_studio/E07C6C41715033585F69934AF08A3431.png");
objects.add(data1);
Map<String, Object> data2 = new HashMap<>();
data2.put("title",columnMap.get("风机台数").toString().replace(".0",""));
data2.put("title2",columnMap.get("风机台数").toString().replace(".0",""));
data2.put("title1","风机台数(台)");
data2.put("url","upload/jxiop/amos_studio/EA3572E1BD31DC1E7D8DA162F09ECB.png");
objects.add(data2);
Map<String, Object> data3 = new HashMap<>();
data3.put("title",columnMap.get("月发电量").toString());
data3.put("title2",columnMap.get("月发电量").toString());
data3.put("title1","月发电量(万kWh)");
data3.put("url","upload/jxiop/amos_studio/6CE2792ABEEAE816CB798649A6796.png");
objects.add(data3);
Map<String, Object> data4 = new HashMap<>();
data4.put("title",columnMap.get("瞬时风速").toString());
data4.put("title2",columnMap.get("瞬时风速").toString());
data4.put("title1","平均风速(m/s)");
data4.put("url","upload/jxiop/amos_studio/3B66742AAB2FEB0F5CEC10DA50156F.png");
objects.add(data4);
Map<String, Object> data5 = new HashMap<>();
data5.put("title",columnMap.get("年发电量").toString());
data5.put("title2",columnMap.get("年发电量").toString());
data5.put("title1","年发电量(万kWh)");
data5.put("url","upload/jxiop/amos_studio/12D321E29727689B334E3E625383EB7C.png");
objects.add(data5);
Map<String, Object> data6 = new HashMap<>();
data6.put("title", String.format("%.2f",Double.parseDouble(columnMap.get("有功功率").toString())/1000)) ;
data6.put("title2", String.format("%.2f",Double.parseDouble(columnMap.get("有功功率").toString())/1000)) ;
data6.put("title1","有功功率(MW)");
data6.put("url","upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png");
objects.add(data6);
Map<String, Object> data7 = new HashMap<>();
data7.put("title",String.format("%.2f",Double.parseDouble(columnMap.get("日发电量").toString())/ (Double.parseDouble(columnMap.get("装机容量").toString())*1000)));
data7.put("title2",String.format("%.2f",Double.parseDouble(columnMap.get("日发电量").toString())/ (Double.parseDouble(columnMap.get("装机容量").toString())*1000)));
data7.put("title1","日利用小时");
data7.put("url","upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png");
objects.add(data7);
Map<String, Object> data8 = new HashMap<>();
data8.put("title",0.23);
data8.put("title2",0.23);
data8.put("title1","上网电量(万kWh)");
data8.put("url","upload/jxiop/amos_studio/1660C5DDA22ACFADC89A60DEDB82FA39.png");
objects.add(data8);
IPage<Map<String,Object>> result = new Page<>();
result.setRecords(objects);
result.setCurrent(1);
......@@ -247,11 +299,14 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览-全站功率曲线")
@GetMapping("/overviewWindSpeed")
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = true)String stationId,@RequestParam(value = "type", required = false)String type) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
if (null == type){
gatewayId = stationBasic.getFanGatewayId();
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = false)String stationId,@RequestParam(value = "type", required = false)String type) {
String gatewayId = "";
if (null != stationId){
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
gatewayId = stationBasic.getBoosterGatewayId();
if (null == type){
gatewayId = stationBasic.getFanGatewayId();
}
}
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeedAll(gatewayId);
......@@ -795,6 +850,7 @@ public class MonitorFanIdxController extends BaseController {
List< Map<String,Object>> monthDataGF = new ArrayList<>();
List< Map<String,Object>> yearDataGF = new ArrayList<>();
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getFanGatewayId();
String querySql = null;
String name = stationBasic.getStationName();
......@@ -805,9 +861,12 @@ public class MonitorFanIdxController extends BaseController {
Map<String, Object> yearMap = new HashMap<>();
dayMap.put("name",name);
dayMap.put("value",map.get("日发电量") == null?0:String.format("%.4f",map.get("日发电量")));
dayMap.put("gateWayId",stationBasic.getFanGatewayId());
monthMap.put("name",name);
monthMap.put("value",map.get("月发电量") == null?0:String.format("%.4f",map.get("月发电量")));
monthMap.put("gateWayId",stationBasic.getFanGatewayId());
yearMap.put("name",name);
yearMap.put("gateWayId",stationBasic.getFanGatewayId());
yearMap.put("value",map.get("年发电量") == null?0:String.format("%.4f",map.get("年发电量")));
datDataFJ.add(dayMap);
monthDataFJ.add(monthMap);
......@@ -819,10 +878,13 @@ public class MonitorFanIdxController extends BaseController {
Map<String, Object> monthMap = new HashMap<>();
Map<String, Object> yearMap = new HashMap<>();
dayMap.put("name",name);
dayMap.put("gateWayId",stationBasic.getFanGatewayId());
dayMap.put("value",map.get("日发电量") == null?0:String.format("%.4f",map.get("日发电量")));
monthMap.put("name",name);
monthMap.put("gateWayId",stationBasic.getFanGatewayId());
monthMap.put("value",map.get("月发电量") == null?0:String.format("%.4f",map.get("月发电量")));
yearMap.put("name",name);
yearMap.put("gateWayId",stationBasic.getFanGatewayId());
yearMap.put("value",map.get("年发电量") == null?0:String.format("%.4f",map.get("年发电量")));
datDataGF.add(dayMap);
monthDataGF.add(monthMap);
......@@ -839,4 +901,62 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "运维数据 ")
@GetMapping("/operationData")
public ResponseModel<IPage<Map<String,Object>>> operationData() {
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto();
List<Map<String,Object>> mapList = new ArrayList<>();
Map<String, List<StationCacheInfoDto>> listMap = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getStationType, Collectors.toList()));
for (StationType value : StationType.values()) {
Map<String, Object> map = new LinkedHashMap<>();
List<StationCacheInfoDto> dtos = listMap.get(value.getCode());
map.put("title",dtos.size());
map.put("data",dtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getInstalledCapacity())).mapToDouble(l->Double.parseDouble(l.getInstalledCapacity())).sum());
mapList.add(map);
}
IPage<Map<String,Object>> result = new Page<>();
result.setRecords(mapList);
result.setCurrent(1);
result.setTotal(mapList.size());
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "社会贡献 ")
@GetMapping("/SocialContribution")
public ResponseModel<Page<SocialContributionDto> > socialContribution() {
List<String> value=new ArrayList<>();
value.add(NFDL);
Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value);
List<? extends Terms.Bucket> lidate= commonService.getgroupsum(map,"valueDouble" ,"equipmentIndexName.keyword", ESEquipments.class);
Map<String,Object> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
Double num = 0.00;
for (Terms.Bucket bucket : lidate) {
Aggregations aggregation= bucket.getAggregations();
List<Aggregation> listdata= Objects.nonNull(aggregation)?aggregation.asList():null;
for (Aggregation agg : listdata) {
ParsedSum parsedSum =(ParsedSum)agg;
num = Double.valueOf(format2.format(parsedSum.getValue()));
}
}
return ResponseHelper.buildResponse(commonService.getSocialContributionDtoList(num));
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESWindSpeed;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.TemporaryData;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -18,4 +18,5 @@ public interface TemporaryDataMapper extends BaseMapper<TemporaryData> {
@RequestParam(value ="equipmentIndexName" ) String equipmentIndexName);
List<ESWindSpeed> getAllData();
}
......@@ -3,18 +3,37 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
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.initdata.StationCacheDataInit;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
......@@ -28,6 +47,15 @@ public class CommonServiceImpl {
@Autowired
SjglZsjZsbtzMapper sjglZsjZsbtzMapper;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private StationCacheDataInit stationCacheDataInit;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
/**
* @deprecated 获取指标值总和
* @param gatewayId 网关id 用于拼接sql语句
......@@ -119,4 +147,53 @@ public class CommonServiceImpl {
socialContributionDtoPage.setCurrent(1);
return socialContributionDtoPage;
}
public List<StationCacheInfoDto> getListStationCacheInfoDto(){
List<StationCacheInfoDto> stationCacheInfoDtoList =redisTemplate.opsForList().range("station_info_cache",0,-1);
if(ObjectUtils.isEmpty(stationCacheInfoDtoList)){
try {
stationCacheDataInit.run();
stationCacheInfoDtoList =redisTemplate.opsForList().range("station_info_cache",0,-1);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return stationCacheInfoDtoList;
}
/*
*分组求和
**/
public List<? extends Terms.Bucket> getgroupsum(Map<String,List<String>> value, String keyavg, String groupKey, Class clas){
List<? extends Terms.Bucket> listdata=null;
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
for(String key:value.keySet()){
List<String> va= value.get(key);
queryBuilder.must( QueryBuilders.termsQuery(key, va));
}
TermsAggregationBuilder tb1 = AggregationBuilders.terms("groupKey").field(groupKey);
SumAggregationBuilder buyCountSum = AggregationBuilders.sum("buyCountSum").field(keyavg);
tb1.subAggregation(buyCountSum); // 通过typeId字段分组统计总数
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.addAggregation(tb1)
.withPageable(PageRequest.of(0, 1))
.build();
query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, ESEquipments.class);
if (search.hasAggregations()) {
Aggregations aggregations = search.getAggregations();
if (Objects.nonNull(aggregations)) {
List<Aggregation> list= aggregations.asList();
listdata= list!=null&&!list.isEmpty()?((ParsedStringTerms) list.get(0)).getBuckets():null;
}
}
return listdata;
}
}
......@@ -103,6 +103,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Autowired
EmqKeeper emqKeeper;
@Autowired
CommonServiceImpl commonServiceImpl;
@Value("${pictureUrl}")
String pictureUrl;
......@@ -1745,22 +1748,32 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public void sendMqttByRanking( List< Map<String,Object>> list,String code,String topic){
list.stream().sorted((o1,o2)->{
double o1Num = Double.parseDouble(o1.get("value").toString());
double o2Num = Double.parseDouble(o2.get("value").toString());
if ((o1Num-o2Num)<0){
return -1;
}else if ((o1Num-o2Num)>0){
return 1;
}else {
return 0;
//先发送区域消息
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getBelongArea));
for (String s : belongAreaList.keySet()) {
List<String> ids = belongAreaList.get(s).stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
String idStrings = String.join(",", ids);
List<Map<String, Object>> dataList = list.stream().filter(e -> idStrings.contains(e.get("gateWayId").toString())).collect(Collectors.toList());
List<Map<String, Object>> resultList = mapListToSort(dataList).stream().limit(5).collect(Collectors.toList());
IPage<Map<String,Object>> result = new Page<>();
result.setRecords(resultList);
result.setCurrent(1);
result.setTotal(resultList.size());
try {
emqKeeper.getMqttClient().publish(s+"/"+topic+"/"+code,JSON.toJSONString(result).getBytes(),0,false);
} catch (MqttException e) {
e.printStackTrace();
}
});
}
//发送全国数据消息
List<Map<String, Object>> maps = mapListToSort(list);
List<Map<String, Object>> resultList = maps.stream().limit(5).collect(Collectors.toList());
IPage<Map<String,Object>> result = new Page<>();
result.setRecords(list);
result.setRecords(resultList);
result.setCurrent(1);
result.setTotal(list.size());
result.setTotal(resultList.size());
try {
emqKeeper.getMqttClient().publish(topic+"/"+code,JSON.toJSONString(result).getBytes(),0,false);
} catch (MqttException e) {
......@@ -1769,6 +1782,22 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
List< Map<String,Object>> mapListToSort(List< Map<String,Object>> list){
list.stream().sorted((o1,o2)->{
double o1Num = Double.parseDouble(o1.get("value").toString());
double o2Num = Double.parseDouble(o2.get("value").toString());
if ((o1Num-o2Num)<0){
return -1;
}else if ((o1Num-o2Num)>0){
return 1;
}else {
return 0;
}
});
return list;
}
public Map<String, Object> generatingCapacity (String gatewayId,String query){
String querySql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量'";
......
package com.yeejoin.amos.boot.module.jxiop.biz.ESDto;
import io.github.classgraph.json.Id;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
@Data
@Accessors(chain = true)
@Document(indexName = "wind_speed")
public class ESWindSpeed {
@Id
private Long sequenceNumber;
@Field(type = FieldType.Text, index = false)
private String createdTime;
@Field(type = FieldType.Text, index = false)
private String equipmentIndexName;
@Field(type = FieldType.Text, index = false)
private String equipmentNumber;
@Field(type = FieldType.Text, index = false)
private String gatewayId;
@Field(type = FieldType.Double, index = false)
private Double value;
@Field(type = FieldType.Text, index = false)
private String batchNo;
}
......@@ -255,12 +255,15 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览-全站功率曲线")
@GetMapping("/overviewWindSpeed")
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = true)String stationId,@RequestParam(value = "type", required = false)String type) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
if (null == type){
gatewayId = stationBasic.getFanGatewayId();
}
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = false)String stationId,@RequestParam(value = "type", required = false)String type) {
String gatewayId = "";
if (null != stationId){
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
gatewayId = stationBasic.getBoosterGatewayId();
if (null == type){
gatewayId = stationBasic.getFanGatewayId();
}
}
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeedAll(gatewayId);
return ResponseHelper.buildResponse(detailsWindSpeed);
......@@ -854,8 +857,4 @@ public class MonitorFanIdxController extends BaseController {
return CommonResponseUtil.success();
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESWindSpeed;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.TemporaryData;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -17,5 +18,5 @@ public interface TemporaryDataMapper extends BaseMapper<TemporaryData> {
Map<String, String> getStatisticsInfo (@RequestParam(value ="gatewayId" ) String gatewayId,
@RequestParam(value ="equipmentIndexName" ) String equipmentIndexName);
List<ESWindSpeed> getAllData();
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESWindSpeed;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.TemporaryData;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/8
*/
@Repository
public interface ESWindSpeedRepository extends PagingAndSortingRepository<ESWindSpeed, Long> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESWindSpeed;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.TemporaryData;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.TemporaryDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESWindSpeedRepository;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.ArrayList;
import java.util.List;
@EnableScheduling
public class WindSpeedScheduled {
@Autowired
TemporaryDataMapper temporaryDataMapper;
@Autowired
ESWindSpeedRepository esWindSpeedRepository;
@Scheduled(cron="${windSpeed.cron}")
private void initData(){
esWindSpeedRepository.saveAll(temporaryDataMapper.getAllData());
}
}
......@@ -777,7 +777,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
TemporaryData temporaryData = new TemporaryData();
temporaryData.setBatchNo(timeInMillis);
temporaryData.setCreatedTime(time.split(" ")[1]);
temporaryData.setEquipmentIndexName(indicatorsDto.getDisplayName());
temporaryData.setGatewayId(indicatorsDto.getGatewayId());
temporaryData.setValue(Float.valueOf(indicatorsDto.getValue()));
temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
......@@ -791,7 +790,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
TemporaryData temporaryData = new TemporaryData();
temporaryData.setBatchNo(timeInMillis);
temporaryData.setCreatedTime(time.split(" ")[1]);
temporaryData.setEquipmentIndexName(indicatorsDto.getDisplayName());
temporaryData.setGatewayId(indicatorsDto.getGatewayId());
temporaryData.setValue(Float.valueOf(indicatorsDto.getValue()));
temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
......
......@@ -77,7 +77,8 @@ gl.avg.column=有功功率,日利用小时,瞬时风速
#ES 曲线图定时 0 57 23 * * ?
windSpeed.cron = 0 25 9 * * ?
spring.elasticsearch.rest.uris=http://39.98.224.23:9200
......
......@@ -14,6 +14,9 @@
<if test="gatewayId != null and gatewayId != ''">
gatewayId = #{gatewayId}
</if>
<if test="gatewayId == null or gatewayId == ''">
equipmentNumber is not null
</if>
</where>
GROUP BY batch_no ,equipmentIndexName;
</select>
......@@ -29,6 +32,16 @@
FROM
`temporary_data`
WHERE
gatewayId = #{gatewayId} and equipmentIndexName =#{equipmentIndexName}
</select>
<select id="getAllData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESWindSpeed">
SELECT
*
FROM
`temporary_data`
</select>
</mapper>
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