|
@@ -75,16 +75,21 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
private WebSocket webSocket;
|
|
private WebSocket webSocket;
|
|
|
|
|
|
// 不知道正式库是否是这个值
|
|
// 不知道正式库是否是这个值
|
|
- private Long guanralarmid = 1228L; // 报警信息
|
|
|
|
- private Long guananachglogid = 1030L; // 设备状态
|
|
|
|
- private Long bwanalogtableid = 286L; // 实时数据信息
|
|
|
|
|
|
+// private Long guanralarmid = 1228L; // 报警信息
|
|
|
|
+// private Long guananachglogid = 1030L; // 设备状态
|
|
|
|
+// private Long bwanalogtableid = 286L; // 实时数据信息
|
|
|
|
|
|
|
|
+// 打包时修改该配置
|
|
|
|
+ private Long guanralarmid = 99L; // 报警信息
|
|
|
|
+ private Long guananachglogid = 90L; // 设备状态
|
|
|
|
+ private Long bwanalogtableid = 86L; // 实时数据信息
|
|
|
|
|
|
@Async
|
|
@Async
|
|
@Override
|
|
@Override
|
|
@Order
|
|
@Order
|
|
public void run(ApplicationArguments args) throws Exception {
|
|
public void run(ApplicationArguments args) throws Exception {
|
|
- initRedisCache();
|
|
|
|
|
|
+ //所有信息都从前端获取,不需要从后端获取啦
|
|
|
|
+// initRedisCache();
|
|
|
|
|
|
//项目启动完成连接bin-log
|
|
//项目启动完成连接bin-log
|
|
new Thread(() -> {
|
|
new Thread(() -> {
|
|
@@ -124,7 +129,7 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
//只要连接的MySQL发生的增删改的操作,则都会进入这里,无论哪个数据库
|
|
//只要连接的MySQL发生的增删改的操作,则都会进入这里,无论哪个数据库
|
|
TableMapEventData tableMapEventData = (TableMapEventData) data;
|
|
TableMapEventData tableMapEventData = (TableMapEventData) data;
|
|
if (schema.equals(tableMapEventData.getDatabase())) {
|
|
if (schema.equals(tableMapEventData.getDatabase())) {
|
|
-// log.error("不是错误,只是想查询binlog对应的表ID:" + tableMapEventData.getTableId() + ",表名:" + tableMapEventData.getTable());
|
|
|
|
|
|
+// log.info("binlog对应的表ID:" + tableMapEventData.getTableId() + ",表名:" + tableMapEventData.getTable());
|
|
if ("guan_ralarm".equals(tableMapEventData.getTable())) {
|
|
if ("guan_ralarm".equals(tableMapEventData.getTable())) {
|
|
guanralarmid = tableMapEventData.getTableId();
|
|
guanralarmid = tableMapEventData.getTableId();
|
|
} else if ("bwanalogtable".equals(tableMapEventData.getTable())) {
|
|
} else if ("bwanalogtable".equals(tableMapEventData.getTable())) {
|
|
@@ -143,7 +148,7 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
|
|
|
|
if (guanralarmid == currTableId) {
|
|
if (guanralarmid == currTableId) {
|
|
// 打包时修改该配置 屏蔽下面的语句
|
|
// 打包时修改该配置 屏蔽下面的语句
|
|
- log.info("guan_ralarm Insert");
|
|
|
|
|
|
+// log.info("guan_ralarm Insert");
|
|
|
|
|
|
WriteRowsEventData writeRowsEventData = (WriteRowsEventData) data;
|
|
WriteRowsEventData writeRowsEventData = (WriteRowsEventData) data;
|
|
List<GuanRAlarm> alarmList = alarmService.selectAlarm24h(false);
|
|
List<GuanRAlarm> alarmList = alarmService.selectAlarm24h(false);
|
|
@@ -189,28 +194,31 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
|
|
|
|
if (guananachglogid == currTableId) {
|
|
if (guananachglogid == currTableId) {
|
|
// 打包时修改该配置 屏蔽下面的语句
|
|
// 打包时修改该配置 屏蔽下面的语句
|
|
- log.info("guan_anachglog Insert");
|
|
|
|
|
|
+// log.info("guan_anachglog Insert");
|
|
|
|
|
|
Object[] obj = Arrays.stream(((WriteRowsEventData) data).getRows().get(0)).toArray();
|
|
Object[] obj = Arrays.stream(((WriteRowsEventData) data).getRows().get(0)).toArray();
|
|
- GuanAnachglog anachglog = new GuanAnachglog();
|
|
|
|
- anachglog.setId((Integer) obj[0]);
|
|
|
|
- anachglog.setProjnodeid((Integer) obj[1]);
|
|
|
|
- anachglog.setTagname(obj[2].toString());
|
|
|
|
- anachglog.setLogdate(obj[3].toString());
|
|
|
|
- anachglog.setLogtime(obj[4].toString());
|
|
|
|
- anachglog.setLogmillisecond((Integer) obj[5]);
|
|
|
|
- anachglog.setLogvalue((Double) obj[6]);
|
|
|
|
- anachglog.setAlarm((Integer) obj[7]);
|
|
|
|
-
|
|
|
|
- // 2.1 缓存设备状态
|
|
|
|
- if (redisUtil.hasKey(GuanCommonConstant.GUAN_EQUIPMENT_STATUS)) {
|
|
|
|
- redisUtil.del(GuanCommonConstant.GUAN_EQUIPMENT_STATUS);
|
|
|
|
- }
|
|
|
|
- redisUtil.set(GuanCommonConstant.GUAN_EQUIPMENT_STATUS, anachglog);
|
|
|
|
|
|
+ if ("设备状态".equals(obj[2].toString())) {
|
|
|
|
+ GuanAnachglog anachglog = new GuanAnachglog();
|
|
|
|
+ anachglog.setId((Integer) obj[0]);
|
|
|
|
+ anachglog.setProjnodeid((Integer) obj[1]);
|
|
|
|
+ anachglog.setTagname(obj[2].toString());
|
|
|
|
+ anachglog.setLogdate(obj[3].toString());
|
|
|
|
+ anachglog.setLogtime(obj[4].toString());
|
|
|
|
+ anachglog.setLogmillisecond((Integer) obj[5]);
|
|
|
|
+ anachglog.setLogvalue((Double) obj[6]);
|
|
|
|
+ anachglog.setAlarm((Integer) obj[7]);
|
|
|
|
+
|
|
|
|
+ // 2.1 缓存设备状态
|
|
|
|
+ if (redisUtil.hasKey(GuanCommonConstant.GUAN_EQUIPMENT_STATUS)) {
|
|
|
|
+ redisUtil.del(GuanCommonConstant.GUAN_EQUIPMENT_STATUS);
|
|
|
|
+ }
|
|
|
|
+ redisUtil.set(GuanCommonConstant.GUAN_EQUIPMENT_STATUS, anachglog);
|
|
|
|
|
|
- // 如果设备状态的LogValue=1,代表设备开始运行,则更新曲线信息
|
|
|
|
- if (anachglog.getLogvalue() == 1) {
|
|
|
|
- refreshCurve();
|
|
|
|
|
|
+ // 如果设备状态的LogValue=1,代表设备开始运行,则更新曲线信息
|
|
|
|
+ if (anachglog.getLogvalue() == 1) {
|
|
|
|
+ // 改成通过前端判断是否获取新的曲线
|
|
|
|
+// refreshCurve();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -245,6 +253,8 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
|
|
|
|
// 实时数据存入redis中
|
|
// 实时数据存入redis中
|
|
redisUtil.set(GuanCommonConstant.GUAN_TAGVALUE_PREFIX + bwanalogtable.getTagname(), bwanalogtable);
|
|
redisUtil.set(GuanCommonConstant.GUAN_TAGVALUE_PREFIX + bwanalogtable.getTagname(), bwanalogtable);
|
|
|
|
+// log.info(bwanalogtable.getTagname() + ":" + redisUtil.hasKey(GuanCommonConstant.GUAN_TAGVALUE_PREFIX + bwanalogtable.getTagname()));
|
|
|
|
+// log.info(redisUtil.get(GuanCommonConstant.GUAN_TAGVALUE_PREFIX + bwanalogtable.getTagname()).toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -261,7 +271,7 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
// 1、报警信息
|
|
// 1、报警信息
|
|
if (guanralarmid == currTableId) {
|
|
if (guanralarmid == currTableId) {
|
|
// 打包时修改该配置 屏蔽下面的语句
|
|
// 打包时修改该配置 屏蔽下面的语句
|
|
- log.info("guan_ralarm Update");
|
|
|
|
|
|
+// log.info("guan_ralarm Update");
|
|
// log.info("guan_ralarm Update:" + data.toString());
|
|
// log.info("guan_ralarm Update:" + data.toString());
|
|
|
|
|
|
DeleteRowsEventData deleteRowsEventData = (DeleteRowsEventData) data;
|
|
DeleteRowsEventData deleteRowsEventData = (DeleteRowsEventData) data;
|
|
@@ -306,7 +316,7 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
* 刷新所有曲线(设备启动)
|
|
* 刷新所有曲线(设备启动)
|
|
*/
|
|
*/
|
|
private void refreshCurve() {
|
|
private void refreshCurve() {
|
|
- log.info(String.format("设备启动,推送新曲线 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
|
|
|
|
|
|
+// log.info(String.format("设备启动,推送新曲线 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
|
|
// 1 更新预制曲线
|
|
// 1 更新预制曲线
|
|
List<String> duans = new ArrayList<>();
|
|
List<String> duans = new ArrayList<>();
|
|
List<CirculateDTO> yzqxList = webAccessService.getYzqx(duans);
|
|
List<CirculateDTO> yzqxList = webAccessService.getYzqx(duans);
|
|
@@ -351,7 +361,7 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
|
|
|
|
webSocket.pushMessage(jsonObject.toString());
|
|
webSocket.pushMessage(jsonObject.toString());
|
|
|
|
|
|
- log.info(String.format("设备启动,推送新曲线 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
|
|
|
|
|
|
+// log.info(String.format("设备启动,推送新曲线 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -388,7 +398,7 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
* 刷新预制曲线
|
|
* 刷新预制曲线
|
|
*/
|
|
*/
|
|
private void refreshPrepareCurve() {
|
|
private void refreshPrepareCurve() {
|
|
- log.info(String.format("刷新预制曲线 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
|
|
|
|
|
|
+// log.info(String.format("刷新预制曲线 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
|
|
// 1 更新预制曲线
|
|
// 1 更新预制曲线
|
|
List<String> duans = new ArrayList<>();
|
|
List<String> duans = new ArrayList<>();
|
|
List<CirculateDTO> yzqxList = webAccessService.getYzqx(duans);
|
|
List<CirculateDTO> yzqxList = webAccessService.getYzqx(duans);
|
|
@@ -413,7 +423,7 @@ public class MysqlBinLogClient implements ApplicationRunner {
|
|
|
|
|
|
webSocket.pushMessage(jsonObject.toString());
|
|
webSocket.pushMessage(jsonObject.toString());
|
|
|
|
|
|
- log.info(String.format("刷新预制曲线 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
|
|
|
|
|
|
+// log.info(String.format("刷新预制曲线 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|