Commit bb5b0b23 authored by caotao's avatar caotao

监盘方法优化

parent d9577110
package com.yeejoin.amos.boot.module.jxiop.biz.dto; package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
...@@ -25,4 +24,6 @@ public class StationCacheInfoDto implements Serializable { ...@@ -25,4 +24,6 @@ public class StationCacheInfoDto implements Serializable {
private String fanGatewayId; private String fanGatewayId;
//升压站网关 //升压站网关
private String boosterGatewayId; private String boosterGatewayId;
//片区code
private String areaCode;
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.extra.pinyin.PinyinUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
...@@ -33,6 +38,7 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -33,6 +38,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -56,6 +62,11 @@ public class CommonServiceImpl { ...@@ -56,6 +62,11 @@ public class CommonServiceImpl {
@Autowired @Autowired
private StationBasicMapper stationBasicMapper; private StationBasicMapper stationBasicMapper;
@Resource
private RegionMapper regionMapper;
@Resource
private MapRegionMapper mapRegionMapper;
/** /**
* 带参数 求平均值 * 带参数 求平均值
*/ */
...@@ -178,6 +189,13 @@ public class CommonServiceImpl { ...@@ -178,6 +189,13 @@ public class CommonServiceImpl {
return value; return value;
} }
/**
* @deprecated 获取场站的设备总数
* @param queryDto
* @param keysum
* @param clas
* @return
*/
public Integer getCount(List<QueryDto> queryDto, String keysum, Class clas) { public Integer getCount(List<QueryDto> queryDto, String keysum, Class clas) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
for (QueryDto dto : queryDto) { for (QueryDto dto : queryDto) {
...@@ -225,7 +243,6 @@ public class CommonServiceImpl { ...@@ -225,7 +243,6 @@ public class CommonServiceImpl {
return Double.valueOf(String.format("%.2f", totalvalue)); return Double.valueOf(String.format("%.2f", totalvalue));
} }
public Double getNumByIndicatior(String gatewayId, String indicator) { public Double getNumByIndicatior(String gatewayId, String indicator) {
String sql = "SELECT * FROM indicators_" + gatewayId + " where equipmentIndexName=~/" + indicator + "$/"; String sql = "SELECT * FROM indicators_" + gatewayId + " where equipmentIndexName=~/" + indicator + "$/";
Double totalvalue = 0.00; Double totalvalue = 0.00;
...@@ -256,6 +273,12 @@ public class CommonServiceImpl { ...@@ -256,6 +273,12 @@ public class CommonServiceImpl {
return Double.valueOf(String.format("%.2f", avageValue)); return Double.valueOf(String.format("%.2f", avageValue));
} }
/**
*
* @param mapList 查询出来的influxdb数据
* @param indicator 指标名称
* @return 该指标的求和数据
*/
public Double getTotalByIndicatior(List<Map<String, Object>> mapList, String indicator) { public Double getTotalByIndicatior(List<Map<String, Object>> mapList, String indicator) {
Double totalvalue = 0.0000; Double totalvalue = 0.0000;
try { try {
...@@ -281,10 +304,21 @@ public class CommonServiceImpl { ...@@ -281,10 +304,21 @@ public class CommonServiceImpl {
return Double.valueOf(String.format("%.2f", avageValue)); return Double.valueOf(String.format("%.2f", avageValue));
} }
/**
* 根据场站Number获取装机容量
* @param WERKS
* @return
*/
public Double getStationCapactityByStationWerks(String WERKS) { public Double getStationCapactityByStationWerks(String WERKS) {
return sjglZsjZsbtzMapper.getStationCapactityByStationWerks(WERKS); return sjglZsjZsbtzMapper.getStationCapactityByStationWerks(WERKS);
} }
/**
* @deprecated 根据发电量获取社会贡献
* @param totalSocialContribution
* @return
*/
public Page<SocialContributionDto> getSocialContributionDtoList(Double totalSocialContribution) { public Page<SocialContributionDto> getSocialContributionDtoList(Double totalSocialContribution) {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>(); Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>(); List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
...@@ -327,12 +361,40 @@ public class CommonServiceImpl { ...@@ -327,12 +361,40 @@ public class CommonServiceImpl {
return socialContributionDtoPage; return socialContributionDtoPage;
} }
/**
* @deprecated 获取缓存场站信息数据
* @return 缓存的场站信息
*/
public List<StationCacheInfoDto> getListStationCacheInfoDto() { public List<StationCacheInfoDto> getListStationCacheInfoDto() {
List<StationCacheInfoDto> stationCacheInfoDtoList = redisTemplate.opsForList().range("station_info_cache", 0, -1); List<StationCacheInfoDto> stationCacheInfoDtoList = redisTemplate.opsForList().range("station_info_cache", 0, -1);
if (ObjectUtils.isEmpty(stationCacheInfoDtoList)) { if (ObjectUtils.isEmpty(stationCacheInfoDtoList)) {
try { try {
stationCacheDataInit.run(); List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
stationCacheInfoDtoList = redisTemplate.opsForList().range("station_info_cache", 0, -1); List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> {
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName());
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.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()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword","有功功率"));
if(!stationBasic.getStationType().equals("FDZ")){
queryDtoList.add(new QueryDto("frontModule","逆变器"));
}
stationCacheInfoDto.setEquipmentNumbers(this.getCount(queryDtoList,"equipmentNumber.Keyword", ESEquipments.class).toString());
stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
stationCacheInfoDtos.add(stationCacheInfoDto);
});
redisTemplate.opsForList().leftPushAll("station_info_cache",stationCacheInfoDtos);
return stationCacheInfoDtos;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -340,13 +402,36 @@ public class CommonServiceImpl { ...@@ -340,13 +402,36 @@ public class CommonServiceImpl {
return stationCacheInfoDtoList; return stationCacheInfoDtoList;
} }
/**
* @deprecated 根据场站id获取缓存数据中的场站对象
* @param stationId 场站id
* @return 缓存的场站对象
*/
public StationCacheInfoDto getStationCacheInfoDtoByStationId(String stationId) { public StationCacheInfoDto getStationCacheInfoDtoByStationId(String stationId) {
StationCacheInfoDto stationCacheInfoDto = this.getListStationCacheInfoDto().stream().filter(stationCacheInfoDto1 -> stationCacheInfoDto1.getStationId().equals(stationId)).collect(Collectors.toList()).get(0); StationCacheInfoDto stationCacheInfoDto = this.getListStationCacheInfoDto().stream().filter(stationCacheInfoDto1 -> stationCacheInfoDto1.getStationId().equals(stationId)).collect(Collectors.toList()).get(0);
return stationCacheInfoDto; return stationCacheInfoDto;
} }
/**
* @deprecated 根据场站id获取场站的首字母缩写
* @param stationid 场站id
* @return 返回该场站的名称拼音缩写
*/
public String getFanDevicePrefix(String stationid) { public String getFanDevicePrefix(String stationid) {
StationBasic stationBasic = stationBasicMapper.selectById(stationid); StationBasic stationBasic = stationBasicMapper.selectById(stationid);
return PinyinUtil.getFirstLetter(stationBasic.getStationName().split("风")[0], "").toUpperCase(Locale.ROOT); return PinyinUtil.getFirstLetter(stationBasic.getStationName().split("风")[0], "").toUpperCase(Locale.ROOT);
} }
/**
* @deprecated 将查询条件进行组装
* @param searchCondtionMap 需要查询的数据的 条件map
* @return List<QueryDto> QueryDtolist 用于给传值
*/
public List<QueryDto> getQueryDtoList(Map<String,String> searchCondtionMap){
List<QueryDto> result = new ArrayList<>();
searchCondtionMap.keySet().forEach(s -> {
result.add(new QueryDto(s,searchCondtionMap.get(s)));
});
return result;
}
} }
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