Commit f8cfc179 authored by caotao's avatar caotao

监盘首页发电量top5调整

parent d1dae55d
......@@ -24,5 +24,8 @@ public interface StationPlanMapper extends BaseMapper<StationPlan> {
//
// @Select("SELECT monthly ,sum(value) value from station_plan where year= #{year} GROUP BY monthly ")
// List<StationPlan> getStationPlanbyids(@Param("year") String year);
@Select("select value from station_plan where station_basic_id=#{stationBasicId} and year= #{year} and monthly= #{monthly}")
Double getPlanGenByStationIdAndMonth(@Param("stationBasicId") String stationId, @Param("year") String year, @Param("monthly") String monthly);
}
......@@ -29,4 +29,6 @@ public class StationCacheInfoDto implements Serializable {
private String boosterGatewayId;
//片区code
private String areaCode;
//
private String address;
}
......@@ -26,7 +26,6 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
......@@ -75,8 +74,8 @@ public class MonitoringServiceImpl {
// InfluxdbUtil influxdbUtil;
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
StationPlanMapper StationPlanMapper;
/**
* 根据场站编号获取该场站的装机容量
*
......@@ -798,48 +797,36 @@ public class MonitoringServiceImpl {
public Page<HashMap<String, String>> getPowerGenerationTrendsOfCompletionTopFive(String areaName) {
Page<HashMap<String, String>> hashMapPage = new Page<>(1, 5);
List<HashMap<String, String>> mapList = new ArrayList<>();
List<StationBasic> stationBasicListAll = new ArrayList<>();
List<StationCacheInfoDto> stationCacheInfoDtoList = new ArrayList<>();
stationCacheInfoDtoList = commonServiceImpl.getListStationCacheInfoDto();
if (!ObjectUtils.isEmpty(areaName)) {
stationBasicListAll = getListOfStationBasicByAreaName(areaName);
} else {
stationBasicListAll = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
stationCacheInfoDtoList = stationCacheInfoDtoList.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getBelongArea().equals(areaName)).collect(Collectors.toList());
}
HashMap<String, List<String>> hashMap = new HashMap<>();
List<String> xList = new ArrayList<>();
List<String> yList = new ArrayList<>();
AtomicReference<Double> total = new AtomicReference<>(0.00);
//月发电量
String finalIndicator = "月发电量";
stationBasicListAll.forEach(stationBasic -> {
stationCacheInfoDtoList.forEach(stationCacheInfoDto -> {
List<Map<String, Object>> mapListData = new ArrayList<>();
if (!stationBasic.getStationType().equals("FDZ")) {
if (!stationCacheInfoDto.getStationType().equals("FDZ")) {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(CommonConstans.taiHeGenIndicatorMonth));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
total.set(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(finalIndicator));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
total.set(commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator));
}
QueryWrapper<StationPlan> wrapper2 = new QueryWrapper<>();
LocalDate currentDate = LocalDate.now();
int month = currentDate.getMonthValue();
wrapper2.select("ifnull(sum(value), 0) as sum_value");
wrapper2.eq("monthly", month);
wrapper2.eq("station_basic_id", stationBasic.getSequenceNbr());
List<Map<String, Object>> list = StationPlanMapper.selectMaps(wrapper2);
System.out.println(total.get()+"9999999999999999999999");
Double sumValue = list != null && !list.isEmpty() ? (Double) list.get(0).get("sum_value") : 0;
stationBasic.setAddress(String.format(CommonConstans.Twodecimalplaces, total.get()/sumValue*100 ));
stationCacheInfoDto.setAddress(String.format(CommonConstans.Twodecimalplaces, (total.get())*100/getPlanGenByStationIdAndMonth(stationCacheInfoDto.getStationId())));
});
List<StationBasic> sorted = stationBasicListAll.stream().sorted(Comparator.comparing(StationBasic::getAddress, Comparator.comparingDouble(Double::parseDouble)).reversed()).collect(Collectors.toList());
List<StationCacheInfoDto> sorted = stationCacheInfoDtoList.stream().sorted(Comparator.comparing(StationCacheInfoDto::getAddress, Comparator.comparingDouble(Double::parseDouble)).reversed()).collect(Collectors.toList());
sorted.forEach(stationBasic -> {
HashMap<String, String> hashMap1 = new HashMap<>();
hashMap1.put("stationName", stationBasic.getStationName());
......
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