|
@@ -208,21 +208,25 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
return CommonUtil.getReturnMap("1", "【目标数据源】连接失败!");
|
|
return CommonUtil.getReturnMap("1", "【目标数据源】连接失败!");
|
|
|
}
|
|
}
|
|
|
Connection dsDestinationConn = (Connection) dsDestinationMap.get("msg");
|
|
Connection dsDestinationConn = (Connection) dsDestinationMap.get("msg");
|
|
|
|
|
+ String tmpString = smartDataTask.getTkDestTable();
|
|
|
// 目标数据表
|
|
// 目标数据表
|
|
|
- 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");
|
|
|
|
|
|
|
+ if (tmpString.contains("[")) {
|
|
|
|
|
+ Map<String, Object> metaDataByTable = dbDestinationUtil.getMetaDataByTable(dsDestinationConn, tmpString.substring(0, tmpString.indexOf("[")).trim());
|
|
|
|
|
+ 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);
|
|
|
|
|
|
|
+ // 组合返回数据
|
|
|
|
|
+ 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;
|
|
|
|
|
|
|
+ return returnMap;
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "【目标数据表】格式错误!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 添加任务2-字段配置
|
|
// 添加任务2-字段配置
|
|
@@ -245,12 +249,13 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (colRelationshipArray.size() > 0) {
|
|
if (colRelationshipArray.size() > 0) {
|
|
|
String colRelationship = colRelationshipArray.toString();
|
|
String colRelationship = colRelationshipArray.toString();
|
|
|
// 检测是否有修改
|
|
// 检测是否有修改
|
|
|
- if (action.equals("编辑")) {
|
|
|
|
|
- SmartDataTask smartDataTask = smartDataTaskMapper.selectColRelationship(tkId);
|
|
|
|
|
- if (JSONArray.parseArray(smartDataTask.getTkColRelationship()).equals(colRelationshipArray)) {
|
|
|
|
|
- return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if (action.equals("编辑")) {
|
|
|
|
|
+// SmartDataTask smartDataTask = smartDataTaskMapper.selectColRelationship(tkId);
|
|
|
|
|
+// if (JSONArray.parseArray(smartDataTask.getTkColRelationship()).equals(colRelationshipArray)) {
|
|
|
|
|
+// return CommonUtil.getReturnMap("1", "数据未修改!");
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+ int hasPrimaryKey = 0;
|
|
|
// 检测数据类型和字段长度是否符合要求
|
|
// 检测数据类型和字段长度是否符合要求
|
|
|
for (int i = 0; i < colRelationshipArray.size(); i++) {
|
|
for (int i = 0; i < colRelationshipArray.size(); i++) {
|
|
|
JSONObject colRelationshipObj = colRelationshipArray.getJSONObject(i);
|
|
JSONObject colRelationshipObj = colRelationshipArray.getJSONObject(i);
|
|
@@ -260,6 +265,9 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
String colDestination = colRelationshipObj.getString("colDestination");
|
|
String colDestination = colRelationshipObj.getString("colDestination");
|
|
|
String colDestinationType = colRelationshipObj.getString("colDestinationType");
|
|
String colDestinationType = colRelationshipObj.getString("colDestinationType");
|
|
|
Integer colDestinationSize = colRelationshipObj.getInteger("colDestinationSize");
|
|
Integer colDestinationSize = colRelationshipObj.getInteger("colDestinationSize");
|
|
|
|
|
+ if (colRelationshipObj.getInteger("isUpdatePrimaryKey") == 1) {
|
|
|
|
|
+ hasPrimaryKey++;
|
|
|
|
|
+ }
|
|
|
// 判断字段类型是否一致
|
|
// 判断字段类型是否一致
|
|
|
if (!colSourceType.equals(colDestinationType)) {
|
|
if (!colSourceType.equals(colDestinationType)) {
|
|
|
return CommonUtil.getReturnMap("1", "来源字段类型【" + colSource + "】与 目标字段类型【" + colDestination + "】不一致!");
|
|
return CommonUtil.getReturnMap("1", "来源字段类型【" + colSource + "】与 目标字段类型【" + colDestination + "】不一致!");
|
|
@@ -269,12 +277,19 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
return CommonUtil.getReturnMap("1", "目标字段长度【" + colSource + "】小于 来源字段长度【" + colDestination + "】!");
|
|
return CommonUtil.getReturnMap("1", "目标字段长度【" + colSource + "】小于 来源字段长度【" + colDestination + "】!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (hasPrimaryKey == 0) {
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "至少需要一个更新主键!");
|
|
|
|
|
+ }
|
|
|
// 存数据库中
|
|
// 存数据库中
|
|
|
int num = smartDataTaskMapper.insertColRelationship(tkId, colRelationship);
|
|
int num = smartDataTaskMapper.insertColRelationship(tkId, colRelationship);
|
|
|
if (num > 0) {
|
|
if (num > 0) {
|
|
|
return CommonUtil.getReturnMap("0", "【" + action + "任务-字段配置】" + action + "成功!");
|
|
return CommonUtil.getReturnMap("0", "【" + action + "任务-字段配置】" + action + "成功!");
|
|
|
} else {
|
|
} else {
|
|
|
- return CommonUtil.getReturnMap("1", "【" + action + "任务-字段配置】" + action + "失败!");
|
|
|
|
|
|
|
+ if (action.equals("编辑")) {
|
|
|
|
|
+ return CommonUtil.getReturnMap("0", "【" + action + "任务-字段配置】数据未修改!");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "【" + action + "任务-字段配置】" + action + "失败!");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
return CommonUtil.getReturnMap("1", "字段对应关系为空!");
|
|
return CommonUtil.getReturnMap("1", "字段对应关系为空!");
|
|
@@ -295,6 +310,9 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Map<String, Object> insertOrUpdate3(SmartDataTask smartDataTask, String action) {
|
|
private Map<String, Object> insertOrUpdate3(SmartDataTask smartDataTask, String action) {
|
|
|
|
|
+ if (smartDataTask.getTkId() == null) {
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "任务ID为空!");
|
|
|
|
|
+ }
|
|
|
if (smartDataTask.getTkManualOrAuto() == null) {
|
|
if (smartDataTask.getTkManualOrAuto() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【手动或定时执行】不能为空!");
|
|
return CommonUtil.getReturnMap("1", "【手动或定时执行】不能为空!");
|
|
|
}
|
|
}
|
|
@@ -325,7 +343,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (action.equals("编辑")) {
|
|
if (action.equals("编辑")) {
|
|
|
int numSDT = smartDataTaskMapper.isRepeatTask(smartDataTask);
|
|
int numSDT = smartDataTaskMapper.isRepeatTask(smartDataTask);
|
|
|
if (numSDT > 0) {
|
|
if (numSDT > 0) {
|
|
|
- return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
|
|
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "数据未修改!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 入库
|
|
// 入库
|
|
@@ -555,7 +573,11 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (smartDataTask.getTkExchangeType() == 0) {
|
|
if (smartDataTask.getTkExchangeType() == 0) {
|
|
|
queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", smartDataTask.getTkSql());
|
|
queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", smartDataTask.getTkSql());
|
|
|
} else {
|
|
} else {
|
|
|
- String sql = "SELECT * FROM " + smartDataTask.getTkSql().substring(0, smartDataTask.getTkSql().indexOf("["));
|
|
|
|
|
|
|
+ String sql;
|
|
|
|
|
+ if (smartDataTask.getTkSql().contains("["))
|
|
|
|
|
+ sql = "SELECT * FROM " + smartDataTask.getTkSql().substring(0, smartDataTask.getTkSql().indexOf("["));
|
|
|
|
|
+ else
|
|
|
|
|
+ sql = "SELECT * FROM " + smartDataTask.getTkSql().trim();
|
|
|
queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", sql);
|
|
queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkSql()), "tk_sql", sql);
|
|
|
smartDataTask.setTkSql(sql);
|
|
smartDataTask.setTkSql(sql);
|
|
|
}
|
|
}
|
|
@@ -571,7 +593,15 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkDsDestinationCharset()), "tk_ds_destination_charset", smartDataTask.getTkDsDestinationCharset());
|
|
queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkDsDestinationCharset()), "tk_ds_destination_charset", smartDataTask.getTkDsDestinationCharset());
|
|
|
SmartDataTask sdt = smartDataTaskMapper.selectOne(queryWrapper);
|
|
SmartDataTask sdt = smartDataTaskMapper.selectOne(queryWrapper);
|
|
|
if (sdt != null) {
|
|
if (sdt != null) {
|
|
|
- return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
|
|
|
|
|
|
|
+ // 获取数据源对应的表、视图、Sql对应的结构
|
|
|
|
|
+ Map<String, Object> returnMap = this.getMetaData(smartDataTask, dsSource, dsDestination, "编辑");
|
|
|
|
|
+ if (returnMap.get("code") == null) {
|
|
|
|
|
+ // 获取字段对应关系
|
|
|
|
|
+ String colRelationship = smartDataTaskMapper.getColRelationship(smartDataTask);
|
|
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(colRelationship);
|
|
|
|
|
+ returnMap.put("colRelationship", jsonArray);
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonUtil.getReturnMap("0", returnMap);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int result = smartDataTaskMapper.updateById(smartDataTask);
|
|
int result = smartDataTaskMapper.updateById(smartDataTask);
|
|
@@ -630,12 +660,20 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
public PageUtils<SmartDataTask> queryPageSmartDataTasks(int currentPage, int pageCount, SmartDataTask smartDataTask) {
|
|
public PageUtils<SmartDataTask> queryPageSmartDataTasks(int currentPage, int pageCount, SmartDataTask smartDataTask) {
|
|
|
Page<SmartDataTask> page = new Page<>(currentPage, pageCount);
|
|
Page<SmartDataTask> page = new Page<>(currentPage, pageCount);
|
|
|
QueryWrapper<SmartDataTask> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<SmartDataTask> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.like(smartDataTask.getTkName() != null, "tk_name", smartDataTask.getTkName());
|
|
|
|
|
|
|
+ queryWrapper.like(smartDataTask.getTkName() != null && !smartDataTask.getTkName().equals("") && !smartDataTask.getTkName().equals("null"),
|
|
|
|
|
+ "tk_name", smartDataTask.getTkName());
|
|
|
queryWrapper.eq(smartDataTask.getTkDsIdSource() != null, "tk_ds_id_source", smartDataTask.getTkDsIdSource());
|
|
queryWrapper.eq(smartDataTask.getTkDsIdSource() != null, "tk_ds_id_source", smartDataTask.getTkDsIdSource());
|
|
|
queryWrapper.eq(smartDataTask.getTkDsIdDestination() != null, "tk_ds_id_destination", smartDataTask.getTkDsIdDestination());
|
|
queryWrapper.eq(smartDataTask.getTkDsIdDestination() != null, "tk_ds_id_destination", smartDataTask.getTkDsIdDestination());
|
|
|
queryWrapper.eq(smartDataTask.getTkExchangeType() != null, "tk_exchange_type", smartDataTask.getTkExchangeType());
|
|
queryWrapper.eq(smartDataTask.getTkExchangeType() != null, "tk_exchange_type", smartDataTask.getTkExchangeType());
|
|
|
- queryWrapper.eq(smartDataTask.getTkExeType() != null, "tk_exe_type", smartDataTask.getTkExeType());
|
|
|
|
|
- queryWrapper.like(smartDataTask.getTkDestTable() != null, "tk_dest_table", smartDataTask.getTkDestTable());
|
|
|
|
|
|
|
+ if (smartDataTask.getTkExeType() != null) {
|
|
|
|
|
+ if (smartDataTask.getTkExeType() == -2) {
|
|
|
|
|
+ queryWrapper.isNull("tk_exe_type");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ queryWrapper.eq(true, "tk_exe_type", smartDataTask.getTkExeType());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ queryWrapper.like(smartDataTask.getTkDestTable() != null && !smartDataTask.getTkDestTable().equals("") && !smartDataTask.getTkDestTable().equals("null"),
|
|
|
|
|
+ "tk_dest_table", smartDataTask.getTkDestTable());
|
|
|
queryWrapper.eq(smartDataTask.getTkActivation() != null, "tk_activation", smartDataTask.getTkActivation());
|
|
queryWrapper.eq(smartDataTask.getTkActivation() != null, "tk_activation", smartDataTask.getTkActivation());
|
|
|
queryWrapper.orderByAsc("tk_deleted");
|
|
queryWrapper.orderByAsc("tk_deleted");
|
|
|
queryWrapper.orderByDesc("tk_update_time");
|
|
queryWrapper.orderByDesc("tk_update_time");
|
|
@@ -991,6 +1029,12 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public List<SmartDataTask> queryAllTask() {
|
|
|
|
|
+ List<SmartDataTask> smartDataTask = smartDataTaskMapper.queryAllTask();
|
|
|
|
|
+ return smartDataTask;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public List<SmartDataTaskSetDebugSql> queryTaskDebugSql() {
|
|
public List<SmartDataTaskSetDebugSql> queryTaskDebugSql() {
|
|
|
List<SmartDataTaskSetDebugSql> smartDataTaskSetDebugSqls = smartDataTaskMapper.queryTaskDebugSql();
|
|
List<SmartDataTaskSetDebugSql> smartDataTaskSetDebugSqls = smartDataTaskMapper.queryTaskDebugSql();
|
|
|
return smartDataTaskSetDebugSqls;
|
|
return smartDataTaskSetDebugSqls;
|