Commit e92810c8 authored by chenzhao's avatar chenzhao

修改代码

parent 279588a9
......@@ -10,6 +10,8 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
import static org.springframework.data.elasticsearch.annotations.DateFormat.*;
/**
* @description:
* @author: tw
......@@ -33,14 +35,15 @@ public class ESEquipments {
private String gatewayId;
@Field(type = FieldType.Text)
private String isAlarm;
@Field(type = FieldType.Date, format = DateFormat.basic_date_time, index = false)
// @Field(type = FieldType.Date, format = custom,pattern = "yyyy-MM-dd HH:mm:ss",index = false)
@Field(type = FieldType.Date, format = basic_date_time,index = false)
private Date createdTime;
@Field(type = FieldType.Text , index = false)
private String unit;
@Field(type = FieldType.Text, index = false)
private String value;
@Field(type = FieldType.Double, index = false)
private Double valueDouble;
@Field(type = FieldType.Float, index = false)
private Float valueDouble;
@Field(type = FieldType.Text , index = false)
private String valueLabel;
@Field(type = FieldType.Text , index = false)
......@@ -59,7 +62,7 @@ public class ESEquipments {
private String displayName;
public ESEquipments(Double valueDouble,String id, String address, String dataType, String equipmentSpecificName, String gatewayId, String isAlarm, Date createdTime, String unit, String value, String valueLabel, String traceId, String equipmentIndexName, String equipmentNumber, String frontModule, String systemType, String pictureName, String displayName) {
public ESEquipments(Float valueDouble,String id, String address, String dataType, String equipmentSpecificName, String gatewayId, String isAlarm, Date createdTime, String unit, String value, String valueLabel, String traceId, String equipmentIndexName, String equipmentNumber, String frontModule, String systemType, String pictureName, String displayName) {
this.valueDouble = valueDouble;
this.id = id;
......
......@@ -286,6 +286,11 @@ public class MonitorFanIdxController extends BaseController {
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 = "";
if (null != areaCode){
List<StationCacheInfoDto> listStationCacheInfoDto = commonService.getListStationCacheInfoDto();
List<String> collect = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
gatewayId = String.join(",", collect);
}
if (null != stationId){
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
gatewayId = stationBasic.getBoosterGatewayId();
......@@ -736,7 +741,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "详情基础信息")
@GetMapping("/getStatisticsInfo")
public ResponseModel<Map<String,String>> getStatisticsInfo(@RequestParam(value = "equipmentIndexName", required = false) String equipmentIndexName,
public ResponseModel<Map<String,Object>> getStatisticsInfo(@RequestParam(value = "equipmentIndexName", required = false) String equipmentIndexName,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "stationType", required = false) String stationType) {
String gatewayId = "";
......@@ -747,8 +752,15 @@ public class MonitorFanIdxController extends BaseController {
gatewayId = stationBasic.getBoosterGatewayId();
}
}
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto();
double sum = 0.0;
sum =list.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getInstalledCapacity())).mapToDouble(l->Double.parseDouble(l.getInstalledCapacity())).sum();
return ResponseHelper.buildResponse(monitorFanIndicator.getStatisticsInfo(gatewayId,equipmentIndexName ));
Map<String, Object> statisticsInfo = monitorFanIndicator.getStatisticsInfo(gatewayId, equipmentIndexName);
double v = Double.parseDouble( statisticsInfo.get("mean").toString());
String load = String.format("%.2f", v / sum);
statisticsInfo.put("load",load);
return ResponseHelper.buildResponse(statisticsInfo);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -853,7 +865,7 @@ public class MonitorFanIdxController extends BaseController {
}
@ApiOperation(value = "电站排名")
// @Scheduled(cron = "0/10 * * * * ? ")
@Scheduled(cron = "0/10 * * * * ? ")
@GetMapping("/stationRanking")
public ResponseModel stationRanking() {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
......@@ -919,11 +931,13 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "运维数据 ")
@GetMapping("/operationData")
public ResponseModel<IPage<Map<String,Object>>> operationData() {
public ResponseModel<IPage<Map<String,Object>>> operationData(@RequestParam(value = "areaCode", required = false)String areaCode) {
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto();
if (null != areaCode){
list = list.stream().filter(e->e.getAreaCode().equals(areaCode)).collect(Collectors.toList());
}
List<Map<String,Object>> mapList = new ArrayList<>();
Map<String, List<StationCacheInfoDto>> listMap = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getStationType, Collectors.toList()));
......@@ -941,8 +955,6 @@ public class MonitorFanIdxController extends BaseController {
result.setRecords(mapList);
result.setCurrent(1);
result.setTotal(mapList.size());
return ResponseHelper.buildResponse(result);
}
......@@ -957,14 +969,15 @@ public class MonitorFanIdxController extends BaseController {
map.put("equipmentIndexName.keyword",value);
if (null != areaCode){
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
List<String> collect = listStationCacheInfoDto.stream().filter(e -> e.getBelongArea().equals(areaCode)).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
map.put("gateWayId",collect);
List<String> collect = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
map.put("gatewayId.keyword",collect);
}
List<? extends Terms.Bucket> lidate= commonService.getgroupsum(map,"valueDouble" ,"equipmentIndexName.keyword", ESEquipments.class);
DecimalFormat format2 = new DecimalFormat("#.0000");
Double num = 0.00;
if (map.containsKey("gateWayId")&&map.get("gateWayId").size() > 0){
for (Terms.Bucket bucket : lidate) {
Aggregations aggregation= bucket.getAggregations();
List<Aggregation> listdata= Objects.nonNull(aggregation)?aggregation.asList():null;
......@@ -973,7 +986,7 @@ public class MonitorFanIdxController extends BaseController {
num = Double.valueOf(format2.format(parsedSum.getValue()));
}
}
}
return ResponseHelper.buildResponse(commonService.getSocialContributionDtoList(num));
}
......@@ -1105,5 +1118,57 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@Scheduled(cron = "0 0/10 * * * ? ")
@ApiOperation(value = "接入情况 ")
@GetMapping("/accessSituation")
public ResponseModel<Map<String,Object>> accessSituation(){
Map<String, Object> map = new LinkedHashMap<>();
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto();
double sum = list.stream().mapToDouble(l -> Double.parseDouble(l.getInstalledCapacity())).sum();
Map<String, List<StationCacheInfoDto>> listMap = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getStationType, Collectors.toList()));
for (StationType value : StationType.values()) {
List<StationCacheInfoDto> dtos = listMap.get(value.getCode());
map.put(value.getCode(),dtos == null ? 0 :dtos.size());
map.put(value.getCode()+"title",dtos == null ? 0 :dtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getInstalledCapacity())).mapToDouble(l->Double.parseDouble(l.getInstalledCapacity())).sum());
}
map.put("total",list.size());
map.put("num",sum);
try {
emqKeeper.getMqttClient().publish("/accessSituation/topic",JSON.toJSONString(map).getBytes(),0,false);
} catch (MqttException e) {
}
return ResponseHelper.buildResponse(map);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@Scheduled(cron = "0 0/10 * * * ? ")
@ApiOperation(value = "区域接入情况 ")
@GetMapping("/qyAccessSituation")
public ResponseModel<Map<String,Object>> qyAccessSituation(){
Map<String, Object> map = new LinkedHashMap<>();
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode));
for (String s : belongAreaList.keySet()) {
double sum = belongAreaList.get(s).stream().mapToDouble(l -> Double.parseDouble(l.getInstalledCapacity())).sum();
Map<String, List<StationCacheInfoDto>> listMap = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getStationType, Collectors.toList()));
for (StationType value : StationType.values()) {
List<StationCacheInfoDto> dtos = listMap.get(value.getCode());
map.put(value.getCode(),dtos == null ? 0 :dtos.size());
map.put(value.getCode()+"title",dtos == null ? 0 :dtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getInstalledCapacity())).mapToDouble(l->Double.parseDouble(l.getInstalledCapacity())).sum());
}
map.put("total",list.size());
map.put("num",sum);
try {
emqKeeper.getMqttClient().publish("/accessSituation/topic/"+"s",JSON.toJSONString(map).getBytes(),0,false);
} catch (MqttException e) {
}
}
return ResponseHelper.buildResponse(map);
}
}
......@@ -53,7 +53,7 @@ public class StationCacheDataInit implements CommandLineRunner {
stationCacheInfoDto.setStationType(stationBasic.getStationType());
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[","").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getAreaCode()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setAreaCode(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getAreaCode()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f",sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId",stationBasic.getFanGatewayId()));
......
......@@ -14,7 +14,7 @@ public interface TemporaryDataMapper extends BaseMapper<TemporaryData> {
List<Map<String, String>> timingTemporarysSorageData (@RequestParam(value ="gatewayId" ) String gatewayId);
Map<String, String> getStatisticsInfo (@RequestParam(value ="gatewayId" ) String gatewayId,
Map<String, Object> getStatisticsInfo (@RequestParam(value ="gatewayId" ) String gatewayId,
@RequestParam(value ="equipmentIndexName" ) String equipmentIndexName);
......
......@@ -53,7 +53,7 @@ public class LargeScreenImpl {
/**
* 全国
*/
@Scheduled(cron = "0/10 * * * * ?")
//@Scheduled(cron = "0/10 * * * * ?")
public Map<String, Double> getqg() {
Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d);
......@@ -154,10 +154,10 @@ public class LargeScreenImpl {
}
@Scheduled(cron = "0/10 * * * * ?")
// @Scheduled(cron = "0/10 * * * * ?")
private void sendQYYXZBMqtt(){
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode));
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());
getqy(ids,s);
......@@ -315,7 +315,7 @@ public class LargeScreenImpl {
@Scheduled(cron = "0/10 * * * * ?")
private void sendQYFDLMqtt(){
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode));
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());
getSeriesDataqy(new Date(),ids,s);
......@@ -377,7 +377,7 @@ public class LargeScreenImpl {
value1.add(monthy);
map.put("moon.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day.keyword",ESEquipments.class);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueDouble" ,"day.keyword",ESEquipments.class);
Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
......@@ -426,7 +426,7 @@ public class LargeScreenImpl {
value1.add(monthy);
map.put("moon.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day.keyword",ESEquipments.class);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueDouble" ,"day.keyword",ESEquipments.class);
Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
......
......@@ -1460,7 +1460,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return resultMap;
}
public Map<String, String> getStatisticsInfo(String gatewayId ,String equipmentIndexName){
public Map<String, Object> getStatisticsInfo(String gatewayId ,String equipmentIndexName){
return temporaryDataMapper.getStatisticsInfo(gatewayId,equipmentIndexName);
}
......@@ -1758,7 +1758,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public void sendMqttByRanking( List< Map<String,Object>> list,String code,String topic){
//先发送区域消息
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getBelongArea));
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());
String idStrings = String.join(",", ids);
......@@ -1769,7 +1769,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
result.setCurrent(1);
result.setTotal(resultList.size());
try {
emqKeeper.getMqttClient().publish(s+"/"+topic+"/"+code,JSON.toJSONString(result).getBytes(),0,false);
emqKeeper.getMqttClient().publish(topic+"/"+code+"/"+s,JSON.toJSONString(result).getBytes(),0,false);
} catch (MqttException e) {
e.printStackTrace();
}
......
......@@ -12,7 +12,7 @@
`temporary_data`
<where>
<if test="gatewayId != null and gatewayId != ''">
gatewayId = #{gatewayId}
gatewayId in( ${gatewayId})
</if>
<if test="gatewayId == null or gatewayId == ''">
equipmentNumber is not null and equipmentIndexName is not null
......
......@@ -39,8 +39,8 @@ public class ESEquipments {
private String unit;
@Field(type = FieldType.Text, index = false)
private String value;
@Field(type = FieldType.Double, index = false)
private Double valueDouble;
@Field(type = FieldType.Float, index = false)
private Float valueDouble;
@Field(type = FieldType.Text , index = false)
private String valueLabel;
@Field(type = FieldType.Text , index = false)
......@@ -59,7 +59,7 @@ public class ESEquipments {
private String displayName;
public ESEquipments(Double valueDouble,String id, String address, String dataType, String equipmentSpecificName, String gatewayId, String isAlarm, Date createdTime, String unit, String value, String valueLabel, String traceId, String equipmentIndexName, String equipmentNumber, String frontModule, String systemType, String pictureName, String displayName) {
public ESEquipments(Float valueDouble,String id, String address, String dataType, String equipmentSpecificName, String gatewayId, String isAlarm, Date createdTime, String unit, String value, String valueLabel, String traceId, String equipmentIndexName, String equipmentNumber, String frontModule, String systemType, String pictureName, String displayName) {
this.valueDouble = valueDouble;
this.id = id;
......
......@@ -175,7 +175,7 @@ public class DemoController extends BaseController {
@GetMapping("/test4")
public ResponseModel<Integer> demoTest3() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801435891929089","1669524885619085313"};
String [] strings = {"1668801435891929089","1669524885619085313","1668801570352926721","1669525017559306241"};
// String [] strings = {"1669524885619085313"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
......@@ -195,7 +195,7 @@ public class DemoController extends BaseController {
for (MonitorFanIndicator monitorFanIndicator : list) {
ESEquipments eSEquipments=new ESEquipments(
3.55,
null,
monitorFanIndicator.getAddressGateway(),
monitorFanIndicator.getIndexAddress(),
monitorFanIndicator.getDataType(),
......@@ -212,7 +212,7 @@ public class DemoController extends BaseController {
monitorFanIndicator.getFrontModule(),
monitorFanIndicator.getSystemType(),
monitorFanIndicator.getPictureName(),
"" );
monitorFanIndicator.getEquipmentNumber());
listit.add(eSEquipments);
......@@ -289,7 +289,7 @@ public class DemoController extends BaseController {
ESEquipments eSEquipments=new ESEquipments(
3.55,
null,
monitorFanIndicator.getAddressGateway(),
monitorFanIndicator.getIndexAddress(),
monitorFanIndicator.getDataType(),
......@@ -395,7 +395,7 @@ public class DemoController extends BaseController {
@ApiOperation(value = "分组求和数")
@GetMapping("/test10")
public SearchHits demoTest10() {
QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "有功功率");
QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "年发电量");
......@@ -490,14 +490,13 @@ public class DemoController extends BaseController {
public Map demoTest14() {
List<String> value=new ArrayList<>();
value.add(ss);
value.add(zfs);
value.add(zfslj);
value.add("年发电量");
Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value);
// List<String> value1=new ArrayList<>();
// value1.add("1668801435891929089");
// map.put("gatewayId.keyword",value1);
List<String> value1=new ArrayList<>();
value1.add("1668801435891929089");
map.put("gatewayId.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueDouble" ,"equipmentIndexName.keyword",ESEquipments.class);
......
......@@ -259,7 +259,7 @@ 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 = false)String stationId,@RequestParam(value = "type", required = false)String type) {
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 = "";
if (null != stationId){
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
......@@ -268,6 +268,7 @@ public class MonitorFanIdxController extends BaseController {
gatewayId = stationBasic.getFanGatewayId();
}
}
Map<String, Object> detailsWindSpeed = monitorFanIndicator.getDetailsWindSpeedAll(gatewayId);
return ResponseHelper.buildResponse(detailsWindSpeed);
......
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