Kaynağa Gözat

日志完成,任务优化

soft5566 2 yıl önce
ebeveyn
işleme
a8a1c3cafb

+ 19 - 8
src/main/java/com/template/api/SmartDataTaskControllerAPI.java

@@ -2,7 +2,6 @@ package com.template.api;
 
 
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONObject;
 import com.template.model.pojo.SmartDataTask;
 import com.template.model.pojo.SmartDataTask;
-import com.template.model.pojo.SmartDataTaskErr;
 import com.template.model.result.CommonResult;
 import com.template.model.result.CommonResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
@@ -10,7 +9,6 @@ import org.springframework.validation.BindingResult;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
-import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 
 /**
 /**
@@ -102,14 +100,27 @@ public interface SmartDataTaskControllerAPI {
     @ApiOperation(value = "根据ID删除数据源任务数据", notes = "根据ID删除数据源任务数据", httpMethod = "GET")
     @ApiOperation(value = "根据ID删除数据源任务数据", notes = "根据ID删除数据源任务数据", httpMethod = "GET")
     CommonResult deleteSmartDataTaskById(@RequestParam int id, @RequestParam int delMethod, HttpServletRequest httpServletRequest);
     CommonResult deleteSmartDataTaskById(@RequestParam int id, @RequestParam int delMethod, HttpServletRequest httpServletRequest);
 
 
-    @GetMapping(value = "/queryPageSmartDataTaskErr")
+    @GetMapping(value = "/queryPageSmartDataTaskDebug")
+    @ApiOperation(value = "任务debug日志记录分页数据", notes = "任务debug日志记录分页数据", httpMethod = "GET")
+    CommonResult queryPageSmartDataTaskDebug(@RequestParam int currentPage, @RequestParam int pageCount,
+                                             @RequestParam(required = false) Integer eTaskId,
+                                             @RequestParam(required = false) String startTime,
+                                             @RequestParam(required = false) String endTime);
+
+    @PostMapping(value = "/delSmartDataTaskDebugByIds")
+    @ApiOperation(value = "删除任务debug日志记录", notes = "删除任务debug日志记录", httpMethod = "POST")
+    CommonResult delSmartDataTaskDebugByIds(@Validated @RequestBody JSONObject json, HttpServletRequest httpServletRequest, BindingResult bindingResult);
+
+    @GetMapping(value = "/queryPageSmartDataTaskLog")
     @ApiOperation(value = "任务运行日志记录分页数据", notes = "任务运行日志记录分页数据", httpMethod = "GET")
     @ApiOperation(value = "任务运行日志记录分页数据", notes = "任务运行日志记录分页数据", httpMethod = "GET")
-    CommonResult queryPageSmartDataTaskErr(@RequestParam int currentPage, @RequestParam int pageCount,
+    CommonResult queryPageSmartDataTaskLog(@RequestParam int currentPage, @RequestParam int pageCount,
                                            @RequestParam(required = false) Integer eTaskId,
                                            @RequestParam(required = false) Integer eTaskId,
+                                           @RequestParam(required = false) String tkLogTaskName,
+                                           @RequestParam(required = false) Integer tkLogAutoManual,
+                                           @RequestParam(required = false) Integer tkLogDsSourceId,
+                                           @RequestParam(required = false) Integer tkLogDsDestinationId,
+                                           @RequestParam(required = false) Integer tkLogCostTime,
+                                           @RequestParam(required = false) Integer tkLogExeStatus,
                                            @RequestParam(required = false) String startTime,
                                            @RequestParam(required = false) String startTime,
                                            @RequestParam(required = false) String endTime);
                                            @RequestParam(required = false) String endTime);
-
-    @PostMapping(value = "/delSmartDataTaskErrByIds")
-    @ApiOperation(value = "删除任务运行日志记录", notes = "删除任务运行日志记录", httpMethod = "POST")
-    CommonResult delSmartDataTaskErrByIds(@Validated @RequestBody JSONObject json, HttpServletRequest httpServletRequest, BindingResult bindingResult);
 }
 }

+ 8 - 9
src/main/java/com/template/common/utils/QuartzJobUtils.java

@@ -17,12 +17,11 @@ public class QuartzJobUtils {
      * 创建定时任务
      * 创建定时任务
      *
      *
      * @param scheduler     调度器
      * @param scheduler     调度器
-     * @param smartDataTask 定时任务信息类
+     * @param smartDataTask_return 定时任务信息类
      */
      */
