|
|
@@ -1,36 +1,38 @@
|
|
|
package com.template.services.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
import com.template.common.utils.CommonUtil;
|
|
|
import com.template.common.utils.DBUtil;
|
|
|
import com.template.common.utils.QuartzJobUtils;
|
|
|
import com.template.mapper.SmartDataSourceMapper;
|
|
|
import com.template.mapper.SmartDataTaskMapper;
|
|
|
-import com.template.model.pojo.*;
|
|
|
-import com.template.model.result.CommonResult;
|
|
|
+import com.template.model.pojo.SmartDataSourceJobParams;
|
|
|
+import com.template.model.pojo.SmartDataTask;
|
|
|
+import com.template.model.pojo.SmartDepartment;
|
|
|
import com.template.model.result.PageUtils;
|
|
|
import com.template.services.SmartDataTaskService;
|
|
|
-import lombok.val;
|
|
|
import org.quartz.CronExpression;
|
|
|
-import org.quartz.JobKey;
|
|
|
import org.quartz.Scheduler;
|
|
|
-import org.quartz.SchedulerException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.sql.*;
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.DateTimeParseException;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
@@ -54,15 +56,17 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
@Autowired
|
|
|
private Scheduler scheduler;
|
|
|
|
|
|
+ // 添加任务1-任务基本信息
|
|
|
@Override
|
|
|
- public Map<String, Object> insertSmartDataTask(SmartDataTask smartDataTask) {
|
|
|
+ public Map<String, Object> insertSmartDataTask1(SmartDataTask smartDataTask) {
|
|
|
// 检测参数,还有是否存在重复记录
|
|
|
// 任务属性
|
|
|
if (smartDataTask.getTkName() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【任务名称】不能为空!");
|
|
|
}
|
|
|
- if (!CommonUtil.checkStrByRegx("^[a-zA-Z0-9]{5,32}$", smartDataTask.getTkName())) {
|
|
|
- return CommonUtil.getReturnMap("1", "【任务名称】只能包含字母、数字,且长度为5-32位!");
|
|
|
+ // 只能包含字母、数字、下划线和中文,且长度为5-32位
|
|
|
+ if (!CommonUtil.checkStrByRegx("^[\\w\\u4e00-\\u9fa5]{4,32}$", smartDataTask.getTkName())) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【任务名称】只能包含字母、数字、下划线和中文,且长度为4-32位!");
|
|
|
}
|
|
|
QueryWrapper<SmartDataTask> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq(smartDataTask.getTkName() != null, "tk_name", smartDataTask.getTkName());
|
|
|
@@ -73,6 +77,10 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (smartDataTask.getTkDtId() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【部门id】不能为空!");
|
|
|
}
|
|
|
+ int numOfDepartment = smartDataTaskMapper.isHaveDepartmentById(smartDataTask.getTkDtId());
|
|
|
+ if (numOfDepartment == 0) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【部门】不存在!");
|
|
|
+ }
|
|
|
if (smartDataTask.getTkSyncPolicy() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【同步策略】不能为空!");
|
|
|
}
|
|
|
@@ -80,8 +88,8 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (smartDataTask.getTkDsIdSource() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【来源数据源id】不能为空!");
|
|
|
}
|
|
|
- SmartDataSource smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsIdSource());
|
|
|
- if (smartDataSource == null) {
|
|
|
+ SmartDataSourceJobParams dsSource = smartDataSourceMapper.getDataSourceInfo(smartDataTask.getTkDsIdSource());
|
|
|
+ if (dsSource == null) {
|
|
|
return CommonUtil.getReturnMap("1", "选择的【来源数据源】不存在!");
|
|
|
}
|
|
|
if (smartDataTask.getTkExchangeType() == null) {
|
|
|
@@ -94,8 +102,8 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (smartDataTask.getTkDsIdDestination() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【目标数据源id】不能为空!");
|
|
|
}
|
|
|
- smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsIdDestination());
|
|
|
- if (smartDataSource == null) {
|
|
|
+ SmartDataSourceJobParams dsDestination = smartDataSourceMapper.getDataSourceInfo(smartDataTask.getTkDsIdDestination());
|
|
|
+ if (dsDestination == null) {
|
|
|
return CommonUtil.getReturnMap("1", "选择的【目标数据源】不存在!");
|
|
|
}
|
|
|
if (smartDataTask.getTkDestTable() == null) {
|
|
|
@@ -110,16 +118,22 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
return CommonUtil.getReturnMap("1", "【指定服务器id】不能为空!");
|
|
|
}
|
|
|
}
|
|
|
- if (smartDataTask.getTkOptCfgAutoManual()== null) {
|
|
|
+ if (smartDataTask.getTkOptCfgAutoManual() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【运行参数配置】不能为空!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkOptCfgAutoManual() == 1){
|
|
|
+ if (smartDataTask.getTkOptCfgAutoManual() == 1) {
|
|
|
if (smartDataTask.getTkOptCfgRsNum() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【运行参数配置:记录数】不能为空!");
|
|
|
}
|
|
|
+ if (smartDataTask.getTkOptCfgRsNum() > 100){
|
|
|
+ return CommonUtil.getReturnMap("1", "【运行参数配置:记录数】不能大于100!");
|
|
|
+ }
|
|
|
if (smartDataTask.getTkOptCfgThreadsNum() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【运行参数配置:线程数】不能为空!");
|
|
|
}
|
|
|
+ if (smartDataTask.getTkOptCfgThreadsNum() > 10) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【运行参数配置:线程数】不能大于10!");
|
|
|
+ }
|
|
|
}
|
|
|
if (smartDataTask.getTkRsIncorrectData() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【是否记录错误数据】不能为空!");
|
|
|
@@ -127,25 +141,35 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (smartDataTask.getTkDsSourceCharset() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【来源数据源字符集】不能为空!");
|
|
|
}
|
|
|
+ if (!smartDataTask.getTkDsSourceCharset().equals("UTF8") && !smartDataTask.getTkDsSourceCharset().equals("GBK")) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【来源数据源字符集】只能为UTF8或GBK!");
|
|
|
+ }
|
|
|
if (smartDataTask.getTkDsDestinationCharset() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【目标数据源字符集】不能为空!");
|
|
|
}
|
|
|
+ if (!smartDataTask.getTkDsDestinationCharset().equals("UTF8") && !smartDataTask.getTkDsDestinationCharset().equals("GBK")) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【目标数据源字符集】只能为UTF8或GBK!");
|
|
|
+ }
|
|
|
|
|
|
queryWrapper.eq(smartDataTask.getTkDtId() != null, "tk_dt_id", smartDataTask.getTkDtId());
|
|
|
queryWrapper.eq(smartDataTask.getTkDsIdSource() != null, "tk_ds_id_source", smartDataTask.getTkDsIdSource());
|
|
|
queryWrapper.eq(smartDataTask.getTkSyncPolicy() != null, "tk_sync_policy", smartDataTask.getTkSyncPolicy());
|
|
|
queryWrapper.eq(smartDataTask.getTkExchangeType() != null, "tk_exchange_type", smartDataTask.getTkExchangeType());
|
|
|
- queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", smartDataTask.getTkSql());
|
|
|
+ // 交换方式:0自定义SQL语句,1数据视图,2数据表,如果是1或2,tkSql传视图或表格名称即可
|
|
|
+ if (smartDataTask.getTkExchangeType() == 0) {
|
|
|
+ queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", smartDataTask.getTkSql());
|
|
|
+ } else {
|
|
|
+ String sql = "SELECT * FROM " + smartDataTask.getTkSql().substring(0, smartDataTask.getTkSql().indexOf("["));
|
|
|
+ queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", sql);
|
|
|
+ smartDataTask.setTkSql(sql);
|
|
|
+ }
|
|
|
queryWrapper.eq(smartDataTask.getTkDsIdDestination() != null, "tk_ds_id_destination", smartDataTask.getTkDsIdDestination());
|
|
|
queryWrapper.eq(smartDataTask.getTkDestTable() != null, "tk_dest_table", smartDataTask.getTkDestTable());
|
|
|
queryWrapper.eq(smartDataTask.getTkExchangeServer() != null, "tk_exchange_server", smartDataTask.getTkExchangeServer());
|
|
|
- queryWrapper.eq(smartDataTask.getTkExchangeServer() != null && smartDataTask.getTkExchangeServerId() != null,
|
|
|
- "tk_exchange_server_id", smartDataTask.getTkExchangeServerId());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkExchangeServer() != null && smartDataTask.getTkExchangeServerId() != null, "tk_exchange_server_id", smartDataTask.getTkExchangeServerId());
|
|
|
queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null, "tk_opt_cfg_auto_manual", smartDataTask.getTkOptCfgAutoManual());
|
|
|
- queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null && smartDataTask.getTkOptCfgRsNum() != null,
|
|
|
- "tk_opt_cfg_rs_num", smartDataTask.getTkOptCfgRsNum());
|
|
|
- queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null && smartDataTask.getTkOptCfgThreadsNum() != null,
|
|
|
- "tk_opt_cfg_threads_num", smartDataTask.getTkOptCfgThreadsNum());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null && smartDataTask.getTkOptCfgRsNum() != null, "tk_opt_cfg_rs_num", smartDataTask.getTkOptCfgRsNum());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null && smartDataTask.getTkOptCfgThreadsNum() != null, "tk_opt_cfg_threads_num", smartDataTask.getTkOptCfgThreadsNum());
|
|
|
queryWrapper.eq(smartDataTask.getTkRsIncorrectData() != null, "tk_rs_incorrect_data", smartDataTask.getTkRsIncorrectData());
|
|
|
queryWrapper.eq(smartDataTask.getTkDsSourceCharset() != null, "tk_ds_source_charset", smartDataTask.getTkDsSourceCharset());
|
|
|
queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkDsDestinationCharset()), "tk_ds_destination_charset", smartDataTask.getTkDsDestinationCharset());
|
|
|
@@ -153,42 +177,164 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (sdt != null) {
|
|
|
return CommonUtil.getReturnMap("1", "有重复记录!");
|
|
|
}
|
|
|
-
|
|
|
+ // 插入记录,插入成功后获取记录的id返回
|
|
|
int result = smartDataTaskMapper.insert(smartDataTask);
|
|
|
if (result > 0) {
|
|
|
- return CommonUtil.getReturnMap("0", "任务添加成功!");
|
|
|
+ // 获取数据源对应的表、视图、Sql对应的结构
|
|
|
+ return CommonUtil.getReturnMap("0", this.getMetaData(smartDataTask, dsSource, dsDestination, "添加"));
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【添加任务-任务基本信息】添加失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> getMetaData(SmartDataTask smartDataTask, SmartDataSourceJobParams dsSource, SmartDataSourceJobParams dsDestination, String action) {
|
|
|
+ // 源连接
|
|
|
+ DBUtil dsSourceDbUtil = new DBUtil(dsSource.getDsUrl(), dsSource.getDsUser(), dsSource.getDsPassword(), dsSource.getDsClsDriver(), "UTF8");
|
|
|
+ Map<String, Object> dsSourceMap = dsSourceDbUtil.getConnection();
|
|
|
+ if (dsSourceMap.get("code") == "1") {
|
|
|
+ return CommonUtil.getReturnMap("1", "【来源数据源】连接失败!");
|
|
|
+ }
|
|
|
+ Connection dsSourceConn = (Connection) dsSourceMap.get("msg");
|
|
|
+ // 解析字段名称、字段类型、字段大小等
|
|
|
+ Map<String, Object> metaDataBySql = dsSourceDbUtil.getMetaDataBySql(dsSourceConn, smartDataTask.getTkSql());
|
|
|
+ if (metaDataBySql.get("code") == "1") {
|
|
|
+ return CommonUtil.getReturnMap("1", metaDataBySql.get("msg"));
|
|
|
+ }
|
|
|
+ List<Map<String, String>> listSource = (List<Map<String, String>>) metaDataBySql.get("msg");
|
|
|
+ // 目标连接
|
|
|
+ DBUtil dbDestinationUtil = new DBUtil(dsDestination.getDsUrl(), dsDestination.getDsUser(), dsDestination.getDsPassword(), dsDestination.getDsClsDriver(), "UTF8");
|
|
|
+ Map<String, Object> dsDestinationMap = dbDestinationUtil.getConnection();
|
|
|
+ if (dsDestinationMap.get("code") == "1") {
|
|
|
+ return CommonUtil.getReturnMap("1", "【目标数据源】连接失败!");
|
|
|
+ }
|
|
|
+ Connection dsDestinationConn = (Connection) dsDestinationMap.get("msg");
|
|
|
+ // 目标数据表
|
|
|
+ Map<String, Object> metaDataByTable = dbDestinationUtil.getMetaDataByTable(dsDestinationConn, smartDataTask.getTkDestTable().substring(0, smartDataTask.getTkDestTable().indexOf("[")));
|
|
|
+ if (metaDataByTable.get("code") == "1") {
|
|
|
+ return CommonUtil.getReturnMap("1", metaDataByTable.get("msg"));
|
|
|
+ }
|
|
|
+ List<Map<String, String>> listDestination = (List<Map<String, String>>) metaDataByTable.get("msg");
|
|
|
+
|
|
|
+ // 组合返回数据
|
|
|
+ Map<String, Object> returnMap = new HashMap<>();
|
|
|
+ returnMap.put("tkId", smartDataTask.getTkId());
|
|
|
+ returnMap.put("msg", "【" + action + "任务-任务基本信息】" + action + "成功!");
|
|
|
+ returnMap.put("dsSourceMetaData", listSource);
|
|
|
+ returnMap.put("dsDestinationMetaData", listDestination);
|
|
|
+
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加任务2-字段配置
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> insertSmartDataTask2(JSONObject requestData) {
|
|
|
+ return this.insertOrUpdate2(requestData, "添加");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> insertOrUpdate2(JSONObject requestData, String action) {
|
|
|
+ // 任务ID
|
|
|
+ if (requestData.containsKey("tkId")) {
|
|
|
+ // tkId 存在
|
|
|
+ int tkId = requestData.getIntValue("tkId");
|
|
|
+ if (tkId <= 0) {
|
|
|
+ return CommonUtil.getReturnMap("1", "任务id错误!");
|
|
|
+ }
|
|
|
+ // 字段对应关系
|
|
|
+ if (requestData.containsKey("colRelationship")) {
|
|
|
+ JSONArray colRelationshipArray = requestData.getJSONArray("colRelationship");
|
|
|
+ if (colRelationshipArray.size() > 0) {
|
|
|
+ String colRelationship = colRelationshipArray.toString();
|
|
|
+ // 检测是否有修改
|
|
|
+ if (action.equals("编辑")) {
|
|
|
+ SmartDataTask smartDataTask = smartDataTaskMapper.selectColRelationship(tkId);
|
|
|
+ if (JSONArray.parseArray(smartDataTask.getTkColRelationship()).equals(colRelationshipArray)) {
|
|
|
+ return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 检测数据类型和字段长度是否符合要求
|
|
|
+ for (int i = 0; i < colRelationshipArray.size(); i++) {
|
|
|
+ JSONObject colRelationshipObj = colRelationshipArray.getJSONObject(i);
|
|
|
+ String colSource = colRelationshipObj.getString("colSource");
|
|
|
+ String colSourceType = colRelationshipObj.getString("colSourceType");
|
|
|
+ Integer colSourceSize = colRelationshipObj.getInteger("colSourceSize");
|
|
|
+ String colDestination = colRelationshipObj.getString("colDestination");
|
|
|
+ String colDestinationType = colRelationshipObj.getString("colDestinationType");
|
|
|
+ Integer colDestinationSize = colRelationshipObj.getInteger("colDestinationSize");
|
|
|
+ // 判断字段类型是否一致
|
|
|
+ if (!colSourceType.equals(colDestinationType)) {
|
|
|
+ return CommonUtil.getReturnMap("1", "来源字段类型【" + colSource + "】与 目标字段类型【" + colDestination + "】不一致!");
|
|
|
+ }
|
|
|
+ // 判断目标字段长度是否小于来源字段长度
|
|
|
+ if (colSourceSize > colDestinationSize) {
|
|
|
+ return CommonUtil.getReturnMap("1", "目标字段长度【" + colSource + "】小于 来源字段长度【" + colDestination + "】!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 存数据库中
|
|
|
+ int num = smartDataTaskMapper.insertColRelationship(tkId, colRelationship);
|
|
|
+ if (num > 0) {
|
|
|
+ return CommonUtil.getReturnMap("0", "【" + action + "任务-字段配置】" + action + "成功!");
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【" + action + "任务-字段配置】" + action + "失败!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "字段对应关系为空!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "字段对应关系为空!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // tkId 不存在
|
|
|
+ return CommonUtil.getReturnMap("1", "任务ID为空!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加任务3-定时信息
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> insertSmartDataTask3(SmartDataTask smartDataTask) {
|
|
|
+ return this.insertOrUpdate3(smartDataTask, "添加");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> insertOrUpdate3(SmartDataTask smartDataTask, String action) {
|
|
|
+ if (smartDataTask.getTkManualOrAuto() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【手动或定时执行】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkManualOrAuto() == 0) {
|
|
|
+ if (smartDataTask.getTkExeType() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【执行方式】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkRepetTime() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】不能为空!");
|
|
|
+ }
|
|
|
+ // 生成cron表达式
|
|
|
+ Map<String, Object> stringObjectMap = generateCron(smartDataTask.getTkExeType(), smartDataTask.getTkRepetTime());
|
|
|
+ if (stringObjectMap.get("code") == "1") {
|
|
|
+ return stringObjectMap;
|
|
|
+ }
|
|
|
+ String cron = (String) stringObjectMap.get("msg");
|
|
|
+ if (CronExpression.isValidExpression(cron)) {
|
|
|
+ smartDataTask.setTkCron(cron);
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "生成的【定时表达式】不正确!请联系管理员!" + cron);
|
|
|
+ }
|
|
|
} else {
|
|
|
- return CommonUtil.getReturnMap("1", "任务添加失败!");
|
|
|
- }
|
|
|
-
|
|
|
-// if (smartDataTask.getTkManualOrAuto() == null) {
|
|
|
-// return CommonUtil.getReturnMap("1", "【手动或定时执行】不能为空!");
|
|
|
-// }
|
|
|
-// if (smartDataTask.getTkManualOrAuto() == 0) {
|
|
|
-// if (smartDataTask.getTkExeType() == null) {
|
|
|
-// return CommonUtil.getReturnMap("1", "【执行方式】不能为空!");
|
|
|
-// }
|
|
|
-// if (smartDataTask.getTkRepetTime() == null) {
|
|
|
-// return CommonUtil.getReturnMap("1", "【重复时间】不能为空!");
|
|
|
-// }
|
|
|
-// // 生成cron表达式
|
|
|
-// Map<String, Object> stringObjectMap = generateCron(smartDataTask.getTkExeType(), smartDataTask.getTkRepetTime());
|
|
|
-// if (stringObjectMap.get("code") == "1") {
|
|
|
-// return stringObjectMap;
|
|
|
-// }
|
|
|
-// String cron = (String) stringObjectMap.get("msg");
|
|
|
-// if (CronExpression.isValidExpression(cron)) {
|
|
|
-// smartDataTask.setTkCron(cron);
|
|
|
-// } else {
|
|
|
-// return CommonUtil.getReturnMap("1", "生成的【定时表达式】不正确!请联系管理员!" + cron);
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// smartDataTask.setTkExeType(-1);
|
|
|
-// smartDataTask.setTkRepetTime("");
|
|
|
-// }
|
|
|
-// if (smartDataTask.getTkDescrition() == null) {
|
|
|
-// return CommonUtil.getReturnMap("1", "【任务描述】不能为空!");
|
|
|
-// }
|
|
|
+ smartDataTask.setTkCron("");
|
|
|
+ smartDataTask.setTkExeType(-1);
|
|
|
+ smartDataTask.setTkRepetTime("");
|
|
|
+ }
|
|
|
+ // 检测是否有重复记录
|
|
|
+ if (action.equals("编辑")) {
|
|
|
+ int numSDT = smartDataTaskMapper.isRepeatTask(smartDataTask);
|
|
|
+ if (numSDT > 0) {
|
|
|
+ return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 入库
|
|
|
+ int num = smartDataTaskMapper.updateById(smartDataTask);
|
|
|
+ if (num > 0) {
|
|
|
+ return CommonUtil.getReturnMap("0", "【" + action + "任务-定时信息】" + action + "成功!");
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【" + action + "任务-定时信息】" + action + "失败!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 生成cron表达式
|
|
|
@@ -277,8 +423,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
|
|
|
|
int day = Integer.parseInt(split[0]);
|
|
|
- if (day > 30 || day < 1)
|
|
|
- CommonUtil.getReturnMap("1", "【重复时间】格式错误2,要求:19 09:40");
|
|
|
+ if (day > 30 || day < 1) CommonUtil.getReturnMap("1", "【重复时间】格式错误2,要求:19 09:40");
|
|
|
|
|
|
if (isOnlyHourAndMinute(split[1])) {
|
|
|
String[] hour_minute = split[1].split(":");
|
|
|
@@ -303,81 +448,127 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> updateSmartDataTaskById(SmartDataTask smartDataTask) {
|
|
|
+ public Map<String, Object> updateSmartDataTaskById1(SmartDataTask smartDataTask) {
|
|
|
if (smartDataTask.getTkId() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【任务id】不能为空!");
|
|
|
}
|
|
|
+ // 任务属性
|
|
|
+ SmartDataTask sdc = smartDataTaskMapper.selectById(smartDataTask.getTkId());
|
|
|
+ if (sdc == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "要修改的【任务】不存在!");
|
|
|
+ }
|
|
|
if (smartDataTask.getTkName() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【任务名称】不能为空!");
|
|
|
}
|
|
|
- // 检测参数,还有是否存在重复记录
|
|
|
- List<SmartDataTask> smartDataSources = smartDataTaskMapper.isRepeatTaskName(smartDataTask);
|
|
|
- if (smartDataSources.size() > 0) {
|
|
|
+ // 只能包含字母、数字、下划线和中文,且长度为5-32位
|
|
|
+ if (!CommonUtil.checkStrByRegx("^[\\w\\u4e00-\\u9fa5]{4,32}$", smartDataTask.getTkName())) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【任务名称】只能包含字母、数字、下划线和中文,且长度为4-32位!");
|
|
|
+ }
|
|
|
+ int numOfDataTask = smartDataTaskMapper.isRepeatTaskName(smartDataTask);
|
|
|
+ if (numOfDataTask > 0) {
|
|
|
return CommonUtil.getReturnMap("1", "任务名有重名!");
|
|
|
}
|
|
|
- SmartDataTask sdc = smartDataTaskMapper.selectById(smartDataTask.getTkId());
|
|
|
- if (sdc == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "要修改的【任务】不存在!");
|
|
|
+ if (smartDataTask.getTkDtId() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【部门id】不能为空!");
|
|
|
+ }
|
|
|
+ int numOfDepartment = smartDataTaskMapper.isHaveDepartmentById(smartDataTask.getTkDtId());
|
|
|
+ if (numOfDepartment == 0) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【部门】不存在!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkSyncPolicy() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【同步策略】不能为空!");
|
|
|
}
|
|
|
+ // 来源库设置
|
|
|
if (smartDataTask.getTkDsIdSource() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【来源数据源id】不能为空!");
|
|
|
}
|
|
|
- SmartDataSource smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsIdSource());
|
|
|
- if (smartDataSource == null) {
|
|
|
+ SmartDataSourceJobParams dsSource = smartDataSourceMapper.getDataSourceInfo(smartDataTask.getTkDsIdSource());
|
|
|
+ if (dsSource == null) {
|
|
|
return CommonUtil.getReturnMap("1", "选择的【来源数据源】不存在!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkSyncPolicy() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【同步策略】不能为空!");
|
|
|
- }
|
|
|
if (smartDataTask.getTkExchangeType() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【交换方式】不能为空!");
|
|
|
}
|
|
|
if (smartDataTask.getTkSql() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【数据来源SQL语句】不能为空!");
|
|
|
+ return CommonUtil.getReturnMap("1", "【自定义SQL语句】不能为空!");
|
|
|
}
|
|
|
+ // 目的库设置
|
|
|
if (smartDataTask.getTkDsIdDestination() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【目标数据源id】不能为空!");
|
|
|
}
|
|
|
- smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsIdDestination());
|
|
|
- if (smartDataSource == null) {
|
|
|
+ SmartDataSourceJobParams dsDestination = smartDataSourceMapper.getDataSourceInfo(smartDataTask.getTkDsIdDestination());
|
|
|
+ if (dsDestination == null) {
|
|
|
return CommonUtil.getReturnMap("1", "选择的【目标数据源】不存在!");
|
|
|
}
|
|
|
if (smartDataTask.getTkDestTable() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【目标数据表】不能为空!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkManualOrAuto() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【手动或定时执行】不能为空!");
|
|
|
+ // 高级设置
|
|
|
+ if (smartDataTask.getTkExchangeServer() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【交换服务器】不能为空!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkManualOrAuto() == 0) {
|
|
|
- if (smartDataTask.getTkExeType() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【执行方式】不能为空!");
|
|
|
+ if (smartDataTask.getTkExchangeServer() == 1) {
|
|
|
+ if (smartDataTask.getTkExchangeServerId() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【指定服务器id】不能为空!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkRepetTime() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【重复时间】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkOptCfgAutoManual() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【运行参数配置】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkOptCfgAutoManual() == 1) {
|
|
|
+ if (smartDataTask.getTkOptCfgRsNum() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【运行参数配置:记录数】不能为空!");
|
|
|
}
|
|
|
- // 生成cron表达式
|
|
|
- Map<String, Object> stringObjectMap = generateCron(smartDataTask.getTkExeType(), smartDataTask.getTkRepetTime());
|
|
|
- if (stringObjectMap.get("code") == "1") {
|
|
|
- return stringObjectMap;
|
|
|
+ if (smartDataTask.getTkOptCfgRsNum() > 100){
|
|
|
+ return CommonUtil.getReturnMap("1", "【运行参数配置:记录数】不能大于100!");
|
|
|
}
|
|
|
- smartDataTask.setTkCron((String) stringObjectMap.get("msg"));
|
|
|
- } else {
|
|
|
- smartDataTask.setTkExeType(0);
|
|
|
- smartDataTask.setTkRepetTime("");
|
|
|
+ if (smartDataTask.getTkOptCfgThreadsNum() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【运行参数配置:线程数】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkOptCfgThreadsNum() > 10) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【运行参数配置:线程数】不能大于10!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkRsIncorrectData() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【是否记录错误数据】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkDsSourceCharset() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【来源数据源字符集】不能为空!");
|
|
|
+ }
|
|
|
+ if (!smartDataTask.getTkDsSourceCharset().equals("UTF8") && !smartDataTask.getTkDsSourceCharset().equals("GBK")) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【来源数据源字符集】只能为UTF8或GBK!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkDsDestinationCharset() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【目标数据源字符集】不能为空!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkDescrition() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【任务描述】不能为空!");
|
|
|
+ if (!smartDataTask.getTkDsDestinationCharset().equals("UTF8") && !smartDataTask.getTkDsDestinationCharset().equals("GBK")) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【目标数据源字符集】只能为UTF8或GBK!");
|
|
|
}
|
|
|
+
|
|
|
QueryWrapper<SmartDataTask> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq(smartDataTask.getTkName() != null, "tk_name", smartDataTask.getTkName());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkDtId() != null, "tk_dt_id", smartDataTask.getTkDtId());
|
|
|
queryWrapper.eq(smartDataTask.getTkDsIdSource() != null, "tk_ds_id_source", smartDataTask.getTkDsIdSource());
|
|
|
queryWrapper.eq(smartDataTask.getTkSyncPolicy() != null, "tk_sync_policy", smartDataTask.getTkSyncPolicy());
|
|
|
queryWrapper.eq(smartDataTask.getTkExchangeType() != null, "tk_exchange_type", smartDataTask.getTkExchangeType());
|
|
|
- queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", smartDataTask.getTkSql());
|
|
|
+ // 交换方式:0自定义SQL语句,1数据视图,2数据表,如果是1或2,tkSql传视图或表格名称即可
|
|
|
+ if (smartDataTask.getTkExchangeType() == 0) {
|
|
|
+ queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", smartDataTask.getTkSql());
|
|
|
+ } else {
|
|
|
+ String sql = "SELECT * FROM " + smartDataTask.getTkSql().substring(0, smartDataTask.getTkSql().indexOf("["));
|
|
|
+ queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", sql);
|
|
|
+ smartDataTask.setTkSql(sql);
|
|
|
+ }
|
|
|
queryWrapper.eq(smartDataTask.getTkDsIdDestination() != null, "tk_ds_id_destination", smartDataTask.getTkDsIdDestination());
|
|
|
queryWrapper.eq(smartDataTask.getTkDestTable() != null, "tk_dest_table", smartDataTask.getTkDestTable());
|
|
|
- queryWrapper.eq(smartDataTask.getTkManualOrAuto() != null, "tk_manual_or_auto", smartDataTask.getTkManualOrAuto());
|
|
|
- queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkDescrition()), "tk_descrition", smartDataTask.getTkDescrition());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkExchangeServer() != null, "tk_exchange_server", smartDataTask.getTkExchangeServer());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkExchangeServer() != null && smartDataTask.getTkExchangeServerId() != null, "tk_exchange_server_id", smartDataTask.getTkExchangeServerId());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null, "tk_opt_cfg_auto_manual", smartDataTask.getTkOptCfgAutoManual());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null && smartDataTask.getTkOptCfgRsNum() != null, "tk_opt_cfg_rs_num", smartDataTask.getTkOptCfgRsNum());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkOptCfgAutoManual() != null && smartDataTask.getTkOptCfgThreadsNum() != null, "tk_opt_cfg_threads_num", smartDataTask.getTkOptCfgThreadsNum());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkRsIncorrectData() != null, "tk_rs_incorrect_data", smartDataTask.getTkRsIncorrectData());
|
|
|
+ queryWrapper.eq(smartDataTask.getTkDsSourceCharset() != null, "tk_ds_source_charset", smartDataTask.getTkDsSourceCharset());
|
|
|
+ queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkDsDestinationCharset()), "tk_ds_destination_charset", smartDataTask.getTkDsDestinationCharset());
|
|
|
SmartDataTask sdt = smartDataTaskMapper.selectOne(queryWrapper);
|
|
|
if (sdt != null) {
|
|
|
return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
|
|
|
@@ -385,12 +576,23 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
|
|
|
int result = smartDataTaskMapper.updateById(smartDataTask);
|
|
|
if (result > 0) {
|
|
|
- return CommonUtil.getReturnMap("0", "任务修改成功!");
|
|
|
+ // 获取数据源对应的表、视图、Sql对应的结构
|
|
|
+ return CommonUtil.getReturnMap("0", this.getMetaData(smartDataTask, dsSource, dsDestination, "编辑"));
|
|
|
} else {
|
|
|
- return CommonUtil.getReturnMap("1", "任务修改失败!");
|
|
|
+ return CommonUtil.getReturnMap("1", "【编辑任务-任务基本信息】失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> updateSmartDataTaskById2(JSONObject requestData) {
|
|
|
+ return this.insertOrUpdate2(requestData, "编辑");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> updateSmartDataTaskById3(SmartDataTask smartDataTask) {
|
|
|
+ return this.insertOrUpdate3(smartDataTask, "编辑");
|
|
|
+ }
|
|
|
+
|
|
|
// 判断之前状态是否启用
|
|
|
public Map<String, Object> updateSmartDataTaskActivation(SmartDataTask smartDataTask) {
|
|
|
// 检测参数,还有是否存在重复记录
|
|
|
@@ -428,15 +630,39 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
queryWrapper.eq(smartDataTask.getTkExeType() != null, "tk_exe_type", smartDataTask.getTkExeType());
|
|
|
queryWrapper.like(smartDataTask.getTkDestTable() != null, "tk_dest_table", smartDataTask.getTkDestTable());
|
|
|
queryWrapper.eq(smartDataTask.getTkActivation() != null, "tk_activation", smartDataTask.getTkActivation());
|
|
|
- queryWrapper.like(smartDataTask.getTkDescrition() != null, "tk_descrition", smartDataTask.getTkDescrition());
|
|
|
+ queryWrapper.orderByAsc("tk_deleted");
|
|
|
queryWrapper.orderByDesc("tk_update_time");
|
|
|
IPage<SmartDataTask> result = smartDataTaskMapper.selectPage(page, queryWrapper);
|
|
|
return new PageUtils<>(result);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int deleteSmartDataTaskById(SmartDataTask smartDataTask) {
|
|
|
- return smartDataTaskMapper.deleteMarkTaskById(smartDataTask);
|
|
|
+ public Map<String, Object> deleteSmartDataTaskById(int id, int delMethod) {
|
|
|
+ if (delMethod == 0) {
|
|
|
+ // 逻辑删除
|
|
|
+ int num = smartDataTaskMapper.logicDeleteMarkTaskById(id);
|
|
|
+ if (num > 0) {
|
|
|
+ return CommonUtil.getReturnMap("0", "逻辑删除成功");
|
|
|
+ }
|
|
|
+ return CommonUtil.getReturnMap("1", "逻辑删除失败");
|
|
|
+ } else if (delMethod == 1) {
|
|
|
+ // 恢复逻辑删除
|
|
|
+ int num = smartDataTaskMapper.restoreLogicDeleteMarkTaskById(id);
|
|
|
+ if (num > 0) {
|
|
|
+ return CommonUtil.getReturnMap("0", "恢复逻辑删除成功");
|
|
|
+ }
|
|
|
+ return CommonUtil.getReturnMap("1", "恢复逻辑删除失败");
|
|
|
+ } else if (delMethod == 9) {
|
|
|
+ // 物理删除
|
|
|
+ int num = smartDataTaskMapper.physicsDeleteMarkTaskById(id);
|
|
|
+ if (num > 0) {
|
|
|
+ return CommonUtil.getReturnMap("0", "物理删除成功");
|
|
|
+ }
|
|
|
+ return CommonUtil.getReturnMap("1", "物理删除失败");
|
|
|
+ } else {
|
|
|
+ // 错误
|
|
|
+ return CommonUtil.getReturnMap("1", "删除方式错误");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -444,6 +670,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
return smartDataTaskMapper.selectById(id);
|
|
|
}
|
|
|
|
|
|
+ // 校验任务名是否存在
|
|
|
public Map<String, Object> TaskNameValidator(SmartDataTask smartDataTask) {
|
|
|
if (smartDataTask.getTkName() == null) {
|
|
|
return CommonUtil.getReturnMap(String.valueOf(1), "任务名称为空!");
|
|
|
@@ -460,21 +687,26 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> createJob(SmartDataTask smartDataTask) {
|
|
|
+ // 校验任务名是否存在
|
|
|
Map<String, Object> tmp_map = TaskNameValidator(smartDataTask);
|
|
|
if ("1".equals(tmp_map.get("code"))) {
|
|
|
return tmp_map;
|
|
|
}
|
|
|
|
|
|
SmartDataTask smartDataTask_return = (SmartDataTask) tmp_map.get("msg");
|
|
|
+ if (smartDataTask_return.getTkCron() == null) {
|
|
|
+ return CommonUtil.getReturnMap(String.valueOf(1), "任务调度cron表达式为空!该任务未设置【定时信息】!");
|
|
|
+ }
|
|
|
// 来源数据源id
|
|
|
Integer tkDsIdSource = smartDataTask_return.getTkDsIdSource();
|
|
|
// 目标数据源id
|
|
|
Integer tkDsIdDestination = smartDataTask_return.getTkDsIdDestination();
|
|
|
// 根据id,获取数据源url、user、password、driver等
|
|
|
SmartDataSourceJobParams dsSourceInfo = smartDataSourceMapper.getDataSourceInfo(tkDsIdSource);
|
|
|
- dsSourceInfo.setSql(smartDataTask_return.getTkSql());
|
|
|
+ dsSourceInfo.setExchangeType(smartDataTask_return.getTkExchangeType());
|
|
|
+ dsSourceInfo.setSourceSql(smartDataTask_return.getTkSql());
|
|
|
SmartDataSourceJobParams dsDestinationInfo = smartDataSourceMapper.getDataSourceInfo(tkDsIdDestination);
|
|
|
- dsDestinationInfo.setSql(smartDataTask_return.getTkSql());
|
|
|
+ dsDestinationInfo.setDestinationTable(smartDataTask_return.getTkDestTable());
|
|
|
|
|
|
Map<String, Object> returnMap = QuartzJobUtils.createScheduleJob(scheduler, smartDataTask_return, dsSourceInfo, dsDestinationInfo);
|
|
|
if ("0".equals(returnMap.get("code"))) {
|
|
|
@@ -652,14 +884,12 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (exchangeType == 0) {
|
|
|
// sql语句
|
|
|
if (dataSourceInfo != null) {
|
|
|
- DBUtil dbUtil = new DBUtil(dataSourceInfo.getDsUrl(), dataSourceInfo.getDsUser(), dataSourceInfo.getDsPassword(), dataSourceInfo.getDsClsDriver());
|
|
|
+ DBUtil dbUtil = new DBUtil(dataSourceInfo.getDsUrl(), dataSourceInfo.getDsUser(), dataSourceInfo.getDsPassword(), dataSourceInfo.getDsClsDriver(), "UTF8");
|
|
|
Map<String, Object> map_return = dbUtil.getConnection();
|
|
|
if (map_return.get("code") == "0") {
|
|
|
Map<String, Object> metaDataBySql = dbUtil.getMetaDataBySql((Connection) map_return.get("msg"), sql);
|
|
|
if (metaDataBySql.get("code") == "0") {
|
|
|
return CommonUtil.getReturnMap("0", "SQL语句正确");
|
|
|
- // 解析字段名称、字段类型、字段大小等
|
|
|
-// return CommonUtil.getReturnMap("0", metaDataBySql.get("msg"));
|
|
|
} else {
|
|
|
return CommonUtil.getReturnMap("1", metaDataBySql.get("msg"));
|
|
|
}
|
|
|
@@ -714,7 +944,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
SmartDataSourceJobParams dataSourceInfo = smartDataSourceMapper.getDataSourceInfo(dsIdSource);
|
|
|
if (dataSourceInfo != null) {
|
|
|
// 创建DBUtil对象
|
|
|
- DBUtil dbUtil = new DBUtil(dataSourceInfo.getDsUrl(), dataSourceInfo.getDsUser(), dataSourceInfo.getDsPassword(), dataSourceInfo.getDsClsDriver());
|
|
|
+ DBUtil dbUtil = new DBUtil(dataSourceInfo.getDsUrl(), dataSourceInfo.getDsUser(), dataSourceInfo.getDsPassword(), dataSourceInfo.getDsClsDriver(), "UTF8");
|
|
|
// 获取连接
|
|
|
Map<String, Object> map_return = dbUtil.getConnection();
|
|
|
if (map_return.get("code") == "0") {
|