修复几个问题

This commit is contained in:
inrgihc
2023-11-29 21:30:47 +08:00
parent 47c708d894
commit 437a0b2b33
19 changed files with 40 additions and 33 deletions

View File

@@ -1,5 +1,10 @@
# 异构数据库数据与结构同步工具
![](https://gitee.com/inrgihc/dbswitch/badge/star.svg)
![](https://gitee.com/inrgihc/dbswitch/badge/fork.svg?theme=gvp)
![dbswitch](https://gitee.com/dromara/dbswitch/raw/master/dbswitch-admin-ui/src/assets/logo.png#pic_center)
## 一、工具介绍
### 1、功能描述

View File

@@ -28,7 +28,7 @@ mybatis:
lazy-loading-enabled: true
aggressive-lazy-loading: false
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
dbswitch:
configuration:

View File

@@ -30,6 +30,7 @@ import java.sql.Timestamp;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.task.AsyncTaskExecutor;
@@ -55,7 +56,7 @@ public class ExecuteJobTaskRunnable implements Runnable {
private AsyncTaskExecutor migrationTaskExecutor;
private Long taskId;
@Getter private Long taskId;
private Integer schedule;

View File

@@ -85,8 +85,12 @@ public class AssignmentService {
.convert(assignmentTaskDAO.getById(assignment.getId()));
}
@Transactional(rollbackFor = Exception.class)
public void deleteAssignment(Long id) {
AssignmentTaskEntity taskEntity = assignmentTaskDAO.getById(id);
if (null != taskEntity && null != taskEntity.getPublished() && taskEntity.getPublished()) {
throw new DbswitchException(ResultCode.ERROR_RESOURCE_HAS_DEPLOY,
"已经发布的任务需先下线后方可执行删除操作");
}
assignmentTaskDAO.deleteById(id);
}
@@ -194,7 +198,9 @@ public class AssignmentService {
AssignmentTaskEntity assignmentTaskEntity = assignmentTaskDAO.getById(id);
if (Objects.nonNull(assignmentTaskEntity.getPublished())
&& assignmentTaskEntity.getPublished()) {
scheduleService.cancelByJobKey(assignmentTaskEntity.getJobKey());
String jobKey = assignmentTaskEntity.getJobKey();
scheduleService.cancelByJobKey(jobKey);
scheduleService.cancelManualJob(id);
assignmentTaskEntity.setPublished(Boolean.FALSE);
assignmentTaskEntity.setContent("{}");
assignmentTaskEntity.setJobKey("");

View File

@@ -18,6 +18,7 @@ import com.gitee.dbswitch.admin.type.JobStatusEnum;
import com.gitee.dbswitch.admin.type.ScheduleModeEnum;
import com.gitee.dbswitch.common.event.TaskEventHub;
import com.gitee.dbswitch.common.util.UuidUtils;
import com.google.common.collect.Sets;
import java.sql.Timestamp;
import java.util.Map;
import java.util.Objects;
@@ -111,14 +112,23 @@ public class ScheduleService {
AssignmentTaskEntity task = assignmentTaskDAO.getById(taskId);
if (ScheduleModeEnum.MANUAL == scheduleMode) {
manualRunEvenHub.notify(evenName, taskId, jobKeyName);
//scheduleOnce(jobBuilder.storeDurably(false).build(), triggerKey);
} else {
scheduleCron(jobBuilder.storeDurably(true).build(), triggerKey, task.getCronExpression());
}
task.setJobKey(jobKeyName);
assignmentTaskDAO.updateById(task);
}
}
public void cancelManualJob(Long taskId) {
Sets.newHashSet(taskRunnableMap.values()).forEach(
runnable -> {
if (taskId == runnable.getTaskId()) {
runnable.interrupt();
}
}
);
}
public void cancelByJobKey(String jobKeyName) {
if (StringUtils.isBlank(jobKeyName)) {
@@ -165,24 +175,6 @@ public class ScheduleService {
}
}
// private void scheduleOnce(JobDetail jobDetail, TriggerKey triggerKey) {
// Scheduler scheduler = schedulerFactoryBean.getScheduler();
// Trigger simpleTrigger = TriggerBuilder.newTrigger()
// .startAt(new Date())
// .withIdentity(triggerKey)
// .withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(0))
// .build();
//
// try {
// scheduler.scheduleJob(jobDetail, simpleTrigger);
// } catch (SchedulerException e) {
// log.error("Quartz schedule task by manual failed, taskId: {}.",
// jobDetail.getJobDataMap().get(JobExecutorService.TASK_ID), e);
// throw new RuntimeException(e);
// }
//
// }
private void scheduleCron(JobDetail jobDetail, TriggerKey triggerKey, String cronExpression) {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
Trigger cronTrigger = TriggerBuilder.newTrigger()

View File

@@ -28,7 +28,7 @@ mybatis:
lazy-loading-enabled: true
aggressive-lazy-loading: false
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
dbswitch:
configuration:

View File

@@ -28,7 +28,7 @@ mybatis:
lazy-loading-enabled: true
aggressive-lazy-loading: false
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
dbswitch:
configuration:

View File

@@ -28,7 +28,7 @@ mybatis:
lazy-loading-enabled: true
aggressive-lazy-loading: false
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
dbswitch:
configuration:

View File

@@ -1,5 +1,6 @@
package com.gitee.dbswitch.common.util;
import cn.hutool.core.codec.Base64;
import cn.hutool.json.JSONUtil;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
@@ -829,6 +830,8 @@ public final class ObjectCastUtils {
return in.toString();
} else if (in instanceof java.sql.Clob) {
return clob2Str((java.sql.Clob) in);
} else if (in instanceof java.sql.Blob) {
return Base64.encode(blob2Bytes((java.sql.Blob) in));
} else if (in instanceof java.lang.Number) {
return in.toString();
} else if (in instanceof java.sql.RowId) {

View File

@@ -100,7 +100,7 @@ public final class GenerateSqlUtils {
sb.append(")");
if (type.isLikeMysql()) {
sb.append("ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin");
sb.append("ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin");
if (withRemarks && StringUtils.isNotBlank(tableRemarks)) {
sb.append(String.format(" COMMENT='%s' ", tableRemarks.replace("'", "\\'")));
}

View File

@@ -25,7 +25,7 @@ import org.springframework.context.annotation.PropertySource;
*/
@Configuration
@Data
@ConfigurationProperties(prefix = "dbswitch", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "dbswitch")
@PropertySource(
value = {"classpath:config.properties", "classpath:config.yml", "classpath:config.yaml"},
ignoreResourceNotFound = true,

View File

@@ -29,7 +29,7 @@ public class TargetDataSourceProperties {
private CaseConvertEnum columnNameCase = CaseConvertEnum.NONE;
private Boolean targetDrop = Boolean.TRUE;
private Boolean onlyCreate = Boolean.FALSE;
private Boolean createTableAutoIncrement = Boolean.TRUE;
private Boolean createTableAutoIncrement = Boolean.FALSE;
private Boolean writerEngineInsert = Boolean.FALSE;
private Boolean changeDataSync = Boolean.FALSE;
}

View File

@@ -124,7 +124,7 @@ public class SqliteMetadataQueryProvider extends AbstractMetadataProvider {
if (null != pks && !pks.isEmpty() && pks.contains(fieldname)) {
// 关键字 AUTOINCREMENT 只能⽤于整型INTEGER字段。
if (useAutoInc) {
retval += "INTEGER PRIMARY KEY AUTOINCREMENT";
retval += "INTEGER AUTOINCREMENT";
} else {
retval += "BIGINT ";
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB