|
@@ -15,6 +15,7 @@ import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
|
|
|
import org.jeecg.modules.peaksAndValleysTimeConfig.entity.SystemVariable;
|
|
|
import org.jeecg.modules.peaksAndValleysTimeConfig.service.ISystemVariableService;
|
|
|
import org.jeecg.modules.utils.PostgreSQLUtil;
|
|
|
+import org.jeecg.modules.utils.PowerCalculatorUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -119,11 +120,29 @@ public class PostgreSQLWatch {
|
|
|
if (fpgGatherData == null) { // 直接新增
|
|
|
FpgGatherData fpgGatherInsert = new FpgGatherData();
|
|
|
fpgGatherInsert.setCreateTime(timestamp);
|
|
|
- // 处理电流+电压
|
|
|
+ // 根据 point_code 和电流或功率的类型进行判断
|
|
|
if ("Ia".equals(point.getCurrentPower())) {
|
|
|
- fpgGatherInsert.setRunCurrent(value);
|
|
|
+ // 如果 point_code 为 YC.3167 或 YC.3151,计算功率
|
|
|
+ if ("YC.3167".equals(point.getPointCode()) || "YC.3151".equals(point.getPointCode())) {
|
|
|
+ BigDecimal powerValue = PowerCalculatorUtil.calculateThreePhasePowerInKW(
|
|
|
+ new BigDecimal("10000"), // 假设电压为 10kV,这里可以替换为实际电压值
|
|
|
+ value, // 当前电流值
|
|
|
+ new BigDecimal("0.8") // 假设功率因数为 0.8,这里可以替换为实际功率因数
|
|
|
+ );
|
|
|
+ fpgGatherInsert.setRunCurrent(value);
|
|
|
+ fpgGatherInsert.setActivePower(powerValue);
|
|
|
+ } else {
|
|
|
+ // 如果不满足条件,直接设置电流
|
|
|
+ fpgGatherInsert.setRunCurrent(value);
|
|
|
+ }
|
|
|
} else if ("P".equals(point.getCurrentPower())) {
|
|
|
- fpgGatherInsert.setActivePower(value);
|
|
|
+ // 如果 point_code 为 YC.3154 或 YC.3168,不进行任何处理
|
|
|
+ if ("YC.3154".equals(point.getPointCode()) || "YC.3168".equals(point.getPointCode())) {
|
|
|
+ continue; // 跳过后续处理
|
|
|
+ } else {
|
|
|
+ // 正常设置功率
|
|
|
+ fpgGatherInsert.setActivePower(value);
|
|
|
+ }
|
|
|
}
|
|
|
fpgGatherInsert.setDevicePointId(pointIdListStrs);
|
|
|
fpgGatherInsert.setDeviceInformationId(point.getDeviceId());
|
|
@@ -134,11 +153,28 @@ public class PostgreSQLWatch {
|
|
|
} else { // 编辑处理
|
|
|
// 处理数据点类型和值的累计
|
|
|
if ("Ia".equals(point.getCurrentPower())) {
|
|
|
- BigDecimal runCurrent = fpgGatherData.getRunCurrent() == null ? value : fpgGatherData.getRunCurrent().add(value);
|
|
|
- fpgGatherData.setRunCurrent(runCurrent);
|
|
|
+ if ("YC.3167".equals(point.getPointCode()) || "YC.3151".equals(point.getPointCode())) {
|
|
|
+ BigDecimal powerValue = PowerCalculatorUtil.calculateThreePhasePowerInKW(
|
|
|
+ new BigDecimal("10000"), // 假设电压为 10kV,这里可以替换为实际电压值
|
|
|
+ value, // 当前电流值
|
|
|
+ new BigDecimal("0.8") // 假设功率因数为 0.8,这里可以替换为实际功率因数
|
|
|
+ );
|
|
|
+ BigDecimal runCurrent = fpgGatherData.getRunCurrent() == null ? value : fpgGatherData.getRunCurrent().add(value);
|
|
|
+ fpgGatherData.setRunCurrent(runCurrent);
|
|
|
+ BigDecimal activePower = fpgGatherData.getActivePower() == null ? powerValue : fpgGatherData.getActivePower().add(powerValue);
|
|
|
+ fpgGatherData.setActivePower(activePower);
|
|
|
+ } else {
|
|
|
+ BigDecimal runCurrent = fpgGatherData.getRunCurrent() == null ? value : fpgGatherData.getRunCurrent().add(value);
|
|
|
+ fpgGatherData.setRunCurrent(runCurrent);
|
|
|
+ }
|
|
|
} else if ("P".equals(point.getCurrentPower())) {
|
|
|
- BigDecimal activePower = fpgGatherData.getActivePower() == null ? value : fpgGatherData.getActivePower().add(value);
|
|
|
- fpgGatherData.setActivePower(activePower);
|
|
|
+ if ("YC.3154".equals(point.getPointCode()) || "YC.3168".equals(point.getPointCode())) {
|
|
|
+ // 跳过特殊点的处理
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ BigDecimal activePower = fpgGatherData.getActivePower() == null ? value : fpgGatherData.getActivePower().add(value);
|
|
|
+ fpgGatherData.setActivePower(activePower);
|
|
|
+ }
|
|
|
}
|
|
|
fpgGatherData.setId(fpgGatherData.getId());
|
|
|
fpgGatherDataMapper.updateById(fpgGatherData);
|