Commit aa3cec0dfce9a980bfc518172700b5a82ef02ca8
1 parent
166272ad
去除数据库自动更新,自动更新会导致wvp在arm架构服务上无法启动
Showing
4 changed files
with
6 additions
and
83 deletions
pom.xml
| @@ -242,13 +242,8 @@ | @@ -242,13 +242,8 @@ | ||
| 242 | <artifactId>spring-boot-starter-test</artifactId> | 242 | <artifactId>spring-boot-starter-test</artifactId> |
| 243 | <!-- <scope>test</scope>--> | 243 | <!-- <scope>test</scope>--> |
| 244 | </dependency> | 244 | </dependency> |
| 245 | - <dependency> | ||
| 246 | - <groupId>org.flywaydb</groupId> | ||
| 247 | - <artifactId>flyway-core</artifactId> | ||
| 248 | - <version>7.15.0</version> | ||
| 249 | - </dependency> | ||
| 250 | - </dependencies> | ||
| 251 | 245 | ||
| 246 | + </dependencies> | ||
| 252 | 247 | ||
| 253 | 248 | ||
| 254 | <build> | 249 | <build> |
src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.conf; | ||
| 2 | - | ||
| 3 | -import org.flywaydb.core.Flyway; | ||
| 4 | -import org.flywaydb.core.api.FlywayException; | ||
| 5 | -import org.slf4j.Logger; | ||
| 6 | -import org.slf4j.LoggerFactory; | ||
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | -import org.springframework.context.annotation.Configuration; | ||
| 9 | - | ||
| 10 | -import javax.annotation.PostConstruct; | ||
| 11 | -import javax.sql.DataSource; | ||
| 12 | - | ||
| 13 | -/** | ||
| 14 | - * 数据库自动升级脚本 | ||
| 15 | - */ | ||
| 16 | -@Configuration | ||
| 17 | -public class FlywayConfig { | ||
| 18 | - | ||
| 19 | - private final static Logger logger = LoggerFactory.getLogger(FlywayConfig.class); | ||
| 20 | - | ||
| 21 | - @Autowired | ||
| 22 | - private DataSource dataSource; | ||
| 23 | - | ||
| 24 | - @Autowired | ||
| 25 | - private UserSetting userSetting; | ||
| 26 | - | ||
| 27 | - @PostConstruct | ||
| 28 | - public void migrate() { | ||
| 29 | - if (!userSetting.getSyncDb()) { | ||
| 30 | - logger.info("[数据库自动升级] 已关闭"); | ||
| 31 | - return; | ||
| 32 | - } | ||
| 33 | - Flyway flyway = Flyway.configure() | ||
| 34 | - .dataSource(dataSource) | ||
| 35 | - .locations("db/migration")//sql文件名称规则:"V20210625.17.30__V1.0.sql" | ||
| 36 | - // 自动创建flyway元数据表标识 | ||
| 37 | - .baselineOnMigrate(true) | ||
| 38 | - .baselineVersion("0") | ||
| 39 | - // 禁止flyway执行清理 | ||
| 40 | - .cleanDisabled(true) | ||
| 41 | - .table("flyway_schema_history_wvp") | ||
| 42 | - // 对于开发环境, 可能是多人协作开发, 很可能先 apply 了自己本地的最新 SQL 代码, 然后发现其他同事早先时候提交的 SQL 代码还没有 apply, | ||
| 43 | - // 所以 开发环境应该设置 spring.flyway.outOfOrder=true, 这样 flyway 将能加载漏掉的老版本 SQL 文件; | ||
| 44 | - // 而生产环境应该设置 spring.flyway.outOfOrder=false | ||
| 45 | - .outOfOrder(true) | ||
| 46 | - .encoding("UTF-8") | ||
| 47 | - .load(); | ||
| 48 | - try { | ||
| 49 | - flyway.migrate(); | ||
| 50 | - } catch (FlywayException e) { | ||
| 51 | - logger.error("[数据库自动升级]配置第一次加载出错", e); | ||
| 52 | - try { | ||
| 53 | - flyway.repair();//生成版本记录表 | ||
| 54 | - logger.info("[数据库自动升级]配置修复成功"); | ||
| 55 | - flyway.migrate(); | ||
| 56 | - logger.info("[数据库自动升级]配置重新加载成功"); | ||
| 57 | - } catch (Exception e1) { | ||
| 58 | - logger.error("[数据库自动升级]配置第二次加载出错", e1); | ||
| 59 | - throw e1; | ||
| 60 | - } | ||
| 61 | - } | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | -} |
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
| @@ -46,7 +46,6 @@ public class UserSetting { | @@ -46,7 +46,6 @@ public class UserSetting { | ||
| 46 | private Boolean syncChannelOnDeviceOnline = Boolean.FALSE; | 46 | private Boolean syncChannelOnDeviceOnline = Boolean.FALSE; |
| 47 | 47 | ||
| 48 | private Boolean sipLog = Boolean.FALSE; | 48 | private Boolean sipLog = Boolean.FALSE; |
| 49 | - private Boolean syncDb = Boolean.TRUE; | ||
| 50 | 49 | ||
| 51 | private String serverId = "000000"; | 50 | private String serverId = "000000"; |
| 52 | 51 | ||
| @@ -217,12 +216,4 @@ public class UserSetting { | @@ -217,12 +216,4 @@ public class UserSetting { | ||
| 217 | public void setSipLog(Boolean sipLog) { | 216 | public void setSipLog(Boolean sipLog) { |
| 218 | this.sipLog = sipLog; | 217 | this.sipLog = sipLog; |
| 219 | } | 218 | } |
| 220 | - | ||
| 221 | - public Boolean getSyncDb() { | ||
| 222 | - return syncDb; | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - public void setSyncDb(Boolean syncDb) { | ||
| 226 | - this.syncDb = syncDb; | ||
| 227 | - } | ||
| 228 | } | 219 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java
| 1 | package com.genersoft.iot.vmp.storager.dao; | 1 | package com.genersoft.iot.vmp.storager.dao; |
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; | 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; |
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 5 | -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; | ||
| 6 | -import org.apache.ibatis.annotations.*; | 4 | +import org.apache.ibatis.annotations.Delete; |
| 5 | +import org.apache.ibatis.annotations.Insert; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | +import org.apache.ibatis.annotations.Select; | ||
| 7 | import org.springframework.stereotype.Repository; | 8 | import org.springframework.stereotype.Repository; |
| 8 | 9 | ||
| 9 | import java.util.List; | 10 | import java.util.List; |
| @@ -20,7 +21,7 @@ public interface DeviceAlarmMapper { | @@ -20,7 +21,7 @@ public interface DeviceAlarmMapper { | ||
| 20 | int add(DeviceAlarm alarm); | 21 | int add(DeviceAlarm alarm); |
| 21 | 22 | ||
| 22 | 23 | ||
| 23 | - @Select(value = {" <script>" + | 24 | + @Select( value = {" <script>" + |
| 24 | " SELECT * FROM device_alarm " + | 25 | " SELECT * FROM device_alarm " + |
| 25 | " WHERE 1=1 " + | 26 | " WHERE 1=1 " + |
| 26 | " <if test=\"deviceId != null\" > AND deviceId = #{deviceId}</if>" + | 27 | " <if test=\"deviceId != null\" > AND deviceId = #{deviceId}</if>" + |