Commit 03b1d875 authored by caotao's avatar caotao

1.运行监盘首页、区域发电量趋势、发电量完成趋势问题修改。

parent c12f7f05
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
@Data
public class BudunMonthTrendDto {
private Integer month;
private Double generating_capacity;
}
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
@Data
public class BundunCompleteDto {
private Integer month;
private Double generating_capacity_complete;
}
......@@ -77,7 +77,8 @@ public class Constants {
public static final String get_month_generation_trend_url="method=scene_screen.data_interface.get_month_generation_trend";
public static final String get_area_item_url="method=scene_screen.data_interface.get_area_item";
public static final String get_month_top_url="method=scene_screen.data_interface.get_month_top";
public static final String get_hours_num_top="scene_screen.data_interface.get_hours_num_top";
public static final String get_hours_num_top="method=scene_screen.data_interface.get_hours_num_top";
public static final String get_generated_quota_trend="method=scene_screen.data_interface.get_generated_quota_trend";
public static final String resovleRule_data = "data";
public static final String areaChinese="区域";
}
......
......@@ -27,6 +27,7 @@ public interface MonitorService {
* @return Map<String, Object>
*/
Map<String, Object> qyAccessSituation();
Map<String, Object> gettimedateyfdqs();
Map<String, Object> gettimedateyfd(String areaName);
Map<String, Object> gettimedateqyyfd(String areaName);
}
......@@ -680,7 +680,6 @@ public Map<String,Object> gettimedateyfd( ){
//全国发电完成趋势
@Scheduled(cron = "0/10 * * * * ?")
public Map<String,Object> gettimedateyfdqs( ){
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy");
String monthy= myFmt2.format(new Date());
List<Double> listdate= new ArrayList<>();
......
......@@ -5,23 +5,37 @@ 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.Enum.StationType;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BudunMonthTrendDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BundunCompleteDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationPlan;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.util.Constants;
import com.yeejoin.amos.boot.module.jxiop.api.util.HttpRequestUtil;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.MonitorService;
import lombok.RequiredArgsConstructor;
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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.io.PipedReader;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class MonitorServiceImpl implements MonitorService {
......@@ -29,6 +43,8 @@ public class MonitorServiceImpl implements MonitorService {
private final MapRegionMapper mapRegionMapper;
private final StationBasicMapper stationBasicMapper;
private final EmqKeeper emqKeeper;
private final HttpRequestUtil httpRequestUtil;
@Override
public IPage<Map<String, Object>> operationData(String areaCode) {
List<StationCacheInfoDto> list = getListStationCacheInfoDto();
......@@ -130,4 +146,86 @@ public class MonitorServiceImpl implements MonitorService {
return stationCacheInfoDtos;
}
public Map<String, Object> gettimedateyfd(String areaName) {
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName));
if (!areaName.contains(Constants.areaChinese)) {
areaName = Constants.areaChinese;
}
String requestUrl = Constants.BASE_URL + "?" + Constants.get_month_generation_trend_url + "&areaName=" + areaName;
List<String> list = new ArrayList<>();
List<Double> listData = new ArrayList<>();
List<BudunMonthTrendDto> budunMonthTrendDtos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BudunMonthTrendDto.class);
budunMonthTrendDtos.forEach(budunMonthTrendDto -> {
listData.add(budunMonthTrendDto.getGenerating_capacity());
list.add(budunMonthTrendDto.getMonth().toString());
});
Map<String, Object> mapjn = new HashMap<>();
mapjn.put("seriesData", listData);
mapjn.put("axisData", list);
try {
if (!ObjectUtils.isEmpty(mapRegion) && !ObjectUtils.isEmpty(mapRegion.getAreaCode())) {
emqKeeper.getMqttClient().publish("qyyfd/fdqs/" + mapRegion.getAreaCode(), JSON.toJSONString(mapjn).getBytes(), 0, false);
}
} catch (MqttException e) {
e.printStackTrace();
}
return mapjn;
}
@Override
public Map<String, Object> gettimedateyfdqs() {
String requestUrl = Constants.BASE_URL + "?" + Constants.get_generated_quota_trend;
List<BundunCompleteDto> bundunCompleteDtoList = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BundunCompleteDto.class);
Map<String, Object> mapjn = new HashMap<>();
List<String> list = new ArrayList<>();
List<Double> listData = new ArrayList<>();
bundunCompleteDtoList.forEach(bundunCompleteDto -> {
listData.add(bundunCompleteDto.getGenerating_capacity_complete());
list.add(bundunCompleteDto.getMonth().toString());
});
mapjn.put("seriesData", listData);
mapjn.put("axisData", list);
try {
emqKeeper.getMqttClient().publish("topic_yfdqs", JSON.toJSONString(mapjn).getBytes(), 0, false);
} catch (MqttException e) {
e.printStackTrace();
}
return mapjn;
}
@Override
public Map<String, Object> gettimedateqyyfd(String areaName) {
String requestUrl = Constants.BASE_URL + "?" + Constants.get_generated_quota_trend + "&areaName=" + areaName;
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName));
if (!areaName.contains(Constants.areaChinese)) {
areaName = Constants.areaChinese;
}
List<BundunCompleteDto> bundunCompleteDtoList = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BundunCompleteDto.class);
Map<String, Object> mapjn = new HashMap<>();
List<String> list = new ArrayList<>();
List<Double> listData = new ArrayList<>();
bundunCompleteDtoList.forEach(bundunCompleteDto -> {
listData.add(bundunCompleteDto.getGenerating_capacity_complete());
list.add(bundunCompleteDto.getMonth().toString());
});
mapjn.put("seriesData", listData);
mapjn.put("axisData", list);
try {
if (!ObjectUtils.isEmpty(mapRegion) && !ObjectUtils.isEmpty(mapRegion.getAreaCode())) {
emqKeeper.getMqttClient().publish("qyyfd/fdqs/" + mapRegion.getAreaCode(), JSON.toJSONString(mapjn).getBytes(), 0, false);
}
} catch (MqttException e) {
e.printStackTrace();
}
return mapjn;
}
}
......@@ -4,24 +4,34 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BuDunGenDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BudunMonthTrendDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BudunStationValueDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BuDunPvFanDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.*;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.*;
import com.yeejoin.amos.boot.module.jxiop.api.util.Constants;
import com.yeejoin.amos.boot.module.jxiop.api.util.HttpRequestUtil;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.service.CoreCommonService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.MonitorService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
......@@ -699,4 +709,7 @@ public class MonitorServiceImpl implements MonitorService {
//组装数据
return page;
}
}
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