fix(UI自动化): 修复开源版任务中心报错问题
This commit is contained in:
parent
b82adc2412
commit
9183fdcb08
|
@ -0,0 +1,8 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface BaseInformationSchemaTableMapper {
|
||||
|
||||
String checkExist(@Param("tableName") String tableName);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?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="io.metersphere.base.mapper.ext.BaseInformationSchemaTableMapper">
|
||||
<select id="checkExist" resultType="java.lang.String">
|
||||
select TABLE_NAME
|
||||
from information_schema.TABLES
|
||||
where TABLE_NAME = #{tableName}
|
||||
</select>
|
||||
</mapper>
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
|
||||
public interface BaseTaskMapper {
|
||||
|
||||
List<TaskCenterDTO> getTasks(@Param("request") TaskCenterRequest request);
|
||||
List<TaskCenterDTO> getTasks(@Param("request") TaskCenterRequest request, @Param("uiPermission") Boolean uiPermission);
|
||||
|
||||
int getRunningTasks(@Param("request") TaskCenterRequest request);
|
||||
|
||||
|
|
|
@ -87,27 +87,29 @@
|
|||
AND t.user_id = #{request.executor}
|
||||
</if>
|
||||
)
|
||||
UNION ALL
|
||||
(SELECT t.id,t.name AS name ,'UI_SCENARIO' AS
|
||||
executionModule,t.report_type, ifnull(t2.name,'LOCAL') AS actuator, t1.`name` AS executor,t.create_time AS
|
||||
executionTime, t.trigger_mode AS triggerMode ,t.status AS executionStatus
|
||||
FROM ui_scenario_report t INNER JOIN `user` t1 ON t.user_id = t1.id LEFT JOIN test_resource_pool t2 ON
|
||||
t.actuator = t2.id
|
||||
WHERE to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) AND t.execute_type !='Debug' AND t.execute_type
|
||||
!='Marge' AND t.project_id IN
|
||||
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||
AND t.trigger_mode = #{request.triggerMode}
|
||||
<if test="uiPermission">
|
||||
UNION ALL
|
||||
(SELECT t.id,t.name AS name ,'UI_SCENARIO' AS
|
||||
executionModule,t.report_type, ifnull(t2.name,'LOCAL') AS actuator, t1.`name` AS executor,t.create_time AS
|
||||
executionTime, t.trigger_mode AS triggerMode ,t.status AS executionStatus
|
||||
FROM ui_scenario_report t INNER JOIN `user` t1 ON t.user_id = t1.id LEFT JOIN test_resource_pool t2 ON
|
||||
t.actuator = t2.id
|
||||
WHERE to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) AND t.execute_type !='Debug' AND t.execute_type
|
||||
!='Marge' AND t.project_id IN
|
||||
<foreach collection="request.projects" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="request.triggerMode != null and request.triggerMode != ''">
|
||||
AND t.trigger_mode = #{request.triggerMode}
|
||||
</if>
|
||||
<if test="request.executionStatus != null and request.executionStatus != ''">
|
||||
AND t.status = #{request.executionStatus}
|
||||
</if>
|
||||
<if test="request.executor != null and request.executor != ''">
|
||||
AND t.user_id = #{request.executor}
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="request.executionStatus != null and request.executionStatus != ''">
|
||||
AND t.status = #{request.executionStatus}
|
||||
</if>
|
||||
<if test="request.executor != null and request.executor != ''">
|
||||
AND t.user_id = #{request.executor}
|
||||
</if>
|
||||
)
|
||||
)tt ORDER BY tt.executionTime DESC
|
||||
</select>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.task.service;
|
||||
|
||||
import io.metersphere.base.mapper.ext.BaseInformationSchemaTableMapper;
|
||||
import io.metersphere.base.mapper.ext.BaseScheduleMapper;
|
||||
import io.metersphere.base.mapper.ext.BaseTaskMapper;
|
||||
import io.metersphere.commons.constants.MicroServiceName;
|
||||
|
@ -30,6 +31,8 @@ public class TaskService {
|
|||
@Resource
|
||||
private BaseScheduleMapper baseScheduleMapper;
|
||||
@Resource
|
||||
private BaseInformationSchemaTableMapper baseInformationSchemaTableMapper;
|
||||
@Resource
|
||||
private BaseCheckPermissionService baseCheckPermissionService;
|
||||
@Resource
|
||||
private MicroService microService;
|
||||
|
@ -38,6 +41,7 @@ public class TaskService {
|
|||
private static final String PERF = "PERFORMANCE";
|
||||
|
||||
private static final String UI = "UI_SCENARIO";
|
||||
private static final String UI_SCENARIO_REPORT = "ui_scenario_report";
|
||||
|
||||
public List<String> getOwnerProjectIds(String userId) {
|
||||
Set<String> userRelatedProjectIds = null;
|
||||
|
@ -56,7 +60,7 @@ public class TaskService {
|
|||
if (CollectionUtils.isEmpty(request.getProjects())) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return baseTaskMapper.getTasks(request);
|
||||
return baseTaskMapper.getTasks(request,checkUiPermission());
|
||||
}
|
||||
|
||||
public int getRunningTasks(TaskCenterRequest request) {
|
||||
|
@ -110,4 +114,15 @@ public class TaskService {
|
|||
microService.postForData(MicroServiceName.API_TEST, "/api/automation/stop/batch", reportIds);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkUiPermission(){
|
||||
try {
|
||||
String uiScenarioReport = baseInformationSchemaTableMapper.checkExist(UI_SCENARIO_REPORT);
|
||||
if(StringUtils.isNotEmpty(uiScenarioReport)){
|
||||
return true;
|
||||
}
|
||||
}catch (Exception e){
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue