|
@@ -160,6 +160,31 @@ public class LeanModelStatistics {
|
|
|
queryWrapper.eq("variable_address", "sys_run_current_limit");
|
|
|
queryWrapper.eq("status", 0);
|
|
|
SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<FpgGatherData> dataLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ dataLambdaQueryWrapper.eq(FpgGatherData::getDeviceInformationId,deviceInformationlinfo.getId());
|
|
|
+ dataLambdaQueryWrapper.orderByDesc(FpgGatherData::getCreateTime).last("LIMIT 1");
|
|
|
+ List<FpgGatherData> list = fpgGatherDataService.list(dataLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ FpgGatherData latestRecord = list.get(0);
|
|
|
+ // 使用 latestRecord
|
|
|
+ DeviceInformation deviceInformation = deviceInformationService.getOne(
|
|
|
+ new LambdaQueryWrapper<DeviceInformation>()
|
|
|
+ .eq(DeviceInformation::getId, latestRecord.getDeviceInformationId())
|
|
|
+ );
|
|
|
+ // 比较大小
|
|
|
+ int result = compareStringWithBigDecimal(systemVariable.getDefaultValue(), latestRecord.getRunCurrent());
|
|
|
+ if (result > 0) {
|
|
|
+ deviceInformation.setStatus("1");
|
|
|
+ } else if (result < 0) {
|
|
|
+ deviceInformation.setStatus("0");
|
|
|
+ }
|
|
|
+ // 只有在 systemVariable 不为空时才进行更新操作
|
|
|
+ deviceInformationService.updateById(deviceInformation);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 处理数据业务逻辑
|
|
|
fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
|
|
|
try {
|
|
@@ -832,5 +857,12 @@ public class LeanModelStatistics {
|
|
|
(createTime.isBefore(end_time) || createTime.equals(end_time));
|
|
|
}
|
|
|
|
|
|
+ public static int compareStringWithBigDecimal(String str, BigDecimal bd) {
|
|
|
+ // 将 String 转换为 BigDecimal
|
|
|
+ BigDecimal strAsBigDecimal = new BigDecimal(str);
|
|
|
+
|
|
|
+ // 使用 BigDecimal 的 compareTo 方法比较
|
|
|
+ return strAsBigDecimal.compareTo(bd);
|
|
|
+ }
|
|
|
|
|
|
}
|