dev #2

Merged
dashixiong merged 349 commits from dev into main 2026-02-11 01:55:46 +00:00
344 changed files with 50445 additions and 1113 deletions
Showing only changes of commit fc5f56b3b0 - Show all commits

View File

@ -953,9 +953,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
// 处理电表每日充放电数据
if (!deviceId.contains(SiteDevice.METEGF.name()) && !deviceId.contains(SiteDevice.METE0.name())) {
if (SiteEnum.FX.getCode().equals(siteId)) {
dealAmmeterDailyDate(siteId, obj, dataUpdateTime, lastAmmeterData);
dealAmmeterDailyDate(siteId, dataMete, dataUpdateTime, lastAmmeterData);
} else if (SiteEnum.DDS.getCode().equals(siteId)) {
dealDDSDailyChargeDate(siteId, obj, deviceId);
dealDDSDailyChargeDate(siteId, dataMete, deviceId);
}
}
}
@ -976,13 +976,15 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
return lastData;
}
private void dealDDSDailyChargeDate(String siteId, Map<String, Object> obj, String deviceId) {
private void dealDDSDailyChargeDate(String siteId, EmsAmmeterData currentData, String deviceId) {
// 初始化今日充放电
BigDecimal dailyDisChargeDate = new BigDecimal(0);
BigDecimal dailyChargeDate = new BigDecimal(0);
BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN"));
BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN"));
// BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN"));
// BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN"));
BigDecimal nowTotalDisChargeDate = currentData.getCurrentReverseActiveTotal();
BigDecimal nowTotalChargeDate = currentData.getCurrentForwardActiveTotal();
// 初始化当日数据-总的
EmsDailyChargeData emsDailyChargeData = initDailyChargeData(siteId, deviceId, nowTotalChargeDate, nowTotalDisChargeDate);
// 获取redis存放昨日最晚数据
@ -1012,7 +1014,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
// 初始化数据-尖峰平谷
EmsDailyEnergyData energyData = initEnergyData(siteId);
// 计算尖峰平谷差值,更新表
calcEnergyDiffAndRevenue(siteId, energyData, obj, yestData);
calcEnergyDiffAndRevenue(siteId, energyData, currentData, yestData);
energyData.setCalcTime(DateUtils.getNowDate());
// 插入或更新电表每日差值数据表
emsDailyEnergyDataMapper.insertOrUpdateData(energyData);
@ -1033,7 +1035,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
return emsDailyChargeData;
}
private void calcEnergyDiffAndRevenue(String siteId, EmsDailyEnergyData energyData, Map<String, Object> obj, EmsAmmeterData yestData) {
private void calcEnergyDiffAndRevenue(String siteId, EmsDailyEnergyData energyData, EmsAmmeterData currentData, EmsAmmeterData yestData) {
// 获取当月电价
String key = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue();
@ -1041,31 +1043,47 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
// 计算尖峰平谷差值
// 正反向-尖
BigDecimal peakChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))
// BigDecimal peakChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActivePeak());
BigDecimal peakChargeDiff = currentData.getCurrentForwardActivePeak()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActivePeak());
energyData.setPeakChargeDiff(peakChargeDiff);
BigDecimal peakDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))
// BigDecimal peakDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActivePeak());
BigDecimal peakDischargeDiff = currentData.getCurrentReverseActivePeak()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActivePeak());
energyData.setPeakDischargeDiff(peakDischargeDiff);
// 正反向-峰
BigDecimal highChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))
// BigDecimal highChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveHigh());
BigDecimal highChargeDiff = currentData.getCurrentForwardActiveHigh()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveHigh());
energyData.setHighChargeDiff(highChargeDiff);
BigDecimal highDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))
// BigDecimal highDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveHigh());
BigDecimal highDischargeDiff = currentData.getCurrentReverseActiveHigh()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveHigh());
energyData.setHighDischargeDiff(highDischargeDiff);
// 正反向-平
BigDecimal flatChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))
// BigDecimal flatChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveFlat());
BigDecimal flatChargeDiff = currentData.getCurrentForwardActiveFlat()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveFlat());
energyData.setFlatChargeDiff(flatChargeDiff);
BigDecimal flatDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))
// BigDecimal flatDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveFlat());
BigDecimal flatDisChargeDiff = currentData.getCurrentReverseActiveFlat()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveFlat());
energyData.setFlatDischargeDiff(flatDisChargeDiff);
// 正反向-谷
BigDecimal valleyChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))
// BigDecimal valleyChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveValley());
BigDecimal valleyChargeDiff = currentData.getCurrentForwardActiveValley()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveValley());
energyData.setValleyChargeDiff(valleyChargeDiff);
BigDecimal valleyDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))
// BigDecimal valleyDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))
// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveValley());
BigDecimal valleyDisChargeDiff = currentData.getCurrentReverseActiveValley()
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveValley());
energyData.setValleyDischargeDiff(valleyDisChargeDiff);
@ -1109,7 +1127,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
return yestLastTotalRevenue;
}
private void dealAmmeterDailyDate(String siteId, Map<String, Object> obj, Date dataUpdateTime, EmsAmmeterData lastData) {
private void dealAmmeterDailyDate(String siteId, EmsAmmeterData currentData, Date dataUpdateTime, EmsAmmeterData lastData) {
// 先获取当月电价配置redis没有这查数据库都没有则返回
String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue();
EnergyPriceVo priceVo = redisCache.getCacheObject(priceKey);
@ -1143,16 +1161,18 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
EmsDailyEnergyData energyData = initEnergyData(siteId);
// 根据 costType计算本次与上次数据差值累加到对应的数据类型里面
setDiffByCostType(siteId, costType, energyData, lastData, obj, priceVo);
setDiffByCostType(siteId, costType, energyData, lastData, currentData, priceVo);
// 插入或更新电表每日差值数据表
emsDailyEnergyDataMapper.insertOrUpdateData(energyData);
}
private void setDiffByCostType(String siteId, String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData,
Map<String, Object> obj, EnergyPriceVo priceVo) {
BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN"));
BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN"));
EmsAmmeterData currentData, EnergyPriceVo priceVo) {
// BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN"));
// BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN"));
BigDecimal currentChargeData = currentData.getCurrentForwardActiveTotal();
BigDecimal currentDischargeData = currentData.getCurrentReverseActiveTotal();
currentChargeData = currentChargeData != null ? currentChargeData : BigDecimal.ZERO;
currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO;