Commit 4a6657ae authored by chenzhao's avatar chenzhao

修改代码

parent c158ee73
...@@ -2,10 +2,13 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; ...@@ -2,10 +2,13 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationPlan; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationPlan;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper;
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.SeriesData; import com.yeejoin.amos.boot.module.jxiop.biz.dto.SeriesData;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil; import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
...@@ -23,6 +26,7 @@ import java.text.DecimalFormat; ...@@ -23,6 +26,7 @@ import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @description: * @description:
...@@ -49,6 +53,7 @@ public class LargeScreenImpl { ...@@ -49,6 +53,7 @@ public class LargeScreenImpl {
/** /**
* 全国 * 全国
*/ */
@Scheduled(cron = "0/10 * * * * ?")
public Map<String, Double> getqg() { public Map<String, Double> getqg() {
Map<String, Double> mapdta = new HashMap<>(); Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d); mapdta.put("SS", 0d);
...@@ -149,11 +154,23 @@ public class LargeScreenImpl { ...@@ -149,11 +154,23 @@ public class LargeScreenImpl {
} }
@Scheduled(cron = "0/10 * * * * ?")
private void sendQYYXZBMqtt(){
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode));
for (String s : belongAreaList.keySet()) {
List<String> ids = belongAreaList.get(s).stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
getqy(ids,s);
}
}
/** /**
* 区域 * 区域
**/ **/
public Map<String, Double> getqy(List<String> gatewayId) { public Map<String, Double> getqy(List<String> gatewayId,String s) {
Map<String, Double> mapdta = new HashMap<>(); Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d); mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d); mapdta.put("ZFS", 0d);
...@@ -246,7 +263,7 @@ public class LargeScreenImpl { ...@@ -246,7 +263,7 @@ public class LargeScreenImpl {
ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
mapdta.put("NJHWC", ybfbn); mapdta.put("NJHWC", ybfbn);
try { try {
emqKeeper.getMqttClient().publish("topic", JSON.toJSONString(mapdta).getBytes(),0,false); emqKeeper.getMqttClient().publish("qyyxzb/"+s, JSON.toJSONString(mapdta).getBytes(),0,false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -257,7 +274,7 @@ public class LargeScreenImpl { ...@@ -257,7 +274,7 @@ public class LargeScreenImpl {
//全国发电趋势 //全国发电趋势
// @Scheduled(cron = "0/10 * * * * *") @Scheduled(cron = "0/10 * * * * ?")
public SeriesData getSeriesDataqg(){ public SeriesData getSeriesDataqg(){
//获取今年当月 日发电趋势 //获取今年当月 日发电趋势
...@@ -292,9 +309,23 @@ public class LargeScreenImpl { ...@@ -292,9 +309,23 @@ public class LargeScreenImpl {
return seriesData; return seriesData;
} }
//区域发电趋势
public SeriesData getSeriesDataqy( Date date,List<String> gatewayId){ //获取区域月日发电量
@Scheduled(cron = "0/10 * * * * ?")
private void sendQYFDLMqtt(){
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode));
for (String s : belongAreaList.keySet()) {
List<String> ids = belongAreaList.get(s).stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
getSeriesDataqy(new Date(),ids,s);
}
}
//区域发电趋势
public SeriesData getSeriesDataqy( Date date,List<String> gatewayId,String areaCode){
//获取今年当月 日发电趋势 //获取今年当月 日发电趋势
List<Double> listjn= gettimedateqy( new Date(),gatewayId); List<Double> listjn= gettimedateqy( new Date(),gatewayId);
...@@ -320,7 +351,7 @@ public class LargeScreenImpl { ...@@ -320,7 +351,7 @@ public class LargeScreenImpl {
List<String> listdate= dayReportnq(new Date()); List<String> listdate= dayReportnq(new Date());
seriesData.setAxisData(listdate); seriesData.setAxisData(listdate);
try { try {
emqKeeper.getMqttClient().publish("qy/yxzb", JSON.toJSONString(seriesData).getBytes(),0,false); emqKeeper.getMqttClient().publish("qy/fdqs/"+areaCode, JSON.toJSONString(seriesData).getBytes(),0,false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -380,7 +411,6 @@ public class LargeScreenImpl { ...@@ -380,7 +411,6 @@ public class LargeScreenImpl {
} }
//获取区域月日发电量
public List<Double> gettimedateqy( Date date,List<String> gatewayId){ public List<Double> gettimedateqy( Date date,List<String> gatewayId){
...@@ -419,11 +449,7 @@ public class LargeScreenImpl { ...@@ -419,11 +449,7 @@ public class LargeScreenImpl {
} }
} }
try {
emqKeeper.getMqttClient().publish("topic", JSON.toJSONString(listdate).getBytes(),0,false);
} catch (MqttException e) {
e.printStackTrace();
}
return listdate; return listdate;
......
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