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 = {"