fix(测试计划): 修改测试计划统计接口没查询子计划的缺陷
This commit is contained in:
parent
52b046cd71
commit
1c4f4e0fec
|
@ -129,7 +129,7 @@ public class SimpleUserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UserCreateInfo> saveUserAndRole(UserBatchCreateRequest userCreateDTO, String source, String operator, String requestPath) {
|
private List<UserCreateInfo> saveUserAndRole(UserBatchCreateRequest userCreateDTO, String source, String operator, String requestPath) {
|
||||||
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).guessWhatHowToAddUser(userCreateDTO, source, operator);
|
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).GWHowToAddUser(userCreateDTO, source, operator);
|
||||||
if (responseCode == 0) {
|
if (responseCode == 0) {
|
||||||
operationLogService.batchAdd(userLogService.getBatchAddLogs(userCreateDTO.getUserInfoList(), operator, requestPath));
|
operationLogService.batchAdd(userLogService.getBatchAddLogs(userCreateDTO.getUserInfoList(), operator, requestPath));
|
||||||
} else {
|
} else {
|
||||||
|
@ -225,7 +225,7 @@ public class SimpleUserService {
|
||||||
this.checkProcessUserAndThrowException(request.getSelectIds(), operatorId, operatorName, Translator.get("user.not.disable"));
|
this.checkProcessUserAndThrowException(request.getSelectIds(), operatorId, operatorName, Translator.get("user.not.disable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).guessWhatHowToChangeUser(request.getSelectIds(), request.isEnable(), operatorName);
|
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).GWHowToChangeUser(request.getSelectIds(), request.isEnable(), operatorName);
|
||||||
|
|
||||||
if (responseCode == 0) {
|
if (responseCode == 0) {
|
||||||
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
||||||
|
@ -319,12 +319,13 @@ public class SimpleUserService {
|
||||||
this.checkUserInDb(userIdList);
|
this.checkUserInDb(userIdList);
|
||||||
//检查是否含有Admin
|
//检查是否含有Admin
|
||||||
this.checkProcessUserAndThrowException(userIdList, operatorId, operatorName, Translator.get("user.not.delete"));
|
this.checkProcessUserAndThrowException(userIdList, operatorId, operatorName, Translator.get("user.not.delete"));
|
||||||
|
//开始删除
|
||||||
UserExample userExample = new UserExample();
|
UserExample userExample = new UserExample();
|
||||||
userExample.createCriteria().andIdIn(userIdList);
|
userExample.createCriteria().andIdIn(userIdList);
|
||||||
//更新删除标志位
|
|
||||||
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
||||||
response.setTotalCount(userIdList.size());
|
response.setTotalCount(userIdList.size());
|
||||||
response.setSuccessCount(this.deleteUserByList(userIdList, operatorId));
|
response.setSuccessCount(
|
||||||
|
Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).GWHowToDeleteUser(userIdList, operatorId));
|
||||||
//删除用户角色关系
|
//删除用户角色关系
|
||||||
userRoleRelationService.deleteByUserIdList(userIdList);
|
userRoleRelationService.deleteByUserIdList(userIdList);
|
||||||
//批量踢出用户
|
//批量踢出用户
|
||||||
|
@ -350,23 +351,6 @@ public class SimpleUserService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int deleteUserByList(List<String> updateUserList, String operator) {
|
|
||||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
|
||||||
BaseUserMapper batchDeleteMapper = sqlSession.getMapper(BaseUserMapper.class);
|
|
||||||
int insertIndex = 0;
|
|
||||||
long deleteTime = System.currentTimeMillis();
|
|
||||||
for (String userId : updateUserList) {
|
|
||||||
batchDeleteMapper.deleteUser(userId, operator, deleteTime);
|
|
||||||
insertIndex++;
|
|
||||||
if (insertIndex % 50 == 0) {
|
|
||||||
sqlSession.flushStatements();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sqlSession.flushStatements();
|
|
||||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
|
||||||
return insertIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<User> getUserList(String keyword) {
|
public List<User> getUserList(String keyword) {
|
||||||
return extUserMapper.selectUserList(keyword);
|
return extUserMapper.selectUserList(keyword);
|
||||||
}
|
}
|
||||||
|
@ -521,7 +505,7 @@ public class SimpleUserService {
|
||||||
this.add(userInvite.getEmail());
|
this.add(userInvite.getEmail());
|
||||||
}});
|
}});
|
||||||
|
|
||||||
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).guessWhatHowToAddUser(request, userInvite);
|
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).GWHowToAddUser(request, userInvite);
|
||||||
if (responseCode == 0) {
|
if (responseCode == 0) {
|
||||||
//删除本次邀请记录
|
//删除本次邀请记录
|
||||||
userInviteService.deleteInviteById(userInvite.getId());
|
userInviteService.deleteInviteById(userInvite.getId());
|
||||||
|
|
|
@ -11,9 +11,11 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface UserXpackService {
|
public interface UserXpackService {
|
||||||
|
|
||||||
int guessWhatHowToAddUser(UserBatchCreateRequest userCreateDTO, String source, String operator);
|
int GWHowToAddUser(UserBatchCreateRequest userCreateDTO, String source, String operator);
|
||||||
|
|
||||||
int guessWhatHowToAddUser(UserRegisterRequest registerRequest, UserInvite userInvite) throws Exception;
|
int GWHowToAddUser(UserRegisterRequest registerRequest, UserInvite userInvite) throws Exception;
|
||||||
|
|
||||||
int guessWhatHowToChangeUser(List<String> userIds, boolean enable, String operator);
|
int GWHowToChangeUser(List<String> userIds, boolean enable, String operator);
|
||||||
|
|
||||||
|
int GWHowToDeleteUser(List<String> userIdList, String operator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||||
public class TestPlanBatchEditRequest extends TestPlanBatchProcessRequest {
|
public class TestPlanBatchEditRequest extends TestPlanBatchProcessRequest {
|
||||||
|
|
||||||
@Schema(description = "是否追加")
|
@Schema(description = "是否追加")
|
||||||
private boolean append;
|
private boolean append = true;
|
||||||
|
|
||||||
@Schema(description = "标签")
|
@Schema(description = "标签")
|
||||||
private List<String> tags;
|
private List<String> tags;
|
||||||
|
|
|
@ -762,16 +762,22 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
testPlan.setStatus(testPlanFinalStatus);
|
testPlan.setStatus(testPlanFinalStatus);
|
||||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||||
|
|
||||||
List<TestPlan> childPlan = this.selectNotArchivedChildren(testPlanId);
|
testPlan = testPlanMapper.selectByPrimaryKey(testPlanId);
|
||||||
|
|
||||||
|
if (!StringUtils.equalsIgnoreCase(testPlan.getGroupId(), TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID)) {
|
||||||
|
//该测试计划是测试计划组内的子计划, 要同步计算测试计划组的状态
|
||||||
|
|
||||||
|
List<TestPlan> childPlan = this.selectNotArchivedChildren(testPlan.getGroupId());
|
||||||
if (CollectionUtils.isNotEmpty(childPlan)) {
|
if (CollectionUtils.isNotEmpty(childPlan)) {
|
||||||
TestPlan updateGroupPlan = new TestPlan();
|
TestPlan updateGroupPlan = new TestPlan();
|
||||||
updateGroupPlan.setId(testPlanId);
|
updateGroupPlan.setId(testPlan.getGroupId());
|
||||||
if (childPlan.stream().allMatch(item -> StringUtils.equals(item.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_COMPLETED))) {
|
if (childPlan.stream().allMatch(item -> StringUtils.equals(item.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_COMPLETED))) {
|
||||||
testPlan.setStatus(TestPlanConstants.TEST_PLAN_STATUS_COMPLETED);
|
updateGroupPlan.setStatus(TestPlanConstants.TEST_PLAN_STATUS_COMPLETED);
|
||||||
} else {
|
} else {
|
||||||
testPlan.setStatus(TestPlanConstants.TEST_PLAN_STATUS_UNDERWAY);
|
updateGroupPlan.setStatus(TestPlanConstants.TEST_PLAN_STATUS_UNDERWAY);
|
||||||
|
}
|
||||||
|
testPlanMapper.updateByPrimaryKeySelective(updateGroupPlan);
|
||||||
}
|
}
|
||||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class TestPlanStatisticsService {
|
public class TestPlanStatisticsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TestPlanMapper testPlanMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanConfigMapper testPlanConfigMapper;
|
private TestPlanConfigMapper testPlanConfigMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -74,12 +76,17 @@ public class TestPlanStatisticsService {
|
||||||
* @param planIds 计划ID集合
|
* @param planIds 计划ID集合
|
||||||
*/
|
*/
|
||||||
public List<TestPlanStatisticsResponse> calculateRate(List<String> planIds) {
|
public List<TestPlanStatisticsResponse> calculateRate(List<String> planIds) {
|
||||||
|
// 查出子计划
|
||||||
|
TestPlanExample testPlanExample = new TestPlanExample();
|
||||||
|
testPlanExample.createCriteria().andGroupIdIn(planIds);
|
||||||
|
List<TestPlan> childrenPlan = testPlanMapper.selectByExample(testPlanExample);
|
||||||
|
childrenPlan.forEach(item -> planIds.add(item.getId()));
|
||||||
|
|
||||||
List<TestPlanStatisticsResponse> planStatisticsResponses = new ArrayList<>();
|
List<TestPlanStatisticsResponse> planStatisticsResponses = new ArrayList<>();
|
||||||
/*
|
/*
|
||||||
* 1. 查询计划下的用例数据集合
|
* 1. 查询计划下的用例数据集合
|
||||||
* 2. 根据执行结果统计(结果小数保留两位)
|
* 2. 根据执行结果统计(结果小数保留两位)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 计划的更多配置
|
// 计划的更多配置
|
||||||
TestPlanConfigExample example = new TestPlanConfigExample();
|
TestPlanConfigExample example = new TestPlanConfigExample();
|
||||||
example.createCriteria().andTestPlanIdIn(planIds);
|
example.createCriteria().andTestPlanIdIn(planIds);
|
||||||
|
@ -99,6 +106,9 @@ public class TestPlanStatisticsService {
|
||||||
planIds.forEach(planId -> {
|
planIds.forEach(planId -> {
|
||||||
TestPlanStatisticsResponse statisticsResponse = new TestPlanStatisticsResponse();
|
TestPlanStatisticsResponse statisticsResponse = new TestPlanStatisticsResponse();
|
||||||
statisticsResponse.setId(planId);
|
statisticsResponse.setId(planId);
|
||||||
|
|
||||||
|
// 测试计划组没有测试计划配置。同理,也不用参与用例等数据的计算
|
||||||
|
if (planConfigMap.containsKey(planId)) {
|
||||||
statisticsResponse.setPassThreshold(planConfigMap.get(planId).getPassThreshold());
|
statisticsResponse.setPassThreshold(planConfigMap.get(planId).getPassThreshold());
|
||||||
// 功能用例分组统计开始 (为空时, 默认为未执行)
|
// 功能用例分组统计开始 (为空时, 默认为未执行)
|
||||||
List<TestPlanFunctionalCase> functionalCases = planFunctionalCaseMap.get(planId);
|
List<TestPlanFunctionalCase> functionalCases = planFunctionalCaseMap.get(planId);
|
||||||
|
@ -125,6 +135,7 @@ public class TestPlanStatisticsService {
|
||||||
// 通过率 {通过用例数/总用例数} && 执行进度 {非未执行的用例数/总用例数}
|
// 通过率 {通过用例数/总用例数} && 执行进度 {非未执行的用例数/总用例数}
|
||||||
statisticsResponse.setPassRate(RateCalculateUtils.divWithPrecision(statisticsResponse.getSuccessCount(), statisticsResponse.getCaseTotal(), 2));
|
statisticsResponse.setPassRate(RateCalculateUtils.divWithPrecision(statisticsResponse.getSuccessCount(), statisticsResponse.getCaseTotal(), 2));
|
||||||
statisticsResponse.setExecuteRate(RateCalculateUtils.divWithPrecision(statisticsResponse.getCaseTotal() - statisticsResponse.getPendingCount(), statisticsResponse.getCaseTotal(), 2));
|
statisticsResponse.setExecuteRate(RateCalculateUtils.divWithPrecision(statisticsResponse.getCaseTotal() - statisticsResponse.getPendingCount(), statisticsResponse.getCaseTotal(), 2));
|
||||||
|
}
|
||||||
planStatisticsResponses.add(statisticsResponse);
|
planStatisticsResponses.add(statisticsResponse);
|
||||||
|
|
||||||
//定时任务
|
//定时任务
|
||||||
|
|
|
@ -1370,7 +1370,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
this.requestPostAndReturn(URL_POST_TEST_PLAN_STATISTICS, List.of(groupTestPlanId7))
|
this.requestPostAndReturn(URL_POST_TEST_PLAN_STATISTICS, List.of(groupTestPlanId7))
|
||||||
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
||||||
TestPlanStatisticsResponse.class);
|
TestPlanStatisticsResponse.class);
|
||||||
Assertions.assertTrue(statisticsResponses.size() == 1);
|
Assertions.assertTrue(statisticsResponses.size() > 1);
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() > 0);
|
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() > 0);
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getScheduleConfig().isEnable());
|
Assertions.assertTrue(statisticsResponses.getFirst().getScheduleConfig().isEnable());
|
||||||
|
|
||||||
|
@ -1395,7 +1395,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
this.requestPostAndReturn(URL_POST_TEST_PLAN_STATISTICS, List.of(groupTestPlanId7))
|
this.requestPostAndReturn(URL_POST_TEST_PLAN_STATISTICS, List.of(groupTestPlanId7))
|
||||||
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
||||||
TestPlanStatisticsResponse.class);
|
TestPlanStatisticsResponse.class);
|
||||||
Assertions.assertTrue(statisticsResponses.size() == 1);
|
Assertions.assertTrue(statisticsResponses.size() > 1);
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() == null);
|
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() == null);
|
||||||
Assertions.assertFalse(statisticsResponses.getFirst().getScheduleConfig().isEnable());
|
Assertions.assertFalse(statisticsResponses.getFirst().getScheduleConfig().isEnable());
|
||||||
|
|
||||||
|
@ -1474,7 +1474,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
this.requestPostAndReturn(URL_POST_TEST_PLAN_STATISTICS, List.of(groupTestPlanId7))
|
this.requestPostAndReturn(URL_POST_TEST_PLAN_STATISTICS, List.of(groupTestPlanId7))
|
||||||
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
||||||
TestPlanStatisticsResponse.class);
|
TestPlanStatisticsResponse.class);
|
||||||
Assertions.assertTrue(statisticsResponses.size() == 1);
|
Assertions.assertTrue(statisticsResponses.size() > 1);
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() == null);
|
Assertions.assertTrue(statisticsResponses.getFirst().getNextTriggerTime() == null);
|
||||||
Assertions.assertTrue(statisticsResponses.getFirst().getScheduleConfig() == null);
|
Assertions.assertTrue(statisticsResponses.getFirst().getScheduleConfig() == null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue