|
@@ -71,7 +71,8 @@ public class LeanModelStatistics {
|
|
|
* 精益模型统计数据
|
|
|
* 执行完后,间隔1秒继续执行
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0/1 * * * *")
|
|
|
+// @Scheduled(cron = "0 */1 * * * ?")
|
|
|
+ @Scheduled(cron = "*/30 * * * * ?")
|
|
|
public void t1(){
|
|
|
leanModel();
|
|
|
}
|
|
@@ -80,7 +81,7 @@ public class LeanModelStatistics {
|
|
|
* 变更占比
|
|
|
* 0 0 03 * * * 每日3点执行 测试期间1ms一次
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0 03 * * *")
|
|
|
+ @Scheduled(cron = "0 0 03 * * ?")
|
|
|
// @Scheduled(fixedDelay = 1000)
|
|
|
public void t2(){
|
|
|
changeProportion();
|
|
@@ -89,7 +90,8 @@ public class LeanModelStatistics {
|
|
|
/**
|
|
|
* 设备启停统计数据
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0/1 * * * *")
|
|
|
+// @Scheduled(cron = "0 */1 * * * ?")
|
|
|
+ @Scheduled(cron = "*/30 * * * * ?")
|
|
|
public void t3(){
|
|
|
deviceStatistics();
|
|
|
}
|
|
@@ -161,6 +163,14 @@ public class LeanModelStatistics {
|
|
|
// 处理数据业务逻辑
|
|
|
fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
|
|
|
try {
|
|
|
+ fpgGatherData.setFpgTotalUpdatetime(new Date());
|
|
|
+ // -数情况直接退出
|
|
|
+ if (fpgGatherData.getActivePower().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ // 执行完成数据 标记已处理
|
|
|
+ fpgGatherData.setId(fpgGatherData.getId());
|
|
|
+ fpgGatherDataService.updateById(fpgGatherData);
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 采集时间
|
|
|
Instant instant = fpgGatherData.getCreateTime().toInstant();
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
|
@@ -267,9 +277,10 @@ public class LeanModelStatistics {
|
|
|
// 设备启停统计 end
|
|
|
// 设备停止运行不统计
|
|
|
if (fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0) { // 设备停止运行
|
|
|
- fpgGatherData.setFpgTotalUpdatetime(new Date());
|
|
|
+ // 执行完成数据 标记已处理
|
|
|
fpgGatherData.setId(fpgGatherData.getId());
|
|
|
-// return;
|
|
|
+ fpgGatherDataService.updateById(fpgGatherData);
|
|
|
+ return;
|
|
|
}
|
|
|
// 日统计尖峰平谷数据(功率+占比+电流+运行时长) start
|
|
|
String dayPowerproportioncurrentRunMonKey = "total_day_powerproportioncurrent";
|
|
@@ -367,7 +378,6 @@ public class LeanModelStatistics {
|
|
|
}
|
|
|
// 日统计尖峰平谷数据(功率+占比+电流+运行时长) end
|
|
|
// 执行完成数据 标记已处理
|
|
|
- fpgGatherData.setFpgTotalUpdatetime(new Date());
|
|
|
fpgGatherData.setId(fpgGatherData.getId());
|
|
|
fpgGatherDataService.updateById(fpgGatherData);
|
|
|
} catch (Exception e) {
|
|
@@ -400,18 +410,22 @@ public class LeanModelStatistics {
|
|
|
|
|
|
// 遍历设备集合
|
|
|
fpgLeanModellist.forEach(fpgLeanModeInfo -> {
|
|
|
- LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgModelUpdatetime).isNotNull(FpgGatherData::getRunCurrent).isNotNull(FpgGatherData::getActivePower).orderByAsc(FpgGatherData::getCreateTime).last("limit 1000");
|
|
|
+ LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgModelUpdatetime).isNotNull(FpgGatherData::getRunCurrent).isNotNull(FpgGatherData::getActivePower).orderByAsc(FpgGatherData::getCreateTime);
|
|
|
// 检测是否配置设备特殊条件
|
|
|
if(oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds()) && oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds())){
|
|
|
fpgGatherQuery.in(FpgGatherData::getDeviceInformationId, Arrays.asList(fpgLeanModeInfo.getDeviceInformationIds().split(",")));
|
|
|
}
|
|
|
- fpgGatherQuery.orderByAsc(FpgGatherData::getCreateTime);
|
|
|
+ fpgGatherQuery.orderByAsc(FpgGatherData::getCreateTime).last("limit 1000");
|
|
|
List<FpgGatherData> fpgGatherList = fpgGatherDataService.list(fpgGatherQuery);
|
|
|
// 处理数据业务逻辑
|
|
|
fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
|
|
|
fpgGatherData.setFpgModelUpdatetime(new Date());
|
|
|
+ // -数情况直接退出
|
|
|
+ if (fpgGatherData.getActivePower().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ fpgGatherUpdateList.add(fpgGatherData);
|
|
|
+ return;
|
|
|
+ }
|
|
|
try {
|
|
|
- BigDecimal runTime = new BigDecimal("300");
|
|
|
// 设备停止运行不统计
|
|
|
if (fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0) { // 设备停止运行
|
|
|
fpgGatherUpdateList.add(fpgGatherData);
|
|
@@ -498,9 +512,11 @@ public class LeanModelStatistics {
|
|
|
|
|
|
FpgStatiscsModelMongodb fpgStatiscsModelMongo = mongoTemplate.findOne(query, FpgStatiscsModelMongodb.class, collectionName);
|
|
|
// 功率
|
|
|
- BigDecimal activePower = fpgGatherData.getActivePower().divide(new BigDecimal("12"), 8, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal activePower = fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal("12"), 8, RoundingMode.HALF_UP) : fpgGatherData.getActivePower();
|
|
|
// 电流
|
|
|
BigDecimal selectricCurrent = fpgGatherData.getRunCurrent() == null ? new BigDecimal("0.00") : fpgGatherData.getRunCurrent();
|
|
|
+ // 运行时常
|
|
|
+ BigDecimal runTime = new BigDecimal("300");
|
|
|
if(fpgStatiscsModelMongo != null){ // 不为空处理
|
|
|
// 基础数据变更不受条件影响
|
|
|
UpdateDefinition update = new Update();
|
|
@@ -697,7 +713,7 @@ public class LeanModelStatistics {
|
|
|
}
|
|
|
}
|
|
|
fpgGatherUpdateList.add(fpgGatherData);
|
|
|
-
|
|
|
+ query.addCriteria(Criteria.where("_id").is(fpgStatiscsModelMongo.get_id()));
|
|
|
mongoTemplate.updateFirst(query, update, FpgStatiscsModelMongodb.class, collectionName);
|
|
|
|
|
|
} else { // 为空直接插入
|