Quellcode durchsuchen

Merge remote-tracking branch 'origin/fpg-master' into fpg-master

lingpeng.li vor 6 Monaten
Ursprung
Commit
53dc8608c6

+ 4 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/devicePoint/entity/DevicePoint.java

@@ -106,6 +106,10 @@ public class DevicePoint implements Serializable {
 	@Excel(name = "采集状态", width = 15)
     @ApiModelProperty(value = "采集状态")
     private String gatherStatus;
+    /**电流(Ia)or功率(P)*/
+    @Excel(name = "电流(Ia)or功率(P)", width = 15)
+    @ApiModelProperty(value = "电流(Ia)or功率(P)")
+    private String CurrentPower;
 	/**测试结果*/
 	@Excel(name = "测试结果", width = 15)
     @ApiModelProperty(value = "测试结果")

+ 25 - 12
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.fpgJob;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -14,7 +15,9 @@ import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
 import org.jeecg.modules.gatherData.entity.*;
 import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
 import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.SystemVariable;
 import org.jeecg.modules.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.ISystemVariableService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
@@ -57,6 +60,9 @@ public class LeanModelStatistics {
     @Autowired
     private IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
 
+    @Autowired
+    private ISystemVariableService systemVariableService;
+
     @Autowired
     MongoTemplate mongoTemplate;
 
@@ -65,7 +71,7 @@ public class LeanModelStatistics {
      * 精益模型统计数据
      * 执行完后,间隔1秒继续执行
      */
-    @Scheduled(fixedDelay = 1000)
+    @Scheduled(fixedDelay = 10000)
     public void t1(){
         leanModel();
     }
@@ -83,7 +89,7 @@ public class LeanModelStatistics {
     /**
      * 设备启停统计数据
      */
-    @Scheduled(fixedDelay = 1000)
+    @Scheduled(fixedDelay = 10000)
     public void t3(){
         deviceStatistics();
     }
@@ -150,8 +156,15 @@ public class LeanModelStatistics {
             // 采集点组合
 //            List<String> idsPoint = devicePointList.stream().map(DevicePoint::getId).collect(Collectors.toList());
             // 查询设备对应数据
-            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgTotalUpdatetime, null).in(FpgGatherData::getDeviceInformationId, deviceInformationlinfo.getId());
+            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgTotalUpdatetime).eq(FpgGatherData::getDeviceInformationId, deviceInformationlinfo.getId());
             List<FpgGatherData> fpgGatherList = fpgGatherDataService.list(fpgGatherQuery);
+
+            // 系统变量查询
+            QueryWrapper<SystemVariable> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("variable_address", "sys_run_current_limit");
+            queryWrapper.eq("status",  0);
+            SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
+
             // 处理数据业务逻辑
             fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
                 try {
@@ -178,7 +191,7 @@ public class LeanModelStatistics {
                         }
                     });
                     // 功率
-                    BigDecimal runPower = fpgGatherData.getActivePower();
+                    BigDecimal runPower = fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal(12), 6, RoundingMode.HALF_UP) : fpgGatherData.getActivePower();
                     // 运行时常
                     BigDecimal runTime = new BigDecimal("300");
                     // 电流
@@ -191,7 +204,7 @@ public class LeanModelStatistics {
                             .addCriteria(Criteria.where("deviceRegionId").is(fpgGatherData.getDeviceRegionId()))
                             .addCriteria(Criteria.where("deviceInformationId").is(fpgGatherData.getDeviceInformationId()));
                     // 设备停止 start
-                    if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal("5")) < 0){ // 设备停止运行 直接更新停止时间结束不用统计任何东西
+                    if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0){ // 设备停止运行 直接更新停止时间结束不用统计任何东西
 //                        queryStartStop.addCriteria(Criteria.where("deviceStopTime").is(null));
                         UpdateDefinition updateStartStop = new Update()
                                 .set("updateTime", curentDate).set("deviceStopTime", DateUtils.date2Str(curentDate, DateUtils.datetimeFormat.get()));
@@ -207,7 +220,7 @@ public class LeanModelStatistics {
                             BigDecimal oldSelectricCurrent = startStopMongo.getSelectricCurrent() == null ? new BigDecimal("0.00") : startStopMongo.getSelectricCurrent();
                             // 更新启动运行数据
                             UpdateDefinition updateStartStop = new Update()
-                                    .set("power", oldPower.add(runPower.divide(new BigDecimal("12"))))
+                                    .set("power", runPower.compareTo(new BigDecimal("0.00")) > 0 ? oldPower.add(runPower) : 0.00)
                                     .set("selectricCurrent", oldSelectricCurrent.add(selectricCurrent))
                                     .set("ingTime", oldRunTime.add(runTime))
                                     .set("updateTime", curentDate);
@@ -239,7 +252,7 @@ public class LeanModelStatistics {
                         if("tops".equals(jfpgStr.get())){ // 尖
                             // 功率处理
                             BigDecimal oldtopsPower = dayPowerproportioncurrentMongo.getTopsPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getTopsPower();
-                            BigDecimal topsPower = oldtopsPower.add(runPower.divide(new BigDecimal("12")));
+                            BigDecimal topsPower = oldtopsPower.add(runPower);
                             ((Update) update).set("topsPower", topsPower);
                             // 运行时常处理
                             BigDecimal oldtopsIngTime = dayPowerproportioncurrentMongo.getTopsIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getTopsIngTime();
@@ -251,7 +264,7 @@ public class LeanModelStatistics {
                         } else if("peaks".equals(jfpgStr.get())){ // 峰
                             // 功率处理
                             BigDecimal oldpeaksPower = dayPowerproportioncurrentMongo.getPeaksPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksPower();
-                            BigDecimal peaksPower = oldpeaksPower.add(runPower.divide(new BigDecimal("12")));
+                            BigDecimal peaksPower = oldpeaksPower.add(runPower);
                             ((Update) update).set("peaksPower", peaksPower);
                             // 运行时常处理
                             BigDecimal oldpeaksIngTime = dayPowerproportioncurrentMongo.getPeaksIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksIngTime();
@@ -263,7 +276,7 @@ public class LeanModelStatistics {
                         } else if("flat".equals(jfpgStr.get())){ // 平
                             // 功率处理
                             BigDecimal oldflatPower = dayPowerproportioncurrentMongo.getFlatPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatPower();
-                            BigDecimal flatPower = oldflatPower.add(runPower.divide(new BigDecimal("12")));
+                            BigDecimal flatPower = oldflatPower.add(runPower);
                             ((Update) update).set("flatPower", flatPower);
                             // 运行时常处理
                             BigDecimal oldflatIngTime = dayPowerproportioncurrentMongo.getFlatIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatIngTime();
@@ -275,7 +288,7 @@ public class LeanModelStatistics {
                         } else if("valleys".equals(jfpgStr.get())){ // 谷
                             // 功率处理
                             BigDecimal oldvalleysPower = dayPowerproportioncurrentMongo.getValleysPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysPower();
-                            BigDecimal valleysPower = oldvalleysPower.add(runPower.divide(new BigDecimal("12")));
+                            BigDecimal valleysPower = oldvalleysPower.add(runPower);
                             ((Update) update).set("valleysPower", oldvalleysPower.add(runPower));
                             // 运行时常处理
                             BigDecimal oldvalleysIngTime = dayPowerproportioncurrentMongo.getValleysIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysIngTime();
@@ -316,7 +329,7 @@ public class LeanModelStatistics {
         List<FpgGatherData> fpgGatherUpdateList= new ArrayList<>();
         // 遍历设备集合
         fpgLeanModellist.forEach(fpgLeanModeInfo -> {
-            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgModelUpdatetime, null);
+            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgModelUpdatetime);
             // 检测是否配置设备特殊条件
             if(oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds()) && oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds())){
                 fpgGatherQuery.in(FpgGatherData::getDeviceInformationId, Arrays.asList(fpgLeanModeInfo.getDeviceInformationIds().split(",")));
@@ -398,7 +411,7 @@ public class LeanModelStatistics {
                         UpdateDefinition update = new Update();
                         ((Update) update).set("updateTime", curentDate);
                         // 功率 5 分钟上报一次  除以 12
-                        BigDecimal activePower = fpgGatherData.getActivePower() == null ? new BigDecimal("0.00") : fpgGatherData.getActivePower().divide(new BigDecimal("12"));
+                        BigDecimal activePower = fpgGatherData.getActivePower() == null ? new BigDecimal("0.00") : fpgGatherData.getActivePower().divide(new BigDecimal("12"), 6, RoundingMode.HALF_UP);
                         // 电流
                         BigDecimal selectricCurrent = fpgGatherData.getRunCurrent() == null ? new BigDecimal("0.00") : fpgGatherData.getRunCurrent();
                         BigDecimal runTime = new BigDecimal("300");

+ 3 - 3
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/impl/LeanEventWarnInfoServiceImpl.java

@@ -458,9 +458,9 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
      */
     public List<FpgStatiscsModelMongodb> queryByTimeRanges(MongoTemplate mongoTemplate, List<Date[]> timeRanges, String devicePointId, String deviceInformationId, String deviceRegionId) {
         Query query = new Query();
-        String devicePointIds = Arrays.stream(devicePointId.split(",")).collect(Collectors.joining("|"));
-        // 设置devicePointId的查询条件,使用正则表达式
-        query.addCriteria(Criteria.where("devicePointId").regex(devicePointIds));
+//        String devicePointIds = Arrays.stream(devicePointId.split(",")).collect(Collectors.joining("|"));
+//        // 设置devicePointId的查询条件,使用正则表达式
+//        query.addCriteria(Criteria.where("devicePointId").regex(devicePointIds));
         query.addCriteria(Criteria.where("deviceInformationId").is(deviceInformationId));
         query.addCriteria(Criteria.where("deviceRegionId").is(deviceRegionId));
         // 使用Criteria添加多个时间范围条件

+ 2 - 2
jeecg-module-gather/src/main/java/org/jeecg/modules/utils/ConnectionUtils.java

@@ -10,9 +10,9 @@ import java.sql.*;
 public class ConnectionUtils {
 
     // PostgreSQL JDBC 连接URL
-    private static final String URL = "jdbc:postgresql://182.22.0.182:10102/history?useUnicode=true&ssl=false";
+    private static final String URL = "jdbc:postgresql://192.168.13.197:5432/epower?useUnicode=true&ssl=false&currentSchema=history";
     private static final String USERNAME = "postgres"; // PostgreSQL 用户名
-    private static final String PASSWORD = "5159273CFBC5";     // PostgreSQL 密码
+    private static final String PASSWORD = "1qaz2wsx..";     // PostgreSQL 密码
 
     /**
      * 获取连接