|
@@ -1,19 +1,20 @@
|
|
|
package com.template.services.impl;
|
|
package com.template.services.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.db.PageResult;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.template.common.utils.CommonUtil;
|
|
import com.template.common.utils.CommonUtil;
|
|
|
import com.template.common.utils.DBUtil;
|
|
import com.template.common.utils.DBUtil;
|
|
|
import com.template.common.utils.QuartzJobUtils;
|
|
import com.template.common.utils.QuartzJobUtils;
|
|
|
import com.template.mapper.SmartDataSourceMapper;
|
|
import com.template.mapper.SmartDataSourceMapper;
|
|
|
import com.template.mapper.SmartDataTaskMapper;
|
|
import com.template.mapper.SmartDataTaskMapper;
|
|
|
-import com.template.model.pojo.SmartDataSourceJobParams;
|
|
|
|
|
-import com.template.model.pojo.SmartDataTask;
|
|
|
|
|
-import com.template.model.pojo.SmartDepartment;
|
|
|
|
|
|
|
+import com.template.model.pojo.*;
|
|
|
import com.template.model.result.PageUtils;
|
|
import com.template.model.result.PageUtils;
|
|
|
import com.template.services.SmartDataTaskService;
|
|
import com.template.services.SmartDataTaskService;
|
|
|
import org.quartz.CronExpression;
|
|
import org.quartz.CronExpression;
|
|
@@ -302,11 +303,11 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (smartDataTask.getTkExeType() == null) {
|
|
if (smartDataTask.getTkExeType() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【执行方式】不能为空!");
|
|
return CommonUtil.getReturnMap("1", "【执行方式】不能为空!");
|
|
|
}
|
|
}
|
|
|
- if (smartDataTask.getTkRepetTime() == null) {
|
|
|
|
|
|
|
+ if (smartDataTask.getTkRepeatTime() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【重复时间】不能为空!");
|
|
return CommonUtil.getReturnMap("1", "【重复时间】不能为空!");
|
|
|
}
|
|
}
|
|
|
// 生成cron表达式
|
|
// 生成cron表达式
|
|
|
- Map<String, Object> stringObjectMap = generateCron(smartDataTask.getTkExeType(), smartDataTask.getTkRepetTime());
|
|
|
|
|
|
|
+ Map<String, Object> stringObjectMap = generateCron(smartDataTask.getTkExeType(), smartDataTask.getTkRepeatTime());
|
|
|
if (stringObjectMap.get("code") == "1") {
|
|
if (stringObjectMap.get("code") == "1") {
|
|
|
return stringObjectMap;
|
|
return stringObjectMap;
|
|
|
}
|
|
}
|
|
@@ -319,7 +320,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
} else {
|
|
} else {
|
|
|
smartDataTask.setTkCron("");
|
|
smartDataTask.setTkCron("");
|
|
|
smartDataTask.setTkExeType(-1);
|
|
smartDataTask.setTkExeType(-1);
|
|
|
- smartDataTask.setTkRepetTime("");
|
|
|
|
|
|
|
+ smartDataTask.setTkRepeatTime("");
|
|
|
}
|
|
}
|
|
|
// 检测是否有重复记录
|
|
// 检测是否有重复记录
|
|
|
if (action.equals("编辑")) {
|
|
if (action.equals("编辑")) {
|
|
@@ -673,6 +674,14 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public PageInfo<SmartDataTaskErr> queryPageSmartDataTaskErr(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime) {
|
|
|
|
|
+ PageHelper.startPage(currentPage, pageCount);
|
|
|
|
|
+ List<SmartDataTaskErr> result = smartDataTaskMapper.selectPageOrderByDatetimeDesc(eTaskId, startTime, endTime);
|
|
|
|
|
+ PageInfo<SmartDataTaskErr> logPageInfo = new PageInfo<>(result);
|
|
|
|
|
+ return logPageInfo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public SmartDataTask getSmartById(int id) {
|
|
public SmartDataTask getSmartById(int id) {
|
|
|
return smartDataTaskMapper.selectById(id);
|
|
return smartDataTaskMapper.selectById(id);
|
|
|
}
|
|
}
|
|
@@ -704,18 +713,8 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (smartDataTask_return.getTkCron() == null) {
|
|
if (smartDataTask_return.getTkCron() == null) {
|
|
|
return CommonUtil.getReturnMap(String.valueOf(1), "任务调度cron表达式为空!该任务未设置【定时信息】!");
|
|
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.setExchangeType(smartDataTask_return.getTkExchangeType());
|
|
|
|
|
- dsSourceInfo.setSourceSql(smartDataTask_return.getTkSql());
|
|
|
|
|
- SmartDataSourceJobParams dsDestinationInfo = smartDataSourceMapper.getDataSourceInfo(tkDsIdDestination);
|
|
|
|
|
- dsDestinationInfo.setDestinationTable(smartDataTask_return.getTkDestTable());
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Object> returnMap = QuartzJobUtils.createScheduleJob(scheduler, smartDataTask_return, dsSourceInfo, dsDestinationInfo);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> returnMap = QuartzJobUtils.createScheduleJob(scheduler, smartDataTask_return);
|
|
|
if ("0".equals(returnMap.get("code"))) {
|
|
if ("0".equals(returnMap.get("code"))) {
|
|
|
smartDataTask.setTkId(smartDataTask_return.getTkId());
|
|
smartDataTask.setTkId(smartDataTask_return.getTkId());
|
|
|
// 下次执行的时间
|
|
// 下次执行的时间
|
|
@@ -744,8 +743,21 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SmartDataTask smartDataTask_return = (SmartDataTask) tmp_map.get("msg");
|
|
SmartDataTask smartDataTask_return = (SmartDataTask) tmp_map.get("msg");
|
|
|
-
|
|
|
|
|
- return QuartzJobUtils.pauseScheduleJob(scheduler, smartDataTask_return.getTkName());
|
|
|
|
|
|
|
+ Map<String, Object> returnMap = QuartzJobUtils.pauseScheduleJob(scheduler, smartDataTask_return.getTkName());
|
|
|
|
|
+ if ("0".equals(returnMap.get("code"))) {
|
|
|
|
|
+ smartDataTask.setTkId(smartDataTask_return.getTkId());
|
|
|
|
|
+ smartDataTask.setTkActivation(2);
|
|
|
|
|
+ Map<String, Object> stringStringMap = updateSmartDataTaskActivation(smartDataTask);
|
|
|
|
|
+ String msg;
|
|
|
|
|
+ if ("0".equals(stringStringMap.get("code"))) {
|
|
|
|
|
+ msg = (String) returnMap.get("msg") + stringStringMap.get("msg");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msg = (String) returnMap.get("msg") + stringStringMap.get("msg");
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonUtil.getReturnMap("0", msg);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return returnMap;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -756,8 +768,21 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SmartDataTask smartDataTask_return = (SmartDataTask) tmp_map.get("msg");
|
|
SmartDataTask smartDataTask_return = (SmartDataTask) tmp_map.get("msg");
|
|
|
-
|
|
|
|
|
- return QuartzJobUtils.resumeScheduleJob(scheduler, smartDataTask_return.getTkName());
|
|
|
|
|
|
|
+ Map<String, Object> returnMap = QuartzJobUtils.resumeScheduleJob(scheduler, smartDataTask_return.getTkName());
|
|
|
|
|
+ if ("0".equals(returnMap.get("code"))) {
|
|
|
|
|
+ smartDataTask.setTkId(smartDataTask_return.getTkId());
|
|
|
|
|
+ smartDataTask.setTkActivation(1);
|
|
|
|
|
+ Map<String, Object> stringStringMap = updateSmartDataTaskActivation(smartDataTask);
|
|
|
|
|
+ String msg;
|
|
|
|
|
+ if ("0".equals(stringStringMap.get("code"))) {
|
|
|
|
|
+ msg = (String) returnMap.get("msg") + stringStringMap.get("msg");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msg = (String) returnMap.get("msg") + stringStringMap.get("msg");
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonUtil.getReturnMap("0", msg);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return returnMap;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -929,6 +954,32 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
return getTablesOrViews(json, sql);
|
|
return getTablesOrViews(json, sql);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, Object> deleteSmartDataTaskErrByIds(JSONObject requestData) {
|
|
|
|
|
+ if (requestData.containsKey("ids")) {
|
|
|
|
|
+ // tkId 存在
|
|
|
|
|
+ String ids = requestData.getString("ids");
|
|
|
|
|
+ if (ids.equals("")) {
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "参数ids不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String[] idsArr = ids.split(",");
|
|
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
|
|
+ for (String id : idsArr) {
|
|
|
|
|
+ idList.add(Long.parseLong(id));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int rowCount = smartDataTaskMapper.deleteSmartDataTaskErrByIds(idList);
|
|
|
|
|
+ if (rowCount > 0) {
|
|
|
|
|
+ return CommonUtil.getReturnMap("0", "删除成功,共删除 " + rowCount + " 条数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "删除失败,共删除 " + rowCount + " 条数据");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // tkId 不存在
|
|
|
|
|
+ return CommonUtil.getReturnMap("1", "请传参数ids");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 获取表或视图信息
|
|
// 获取表或视图信息
|
|
|
private Map<String, Object> getTablesOrViews(String json, String sql) {
|
|
private Map<String, Object> getTablesOrViews(String json, String sql) {
|
|
|
// 判断json是否为空
|
|
// 判断json是否为空
|