数据互导功能开发
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
public class DbTransferTask implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 查询数据源ID
|
||||
*/
|
||||
private Long queryDatasourceId;
|
||||
|
||||
/**
|
||||
* 入库数据源ID
|
||||
*/
|
||||
private Long storageDatasourceId;
|
||||
|
||||
/**
|
||||
* 查询数据的sql
|
||||
*/
|
||||
private String querySql;
|
||||
|
||||
/**
|
||||
* 数据入库的sql
|
||||
*/
|
||||
private String storageSql;
|
||||
|
||||
/**
|
||||
* 自动查询总条数 0=否 1=是
|
||||
*/
|
||||
private Integer needCount;
|
||||
|
||||
/**
|
||||
* 最后执行状态 0=未执行 1=执行中 2=执行成功 3=执行失败 4=取消执行
|
||||
*/
|
||||
private Integer lastExecuteStatus;
|
||||
|
||||
/**
|
||||
* 最后执行时间
|
||||
*/
|
||||
private Date lastExecuteTime;
|
||||
|
||||
/**
|
||||
* 最后执行信息
|
||||
*/
|
||||
private String lastExecuteInfo;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标记 0=正常 1=已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Long getQueryDatasourceId() {
|
||||
return queryDatasourceId;
|
||||
}
|
||||
|
||||
public void setQueryDatasourceId(Long queryDatasourceId) {
|
||||
this.queryDatasourceId = queryDatasourceId;
|
||||
}
|
||||
public Long getStorageDatasourceId() {
|
||||
return storageDatasourceId;
|
||||
}
|
||||
|
||||
public void setStorageDatasourceId(Long storageDatasourceId) {
|
||||
this.storageDatasourceId = storageDatasourceId;
|
||||
}
|
||||
public String getQuerySql() {
|
||||
return querySql;
|
||||
}
|
||||
|
||||
public void setQuerySql(String querySql) {
|
||||
this.querySql = querySql;
|
||||
}
|
||||
public String getStorageSql() {
|
||||
return storageSql;
|
||||
}
|
||||
|
||||
public void setStorageSql(String storageSql) {
|
||||
this.storageSql = storageSql;
|
||||
}
|
||||
public Integer getNeedCount() {
|
||||
return needCount;
|
||||
}
|
||||
|
||||
public void setNeedCount(Integer needCount) {
|
||||
this.needCount = needCount;
|
||||
}
|
||||
public Integer getLastExecuteStatus() {
|
||||
return lastExecuteStatus;
|
||||
}
|
||||
|
||||
public void setLastExecuteStatus(Integer lastExecuteStatus) {
|
||||
this.lastExecuteStatus = lastExecuteStatus;
|
||||
}
|
||||
public Date getLastExecuteTime() {
|
||||
return lastExecuteTime;
|
||||
}
|
||||
|
||||
public void setLastExecuteTime(Date lastExecuteTime) {
|
||||
this.lastExecuteTime = lastExecuteTime;
|
||||
}
|
||||
public String getLastExecuteInfo() {
|
||||
return lastExecuteInfo;
|
||||
}
|
||||
|
||||
public void setLastExecuteInfo(String lastExecuteInfo) {
|
||||
this.lastExecuteInfo = lastExecuteInfo;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DbTransferTask{" +
|
||||
"id=" + id +
|
||||
", name=" + name +
|
||||
", queryDatasourceId=" + queryDatasourceId +
|
||||
", storageDatasourceId=" + storageDatasourceId +
|
||||
", querySql=" + querySql +
|
||||
", storageSql=" + storageSql +
|
||||
", needCount=" + needCount +
|
||||
", lastExecuteStatus=" + lastExecuteStatus +
|
||||
", lastExecuteTime=" + lastExecuteTime +
|
||||
", lastExecuteInfo=" + lastExecuteInfo +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", delFlag=" + delFlag +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbTransferTask;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
public interface DbTransferTaskMapper extends BaseMapper<DbTransferTask> {
|
||||
|
||||
@Update("update db_transfer_task set last_execute_status=#{status}, last_execute_info = CONCAT(ifnull(last_execute_info,''), #{executeInfo}) where id=#{taskId} and last_execute_status in(0, 1)")
|
||||
void addExecuteInfo(@Param("taskId") Long taskId, @Param("status") Integer status, @Param("executeInfo") String executeInfo);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class CodeGenerator {
|
||||
// final String[] tableName = { "zyplayer_storage", "auth_info", "user_auth", "user_info", "db_datasource" };
|
||||
// final String[] tableName = { "wiki_space", "wiki_page", "wiki_page_content", "wiki_page_file", "wiki_page_comment", "wiki_page_zan" };
|
||||
// final String[] tableName = { "db_datasource", "es_datasource", "db_favorite" };
|
||||
final String[] tableName = { "db_history" };
|
||||
final String[] tableName = { "db_transfer_task" };
|
||||
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbTransferTask;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
public interface DbTransferTaskService extends IService<DbTransferTask> {
|
||||
|
||||
void addExecuteInfo(Long taskId, Integer status, String executeInfo);
|
||||
|
||||
void resetExecuteInfo(Long taskId);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.DbTransferTask;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.DbTransferTaskMapper;
|
||||
import com.zyplayer.doc.data.service.manage.DbTransferTaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Service
|
||||
public class DbTransferTaskServiceImpl extends ServiceImpl<DbTransferTaskMapper, DbTransferTask> implements DbTransferTaskService {
|
||||
|
||||
@Override
|
||||
public void addExecuteInfo(Long taskId, Integer status, String executeInfo) {
|
||||
executeInfo = "> " + executeInfo + "\n";
|
||||
baseMapper.addExecuteInfo(taskId, status, executeInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetExecuteInfo(Long taskId) {
|
||||
DbTransferTask taskUpdate = new DbTransferTask();
|
||||
taskUpdate.setId(taskId);
|
||||
taskUpdate.setLastExecuteInfo("");
|
||||
taskUpdate.setLastExecuteTime(new Date());
|
||||
taskUpdate.setLastExecuteStatus(0);
|
||||
this.updateById(taskUpdate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.utils;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ThreadPoolUtil {
|
||||
private static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(20, 100, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
||||
|
||||
/**
|
||||
* 获取线程池
|
||||
*/
|
||||
public static ThreadPoolExecutor getThreadPool() {
|
||||
return threadPoolExecutor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.DbTransferTaskMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user