refactor(用例管理): provider加错误日志读取文件关闭流

This commit is contained in:
guoyuqi 2023-12-25 18:09:52 +08:00 committed by 刘瑞斌
parent 6a04e8c4dd
commit bb3c121b8b
12 changed files with 227 additions and 158 deletions

View File

@ -60,6 +60,7 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
* 1.关联用例单独/批量重新计算用例评审的通过率和用例数
*/
private void updateCaseReviewByAssociate(Map<String, Object> paramMap) {
try {
String reviewId = paramMap.get(CaseEvent.Param.REVIEW_ID).toString();
Object caseIds = paramMap.get(CaseEvent.Param.CASE_IDS);
List<String> caseIdList = JSON.parseArray(JSON.toJSONString(caseIds), String.class);
@ -69,7 +70,10 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
int caseCount = Integer.parseInt(paramMap.get(CaseEvent.Param.CASE_COUNT).toString()) + caseReviewFunctionalCases.size();
int passNumber = passList.size();
List<CaseReviewFunctionalCase> unCompletedCaseList = getUnCompletedCaseList(caseReviewFunctionalCases, new ArrayList<>());
updateCaseReview(reviewId, caseCount, passNumber, unCompletedCaseList.size()+Integer.parseInt(paramMap.get(CaseEvent.Param.CASE_COUNT).toString()), paramMap.get(CaseEvent.Param.USER_ID).toString());
updateCaseReview(reviewId, caseCount, passNumber, unCompletedCaseList.size() + Integer.parseInt(paramMap.get(CaseEvent.Param.CASE_COUNT).toString()), paramMap.get(CaseEvent.Param.USER_ID).toString());
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.ASSOCIATE + "事件更新失败", e.getMessage());
}
}
/**
@ -78,6 +82,7 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
* 2.删除用例和用例评审人的关系
*/
private void updateCaseReviewByDisAssociate(Map<String, Object> paramMap) {
try {
String reviewId = paramMap.get(CaseEvent.Param.REVIEW_ID).toString();
CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(reviewId);
if (caseReview == null) {
@ -88,14 +93,17 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
//获取与选中case无关的其他case
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = extCaseReviewFunctionalCaseMapper.getListIncludes(reviewId, caseIdList, false);
List<CaseReviewFunctionalCase> passList = caseReviewFunctionalCases.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getStatus(), FunctionalCaseReviewStatus.PASS.toString())).toList();
int caseCount = caseReviewFunctionalCases.size()- caseIdList.size();
int caseCount = caseReviewFunctionalCases.size() - caseIdList.size();
int passNumber = passList.size();
List<CaseReviewFunctionalCase> unCompletedCaseList = getUnCompletedCaseList(caseReviewFunctionalCases, new ArrayList<>());
updateCaseReview(reviewId, caseReview.getCaseCount() - caseCount, passNumber, unCompletedCaseList.size(), paramMap.get(CaseEvent.Param.USER_ID).toString());
//删除用例和用例评审人的关系
deleteCaseReviewFunctionalCaseUser(paramMap);
//将评审历史状态置为true
extCaseReviewHistoryMapper.updateDelete(caseIdList,reviewId,true);
extCaseReviewHistoryMapper.updateDelete(caseIdList, reviewId, true);
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.DISASSOCIATE + "事件更新失败", e.getMessage());
}
}
/**
@ -104,6 +112,7 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
* 2.删除用例和用例评审人的关系
*/
private void updateCaseReviewByBatchDisassociate(Map<String, Object> paramMap) {
try {
String reviewId = paramMap.get(CaseEvent.Param.REVIEW_ID).toString();
CaseReview caseReviewOld = caseReviewMapper.selectByPrimaryKey(reviewId);
Integer oldCaseCount = caseReviewOld.getCaseCount();
@ -118,22 +127,30 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
//删除用例和用例评审人的关系
deleteCaseReviewFunctionalCaseUser(paramMap);
//将评审历史状态置为true
extCaseReviewHistoryMapper.updateDelete(caseIdList,reviewId,true);
extCaseReviewHistoryMapper.updateDelete(caseIdList, reviewId, true);
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.BATCH_DISASSOCIATE + "事件更新失败", e.getMessage());
}
}
/**
* 4.功能用例的删除/批量删除重新计算用例评审的通过率和用例数
*/
private void updateCaseReviewByDeleteFunctionalCase(Map<String, Object> paramMap) {
try {
Object caseIds = paramMap.get(CaseEvent.Param.CASE_IDS);
List<String> caseIdList = JSON.parseArray(JSON.toJSONString(caseIds), String.class);
startUpdateCaseReview(paramMap, caseIdList);
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.DELETE_FUNCTIONAL_CASE + "事件更新失败", e.getMessage());
}
}
/**
* 5.功能用例的回收站删除/批量删除重新计算用例评审的通过率和用例数
*/
private void updateCaseReviewByDeleteTrashFunctionalCase(Map<String, Object> paramMap) {
try {
Object caseIds = paramMap.get(CaseEvent.Param.CASE_IDS);
List<String> caseIdList = JSON.parseArray(JSON.toJSONString(caseIds), String.class);
if (startUpdateCaseReview(paramMap, caseIdList)) return;
@ -144,13 +161,16 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(caseIdList);
caseReviewFunctionalCaseMapper.deleteByExample(caseReviewFunctionalCaseExample);
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.DELETE_TRASH_FUNCTIONAL_CASE + "事件更新失败", e.getMessage());
}
}
/**
* 6.功能用例的回收站恢复/批量恢复重新计算用例评审的通过率和用例数
*/
private void updateCaseReviewByRecoverFunctionalCase(Map<String, Object> paramMap) {
try {
Object caseIds = paramMap.get(CaseEvent.Param.CASE_IDS);
List<String> caseIdList = JSON.parseArray(JSON.toJSONString(caseIds), String.class);
CaseReviewFunctionalCaseExample functionalCaseExample = new CaseReviewFunctionalCaseExample();
@ -160,22 +180,30 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
return;
}
List<String> reviewIds = recoverCases.stream().map(CaseReviewFunctionalCase::getReviewId).distinct().toList();
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = extCaseReviewFunctionalCaseMapper.getListExcludes(reviewIds, caseIdList, false);
Map<String, List<CaseReviewFunctionalCase>> recoverCaseMap = recoverCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getReviewId));
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = extCaseReviewFunctionalCaseMapper.getListExcludes(reviewIds, caseIdList, false);
Map<String, List<CaseReviewFunctionalCase>> reviewIdMap = caseReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getReviewId));
CaseReviewExample caseReviewExample = new CaseReviewExample();
caseReviewExample.createCriteria().andIdIn(reviewIds);
List<CaseReview> caseReviews = caseReviewMapper.selectByExample(caseReviewExample);
Map<String, CaseReview> reviewMap = caseReviews.stream().collect(Collectors.toMap(CaseReview::getId, t -> t));
reviewIdMap.forEach((reviewId, caseReviewFunctionalCaseList) -> {
CaseReview caseReview = reviewMap.get(reviewId);
reviewMap.forEach((reviewId, caseReview) -> {
List<CaseReviewFunctionalCase> recoverCaseList = recoverCaseMap.get(reviewId);
List<CaseReviewFunctionalCase> caseReviewFunctionalCaseList = reviewIdMap.get(reviewId);
if (CollectionUtils.isNotEmpty(caseReviewFunctionalCaseList)) {
caseReviewFunctionalCaseList.addAll(recoverCaseList);
} else {
caseReviewFunctionalCaseList = recoverCaseList;
}
List<String> ids = caseReviewFunctionalCaseList.stream().map(CaseReviewFunctionalCase::getId).toList();
List<CaseReviewFunctionalCase> unCompleteList = getUnCompletedCaseList(caseReviewFunctionalCaseList, ids);
List<CaseReviewFunctionalCase> passList = caseReviewFunctionalCaseList.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getStatus(), FunctionalCaseReviewStatus.PASS.toString())).toList();
updateCaseReview(reviewId, caseReview.getCaseCount() + caseReviewFunctionalCaseList.size(), passList.size(), unCompleteList.size(), paramMap.get(CaseEvent.Param.USER_ID).toString());
});
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.RECOVER_FUNCTIONAL_CASE + "事件更新失败", e.getMessage());
}
}
@ -183,6 +211,7 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
* 7.评审用例/批量评审用例重新计算用例评审的通过率和用例评审状态和发送通知
*/
private void updateCaseReviewByReviewFunctionalCase(Map<String, Object> paramMap) {
try {
String reviewId = paramMap.get(CaseEvent.Param.REVIEW_ID).toString();
Object caseIds = paramMap.get(CaseEvent.Param.CASE_IDS);
List<String> caseIdList = JSON.parseArray(JSON.toJSONString(caseIds), String.class);
@ -204,9 +233,9 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
caseReview.setStatus(CaseReviewStatus.COMPLETED.toString());
}
int passNumber = passList.size();
if (StringUtils.equalsIgnoreCase(status, FunctionalCaseReviewStatus.PASS.toString())) {
passNumber += caseIdList.size();
}
int pass = Integer.parseInt(paramMap.get(CaseEvent.Param.PASS_COUNT).toString());
passNumber += pass;
//通过率
BigDecimal passCount = BigDecimal.valueOf(passNumber);
BigDecimal totalCount = BigDecimal.valueOf(caseReview.getCaseCount());
@ -221,7 +250,9 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
if (completed) {
reviewSendNoticeService.sendNotice(new ArrayList<>(), paramMap.get(CaseEvent.Param.USER_ID).toString(), reviewId, NoticeConstants.TaskType.CASE_REVIEW_TASK, NoticeConstants.Event.REVIEW_COMPLETED);
}
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.REVIEW_FUNCTIONAL_CASE + "事件更新失败", e.getMessage());
}
}
/**

View File

@ -149,10 +149,10 @@ public class CaseReviewFunctionalCaseService {
List<CaseReviewFunctionalCase> unCompletedCaseList = caseReviewFunctionalCases.stream().filter(t -> !ids.contains(t.getId()) && statusList.contains(t.getStatus())).toList();
List<String> list = caseReviewFunctionalCases.stream().filter(t -> ids.contains(t.getId())).map(CaseReviewFunctionalCase::getCaseId).toList();
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.CASE_IDS, list.size());
param.put(CaseEvent.Param.CASE_IDS, CollectionUtils.isNotEmpty(list) ? list : new ArrayList<>());
param.put(CaseEvent.Param.REVIEW_ID, reviewId);
param.put(CaseEvent.Param.PASS_COUNT, passList.size());
param.put(CaseEvent.Param.UN_COMPLETED_COUNT, unCompletedCaseList.size());
param.put(CaseEvent.Param.PASS_COUNT, CollectionUtils.isNotEmpty(passList) ? passList.size() : 0);
param.put(CaseEvent.Param.UN_COMPLETED_COUNT, CollectionUtils.isNotEmpty(unCompletedCaseList) ? unCompletedCaseList.size() : 0);
return param;
}
@ -287,6 +287,7 @@ public class CaseReviewFunctionalCaseService {
CaseReviewHistoryMapper caseReviewHistoryMapper = sqlSession.getMapper(CaseReviewHistoryMapper.class);
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
int passCount = 0;
for (CaseReviewFunctionalCase caseReviewFunctionalCase : caseReviewFunctionalCaseList) {
String caseId = caseReviewFunctionalCase.getCaseId();
CaseReviewHistory caseReviewHistory = buildCaseReviewHistory(request, userId, caseId);
@ -300,6 +301,9 @@ public class CaseReviewFunctionalCaseService {
}
//根据评审规则更新用例评审和功能用例关系表中的状态 1.单人评审直接更新评审结果 2.多人评审需要计算
setStatus(request, caseReviewFunctionalCase, caseHistoryMap, reviewerMap);
if (StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(), FunctionalCaseReviewStatus.PASS.toString())) {
passCount += 1;
}
caseReviewFunctionalCaseMapper.updateByPrimaryKeySelective(caseReviewFunctionalCase);
//检查是否有@发送@通知
@ -319,7 +323,8 @@ public class CaseReviewFunctionalCaseService {
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.CASE_IDS, caseIds);
param.put(CaseEvent.Param.CASE_IDS, CollectionUtils.isNotEmpty(caseIds) ? caseIds : new ArrayList<>());
param.put(CaseEvent.Param.PASS_COUNT, passCount);
param.put(CaseEvent.Param.REVIEW_ID, reviewId);
param.put(CaseEvent.Param.STATUS, request.getStatus());
param.put(CaseEvent.Param.USER_ID, userId);

View File

@ -470,7 +470,7 @@ public class CaseReviewService {
param.put(CaseEvent.Param.USER_ID, userId);
param.put(CaseEvent.Param.REVIEW_ID, caseReviewId);
param.put(CaseEvent.Param.CASE_IDS, castIds);
param.put(CaseEvent.Param.CASE_COUNT, caseRealIds.size());
param.put(CaseEvent.Param.CASE_COUNT, CollectionUtils.isNotEmpty(caseRealIds) ? caseRealIds.size() : 0);
param.put(CaseEvent.Param.EVENT_NAME, CaseEvent.Event.ASSOCIATE);
provider.updateCaseReview(param);
}

View File

@ -398,10 +398,10 @@ public class FunctionalCaseService {
functionalCaseExample.createCriteria().andRefIdIn(refId);
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
List<String> caseIds = functionalCases.stream().map(FunctionalCase::getId).toList();
param.put(CaseEvent.Param.CASE_IDS, caseIds);
param.put(CaseEvent.Param.CASE_IDS, CollectionUtils.isNotEmpty(caseIds) ? caseIds : new ArrayList<>());
extFunctionalCaseMapper.batchDelete(refId, userId);
} else {
param.put(CaseEvent.Param.CASE_IDS, ids);
param.put(CaseEvent.Param.CASE_IDS, CollectionUtils.isNotEmpty(ids) ? ids : new ArrayList<>());
doDelete(ids, userId);
}
param.put(CaseEvent.Param.USER_ID, userId);

View File

@ -57,6 +57,7 @@ public class FunctionalCaseTrashService {
throw new MSException(Translator.get("case_comment.case_is_null"));
}
List<String> ids = getIdsByRefId(functionalCase.getRefId());
if (CollectionUtils.isNotEmpty(ids)) {
//检查自定义字段是否还存在不存在删除关联关系与恢复流程没关系可异步执行
delCustomFields(ids);
Map<String, Object> param = new HashMap<>();
@ -66,6 +67,7 @@ public class FunctionalCaseTrashService {
provider.updateCaseReview(param);
extFunctionalCaseMapper.recoverCase(ids,userId,System.currentTimeMillis());
}
}
/**
* 检查自定义字段是否还存在不存在删除关联关系与恢复流程没关系可异步执行
@ -104,7 +106,7 @@ public class FunctionalCaseTrashService {
}
/**
* 从回收站彻底用例
* 从回收站彻底删除用例
* @param id 用例ID
*/
public void deleteCase(String id, String userId) {
@ -113,6 +115,7 @@ public class FunctionalCaseTrashService {
return;
}
List<String> ids = getIdsByRefId(functionalCase.getRefId());
if (CollectionUtils.isNotEmpty(ids)){
deleteFunctionalCaseService.deleteFunctionalCaseResource(ids, functionalCase.getProjectId());
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.CASE_IDS,ids);
@ -120,6 +123,7 @@ public class FunctionalCaseTrashService {
param.put(CaseEvent.Param.EVENT_NAME,CaseEvent.Event.DELETE_TRASH_FUNCTIONAL_CASE);
provider.updateCaseReview(param);
}
}
private List<String> getIdsByRefId(String refId) {
FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample();
@ -138,7 +142,7 @@ public class FunctionalCaseTrashService {
if (request.isSelectAll()) {
//回收站全部恢复
List<String> ids = getIds(request);
if (ids == null) return;
if (CollectionUtils.isEmpty(ids)) return;
refIds = extFunctionalCaseMapper.getRefIds(ids, true);
} else {
if (CollectionUtils.isEmpty(request.getSelectIds())) {
@ -155,7 +159,7 @@ public class FunctionalCaseTrashService {
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
List<String> ids = functionalCases.stream().map(FunctionalCase::getId).toList();
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.CASE_IDS,ids);
param.put(CaseEvent.Param.CASE_IDS,CollectionUtils.isNotEmpty(ids) ? ids : new ArrayList<>());
param.put(CaseEvent.Param.USER_ID,userId);
param.put(CaseEvent.Param.EVENT_NAME,CaseEvent.Event.RECOVER_FUNCTIONAL_CASE);
provider.updateCaseReview(param);
@ -193,7 +197,7 @@ public class FunctionalCaseTrashService {
if (request.isSelectAll()) {
//判断是否全部删除
List<String> ids = getIds(request);
if (ids == null) return;
if (CollectionUtils.isEmpty(ids)) return;
if (request.getDeleteAll()) {
//回收站全部版本全都删除
refIds = extFunctionalCaseMapper.getRefIds(ids, true);
@ -237,7 +241,7 @@ public class FunctionalCaseTrashService {
List<String> deleteIds = functionalCases.stream().map(FunctionalCase::getId).toList();
deleteFunctionalCaseService.deleteFunctionalCaseResource(deleteIds, request.getProjectId());
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.CASE_IDS,deleteIds);
param.put(CaseEvent.Param.CASE_IDS,CollectionUtils.isNotEmpty(deleteIds) ? deleteIds : new ArrayList<>());
param.put(CaseEvent.Param.USER_ID,userId);
param.put(CaseEvent.Param.EVENT_NAME,CaseEvent.Event.DELETE_TRASH_FUNCTIONAL_CASE);
provider.updateCaseReview(param);

View File

@ -68,6 +68,10 @@ public class ReviewFunctionalCaseService {
String functionalCaseStatus = getFunctionalCaseStatus(request, hasReviewedUserMap);
extCaseReviewFunctionalCaseMapper.updateStatus(caseId, reviewId, functionalCaseStatus);
caseReviewHistoryMapper.insert(caseReviewHistory);
int passCount = 0;
if (StringUtils.equalsIgnoreCase(FunctionalCaseReviewStatus.PASS.toString(),functionalCaseStatus)) {
passCount=1;
}
//检查是否有@发送@通知
if (StringUtils.isNotBlank(request.getNotifier())) {
@ -83,6 +87,7 @@ public class ReviewFunctionalCaseService {
}
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.CASE_IDS, List.of(caseId));
param.put(CaseEvent.Param.PASS_COUNT,passCount);
param.put(CaseEvent.Param.REVIEW_ID, reviewId);
param.put(CaseEvent.Param.STATUS, request.getStatus());
param.put(CaseEvent.Param.USER_ID, userId);

View File

@ -66,12 +66,24 @@ VALUES ('Trash_TEST_FUNCTIONAL_CASE_ID_g', 8, 'Trash_TEST_MOUDLE_ID_1', 'project
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('Trash_TEST_FUNCTIONAL_CASE_ID_GYQ', 100, 'Trash_TEST_MOUDLE_ID', 'project-case-trash-test', '100001', '回收站测信', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'Trash_TEST_FUNCTIONAL_CASE_ID_GYQ', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('unTrash_TEST_FUNCTIONAL_CASE_ID', 100, 'Trash_TEST_MOUDLE_ID', 'project-case-trash-test', '100001', '回收站测信', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'unTrash_TEST_FUNCTIONAL_CASE_ID', 'UN_EXECUTED', false, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL);
INSERT INTO case_review_functional_case(id, review_id, case_id, status, create_time, create_user, update_time, pos)
VALUES ('Gyq_Review_Case_Id','Gyq_review_id', 'Trash_TEST_FUNCTIONAL_CASE_ID', 'PASS', 1698058347559, 'admin',1698058347559, 0);
INSERT INTO case_review_functional_case(id, review_id, case_id, status, create_time, create_user, update_time, pos)
VALUES ('Gyq_Review_Case_Id2','Gyq_review_id1', 'Trash_TEST_FUNCTIONAL_CASE_ID_1', 'PASS', 1698058347559, 'admin',1698058347559, 0);
INSERT INTO case_review_functional_case(id, review_id, case_id, status, create_time, create_user, update_time, pos)
VALUES ('Gyq_Review_Case_Id3','Gyq_review_id1', 'unTrash_TEST_FUNCTIONAL_CASE_ID', 'PASS', 1698058347559, 'admin',1698058347559, 0);
INSERT INTO case_review(id, num, name, module_id, project_id, status, review_pass_rule, pos, start_time, end_time, case_count, pass_rate, tags, description, create_time, create_user, update_time, update_user)
VALUES ('Gyq_review_id', 10001, '用例评审1', 'Trash_TEST_MOUDLE_ID_1', 'project-case-trash-test', 'COMPLETE' , 'SINGLE', 0, 1698058347559, 1698058347559, 1, 100.00, null, null, 1698058347559, 'admin', 1698058347559, 'admin');
INSERT INTO case_review(id, num, name, module_id, project_id, status, review_pass_rule, pos, start_time, end_time, case_count, pass_rate, tags, description, create_time, create_user, update_time, update_user)
VALUES ('Gyq_review_id1', 10001, '用例评审2', 'Trash_TEST_MOUDLE_ID_1', 'project-case-trash-test', 'COMPLETE' , 'SINGLE', 0, 1698058347559, 1698058347559, 1, 100.00, null, null, 1698058347559, 'admin', 1698058347559, 'admin');
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('Trash_TEST_FUNCTIONAL_CASE_ID', 'gyq_custom_id1', '22');
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('Trash_TEST_FUNCTIONAL_CASE_ID', 'gyq_custom_id2', '33');

View File

@ -78,15 +78,16 @@ public class CreateRobotResourceService implements CreateProjectResourceService
public void setMessageTask(String projectId, String defaultRobotId) {
StringBuilder jsonStr = new StringBuilder();
try {
InputStream inputStream = getClass().getResourceAsStream("/message_task.json");
assert inputStream != null;
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
try {
while ((line = reader.readLine()) != null) {
jsonStr.append(line);
}
reader.close();
inputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}

View File

@ -320,13 +320,20 @@ public class NoticeMessageTaskService {
checkProjectExist(projectId);
//获取返回数据结构
StringBuilder jsonStr = new StringBuilder();
try{
InputStream inputStream = getClass().getResourceAsStream("/message_task.json");
assert inputStream != null;
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null) {
jsonStr.append(line);
}
reader.close();
inputStream.close();
} catch (IOException e){
throw new RuntimeException(e);
}
List<MessageTaskDTO> messageTaskDTOList = JSON.parseArray(jsonStr.toString(), MessageTaskDTO.class);
//查询数据
MessageTaskExample messageTaskExample = new MessageTaskExample();

View File

@ -595,18 +595,19 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
public void setMessageTask(String projectId, String defaultRobotId) {
StringBuilder jsonStr = new StringBuilder();
try {
InputStream inputStream = getClass().getResourceAsStream("/message_task.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
try {
while ((line = reader.readLine()) != null) {
jsonStr.append(line);
}
reader.close();
inputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
MessageTaskMapper mapper = sqlSession.getMapper(MessageTaskMapper.class);
MessageTaskBlobMapper blobMapper = sqlSession.getMapper(MessageTaskBlobMapper.class);

View File

@ -516,18 +516,18 @@ public class ProjectRobotControllerTests extends BaseTest {
public void setMessageTask(String projectId, String defaultRobotId) throws Exception {
StringBuilder jsonStr = new StringBuilder();
try {
InputStream inputStream = getClass().getResourceAsStream("/message_task.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
try {
while ((line = reader.readLine()) != null) {
jsonStr.append(line);
}
reader.close();
inputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
MessageTaskMapper mapper = sqlSession.getMapper(MessageTaskMapper.class);
MessageTaskBlobMapper blobMapper = sqlSession.getMapper(MessageTaskBlobMapper.class);

View File

@ -41,6 +41,9 @@ INSERT INTO project_robot(id, project_id, name, platform, webhook, type, app_key
('test_message_robot4', 'project-message-test-3', '测试机器人1', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null),
('test_message_robot5', 'project-message-test', '测试机器人6', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
INSERT INTO custom_field(id, name, scene, `type`, remark, internal, scope_type, create_time, update_time, create_user, scope_id)
VALUES('gyq_custom_id_message1', 'gyq_functional_priority', 'FUNCTIONAL', 'SELECT', '', 1, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'project-message-test');