diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/config/mybatis/ClearForeignKey.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/config/mybatis/ClearForeignKey.java
deleted file mode 100644
index 529b255d..00000000
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/config/mybatis/ClearForeignKey.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * sonic-server Sonic Cloud Real Machine Platform.
- * Copyright (C) 2022 SonicCloudOrg
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package org.cloud.sonic.controller.config.mybatis;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceSchemaCreatedEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.stereotype.Component;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 清除历史遗留的外键
- *
- * @author JayWenStar, Eason
- * @date 2021/12/26 1:39 上午
- */
-@Component
-@Slf4j
-public class ClearForeignKey implements ApplicationListener {
-
- @Override
- public void onApplicationEvent(DataSourceSchemaCreatedEvent event) {
- DataSource dataSource = (DataSource) event.getSource();
- String dataBase = "";
-// String findFKSql = "SELECT CONCAT('ALTER TABLE ', TABLE_NAME,' DROP FOREIGN KEY ',CONSTRAINT_NAME) as ddl " +
-// "FROM information_schema.TABLE_CONSTRAINTS c " +
-// "WHERE c.TABLE_SCHEMA='%s' AND c.CONSTRAINT_TYPE='FOREIGN KEY'";
- String transSql = "UPDATE jobs SET type = 'testJob' WHERE type is null or type = \"\"";
- List deleteSqlList = new ArrayList<>();
- try (Connection connection = dataSource.getConnection()) {
- try (Statement statement = connection.createStatement()) {
-
- // 获取当前数据库名
- ResultSet resultSet1 = statement.executeQuery("select DATABASE() db");
- if (resultSet1.next()) {
- dataBase = resultSet1.getString("db");
- }
-
-// // 查询所有外键索引,并拼装成删除sql
-// ResultSet resultSet2 = statement.executeQuery(String.format(findFKSql, dataBase));
-// while (resultSet2.next()) {
-// deleteSqlList.add(resultSet2.getString("ddl"));
-// }
-
- // 版本兼容sql
- Boolean resultSet3 = statement.execute(String.format(transSql, dataBase));
- if (!resultSet3) {
- log.info(String.format("transfer sql %s failed, ignore...", transSql));
- }
-
- // 执行删除外键sql
- for (String deleteSql : deleteSqlList) {
- statement.executeUpdate(deleteSql);
- }
-
-// // 删除 test_suites_devices 表的主键
-// try {
-// statement.executeUpdate("Alter table test_suites_devices Drop primary key");
-// } catch (Exception e) {
-// // 无视错误
-// }
- }
- } catch (Exception e) {
- log.error("clear foreign key failed.");
- e.printStackTrace();
- }
- }
-}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Jobs.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Jobs.java
index 8a67c326..6cb7106a 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Jobs.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Jobs.java
@@ -56,6 +56,6 @@ public class Jobs implements Serializable, TypeConverter {
private Integer suiteId;
@TableField
- @Column(isNull = false, comment = "定时任务类型")
+ @Column(isNull = false, defaultValue = "testJob", comment = "定时任务类型")
private String type;
}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/quartz/QuartzHandler.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/quartz/QuartzHandler.java
index c9f53321..4e7e7ee4 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/quartz/QuartzHandler.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/quartz/QuartzHandler.java
@@ -250,9 +250,7 @@ public void updateSysScheduleJob(String type, String cron) {
public void createSysTrigger() {
for (String type : typeList) {
-// 从数据库中获取数据,然后创建
Jobs job = jobsService.findByType(type);
-// 首次部署,初始化系统定时任务
if (job == null) {
job = initSysJob(type);
}
diff --git a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/service/impl/AgentsServiceImplTest.java b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/service/impl/AgentsServiceImplTest.java
index 537910d2..778889d4 100644
--- a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/service/impl/AgentsServiceImplTest.java
+++ b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/service/impl/AgentsServiceImplTest.java
@@ -100,11 +100,6 @@ public void testUpdate() {
agentsService.update(id, name, highTemp, highTempTime, robotType, robotToken, robotSecret);
- agents.setId(1);
- Mockito.when(agentsMapper.selectById(Mockito.any()))
- .thenReturn(agents);
- agentsService.update(1, name, highTemp, highTempTime, robotType, robotToken, robotSecret);
-
}