|
|
@@ -14,6 +14,7 @@ import com.template.model.pojo.SmartDataTask;
|
|
|
import com.template.model.result.CommonResult;
|
|
|
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;
|
|
|
@@ -23,7 +24,12 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.format.DateTimeParseException;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -58,33 +64,68 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
return CommonUtil.getReturnMap("1", "任务名有重名!");
|
|
|
}
|
|
|
// 检测必要参数是否为null
|
|
|
- if (smartDataTask.getTkDsId() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【数据源id】不能为空!");
|
|
|
+ if (smartDataTask.getTkDsIdSource() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【来源数据源id】不能为空!");
|
|
|
}
|
|
|
- SmartDataSource smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsId());
|
|
|
+ SmartDataSource smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsIdSource());
|
|
|
if (smartDataSource == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "选择的【数据源】不存在!");
|
|
|
+ return CommonUtil.getReturnMap("1", "选择的【来源数据源】不存在!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkCron() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【定时表达式】不能为空!");
|
|
|
+ if (smartDataTask.getTkSyncPolicy() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【同步策略】不能为空!");
|
|
|
}
|
|
|
- if (CronExpression.isValidExpression(smartDataTask.getTkCron())) {
|
|
|
- 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) {
|
|
|
+ return CommonUtil.getReturnMap("1", "选择的【目标数据源】不存在!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkDestTable() == null) {
|
|
|
+ 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", "【任务描述】不能为空!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkActivation() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【是否启用】不能为空!");
|
|
|
- }
|
|
|
- queryWrapper.eq(smartDataTask.getTkDsId() != null, "tk_ds_id", smartDataTask.getTkDsId());
|
|
|
- queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkCron()), "tk_cron", smartDataTask.getTkCron());
|
|
|
+ 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());
|
|
|
+ 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.getTkActivation() != null, "tk_activation", smartDataTask.getTkActivation());
|
|
|
sdt = smartDataTaskMapper.selectOne(queryWrapper);
|
|
|
if (sdt != null) {
|
|
|
return CommonUtil.getReturnMap("1", "有重复记录!");
|
|
|
@@ -98,6 +139,117 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 生成cron表达式
|
|
|
+ private Map<String, Object> generateCron(Integer exeType, String repetTime) {
|
|
|
+ if (exeType == 0) {
|
|
|
+ if (repetTime.endsWith("天")) {
|
|
|
+ String n = CommonUtil.getNumberFromString(repetTime);
|
|
|
+ if (n != null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "0 0 0 1/" + n + " * ?");
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误,要求:x天");
|
|
|
+ }
|
|
|
+ } else if (repetTime.endsWith("小时")) {
|
|
|
+ String n = CommonUtil.getNumberFromString(repetTime);
|
|
|
+ if (n != null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "0 0 0/" + n + " * * ?");
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误,要求:x小时");
|
|
|
+ }
|
|
|
+ } else if (repetTime.endsWith("分钟")) {
|
|
|
+ String n = CommonUtil.getNumberFromString(repetTime);
|
|
|
+ if (n != null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "0 0/" + n + " * * * ?");
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误,要求:x分钟");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误,要求:x天 或者 x小时 或者 x分钟");
|
|
|
+ }
|
|
|
+ } else if (exeType == 1) {
|
|
|
+ // 检查是否是格式:2023-12-19 09:40
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+ try {
|
|
|
+ LocalDateTime dateTime = LocalDateTime.parse(repetTime, formatter);
|
|
|
+ int year = dateTime.getYear();
|
|
|
+ int month = dateTime.getMonthValue();
|
|
|
+ int day = dateTime.getDayOfMonth();
|
|
|
+ int hour = dateTime.getHour();
|
|
|
+ int minute = dateTime.getMinute();
|
|
|
+
|
|
|
+ return CommonUtil.getReturnMap("0", String.format("0 %d %d %d %d ? %d", minute, hour, day, month, year));
|
|
|
+ } catch (DateTimeParseException e) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误,要求:2023-12-19 09:40");
|
|
|
+ }
|
|
|
+ } else if (exeType == 2) {
|
|
|
+ // 检查是否是格式:09:40
|
|
|
+ if (isOnlyHourAndMinute(repetTime)) {
|
|
|
+ String[] split = repetTime.split(":");
|
|
|
+ int hour = Integer.parseInt(split[0]);
|
|
|
+ int minute = Integer.parseInt(split[1]);
|
|
|
+ return CommonUtil.getReturnMap("0", String.format("0 %d %d 1/1 * ?", minute, hour));
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误,要求:09:40");
|
|
|
+ }
|
|
|
+ } else if (exeType == 3) {
|
|
|
+ // 检查是否是格式:周日 09:40
|
|
|
+ String[] split = repetTime.split(" ");
|
|
|
+ if (split.length != 2) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误1,要求:周日 09:40");
|
|
|
+ }
|
|
|
+
|
|
|
+ String weekday = ""; // MON, TUE, WED, THU, FRI, SAT, SUN
|
|
|
+ if ("周一".equals(split[0])) weekday = "MON";
|
|
|
+ else if ("周二".equals(split[0])) weekday = "TUE";
|
|
|
+ else if ("周三".equals(split[0])) weekday = "WED";
|
|
|
+ else if ("周四".equals(split[0])) weekday = "THU";
|
|
|
+ else if ("周五".equals(split[0])) weekday = "FRI";
|
|
|
+ else if ("周六".equals(split[0])) weekday = "SAT";
|
|
|
+ else if ("周日".equals(split[0])) weekday = "SUN";
|
|
|
+ else CommonUtil.getReturnMap("1", "【重复时间】格式错误2,要求:周日 09:40");
|
|
|
+
|
|
|
+ if (isOnlyHourAndMinute(split[1])) {
|
|
|
+ String[] hour_minute = split[1].split(":");
|
|
|
+ int hour = Integer.parseInt(hour_minute[0]);
|
|
|
+ int minute = Integer.parseInt(hour_minute[1]);
|
|
|
+
|
|
|
+ return CommonUtil.getReturnMap("0", String.format("0 %d %d ? * %s", minute, hour, weekday));
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误3,要求:周日 09:40");
|
|
|
+ }
|
|
|
+ } else if (exeType == 4) {
|
|
|
+ // 检查是否是格式:19 09:40
|
|
|
+ String[] split = repetTime.split(" ");
|
|
|
+ if (split.length != 2) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误1,要求:19 09:40");
|
|
|
+ }
|
|
|
+
|
|
|
+ int day = Integer.parseInt(split[0]);
|
|
|
+ if (day > 30 || day < 1)
|
|
|
+ CommonUtil.getReturnMap("1", "【重复时间】格式错误2,要求:19 09:40");
|
|
|
+
|
|
|
+ if (isOnlyHourAndMinute(split[1])) {
|
|
|
+ String[] hour_minute = split[1].split(":");
|
|
|
+ int hour = Integer.parseInt(hour_minute[0]);
|
|
|
+ int minute = Integer.parseInt(hour_minute[1]);
|
|
|
+
|
|
|
+ return CommonUtil.getReturnMap("0", String.format("0 %d %d %d * ?", minute, hour, day));
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【重复时间】格式错误3,要求:19 09:40");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap("1", "【执行方式】格式错误,要求:0间隔执行,1定点执行,2每天,3每周,4每月");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断时分
|
|
|
+ private boolean isOnlyHourAndMinute(String time) {
|
|
|
+ String regex = "^([01]?[0-9]|2[0-3]):[0-5][0-9]$";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(time);
|
|
|
+ return matcher.matches();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> updateSmartDataTaskById(SmartDataTask smartDataTask) {
|
|
|
if (smartDataTask.getTkId() == null) {
|
|
|
@@ -115,36 +267,65 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
if (sdc == null) {
|
|
|
return CommonUtil.getReturnMap("1", "要修改的【任务】不存在!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkDsId() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【数据源id】不能为空!");
|
|
|
+ if (smartDataTask.getTkDsIdSource() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【来源数据源id】不能为空!");
|
|
|
}
|
|
|
- SmartDataSource smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsId());
|
|
|
+ SmartDataSource smartDataSource = smartDataSourceMapper.selectById(smartDataTask.getTkDsIdSource());
|
|
|
if (smartDataSource == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "选择的【数据源】不存在!");
|
|
|
+ return CommonUtil.getReturnMap("1", "选择的【来源数据源】不存在!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkCron() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【定时表达式】不能为空!");
|
|
|
+ if (smartDataTask.getTkSyncPolicy() == null) {
|
|
|
+ return CommonUtil.getReturnMap("1", "【同步策略】不能为空!");
|
|
|
}
|
|
|
- if (CronExpression.isValidExpression(smartDataTask.getTkCron())) {
|
|
|
- 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) {
|
|
|
+ return CommonUtil.getReturnMap("1", "选择的【目标数据源】不存在!");
|
|
|
+ }
|
|
|
+ if (smartDataTask.getTkDestTable() == null) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ smartDataTask.setTkCron((String) stringObjectMap.get("msg"));
|
|
|
+ } else {
|
|
|
+ smartDataTask.setTkExeType(0);
|
|
|
+ smartDataTask.setTkRepetTime("");
|
|
|
}
|
|
|
if (smartDataTask.getTkDescrition() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【任务描述】不能为空!");
|
|
|
}
|
|
|
- if (smartDataTask.getTkActivation() == null) {
|
|
|
- return CommonUtil.getReturnMap("1", "【是否启动】不能为空!");
|
|
|
- }
|
|
|
QueryWrapper<SmartDataTask> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq(smartDataTask.getTkId() != null, "tk_id", smartDataTask.getTkId());
|
|
|
- queryWrapper.eq(smartDataTask.getTkDsId() != null, "tk_ds_id", smartDataTask.getTkDsId());
|
|
|
queryWrapper.eq(smartDataTask.getTkName() != null, "tk_name", smartDataTask.getTkName());
|
|
|
- queryWrapper.eq(StringUtils.hasText(smartDataTask.getTkCron()), "tk_cron", smartDataTask.getTkCron());
|
|
|
+ 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());
|
|
|
+ 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.getTkActivation() != null, "tk_activation", smartDataTask.getTkActivation());
|
|
|
SmartDataTask sdt = smartDataTaskMapper.selectOne(queryWrapper);
|
|
|
if (sdt != null) {
|
|
|
return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
|
|
|
@@ -159,7 +340,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
|
|
|
|
// 判断之前状态是否启用
|
|
|
- private Map<String, Object> updateSmartDataTaskActivation(SmartDataTask smartDataTask) {
|
|
|
+ public Map<String, Object> updateSmartDataTaskActivation(SmartDataTask smartDataTask) {
|
|
|
// 检测参数,还有是否存在重复记录
|
|
|
if (smartDataTask.getTkId() == null) {
|
|
|
return CommonUtil.getReturnMap("1", "【任务id】不能为空!");
|
|
|
@@ -172,7 +353,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
return CommonUtil.getReturnMap("1", "【是否启用】不能为空!");
|
|
|
}
|
|
|
|
|
|
- int result = smartDataTaskMapper.updateById(smartDataTask);
|
|
|
+ int result = smartDataTaskMapper.markTaskById(smartDataTask);
|
|
|
if (result > 0) {
|
|
|
return CommonUtil.getReturnMap(String.valueOf(result), "标注成功!");
|
|
|
} else {
|
|
|
@@ -188,8 +369,12 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
public PageUtils<SmartDataTask> queryPageSmartDataTasks(int currentPage, int pageCount, SmartDataTask smartDataTask) {
|
|
|
Page<SmartDataTask> page = new Page<>(currentPage, pageCount);
|
|
|
QueryWrapper<SmartDataTask> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq(smartDataTask.getTkDsId() != null, "tk_ds_id", smartDataTask.getTkDsId());
|
|
|
queryWrapper.like(smartDataTask.getTkName() != null, "tk_name", smartDataTask.getTkName());
|
|
|
+ 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.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());
|
|
|
queryWrapper.eq(smartDataTask.getTkActivation() != null, "tk_activation", smartDataTask.getTkActivation());
|
|
|
queryWrapper.like(smartDataTask.getTkDescrition() != null, "tk_descrition", smartDataTask.getTkDescrition());
|
|
|
queryWrapper.orderByDesc("tk_update_time");
|
|
|
@@ -198,18 +383,16 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int deleteSmartDataTaskById(int id) {
|
|
|
- int result = smartDataTaskMapper.deleteById(id);
|
|
|
- return result;
|
|
|
+ public int deleteSmartDataTaskById(SmartDataTask smartDataTask) {
|
|
|
+ return smartDataTaskMapper.deleteMarkTaskById(smartDataTask);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SmartDataTask getSmartById(int id) {
|
|
|
- SmartDataTask result = smartDataTaskMapper.selectById(id);
|
|
|
- return result;
|
|
|
+ return smartDataTaskMapper.selectById(id);
|
|
|
}
|
|
|
|
|
|
- private Map<String, Object> TaskNameValidator(SmartDataTask smartDataTask) {
|
|
|
+ public Map<String, Object> TaskNameValidator(SmartDataTask smartDataTask) {
|
|
|
if (smartDataTask.getTkName() == null) {
|
|
|
return CommonUtil.getReturnMap(String.valueOf(1), "任务名称为空!");
|
|
|
}
|
|
|
@@ -234,6 +417,10 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
Map<String, Object> returnMap = QuartzJobUtils.createScheduleJob(scheduler, smartDataTask_return);
|
|
|
if ("0".equals(returnMap.get("code"))) {
|
|
|
smartDataTask.setTkId(smartDataTask_return.getTkId());
|
|
|
+ // 下次执行的时间
|
|
|
+ String nextExeTime = QuartzJobUtils.getNextExeTime(smartDataTask_return.getTkCron());
|
|
|
+ // 更新数据库中的下次执行时间
|
|
|
+ smartDataTask.setTkNextExeTime(nextExeTime);
|
|
|
smartDataTask.setTkActivation(1);
|
|
|
Map<String, Object> stringStringMap = updateSmartDataTaskActivation(smartDataTask);
|
|
|
String msg;
|
|
|
@@ -296,6 +483,8 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
|
|
|
Map<String, Object> returnMap = QuartzJobUtils.deleteScheduleJob(scheduler, smartDataTask_return.getTkName());
|
|
|
if ("0".equals(returnMap.get("code"))) {
|
|
|
smartDataTask.setTkId(smartDataTask_return.getTkId());
|
|
|
+ // 更新数据库中的下次执行时间
|
|
|
+ smartDataTask.setTkNextExeTime(null);
|
|
|
smartDataTask.setTkActivation(0);
|
|
|
Map<String, Object> stringStringMap = updateSmartDataTaskActivation(smartDataTask);
|
|
|
String msg;
|