refactor(缺陷管理): 优化缺陷列表处理人及状态字段

This commit is contained in:
song-cc-rock 2024-02-21 20:44:11 +08:00 committed by Craftsman
parent be0110714a
commit 4ecefaa8f6
3 changed files with 13 additions and 13 deletions

View File

@ -16,7 +16,6 @@ import io.metersphere.system.domain.ServiceIntegration;
import io.metersphere.system.service.PlatformPluginService;
import io.metersphere.system.service.PluginLoadService;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -51,8 +50,7 @@ public class BugCommonService {
// Local处理人
return getLocalHandlerOption(projectId);
} else {
// 第三方平台(Local处理人 && 平台处理人)
List<SelectOption> localHandlerOption = getLocalHandlerOption(projectId);
// 第三方平台处理人
// 获取插件中自定义的注入字段(处理人)
Platform platform = platformPluginService.getPlatform(serviceIntegration.getPluginId(), serviceIntegration.getOrganizationId(),
new String(serviceIntegration.getConfiguration()));
@ -66,7 +64,7 @@ public class BugCommonService {
platformHandlerOption = platform.getFormOptions(request);
}
}
return ListUtils.union(localHandlerOption, platformHandlerOption);
return platformHandlerOption;
}
}

View File

@ -1118,17 +1118,21 @@ public class BugService {
List<String> ids = bugs.stream().map(BugDTO::getId).toList();
List<BugCustomFieldDTO> customFields = extBugCustomFieldMapper.getBugAllCustomFields(ids, projectId);
Map<String, List<BugCustomFieldDTO>> customFieldMap = customFields.stream().collect(Collectors.groupingBy(BugCustomFieldDTO::getBugId));
// 处理人选项
// 表头处理人选项
List<SelectOption> handleUserOption = bugCommonService.getHeaderHandlerOption(projectId);
Map<String, String> handleMap = handleUserOption.stream().collect(Collectors.toMap(SelectOption::getValue, SelectOption::getText));
// 状态选项
List<SelectOption> localHandlerOption = bugCommonService.getLocalHandlerOption(projectId);
Map<String, String> localHandleMap = localHandlerOption.stream().collect(Collectors.toMap(SelectOption::getValue, SelectOption::getText));
// 表头状态选项
List<SelectOption> statusOption = bugStatusService.getHeaderStatusOption(projectId);
Map<String, String> statusMap = statusOption.stream().collect(Collectors.toMap(SelectOption::getValue, SelectOption::getText));
List<SelectOption> localStatusOptions = bugStatusService.getAllLocalStatusOptions(projectId);
Map<String, String> localStatusMap = localStatusOptions.stream().collect(Collectors.toMap(SelectOption::getValue, SelectOption::getText));
bugs.forEach(bug -> {
bug.setCustomFields(customFieldMap.get(bug.getId()));
// 解析处理人, 状态, 严重程度
bug.setHandleUserName(handleMap.get(bug.getHandleUser()));
bug.setStatusName(statusMap.get(bug.getStatus()));
// 解析处理人, 状态
bug.setHandleUserName(StringUtils.isBlank(handleMap.get(bug.getHandleUser())) ? localHandleMap.get(bug.getHandleUser()) : handleMap.get(bug.getHandleUser()));
bug.setStatusName(StringUtils.isBlank(statusMap.get(bug.getStatus())) ? localStatusMap.get(bug.getStatus()) : statusMap.get(bug.getStatus()));
});
return bugs;
}

View File

@ -12,7 +12,6 @@ import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.service.BaseStatusFlowSettingService;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -41,8 +40,7 @@ public class BugStatusService {
// Local状态流
return getAllLocalStatusOptions(projectId);
} else {
// 第三方平台(Local状态流 && 第三方平台状态流)
List<SelectOption> localStatusOption = getAllLocalStatusOptions(projectId);
// 第三方平台状态流
Platform platform = projectApplicationService.getPlatform(projectId, true);
String projectConfig = projectApplicationService.getProjectBugThirdPartConfig(projectId);
// 获取一条最新的Jira默认模板缺陷Key
@ -52,7 +50,7 @@ public class BugStatusService {
} catch (Exception e) {
LogUtils.error("获取平台状态选项有误: " + e.getMessage());
}
return ListUtils.union(localStatusOption, platformStatusOption);
return platformStatusOption;
}
}