定时任务操作日志提交
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.test.test.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.test.common.annotation.Excel;
|
||||
import com.test.common.core.domain.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 自动化测试任务日志对象 test_task_log
|
||||
*
|
||||
* @author test
|
||||
* @date 2025-02-25
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class TestTaskLog extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 日志id */
|
||||
private Long id;
|
||||
|
||||
/** 任务id */
|
||||
@Excel(name = "任务id")
|
||||
private Long taskId;
|
||||
|
||||
/** 操作类别 */
|
||||
@Excel(name = "操作类别")
|
||||
private String operType;
|
||||
|
||||
/** 操作详情 */
|
||||
@Excel(name = "操作详情")
|
||||
private String operDetail;
|
||||
|
||||
/** 操作人员 */
|
||||
@Excel(name = "操作人员")
|
||||
private String operUser;
|
||||
|
||||
/** 操作时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date operTime;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.test.test.mapper;
|
||||
|
||||
import com.test.test.domain.TestTaskLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动化测试日志Mapper接口
|
||||
*
|
||||
* @author test
|
||||
* @date 2025-02-25
|
||||
*/
|
||||
public interface TestTaskLogMapper
|
||||
{
|
||||
/**
|
||||
* 查询自动化测试日志
|
||||
*
|
||||
* @param id 自动化测试日志主键
|
||||
* @return 自动化测试日志
|
||||
*/
|
||||
public TestTaskLog selectTestTaskLogById(Long id);
|
||||
|
||||
/**
|
||||
* 查询自动化测试日志列表
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 自动化测试日志集合
|
||||
*/
|
||||
public List<TestTaskLog> selectTestTaskLogList(TestTaskLog testTaskLog);
|
||||
|
||||
/**
|
||||
* 新增自动化测试日志
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTestTaskLog(TestTaskLog testTaskLog);
|
||||
|
||||
/**
|
||||
* 修改自动化测试日志
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTestTaskLog(TestTaskLog testTaskLog);
|
||||
|
||||
/**
|
||||
* 删除自动化测试日志
|
||||
*
|
||||
* @param id 自动化测试日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestTaskLogById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除自动化测试日志
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestTaskLogByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.test.test.service;
|
||||
|
||||
import com.test.test.domain.TestTaskLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动化测试日志Service接口
|
||||
*
|
||||
* @author test
|
||||
* @date 2025-02-25
|
||||
*/
|
||||
public interface ITestTaskLogService
|
||||
{
|
||||
/**
|
||||
* 查询自动化测试日志
|
||||
*
|
||||
* @param id 自动化测试日志主键
|
||||
* @return 自动化测试日志
|
||||
*/
|
||||
public TestTaskLog selectTestTaskLogById(Long id);
|
||||
|
||||
/**
|
||||
* 查询自动化测试日志列表
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 自动化测试日志集合
|
||||
*/
|
||||
public List<TestTaskLog> selectTestTaskLogList(TestTaskLog testTaskLog);
|
||||
|
||||
/**
|
||||
* 新增自动化测试日志
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTestTaskLog(TestTaskLog testTaskLog);
|
||||
|
||||
/**
|
||||
* 修改自动化测试日志
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTestTaskLog(TestTaskLog testTaskLog);
|
||||
|
||||
/**
|
||||
* 批量删除自动化测试日志
|
||||
*
|
||||
* @param ids 需要删除的自动化测试日志主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestTaskLogByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除自动化测试日志信息
|
||||
*
|
||||
* @param id 自动化测试日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestTaskLogById(Long id);
|
||||
}
|
||||
@@ -45,7 +45,8 @@ public interface ITestTaskService {
|
||||
* @param triggerType 触发方式:1-定时任务;2-手动
|
||||
* @param environment 环境
|
||||
* @param jmeterHomePath jmeter安装路径
|
||||
* @param operUser 操作人
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean executeTestTaskById(Long id, Integer triggerType, String environment, String jmeterHomePath);
|
||||
boolean executeTestTaskById(Long id, Integer triggerType, String environment, String jmeterHomePath, String operUser);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.test.test.service.impl;
|
||||
|
||||
import com.test.test.domain.TestTaskLog;
|
||||
import com.test.test.mapper.TestTaskLogMapper;
|
||||
import com.test.test.service.ITestTaskLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动化测试日志Service业务层处理
|
||||
*
|
||||
* @author test
|
||||
* @date 2025-02-25
|
||||
*/
|
||||
@Service
|
||||
public class TestTaskLogServiceImpl implements ITestTaskLogService
|
||||
{
|
||||
@Resource
|
||||
private TestTaskLogMapper testTaskLogMapper;
|
||||
|
||||
/**
|
||||
* 查询自动化测试日志
|
||||
*
|
||||
* @param id 自动化测试日志主键
|
||||
* @return 自动化测试日志
|
||||
*/
|
||||
@Override
|
||||
public TestTaskLog selectTestTaskLogById(Long id)
|
||||
{
|
||||
return testTaskLogMapper.selectTestTaskLogById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自动化测试日志列表
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 自动化测试日志
|
||||
*/
|
||||
@Override
|
||||
public List<TestTaskLog> selectTestTaskLogList(TestTaskLog testTaskLog)
|
||||
{
|
||||
return testTaskLogMapper.selectTestTaskLogList(testTaskLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增自动化测试日志
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertTestTaskLog(TestTaskLog testTaskLog)
|
||||
{
|
||||
return testTaskLogMapper.insertTestTaskLog(testTaskLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改自动化测试日志
|
||||
*
|
||||
* @param testTaskLog 自动化测试日志
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTestTaskLog(TestTaskLog testTaskLog)
|
||||
{
|
||||
return testTaskLogMapper.updateTestTaskLog(testTaskLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除自动化测试日志
|
||||
*
|
||||
* @param ids 需要删除的自动化测试日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTestTaskLogByIds(Long[] ids)
|
||||
{
|
||||
return testTaskLogMapper.deleteTestTaskLogByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自动化测试日志信息
|
||||
*
|
||||
* @param id 自动化测试日志主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTestTaskLogById(Long id)
|
||||
{
|
||||
return testTaskLogMapper.deleteTestTaskLogById(id);
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,7 @@ package com.test.test.service.impl;
|
||||
import com.test.common.utils.DateUtils;
|
||||
import com.test.test.domain.*;
|
||||
import com.test.test.domain.qo.GroupIdQO;
|
||||
import com.test.test.mapper.TestCaseMapper;
|
||||
import com.test.test.mapper.TestCaseStepMapper;
|
||||
import com.test.test.mapper.TestTaskCaseMapper;
|
||||
import com.test.test.mapper.TestTaskMapper;
|
||||
import com.test.test.mapper.*;
|
||||
import com.test.test.service.ITestTaskService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -35,6 +32,9 @@ public class TestTaskServiceImpl implements ITestTaskService {
|
||||
@Resource
|
||||
private TestCaseStepMapper testCaseStepMapper;
|
||||
|
||||
@Resource
|
||||
private TestTaskLogMapper testTaskLogMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskManagerService taskManagerService;
|
||||
|
||||
@@ -93,16 +93,24 @@ public class TestTaskServiceImpl implements ITestTaskService {
|
||||
* @param triggerType 触发方式:1-定时任务;2-手动
|
||||
* @param environment 环境
|
||||
* @param jmeterHomePath jmeter安装路径
|
||||
* @param operUser 操作人
|
||||
* @return 是否执行完成(注:是否成功得看任务结果表)
|
||||
*/
|
||||
@Override
|
||||
public boolean executeTestTaskById(Long id, Integer triggerType, String environment, String jmeterHomePath) {
|
||||
public boolean executeTestTaskById(Long id, Integer triggerType, String environment, String jmeterHomePath, String operUser) {
|
||||
TestTask testTask = this.selectTestTaskById(id);
|
||||
if (testTask == null || testTask.getStatus() == null
|
||||
|| testTask.getStatus() > 0 || "2".equals(testTask.getDelFlag())) {
|
||||
log.error("定时任务已删除或未启用,不能执行!");
|
||||
return false;
|
||||
}
|
||||
TestTaskLog testTaskLog = new TestTaskLog();
|
||||
testTaskLog.setTaskId(id);
|
||||
testTaskLog.setOperType("执行");
|
||||
testTaskLog.setOperDetail("操作人:" + operUser + "提交执行了【" + testTask.getName() + "】定时任务测试用例");
|
||||
testTaskLog.setOperUser(operUser);
|
||||
testTaskLog.setOperTime(DateUtils.getNowDate());
|
||||
testTaskLogMapper.insertTestTaskLog(testTaskLog);
|
||||
TestTaskResult testTaskResult = new TestTaskResult();
|
||||
testTaskResult.setTaskId(id);
|
||||
testTaskResult.setTriggerTime(DateUtils.getNowDate());
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.test.test.mapper.TestTaskLogMapper">
|
||||
|
||||
<resultMap type="TestTaskLog" id="TestTaskLogResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="operType" column="oper_type" />
|
||||
<result property="operDetail" column="oper_detail" />
|
||||
<result property="operUser" column="oper_user" />
|
||||
<result property="operTime" column="oper_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTestTaskLogVo">
|
||||
select id, task_id, oper_type, oper_detail, oper_user, oper_time from test_task_log
|
||||
</sql>
|
||||
|
||||
<select id="selectTestTaskLogList" parameterType="TestTaskLog" resultMap="TestTaskLogResult">
|
||||
<include refid="selectTestTaskLogVo"/>
|
||||
<where>
|
||||
<if test="taskId != null "> and task_id = #{taskId}</if>
|
||||
<if test="operType != null and operType != ''"> and oper_type = #{operType}</if>
|
||||
<if test="operDetail != null and operDetail != ''"> and oper_detail = #{operDetail}</if>
|
||||
<if test="operUser != null and operUser != ''"> and oper_user = #{operUser}</if>
|
||||
<if test="operTime != null "> and oper_time = #{operTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTestTaskLogById" parameterType="Long" resultMap="TestTaskLogResult">
|
||||
<include refid="selectTestTaskLogVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertTestTaskLog" parameterType="TestTaskLog" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into test_task_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id,</if>
|
||||
<if test="operType != null">oper_type,</if>
|
||||
<if test="operDetail != null">oper_detail,</if>
|
||||
<if test="operUser != null">oper_user,</if>
|
||||
<if test="operTime != null">oper_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">#{taskId},</if>
|
||||
<if test="operType != null">#{operType},</if>
|
||||
<if test="operDetail != null">#{operDetail},</if>
|
||||
<if test="operUser != null">#{operUser},</if>
|
||||
<if test="operTime != null">#{operTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateTestTaskLog" parameterType="TestTaskLog">
|
||||
update test_task_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id = #{taskId},</if>
|
||||
<if test="operType != null">oper_type = #{operType},</if>
|
||||
<if test="operDetail != null">oper_detail = #{operDetail},</if>
|
||||
<if test="operUser != null">oper_user = #{operUser},</if>
|
||||
<if test="operTime != null">oper_time = #{operTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTestTaskLogById" parameterType="Long">
|
||||
delete from test_task_log where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTestTaskLogByIds" parameterType="String">
|
||||
delete from test_task_log where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user