From aa3cec0dfce9a980bfc518172700b5a82ef02ca8 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Mon, 6 Feb 2023 10:46:23 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=95=B0=E6=8D=AE=E5=BA=93?=
=?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=EF=BC=8C=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=9A=E5=AF=BC=E8=87=B4wvp=E5=9C=A8arm?=
=?UTF-8?q?=E6=9E=B6=E6=9E=84=E6=9C=8D=E5=8A=A1=E4=B8=8A=E6=97=A0=E6=B3=95?=
=?UTF-8?q?=E5=90=AF=E5=8A=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 7 +-
.../genersoft/iot/vmp/conf/FlywayConfig.java | 64 -------------------
.../genersoft/iot/vmp/conf/UserSetting.java | 9 ---
.../vmp/storager/dao/DeviceAlarmMapper.java | 9 +--
4 files changed, 6 insertions(+), 83 deletions(-)
delete mode 100644 src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java
diff --git a/pom.xml b/pom.xml
index 510f528a..29433430 100644
--- a/pom.xml
+++ b/pom.xml
@@ -242,13 +242,8 @@
spring-boot-starter-test
-
- org.flywaydb
- flyway-core
- 7.15.0
-
-
+
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java
deleted file mode 100644
index 6133694d..00000000
--- a/src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.genersoft.iot.vmp.conf;
-
-import org.flywaydb.core.Flyway;
-import org.flywaydb.core.api.FlywayException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-
-import javax.annotation.PostConstruct;
-import javax.sql.DataSource;
-
-/**
- * 数据库自动升级脚本
- */
-@Configuration
-public class FlywayConfig {
-
- private final static Logger logger = LoggerFactory.getLogger(FlywayConfig.class);
-
- @Autowired
- private DataSource dataSource;
-
- @Autowired
- private UserSetting userSetting;
-
- @PostConstruct
- public void migrate() {
- if (!userSetting.getSyncDb()) {
- logger.info("[数据库自动升级] 已关闭");
- return;
- }
- Flyway flyway = Flyway.configure()
- .dataSource(dataSource)
- .locations("db/migration")//sql文件名称规则:"V20210625.17.30__V1.0.sql"
- // 自动创建flyway元数据表标识
- .baselineOnMigrate(true)
- .baselineVersion("0")
- // 禁止flyway执行清理
- .cleanDisabled(true)
- .table("flyway_schema_history_wvp")
- // 对于开发环境, 可能是多人协作开发, 很可能先 apply 了自己本地的最新 SQL 代码, 然后发现其他同事早先时候提交的 SQL 代码还没有 apply,
- // 所以 开发环境应该设置 spring.flyway.outOfOrder=true, 这样 flyway 将能加载漏掉的老版本 SQL 文件;
- // 而生产环境应该设置 spring.flyway.outOfOrder=false
- .outOfOrder(true)
- .encoding("UTF-8")
- .load();
- try {
- flyway.migrate();
- } catch (FlywayException e) {
- logger.error("[数据库自动升级]配置第一次加载出错", e);
- try {
- flyway.repair();//生成版本记录表
- logger.info("[数据库自动升级]配置修复成功");
- flyway.migrate();
- logger.info("[数据库自动升级]配置重新加载成功");
- } catch (Exception e1) {
- logger.error("[数据库自动升级]配置第二次加载出错", e1);
- throw e1;
- }
- }
- }
-
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
index be7d5af4..a0956cc8 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
@@ -46,7 +46,6 @@ public class UserSetting {
private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
private Boolean sipLog = Boolean.FALSE;
- private Boolean syncDb = Boolean.TRUE;
private String serverId = "000000";
@@ -217,12 +216,4 @@ public class UserSetting {
public void setSipLog(Boolean sipLog) {
this.sipLog = sipLog;
}
-
- public Boolean getSyncDb() {
- return syncDb;
- }
-
- public void setSyncDb(Boolean syncDb) {
- this.syncDb = syncDb;
- }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java
index f67e152f..f927d51e 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java
@@ -1,9 +1,10 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
-import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
-import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
-import org.apache.ibatis.annotations.*;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -20,7 +21,7 @@ public interface DeviceAlarmMapper {
int add(DeviceAlarm alarm);
- @Select(value = {"