Commit 5b39e643 authored by 朱晨阳's avatar 朱晨阳

Merge remote-tracking branch 'origin/developer' into developer

parents cc688c20 d6f08601
......@@ -27,5 +27,13 @@ public interface StationPlanMapper extends BaseMapper<StationPlan> {
@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);
@Select("select value,monthly from station_plan where station_basic_id=#{stationBasicId} and year= #{year} ")
List<StationPlan> getPlanGenByStationIdAndYear(@Param("stationBasicId") String stationId, @Param("year") String year);
@Select("select value,monthly from station_plan where station_basic_id in (${stationBasicId}) and year= #{year} ")
List<StationPlan> getPlansGenByStationIdAndYear(@Param("stationBasicId") String stationId, @Param("year") String year);
}
......@@ -47,7 +47,16 @@ public class EarningsForecastController {
public ResponseModel<Object> earningsForecast (@RequestParam(required = true,value = "stationId") Long stationId,
@RequestParam(required = true,value = "type") String type){
return ResponseHelper.buildResponse(earningsForecast.earningsForecast(stationId,type));
return ResponseHelper.buildResponse(earningsForecast.earningsForecastZXT(stationId,type));
}
@RequestMapping(value = "earningsForecastSJQXT",method = RequestMethod.GET)
@TycloudOperation(needAuth = false,ApiLevel = UserType.AGENCY)
public ResponseModel<Object> earningsForecastSJQXT (@RequestParam(required = true,value = "stationId") Long stationId,
@RequestParam(required = true,value = "type") String type){
return ResponseHelper.buildResponse(earningsForecast.earningsForecastSJQXT(stationId,type));
}
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
......@@ -10,6 +11,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
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.mapper2.CommonMapper;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -29,8 +31,8 @@ public class EarningsForecastImpl {
private String forecastUrl;
@Autowired
private StationBasicMapper stationBasicMapper;
public Object earningsForecast (Long stationId, String type){
//收益 时间曲线图数据组装
public Object earningsForecastSJQXT (Long stationId, String type){
List<Map<String, String>> list = commonMapper.selectAgo10Month();
List<Map<String, String>> lastThreeMonth = commonMapper.selectLast3Month();
......@@ -54,17 +56,17 @@ public class EarningsForecastImpl {
});
TreeMap<String, Double> map = commonService.getListDataByCondtionsSum(queryCondtion1,objects, ESMoonPowerGeneration.class,null);
TreeMap<String, Double> carbonDioxide = new TreeMap<>();
TreeMap<String, Double> standardCoal = new TreeMap<>();
TreeMap<String, Double> toner = new TreeMap<>();
TreeMap<String, Double> sulfurDioxide = new TreeMap<>();
TreeMap<String, String> carbonDioxide = new TreeMap<>();
TreeMap<String, String> standardCoal = new TreeMap<>();
TreeMap<String, String> toner = new TreeMap<>();
TreeMap<String, String> sulfurDioxide = new TreeMap<>();
//计算历史月发电量的收益
map.keySet().forEach(e->{
carbonDioxide.put(months.get(e), Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.carbonDioxide)));
standardCoal.put(months.get(e),Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.standardCoal)));
toner.put(months.get(e),Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.toner)));
sulfurDioxide.put(months.get(e),Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.sulfurDioxide)));
carbonDioxide.put(months.get(e), String.format("%.3f",map.get(e) * CommonConstans.carbonDioxide));
standardCoal.put(months.get(e),String.format("%.3f",map.get(e) * CommonConstans.standardCoal));
toner.put(months.get(e),String.format("%.3f",map.get(e) * CommonConstans.toner));
sulfurDioxide.put(months.get(e),String.format("%.3f",map.get(e) * CommonConstans.sulfurDioxide));
});
......@@ -120,8 +122,81 @@ public class EarningsForecastImpl {
}
//收益 折线图数据组装
public Object earningsForecastZXT (Long stationId, String type){
List<Map<String, String>> list = commonMapper.selectAgo10Month();
List<Map<String, String>> lastThreeMonth = commonMapper.selectLast3Month();
Map<String, List<String>> queryCondtion1 = new HashMap<>();
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
if (type.equals("FDZ")){
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
}else {
queryCondtion1.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getBoosterGatewayId()));
}
List<Map<String, String>> objects = new ArrayList<>();
TreeMap<String, String> months= new TreeMap<>();
list.forEach(e->{
Map<String, String> likeQueryCondtion = new HashMap<>();
likeQueryCondtion.put("id.keyword",e.get("MonthYear")+"*");
objects.add(likeQueryCondtion);
String key = e.get("MonthYear").split("-")[1];
months.put(String.valueOf(Integer.parseInt(key)),e.get("MonthYear"));
});
TreeMap<String, Double> map = commonService.getListDataByCondtionsSum(queryCondtion1,objects, ESMoonPowerGeneration.class,null);
TreeMap<String, String> carbonDioxide = new TreeMap<>();
TreeMap<String, String> standardCoal = new TreeMap<>();
TreeMap<String, String> toner = new TreeMap<>();
TreeMap<String, String> sulfurDioxide = new TreeMap<>();
//计算历史月发电量的收益
map.keySet().forEach(e->{
carbonDioxide.put(months.get(e), String.format("%.3f",map.get(e) * CommonConstans.carbonDioxide));
standardCoal.put(months.get(e),String.format("%.3f",map.get(e) * CommonConstans.standardCoal));
toner.put(months.get(e),String.format("%.3f",map.get(e) * CommonConstans.toner));
sulfurDioxide.put(months.get(e),String.format("%.3f",map.get(e) * CommonConstans.sulfurDioxide));
});
//查询预测收益接口
JSONObject carbonDioxideData = getResponse("二氧化碳减排量", carbonDioxide.values().stream().collect(Collectors.toList()));
JSONObject standardCoalData = getResponse("标准煤减排量", standardCoal.values().stream().collect(Collectors.toList()));
JSONObject tonerData = getResponse("炭粉尘减排量", toner.values().stream().collect(Collectors.toList()));
JSONObject sulfurDioxideData = getResponse("二氧化硫减排量", sulfurDioxide.values().stream().collect(Collectors.toList()));
Map<String, Object> carbonDioxideMap = this.buildDataNew(carbonDioxideData);
Map<String, Object> standardCoalMap = this.buildDataNew(standardCoalData);
Map<String, Object> tonerDataMap = this.buildDataNew(tonerData);
Map<String, Object> sulfurDioxideMap = this.buildDataNew(sulfurDioxideData);
List<Map<String, Object>> dataList = new ArrayList<>();
dataList.add(MapBuilder.<String, Object>create().put("data",carbonDioxide.values()).build());
dataList.add(MapBuilder.<String, Object>create().put("data",standardCoal.values()).build());
dataList.add(MapBuilder.<String, Object>create().put("data",toner.values()).build());
dataList.add( MapBuilder.<String, Object>create().put("data",sulfurDioxide.values()).build());
dataList.add(carbonDioxideMap);
dataList.add(standardCoalMap);
dataList.add(tonerDataMap);
dataList.add(sulfurDioxideMap);
List<String> axisData = new ArrayList<>();
lastThreeMonth.forEach(e->{
axisData.add(e.get("MonthYear")) ;
});
List<String> data = new ArrayList<>(carbonDioxide.keySet());
data.addAll(axisData);
return MapBuilder.<String, Object>create().put("axisData",data).put("seriesData",dataList).build();
}
List<List<String>> buildResultData( TreeMap<String, Double> map){
List<List<String>> buildResultData( TreeMap<String, String> map){
List<List<String>> lists = new ArrayList<>();
map.keySet().forEach(e->{
List<String> list = Arrays.asList(e, String.valueOf(map.get(e)));
......@@ -132,7 +207,7 @@ public class EarningsForecastImpl {
}
String buildParams(String name, List<Double> values){
String buildParams(String name, List<String> values){
HashMap<Object, Object> requestParams = new HashMap<>();
HashMap<Object, Object> valueLabel = new HashMap<>();
......@@ -158,7 +233,7 @@ public class EarningsForecastImpl {
}
JSONObject getResponse(String name, List<Double> values){
JSONObject getResponse(String name, List<String> values){
String requestParam=buildParams(name,values);
Map<String, String> hashMaphead = new HashMap<>();
hashMaphead.put("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
......@@ -181,6 +256,17 @@ public class EarningsForecastImpl {
return newList;
}
Map<String, Object> buildDataNew(JSONObject forecastObj){
JSONObject dataObject = forecastObj.getJSONObject("data");
// 从data对象中提取forecast和history数组
JSONArray forecastArray = dataObject.getJSONArray("forecast");
JSONArray historyArray = dataObject.getJSONArray("history");
forecastArray.addAll(historyArray);
return MapBuilder.<String,Object>create().put("data",forecastArray).build();
}
......
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
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.util.CommonResponse;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
......@@ -39,7 +40,6 @@ public class AppletMonitorController {
@Autowired
StationBasicMapper stationBasicMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图-总概览")
@GetMapping("/CockpitData")
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationPlan;
import com.yeejoin.amos.boot.module.jxiop.api.feign.IdxFeign;
import com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper.CompanyMapper;
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.ESEquipmentsDTO;
......@@ -37,11 +41,14 @@ public class AppletMonitorServiceImpl {
IdxFeign idxFeign;
@Autowired
AmosRequestContext requestContext;
@Autowired
StationPlanMapper stationPlanMapper;
public Map<String,Object> getFanStationInfo(StationBasicDto stationBasic ){
List<StationPlan> planPower = stationPlanMapper.getPlanGenByStationIdAndYear(String.valueOf(stationBasic.getSequenceNbr()), String.valueOf(DateUtils.getYear(new Date())));
String gatewayId = stationBasic.getFanGatewayId();
Map<String, Object> columnMap = new HashMap<>();
Map<String, List<String>> queryCondtion = new HashMap<>();
......@@ -87,6 +94,12 @@ public class AppletMonitorServiceImpl {
});
data.put("value",stationMark.get("value"));
double yearPower = planPower.stream().mapToDouble(StationPlan::getValue).sum();
Double monthPower = planPower.stream().filter(e -> e.getMonthly().equals(DateUtils.getMonth(new Date()))).findFirst().get().getValue();
double dayPower = monthPower / DateUtils.getDaysOfMonth(new Date());
data.put("yearPower",yearPower);
data.put("monthPower",monthPower);
data.put("dayPower",dayPower);
return data;
}
......@@ -146,7 +159,14 @@ public class AppletMonitorServiceImpl {
data.put(e,stationMark.get(e));
});
data.put("value",stationMark.get("value"));
//计划发电量
List<StationPlan> planPower = stationPlanMapper.getPlanGenByStationIdAndYear(String.valueOf(stationBasic.getSequenceNbr()), String.valueOf(DateUtils.getYear(new Date())));
double yearPower = planPower.stream().mapToDouble(StationPlan::getValue).sum();
Double monthPower = planPower.stream().filter(e -> e.getMonthly().equals(DateUtils.getMonth(new Date()))).findFirst().get().getValue();
double dayPower = monthPower / DateUtils.getDaysOfMonth(new Date());
data.put("yearPower",yearPower);
data.put("monthPower",monthPower);
data.put("dayPower",dayPower);
return data;
}
......@@ -158,8 +178,6 @@ public class AppletMonitorServiceImpl {
double installedCapacity = stations.stream().mapToDouble(StationBasicDto::getInstalledCapacity).sum();
result.put("installedCapacity",String.format("%.2f",installedCapacity));
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P", "WTX-801_25_WTX-801_总辐射累计", "WTX-801_25_WTX-801_总辐射", "313光差保护_总反向有功电度"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, stations.stream().map(StationBasicDto::getBoosterGatewayId).collect(Collectors.toList()));
......@@ -230,7 +248,15 @@ public class AppletMonitorServiceImpl {
result.put("monthPowerGeneration",String.format("%.4f",monthPowerGeneration));
result.put("yearPowerGeneration",String.format("%.4f",yearPowerGeneration));
List<String> collect1 = stations.stream().map(BaseDto::getSequenceNbr).map(String::valueOf).collect(Collectors.toList());
String join = String.join(",", collect1);
List<StationPlan> plansPower = stationPlanMapper.getPlansGenByStationIdAndYear(join, String.valueOf(DateUtils.getYear(new Date())));
double yearPower = plansPower.stream().mapToDouble(StationPlan::getValue).sum();
Double monthPower = plansPower.stream().filter(e -> e.getMonthly().equals(DateUtils.getMonth(new Date()))).mapToDouble(StationPlan::getValue).sum();
double dayPower = monthPower / DateUtils.getDaysOfMonth(new Date());
result.put("yearPower",yearPower);
result.put("monthPower",monthPower);
result.put("dayPower",dayPower);
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