-    public static Map<String, Object> createScheduleJob(Scheduler scheduler,
-                                                        SmartDataTask smartDataTask) {
+    public static Map<String, Object> createScheduleJob(Scheduler scheduler, SmartDataTask smartDataTask_return) {
         // 判断是否存在该任务,存在则不创建任务,直接返回信息提示
         // 判断是否存在该任务,存在则不创建任务,直接返回信息提示
-        Map<String, Object> exists = exists(scheduler, smartDataTask.getTkName());
+        Map<String, Object> exists = exists(scheduler, smartDataTask_return.getTkName());
         if ("0".equals(exists.get("code"))) {
         if ("0".equals(exists.get("code"))) {
             return exists;
             return exists;
         }
         }
@@ -31,29 +30,29 @@ public class QuartzJobUtils {
             Class<? extends Job> jobClass = (Class<? extends Job>) Class.forName(JobClass);
             Class<? extends Job> jobClass = (Class<? extends Job>) Class.forName(JobClass);
             // 构建定时任务信息
             // 构建定时任务信息
             JobDetail jobDetail = JobBuilder.newJob(jobClass)
             JobDetail jobDetail = JobBuilder.newJob(jobClass)
-                    .withIdentity(smartDataTask.getTkName())
+                    .withIdentity(smartDataTask_return.getTkName())
                     .build();
                     .build();
 
 
             // 创建一个JobDataMap对象,并设置参数
             // 创建一个JobDataMap对象,并设置参数
             JobDataMap jobDataMap = new JobDataMap();
             JobDataMap jobDataMap = new JobDataMap();
 
 
             // 任务参数
             // 任务参数
-            jobDataMap.put("smartDataTask", smartDataTask);
+            jobDataMap.put("smartDataTask", smartDataTask_return);
 
 
             // 将JobDataMap对象与JobDetail关联
             // 将JobDataMap对象与JobDetail关联
             jobDetail.getJobDataMap().putAll(jobDataMap);
             jobDetail.getJobDataMap().putAll(jobDataMap);
 
 
             // 设置定时任务的执行方式
             // 设置定时任务的执行方式
-            CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(smartDataTask.getTkCron());
+            CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(smartDataTask_return.getTkCron());
             // 构建触发器
             // 构建触发器
             CronTrigger cronTrigger = TriggerBuilder.newTrigger()
             CronTrigger cronTrigger = TriggerBuilder.newTrigger()
-                    .withIdentity(smartDataTask.getTkName())
+                    .withIdentity(smartDataTask_return.getTkName())
                     .withSchedule(cronScheduleBuilder)
                     .withSchedule(cronScheduleBuilder)
                     .build();
                     .build();
             // 把触发器与任务进行绑定
             // 把触发器与任务进行绑定
             scheduler.scheduleJob(jobDetail, cronTrigger);
             scheduler.scheduleJob(jobDetail, cronTrigger);
 
 
-            return CommonUtil.getReturnMap(String.valueOf(0), "定时任务【" + smartDataTask.getTkName() + "】创建成功!");
+            return CommonUtil.getReturnMap(String.valueOf(0), "定时任务【" + smartDataTask_return.getTkName() + "】创建成功!");
         } catch (ClassNotFoundException e) {
         } catch (ClassNotFoundException e) {
             return CommonUtil.getReturnMap(String.valueOf(1), "找不到定时任务类!");
             return CommonUtil.getReturnMap(String.valueOf(1), "找不到定时任务类!");
         } catch (SchedulerException e) {
         } catch (SchedulerException e) {

+ 3 - 2
src/main/java/com/template/controller/SmartDataClassController.java

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.net.InetAddress;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.net.UnknownHostException;
+import java.util.Map;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -153,7 +154,7 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
         SmartDataClass data = smartDataClassService.getSmartById(id);
         SmartDataClass data = smartDataClassService.getSmartById(id);
 
 
         if (data == null) {
         if (data == null) {
-            return CommonResult.fail("当前数据不存在,删除失败!");
+            return CommonResult.fail("当前数据源类别不存在,删除失败!");
         }
         }
 
 
         // 检测当前类别下是否有数据源,有则不能删除,否则可以删除
         // 检测当前类别下是否有数据源,有则不能删除,否则可以删除
@@ -161,7 +162,7 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
         smartDataSourceQueryWrapper.eq("ds_cls_id", id);
         smartDataSourceQueryWrapper.eq("ds_cls_id", id);
         int count = smartDataSourceService.count(smartDataSourceQueryWrapper);
         int count = smartDataSourceService.count(smartDataSourceQueryWrapper);
         if (count > 0) {
         if (count > 0) {
-            return CommonResult.fail("当前类别下有数据,不能删除,删除失败!");
+            return CommonResult.fail("当前类别下有数据,不能删除,删除失败!");
         }
         }
 
 
         SmartDataSourceLog smartDataSourceLog =
         SmartDataSourceLog smartDataSourceLog =

+ 21 - 4
src/main/java/com/template/controller/SmartDataSourceController.java

@@ -1,16 +1,19 @@
 package com.template.controller;
 package com.template.controller;
 
 
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import com.template.api.SmartDataSourceControllerAPI;
 import com.template.api.SmartDataSourceControllerAPI;
 import com.template.common.utils.CommonUtil;
 import com.template.common.utils.CommonUtil;
 import com.template.common.utils.paramUtils;
 import com.template.common.utils.paramUtils;
 import com.template.model.pojo.SmartDataSource;
 import com.template.model.pojo.SmartDataSource;
 import com.template.model.pojo.SmartDataSourceLog;
 import com.template.model.pojo.SmartDataSourceLog;
+import com.template.model.pojo.SmartDataTask;
 import com.template.model.result.CommonResult;
 import com.template.model.result.CommonResult;
 import com.template.model.result.PageUtils;
 import com.template.model.result.PageUtils;
 import com.template.services.SmartDataSourceLogService;
 import com.template.services.SmartDataSourceLogService;
 import com.template.services.SmartDataSourceService;
 import com.template.services.SmartDataSourceService;
+import com.template.services.SmartDataTaskService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -35,10 +38,14 @@ public class SmartDataSourceController implements SmartDataSourceControllerAPI {
     private SmartDataSourceService smartDataSourceService;
     private SmartDataSourceService smartDataSourceService;
 
 
     @Autowired
     @Autowired
+    private SmartDataTaskService smartDataTaskService;
+
+    @Autowired
     private SmartDataSourceLogService smartDataSourceLogService;
     private SmartDataSourceLogService smartDataSourceLogService;
 
 
     /**
     /**
      * 新增数据源
      * 新增数据源
+     *
      * @param smartDataSource 数据源
      * @param smartDataSource 数据源
      * @param bindingResult
      * @param bindingResult
      * @return
      * @return
@@ -64,6 +71,7 @@ public class SmartDataSourceController implements SmartDataSourceControllerAPI {
 
 
     /**
     /**
      * 测试 数据源连接状态
      * 测试 数据源连接状态
+     *
      * @param smartDataSource
      * @param smartDataSource
      * @param bindingResult
      * @param bindingResult
      * @return
      * @return
@@ -82,6 +90,7 @@ public class SmartDataSourceController implements SmartDataSourceControllerAPI {
 
 
     /**
     /**
      * 更新数据源
      * 更新数据源
+     *
      * @param smartDataSource
      * @param smartDataSource
      * @param bindingResult
      * @param bindingResult
      * @return
      * @return
@@ -108,8 +117,9 @@ public class SmartDataSourceController implements SmartDataSourceControllerAPI {
 
 
     /**
     /**
      * 数据源分页数据查询
      * 数据源分页数据查询
-     * @param currentPage 当前页数
-     * @param pageCount 一页数据条数
+     *
+     * @param currentPage     当前页数
+     * @param pageCount       一页数据条数
      * @param smartDataSource 查询数据源实体
      * @param smartDataSource 查询数据源实体
      * @return
      * @return
      */
      */
@@ -126,10 +136,17 @@ public class SmartDataSourceController implements SmartDataSourceControllerAPI {
 
 
         SmartDataSource data = smartDataSourceService.getSmartById(id);
         SmartDataSource data = smartDataSourceService.getSmartById(id);
 
 
-        if(data == null){
-            return CommonResult.fail("当前数据不存在,删除失败!");
+        if (data == null) {
+            return CommonResult.fail("当前数据不存在,删除失败!");
         }
         }
 
 
+        // 检测当前类别下是否有数据源,有则不能删除,否则可以删除
+        QueryWrapper<SmartDataTask> smartDataTaskQueryWrapper = new QueryWrapper<>();
+        smartDataTaskQueryWrapper.eq("tk_ds_id_source", id).or().eq("tk_ds_id_destination", id);
+        int count = smartDataTaskService.count(smartDataTaskQueryWrapper);
+        if (count > 0) {
+            return CommonResult.fail("当前数据源下有任务,不能删除,删除失败!");
+        }
 
 
         SmartDataSourceLog smartDataSourceLog =
         SmartDataSourceLog smartDataSourceLog =
                 CommonUtil.generateLog("删除数据源|【数据交换中心】→【数据源管理】|删除【数据源】|delete", httpServletRequest);
                 CommonUtil.generateLog("删除数据源|【数据交换中心】→【数据源管理】|删除【数据源】|delete", httpServletRequest);

+ 24 - 6
src/main/java/com/template/controller/SmartDataTaskController.java

@@ -8,7 +8,8 @@ import com.template.common.utils.CommonUtil;
 import com.template.common.utils.paramUtils;
 import com.template.common.utils.paramUtils;
 import com.template.model.pojo.SmartDataSourceLog;
 import com.template.model.pojo.SmartDataSourceLog;
 import com.template.model.pojo.SmartDataTask;
 import com.template.model.pojo.SmartDataTask;
-import com.template.model.pojo.SmartDataTaskErr;
+import com.template.model.pojo.SmartDataTaskDebug;
+import com.template.model.pojo.SmartDataTaskLog;
 import com.template.model.result.CommonResult;
 import com.template.model.result.CommonResult;
 import com.template.model.result.PageUtils;
 import com.template.model.result.PageUtils;
 import com.template.services.SmartDataSourceLogService;
 import com.template.services.SmartDataSourceLogService;
@@ -18,7 +19,6 @@ import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
-import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -427,14 +427,22 @@ public class SmartDataTaskController implements SmartDataTaskControllerAPI {
      * @return 返回
      * @return 返回
      */
      */
     @Override
     @Override
-    public CommonResult queryPageSmartDataTaskErr(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime) {
-        PageInfo<SmartDataTaskErr> result = smartDataTaskService.queryPageSmartDataTaskErr(currentPage, pageCount, eTaskId, startTime, endTime);
+    public CommonResult queryPageSmartDataTaskDebug(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime) {
+        PageInfo<SmartDataTaskDebug> result = smartDataTaskService.queryPageSmartDataTaskDebug(currentPage, pageCount, eTaskId, startTime, endTime);
 
 
         return CommonResult.ok(result);
         return CommonResult.ok(result);
     }
     }
 
 
+    /**
+     * 删除任务运行日志
+     *
+     * @param json               json数据
+     * @param httpServletRequest 请求对象
+     * @param bindingResult      绑定对象
+     * @return 返回
+     */
     @Override
     @Override
-    public CommonResult delSmartDataTaskErrByIds(JSONObject json, HttpServletRequest httpServletRequest, BindingResult bindingResult) {
+    public CommonResult delSmartDataTaskDebugByIds(JSONObject json, HttpServletRequest httpServletRequest, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
         if (bindingResult.hasErrors()) {
             String st = paramUtils.getParamError(bindingResult);
             String st = paramUtils.getParamError(bindingResult);
             return CommonResult.fail(st);
             return CommonResult.fail(st);
@@ -442,7 +450,7 @@ public class SmartDataTaskController implements SmartDataTaskControllerAPI {
 
 
         SmartDataSourceLog smartDataSourceLog =
         SmartDataSourceLog smartDataSourceLog =
                 CommonUtil.generateLog("删除任务运行日志数据|【数据交换中心】→【任务运行日志】|删除【任务运行日志数据】|delete", httpServletRequest);
                 CommonUtil.generateLog("删除任务运行日志数据|【数据交换中心】→【任务运行日志】|删除【任务运行日志数据】|delete", httpServletRequest);
-        Map<String, Object> result = smartDataTaskService.deleteSmartDataTaskErrByIds(json);
+        Map<String, Object> result = smartDataTaskService.deleteSmartDataTaskDebugByIds(json);
         if (result.get("code") == "0") {
         if (result.get("code") == "0") {
             smartDataSourceLog.setLogActionStatus(1);
             smartDataSourceLog.setLogActionStatus(1);
             smartDataSourceLogService.insertSmartDataSourceLog(smartDataSourceLog);
             smartDataSourceLogService.insertSmartDataSourceLog(smartDataSourceLog);
@@ -451,5 +459,15 @@ public class SmartDataTaskController implements SmartDataTaskControllerAPI {
             return CommonResult.fail((String) result.get("msg"));
             return CommonResult.fail((String) result.get("msg"));
         }
         }
     }
     }
+
+    @Override
+    public CommonResult queryPageSmartDataTaskLog(int currentPage, int pageCount, Integer eTaskId, String tkLogTaskName, Integer tkLogAutoManual,
+                                                  Integer tkLogDsSourceId, Integer tkLogDsDestinationId,
+                                                  Integer tkLogCostTime, Integer tkLogExeStatus, String startTime, String endTime) {
+        PageInfo<SmartDataTaskLog> result = smartDataTaskService.queryPageSmartDataTaskLog(currentPage, pageCount, eTaskId, tkLogTaskName,
+                tkLogAutoManual, tkLogDsSourceId, tkLogDsDestinationId, tkLogCostTime, tkLogExeStatus, startTime, endTime);
+
+        return CommonResult.ok(result);
+    }
 }
 }
 
 

Dosya farkı çok büyük olduğundan ihmal edildi
+ 455 - 530
src/main/java/com/template/controller/Task.java


+ 9 - 0
src/main/java/com/template/mapper/SmartDataClassMapper.java

@@ -2,6 +2,8 @@ package com.template.mapper;
 
 
 import com.template.model.pojo.SmartDataClass;
 import com.template.model.pojo.SmartDataClass;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.template.model.pojo.SmartDataSource;
+import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
 /**
 /**
@@ -15,4 +17,11 @@ import org.springframework.stereotype.Repository;
 @Repository
 @Repository
 public interface SmartDataClassMapper extends BaseMapper<SmartDataClass> {
 public interface SmartDataClassMapper extends BaseMapper<SmartDataClass> {
 
 
+    @Select(" SELECT " +
+            "    COUNT(*) " +
+            " FROM " +
+            "    smart_data_source " +
+            " WHERE " +
+            "    ds_cls_id = #{id}")
+    int checkDataSourceExist(int id);
 }
 }

+ 11 - 0
src/main/java/com/template/mapper/SmartDataSourceMapper.java

@@ -3,6 +3,7 @@ package com.template.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.template.model.pojo.SmartDataSource;
 import com.template.model.pojo.SmartDataSource;
 import com.template.model.pojo.SmartDataSourceJobParams;
 import com.template.model.pojo.SmartDataSourceJobParams;
+import com.template.model.pojo.SmartDataTask;
 import com.template.model.pojo.SmartDepartment;
 import com.template.model.pojo.SmartDepartment;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
@@ -65,4 +66,14 @@ public interface SmartDataSourceMapper extends BaseMapper<SmartDataSource> {
             "</script>"
             "</script>"
     })
     })
     List<SmartDataSource> selectPageDsSource(SmartDataSource smartDataSource);
     List<SmartDataSource> selectPageDsSource(SmartDataSource smartDataSource);
+
+    @Select(" SELECT " +
+            "    COUNT(*) " +
+            " FROM " +
+            "    smart_data_task " +
+            " WHERE " +
+            "    tk_ds_id_source = #{id} " +
+            " Or " +
+            "    tk_ds_id_destination = #{id} ")
+    int checkTaskExist(int id);
 }
 }

+ 163 - 15
src/main/java/com/template/mapper/SmartDataTaskMapper.java

@@ -2,7 +2,8 @@ package com.template.mapper;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.template.model.pojo.SmartDataTask;
 import com.template.model.pojo.SmartDataTask;
-import com.template.model.pojo.SmartDataTaskErr;
+import com.template.model.pojo.SmartDataTaskDebug;
+import com.template.model.pojo.SmartDataTaskLog;
 import org.apache.ibatis.annotations.*;
 import org.apache.ibatis.annotations.*;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
@@ -95,7 +96,7 @@ public interface SmartDataTaskMapper extends BaseMapper<SmartDataTask> {
             "</script>"
             "</script>"
     })
     })
     @Options(useGeneratedKeys = true, keyProperty = "tk_id")
     @Options(useGeneratedKeys = true, keyProperty = "tk_id")
-    int insert(SmartDataTask smartDataTask);
+    int insertOne(SmartDataTask smartDataTask);
 
 
     @Update("UPDATE smart_data_task " +
     @Update("UPDATE smart_data_task " +
             "   SET tk_col_relationship = #{colRelationship} " +
             "   SET tk_col_relationship = #{colRelationship} " +
@@ -195,44 +196,48 @@ public interface SmartDataTaskMapper extends BaseMapper<SmartDataTask> {
 
 
     @Insert({
     @Insert({
             "<script>",
             "<script>",
-            "INSERT INTO smart_data_task_err ",
+            "INSERT INTO smart_data_task_debug ",
             "   <trim prefix='(' suffix=')' suffixOverrides=','> ",
             "   <trim prefix='(' suffix=')' suffixOverrides=','> ",
             "       <if test='eTaskId != null'>e_task_id,</if> ",
             "       <if test='eTaskId != null'>e_task_id,</if> ",
+            "       <if test='eTaskName != null'>e_task_name,</if> ",
             "       <if test='eDateTime != null'>e_date_time,</if> ",
             "       <if test='eDateTime != null'>e_date_time,</if> ",
             "       <if test='eMsg != null'>e_msg,</if> ",
             "       <if test='eMsg != null'>e_msg,</if> ",
             "   </trim> ",
             "   </trim> ",
             "VALUES ",
             "VALUES ",
             "   <trim prefix='(' suffix=')' suffixOverrides=','>",
             "   <trim prefix='(' suffix=')' suffixOverrides=','>",
             "      <if test='eTaskId != null'>#{eTaskId},</if> ",
             "      <if test='eTaskId != null'>#{eTaskId},</if> ",
+            "      <if test='eTaskName != null'>#{eTaskName},</if> ",
             "      <if test='eDateTime != null'>#{eDateTime},</if> ",
             "      <if test='eDateTime != null'>#{eDateTime},</if> ",
             "      <if test='eMsg != null'>#{eMsg},</if> ",
             "      <if test='eMsg != null'>#{eMsg},</if> ",
             "   </trim>",
             "   </trim>",
             "</script>"
             "</script>"
     })
     })
-    int insertErrorMsg(SmartDataTaskErr smartDataTaskErr);
+    int insertErrorMsg(SmartDataTaskDebug smartDataTaskDebug);
 
 
     @Select({
     @Select({
             "<script>",
             "<script>",
             "   SELECT ",
             "   SELECT ",
             "      * ",
             "      * ",
-            "   FROM smart_data_task_err ",
+            "   FROM smart_data_task_debug ",
             "   <where>",
             "   <where>",
             "      <if test='eTaskId != null'>AND e_task_id = #{eTaskId}</if> ",
             "      <if test='eTaskId != null'>AND e_task_id = #{eTaskId}</if> ",
             "      <if test='eMsg != null'>AND e_msg = #{eMsg}</if> ",
             "      <if test='eMsg != null'>AND e_msg = #{eMsg}</if> ",
             "   </where>",
             "   </where>",
             "</script>"
             "</script>"
     })
     })
-    SmartDataTaskErr selectErrorMsg(SmartDataTaskErr smartDataTaskErr);
+    SmartDataTaskDebug selectErrorMsg(SmartDataTaskDebug smartDataTaskDebug);
 
 
-    @Update("UPDATE smart_data_task_err " +
-            "SET e_task_id = #{eTaskId} " +
+    @Update("UPDATE smart_data_task_debug " +
+            "SET " +
+            "    e_task_id = #{eTaskId} " +
+            "    ,e_task_name = #{eTaskName} " +
             "    ,e_msg = #{eMsg} " +
             "    ,e_msg = #{eMsg} " +
             "    ,e_num = e_num + 1 " +
             "    ,e_num = e_num + 1 " +
             "    ,e_date_time = #{eDateTime} " +
             "    ,e_date_time = #{eDateTime} " +
             "WHERE " +
             "WHERE " +
             "    e_id = #{eId} "
             "    e_id = #{eId} "
     )
     )
-    int updateErrorMsg(SmartDataTaskErr smartDataTaskErr);
+    int updateErrorMsg(SmartDataTaskDebug smartDataTaskErr);
 
 
     @Select({
     @Select({
             "<script>",
             "<script>",
@@ -249,10 +254,9 @@ public interface SmartDataTaskMapper extends BaseMapper<SmartDataTask> {
     @Select({
     @Select({
             "<script>",
             "<script>",
             "   SELECT ",
             "   SELECT ",
-            "      e_id, tk_name, e_msg, e_num, e_date_time, e_create_time ",
-            "   FROM smart_data_task_err e, smart_data_task t ",
+            "      e_id, e_task_id, e_task_name, e_msg, e_num, e_date_time, e_create_time ",
+            "   FROM smart_data_task_debug ",
             "   <where>",
             "   <where>",
-            "      e.e_task_id = t.tk_id ",
             "      <if test='eTaskId != null'>AND e_task_id = #{eTaskId}</if> ",
             "      <if test='eTaskId != null'>AND e_task_id = #{eTaskId}</if> ",
             "      <if test='startTime != null'>AND e_date_time &gt;= #{startTime}</if> ",
             "      <if test='startTime != null'>AND e_date_time &gt;= #{startTime}</if> ",
             "      <if test='endTime != null'>AND e_date_time &lt;= #{endTime}</if> ",
             "      <if test='endTime != null'>AND e_date_time &lt;= #{endTime}</if> ",
@@ -260,13 +264,157 @@ public interface SmartDataTaskMapper extends BaseMapper<SmartDataTask> {
             "   ORDER BY e_date_time DESC, e_id DESC ",
             "   ORDER BY e_date_time DESC, e_id DESC ",
             "</script>"
             "</script>"
     })
     })
-    List<SmartDataTaskErr> selectPageOrderByDatetimeDesc(Integer eTaskId, String startTime, String endTime);
+    List<SmartDataTaskDebug> selectTaskDebugPageOrderByDatetimeDesc(Integer eTaskId, String startTime, String endTime);
 
 
     @Delete({
     @Delete({
             "<script>",
             "<script>",
-            "DELETE FROM smart_data_task_err WHERE e_id IN ",
+            "   DELETE ",
+            "   FROM ",
+            "      smart_data_task_debug ",
+            "   WHERE ",
+            "      e_id IN ",
             "<foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach>",
             "<foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach>",
             "</script>"
             "</script>"
     })
     })
-    int deleteSmartDataTaskErrByIds(List<Long> ids);
+    int deleteSmartDataTaskDebugByIds(List<Long> ids);
+
+    @Insert({
+            "<script>",
+            "   INSERT INTO smart_data_task_log ",
+            "   <trim prefix='(' suffix=')' suffixOverrides=','>",
+            "      <if test='tkLogTaskId != null'>tk_log_task_id,</if>",
+            "      <if test='tkLogTaskName != null'>tk_log_task_name,</if>",
+            "      <if test='tkLogDtName != null'>tk_log_dt_name,</if>",
+            "      <if test='tkLogDsSourceId != null'>tk_log_ds_source_id,</if>",
+            "      <if test='tkLogDsSourceName != null'>tk_log_ds_source_name,</if>",
+            "      <if test='tkLogDsDestinationId != null'>tk_log_ds_destination_id,</if>",
+            "      <if test='tkLogDsDestinationName != null'>tk_log_ds_destination_name,</if>",
+            "      <if test='tkLogDestTable != null'>tk_log_dest_table,</if>",
+            "      <if test='tkLogExchangeServer != null'>tk_log_exchange_server,</if>",
+            "      <if test='tkLogExchangeType != null'>tk_log_exchange_type,</if>",
+            "      <if test='tkLogAutoManual != null'>tk_log_auto_manual,</if>",
+            "      <if test='tkLogExeType != null'>tk_log_exe_type,</if>",
+            "      <if test='tkLogExeStatus != null'>tk_log_exe_status,</if>",
+            "      <if test='tkLogStartTime != null'>tk_log_start_time,</if>",
+            "      <if test='tkLogEndTime != null'>tk_log_end_time,</if>",
+            "      <if test='tkLogCostTime != null'>tk_log_cost_time,</if>",
+            "      <if test='tkLogReadRows != null'>tk_log_read_rows,</if>",
+            "      <if test='tkLogInsertRows != null'>tk_log_insert_rows,</if>",
+            "      <if test='tkLogUpdateRows != null'>tk_log_update_rows,</if>",
+            "      <if test='tkLogErrRows != null'>tk_log_err_rows,</if>",
+            "      <if test='tkLogErrException != null'>tk_log_err_exception,</if>",
+            "   </trim>",
+            "VALUES",
+            "   <trim prefix='(' suffix=')' suffixOverrides=','>",
+            "      <if test='tkLogTaskId != null'>#{tkLogTaskId},</if>",
+            "      <if test='tkLogTaskName != null'>#{tkLogTaskName},</if>",
+            "      <if test='tkLogDtName != null'>#{tkLogDtName},</if>",
+            "      <if test='tkLogDsSourceId != null'>#{tkLogDsSourceId},</if>",
+            "      <if test='tkLogDsSourceName != null'>#{tkLogDsSourceName},</if>",
+            "      <if test='tkLogDsDestinationId != null'>#{tkLogDsDestinationId},</if>",
+            "      <if test='tkLogDsDestinationName != null'>#{tkLogDsDestinationName},</if>",
+            "      <if test='tkLogDestTable != null'>#{tkLogDestTable},</if>",
+            "      <if test='tkLogExchangeServer != null'>#{tkLogExchangeServer},</if>",
+            "      <if test='tkLogExchangeType != null'>#{tkLogExchangeType},</if>",
+            "      <if test='tkLogAutoManual != null'>#{tkLogAutoManual},</if>",
+            "      <if test='tkLogExeType != null'>#{tkLogExeType},</if>",
+            "      <if test='tkLogExeStatus != null'>#{tkLogExeStatus},</if>",
+            "      <if test='tkLogStartTime != null'>#{tkLogStartTime},</if>",
+            "      <if test='tkLogEndTime != null'>#{tkLogEndTime},</if>",
+            "      <if test='tkLogCostTime != null'>#{tkLogCostTime},</if>",
+            "      <if test='tkLogReadRows != null'>#{tkLogReadRows},</if>",
+            "      <if test='tkLogInsertRows != null'>#{tkLogInsertRows},</if>",
+            "      <if test='tkLogUpdateRows != null'>#{tkLogUpdateRows},</if>",
+            "      <if test='tkLogErrRows != null'>#{tkLogErrRows},</if>",
+            "      <if test='tkLogErrException != null'>#{tkLogErrException},</if>",
+            "   </trim>",
+            "</script>"
+    })
+    @Options(useGeneratedKeys = true, keyProperty = "tkLogId")
+    int insertTaskLog(SmartDataTaskLog smartDataTaskLog);
+
+    @Update({
+            "<script>",
+            "   UPDATE smart_data_task_log ",
+            "   SET",
+            "   <trim suffixOverrides=','>",
+            "      <if test='tkLogTaskId != null'>tk_log_task_id = #{tkLogTaskId},</if>",
+            "      <if test='tkLogTaskName != null'>tk_log_task_name = #{tkLogTaskName},</if>",
+            "      <if test='tkLogDtName != null'>tk_log_dt_name = #{tkLogDtName},</if>",
+            "      <if test='tkLogDsSourceName != null'>tk_log_ds_source_name = #{tkLogDsSourceName},</if>",
+            "      <if test='tkLogDsSourceId != null'>tk_log_ds_source_id = #{tkLogDsSourceId},</if>",
+            "      <if test='tkLogDsDestinationName != null'>tk_log_ds_destination_name = #{tkLogDsDestinationName},</if>",
+            "      <if test='tkLogDsDestinationId != null'>tk_log_ds_destination_id = #{tkLogDsDestinationId},</if>",
+            "      <if test='tkLogDestTable != null'>tk_log_dest_table = #{tkLogDestTable},</if>",
+            "      <if test='tkLogExchangeServer != null'>tk_log_exchange_server = #{tkLogExchangeServer},</if>",
+            "      <if test='tkLogExchangeType != null'>tk_log_exchange_type = #{tkLogExchangeType},</if>",
+            "      <if test='tkLogAutoManual != null'>tk_log_auto_manual = #{tkLogAutoManual},</if>",
+            "      <if test='tkLogExeType != null'>tk_log_exe_type = #{tkLogExeType},</if>",
+            "      <if test='tkLogExeStatus != null'>tk_log_exe_status = #{tkLogExeStatus},</if>",
+            "      <if test='tkLogStartTime != null'>tk_log_start_time = #{tkLogStartTime},</if>",
+            "      <if test='tkLogEndTime != null'>tk_log_end_time = #{tkLogEndTime},</if>",
+            "      <if test='tkLogCostTime != null'>tk_log_cost_time = #{tkLogCostTime},</if>",
+            "      <if test='tkLogReadRows != null'>tk_log_read_rows = #{tkLogReadRows},</if>",
+            "      <if test='tkLogInsertRows != null'>tk_log_insert_rows = #{tkLogInsertRows},</if>",
+            "      <if test='tkLogUpdateRows != null'>tk_log_update_rows = #{tkLogUpdateRows},</if>",
+            "      <if test='tkLogErrRows != null'>tk_log_err_rows = #{tkLogErrRows},</if>",
+            "      <if test='tkLogErrException != null'>tk_log_err_exception = #{tkLogErrException},</if>",
+            "   </trim>",
+            "   WHERE ",
+            "      tk_log_id = #{tkLogId} ",
+            "</script>"
+    })
+    int updateTaskLog(SmartDataTaskLog smartDataTaskLog);
+
+    @Select({
+            "<script>",
+            "   SELECT ",
+            "      * ",
+            "   FROM smart_data_task_log ",
+            "   <where>",
+            "      <if test='eTaskId != null'>AND tk_log_task_id = #{eTaskId}</if> ",
+            "      <if test='tkLogAutoManual != null'>AND tk_log_auto_manual = #{tkLogAutoManual}</if> ",
+            "      <if test='tkLogDsSourceId != null'>AND tk_log_ds_source_id = #{tkLogDsSourceId}</if> ",
+            "      <if test='tkLogDsDestinationId != null'>AND tk_log_ds_destination_id = #{tkLogDsDestinationId}</if> ",
+            "      <if test='tkLogCostTime != null'> ",
+            "         <if test='tkLogCostTime == 1'>AND tk_log_cost_time &lt; 60000</if> ",
+            "         <if test='tkLogCostTime == 2'>AND tk_log_cost_time BETWEEN 60000 AND 300000</if> ",
+            "         <if test='tkLogCostTime == 3'>AND tk_log_cost_time BETWEEN 300000 AND 600000</if> ",
+            "         <if test='tkLogCostTime == 4'>AND tk_log_cost_time BETWEEN 300000 AND 600000</if> ",
+            "         <if test='tkLogCostTime == 5'>AND tk_log_cost_time BETWEEN 600000 AND 1800000</if> ",
+            "         <if test='tkLogCostTime == 6'>AND tk_log_cost_time &gt; 1800000</if> ",
+            "      </if> ",
+            "      <if test='tkLogExeStatus != null'> ",
+            "         <if test='tkLogExeStatus == 1'>AND tk_log_exe_status = '执行中'</if> ",
+            "         <if test='tkLogExeStatus == 2'>AND tk_log_exe_status = '执行成功'</if> ",
+            "         <if test='tkLogExeStatus == 3'>AND tk_log_exe_status = '部分数据异常'</if> ",
+            "         <if test='tkLogExeStatus == 4'>AND tk_log_exe_status = '执行中断'</if> ",
+            "         <if test='tkLogExeStatus == 5'>AND tk_log_exe_status = '执行跳过'</if> ",
+            "         <if test='tkLogExeStatus == 6'>AND tk_log_exe_status = '执行失败'</if> ",
+            "      </if> ",
+            "      <if test='startTime != null'>AND tk_log_start_time &gt;= #{startTime}</if> ",
+            "      <if test='endTime != null'>AND tk_log_end_time &lt;= #{endTime}</if> ",
+            "   </where>",
+            "   ORDER BY tk_log_update_time DESC, tk_log_task_id DESC ",
+            "</script>"
+    })
+    List<SmartDataTaskLog> selectTaskLogPageOrderByDatetimeDesc(Integer eTaskId, String tkLogTaskName, Integer tkLogAutoManual,
+                                                                Integer tkLogDsSourceId, Integer tkLogDsDestinationId,
+                                                                Integer tkLogCostTime, Integer tkLogExeStatus,
+                                                                String startTime, String endTime);
+
+    @Select({
+            "<script>",
+            "   SELECT ",
+            "      * ",
+            "   FROM smart_data_task_log ",
+            "   <where>",
+            "      <if test='tkLogTaskId != null'>AND tk_log_task_id = #{tkLogTaskId}</if> ",
+            "      <if test='tkLogExeStatus != null'> ",
+            "         <if test='tkLogExeStatus == 1'>AND tk_log_exe_status = '执行中'</if> ",
+            "      </if> ",
+            "   </where>",
+            "</script>"
+    })
+    List<SmartDataTaskLog> queryTaskExecuting(Integer tkLogTaskId, Integer tkLogExeStatus);
 }
 }

+ 2 - 2
src/main/java/com/template/model/pojo/SmartDataSourceJobParams.java

@@ -27,6 +27,8 @@ public class SmartDataSourceJobParams {
 
 
     private String dsUser;
     private String dsUser;
 
 
+    private String dsPassword;
+
     private Integer exchangeType;
     private Integer exchangeType;
 
 
     private String sourceSql;
     private String sourceSql;
@@ -35,8 +37,6 @@ public class SmartDataSourceJobParams {
 
 
     private String colRelationship;
     private String colRelationship;
 
 
-    private String dsPassword;
-
     private Integer dsStatus;
     private Integer dsStatus;
 
 
     private String dsDescrition;
     private String dsDescrition;

+ 5 - 2
src/main/java/com/template/model/pojo/SmartDataTask.java

@@ -56,8 +56,8 @@ public class SmartDataTask implements Serializable {
     @ApiModelProperty(value = "目标数据表")
     @ApiModelProperty(value = "目标数据表")
     private String tkDestTable;
     private String tkDestTable;
 
 
-    @ApiModelProperty(value = "交换服务器:0自动,1手动")
-    private Integer tkExchangeServer;
+    @ApiModelProperty(value = "交换服务器")
+    private String tkExchangeServer;
 
 
     @ApiModelProperty(value = "交换服务器id")
     @ApiModelProperty(value = "交换服务器id")
     private Integer tkExchangeServerId;
     private Integer tkExchangeServerId;
@@ -108,6 +108,9 @@ public class SmartDataTask implements Serializable {
     @ApiModelProperty(value = "下次执行时间")
     @ApiModelProperty(value = "下次执行时间")
     private String tkNextExeTime;
     private String tkNextExeTime;
 
 
+    @ApiModelProperty(value = "调试SQL语句")
+    private Integer tkDebugSql;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @ApiModelProperty(value = "创建时间")
     @ApiModelProperty(value = "创建时间")
     private Date tkCreateTime;
     private Date tkCreateTime;

+ 5 - 2
src/main/java/com/template/model/pojo/SmartDataTaskErr.java

@@ -23,8 +23,8 @@ import java.util.Date;
 @Data
 @Data
 @EqualsAndHashCode(callSuper = false)
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @Accessors(chain = true)
-@ApiModel(value="SmartDataTaskErr对象", description="数据源任务错误管理")
-public class SmartDataTaskErr implements Serializable {
+@ApiModel(value="SmartDataTaskDebug对象", description="数据源任务调试")
+public class SmartDataTaskDebug implements Serializable {
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
@@ -35,6 +35,9 @@ public class SmartDataTaskErr implements Serializable {
     @ApiModelProperty(value = "出错的任务id")
     @ApiModelProperty(value = "出错的任务id")
     private Integer eTaskId;
     private Integer eTaskId;
 
 
+    @ApiModelProperty(value = "出错的任务名称")
+    private String eTaskName;
+
     @ApiModelProperty(value = "错误文本")
     @ApiModelProperty(value = "错误文本")
     private String eMsg;
     private String eMsg;
 
 

+ 108 - 0
src/main/java/com/template/model/pojo/SmartDataTaskLog.java

@@ -0,0 +1,108 @@
+package com.template.model.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 数据源操作日志
+ * </p>
+ *
+ * @author ceshi
+ * @since 2023-12-05
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="SmartDataTaskLog对象", description="数据源任务日志")
+public class SmartDataTaskLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "任务日志id")
+    @TableId(value = "tk_log_id", type = IdType.AUTO)
+    private Integer tkLogId;
+
+    @ApiModelProperty(value = "任务id")
+    private Integer tkLogTaskId;
+
+    @ApiModelProperty(value = "任务名称")
+    private String tkLogTaskName;
+
+    @ApiModelProperty(value = "部门名称")
+    private String tkLogDtName;
+
+    @ApiModelProperty(value = "来源库id")
+    private Integer tkLogDsSourceId;
+
+    @ApiModelProperty(value = "来源库")
+    private String tkLogDsSourceName;
+
+    @ApiModelProperty(value = "目标库id")
+    private Integer tkLogDsDestinationId;
+
+    @ApiModelProperty(value = "目标库")
+    private String tkLogDsDestinationName;
+
+    @ApiModelProperty(value = "目标表")
+    private String tkLogDestTable;
+
+    @ApiModelProperty(value = "交换服务器")
+    private String tkLogExchangeServer;
+
+    @ApiModelProperty(value = "交换方式")
+    private String tkLogExchangeType;
+
+    @ApiModelProperty(value = "执行标识")
+    private String tkLogAutoManual;
+
+    @ApiModelProperty(value = "执行方式")
+    private String tkLogExeType;
+
+    @ApiModelProperty(value = "执行状态")
+    private String tkLogExeStatus;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "执行开始时间")
+    private String tkLogStartTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "执行结束时间")
+    private String tkLogEndTime;
+
+    @ApiModelProperty(value = "耗时")
+    private String tkLogCostTime;
+
+    @ApiModelProperty(value = "读取数据量")
+    private Integer tkLogReadRows;
+
+    @ApiModelProperty(value = "增加数据量")
+    private Integer tkLogInsertRows;
+
+    @ApiModelProperty(value = "更新数据量")
+    private Integer tkLogUpdateRows;
+
+    @ApiModelProperty(value = "错误数据量")
+    private Integer tkLogErrRows;
+
+    @ApiModelProperty(value = "异常")
+    private String tkLogErrException;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "创建时间")
+    private String tkLogCreateTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "更新时间")
+    private String tkLogUpdateTime;
+}

+ 3 - 2
src/main/java/com/template/services/SmartDataClassService.java

@@ -1,10 +1,11 @@
 package com.template.services;
 package com.template.services;
 
 
-import com.template.model.pojo.SmartDataClass;
-import com.template.model.pojo.SmartDataClass;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.template.model.pojo.SmartDataClass;
 import com.template.model.result.PageUtils;
 import com.template.model.result.PageUtils;
 
 
+import java.util.Map;
+
 /**
 /**
  * <p>
  * <p>
  * 数据源类别 服务类
  * 数据源类别 服务类

+ 8 - 4
src/main/java/com/template/services/SmartDataTaskService.java

@@ -4,10 +4,10 @@ import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import com.template.model.pojo.SmartDataTask;
 import com.template.model.pojo.SmartDataTask;
-import com.template.model.pojo.SmartDataTaskErr;
+import com.template.model.pojo.SmartDataTaskDebug;
+import com.template.model.pojo.SmartDataTaskLog;
 import com.template.model.result.PageUtils;
 import com.template.model.result.PageUtils;
 
 
-import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -36,7 +36,7 @@ public interface SmartDataTaskService extends IService<SmartDataTask> {
 
 
     Map<String, Object> deleteSmartDataTaskById(int id, int delMethod);
     Map<String, Object> deleteSmartDataTaskById(int id, int delMethod);
 
 
-    PageInfo<SmartDataTaskErr> queryPageSmartDataTaskErr(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime);
+    PageInfo<SmartDataTaskDebug> queryPageSmartDataTaskDebug(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime);
 
 
     SmartDataTask getSmartById(int id);
     SmartDataTask getSmartById(int id);
 
 
@@ -64,5 +64,9 @@ public interface SmartDataTaskService extends IService<SmartDataTask> {
 
 
     Map<String, Object> getViews(String json);
     Map<String, Object> getViews(String json);
 
 
-    Map<String, Object> deleteSmartDataTaskErrByIds(JSONObject json);
+    Map<String, Object> deleteSmartDataTaskDebugByIds(JSONObject json);
+
+    PageInfo<SmartDataTaskLog> queryPageSmartDataTaskLog(int currentPage, int pageCount, Integer eTaskId, String tkLogTaskName, Integer tkLogAutoManual,
+                                                         Integer tkLogDsSourceId, Integer tkLogDsDestinationId,
+                                                         Integer tkLogCostTime, Integer tkLogExeStatus, String startTime, String endTime);
 }
 }

+ 32 - 5
src/main/java/com/template/services/impl/SmartDataClassServiceImpl.java

@@ -3,10 +3,12 @@ package com.template.services.impl;
 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.template.common.utils.CommonUtil;
 import com.template.mapper.SmartDataClassMapper;
 import com.template.mapper.SmartDataClassMapper;
 import com.template.model.pojo.SmartDataClass;
 import com.template.model.pojo.SmartDataClass;
 import com.template.model.pojo.SmartDataClass;
 import com.template.model.pojo.SmartDataClass;
 import com.template.mapper.SmartDataClassMapper;
 import com.template.mapper.SmartDataClassMapper;
+import com.template.model.pojo.SmartDataSource;
 import com.template.model.result.PageUtils;
 import com.template.model.result.PageUtils;
 import com.template.services.SmartDataClassService;
 import com.template.services.SmartDataClassService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,6 +17,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
 import java.sql.SQLIntegrityConstraintViolationException;
 import java.sql.SQLIntegrityConstraintViolationException;
+import java.util.Map;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -29,32 +32,56 @@ public class SmartDataClassServiceImpl extends ServiceImpl<SmartDataClassMapper,
     @Autowired
     @Autowired
     private SmartDataClassMapper smartDataClassMapper;
     private SmartDataClassMapper smartDataClassMapper;
 
 
+    /**
+     * 插入数据源类别
+     *
+     * @param smartDataClass 数据源类别对象
+     * @return 返回
+     */
     @Override
     @Override
     public int insertSmartDataClass(SmartDataClass smartDataClass) {
     public int insertSmartDataClass(SmartDataClass smartDataClass) {
-        int result = smartDataClassMapper.insert(smartDataClass);
-        return result;
+        return smartDataClassMapper.insert(smartDataClass);
     }
     }
 
 
+    /**
+     * 更新数据源类别
+     *
+     * @param smartDataClass 数据源类别对象
+     * @return 返回
+     */
     @Override
     @Override
     public int updateSmartDataClass(SmartDataClass smartDataClass) {
     public int updateSmartDataClass(SmartDataClass smartDataClass) {
         int result = smartDataClassMapper.updateById(smartDataClass);
         int result = smartDataClassMapper.updateById(smartDataClass);
         return result;
         return result;
     }
     }
 
 
+    /**
+     * 数据源类别分页查询
+     *
+     * @param currentPage 当前页
+     * @param pageCount   每页显示数量
+     * @param name        数据源类别名称
+     * @return 返回
+     */
     @Override
     @Override
     public PageUtils<SmartDataClass> queryPageSmartDataClasss(int currentPage, int pageCount, String name) {
     public PageUtils<SmartDataClass> queryPageSmartDataClasss(int currentPage, int pageCount, String name) {
         Page<SmartDataClass> page = new Page<>(currentPage, pageCount);
         Page<SmartDataClass> page = new Page<>(currentPage, pageCount);
         QueryWrapper<SmartDataClass> queryWrapper = new QueryWrapper<>();
         QueryWrapper<SmartDataClass> queryWrapper = new QueryWrapper<>();
         queryWrapper.like(StringUtils.hasText(name), "ds_cls_name", name);
         queryWrapper.like(StringUtils.hasText(name), "ds_cls_name", name);
         queryWrapper.orderByDesc("ds_cls_update_time");
         queryWrapper.orderByDesc("ds_cls_update_time");
-        IPage<SmartDataClass> result = smartDataClassMapper.selectPage(page,queryWrapper);
+        IPage<SmartDataClass> result = smartDataClassMapper.selectPage(page, queryWrapper);
         return new PageUtils<>(result);
         return new PageUtils<>(result);
     }
     }
 
 
+    /**
+     * 删除数据源类别
+     *
+     * @param id 数据源类别id
+     * @return 返回
+     */
     @Override
     @Override
     public int deleteSmartDataClassById(int id) {
     public int deleteSmartDataClassById(int id) {
-        int result = smartDataClassMapper.deleteById(id);
-        return result;
+        return smartDataClassMapper.deleteById(id);
     }
     }
 
 
     @Override
     @Override

+ 9 - 9
src/main/java/com/template/services/impl/SmartDataSourceServiceImpl.java

@@ -1,8 +1,6 @@
 package com.template.services.impl;
 package com.template.services.impl;
 
 
 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.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.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
@@ -11,13 +9,11 @@ import com.template.mapper.SmartDataClassMapper;
 import com.template.mapper.SmartDataSourceMapper;
 import com.template.mapper.SmartDataSourceMapper;
 import com.template.model.pojo.SmartDataClass;
 import com.template.model.pojo.SmartDataClass;
 import com.template.model.pojo.SmartDataSource;
 import com.template.model.pojo.SmartDataSource;
-import com.template.model.pojo.SmartDataTaskErr;
-import com.template.model.result.PageUtils;
+import com.template.model.pojo.SmartDataTask;
 import com.template.services.SmartDataSourceService;
 import com.template.services.SmartDataSourceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.datasource.DriverManagerDataSource;
 import org.springframework.jdbc.datasource.DriverManagerDataSource;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
 
 
 import java.sql.Connection;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.SQLException;
@@ -191,16 +187,20 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
         return new PageInfo<>(result);
         return new PageInfo<>(result);
     }
     }
 
 
+    /**
+     * 根据id删除数据源
+     *
+     * @param id 数据源id
+     * @return 返回
+     */
     @Override
     @Override
     public int deleteSmartDataSourceById(int id) {
     public int deleteSmartDataSourceById(int id) {
-        int result = smartDataSourceMapper.deleteById(id);
-        return result;
+        return smartDataSourceMapper.deleteById(id);
     }
     }
 
 
     @Override
     @Override
     public SmartDataSource getSmartById(int id) {
     public SmartDataSource getSmartById(int id) {
-        SmartDataSource result = smartDataSourceMapper.selectById(id);
-        return result;
+        return smartDataSourceMapper.selectById(id);
     }
     }
 
 
     /**
     /**

+ 56 - 11
src/main/java/com/template/services/impl/SmartDataTaskServiceImpl.java

@@ -13,10 +13,7 @@ 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.SmartDataTaskErr;
-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;
@@ -116,7 +113,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
         if (smartDataTask.getTkExchangeServer() == null) {
         if (smartDataTask.getTkExchangeServer() == null) {
             return CommonUtil.getReturnMap("1", "【交换服务器】不能为空!");
             return CommonUtil.getReturnMap("1", "【交换服务器】不能为空!");
         }
         }
-        if (smartDataTask.getTkExchangeServer() == 1) {
+        if (smartDataTask.getTkExchangeServer().equals("")) {
             if (smartDataTask.getTkExchangeServerId() == null) {
             if (smartDataTask.getTkExchangeServerId() == null) {
                 return CommonUtil.getReturnMap("1", "【指定服务器id】不能为空!");
                 return CommonUtil.getReturnMap("1", "【指定服务器id】不能为空!");
             }
             }
@@ -181,7 +178,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
             return CommonUtil.getReturnMap("1", "有重复记录!");
             return CommonUtil.getReturnMap("1", "有重复记录!");
         }
         }
         // 插入记录,插入成功后获取记录的id返回
         // 插入记录,插入成功后获取记录的id返回
-        int result = smartDataTaskMapper.insert(smartDataTask);
+        int result = smartDataTaskMapper.insertOne(smartDataTask);
         if (result > 0) {
         if (result > 0) {
             // 获取数据源对应的表、视图、Sql对应的结构
             // 获取数据源对应的表、视图、Sql对应的结构
             return CommonUtil.getReturnMap("0", this.getMetaData(smartDataTask, dsSource, dsDestination, "添加"));
             return CommonUtil.getReturnMap("0", this.getMetaData(smartDataTask, dsSource, dsDestination, "添加"));
@@ -510,7 +507,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
         if (smartDataTask.getTkExchangeServer() == null) {
         if (smartDataTask.getTkExchangeServer() == null) {
             return CommonUtil.getReturnMap("1", "【交换服务器】不能为空!");
             return CommonUtil.getReturnMap("1", "【交换服务器】不能为空!");
         }
         }
-        if (smartDataTask.getTkExchangeServer() == 1) {
+        if (smartDataTask.getTkExchangeServer().equals("")) {
             if (smartDataTask.getTkExchangeServerId() == null) {
             if (smartDataTask.getTkExchangeServerId() == null) {
                 return CommonUtil.getReturnMap("1", "【指定服务器id】不能为空!");
                 return CommonUtil.getReturnMap("1", "【指定服务器id】不能为空!");
             }
             }
@@ -676,9 +673,9 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
     }
     }
 
 
     @Override
     @Override
-    public PageInfo<SmartDataTaskErr> queryPageSmartDataTaskErr(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime) {
+    public PageInfo<SmartDataTaskDebug> queryPageSmartDataTaskDebug(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime) {
         PageHelper.startPage(currentPage, pageCount);
         PageHelper.startPage(currentPage, pageCount);
-        List<SmartDataTaskErr> result = smartDataTaskMapper.selectPageOrderByDatetimeDesc(eTaskId, startTime, endTime);
+        List<SmartDataTaskDebug> result = smartDataTaskMapper.selectTaskDebugPageOrderByDatetimeDesc(eTaskId, startTime, endTime);
         return new PageInfo<>(result);
         return new PageInfo<>(result);
     }
     }
 
 
@@ -956,7 +953,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
     }
     }
 
 
     @Override
     @Override
-    public Map<String, Object> deleteSmartDataTaskErrByIds(JSONObject requestData) {
+    public Map<String, Object> deleteSmartDataTaskDebugByIds(JSONObject requestData) {
         if (requestData.containsKey("ids")) {
         if (requestData.containsKey("ids")) {
             // tkId 存在
             // tkId 存在
             String ids = requestData.getString("ids");
             String ids = requestData.getString("ids");
@@ -970,7 +967,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
                 idList.add(Long.parseLong(id));
                 idList.add(Long.parseLong(id));
             }
             }
 
 
-            int rowCount = smartDataTaskMapper.deleteSmartDataTaskErrByIds(idList);
+            int rowCount = smartDataTaskMapper.deleteSmartDataTaskDebugByIds(idList);
             if (rowCount > 0) {
             if (rowCount > 0) {
                 return CommonUtil.getReturnMap("0", "删除成功,共删除 " + rowCount + " 条数据");
                 return CommonUtil.getReturnMap("0", "删除成功,共删除 " + rowCount + " 条数据");
             }
             }
@@ -981,6 +978,54 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
         }
         }
     }
     }
 
 
+    @Override
+    public PageInfo<SmartDataTaskLog> queryPageSmartDataTaskLog(int currentPage, int pageCount, Integer eLogId, String tkLogTaskName, Integer tkLogAutoManual,
+                                                                Integer tkLogDsSourceId, Integer tkLogDsDestinationId,
+                                                                Integer tkLogCostTime, Integer tkLogExeStatus, String startTime, String endTime) {
+        PageHelper.startPage(currentPage, pageCount);
+        List<SmartDataTaskLog> result = smartDataTaskMapper.selectTaskLogPageOrderByDatetimeDesc(eLogId, tkLogTaskName,
+                tkLogAutoManual, tkLogDsSourceId, tkLogDsDestinationId, tkLogCostTime, tkLogExeStatus, startTime, endTime);
+        // 将耗时转成天时分秒毫秒
+        result.forEach(item -> item.setTkLogCostTime(this.convertMillisToDaysHoursMinutesSecondsMillis(Long.parseLong(item.getTkLogCostTime()))));
+        return new PageInfo<>(result);
+    }
+
+    // 计算任务执行的时间
+    private String convertMillisToDaysHoursMinutesSecondsMillis(long millis) {
+        long days = millis / (1000 * 60 * 60 * 24);
+        long hours = (millis % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
+        long minutes = ((millis % (1000 * 60 * 60)) / (1000 * 60)) % 60;
+        long seconds = (((millis % (1000 * 60 * 60)) % (1000 * 60)) / 1000) % 60;
+        long milliseconds = (((millis % (1000 * 60 * 60)) % (1000 * 60)) % 1000);
+
+        StringBuilder returnStr = new StringBuilder();
+        if (days > 0) {
+            returnStr.append(days).append("天");
+        }
+        if (hours > 0) {
+            returnStr.append(hours).append("小时");
+        }
+        if (minutes > 0) {
+            returnStr.append(minutes).append("分钟");
+        }
+        if (seconds > 0) {
+            returnStr.append(seconds).append("秒");
+        }
+        // 毫秒级也显示
+//        if (milliseconds > 0) {
+//            returnStr.append(milliseconds).append("毫秒");
+//        }
+        // 如果超过毫秒级,则不显示毫秒级,否则显示毫秒级。
+        if (returnStr.length() == 0) {
+            if (milliseconds > 0) {
+                returnStr.append(milliseconds).append("毫秒");
+            } else {
+                returnStr.append("执行时间未知");
+            }
+        }
+        return returnStr.toString();
+    }
+
     // 获取表或视图信息
     // 获取表或视图信息
     private Map<String, Object> getTablesOrViews(String json, String sql) {
     private Map<String, Object> getTablesOrViews(String json, String sql) {
         // 判断json是否为空
         // 判断json是否为空