Commit 8d245eb1 authored by caotao's avatar caotao

修改监盘大屏区域不显示运维信息问题,代码新增健壮性

parent a938cd3b
...@@ -88,8 +88,6 @@ public class MonitorFanIdxController extends BaseController { ...@@ -88,8 +88,6 @@ public class MonitorFanIdxController extends BaseController {
@Value("classpath:/json/overviewGF.json") @Value("classpath:/json/overviewGF.json")
private Resource overviewGF; private Resource overviewGF;
@Autowired
CommonServiceImpl commonService;
@Value("${fan.statuts.stattuspath}") @Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix; private String fanStatusImagePathPrefix;
...@@ -233,18 +231,18 @@ public class MonitorFanIdxController extends BaseController { ...@@ -233,18 +231,18 @@ public class MonitorFanIdxController extends BaseController {
Map<String, Object> columnMap = new HashMap<>(); Map<String, Object> columnMap = new HashMap<>();
for (String column : columnList) { for (String column : columnList) {
Double result = commonService.getTotalByIndicatior(gatewayId, column); Double result = commonServiceImpl.getTotalByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f",result)); columnMap.put(column, String.format("%.2f",result));
} }
for (String column : columnLists) { for (String column : columnLists) {
Double result = commonService.getAvgvalueByIndicatior(gatewayId, column); Double result = commonServiceImpl.getAvgvalueByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f",result)); columnMap.put(column, String.format("%.2f",result));
} }
String num = monitorFanIndicator.getFJCount(gatewayId); String num = monitorFanIndicator.getFJCount(gatewayId);
columnMap.put("风机台数",num); columnMap.put("风机台数",num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber()); Double capacityl = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量",String.format("%.2f",capacityl)); columnMap.put("装机容量",String.format("%.2f",capacityl));
String json = null; String json = null;
...@@ -287,7 +285,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -287,7 +285,7 @@ public class MonitorFanIdxController extends BaseController {
,@RequestParam(value = "areaCode", required = false)String areaCode) { ,@RequestParam(value = "areaCode", required = false)String areaCode) {
String gatewayId = ""; String gatewayId = "";
if (null != areaCode){ if (null != areaCode){
List<StationCacheInfoDto> listStationCacheInfoDto = commonService.getListStationCacheInfoDto(); List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
List<String> collect = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList()); List<String> collect = listStationCacheInfoDto.stream().filter(e -> e.getAreaCode().equals(areaCode)).map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
gatewayId = String.join(",", collect); gatewayId = String.join(",", collect);
} }
...@@ -621,23 +619,23 @@ public class MonitorFanIdxController extends BaseController { ...@@ -621,23 +619,23 @@ public class MonitorFanIdxController extends BaseController {
for (String column : columnList) { for (String column : columnList) {
Double result = commonService.getTotalByIndicatior(gatewayId, column); Double result = commonServiceImpl.getTotalByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f",result)); columnMap.put(column, String.format("%.2f",result));
} }
for (String column : syLists) { for (String column : syLists) {
Double result = commonService.getNumByIndicatior(boosterGatewayId, column); Double result = commonServiceImpl.getNumByIndicatior(boosterGatewayId, column);
columnMap.put(column, String.format("%.2f",result)); columnMap.put(column, String.format("%.2f",result));
} }
for (String column : columnLists) { for (String column : columnLists) {
Double result = commonService.getAvgvalueByIndicatior(gatewayId, column); Double result = commonServiceImpl.getAvgvalueByIndicatior(gatewayId, column);
columnMap.put(column, String.format("%.2f",result)); columnMap.put(column, String.format("%.2f",result));
} }
String num = monitorFanIndicator.getFJCount(gatewayId); String num = monitorFanIndicator.getFJCount(gatewayId);
columnMap.put("逆变器台数",num); columnMap.put("逆变器台数",num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber()); Double capacityl = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量",String.format("%.2f",capacityl)); columnMap.put("装机容量",String.format("%.2f",capacityl));
String json = null; String json = null;
...@@ -752,7 +750,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -752,7 +750,7 @@ public class MonitorFanIdxController extends BaseController {
gatewayId = stationBasic.getBoosterGatewayId(); gatewayId = stationBasic.getBoosterGatewayId();
} }
} }
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto(); List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
double sum = 0.0; double sum = 0.0;
sum =list.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getInstalledCapacity())).mapToDouble(l->Double.parseDouble(l.getInstalledCapacity())).sum(); sum =list.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getInstalledCapacity())).mapToDouble(l->Double.parseDouble(l.getInstalledCapacity())).sum();
...@@ -934,9 +932,9 @@ public class MonitorFanIdxController extends BaseController { ...@@ -934,9 +932,9 @@ public class MonitorFanIdxController extends BaseController {
public ResponseModel<IPage<Map<String,Object>>> operationData(@RequestParam(value = "areaCode", required = false)String areaCode) { public ResponseModel<IPage<Map<String,Object>>> operationData(@RequestParam(value = "areaCode", required = false)String areaCode) {
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto(); List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
if (null != areaCode){ if (null != areaCode){
list = list.stream().filter(e->e.getAreaCode().equals(areaCode)).collect(Collectors.toList()); list = list.stream().filter(e->e.getAreaCode().toUpperCase(Locale.ROOT).equals(areaCode.toUpperCase(Locale.ROOT))).collect(Collectors.toList());
} }
List<Map<String,Object>> mapList = new ArrayList<>(); List<Map<String,Object>> mapList = new ArrayList<>();
Map<String, List<StationCacheInfoDto>> listMap = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getStationType, Collectors.toList())); Map<String, List<StationCacheInfoDto>> listMap = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getStationType, Collectors.toList()));
...@@ -973,7 +971,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -973,7 +971,7 @@ public class MonitorFanIdxController extends BaseController {
map.put("gatewayId.keyword",collect); map.put("gatewayId.keyword",collect);
} }
List<? extends Terms.Bucket> lidate= commonService.getgroupsum(map,"valueDouble" ,"equipmentIndexName.keyword", ESEquipments.class); List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueDouble" ,"equipmentIndexName.keyword", ESEquipments.class);
DecimalFormat format2 = new DecimalFormat("#.0000"); DecimalFormat format2 = new DecimalFormat("#.0000");
Double num = 0.00; Double num = 0.00;
...@@ -987,7 +985,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -987,7 +985,7 @@ public class MonitorFanIdxController extends BaseController {
} }
} }
} }
return ResponseHelper.buildResponse(commonService.getSocialContributionDtoList(num)); return ResponseHelper.buildResponse(commonServiceImpl.getSocialContributionDtoList(num));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
...@@ -1124,7 +1122,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -1124,7 +1122,7 @@ public class MonitorFanIdxController extends BaseController {
@GetMapping("/accessSituation") @GetMapping("/accessSituation")
public ResponseModel<Map<String,Object>> accessSituation(){ public ResponseModel<Map<String,Object>> accessSituation(){
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto(); List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
double sum = list.stream().mapToDouble(l -> Double.parseDouble(l.getInstalledCapacity())).sum(); 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())); Map<String, List<StationCacheInfoDto>> listMap = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getStationType, Collectors.toList()));
for (StationType value : StationType.values()) { for (StationType value : StationType.values()) {
...@@ -1148,7 +1146,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -1148,7 +1146,7 @@ public class MonitorFanIdxController extends BaseController {
@GetMapping("/qyAccessSituation") @GetMapping("/qyAccessSituation")
public ResponseModel<Map<String,Object>> qyAccessSituation(){ public ResponseModel<Map<String,Object>> qyAccessSituation(){
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
List<StationCacheInfoDto> list = commonService.getListStationCacheInfoDto(); List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode)); Map<String, List<StationCacheInfoDto>> belongAreaList = list.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getAreaCode));
for (String s : belongAreaList.keySet()) { for (String s : belongAreaList.keySet()) {
double sum = belongAreaList.get(s).stream().mapToDouble(l -> Double.parseDouble(l.getInstalledCapacity())).sum(); double sum = belongAreaList.get(s).stream().mapToDouble(l -> Double.parseDouble(l.getInstalledCapacity())).sum();
......
...@@ -2,7 +2,12 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; ...@@ -2,7 +2,12 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
...@@ -32,10 +37,12 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -32,10 +37,12 @@ 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.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
@Service @Service
public class CommonServiceImpl { public class CommonServiceImpl {
...@@ -55,6 +62,12 @@ public class CommonServiceImpl { ...@@ -55,6 +62,12 @@ public class CommonServiceImpl {
@Autowired @Autowired
private ElasticsearchRestTemplate elasticsearchTemplate; private ElasticsearchRestTemplate elasticsearchTemplate;
@Resource
private StationBasicMapper stationBasicMapper;
@Resource
private RegionMapper regionMapper;
@Resource
private MapRegionMapper mapRegionMapper;
/** /**
* @deprecated 获取指标值总和 * @deprecated 获取指标值总和
...@@ -154,13 +167,36 @@ public class CommonServiceImpl { ...@@ -154,13 +167,36 @@ public class CommonServiceImpl {
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);
} }
} }
return stationCacheInfoDtoList; return stationCacheInfoDtoList;
} }
......
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