中车电站数据融合
This commit is contained in:
@ -0,0 +1,354 @@
|
|||||||
|
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.ho.business.constant.DeviceTypeConstant;
|
||||||
|
import com.ho.business.entity.EarningsCalculate;
|
||||||
|
import com.ho.business.entity.ElecMeterValue;
|
||||||
|
import com.ho.business.mapper.EarningsCalculateMapper;
|
||||||
|
import com.ho.business.vo.req.carbin.EarningsCalculateReq;
|
||||||
|
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||||
|
import com.ho.common.tools.constant.CommonConstant;
|
||||||
|
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 java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成都巨石 能源 储能
|
||||||
|
* 成都巨石能源 API 接口 服务
|
||||||
|
*
|
||||||
|
* @author kerwin
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class BoulderEnergyService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取token 参数 appAccount
|
||||||
|
*/
|
||||||
|
private static final String APP_ACCOUNT = "cdjs_app";
|
||||||
|
/**
|
||||||
|
* 获取token 参数 appSecretKey
|
||||||
|
*/
|
||||||
|
private static final String APP_SECRET_KEY = "cdjs@0108";
|
||||||
|
/**
|
||||||
|
* 中车- 获取电站id
|
||||||
|
*/
|
||||||
|
private static final Integer BOULDER_STATION_ID = 11006;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中车- 获取token Url
|
||||||
|
*/
|
||||||
|
private static final String TOKEN_URL = "http://111.15.176.77:18082/gate-newpc/zhny-openapi/openapi/v1/authentication/getAccessToken";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中车- 统计数据 Url
|
||||||
|
*/
|
||||||
|
private static final String BOULDER_DATA_URL = "http://111.15.176.77:18082/gate-newpc/zhny-openapi/openapi/v1/statistics/station/qryIncDayBill";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ElecMeterValueService elecMeterValueService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
EarningsCalculateMapper earningsCalculateMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中车能源 - 获取token
|
||||||
|
* @return token
|
||||||
|
*/
|
||||||
|
public String getToken(){
|
||||||
|
String token = null;
|
||||||
|
if(redisService.hasKey(CommonConstant.BOULDER_ENERGY_TOKEN_KEY)){
|
||||||
|
token = (String)redisService.get(CommonConstant.BOULDER_ENERGY_TOKEN_KEY);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
Map<String, Object> params = Maps.newHashMap();
|
||||||
|
params.put("appAccount",APP_ACCOUNT);
|
||||||
|
params.put("appSecretKey",APP_SECRET_KEY);
|
||||||
|
try {
|
||||||
|
String json = HttpUtils.postWithJson(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("accessToken");
|
||||||
|
//redis 缓存
|
||||||
|
redisService.set(CommonConstant.BOULDER_ENERGY_TOKEN_KEY,token,50, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中车能源 - 统计数据
|
||||||
|
* @param beginTime 开始时间
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getBoulderData(String beginTime){
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("Authorization", getToken());
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("stationCode","SC020075040001");
|
||||||
|
params.put("time",beginTime);
|
||||||
|
String contentType = "application/json; charset=utf-8";
|
||||||
|
try {
|
||||||
|
String json = HttpUtils.postWithHeaders(BOULDER_DATA_URL,HttpUtils.mapToJson(params),contentType,headers);
|
||||||
|
log.info("MAIN_URL:" + BOULDER_DATA_URL);
|
||||||
|
log.info("json:" + json);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||||
|
String data = jsonObject.getString("data");
|
||||||
|
JSONObject dataJson = JSONObject.parseObject(data);
|
||||||
|
return dataJson.getString("records");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/*****************************************业务处理******************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中车 - 获取电站历史收益、充放电数据并存储
|
||||||
|
*/
|
||||||
|
public void getBoulderEleIncome(String beginTime){
|
||||||
|
DateTime yesterday = DateUtil.yesterday();
|
||||||
|
String yesterdayStr = DateUtil.formatDate(yesterday);
|
||||||
|
if(beginTime==null){
|
||||||
|
beginTime = yesterdayStr;
|
||||||
|
}
|
||||||
|
long timestamp = dateStringToTimestamp(beginTime);
|
||||||
|
String records = getBoulderData(String.valueOf(timestamp));
|
||||||
|
JSONArray data = JSON.parseArray(records);
|
||||||
|
String finalBeginTime = beginTime;
|
||||||
|
data.forEach(i->{
|
||||||
|
List<EarningsCalculate> list = new ArrayList<>();
|
||||||
|
List<ElecMeterValue> elecList = new ArrayList<>();
|
||||||
|
JSONObject obj = (JSONObject) i;
|
||||||
|
String date = timestampToDateString(obj.getLong("balanceDate"));
|
||||||
|
if(finalBeginTime.equals(date)){
|
||||||
|
//收益-充-尖
|
||||||
|
EarningsCalculate sharpCharge = new EarningsCalculate();
|
||||||
|
BigDecimal sharpChargeEle = obj.getBigDecimal("sharpChargeElectricity");
|
||||||
|
sharpCharge.setElec(sharpChargeEle);
|
||||||
|
sharpCharge.setType(0);
|
||||||
|
sharpCharge.setRateType(CommonConstant.RateType.TIP);
|
||||||
|
sharpCharge.setPrice(BigDecimal.ZERO);
|
||||||
|
sharpCharge.setDigital(BigDecimal.ZERO);
|
||||||
|
sharpCharge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(sharpCharge);
|
||||||
|
//收益-充-峰
|
||||||
|
EarningsCalculate peakCharge = new EarningsCalculate();
|
||||||
|
BigDecimal peakChargeEle = obj.getBigDecimal("peakChargeElectricity");
|
||||||
|
peakCharge.setElec(peakChargeEle);
|
||||||
|
peakCharge.setType(0);
|
||||||
|
peakCharge.setRateType(CommonConstant.RateType.PEAK);
|
||||||
|
peakCharge.setPrice(BigDecimal.ZERO);
|
||||||
|
peakCharge.setDigital(BigDecimal.ZERO);
|
||||||
|
peakCharge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(peakCharge);
|
||||||
|
//收益-充-平
|
||||||
|
EarningsCalculate flatCharge = new EarningsCalculate();
|
||||||
|
BigDecimal flatChargeEle = obj.getBigDecimal("flatChargeElectricity");
|
||||||
|
flatCharge.setElec(flatChargeEle);
|
||||||
|
flatCharge.setType(0);
|
||||||
|
flatCharge.setRateType(CommonConstant.RateType.FLAT);
|
||||||
|
flatCharge.setPrice(BigDecimal.ZERO);
|
||||||
|
flatCharge.setDigital(BigDecimal.ZERO);
|
||||||
|
flatCharge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(flatCharge);
|
||||||
|
//收益-充-谷
|
||||||
|
EarningsCalculate valleyCharge = new EarningsCalculate();
|
||||||
|
BigDecimal valleyChargeEle = obj.getBigDecimal("valleyChargeElectricity");
|
||||||
|
valleyCharge.setElec(valleyChargeEle);
|
||||||
|
valleyCharge.setType(0);
|
||||||
|
valleyCharge.setRateType(CommonConstant.RateType.VALLEY);
|
||||||
|
valleyCharge.setPrice(BigDecimal.ZERO);
|
||||||
|
valleyCharge.setDigital(BigDecimal.ZERO);
|
||||||
|
valleyCharge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(valleyCharge);
|
||||||
|
//收益-充-深谷
|
||||||
|
EarningsCalculate deepValleyCharge = new EarningsCalculate();
|
||||||
|
BigDecimal deepValleyChargeEle = obj.getBigDecimal("deepValleyChargeElectricity");
|
||||||
|
deepValleyCharge.setElec(deepValleyChargeEle);
|
||||||
|
deepValleyCharge.setType(0);
|
||||||
|
deepValleyCharge.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||||
|
deepValleyCharge.setPrice(BigDecimal.ZERO);
|
||||||
|
deepValleyCharge.setDigital(BigDecimal.ZERO);
|
||||||
|
deepValleyCharge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(deepValleyCharge);
|
||||||
|
//收益-放-尖
|
||||||
|
EarningsCalculate sharpDischarge = new EarningsCalculate();
|
||||||
|
BigDecimal reverseSharp = obj.getBigDecimal("sharpDischargeElectricity");
|
||||||
|
sharpDischarge.setElec(reverseSharp);
|
||||||
|
sharpDischarge.setType(1);
|
||||||
|
sharpDischarge.setRateType(CommonConstant.RateType.TIP);
|
||||||
|
sharpDischarge.setPrice(BigDecimal.ZERO);
|
||||||
|
sharpDischarge.setDigital(BigDecimal.ZERO);
|
||||||
|
sharpDischarge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(sharpDischarge);
|
||||||
|
//收益-放-峰
|
||||||
|
EarningsCalculate peakDischarge = new EarningsCalculate();
|
||||||
|
BigDecimal peakDischargeEle = obj.getBigDecimal("peakDischargeElectricity");
|
||||||
|
peakDischarge.setElec(peakDischargeEle);
|
||||||
|
peakDischarge.setType(1);
|
||||||
|
peakDischarge.setRateType(CommonConstant.RateType.PEAK);
|
||||||
|
peakDischarge.setPrice(BigDecimal.ZERO);
|
||||||
|
peakDischarge.setDigital(BigDecimal.ZERO);
|
||||||
|
peakDischarge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(peakDischarge);
|
||||||
|
//收益-放-平
|
||||||
|
EarningsCalculate flatDischarge = new EarningsCalculate();
|
||||||
|
BigDecimal flatDischargeEle = obj.getBigDecimal("flatDischargeElectricity");
|
||||||
|
flatDischarge.setElec(flatDischargeEle);
|
||||||
|
flatDischarge.setType(1);
|
||||||
|
flatDischarge.setRateType(CommonConstant.RateType.FLAT);
|
||||||
|
flatDischarge.setPrice(BigDecimal.ZERO);
|
||||||
|
flatDischarge.setDigital(BigDecimal.ZERO);
|
||||||
|
flatDischarge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(flatDischarge);
|
||||||
|
//收益-放-谷
|
||||||
|
EarningsCalculate valleyDischarge = new EarningsCalculate();
|
||||||
|
BigDecimal valleyDischargeEle = obj.getBigDecimal("valleyDischargeElectricity");
|
||||||
|
valleyDischarge.setElec(valleyDischargeEle);
|
||||||
|
valleyDischarge.setType(1);
|
||||||
|
valleyDischarge.setRateType(CommonConstant.RateType.VALLEY);
|
||||||
|
valleyDischarge.setPrice(BigDecimal.ZERO);
|
||||||
|
valleyDischarge.setDigital(BigDecimal.ZERO);
|
||||||
|
valleyDischarge.setTotal(BigDecimal.ZERO);
|
||||||
|
list.add(valleyDischarge);
|
||||||
|
//收益-放-深谷
|
||||||
|
EarningsCalculate deepValleyDischarge = new EarningsCalculate();
|
||||||
|
BigDecimal deepValleyDischargeEle = obj.getBigDecimal("deepValleyDischargeElectricity");
|
||||||
|
BigDecimal income = obj.getBigDecimal("income");
|
||||||
|
deepValleyDischarge.setElec(deepValleyDischargeEle);
|
||||||
|
deepValleyDischarge.setType(1);
|
||||||
|
deepValleyDischarge.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||||
|
deepValleyDischarge.setPrice(BigDecimal.ZERO);
|
||||||
|
deepValleyDischarge.setDigital(income);
|
||||||
|
deepValleyDischarge.setTotal(income);
|
||||||
|
list.add(deepValleyDischarge);
|
||||||
|
// 充电
|
||||||
|
ElecMeterValue charge = new ElecMeterValue();
|
||||||
|
BigDecimal chargeEle = obj.getBigDecimal("chargeElectricity");
|
||||||
|
charge.setDigital(chargeEle);
|
||||||
|
charge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.CHARGE);
|
||||||
|
charge.setStatus(CommonConstant.STATUS_FLAG);
|
||||||
|
elecList.add(charge);
|
||||||
|
// 放电
|
||||||
|
ElecMeterValue disCharge = new ElecMeterValue();
|
||||||
|
BigDecimal dischargeEle = obj.getBigDecimal("dischargeElectricity");
|
||||||
|
disCharge.setDigital(dischargeEle);
|
||||||
|
disCharge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.DISCHARGE);
|
||||||
|
disCharge.setStatus(CommonConstant.STATUS_FLAG);
|
||||||
|
elecList.add(disCharge);
|
||||||
|
|
||||||
|
if(elecList.size()>0){
|
||||||
|
//删除
|
||||||
|
elecMeterValueService.deleteByStationAndDay(BOULDER_STATION_ID,date,null);
|
||||||
|
elecList.forEach(eleMeter -> {
|
||||||
|
eleMeter.setGroupId(155);
|
||||||
|
eleMeter.setStationId(BOULDER_STATION_ID);
|
||||||
|
eleMeter.setCreateTime(new Date());
|
||||||
|
eleMeter.setDay(date);
|
||||||
|
//新增
|
||||||
|
elecMeterValueService.insert(eleMeter);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(list.size()>0){
|
||||||
|
//删除
|
||||||
|
earningsCalculateMapper.deleteByStationAndDay(date,null,BOULDER_STATION_ID);
|
||||||
|
list.forEach(a->{
|
||||||
|
a.setGroupId(155);
|
||||||
|
a.setStationId(BOULDER_STATION_ID);
|
||||||
|
a.setCreateTime(new Date());
|
||||||
|
a.setDay(date);
|
||||||
|
a.setDiscount(BigDecimal.ONE);
|
||||||
|
//新增
|
||||||
|
earningsCalculateMapper.insertSelective(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public void getCacheBoulderData(){
|
||||||
|
ShipStationRespVO vo = new ShipStationRespVO();
|
||||||
|
//查询电站收益数据
|
||||||
|
EarningsCalculateReq ec = new EarningsCalculateReq();
|
||||||
|
//昨日
|
||||||
|
DateTime yesterday = DateUtil.yesterday();
|
||||||
|
String yesterdayStr = DateUtil.formatDate(yesterday);
|
||||||
|
//今日
|
||||||
|
DateTime nowDay = DateUtil.date();
|
||||||
|
String nowDayStr = DateUtil.formatDate(nowDay);
|
||||||
|
//查询电站所有收益数据-组装参数
|
||||||
|
ec.setStationId(BOULDER_STATION_ID);
|
||||||
|
ec.setBeginTime(earningsCalculateMapper.getFirstTime());
|
||||||
|
ec.setEndTime(nowDayStr);
|
||||||
|
List<EarningsCalculate> earnList = earningsCalculateMapper.selectList(ec);
|
||||||
|
// 累计充电、放电、收益
|
||||||
|
BigDecimal incomeSum = earnList.stream().map(EarningsCalculate::getDigital).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal positivePowerSum = earnList.stream().filter(i->i.getType().equals(CommonConstant.ZERO)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal reversePowerSum = earnList.stream().filter(i->i.getType().equals(CommonConstant.ONE)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
vo.setIncomeSum(incomeSum.floatValue());
|
||||||
|
vo.setPositivePowerSum(positivePowerSum.floatValue());
|
||||||
|
vo.setReversePowerSum(reversePowerSum.floatValue());
|
||||||
|
// 昨日收益
|
||||||
|
BigDecimal incomeYesterday = earnList.stream().filter(i->i.getDay().equals(yesterdayStr)).map(EarningsCalculate::getDigital).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
vo.setIncomeYesterday(incomeYesterday.floatValue());
|
||||||
|
// 今日充、放电
|
||||||
|
BigDecimal positivePowerToday = earnList.stream().filter(i->i.getDay().equals(nowDayStr)&&i.getType().equals(CommonConstant.ZERO)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
vo.setPositivePowerToday(positivePowerToday.floatValue());
|
||||||
|
BigDecimal reversePowerToday = earnList.stream().filter(i->i.getDay().equals(nowDayStr)&&i.getType().equals(CommonConstant.ONE)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
vo.setReversePowerToday(reversePowerToday.floatValue());
|
||||||
|
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + BOULDER_STATION_ID;
|
||||||
|
redisService.set(mainKey,JSONObject.toJSONString(vo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间日期 转换为时间戳
|
||||||
|
* @param dateStr yyyy-MM-dd
|
||||||
|
* @return long 时间戳
|
||||||
|
*/
|
||||||
|
public static long dateStringToTimestamp(String dateStr) {
|
||||||
|
LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ISO_LOCAL_DATE);
|
||||||
|
return localDate.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 毫秒级时间戳 转换为日期 yyyy-MM-dd
|
||||||
|
* @param timestamp long 时间戳
|
||||||
|
* @return yyyy-MM-dd
|
||||||
|
*/
|
||||||
|
public static String timestampToDateString(long timestamp) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CommonConstant.DATE_YMD);
|
||||||
|
return Instant.ofEpochMilli(timestamp)
|
||||||
|
.atZone(ZoneId.systemDefault())
|
||||||
|
.format(formatter);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1447,15 +1447,14 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService {
|
|||||||
revenueOverview.setStationName(station.getName());
|
revenueOverview.setStationName(station.getName());
|
||||||
revenueOverview.setCapacity(station.getCapacity());
|
revenueOverview.setCapacity(station.getCapacity());
|
||||||
revenueOverview.setOperationDays((int) operationDays);
|
revenueOverview.setOperationDays((int) operationDays);
|
||||||
if(station.getId()==11003 || station.getId()==10942){
|
if(station.getId()==11003 || station.getId()==10942 ||station.getId()==11006){
|
||||||
// 寄点电站数据
|
// 寄点电站数据
|
||||||
Integer stationId = station.getId()-10000;
|
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + station.getId();
|
||||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + stationId;
|
|
||||||
String json = (String)redisService.get(mainKey);
|
String json = (String)redisService.get(mainKey);
|
||||||
ShipStationRespVO respVO = JSON.parseObject(json,ShipStationRespVO.class);
|
ShipStationRespVO respVO = JSON.parseObject(json,ShipStationRespVO.class);
|
||||||
revenueOverview.setCharging(BigDecimal.valueOf(respVO.getPositivePowerSum()));
|
revenueOverview.setCharging(respVO.getPositivePowerSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getPositivePowerSum()));
|
||||||
revenueOverview.setDischarging(BigDecimal.valueOf(respVO.getReversePowerSum()));
|
revenueOverview.setDischarging(respVO.getReversePowerSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getReversePowerSum()));
|
||||||
revenueOverview.setTotalRevenue(BigDecimal.valueOf(respVO.getIncomeSum()));
|
revenueOverview.setTotalRevenue(respVO.getIncomeSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getIncomeSum()));
|
||||||
return revenueOverview;
|
return revenueOverview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
package com.ho.business.controller;
|
||||||
|
|
||||||
|
import com.ho.business.service.BoulderEnergyService;
|
||||||
|
import com.ho.common.tools.annotation.TokenIgnore;
|
||||||
|
import com.ho.common.tools.constant.ContextConstant;
|
||||||
|
import com.ho.common.tools.exception.DataResult;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RequestMapping(ContextConstant.BUSINESS + "boulderEnergyStation")
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "业务模块-中车能源电站管理")
|
||||||
|
@Slf4j
|
||||||
|
public class BoulderEnergyController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
BoulderEnergyService boulderEnergyService;
|
||||||
|
|
||||||
|
@PostMapping("getToken")
|
||||||
|
@ApiOperation(value = "获取token")
|
||||||
|
@TokenIgnore
|
||||||
|
public DataResult<String> getToken() {
|
||||||
|
return DataResult.success(boulderEnergyService.getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("getBoulderEleIncome")
|
||||||
|
@ApiOperation(value = "中车-统计缓存充放电、及收益数据")
|
||||||
|
@TokenIgnore
|
||||||
|
public DataResult getBoulderEleIncome(@RequestBody(required = false) String beginTime) {
|
||||||
|
log.info("参数: {} ", beginTime);
|
||||||
|
// beginTime ==null 时统计昨日充放电、及收益数据
|
||||||
|
// beginTime !=null 时统计beginTime充放电、及收益数据
|
||||||
|
boulderEnergyService.getBoulderEleIncome(beginTime);
|
||||||
|
if(beginTime!=null){
|
||||||
|
//beginTime !=null 缓存中车电站累计数据
|
||||||
|
boulderEnergyService.getCacheBoulderData();
|
||||||
|
}
|
||||||
|
return DataResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1046,6 +1046,10 @@ public interface CommonConstant {
|
|||||||
* 寄点 token 缓存 key
|
* 寄点 token 缓存 key
|
||||||
*/
|
*/
|
||||||
String SHIP_ENERGY_TOKEN_KEY = "ShipEnergyToken";
|
String SHIP_ENERGY_TOKEN_KEY = "ShipEnergyToken";
|
||||||
|
/**
|
||||||
|
* 中车 token 缓存 key
|
||||||
|
*/
|
||||||
|
String BOULDER_ENERGY_TOKEN_KEY = "BoulderEnergyToken";
|
||||||
/**
|
/**
|
||||||
* 监控数据
|
* 监控数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -77,4 +77,9 @@ public interface BusinessFeignClient {
|
|||||||
|
|
||||||
@PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "shipEnergyStation/getStationIncomeHis")
|
@PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "shipEnergyStation/getStationIncomeHis")
|
||||||
void jobCacheShipEleIncome(@RequestBody String dateTime);
|
void jobCacheShipEleIncome(@RequestBody String dateTime);
|
||||||
|
|
||||||
|
@PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "boulderEnergyStation/getBoulderEleIncome")
|
||||||
|
void jobBoulderEleIncome(@RequestBody String dateTime);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,4 +123,9 @@ public class BusinessFeignClientFallback implements BusinessFeignClient {
|
|||||||
throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL);
|
throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void jobBoulderEleIncome(String dateTime) {
|
||||||
|
log.error("BusinessFeignClient.jobBoulderEleIncome error!");
|
||||||
|
throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user