Commit f72ad26a authored by caotao's avatar caotao

1.运行监盘全国、省份接口调整。

parent 70dc4643
......@@ -19,5 +19,11 @@
<artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.22</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
@Data
public class BuDunGenDto {
private Double day;
private Double month;
private Double year;
private Double year_complete;
private Double year_hour_number;
}
......@@ -69,6 +69,12 @@ public class Constants {
* 江西电建证书字典key
*/
public static final String JXIOP_DICT_CERTIFICATES = "jxIop:dict:certificates";
public static final String BASE_URL = "http://iiet-jepcc.powerchina.cn:8088/screen_api";
public static final String REQUEST_GET="GET";
public static final String REQUEST_POST="POST";
public static final String get_province_item_url="method=scene_screen.data_interface.get_province_item";
public static String resovleRule_data = "data";
}
package com.yeejoin.amos.boot.module.jxiop.api.util;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Component
public class HttpRequestUtil {
public String sendRequest(String requestMethod, String url, String params, HashMap<String, String> headMap) {
String respone = "";
if (requestMethod.equals("POST")) {
respone = HttpUtil.createPost(url).headerMap(headMap, false).
body(params).execute().body();
}
if (requestMethod.equals("GET")) {
respone = HttpUtil.createGet(url).headerMap(headMap, true).
body(params).execute().body();
}
return respone;
}
public JSONArray handlerResponseByResultResolverule(String resultResovle, String response) {
JSONObject jsonObject = JSONObject.parseObject(response);
JSONArray jsonArray = new JSONArray();
if (ObjectUtil.isNotEmpty(resultResovle)) {
String[] rules = resultResovle.split(",");
if (rules.length > 0) {
for (int i = 0; i < rules.length; i++) {
try {
jsonObject = (JSONObject) jsonObject.get(rules[i]);
if (jsonObject == null) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
} catch (Exception exception) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
}
}
if (jsonArray.size() == 0) {
jsonArray.add(jsonObject);
}
}
return jsonArray;
}
public <T> List<T> getResPonse(String apiurl, String requestMethod, String requestParmInfo, String ResultResolveRule, Class<T> tClass) {
String respone = "";
String params = "";
JSONArray jsonArray = null;
List<T> result = new ArrayList<>();
try {
respone = sendRequest(requestMethod, apiurl, requestParmInfo, null);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) {
result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
}
} catch (Exception exception) {
return result;
}
return result;
}
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.constants;
import com.sun.javafx.logging.PulseLogger;
import org.checkerframework.checker.units.qual.C;
import org.elasticsearch.search.fetch.subphase.FieldAndFormat;
import java.util.*;
......@@ -181,7 +182,6 @@ public class CommonConstans {
public static final String TOTAL_RADIATION = "辐照度";
public static final String ACTIVE_POWER = "有功功率";
//------------------监盘服务改造新增常量结束------------------------------
}
......@@ -94,8 +94,8 @@ public class DemoController extends BaseController {
Logger logger = LoggerFactory.getLogger(DemoController.class);
@Autowired
StationBasicServiceImpl stationBasicServiceimpl;
@Autowired
TestServiceImpl testServiceimpl;
// @Autowired
// TestServiceImpl testServiceimpl;
@Autowired
EmqKeeper emqKeeper;
@Autowired
......@@ -511,16 +511,16 @@ public class DemoController extends BaseController {
commonServiceImpl.getListDataByCondtions(queryConditon, null, ESEquipments.class);
}
@TycloudOperation( ApiLevel = UserType.AGENCY)
@TycloudOperation( ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "测试feign调用")
@GetMapping("/testFeignCall")
public List<CoreValuesDto> testFeignCall() {
List<CoreValuesDto> coreValuesDtos =coreCommonService.getValuesByStationNamesAndPointsNames(null,null);
// List<CoreValuesDto> coreValuesDtos =coreCommonService.getValuesByStationNamesAndPointsNames(null,null);
// monitorService.getTotalData();
// monitorService.getNationWideInfo("江西省","gis");
monitorService.getCompletionOfPowerIndicatorsByProvinceName(1,20,"陕西省");
monitorService.getNationWideInfo("江西省","gis");
// monitorService.getCompletionOfPowerIndicatorsByProvinceName(1,20,"陕西省");
// Double sum = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
// Double avg = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
return coreValuesDtos;
return null;
}
}
......@@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.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.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
......@@ -35,12 +38,13 @@ public class MonitorServiceImpl implements MonitorService {
private final RegionMapper regionMapper;
private final StationCoordinateMapper stationCoordinateMapper;
private final MapRegionMapper mapRegionMapper;
private final HttpRequestUtil httpRequestUtil;
@Override
public void getTotalData() {
//获取所有的场站数据
List<CoreValuesDto> coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
// List<CoreValuesDto> coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
List<StationBasic> stationBasicListAll = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
List<StationBasic> fdzList = stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("FDZ")).collect(Collectors.toList());
......@@ -97,34 +101,67 @@ public class MonitorServiceImpl implements MonitorService {
Double completeRateOfAnnualGF = 0.00;
Double useHoursOfAnnualGF = 0.00;
if (coreValuesDtos.size() > 0) {
powerOfDay = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
powerOfMonth = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.MONTH_POWER_GENERATION);
powerOfAnnual = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_POWER_GENERATION);
completeRateOfAnnual = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE);
//年利用小时数
useHoursOfAnnual = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_HOURS);
List<String> fdNames = fdzList.stream().map(StationBasic::getStationCoreName).collect(Collectors.toList());
List<String> gfNames = gfList.stream().map(StationBasic::getStationCoreName).collect(Collectors.toList());
List<CoreValuesDto> fdcoreValuesDtos = coreValuesDtos.stream().filter(dto -> fdNames.contains(dto.getName())).collect(Collectors.toList());
List<CoreValuesDto> gfcoreValuesDtos = coreValuesDtos.stream().filter(dto -> gfNames.contains(dto.getName())).collect(Collectors.toList());
if (fdcoreValuesDtos.size() > 0) {
powerOfDayFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
powerOfMonthFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.MONTH_POWER_GENERATION);
powerOfAnnualFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_POWER_GENERATION);
completeRateOfAnnualFD = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE);
//年利用小时数
useHoursOfAnnualFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_HOURS);
}
if (gfcoreValuesDtos.size() > 0) {
powerOfDayGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
powerOfMonthGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.MONTH_POWER_GENERATION);
powerOfAnnualGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_POWER_GENERATION);
completeRateOfAnnualGF = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE);
//年利用小时数
useHoursOfAnnualGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_HOURS);
}
//获取全国数据
String nationalUrl = Constants.BASE_URL+"?"+Constants.get_province_item_url;
//获取风电
String nationalFanUrl = Constants.BASE_URL+"?"+Constants.get_province_item_url+"&type=fan";
//获取光伏
String nationalPVUrl = Constants.BASE_URL+"?"+Constants.get_province_item_url+"&type=pv";
List<BuDunGenDto> nationalGendto = httpRequestUtil.getResPonse(nationalPVUrl,Constants.REQUEST_GET,"",Constants.resovleRule_data, BuDunGenDto.class);
List<BuDunGenDto> fanGendto = httpRequestUtil.getResPonse(nationalPVUrl,Constants.REQUEST_GET,"",Constants.resovleRule_data, BuDunGenDto.class);
List<BuDunGenDto> pvGendto = httpRequestUtil.getResPonse(nationalPVUrl,Constants.REQUEST_GET,"",Constants.resovleRule_data, BuDunGenDto.class);
if(nationalGendto.size()>0){
BuDunGenDto buDunGenDto = nationalGendto.get(0);
powerOfDay = buDunGenDto.getDay();
powerOfMonth = buDunGenDto.getMonth();
powerOfAnnual = buDunGenDto.getYear();
completeRateOfAnnual=buDunGenDto.getYear_complete();
useHoursOfAnnual = buDunGenDto.getYear_hour_number();
}
if(fanGendto.size()>0){
BuDunGenDto buDunGenDto = nationalGendto.get(0);
powerOfDayFD = buDunGenDto.getDay();
powerOfMonthFD = buDunGenDto.getMonth();
powerOfAnnualFD = buDunGenDto.getYear();
completeRateOfAnnualFD=buDunGenDto.getYear_complete();
useHoursOfAnnualFD = buDunGenDto.getYear_hour_number();
}
if(pvGendto.size()>0){
BuDunGenDto buDunGenDto = nationalGendto.get(0);
powerOfDayGF = buDunGenDto.getDay();
powerOfMonthGF = buDunGenDto.getMonth();
powerOfAnnualGF = buDunGenDto.getYear();
completeRateOfAnnualGF=buDunGenDto.getYear_complete();
useHoursOfAnnualGF = buDunGenDto.getYear_hour_number();
}
// if (coreValuesDtos.size() > 0) {
// powerOfDay = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
// powerOfMonth = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.MONTH_POWER_GENERATION);
// powerOfAnnual = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_POWER_GENERATION);
// completeRateOfAnnual = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE);
// //年利用小时数
// useHoursOfAnnual = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_HOURS);
// List<String> fdNames = fdzList.stream().map(StationBasic::getStationCoreName).collect(Collectors.toList());
// List<String> gfNames = gfList.stream().map(StationBasic::getStationCoreName).collect(Collectors.toList());
// List<CoreValuesDto> fdcoreValuesDtos = coreValuesDtos.stream().filter(dto -> fdNames.contains(dto.getName())).collect(Collectors.toList());
// List<CoreValuesDto> gfcoreValuesDtos = coreValuesDtos.stream().filter(dto -> gfNames.contains(dto.getName())).collect(Collectors.toList());
// if (fdcoreValuesDtos.size() > 0) {
// powerOfDayFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
// powerOfMonthFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.MONTH_POWER_GENERATION);
// powerOfAnnualFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_POWER_GENERATION);
// completeRateOfAnnualFD = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE);
// //年利用小时数
// useHoursOfAnnualFD = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_HOURS);
// }
// if (gfcoreValuesDtos.size() > 0) {
// powerOfDayGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
// powerOfMonthGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.MONTH_POWER_GENERATION);
// powerOfAnnualGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_POWER_GENERATION);
// completeRateOfAnnualGF = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE);
// //年利用小时数
// useHoursOfAnnualGF = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_HOURS);
// }
// }
HashMap<String, String> stringHashMap4 = new HashMap<>();
stringHashMap4.put("title", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD) + "/" + String.format(CommonConstans.Fourdecimalplaces, powerOfDayGF));
......@@ -226,7 +263,7 @@ public class MonitorServiceImpl implements MonitorService {
} else if (stationCacheInfoDto.getStationType().contains("GFDZ") && stationCacheInfoDto.getStationCoreName() != null && stationCacheInfoDto.getBoosterCoreName() != null) {
List<CoreValuesDto> coreValuesDtoList = coreValuesDtos.stream().filter(coreValuesDto -> coreValuesDto.getName().equals(stationCacheInfoDto.getStationCoreName()) || coreValuesDto.getName().equals(stationCacheInfoDto.getBoosterCoreName())).collect(Collectors.toList());
if (coreValuesDtoList != null && coreValuesDtoList.size() > 0) {
speendOrirradiate = String.format(CommonConstans.Twodecimalplaces, coreCommonService.getAverageOfByPointName(coreValuesDtoList, CommonConstans.WIND_SPEED_THIRTY_SECONDS));
speendOrirradiate = String.format(CommonConstans.Twodecimalplaces, coreCommonService.getAverageOfByPointName(coreValuesDtoList, CommonConstans.TOTAL_RADIATION));
}
}
......@@ -365,9 +402,18 @@ public class MonitorServiceImpl implements MonitorService {
}
completionOfPowerIndicatorsDtoList.add(completionOfPowerIndicatorsDto);
});
String provincelUrl = Constants.BASE_URL+"?"+Constants.get_province_item_url+"&provinceName="+provinceName;
List<BuDunGenDto> provinceDtos = httpRequestUtil.getResPonse(provincelUrl,Constants.REQUEST_GET,"",Constants.resovleRule_data, BuDunGenDto.class);
if(provinceDtos.size()>0){
BuDunGenDto buDunGenDto = provinceDtos.get(0);
dailyPower.set(buDunGenDto.getDay());
monthlyPower.set(buDunGenDto.getMonth());
annualPower.set(buDunGenDto.getYear());
completionRatio = String.format(CommonConstans.Twodecimalplaces, buDunGenDto.getYear_complete());
}
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
completionRatio = String.format(CommonConstans.Twodecimalplaces, coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE));
// completionRatio = String.format(CommonConstans.Twodecimalplaces, coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE));
SocialContributionDto dailyPowerdto = new SocialContributionDto();
dailyPowerdto.setTitle(String.format(CommonConstans.Fourdecimalplaces, dailyPower.get()));
dailyPowerdto.setUnit("万kWh");
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.netflix.loadbalancer.RetryRule;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.TestMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.ItestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TestServiceImpl implements ItestService {
@Autowired
TestMapper testMapper;
public List<Test> getList(){
return testMapper.selectList(new QueryWrapper<Test>().isNotNull("name"));
}
}
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