寄点电站数据融合
This commit is contained in:
@ -28,7 +28,7 @@ public interface EarningsCalculateMapper {
|
||||
int insertSelective(EarningsCalculate record);
|
||||
|
||||
int deleteByDay(@Param("day") String day, @Param("typeList") List<Integer> typeList);
|
||||
|
||||
int deleteByStationAndDay(@Param("day") String day, @Param("typeList") List<Integer> typeList, @Param("stationId") Integer stationId);
|
||||
int insertBatch(List<EarningsCalculate> list);
|
||||
// 类型是传入多个
|
||||
//List<EarningsCalculate> selectList(@Param("stationId") Integer stationId, @Param("typeList") List<Integer> typeList, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
|
||||
|
||||
@ -1,22 +1,34 @@
|
||||
package com.ho.business.service;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.EarningsCalculate;
|
||||
import com.ho.business.entity.ElecMeterValue;
|
||||
import com.ho.business.entity.Station;
|
||||
import com.ho.business.mapper.EarningsCalculateMapper;
|
||||
import com.ho.business.vo.req.StationReqVO;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.HttpUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.jsf.FacesContextUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -29,10 +41,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@Slf4j
|
||||
public class ShipEnergyService {
|
||||
|
||||
/**
|
||||
* token 缓存 key
|
||||
*/
|
||||
private static final String SHIP_ENERGY_TOKEN_KEY = "ShipEnergyToken";
|
||||
|
||||
/**
|
||||
* 获取token 参数 platform
|
||||
@ -58,6 +66,10 @@ public class ShipEnergyService {
|
||||
* 寄点能源- 主监控汇总 Url
|
||||
*/
|
||||
private static final String MAIN_URL = "https://www.emind2000.cloud/rest-api/getMainTotal";
|
||||
/**
|
||||
* 寄点能源- 历史收益 Url
|
||||
*/
|
||||
private static final String INCOME_HIS_URL = "https://www.emind2000.cloud/rest-api/getIncomeHis";
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@ -65,27 +77,36 @@ public class ShipEnergyService {
|
||||
@Autowired
|
||||
private StationService stationService;
|
||||
|
||||
@Autowired
|
||||
ElecMeterValueService elecMeterValueService;
|
||||
|
||||
@Autowired
|
||||
EarningsCalculateMapper earningsCalculateMapper;
|
||||
|
||||
/**
|
||||
* 寄点能源 - 获取token
|
||||
* @return token
|
||||
*/
|
||||
public String getToken(){
|
||||
String token = null;
|
||||
if(redisService.hasKey(SHIP_ENERGY_TOKEN_KEY)){
|
||||
token = (String)redisService.get(SHIP_ENERGY_TOKEN_KEY);
|
||||
if(redisService.hasKey(CommonConstant.SHIP_ENERGY_TOKEN_KEY)){
|
||||
token = (String)redisService.get(CommonConstant.SHIP_ENERGY_TOKEN_KEY);
|
||||
return token;
|
||||
}
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("platform",PLATFORM);
|
||||
params.put("platformsecret",PLATFORM_SECRET);
|
||||
try {
|
||||
String json = HttpUtils.getWithForm(TOKEN_URL,params);
|
||||
log.info("json:" + TOKEN_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
token = data.getString("access_token");
|
||||
//redis 缓存
|
||||
redisService.set(SHIP_ENERGY_TOKEN_KEY,token,10, TimeUnit.HOURS);
|
||||
redisService.set(CommonConstant.SHIP_ENERGY_TOKEN_KEY,token,10, TimeUnit.HOURS);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -98,11 +119,12 @@ public class ShipEnergyService {
|
||||
* @return 项目列表 json 字符串
|
||||
*/
|
||||
public String getStations(){
|
||||
String Authorization = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjo5Nzg2LCJ1c2VyX2tleSI6Ijk3ODY6N2RkNjU0MTgtNDg5ZS00MzgzLWI1ZmYtMTU2MmI5ZTY0NDFkIiwidXNlcm5hbWUiOiJ6emt5YXBpIn0.fQLMlOHaEjmfHeyEu5EcxZmQ8UjRBOUoteNV-tJ2ttAwyJmQidOk7xqL25K_wRIC-OQKt0vFVOpTzMFdH71uhw";
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization",Authorization);
|
||||
headers.put("Authorization", getToken());
|
||||
try {
|
||||
String json = HttpUtils.getWithHeaders(STATION_URL,null,headers);
|
||||
log.info("json:" + STATION_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
@ -121,14 +143,42 @@ public class ShipEnergyService {
|
||||
* @param stationId 电站id
|
||||
* @return 返回对应电站汇总信息
|
||||
*/
|
||||
public String getMainTotal(String stationId){
|
||||
String Authorization = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjo5Nzg2LCJ1c2VyX2tleSI6Ijk3ODY6MmE5YjUzODUtNjNiNC00OWRiLWFjODEtNzhmNWRmNjE0ZDgyIiwidXNlcm5hbWUiOiJ6emt5YXBpIn0.WMi4PgYQByeYXBfOGVM0mc4P5GcyAcGRkDo8F7TK8fXIkj9QZ9D34WmugiVX3GxRGODFs3u1ujH7qJyuQAM99w";
|
||||
public String getMainTotal(Integer stationId){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization",Authorization);
|
||||
headers.put("Authorization", getToken());
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("stationId",stationId);
|
||||
params.put("stationId",stationId.toString());
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
String json = HttpUtils.getWithHeaders(MAIN_URL,params,headers);
|
||||
log.info("MAIN_URL:" + MAIN_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
return jsonObject.getString("data");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 寄点能源 - 获取 历史收益查询
|
||||
*/
|
||||
public String getIncomeHis(Integer stationId,String beginTime){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", getToken());
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("stationId",stationId.toString());
|
||||
params.put("startTime",beginTime+CommonConstant.START_SUFFIX_TIMESTAMP);
|
||||
params.put("endTime",beginTime+CommonConstant.END_SUFFIX_TIMESTAMP);
|
||||
try {
|
||||
String json = HttpUtils.getWithHeaders(INCOME_HIS_URL,params,headers);
|
||||
log.info("INCOME_HIS_URL:" + INCOME_HIS_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
@ -145,8 +195,8 @@ public class ShipEnergyService {
|
||||
* 寄点能源 - 电站信息融合储能平台处理
|
||||
*/
|
||||
public void addShipEnergyStation(){
|
||||
String stationJson = getStations();
|
||||
JSONArray jsonStation = JSON.parseArray(stationJson);
|
||||
String json = getStations();
|
||||
JSONArray jsonStation = JSON.parseArray(json);
|
||||
jsonStation.forEach(i->{
|
||||
JSONObject jsonObj = (JSONObject) i;
|
||||
Integer stationId = jsonObj.getInteger("stationId");
|
||||
@ -169,9 +219,224 @@ public class ShipEnergyService {
|
||||
vo.setRatePower(maxPower);
|
||||
vo.setGridTime(commossioningTime);
|
||||
vo.setGroupId(155);
|
||||
vo.setDeptId(155);
|
||||
vo.setDeptId(592);
|
||||
vo.setStatus(1);
|
||||
vo.setType(7);
|
||||
vo.setPId(0);
|
||||
vo.setIsDailyCount(0);
|
||||
vo.setTopologyType(1);
|
||||
vo.setCupboardType(2);
|
||||
Station station = stationService.selectByName(vo.getName());
|
||||
if (station != null) {
|
||||
throw new BusinessException(BaseResponseCode.STATION_ALREADY_EXISTS);
|
||||
}
|
||||
stationService.insertStation(vo);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 寄点能源 - 缓存电站监控信息
|
||||
*/
|
||||
public void getShipEnergyTotal(){
|
||||
String stations = getStations();
|
||||
JSONArray jsonStation = JSON.parseArray(stations);
|
||||
jsonStation.forEach(i->{
|
||||
JSONObject jsonObj = (JSONObject) i;
|
||||
Integer stationId = jsonObj.getInteger("stationId");
|
||||
String json = getMainTotal(stationId);
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + stationId;
|
||||
redisService.set(mainKey,json);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 寄点能源 - 获取寄点电站历史收益 并存储
|
||||
*/
|
||||
public void getStationIncomeHis(String beginTime){
|
||||
DateTime yesterday = DateUtil.yesterday();
|
||||
String yesterdayStr = DateUtil.formatDate(yesterday);
|
||||
if(beginTime==null){
|
||||
beginTime = yesterdayStr;
|
||||
}
|
||||
String stations = getStations();
|
||||
JSONArray jsonStation = JSON.parseArray(stations);
|
||||
String finalBeginTime = beginTime;
|
||||
jsonStation.forEach(i->{
|
||||
JSONObject jsonObj = (JSONObject) i;
|
||||
Integer stationId = jsonObj.getInteger("stationId");
|
||||
String incomeHis = getIncomeHis(stationId, finalBeginTime);
|
||||
JSONArray incomes = JSON.parseArray(incomeHis);
|
||||
incomes.forEach(j->{
|
||||
JSONObject income = (JSONObject) j;
|
||||
String date=income.getString("date");
|
||||
String price = income.getString("price");
|
||||
JsonObject jsonPrice = JsonParser.parseString(price).getAsJsonObject();
|
||||
List<EarningsCalculate> list = new ArrayList<>();
|
||||
List<ElecMeterValue> elecList = new ArrayList<>();
|
||||
BigDecimal inTotalIncome = BigDecimal.ZERO;
|
||||
BigDecimal outTotalIncome = BigDecimal.ZERO;
|
||||
if(finalBeginTime.equals(date)){
|
||||
//收益-充-尖
|
||||
EarningsCalculate inSharp = new EarningsCalculate();
|
||||
BigDecimal positiveSharp = income.getBigDecimal("sum_e_positive_sharp");
|
||||
inSharp.setElec(positiveSharp);
|
||||
inSharp.setType(0);
|
||||
inSharp.setRateType(CommonConstant.RateType.TIP);
|
||||
BigDecimal inSharpPrice = jsonPrice.get("in_sharp_price").getAsBigDecimal();
|
||||
inSharp.setPrice(inSharpPrice);
|
||||
inSharp.setDigital(positiveSharp.multiply(inSharpPrice));
|
||||
inTotalIncome = inTotalIncome.add(inSharp.getDigital());
|
||||
inSharp.setTotal(BigDecimal.ZERO);
|
||||
list.add(inSharp);
|
||||
//收益-充-峰
|
||||
EarningsCalculate inPeak = new EarningsCalculate();
|
||||
BigDecimal positivePeak = income.getBigDecimal("sum_e_positive_peak");
|
||||
inPeak.setElec(positivePeak);
|
||||
inPeak.setType(0);
|
||||
inPeak.setRateType(CommonConstant.RateType.PEAK);
|
||||
BigDecimal inPeakPrice = jsonPrice.get("in_peak_price").getAsBigDecimal();
|
||||
inPeak.setPrice(inPeakPrice);
|
||||
inPeak.setDigital(positivePeak.multiply(inPeakPrice));
|
||||
inTotalIncome = inTotalIncome.add(inPeak.getDigital());
|
||||
inPeak.setTotal(BigDecimal.ZERO);
|
||||
list.add(inPeak);
|
||||
//收益-充-平
|
||||
EarningsCalculate inFlat = new EarningsCalculate();
|
||||
BigDecimal positiveFlat = income.getBigDecimal("sum_e_positive_flat");
|
||||
inFlat.setElec(positiveFlat);
|
||||
inFlat.setType(0);
|
||||
inFlat.setRateType(CommonConstant.RateType.FLAT);
|
||||
BigDecimal inFlatPrice = jsonPrice.get("in_flat_price").getAsBigDecimal();
|
||||
inFlat.setPrice(inFlatPrice);
|
||||
inFlat.setDigital(positiveFlat.multiply(inFlatPrice));
|
||||
inTotalIncome = inTotalIncome.add(inFlat.getDigital());
|
||||
inFlat.setTotal(BigDecimal.ZERO);
|
||||
list.add(inFlat);
|
||||
//收益-充-谷
|
||||
EarningsCalculate inValley = new EarningsCalculate();
|
||||
BigDecimal positiveValley = income.getBigDecimal("sum_e_positive_valley");
|
||||
inValley.setElec(positiveValley);
|
||||
inValley.setType(0);
|
||||
inValley.setRateType(CommonConstant.RateType.VALLEY);
|
||||
BigDecimal inValleyPrice = jsonPrice.get("in_valley_price").getAsBigDecimal();
|
||||
inValley.setPrice(inValleyPrice);
|
||||
inValley.setDigital(positiveValley.multiply(inValleyPrice));
|
||||
inTotalIncome = inTotalIncome.add(inValley.getDigital());
|
||||
inValley.setTotal(BigDecimal.ZERO);
|
||||
list.add(inValley);
|
||||
//收益-充-深谷
|
||||
EarningsCalculate inDeepValley = new EarningsCalculate();
|
||||
BigDecimal positiveDeepValley = income.getBigDecimal("sum_e_positive_deep_valley");
|
||||
inDeepValley.setElec(positiveDeepValley);
|
||||
inDeepValley.setType(0);
|
||||
inDeepValley.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||
BigDecimal inDeepValleyPrice = jsonPrice.get("in_deep_valley_price").getAsBigDecimal();
|
||||
inDeepValley.setPrice(inDeepValleyPrice);
|
||||
inDeepValley.setDigital(positiveDeepValley.multiply(inDeepValleyPrice));
|
||||
inTotalIncome = inTotalIncome.add(inValley.getDigital());
|
||||
inDeepValley.setTotal(inTotalIncome);
|
||||
list.add(inDeepValley);
|
||||
//收益-放-尖
|
||||
EarningsCalculate outSharp = new EarningsCalculate();
|
||||
BigDecimal reverseSharp = income.getBigDecimal("sum_e_reverse_sharp");
|
||||
outSharp.setElec(reverseSharp);
|
||||
outSharp.setType(1);
|
||||
outSharp.setRateType(CommonConstant.RateType.TIP);
|
||||
BigDecimal outSharpPrice = jsonPrice.get("out_sharp_price").getAsBigDecimal();
|
||||
outSharp.setPrice(outSharpPrice);
|
||||
outSharp.setDigital(reverseSharp.multiply(outSharpPrice));
|
||||
outTotalIncome = outTotalIncome.add(outSharp.getDigital());
|
||||
outSharp.setTotal(BigDecimal.ZERO);
|
||||
list.add(outSharp);
|
||||
//收益-放-峰
|
||||
EarningsCalculate outPeak = new EarningsCalculate();
|
||||
BigDecimal reversePeak = income.getBigDecimal("sum_e_reverse_peak");
|
||||
outPeak.setElec(reversePeak);
|
||||
outPeak.setType(1);
|
||||
outPeak.setRateType(CommonConstant.RateType.PEAK);
|
||||
BigDecimal outPeakPrice = jsonPrice.get("out_peak_price").getAsBigDecimal();
|
||||
outPeak.setPrice(outPeakPrice);
|
||||
outPeak.setDigital(reversePeak.multiply(outPeakPrice));
|
||||
outTotalIncome = outTotalIncome.add(outPeak.getDigital());
|
||||
outPeak.setTotal(BigDecimal.ZERO);
|
||||
list.add(outPeak);
|
||||
//收益-放-平
|
||||
EarningsCalculate outFlat = new EarningsCalculate();
|
||||
BigDecimal reverseFlat = income.getBigDecimal("sum_e_reverse_flat");
|
||||
outFlat.setElec(reverseFlat);
|
||||
outFlat.setType(1);
|
||||
outFlat.setRateType(CommonConstant.RateType.FLAT);
|
||||
BigDecimal outFlatPrice = jsonPrice.get("out_flat_price").getAsBigDecimal();
|
||||
outFlat.setPrice(outFlatPrice);
|
||||
outFlat.setDigital(reverseFlat.multiply(outFlatPrice));
|
||||
outTotalIncome = outTotalIncome.add(outFlat.getDigital());
|
||||
outFlat.setTotal(BigDecimal.ZERO);
|
||||
list.add(outFlat);
|
||||
//收益-放-谷
|
||||
EarningsCalculate outValley = new EarningsCalculate();
|
||||
BigDecimal reverseValley = income.getBigDecimal("sum_e_reverse_valley");
|
||||
outValley.setElec(reverseValley);
|
||||
outValley.setType(1);
|
||||
outValley.setRateType(CommonConstant.RateType.VALLEY);
|
||||
BigDecimal outValleyPrice = jsonPrice.get("out_valley_price").getAsBigDecimal();
|
||||
outValley.setPrice(outValleyPrice);
|
||||
outValley.setDigital(reverseValley.multiply(outValleyPrice));
|
||||
outTotalIncome = outTotalIncome.add(outValley.getDigital());
|
||||
outValley.setTotal(BigDecimal.ZERO);
|
||||
list.add(outValley);
|
||||
//收益-放-深谷
|
||||
EarningsCalculate outDeepValley = new EarningsCalculate();
|
||||
BigDecimal reverseDeepValley = income.getBigDecimal("sum_e_reverse_deep_valley");
|
||||
outDeepValley.setElec(reverseDeepValley);
|
||||
outDeepValley.setType(1);
|
||||
outDeepValley.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||
BigDecimal outDeepValleyPrice = jsonPrice.get("out_deep_valley_price").getAsBigDecimal();
|
||||
outDeepValley.setPrice(outDeepValleyPrice);
|
||||
outDeepValley.setDigital(reverseDeepValley.multiply(outDeepValleyPrice));
|
||||
outTotalIncome = outTotalIncome.add(outDeepValley.getDigital());
|
||||
outDeepValley.setTotal(outTotalIncome);
|
||||
list.add(outDeepValley);
|
||||
// 充电
|
||||
ElecMeterValue charge = new ElecMeterValue();
|
||||
BigDecimal sumEPositive = income.getBigDecimal("sum_e_positive");
|
||||
charge.setDigital(sumEPositive);
|
||||
charge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.CHARGE);
|
||||
charge.setStatus(CommonConstant.STATUS_FLAG);
|
||||
elecList.add(charge);
|
||||
// 放电
|
||||
ElecMeterValue disCharge = new ElecMeterValue();
|
||||
BigDecimal sumEReverse = income.getBigDecimal("sum_e_reverse");
|
||||
disCharge.setDigital(sumEReverse);
|
||||
disCharge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.DISCHARGE);
|
||||
disCharge.setStatus(CommonConstant.STATUS_FLAG);
|
||||
elecList.add(disCharge);
|
||||
}
|
||||
if(elecList.size()>0){
|
||||
//删除
|
||||
elecMeterValueService.deleteByStationAndDay(stationId+10000,date,null);
|
||||
elecList.forEach(eleMeter -> {
|
||||
eleMeter.setGroupId(155);
|
||||
eleMeter.setStationId(stationId+10000);
|
||||
eleMeter.setCreateTime(new Date());
|
||||
eleMeter.setDay(date);
|
||||
//新增
|
||||
elecMeterValueService.insert(eleMeter);
|
||||
});
|
||||
}
|
||||
if(list.size()>0){
|
||||
//删除
|
||||
earningsCalculateMapper.deleteByStationAndDay(date,null,stationId+10000);
|
||||
list.forEach(a->{
|
||||
a.setGroupId(155);
|
||||
a.setStationId(stationId+10000);
|
||||
a.setCreateTime(new Date());
|
||||
a.setDay(date);
|
||||
a.setDiscount(BigDecimal.ONE);
|
||||
//新增
|
||||
earningsCalculateMapper.insertSelective(a);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.*;
|
||||
import com.ho.business.feignclient.UserFeignClient;
|
||||
@ -25,6 +26,7 @@ import com.ho.business.vo.req.report.ReportReqVO;
|
||||
import com.ho.business.vo.resp.CountEleData;
|
||||
import com.ho.business.vo.resp.DeviceRespVO;
|
||||
import com.ho.business.vo.resp.InverterResp.PowerGenerateRespVO;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.business.vo.resp.cabin.EarningsCalculateCountResp;
|
||||
import com.ho.business.vo.resp.cabin.EarningsCalculateResp;
|
||||
import com.ho.business.vo.resp.colCount.ColCountResp;
|
||||
@ -1445,6 +1447,17 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService {
|
||||
revenueOverview.setStationName(station.getName());
|
||||
revenueOverview.setCapacity(station.getCapacity());
|
||||
revenueOverview.setOperationDays((int) operationDays);
|
||||
if(station.getId()==11003 || station.getId()==10942){
|
||||
// 寄点电站数据
|
||||
Integer stationId = station.getId()-10000;
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + stationId;
|
||||
String json = (String)redisService.get(mainKey);
|
||||
ShipStationRespVO respVO = JSON.parseObject(json,ShipStationRespVO.class);
|
||||
revenueOverview.setCharging(BigDecimal.valueOf(respVO.getPositivePowerSum()));
|
||||
revenueOverview.setDischarging(BigDecimal.valueOf(respVO.getReversePowerSum()));
|
||||
revenueOverview.setTotalRevenue(BigDecimal.valueOf(respVO.getIncomeSum()));
|
||||
return revenueOverview;
|
||||
}
|
||||
|
||||
List<RevenueOverviewData> list = getRevenueOverviewData(vo);
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.ho.business.service.impl;
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.Device;
|
||||
import com.ho.business.entity.ElecMeterValue;
|
||||
@ -17,6 +18,7 @@ import com.ho.business.vo.req.colCount.ColCountReq;
|
||||
import com.ho.business.vo.resp.CountEleData;
|
||||
import com.ho.business.vo.resp.DeviceRespVO;
|
||||
import com.ho.business.vo.resp.ProvinceStation;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.business.vo.resp.colCount.ColCountResp;
|
||||
import com.ho.business.vo.resp.iargeScreen.*;
|
||||
import com.ho.business.vo.resp.mppt.MpptActiveVo;
|
||||
@ -287,22 +289,10 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
BigDecimal dayCharge = BigDecimal.ZERO;
|
||||
BigDecimal dayDischarge = BigDecimal.ZERO;
|
||||
StringBuffer stationDayLog = new StringBuffer();
|
||||
// ColCountReq colCountReq = new ColCountReq();
|
||||
// colCountReq.setCol(DataCollectConstant.Elec_Meter.TOTAL_CHARGE);
|
||||
// List<Integer> ids = stations.stream().map(Station::getId).collect(Collectors.toList());
|
||||
// colCountReq.setIds(ids);
|
||||
// List<ColCountResp> colCountResps = colCountService.selectByParam(colCountReq);
|
||||
// Map<Integer, String> stationMapAndType = new HashMap<>();
|
||||
// if (colCountResps != null) {
|
||||
// stationMapAndType = colCountResps.stream().collect(Collectors.toMap(ColCountResp::getStationId, ColCountResp::getDeviceType, (k1, k2) -> k1));
|
||||
// }
|
||||
|
||||
for (Station station : stations) {
|
||||
// StationReq req = new StationReq();
|
||||
// req.setStationId(station.getId());
|
||||
// req.setDeviceType(stationMapAndType.get(req.getStationId()));
|
||||
BigDecimal dailyChargeElec = BigDecimal.ZERO;
|
||||
BigDecimal dailyDischargeElec = BigDecimal.ZERO;
|
||||
// CountEleData countEleData = stationHomeService.getCountEleData(req);
|
||||
CountEleData countEleData = getByRedisData(station.getId());
|
||||
if (null == countEleData || null == countEleData.getDailyChargeElec() || null == countEleData.getDailyDischargeElec()) {
|
||||
dailyChargeElec = BigDecimal.ZERO;
|
||||
@ -357,6 +347,20 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
annualOverviewResp.setTotalCharge(incomeShow1.getYearCharge());
|
||||
annualOverviewResp.setTotalDischarge(incomeShow1.getYearDischarge());
|
||||
}
|
||||
// 寄点站点数据融合
|
||||
stations.forEach(s->{
|
||||
if(s.getId()==11003 || s.getId()==10942) {
|
||||
// 寄点电站数据
|
||||
Integer stationId = s.getId() - 10000;
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + stationId;
|
||||
String json = (String) redisService.get(mainKey);
|
||||
ShipStationRespVO respVO = JSON.parseObject(json, ShipStationRespVO.class);
|
||||
// 日充
|
||||
annualOverviewResp.setDayCharge(annualOverviewResp.getDayCharge().add(BigDecimal.valueOf(respVO.getPositivePowerToday())));
|
||||
// 日放
|
||||
annualOverviewResp.setDayDischarge(annualOverviewResp.getDayDischarge().add(BigDecimal.valueOf(respVO.getReversePowerToday())));
|
||||
}
|
||||
});
|
||||
return annualOverviewResp;
|
||||
}
|
||||
|
||||
|
||||
@ -176,6 +176,7 @@ public class OutApiServiceImpl implements OutApiService {
|
||||
}
|
||||
String deviceType = DeviceTypeConstant.BMS;
|
||||
log.info("stations.size:" + stations.size());
|
||||
stations = stations.stream().filter(i->i.getId()!=11003 && i.getId()!=10942).collect(Collectors.toList());
|
||||
for (Station station : stations) {
|
||||
try {
|
||||
//先删除站的当日数据
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.*;
|
||||
@ -959,6 +960,15 @@ public class StationHomeServiceImpl implements StationHomeService {
|
||||
dailyDischargeElec = new BigDecimal(dailyDischargeElecStr);
|
||||
pcsElecData.setChargeElec(dailyChargeElec);
|
||||
pcsElecData.setDischargeElec(dailyDischargeElec);
|
||||
if(req.getStationId()==11003 || req.getStationId()==10942){
|
||||
// 寄点电站数据
|
||||
Integer stationId = req.getStationId()-10000;
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + stationId;
|
||||
String json = (String)redisService.get(mainKey);
|
||||
ShipStationRespVO vo = JSON.parseObject(json,ShipStationRespVO.class);
|
||||
pcsElecData.setChargeElec(BigDecimal.valueOf(vo.getPositivePowerToday()));
|
||||
pcsElecData.setDischargeElec(BigDecimal.valueOf(vo.getReversePowerToday()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user