fix:修改物联设备倍率为乘法,添加能耗报表数值倍率展示

main
HuangHuiKang 1 day ago
parent aa0afdb345
commit 1f65f01605

@ -650,7 +650,7 @@ public class DeviceServiceImpl implements DeviceService {
try { try {
Double result = Double.parseDouble(value.toString()); Double result = Double.parseDouble(value.toString());
return (ratio != null && ratio != 0.0) ? result / ratio : result; return ratio != null ? result * ratio : result;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return value; // 转换失败返回原值 return value; // 转换失败返回原值
} }

@ -379,7 +379,7 @@ public class EnergyDeviceServiceImpl implements EnergyDeviceService {
// 保留2位小数 // 保留2位小数
BigDecimal bd = new BigDecimal(value.toString()); BigDecimal bd = new BigDecimal(value.toString());
Double finalValue = bd.setScale(2, RoundingMode.HALF_UP).doubleValue(); Double finalValue = adjustByRatio(bd.setScale(2, RoundingMode.HALF_UP).doubleValue(), pointInfo.getRatio());
pointValueMap.put(pointId, finalValue); pointValueMap.put(pointId, finalValue);
} catch (Exception e) { } catch (Exception e) {
log.warn("点位值转换失败, pointId={}, value={}, dataType={}", pointId, value, pointInfo.getDataType(), e); log.warn("点位值转换失败, pointId={}, value={}, dataType={}", pointId, value, pointInfo.getDataType(), e);
@ -521,7 +521,7 @@ public class EnergyDeviceServiceImpl implements EnergyDeviceService {
if (value != null) { if (value != null) {
try { try {
BigDecimal bd = new BigDecimal(value.toString()); BigDecimal bd = new BigDecimal(value.toString());
pointValueMap.put(pointId, bd.setScale(2, RoundingMode.HALF_UP).doubleValue()); pointValueMap.put(pointId, adjustByRatio(bd.setScale(2, RoundingMode.HALF_UP).doubleValue(), pointInfo.getRatio()));
} catch (Exception e) { } catch (Exception e) {
log.warn("点位值转换失败, pointId={}, value={}, dataType={}", pointId, value, pointInfo.getDataType(), e); log.warn("点位值转换失败, pointId={}, value={}, dataType={}", pointId, value, pointInfo.getDataType(), e);
} }
@ -726,7 +726,7 @@ public class EnergyDeviceServiceImpl implements EnergyDeviceService {
pointInfo.getDataType(), pointInfo.getDataType(),
value.toString() value.toString()
); );
Double finalValue = convertToDouble(converted); Double finalValue = adjustByRatio(convertToDouble(converted), pointInfo.getRatio());
valueMap.put(pointId, finalValue); valueMap.put(pointId, finalValue);
} catch (Exception e) { } catch (Exception e) {
log.warn("点位值转换失败, pointId={}, value={}, dataType={}", pointId, value, pointInfo.getDataType(), e); log.warn("点位值转换失败, pointId={}, value={}, dataType={}", pointId, value, pointInfo.getDataType(), e);
@ -978,7 +978,7 @@ public class EnergyDeviceServiceImpl implements EnergyDeviceService {
continue; continue;
} }
try { try {
pointValueMap.put(rule.getPointId(), new BigDecimal(value.toString()).setScale(2, RoundingMode.HALF_UP).doubleValue()); pointValueMap.put(rule.getPointId(), adjustByRatio(new BigDecimal(value.toString()).setScale(2, RoundingMode.HALF_UP).doubleValue(), pointInfo.getRatio()));
} catch (Exception e) { } catch (Exception e) {
log.warn("解析趋势点位值失败, deviceId={}, pointId={}, value={}", deviceId, rule.getPointId(), value, e); log.warn("解析趋势点位值失败, deviceId={}, pointId={}, value={}", deviceId, rule.getPointId(), value, e);
} }
@ -1151,6 +1151,13 @@ public class EnergyDeviceServiceImpl implements EnergyDeviceService {
return vo; return vo;
} }
private Double adjustByRatio(Double value, Double ratio) {
if (value == null) {
return null;
}
return ratio != null ? value * ratio : value;
}
/** 根据规则计算总值 */ /** 根据规则计算总值 */
private Double calculateByRules( private Double calculateByRules(
Long energyDeviceId, Long energyDeviceId,

Loading…
Cancel
Save