Commit b8c40195 authored by wujiang's avatar wujiang

Merge branch 'developer' of http://36.40.66.175:5000/moa/jxdj_zx/amos-boot-zx-biz into developer

parents b84899d2 c5693539
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
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.QueryWrapper;
......@@ -9,7 +8,6 @@ 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;
......@@ -19,7 +17,8 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
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.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.MonitorService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
......@@ -28,15 +27,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchPhraseQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
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.core.io.Resource;
......@@ -58,10 +52,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.parseArray;
......@@ -89,6 +81,8 @@ public class MonitorFanIdxController extends BaseController {
@Autowired
MonitorService monitorService;
@Autowired
StationPlanMapper StationPlanMapper;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Value("classpath:/json/overview.json")
private Resource overview;
......@@ -97,9 +91,6 @@ public class MonitorFanIdxController extends BaseController {
@Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix;
@Autowired
StationPlanMapper StationPlanMapper;
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "根据设备编号、场站id、前段展示模块、系统类型查询表数据")
// @GetMapping("/getFanIdxInfoByPage")
......@@ -112,30 +103,23 @@ public class MonitorFanIdxController extends BaseController {
// return ResponseHelper.buildResponse(monitorFanIndicator.getFanIdxInfoByPage(equipNum, stationId, frontModule, current, size, systemType));
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "左侧树API")
@GetMapping("/getTreeInfo")
public ResponseModel<TreeDto> getTreeInfo(@RequestParam(value = "sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr));
}
public static List<Map<String, Object>> sortByFeild(List<Map<String, Object>> list, String feild) {
if (CollectionUtils.isNotEmpty(list)) {
Collections.sort(list, (m1, m2) -> Integer.valueOf(m1.get(feild).toString()).compareTo(Integer.valueOf(m2.get(feild).toString())));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏三维地图信息弹框")
@GetMapping("/getBasicInfonew")
public ResponseModel< Map<String, Object>> getBasicInfonew(@RequestParam(value = "stationId") String stationId) {
List<Map<String,String>> list =new ArrayList<>();
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Map<String,String> date= monitoringService.getStationfs(stationBasic);
Map<String,String> date1= monitoringService.getStationrl(stationBasic);
list.add(date);
list.add(date1);
Map<String, Object> queryCondtion = new HashMap<>();
queryCondtion.put("color",stationBasic.getQrcodeColor());
queryCondtion.put("data",list);
return ResponseHelper.buildResponse(queryCondtion);
return list;
}
public static List<Map<String, Object>> sortByFeildString(List<Map<String, Object>> list, String feild) {
if (CollectionUtils.isNotEmpty(list)) {
Collections.sort(list, (m1, m2) -> String.valueOf(m1.get(feild).toString()).compareTo(String.valueOf(m2.get(feild).toString())));
}
return list;
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -220,11 +204,10 @@ public class MonitorFanIdxController extends BaseController {
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机基础信息")
@GetMapping("/getFanBasicInfoByEquipNum")
public ResponseModel<IndexDto> getFanBasicInfoByEquipNum(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanBasicInfoByEquipNum(equipNum, stationId));
@ApiOperation(value = "左侧树API")
@GetMapping("/getTreeInfo")
public ResponseModel<TreeDto> getTreeInfo(@RequestParam(value = "sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr));
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -237,138 +220,27 @@ public class MonitorFanIdxController extends BaseController {
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全国风机-总概览")
@GetMapping("/overview")
public ResponseModel<IPage<Map>> getData(@RequestParam(value = "stationId") String stationId) {
@ApiOperation(value = "大屏三维地图信息弹框")
@GetMapping("/getBasicInfonew")
public ResponseModel<Map<String, Object>> getBasicInfonew(@RequestParam(value = "stationId") String stationId) {
List<Map<String, String>> list = new ArrayList<>();
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
String[] columnList = new String[]{"日发电量", "月发电量", "年发电量"};
String[] columnLists = new String[]{"30秒平均风速"};
Map<String, Object> columnMap = new HashMap<>();
for (String column : columnList) {
Double result = commonServiceImpl.getTotalByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f", result));
}
for (String column : columnLists) {
// Double result = commonServiceImpl.getAvgvalueByIndicatior(gatewayId, column);
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put(column, String.format("%.2f", commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速")));
}
Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
columnMap.put("有功功率", String.format("%.2f", result1.get(0).getValueF()));
//String num = monitorFanIndicator.getFJCount(gatewayId);
String num = monitorFanIndicator.getEquipCount(gatewayId, "FDZ");
columnMap.put("风机台数", num);
columnMap.put("风机台数", Double.valueOf(num).intValue());
Double capacityl = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量", String.format("%.2f", capacityl));
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy");
String monthy= myFmt2.format(new Date());
QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
wrapper.select(" monthly ,sum(value) value ");
wrapper.eq("year", monthy);
wrapper.eq("station_basic_id", stationBasic.getSequenceNbr());
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper);
Double sumValue = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("value") : 0;
columnMap.put("年发电量完成率(%)", String.format("%.2f", Double.parseDouble(columnMap.get("年发电量").toString())/sumValue*100));
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// String [] columnList = new String[]{"日发电量","月发电量","年发电量"};
// String [] columnLists = new String[]{"有功功率","瞬时风速"};
// Map<String, Object> columnMap = new HashMap<>();
//
// for (String column : columnList) {
// Double result = commonServiceImpl.getTotalByIndicatior(gatewayId, column);
// columnMap.put(column, String.format("%.2f",result));
// }
// for (String column : columnLists) {
// Double result = commonServiceImpl.getAvgvalueByIndicatior(gatewayId, column);
// columnMap.put(column, String.format("%.2f",result));
// }
//
// String num = monitorFanIndicator.getFJCount(gatewayId);
//
//
// Double capacityl = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
// columnMap.put("装机容量",String.format("%.2f",capacityl));
String json = null;
try {
json = IOUtils.toString(overview.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
List<Map> list = parseArray(json, Map.class);
for (Map map : list) {
String key = map.get("title").toString();
map.put("title", columnMap.get(key) == null ? 0.00 : columnMap.get(key));
map.put("title2", map.get("title"));
if (map.containsKey("action")) {
if (key.equals("日利用小时(h)")) {
String format = String.format("%.2f", ((Double.parseDouble(columnMap.get("日发电量").toString()) * 10) / (Double.parseDouble(columnMap.get("装机容量").toString()))));
map.put("title", format);
map.put("title2", map.get("title"));
} else {
map.put("title", String.format("%.2f", Double.parseDouble(columnMap.get(key).toString()) / 1000));
map.put("title2", map.get("title"));
}
}
}
IPage<Map> result = new Page<>();
result.setRecords(list);
result.setCurrent(1);
result.setTotal(list.size());
return ResponseHelper.buildResponse(result);
Map<String, String> date = monitoringService.getStationfs(stationBasic);
Map<String, String> date1 = monitoringService.getStationrl(stationBasic);
list.add(date);
list.add(date1);
Map<String, Object> queryCondtion = new HashMap<>();
queryCondtion.put("color", stationBasic.getQrcodeColor());
queryCondtion.put("data", list);
return ResponseHelper.buildResponse(queryCondtion);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览-全站功率曲线")
@GetMapping("/overviewWindSpeed")
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = false) String stationId, @RequestParam(value = "type", required = false) String type
, @RequestParam(value = "areaCode", required = false) String areaCode) {
String gatewayId = "";
String paramId = "";
List<String> ids = new ArrayList<>();
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
double installedCapacity = listStationCacheInfoDto.stream().mapToDouble(t -> Double.parseDouble(t.getInstalledCapacity())).sum();
if (null != areaCode) {
List<String> collect = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
ids = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getBoosterGatewayId).collect(Collectors.toList());
installedCapacity = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).mapToDouble(t -> Double.parseDouble(t.getInstalledCapacity())).sum();
gatewayId = String.join(",", collect);
}
if (null != stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
gatewayId = stationBasic.getBoosterGatewayId();
if (null == type) {
gatewayId = stationBasic.getFanGatewayId();
}
installedCapacity = listStationCacheInfoDto.stream().filter(e -> e.getStationId().equals(stationId)).mapToDouble(t -> Double.parseDouble(t.getInstalledCapacity())).sum();
}
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeedAll(gatewayId, installedCapacity, ids);
return ResponseHelper.buildResponse(detailsWindSpeed);
@ApiOperation(value = "风机布置图 - 风机基础信息")
@GetMapping("/getFanBasicInfoByEquipNum")
public ResponseModel<IndexDto> getFanBasicInfoByEquipNum(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanBasicInfoByEquipNum(equipNum, stationId));
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -575,6 +447,246 @@ public class MonitorFanIdxController extends BaseController {
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全国风机-总概览")
@GetMapping("/overview")
public ResponseModel<IPage<Map>> getData(@RequestParam(value = "stationId") String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getFanGatewayId();
String[] columnList = new String[]{"日发电量", "月发电量", "年发电量"};
String[] columnLists = new String[]{"30秒平均风速"};
Map<String, Object> columnMap = new HashMap<>();
for (String column : columnList) {
Double result = commonServiceImpl.getTotalByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f", result));
}
for (String column : columnLists) {
// Double result = commonServiceImpl.getAvgvalueByIndicatior(gatewayId, column);
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put(column, String.format("%.2f", commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速")));
}
Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
columnMap.put("有功功率", String.format("%.2f", result1.get(0).getValueF()));
//String num = monitorFanIndicator.getFJCount(gatewayId);
String num = monitorFanIndicator.getEquipCount(gatewayId, "FDZ");
columnMap.put("风机台数", num);
columnMap.put("风机台数", Double.valueOf(num).intValue());
Double capacityl = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量", String.format("%.2f", capacityl));
SimpleDateFormat myFmt2 = new SimpleDateFormat("yyyy");
String monthy = myFmt2.format(new Date());
QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
wrapper.select(" monthly ,sum(value) value ");
wrapper.eq("year", monthy);
wrapper.eq("station_basic_id", stationBasic.getSequenceNbr());
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper);
Double sumValue = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("value") : 0;
columnMap.put("年发电量完成率(%)", String.format("%.2f", Double.parseDouble(columnMap.get("年发电量").toString()) / sumValue * 100));
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// String [] columnList = new String[]{"日发电量","月发电量","年发电量"};
// String [] columnLists = new String[]{"有功功率","瞬时风速"};
// Map<String, Object> columnMap = new HashMap<>();
//
// for (String column : columnList) {
// Double result = commonServiceImpl.getTotalByIndicatior(gatewayId, column);
// columnMap.put(column, String.format("%.2f",result));
// }
// for (String column : columnLists) {
// Double result = commonServiceImpl.getAvgvalueByIndicatior(gatewayId, column);
// columnMap.put(column, String.format("%.2f",result));
// }
//
// String num = monitorFanIndicator.getFJCount(gatewayId);
//
//
// Double capacityl = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
// columnMap.put("装机容量",String.format("%.2f",capacityl));
String json = null;
try {
json = IOUtils.toString(overview.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
List<Map> list = parseArray(json, Map.class);
for (Map map : list) {
String key = map.get("title").toString();
map.put("title", columnMap.get(key) == null ? 0.00 : columnMap.get(key));
map.put("title2", map.get("title"));
if (map.containsKey("action")) {
if (key.equals("日利用小时(h)")) {
String format = String.format("%.2f", ((Double.parseDouble(columnMap.get("日发电量").toString()) * 10) / (Double.parseDouble(columnMap.get("装机容量").toString()))));
map.put("title", format);
map.put("title2", map.get("title"));
} else {
map.put("title", String.format("%.2f", Double.parseDouble(columnMap.get(key).toString()) / 1000));
map.put("title2", map.get("title"));
}
}
}
IPage<Map> result = new Page<>();
result.setRecords(list);
result.setCurrent(1);
result.setTotal(list.size());
return ResponseHelper.buildResponse(result);
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "夏造电量表计API")
// @GetMapping("/electricQuantity")
// public ResponseModel<ResultsData> getElectricQuantityList(@RequestParam(value = "current") int current,
// @RequestParam(value = "size") int size,
// @RequestParam(value = "stationId") String stationId,
// @RequestParam(value = "stationType",required = false) String stationType) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getBoosterGatewayId();
// ResultsData resultsData = monitorFanIndicatorImpl.getElectricQuantityList(current, size, gatewayId,stationType);
// return ResponseHelper.buildResponse(resultsData);
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "开关图片API/消息")
// @GetMapping("/switchUrl")
// public ResponseModel<Map<String,Object>> getElectricQuantityList(
// @RequestParam(value = "stationId") String stationId
// ) {
//
// LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
// List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
// for (StationBasic stationBasic : stationBasics) {
// monitorFanIndicatorImpl.getSwitchUrlAll(stationBasic);
// }
//
// return CommonResponseUtil.success();
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "动态面板页面消息")
// @GetMapping("/pageTopic")
// public ResponseModel<Map<String,Object>> sendPageTopic(
// @RequestParam(value = "stationId") String stationId, @RequestParam(value = "equipName") String equipName
// ) {
//
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getBoosterGatewayId();
//
//
// Map<String, String> map = monitorFanIndicatorMapper.getMajorBoosterStationInfoBySort(gatewayId, equipName);
// String name = map.get("text").equals("1主变高压侧") || map.get("text").equals("1主变低压侧") ?map.get("text").substring(0,3):map.get("text");
//
//
// Map<String, Object> switchUrl = monitorFanIndicatorImpl.getSwitchUrl(gatewayId, name);
// List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId ,"网络",name,null);
// IPage<Map<String, Object>> result = new Page<>();
// switchUrl.put("records",statusMonitoring);
// switchUrl.put("current",1);
// switchUrl.put("total",100);
// List<Map<String, Object>> data = new ArrayList<>();
// data.add(switchUrl);
// result.setRecords(data);
// result.setCurrent(1);
// result.setTotal(100);
//
// try {
// emqKeeper.getMqttClient().publish(stationId+"/switch/"+equipName, JSON.toJSONString(result).getBytes(),0,false);
// } catch (MqttException e) {
// e.printStackTrace();
// }
// return CommonResponseUtil.success();
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "1#主变油温")
// @GetMapping("/zbyw")
// public ResponseModel<Map<String,Object>> getYwData(@RequestParam(value = "stationId") String stationId) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getBoosterGatewayId();
// Map<String,Object> resultsData = monitorFanIndicatorImpl.getyw( gatewayId);
// return ResponseHelper.buildResponse(resultsData);
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "概览-全站功率曲线")
@GetMapping("/overviewWindSpeed")
public ResponseModel<Map<String, Object>> getOverviewWindSpeed(@RequestParam(value = "stationId", required = false) String stationId, @RequestParam(value = "type", required = false) String type
, @RequestParam(value = "areaCode", required = false) String areaCode) {
String gatewayId = "";
String paramId = "";
List<String> ids = new ArrayList<>();
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
double installedCapacity = listStationCacheInfoDto.stream().mapToDouble(t -> Double.parseDouble(t.getInstalledCapacity())).sum();
if (null != areaCode) {
List<String> collect = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
ids = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getBoosterGatewayId).collect(Collectors.toList());
installedCapacity = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).mapToDouble(t -> Double.parseDouble(t.getInstalledCapacity())).sum();
gatewayId = String.join(",", collect);
}
if (null != stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
gatewayId = stationBasic.getBoosterGatewayId();
if (null == type) {
gatewayId = stationBasic.getFanGatewayId();
}
installedCapacity = listStationCacheInfoDto.stream().filter(e -> e.getStationId().equals(stationId)).mapToDouble(t -> Double.parseDouble(t.getInstalledCapacity())).sum();
}
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeedAll(gatewayId, installedCapacity, ids);
return ResponseHelper.buildResponse(detailsWindSpeed);
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "详情基础信息")
// @GetMapping("/getEquipInfoByEquipNum")
// public ResponseModel<Map<String,Object>> getEquipInfoByEquipNum(@RequestParam(value = "equipNum", required = false) String equipNum,
// @RequestParam(value = "stationId", required = false) String stationId) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// return ResponseHelper.buildResponse(monitorFanIndicator.getEquipInfoByEquipNum(gatewayId,equipNum ));
// }
//
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "光伏左侧资源树")
// @GetMapping("/getEquipTree")
// public ResponseModel<IPage<Map<String, Object>>> getEquipTree(@RequestParam(value = "stationId", required = false) String stationId,
// @RequestParam(value = "frontModule", required = false) String frontModule,
// @RequestParam(value = "equipmentNumber", required = false) String equipmentNumber
// ) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// List<Map<String, Object>> equipmentNum = monitorFanIndicator.getEquipmentNum(gatewayId, frontModule, equipmentNumber);
// IPage<Map<String, Object>> result = new Page<>();
// result.setRecords(equipmentNum);
// result.setCurrent(1);
// result.setTotal(equipmentNum.size());
// return ResponseHelper.buildResponse(result);
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "故障记录API")
@GetMapping("/alarmEventtList")
public ResponseModel<ResultsData> getAlarmEventList(@RequestParam(value = "current") int current,
......@@ -594,84 +706,107 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(resultsData);
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "夏造电量表计API")
// @GetMapping("/electricQuantity")
// public ResponseModel<ResultsData> getElectricQuantityList(@RequestParam(value = "current") int current,
// @RequestParam(value = "size") int size,
// @RequestParam(value = "stationId") String stationId,
// @RequestParam(value = "stationType",required = false) String stationType) {
// @ApiOperation(value = "码速表")
// @GetMapping("/SpeedIndicator")
// public ResponseModel<Map<String,Object>> SpeedIndicator(@RequestParam(value = "equipNum", required = false) String equipNum,
// @RequestParam(value = "stationId", required = false) String stationId,
// @RequestParam(value = "equipmentIndexName", required = false) String equipmentIndexName
// ) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getBoosterGatewayId();
// ResultsData resultsData = monitorFanIndicatorImpl.getElectricQuantityList(current, size, gatewayId,stationType);
// return ResponseHelper.buildResponse(resultsData);
// String gatewayId = stationBasic.getFanGatewayId();
// return ResponseHelper.buildResponse(monitorFanIndicator.SpeedIndicator(gatewayId,equipNum,equipmentIndexName ));
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "箱变实时开关状态")
// @GetMapping("/equipSwitchStatus")
// // @Scheduled(cron = "0/10 * * * * ? ")
// public ResponseModel<Map<String,Object>> getEquipSwitchStatus() {
//
//
// LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
// List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
// for (StationBasic stationBasic : stationBasics) {
// String fanGatewayId = stationBasic.getFanGatewayId();
// monitorFanIndicatorImpl.getEquipSwitchStatus(stationBasic);
// }
//
// return CommonResponseUtil.success();
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "汇流箱支路电流离散率")
// @GetMapping("/collectingBox")
// public ResponseModel<ResultsData> collectingBox(@RequestParam(value = "current") int current,
// @RequestParam(value = "size") int size,
// @RequestParam(value = "stationId") String stationId) {
//
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// return ResponseHelper.buildResponse(monitorFanIndicatorImpl.collectingBox(gatewayId,current, size ));
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "开关图片API/消息")
// @GetMapping("/switchUrl")
// public ResponseModel<Map<String,Object>> getElectricQuantityList(
// @RequestParam(value = "stationId") String stationId
// ) {
//
// LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
// List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
// for (StationBasic stationBasic : stationBasics) {
// monitorFanIndicatorImpl.getSwitchUrlAll(stationBasic);
// }
// @ApiOperation(value = "光伏 运行列表")
// @GetMapping("/solarPowerOperation")
// public ResponseModel<IPage<Map<String, Object>>> solarPowerOperation(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "current") int current, int size) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
//
// return CommonResponseUtil.success();
// List<Map<String, Object>> statusMonitoring = monitorFanIndicator.solarPowerOperation(gatewayId);
// List<Map<String, Object>> collect = statusMonitoring.stream()
// .skip((long) (current - 1) * size)
// .limit(size)
// .collect(Collectors.toList());
// IPage<Map<String,Object>> result = new Page<>();
// result.setRecords(collect);
// result.setCurrent(current);
// result.setTotal(statusMonitoring.size());
// return ResponseHelper.buildResponse(result);
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "动态面板页面消息")
// @GetMapping("/pageTopic")
// public ResponseModel<Map<String,Object>> sendPageTopic(
// @RequestParam(value = "stationId") String stationId, @RequestParam(value = "equipName") String equipName
// ) {
//
// @ApiOperation(value = "汇流箱 功率曲线")
// @GetMapping("/hlWindSpeeds")
// public ResponseModel<Map<String, Object>> hlWindSpeeds(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "equipNum") String equipNum) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getBoosterGatewayId();
//
// String gatewayId = stationBasic.getFanGatewayId();
//
// Map<String, String> map = monitorFanIndicatorMapper.getMajorBoosterStationInfoBySort(gatewayId, equipName);
// String name = map.get("text").equals("1主变高压侧") || map.get("text").equals("1主变低压侧") ?map.get("text").substring(0,3):map.get("text");
// Map<String, Object> result = monitorFanIndicator.hlWindSpeeds(gatewayId,equipNum);
//
// return ResponseHelper.buildResponse(result);
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "集电线路图右侧 光伏列表")
// @GetMapping("/gfList")
// // @Scheduled(cron = "0/10 * * * * ? ")
// public ResponseModel getListByNbq() {
//
// Map<String, Object> switchUrl = monitorFanIndicatorImpl.getSwitchUrl(gatewayId, name);
// List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId ,"网络",name,null);
// IPage<Map<String, Object>> result = new Page<>();
// switchUrl.put("records",statusMonitoring);
// switchUrl.put("current",1);
// switchUrl.put("total",100);
// List<Map<String, Object>> data = new ArrayList<>();
// data.add(switchUrl);
// result.setRecords(data);
// result.setCurrent(1);
// result.setTotal(100);
//
// try {
// emqKeeper.getMqttClient().publish(stationId+"/switch/"+equipName, JSON.toJSONString(result).getBytes(),0,false);
// } catch (MqttException e) {
// e.printStackTrace();
// LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
// List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
// for (StationBasic stationBasic : stationBasics) {
// String gatewayId = stationBasic.getFanGatewayId();
// String werks = stationBasic.getStationNumber();
// monitorFanIndicator.getListByNbq(gatewayId,werks,stationBasic.getSequenceNbr().toString());
// }
//
//
// return CommonResponseUtil.success();
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "1#主变油温")
// @GetMapping("/zbyw")
// public ResponseModel<Map<String,Object>> getYwData(@RequestParam(value = "stationId") String stationId) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getBoosterGatewayId();
// Map<String,Object> resultsData = monitorFanIndicatorImpl.getyw( gatewayId);
// return ResponseHelper.buildResponse(resultsData);
//
// @ApiOperation(value = "风机-三维告警")
// @GetMapping("/partofWaring3D")
// public ResponseModel<Map<String, Object>> partofWaring3D(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "equipNum") String equipNum) {
// Map<String, Object> result = monitorFanIndicator.partofWaring3D(stationId,equipNum);
// return ResponseHelper.buildResponse(result);
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "光伏-总概览")
@GetMapping("/solarPowerOverview")
......@@ -706,9 +841,8 @@ public class MonitorFanIdxController extends BaseController {
columnMap.put("辐照强度", String.format("%.2f", commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")));
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy");
String monthy= myFmt2.format(new Date());
SimpleDateFormat myFmt2 = new SimpleDateFormat("yyyy");
String monthy = myFmt2.format(new Date());
QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
wrapper.select(" monthly ,sum(value) value ");
wrapper.eq("year", monthy);
......@@ -716,11 +850,10 @@ public class MonitorFanIdxController extends BaseController {
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper);
Double sumValue = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("value") : 0;
columnMap.put("年发电量完成率(%)", String.format("%.2f", Double.parseDouble(columnMap.get("年发电量").toString())/sumValue*100));
columnMap.put("年发电量完成率(%)", String.format("%.2f", Double.parseDouble(columnMap.get("年发电量").toString()) / sumValue * 100));
columnMap.put("总辐射累计", String.format("%.2f",commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计")));
columnMap.put("总辐射累计", String.format("%.2f", commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计")));
//综合效率 = 发电量/理论发电量
......@@ -734,7 +867,6 @@ public class MonitorFanIdxController extends BaseController {
}
String json = null;
try {
json = IOUtils.toString(overviewGF.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
......@@ -801,36 +933,6 @@ public class MonitorFanIdxController extends BaseController {
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "详情基础信息")
// @GetMapping("/getEquipInfoByEquipNum")
// public ResponseModel<Map<String,Object>> getEquipInfoByEquipNum(@RequestParam(value = "equipNum", required = false) String equipNum,
// @RequestParam(value = "stationId", required = false) String stationId) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// return ResponseHelper.buildResponse(monitorFanIndicator.getEquipInfoByEquipNum(gatewayId,equipNum ));
// }
//
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "光伏左侧资源树")
// @GetMapping("/getEquipTree")
// public ResponseModel<IPage<Map<String, Object>>> getEquipTree(@RequestParam(value = "stationId", required = false) String stationId,
// @RequestParam(value = "frontModule", required = false) String frontModule,
// @RequestParam(value = "equipmentNumber", required = false) String equipmentNumber
// ) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// List<Map<String, Object>> equipmentNum = monitorFanIndicator.getEquipmentNum(gatewayId, frontModule, equipmentNumber);
// IPage<Map<String, Object>> result = new Page<>();
// result.setRecords(equipmentNum);
// result.setCurrent(1);
// result.setTotal(equipmentNum.size());
// return ResponseHelper.buildResponse(result);
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "详情基础信息")
@GetMapping("/getStatisticsInfo")
......@@ -856,107 +958,6 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(statisticsInfo);
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "码速表")
// @GetMapping("/SpeedIndicator")
// public ResponseModel<Map<String,Object>> SpeedIndicator(@RequestParam(value = "equipNum", required = false) String equipNum,
// @RequestParam(value = "stationId", required = false) String stationId,
// @RequestParam(value = "equipmentIndexName", required = false) String equipmentIndexName
// ) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// return ResponseHelper.buildResponse(monitorFanIndicator.SpeedIndicator(gatewayId,equipNum,equipmentIndexName ));
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "箱变实时开关状态")
// @GetMapping("/equipSwitchStatus")
// // @Scheduled(cron = "0/10 * * * * ? ")
// public ResponseModel<Map<String,Object>> getEquipSwitchStatus() {
//
//
// LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
// List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
// for (StationBasic stationBasic : stationBasics) {
// String fanGatewayId = stationBasic.getFanGatewayId();
// monitorFanIndicatorImpl.getEquipSwitchStatus(stationBasic);
// }
//
// return CommonResponseUtil.success();
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "汇流箱支路电流离散率")
// @GetMapping("/collectingBox")
// public ResponseModel<ResultsData> collectingBox(@RequestParam(value = "current") int current,
// @RequestParam(value = "size") int size,
// @RequestParam(value = "stationId") String stationId) {
//
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
// return ResponseHelper.buildResponse(monitorFanIndicatorImpl.collectingBox(gatewayId,current, size ));
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "光伏 运行列表")
// @GetMapping("/solarPowerOperation")
// public ResponseModel<IPage<Map<String, Object>>> solarPowerOperation(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "current") int current, int size) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
//
// List<Map<String, Object>> statusMonitoring = monitorFanIndicator.solarPowerOperation(gatewayId);
// List<Map<String, Object>> collect = statusMonitoring.stream()
// .skip((long) (current - 1) * size)
// .limit(size)
// .collect(Collectors.toList());
// IPage<Map<String,Object>> result = new Page<>();
// result.setRecords(collect);
// result.setCurrent(current);
// result.setTotal(statusMonitoring.size());
// return ResponseHelper.buildResponse(result);
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "汇流箱 功率曲线")
// @GetMapping("/hlWindSpeeds")
// public ResponseModel<Map<String, Object>> hlWindSpeeds(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "equipNum") String equipNum) {
// StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// String gatewayId = stationBasic.getFanGatewayId();
//
// Map<String, Object> result = monitorFanIndicator.hlWindSpeeds(gatewayId,equipNum);
//
// return ResponseHelper.buildResponse(result);
// }
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "集电线路图右侧 光伏列表")
// @GetMapping("/gfList")
// // @Scheduled(cron = "0/10 * * * * ? ")
// public ResponseModel getListByNbq() {
//
//
// LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
// List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
// for (StationBasic stationBasic : stationBasics) {
// String gatewayId = stationBasic.getFanGatewayId();
// String werks = stationBasic.getStationNumber();
// monitorFanIndicator.getListByNbq(gatewayId,werks,stationBasic.getSequenceNbr().toString());
// }
//
//
// return CommonResponseUtil.success();
// }
//
// @ApiOperation(value = "风机-三维告警")
// @GetMapping("/partofWaring3D")
// public ResponseModel<Map<String, Object>> partofWaring3D(@RequestParam(value = "stationId")String stationId,@RequestParam(value = "equipNum") String equipNum) {
// Map<String, Object> result = monitorFanIndicator.partofWaring3D(stationId,equipNum);
// return ResponseHelper.buildResponse(result);
// }
@ApiOperation(value = "电站排名")
@Scheduled(cron = "0/10 * * * * ? ")
@GetMapping("/stationRanking")
......@@ -1021,12 +1022,10 @@ public class MonitorFanIdxController extends BaseController {
return CommonResponseUtil.success();
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "电站排名")
@GetMapping("/stationRankingtype")
public ResponseModel stationRanking(String day,String type,String areaCode ) {
public ResponseModel stationRanking(String day, String type, String areaCode) {
// LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
......@@ -1121,18 +1120,11 @@ public class MonitorFanIdxController extends BaseController {
// }
return CommonResponseUtil.success(monitorService.stationRanking(day,type,areaCode));
return CommonResponseUtil.success(monitorService.stationRanking(day, type, areaCode));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "运维数据 ")
@GetMapping("/operationData")
......@@ -1162,6 +1154,12 @@ public class MonitorFanIdxController extends BaseController {
// result.setTotal(mapList.size());
return ResponseHelper.buildResponse(monitorService.operationData(areaCode));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全国新能源接入情况 ")
@GetMapping("/getAccessSituation")
public ResponseModel<Map<String, Object>> getAccessSituation(@RequestParam(value = "areaCode", required = false) String areaCode) {
return ResponseHelper.buildResponse(monitorService.getAccessSituation(areaCode));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "社会贡献 ")
......@@ -1226,7 +1224,7 @@ public class MonitorFanIdxController extends BaseController {
// list3.add(stringHashMap16);
// page3.setRecords(list3);
return ResponseHelper.buildResponse( monitorService.socialContribution(areaCode));
return ResponseHelper.buildResponse(monitorService.socialContribution(areaCode));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -1241,7 +1239,7 @@ public class MonitorFanIdxController extends BaseController {
BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
List<QueryBuilder> should = boolMustAll.should();
String[] keys = new String[]{"日发电量", "月发电量", "年发电量","有功功率"};
String[] keys = new String[]{"日发电量", "月发电量", "年发电量", "有功功率"};
List<String> list = Arrays.asList(keys);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if (!stationBasic.getStationType().equals("FDZ")) {
......@@ -1286,9 +1284,9 @@ public class MonitorFanIdxController extends BaseController {
for (ESEquipments equip : resultMap.get(key)) {
String value = String.format("%.4f", equip.getValueF());
if (stationBasic.getStationType().equals("FDZ")) {
map.put("name", equip.getEquipmentSpecificName().substring(0, equip.getEquipmentSpecificName().indexOf("#"))+"/"+key);
map.put("name", equip.getEquipmentSpecificName().substring(0, equip.getEquipmentSpecificName().indexOf("#")) + "/" + key);
}else{
} else {
map.put("name", key);
}
if (!stationBasic.getStationType().equals("FDZ")) {
......@@ -1303,10 +1301,10 @@ public class MonitorFanIdxController extends BaseController {
case "年发电量":
map.put("yearNum", String.format(CommonConstans.Fourdecimalplaces, Double.valueOf(value) * CommonConstans.pvGenPoweActorCurrentData));
case "有功功率":
map.put("yggl", String.format(CommonConstans.Fourdecimalplaces,Double.valueOf(value)));
map.put("yggl", String.format(CommonConstans.Fourdecimalplaces, Double.valueOf(value)));
}
}else{
} else {
switch (equip.getEquipmentIndexName()) {
case "日发电量":
map.put("dayNum", value);
......@@ -1326,7 +1324,7 @@ public class MonitorFanIdxController extends BaseController {
// map.put("yearNum", value);
// break;
case "有功功率":
map.put("yggl", String.format(CommonConstans.Fourdecimalplaces,Double.valueOf(value)));
map.put("yggl", String.format(CommonConstans.Fourdecimalplaces, Double.valueOf(value)));
}
}
......@@ -1335,7 +1333,7 @@ public class MonitorFanIdxController extends BaseController {
}
if (stationBasic.getStationType().equals("FDZ")) {
this.sortByFeild(esEquipmentsMap, "num");
}else{
} else {
this.sortByFeildString(esEquipmentsMap, "num");
}
......@@ -1358,25 +1356,6 @@ public class MonitorFanIdxController extends BaseController {
}
public static List<Map<String, Object>> sortByFeild(List<Map<String, Object>> list, String feild) {
if (CollectionUtils.isNotEmpty(list)) {
Collections.sort(list, (m1, m2)-> Integer.valueOf(m1.get(feild).toString()).compareTo(Integer.valueOf(m2.get(feild).toString())));
}
return list;
}
public static List<Map<String, Object>> sortByFeildString(List<Map<String, Object>> list, String feild) {
if (CollectionUtils.isNotEmpty(list)) {
Collections.sort(list, (m1, m2)-> String.valueOf(m1.get(feild).toString()).compareTo(String.valueOf(m2.get(feild).toString())));
}
return list;
}
//@Scheduled(cron = "0/10 * * * * ? ")
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "测试方法 ")
......@@ -1431,7 +1410,7 @@ public class MonitorFanIdxController extends BaseController {
@Scheduled(cron = "0/30 * * * * ? ")
@ApiOperation(value = "接入情况 ")
@GetMapping("/accessSituation")
public ResponseModel<Map<String, Object>> accessSituation() {
public ResponseModel accessSituation() {
Map<String, Object> map = monitorService.accessSituation();
// List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
// double sum = list.stream().mapToDouble(l -> Double.parseDouble(l.getInstalledCapacity())).sum();
......@@ -1455,7 +1434,7 @@ public class MonitorFanIdxController extends BaseController {
@Scheduled(cron = "0/30 * * * * ? ")
@ApiOperation(value = "区域接入情况 ")
@GetMapping("/qyAccessSituation")
public ResponseModel<Map<String, Object>> qyAccessSituation() {
public ResponseModel qyAccessSituation() {
monitorService.qyAccessSituation();
// Map<String, Object> map = new LinkedHashMap<>();
// List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
......@@ -1526,8 +1505,8 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "给部盾提供的发电率完成情况接口")
@GetMapping("/getGenPowerInfoForBuDun")
public ResponseModel<Map<String, String>> getGenPowerInfoForBuDun(@RequestParam(required = false) String areaCode,@RequestParam(required = false) String stationId) {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfoForBuDun(areaCode,stationId));
public ResponseModel<Map<String, String>> getGenPowerInfoForBuDun(@RequestParam(required = false) String areaCode, @RequestParam(required = false) String stationId) {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfoForBuDun(areaCode, stationId));
}
......
......@@ -119,4 +119,10 @@ public interface MonitorService {
*/
Map<String, Object> getDetailsWindSpeedAlldataqg();
/**
* 获取接入情况
* @param areaCode
* @return
*/
Map<String, Object> getAccessSituation(String areaCode);
}
......@@ -16,7 +16,6 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationElectricityMeterMapper;
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.entity.IndicatorData;
......@@ -26,23 +25,17 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdanalysismapper.IndicatorDataNewM
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.IOUtils;
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.Value;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
......@@ -79,7 +72,7 @@ public class MonitorServiceImpl implements MonitorService {
List<StationCacheInfoDto> dtos = listMap.get(value.getCode());
map.put("data", dtos == null ? 0 : dtos.size());
map.put("title", dtos == null ? 0 : dtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getInstalledCapacity())).mapToDouble(l -> Double.parseDouble(l.getInstalledCapacity())).sum());
map.put("title",keepTwodecimalPlaces(Double.valueOf(map.get("title").toString())));
map.put("title", keepTwodecimalPlaces(Double.valueOf(map.get("title").toString())));
mapList.add(map);
}
IPage<Map<String, Object>> result = new Page<>();
......@@ -220,9 +213,10 @@ public class MonitorServiceImpl implements MonitorService {
return mapjn;
}
public Map<String,Object> gettimedateyfd( ){
String requestUrl = Constants.BASE_URL + "?" + Constants.get_month_generation_trend_url ;
public Map<String, Object> gettimedateyfd() {
String requestUrl = Constants.BASE_URL + "?" + Constants.get_month_generation_trend_url;
List<String> list = new ArrayList<>();
List<Double> listData = new ArrayList<>();
List<BudunMonthTrendDto> budunMonthTrendDtos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BudunMonthTrendDto.class);
......@@ -235,7 +229,7 @@ public class MonitorServiceImpl implements MonitorService {
mapjn.put("axisData", list);
try {
System.out.println(JSON.toJSONString(mapjn));
emqKeeper.getMqttClient().publish("topic_yfd", JSON.toJSONString(mapjn).getBytes(),0,false);
emqKeeper.getMqttClient().publish("topic_yfd", JSON.toJSONString(mapjn).getBytes(), 0, false);
} catch (MqttException e) {
e.printStackTrace();
}
......@@ -247,11 +241,11 @@ public class MonitorServiceImpl implements MonitorService {
@Override
public Map<String, Object> gettimedateqyyfd(String areaName) {
String requestUrl = Constants.BASE_URL + "?" + Constants.get_generated_quota_trend ;
String requestUrl = Constants.BASE_URL + "?" + Constants.get_generated_quota_trend;
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName));
if (!areaName.contains(Constants.areaChinese)) {
areaName =areaName+ Constants.areaChinese;
requestUrl =requestUrl+ "&areaName=" + areaName;
areaName = areaName + Constants.areaChinese;
requestUrl = requestUrl + "&areaName=" + areaName;
}
List<BundunCompleteDto> bundunCompleteDtoList = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BundunCompleteDto.class);
......@@ -609,7 +603,6 @@ public class MonitorServiceImpl implements MonitorService {
// }
// return mapdta;
// }
@Scheduled(cron = "0/10 * * * * ?")
private void sendQYYXZBMqtt() {
List<CoreValuesDto> coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
......@@ -900,12 +893,11 @@ public class MonitorServiceImpl implements MonitorService {
}
public Map<String, Object> getDetailsWindSpeedAlldataqg() {
public Map<String, Object> getDetailsWindSpeedAlldataqg() {
List<StationCacheInfoDto> stationCacheInfoDtos = getListStationCacheInfoDto();
List<StationCacheInfoDto> stationCacheInfoDtos = getListStationCacheInfoDto();
AtomicReference<Double> installedCapacity = new AtomicReference<>(0.0);
stationCacheInfoDtos.forEach( stationCacheInfoDto-> {
stationCacheInfoDtos.forEach(stationCacheInfoDto -> {
installedCapacity.updateAndGet(v -> v + Double.parseDouble(stationCacheInfoDto.getInstalledCapacity()));
});
Map<String, Object> map = new HashMap<>();
......@@ -915,10 +907,10 @@ public class MonitorServiceImpl implements MonitorService {
Map<String, Object> activePowerInfo = new HashMap<>();
List<IndicatorData> activePowerList = new ArrayList<>();
activePowerList = indicatorDataNewMapper.selectDataByequipmentIndexNameAndtimeqgNew(CommonConstans.ACTIVE_POWER);
Map<String,List<IndicatorData>> stringObjectMap =activePowerList.stream().collect(Collectors.groupingBy(IndicatorData::getDasTime));
Map<String, List<IndicatorData>> stringObjectMap = activePowerList.stream().collect(Collectors.groupingBy(IndicatorData::getDasTime));
stringObjectMap.keySet().stream().forEach(dasTime -> {
time.add(dasTime.split(":")[1]);
Double vl= stringObjectMap.get(dasTime).stream().mapToDouble(IndicatorData::getValueF).sum();
Double vl = stringObjectMap.get(dasTime).stream().mapToDouble(IndicatorData::getValueF).sum();
values.add(String.format(CommonConstans.Twodecimalplaces, vl));
});
......@@ -943,7 +935,7 @@ public class MonitorServiceImpl implements MonitorService {
map.put("axisData", time);
System.out.println(JSON.toJSONString(map));
try {
emqKeeper.getMqttClient().publish( "all_Power_table", JSON.toJSON(map).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("all_Power_table", JSON.toJSON(map).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("all_Power_info", JSON.toJSON(activePowerInfo).toString().getBytes("UTF-8"), 1, true);
} catch (Exception exception) {
exception.printStackTrace();
......@@ -951,7 +943,35 @@ public class MonitorServiceImpl implements MonitorService {
return map;
}
public Map<String, Object> getDetailsWindqy(String s ) {
@Override
public Map<String, Object> getAccessSituation(String areaCode) {
IPage<Map<String, Object>> page = operationData(areaCode);
List<Map<String, Object>> records = page.getRecords();
Map<String, Object> map = new HashMap<>();
if (!CollectionUtils.isEmpty(records)) {
int total = 0;
Double num = 0.0;
for (Map<String, Object> record : records) {
Integer data = (Integer) record.get("data");
total += data;
Double title = (Double)record.get("title");
num += title;
}
map.put("total", total);
map.put("num", String.format("%.2f", num / 1024) + "GW");
if (records.size() >= 3) {
map.put("FDZ", records.get(0).get("data"));
map.put("FDZtitle", records.get(0).get("title"));
map.put("JZSGFDZ", records.get(1).get("data"));
map.put("JZSGFDZtitle", records.get(1).get("title"));
map.put("FBSGFDZ", records.get(2).get("data"));
map.put("FBSGFDZtitle", records.get(2).get("title"));
}
}
return map;
}
public Map<String, Object> getDetailsWindqy(String s) {
List<StationCacheInfoDto> stationCacheInfoDtos = getListStationCacheInfoDto();
AtomicReference<Double> installedCapacity = new AtomicReference<>(0.0);
stationCacheInfoDtos = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getBelongArea().equals(s)).collect(Collectors.toList());
......@@ -960,18 +980,18 @@ public class MonitorServiceImpl implements MonitorService {
});
Map<String, Object> map = new HashMap<>();
List<String> values = new ArrayList<>();
List<String> fanGateWayIds = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getFanGatewayId()!=null).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
List<String> boostGateWayIds = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getBoosterGatewayId()!=null).map(StationCacheInfoDto::getBoosterGatewayId).collect(Collectors.toList());
List<String> fanGateWayIds = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getFanGatewayId() != null).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
List<String> boostGateWayIds = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getBoosterGatewayId() != null).map(StationCacheInfoDto::getBoosterGatewayId).collect(Collectors.toList());
fanGateWayIds.addAll(boostGateWayIds);
String gatewayIds =Optional.ofNullable(fanGateWayIds).orElse(new ArrayList<>()).stream().distinct().collect(Collectors.joining(","));
String gatewayIds = Optional.ofNullable(fanGateWayIds).orElse(new ArrayList<>()).stream().distinct().collect(Collectors.joining(","));
List<String> time = new ArrayList<>();
Map<String, Object> activePowerInfo = new HashMap<>();
List<IndicatorData> activePowerList = new ArrayList<>();
activePowerList = indicatorDataNewMapper.selectDataByequipmentIndexNameAndtimeqgNew(CommonConstans.ACTIVE_POWER,gatewayIds);
Map<String,List<IndicatorData>> stringObjectMap =activePowerList.stream().collect(Collectors.groupingBy(IndicatorData::getDasTime));
activePowerList = indicatorDataNewMapper.selectDataByequipmentIndexNameAndtimeqgNew(CommonConstans.ACTIVE_POWER, gatewayIds);
Map<String, List<IndicatorData>> stringObjectMap = activePowerList.stream().collect(Collectors.groupingBy(IndicatorData::getDasTime));
stringObjectMap.keySet().stream().forEach(dasTime -> {
time.add(dasTime.split(":")[1]);
Double vl= stringObjectMap.get(dasTime).stream().mapToDouble(IndicatorData::getValueF).sum();
Double vl = stringObjectMap.get(dasTime).stream().mapToDouble(IndicatorData::getValueF).sum();
values.add(String.format(CommonConstans.Twodecimalplaces, vl));
});
......@@ -996,8 +1016,8 @@ public class MonitorServiceImpl implements MonitorService {
map.put("seriesData", seriesData);
map.put("axisData", time);
try {
emqKeeper.getMqttClient().publish( s+"_Power_table", JSON.toJSON(map).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(s+"_Power_info", JSON.toJSON(activePowerInfo).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(s + "_Power_table", JSON.toJSON(map).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(s + "_Power_info", JSON.toJSON(activePowerInfo).toString().getBytes("UTF-8"), 1, true);
} catch (Exception exception) {
exception.printStackTrace();
}
......
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