Bläddra i källkod

调整 数据统计 峰平谷

guoqiang 5 månader sedan
förälder
incheckning
c337ee6022

+ 40 - 107
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -71,7 +71,7 @@ public class LeanModelStatistics {
      * 精益模型统计数据
      * 执行完后,间隔1秒继续执行
      */
-    @Scheduled(fixedDelay = 40000)
+    @Scheduled(cron = "0 0/1 * * * *")
     public void t1(){
         leanModel();
     }
@@ -89,7 +89,7 @@ public class LeanModelStatistics {
     /**
      * 设备启停统计数据
      */
-    @Scheduled(fixedDelay = 30000)
+    @Scheduled(cron = "0 0/1 * * * *")
     public void t3(){
         deviceStatistics();
     }
@@ -118,16 +118,16 @@ public class LeanModelStatistics {
                 UpdateDefinition update = new Update();
                 ((Update) update).set("proportion", 2);
                 if(topsProportion.compareTo(new BigDecimal("0.00")) > 0) { // 尖
-                    ((Update) update).set("topsProportion", topsProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                    ((Update) update).set("topsProportion", topsProportion.divide(proportion, 4, RoundingMode.HALF_UP).multiply(zb));
                 }
                 if(peaksProportion.compareTo(new BigDecimal("0.00")) > 0) { // 峰
-                    ((Update) update).set("peaksProportion", peaksProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                    ((Update) update).set("peaksProportion", peaksProportion.divide(proportion, 4, RoundingMode.HALF_UP).multiply(zb));
                 }
                 if(flatProportion.compareTo(new BigDecimal("0.00")) > 0) { // 平
-                    ((Update) update).set("flatProportion", flatProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                    ((Update) update).set("flatProportion", flatProportion.divide(proportion, 4, RoundingMode.HALF_UP).multiply(zb));
                 }
                 if(valleysProportion.compareTo(new BigDecimal("0.00")) > 0) { // 谷
-                    ((Update) update).set("valleysProportion", valleysProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                    ((Update) update).set("valleysProportion", valleysProportion.divide(proportion, 4, RoundingMode.HALF_UP).multiply(zb));
                 }
                 // 保存
                 mongoTemplate.updateFirst(query, update, FpgStatiscsModelMongodb.class, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
@@ -150,24 +150,14 @@ public class LeanModelStatistics {
         BigDecimal zb = new BigDecimal("100");
         //遍历设备集合
         deviceInformationllist.forEach(deviceInformationlinfo -> {
-            // 查询采集点
-//            LambdaQueryWrapper<DevicePoint> devicePointQuery = new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId, deviceInformationlinfo.getId());
-//            List<DevicePoint> devicePointList = devicePointService.list(devicePointQuery);
-//            if(oConvertUtils.listIsEmpty(devicePointList)){
-//                return;
-//            }
-            // 采集点组合
-//            List<String> idsPoint = devicePointList.stream().map(DevicePoint::getId).collect(Collectors.toList());
             // 查询设备对应数据
-            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgTotalUpdatetime).eq(FpgGatherData::getDeviceInformationId, deviceInformationlinfo.getId()).isNotNull(FpgGatherData::getRunCurrent).isNotNull(FpgGatherData::getActivePower).orderByAsc(FpgGatherData::getCreateTime);
+            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgTotalUpdatetime).eq(FpgGatherData::getDeviceInformationId, deviceInformationlinfo.getId()).isNotNull(FpgGatherData::getRunCurrent).isNotNull(FpgGatherData::getActivePower).orderByAsc(FpgGatherData::getCreateTime).last("limit 1000");
             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 {
@@ -195,6 +185,8 @@ public class LeanModelStatistics {
                     });
                     // 功率
                     BigDecimal runPower = fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal(12), 8, RoundingMode.HALF_UP) : fpgGatherData.getActivePower();
+                    // 占比
+                    BigDecimal proportion = new BigDecimal("0.00");
                     // 运行时常
                     BigDecimal runTime = new BigDecimal("300");
                     // 电流
@@ -209,77 +201,60 @@ public class LeanModelStatistics {
                             .with(Sort.by(Sort.Order.desc("deviceStartTime"))).limit(1);
                     // 查找设备运行记录
                     DeviceStatiscsModelMongodb startStopMongo = mongoTemplate.findOne(queryStartStop, DeviceStatiscsModelMongodb.class, startStopMonKey);
-                    if(startStopMongo != null){
-                        // 验证两个时间是否相等
-                        int timeRes = compareDatesByTimeStamp(DateUtils.str2Date(startStopMongo.getDeviceStartTime(), DateUtils.datetimeFormat.get()), DateUtils.str2Date(startStopMongo.getDeviceStopTimeBank(), DateUtils.datetimeFormat.get()));
-//                        Date deviceStopTimeEnd = DateUtils.addHours(fpgGatherData.getCreateTime(), 8);
+                    if(startStopMongo != null){ // 存在该设备记录
                         Date deviceStopTimeEnd = DateUtils.addHours(fpgGatherData.getCreateTime(), 0);
-                        if (fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0) { // 设备停止运行 直接更新停止时间结束不用统计任何东西
+                        if (fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0 && "1".equals(startStopMongo.getDeviceStopTimeBank())) {
+                            // 设备正常运行的 直接停止更新启停时间
                             Date startDate = dateFormat.parse(startStopMongo.getDeviceStartTime());
-
                             // 将 Date 转换为 Instant
                             Instant oldInstant = startDate.toInstant();
                             Instant newInstant = fpgGatherData.getCreateTime().toInstant();
-
                             // 计算时间差
                             Duration duration = Duration.between(oldInstant, newInstant);
-
                             // 获取时间差的秒数
                             long diffInSeconds = duration.getSeconds();
-
                             BigDecimal timeDifference = new BigDecimal(diffInSeconds);
-
                             UpdateDefinition updateStartStop = new Update()
                                     .set("updateTime", curentDate).set("deviceStopTime", DateUtils.date2Str(deviceStopTimeEnd, DateUtils.datetimeFormat.get()))
-                                    .set("deviceStopTimeBank", DateUtils.date2Str(deviceStopTimeEnd, DateUtils.datetimeFormat.get())).set("ingTime", timeDifference);
-
+                                    .set("deviceStopTimeBank", "2").set("ingTime", timeDifference);
                             Query modifyStartStop = new Query()
                                     .addCriteria(Criteria.where("deviceRegionId").is(fpgGatherData.getDeviceRegionId()))
                                     .addCriteria(Criteria.where("deviceInformationId").is(fpgGatherData.getDeviceInformationId()))
                                     .addCriteria(Criteria.where("_id").is(startStopMongo.get_id()));
                             mongoTemplate.findAndModify(modifyStartStop, updateStartStop, DeviceStatiscsModelMongodb.class, startStopMonKey);
-                        } else if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) > 0 && timeRes != 0){ // 设备重新启动
-                            startStopStatiscsData.setPower(runPower);
-                            startStopStatiscsData.setIngTime(runTime);
-                            startStopStatiscsData.setSelectricCurrent(selectricCurrent);
-                            mongoTemplate.insert(startStopStatiscsData, startStopMonKey);
-//                            return;
-                        } else { // 设备运行累加
-                            // 历史数据
+                        } else if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) > 0  && "1".equals(startStopMongo.getDeviceStopTimeBank())){
+                            // 设备运行累加运行记录
                             BigDecimal oldPower = startStopMongo.getPower() == null ? new BigDecimal("0.00") : startStopMongo.getPower();
-                            BigDecimal oldRunTime = startStopMongo.getIngTime() == null ? new BigDecimal("0.00") : startStopMongo.getIngTime();
                             BigDecimal oldSelectricCurrent = startStopMongo.getSelectricCurrent() == null ? new BigDecimal("0.00") : startStopMongo.getSelectricCurrent();
                             // 更新启动运行数据
                             Date deviceStopTime = DateUtils.addHours(fpgGatherData.getCreateTime(), 0);
-
-
                             Date startDate = dateFormat.parse(startStopMongo.getDeviceStartTime());
-
-                            // 将 Date 转换为 Instant
+                            // 将Date转换为Instant
                             Instant oldInstant = startDate.toInstant();
                             Instant newInstant = fpgGatherData.getCreateTime().toInstant();
-
                             // 计算时间差
                             Duration duration = Duration.between(oldInstant, newInstant);
-
                             // 获取时间差的秒数
                             long diffInSeconds = duration.getSeconds();
-
                             BigDecimal timeDifference = new BigDecimal(diffInSeconds);
-
                             UpdateDefinition updateStartStop = new Update()
                                     .set("power", oldPower.add(runPower))
                                     .set("selectricCurrent", oldSelectricCurrent.add(selectricCurrent))
                                     .set("ingTime", timeDifference)
                                     .set("deviceStopTime", DateUtils.date2Str(deviceStopTime, DateUtils.datetimeFormat.get()))
                                     .set("updateTime", curentDate);
-
                             Query modifyStartStop = new Query()
                                     .addCriteria(Criteria.where("deviceRegionId").is(fpgGatherData.getDeviceRegionId()))
                                     .addCriteria(Criteria.where("deviceInformationId").is(fpgGatherData.getDeviceInformationId()))
                                     .addCriteria(Criteria.where("_id").is(startStopMongo.get_id()));
                             mongoTemplate.findAndModify(modifyStartStop, updateStartStop, DeviceStatiscsModelMongodb.class, startStopMonKey);
                             mongoTemplate.updateFirst(modifyStartStop, updateStartStop, FpgStatiscsModelMongodb.class, startStopMonKey);
+                        } else if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) > 0  && "2".equals(startStopMongo.getDeviceStopTimeBank())){
+                            // 上一个设备停止,重新记录启停记录
+                            startStopStatiscsData.setPower(runPower);
+                            startStopStatiscsData.setIngTime(runTime);
+                            startStopStatiscsData.setSelectricCurrent(selectricCurrent);
+                            mongoTemplate.insert(startStopStatiscsData, startStopMonKey);
                         }
                     } else { // 直接插入
                         if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) > 0){ // 运行中计入启停记录
@@ -296,7 +271,7 @@ public class LeanModelStatistics {
                         fpgGatherData.setId(fpgGatherData.getId());
 //                        return;
                     }
-                     //日统计尖峰平谷数据(功率+占比+电流+运行时长) start
+                     // 日统计尖峰平谷数据(功率+占比+电流+运行时长) start
                     String dayPowerproportioncurrentRunMonKey = "total_day_powerproportioncurrent";
                     DeviceStatiscsModelData dayPowerproportioncurrentRunData = new DeviceStatiscsModelData(fpgGatherData, dayPowerproportioncurrentRunMonKey, dayDate, classs, curentDate, curentDate);
                     // 组合mongodb条件
@@ -314,6 +289,12 @@ public class LeanModelStatistics {
                         ((Update) update).set("selectricCurrent", oldSelectricCurrent.add(selectricCurrent));
                         ((Update) update).set("ingTime", oldRunTime.add(runTime));
                         ((Update) update).set("updateTime", curentDate);
+                        // 占比
+                        BigDecimal topsProportion = dayPowerproportioncurrentMongo.getTopsPower().compareTo(new BigDecimal("0.00")) > 0 ? dayPowerproportioncurrentMongo.getTopsPower().divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : proportion;
+                        // 其他三个重新核算
+                        BigDecimal flatProportion = dayPowerproportioncurrentMongo.getFlatPower().compareTo(new BigDecimal("0.00")) > 0 ? dayPowerproportioncurrentMongo.getFlatPower().divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : proportion;
+                        BigDecimal peaksProportion = dayPowerproportioncurrentMongo.getPeaksPower().compareTo(new BigDecimal("0.00")) > 0 ? dayPowerproportioncurrentMongo.getPeaksPower().divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : proportion;
+                        BigDecimal valleysProportion = dayPowerproportioncurrentMongo.getValleysPower().compareTo(new BigDecimal("0.00")) > 0 ? dayPowerproportioncurrentMongo.getValleysPower().divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : proportion;
                         // 尖峰平谷判定
                         if("tops".equals(jfpgStr.get())){ // 尖
                             // 功率处理
@@ -324,19 +305,7 @@ public class LeanModelStatistics {
                             BigDecimal oldtopsIngTime = dayPowerproportioncurrentMongo.getTopsIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getTopsIngTime();
                             ((Update) update).set("topsIngTime", oldtopsIngTime.add(runTime));
                             // 占比
-                            if(topsPower.compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("topsProportion", topsPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            // 其他三个重新核算
-                            if(dayPowerproportioncurrentMongo.getFlatPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("flatProportion", dayPowerproportioncurrentMongo.getFlatPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getPeaksPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("peaksProportion", dayPowerproportioncurrentMongo.getPeaksPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getTopsPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("topsProportion", dayPowerproportioncurrentMongo.getTopsPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
+                            topsProportion = topsPower.compareTo(new BigDecimal("0.00")) > 0 ? topsPower.divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : topsProportion;
                         } else if("peaks".equals(jfpgStr.get())){ // 峰
                             // 功率处理
                             BigDecimal oldpeaksPower = dayPowerproportioncurrentMongo.getPeaksPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksPower();
@@ -346,19 +315,7 @@ public class LeanModelStatistics {
                             BigDecimal oldpeaksIngTime = dayPowerproportioncurrentMongo.getPeaksIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksIngTime();
                             ((Update) update).set("peaksIngTime", oldpeaksIngTime.add(runTime));
                             // 占比
-                            if(peaksPower.compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("peaksProportion", peaksPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            // 其他三个重新核算
-                            if(dayPowerproportioncurrentMongo.getValleysPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("valleysProportion", dayPowerproportioncurrentMongo.getValleysPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getPeaksPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("peaksProportion", dayPowerproportioncurrentMongo.getPeaksPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getTopsPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("topsProportion", dayPowerproportioncurrentMongo.getTopsPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
+                            peaksProportion = peaksPower.compareTo(new BigDecimal("0.00")) > 0 ? peaksPower.divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : peaksProportion;
                         } else if("flat".equals(jfpgStr.get())){ // 平
                             // 功率处理
                             BigDecimal oldflatPower = dayPowerproportioncurrentMongo.getFlatPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatPower();
@@ -368,19 +325,7 @@ public class LeanModelStatistics {
                             BigDecimal oldflatIngTime = dayPowerproportioncurrentMongo.getFlatIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatIngTime();
                             ((Update) update).set("flatIngTime", oldflatIngTime.add(runTime));
                             // 占比
-                            if(flatPower.compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("flatProportion", flatPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            // 其他三个重新核算
-                            if(dayPowerproportioncurrentMongo.getValleysPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("valleysProportion", dayPowerproportioncurrentMongo.getValleysPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getPeaksPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("peaksProportion", dayPowerproportioncurrentMongo.getPeaksPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getTopsPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("topsProportion", dayPowerproportioncurrentMongo.getTopsPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
+                            flatProportion = flatPower.compareTo(new BigDecimal("0.00")) > 0 ? flatPower.divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : flatProportion;
                         } else if("valleys".equals(jfpgStr.get())){ // 谷
                             // 功率处理
                             BigDecimal oldvalleysPower = dayPowerproportioncurrentMongo.getValleysPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysPower();
@@ -389,21 +334,14 @@ public class LeanModelStatistics {
                             // 运行时常处理
                             BigDecimal oldvalleysIngTime = dayPowerproportioncurrentMongo.getValleysIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysIngTime();
                             ((Update) update).set("valleysIngTime", oldvalleysIngTime.add(runTime));
-                            // 占比核算
-                            if(valleysPower.compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("valleysProportion", valleysPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            // 其他三个重新核算
-                            if(dayPowerproportioncurrentMongo.getFlatPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("flatProportion", dayPowerproportioncurrentMongo.getFlatPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getPeaksPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("peaksProportion", dayPowerproportioncurrentMongo.getPeaksPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
-                            if(dayPowerproportioncurrentMongo.getTopsPower().compareTo(new BigDecimal("0.00")) > 0) {
-                                ((Update) update).set("topsProportion", dayPowerproportioncurrentMongo.getTopsPower().divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
-                            }
+                            // 占比
+                            valleysProportion = valleysPower.compareTo(new BigDecimal("0.00")) > 0 ? valleysPower.divide(runNewPower, 4, RoundingMode.HALF_UP).multiply(zb) : valleysProportion;
                         }
+                        // 占比
+                        ((Update) update).set("topsProportion", topsProportion);
+                        ((Update) update).set("peaksProportion", peaksProportion);
+                        ((Update) update).set("flatProportion", flatProportion);
+                        ((Update) update).set("valleysProportion", valleysProportion);
                         mongoTemplate.updateFirst(queryDayPowerproportioncurrentRun, update, DeviceStatiscsModelMongodb.class, dayPowerproportioncurrentRunMonKey);
                     } else { // 为空直接插入
                         // 尖峰平谷判定
@@ -411,25 +349,20 @@ public class LeanModelStatistics {
                             // 功率处理
                             dayPowerproportioncurrentRunData.setTopsPower(runPower);
                             dayPowerproportioncurrentRunData.setTopsIngTime(runTime);
-//                            dayPowerproportioncurrentRunData.setTopsSelectricCurrent(selectricCurrent);
                         } else if("peaks".equals(jfpgStr.get())){ // 峰
                             // 功率处理
                             dayPowerproportioncurrentRunData.setPeaksPower(runPower);
                             dayPowerproportioncurrentRunData.setPeaksIngTime(runTime);
-//                            dayPowerproportioncurrentRunData.setPeaksSelectricCurrent(selectricCurrent);
                         } else if("flat".equals(jfpgStr.get())){ // 平
                             // 功率处理
                             dayPowerproportioncurrentRunData.setFlatPower(runPower);
                             dayPowerproportioncurrentRunData.setFlatIngTime(runTime);
-//                            dayPowerproportioncurrentRunData.setFlatSelectricCurrent(selectricCurrent);
                         } else if("valleys".equals(jfpgStr.get())){ // 谷
                             dayPowerproportioncurrentRunData.setValleysPower(runPower);
                             dayPowerproportioncurrentRunData.setValleysIngTime(runTime);
-//                            dayPowerproportioncurrentRunData.setValleysSelectricCurrent(selectricCurrent);
                         }
                         dayPowerproportioncurrentRunData.setPower(runPower);
                         dayPowerproportioncurrentRunData.setIngTime(runTime);
-//                        dayPowerproportioncurrentRunData.setSelectricCurrent(selectricCurrent);
                         mongoTemplate.insert(dayPowerproportioncurrentRunData, dayPowerproportioncurrentRunMonKey);
                     }
                     // 日统计尖峰平谷数据(功率+占比+电流+运行时长) end
@@ -486,7 +419,7 @@ public class LeanModelStatistics {
 
         // 遍历设备集合
         fpgLeanModellist.forEach(fpgLeanModeInfo -> {
-            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgModelUpdatetime).isNotNull(FpgGatherData::getRunCurrent).isNotNull(FpgGatherData::getActivePower);
+            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgModelUpdatetime).isNotNull(FpgGatherData::getRunCurrent).isNotNull(FpgGatherData::getActivePower).orderByAsc(FpgGatherData::getCreateTime).last("limit 1000");
             // 检测是否配置设备特殊条件
             if(oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds()) && oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds())){
                 fpgGatherQuery.in(FpgGatherData::getDeviceInformationId, Arrays.asList(fpgLeanModeInfo.getDeviceInformationIds().split(",")));

+ 3 - 3
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/DeviceStatiscsModelData.java

@@ -24,8 +24,8 @@ public class DeviceStatiscsModelData {
     /**设备关停时间*/
     @ApiModelProperty(value = "设备关停时间")
     private String deviceStopTime;
-    /**设备关停时间-备用*/
-    @ApiModelProperty(value = "设备关停时间-备用")
+    /**标记设备启停状态*/
+    @ApiModelProperty(value = "标记设备启停状态1: 运行 2: 停止")
     private String deviceStopTimeBank;
     /**区域ID*/
     @ApiModelProperty(value = "区域ID")
@@ -129,7 +129,7 @@ public class DeviceStatiscsModelData {
         } else if("total_startstop".equals(totalType)){
             this.deviceStartTime = DateUtils.date2Str(fpgGather.getCreateTime(), DateUtils.datetimeFormat.get());
             this.deviceStopTime = DateUtils.date2Str(fpgGather.getCreateTime(), DateUtils.datetimeFormat.get());
-            this.deviceStopTimeBank = DateUtils.date2Str(fpgGather.getCreateTime(), DateUtils.datetimeFormat.get());
+            this.deviceStopTimeBank = "1";
         }
         this.dates = dates;
         this.createTime = createTime;

+ 1 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/PostgreSQLWatch.java

@@ -50,7 +50,7 @@ public class PostgreSQLWatch {
     @Autowired
     MongoTemplate mongoTemplate;
 
-    @Scheduled(fixedDelay = 40000)
+    @Scheduled(cron = "0 0/4 * * * *")
     public void getTsData() {
         Connection connection = null;
         PreparedStatement statement = null;