|
@@ -1,15 +1,20 @@
|
|
|
package io.renren.modules.aspen.controller;
|
|
|
|
|
|
+import io.renren.modules.aspen.entity.TElecdashboardAlarmEntity;
|
|
|
import io.renren.modules.aspen.entity.TElecdashboardRealtimeEntity;
|
|
|
import io.renren.modules.aspen.entity.base.TElecdashboard;
|
|
|
+import io.renren.modules.aspen.service.TElecdashboardAlarmService;
|
|
|
import io.renren.modules.aspen.service.TElecdashboardRealtimeService;
|
|
|
import io.renren.modules.aspen.core.utils.DashboardDataPullUtils;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import io.renren.modules.aspen.core.constant.AlarmValue;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* 电厂大屏实时数据
|
|
@@ -26,23 +31,78 @@ public class TElecdashboardRealtimeController {
|
|
|
@Resource
|
|
|
private TElecdashboardRealtimeService tElecdashboardRealtimeService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TElecdashboardAlarmService tElecdashboardAlarmService;
|
|
|
+
|
|
|
/**
|
|
|
* 每5秒抓取实时数据,存入数据库
|
|
|
*/
|
|
|
@Scheduled(cron = "*/5 * * * * ?" )
|
|
|
public void getExcelDataEvery5Seconds(){
|
|
|
DashboardDataPullUtils dashboardDataPullUtils = new DashboardDataPullUtils();
|
|
|
+ // 抓取实时数据
|
|
|
TElecdashboard tElecdashboard = dashboardDataPullUtils.getExcelData(new TElecdashboardRealtimeEntity());
|
|
|
TElecdashboardRealtimeEntity tElecdashboardRealtimeEntity = (TElecdashboardRealtimeEntity) tElecdashboard;
|
|
|
+ // 存入数据库
|
|
|
tElecdashboardRealtimeService.insertTElecdashboardRealtime(tElecdashboardRealtimeEntity);
|
|
|
// 检查预警值
|
|
|
- this.checkAlarmValue();
|
|
|
+ this.checkAlarmValue(tElecdashboardRealtimeEntity);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 检查预警值
|
|
|
+ * 检查预警值,如果实时数据超出预警值范围,插入预警数据
|
|
|
+ *
|
|
|
+ * @param tElecdashboardRealtimeEntity 电厂大屏实时数据
|
|
|
*/
|
|
|
- private void checkAlarmValue() {
|
|
|
+ private void checkAlarmValue(TElecdashboardRealtimeEntity tElecdashboardRealtimeEntity) {
|
|
|
+ // 清空电厂大屏预警表
|
|
|
+ tElecdashboardAlarmService.deleteTElecdashboardAlarm();
|
|
|
+ // 预警值
|
|
|
+ ArrayList<String> alarmValueList = new ArrayList();
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61001());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61002());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61003());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61004());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61005());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61101());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61102());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61103());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61104());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt61105());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt76001());
|
|
|
+ alarmValueList.add(tElecdashboardRealtimeEntity.getQt76002());
|
|
|
+ // 位号
|
|
|
+ ArrayList<String> codeList = new ArrayList();
|
|
|
+ alarmValueList.add("QT61001");
|
|
|
+ alarmValueList.add("QT61002");
|
|
|
+ alarmValueList.add("QT61003");
|
|
|
+ alarmValueList.add("QT61004");
|
|
|
+ alarmValueList.add("QT61005");
|
|
|
+ alarmValueList.add("QT61101");
|
|
|
+ alarmValueList.add("QT61102");
|
|
|
+ alarmValueList.add("QT61103");
|
|
|
+ alarmValueList.add("QT61104");
|
|
|
+ alarmValueList.add("QT61105");
|
|
|
+ alarmValueList.add("QT76001");
|
|
|
+ alarmValueList.add("QT76002");
|
|
|
+ for (int i = 0; i < alarmValueList.size(); i++) {
|
|
|
+ // 空值或错误值,不处理
|
|
|
+ if ("".equals(alarmValueList.get(i)) || "#NAME?".equals(alarmValueList.get(i))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 小于最小值或大于最大值,插入预警数据
|
|
|
+ if (
|
|
|
+ AlarmValue.valueOf(codeList.get(i)).getMin() >= Double.parseDouble(alarmValueList.get(i))
|
|
|
+ || AlarmValue.valueOf(codeList.get(i)).getMax() <= Double.parseDouble(alarmValueList.get(i))
|
|
|
+ ) {
|
|
|
+ tElecdashboardAlarmService.insertTElecdashboardAlarm(new TElecdashboardAlarmEntity(
|
|
|
+ alarmValueList.get(i),
|
|
|
+ new Date(),
|
|
|
+ codeList.get(i),
|
|
|
+ AlarmValue.valueOf(codeList.get(i)).getDesc()
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -50,9 +110,7 @@ public class TElecdashboardRealtimeController {
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 8 * * ?")
|
|
|
public void clearTElecdashboardRealtimeEveryHour() {
|
|
|
- System.out.println("clearTElecdashboardRealtimeEveryHour is running...");
|
|
|
tElecdashboardRealtimeService.deleteTElecdashboardRealtime();
|
|
|
- System.out.println("clearTElecdashboardRealtimeEveryHour finished!");
|
|
|
}
|
|
|
|
|
|
}
|