修复空指针

master
youys 2 years ago
parent 4874377f89
commit a3acd04f2c

@ -129,7 +129,7 @@ public class QualityInspectController {
*/ */
@GetMapping("/problemAnalysis") @GetMapping("/problemAnalysis")
@ResponseBody @ResponseBody
public ResponseResult<String> problemAnalysis(@RequestParam Integer ruleId) { public ResponseResult<ProblemAnalysisDTO> problemAnalysis(@RequestParam Integer ruleId) {
ProblemAnalysisDTO problemAnalysis = qualityInspectService.getProblemAnalysis(ruleId); ProblemAnalysisDTO problemAnalysis = qualityInspectService.getProblemAnalysis(ruleId);
return ResponseResult.success(problemAnalysis); return ResponseResult.success(problemAnalysis);
} }

@ -20,6 +20,7 @@ import net.educoder.ecsonar.utils.IdUtils;
import net.educoder.ecsonar.utils.SystemUtil; import net.educoder.ecsonar.utils.SystemUtil;
import net.educoder.ecsonar.utils.html.HtmlSourceDecorator; import net.educoder.ecsonar.utils.html.HtmlSourceDecorator;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -318,7 +319,13 @@ public class QualityInspectService {
problemAnalysisDTO.setExample(example); problemAnalysisDTO.setExample(example);
problemAnalysisDTO.setLanguage(rule.getLanguage()); problemAnalysisDTO.setLanguage(rule.getLanguage());
problemAnalysisDTO.setConstantIssue(rule.getDefRemediationBaseEffort()); problemAnalysisDTO.setConstantIssue(rule.getDefRemediationBaseEffort());
problemAnalysisDTO.setTags(Arrays.asList(rule.getTags().split(",")));
if (StringUtils.isBlank(rule.getTags())) {
problemAnalysisDTO.setTags(new ArrayList<>());
}else{
problemAnalysisDTO.setTags(Arrays.asList(rule.getTags().split(",")));
}
problemAnalysisDTO.setCreateTime(DateUtil.formatDateTime(new Date(rule.getCreateTime()))); problemAnalysisDTO.setCreateTime(DateUtil.formatDateTime(new Date(rule.getCreateTime())));
}else{ }else{
problemAnalysisDTO.setTitle(""); problemAnalysisDTO.setTitle("");

@ -11,6 +11,7 @@
inner join rules r on i.rule_id =r.id inner join rules r on i.rule_id =r.id
inner join projects p on p.uuid =i.component_uuid inner join projects p on p.uuid =i.component_uuid
where i.project_uuid = #{projectUuid,jdbcType=VARCHAR} where i.project_uuid = #{projectUuid,jdbcType=VARCHAR}
and i.status='OPEN'
and p.root_uuid =#{projectUuid,jdbcType=VARCHAR} and p.uuid !=#{projectUuid,jdbcType=VARCHAR} and p."scope" ='FIL' and p.root_uuid =#{projectUuid,jdbcType=VARCHAR} and p.uuid !=#{projectUuid,jdbcType=VARCHAR} and p."scope" ='FIL'
<if test="issueType != null"> <if test="issueType != null">
and i.issue_type=#{issueType,jdbcType=INTEGER} and i.issue_type=#{issueType,jdbcType=INTEGER}
@ -28,6 +29,7 @@
inner join rules r on i.rule_id =r.id inner join rules r on i.rule_id =r.id
inner join projects p on p.uuid =i.component_uuid inner join projects p on p.uuid =i.component_uuid
where i.project_uuid = #{projectUuid,jdbcType=VARCHAR} where i.project_uuid = #{projectUuid,jdbcType=VARCHAR}
and i.status='OPEN'
and p.root_uuid =#{projectUuid,jdbcType=VARCHAR} and p.uuid !=#{projectUuid,jdbcType=VARCHAR} and p."scope" ='FIL' and p.root_uuid =#{projectUuid,jdbcType=VARCHAR} and p.uuid !=#{projectUuid,jdbcType=VARCHAR} and p."scope" ='FIL'
<if test="issueType != null"> <if test="issueType != null">
and i.issue_type=#{issueType,jdbcType=INTEGER} and i.issue_type=#{issueType,jdbcType=INTEGER}
@ -40,11 +42,11 @@
<select id="queryDegree" resultType="net.educoder.ecsonar.model.dto.DegreeDTO"> <select id="queryDegree" resultType="net.educoder.ecsonar.model.dto.DegreeDTO">
select select
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType}) total, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and status='OPEN') total,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MAJOR') major, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MAJOR' and status='OPEN') major,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MINOR') minor, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MINOR' and status='OPEN') minor,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'BLOCKER') blocker, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'BLOCKER' and status='OPEN') blocker,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'CRITICAL') critical, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'CRITICAL' and status='OPEN') critical,
(select text_value from project_measures i where component_uuid =#{projectUuid} and metric_id = 80 order by id desc limit 1) levelStr (select text_value from project_measures i where component_uuid =#{projectUuid} and metric_id = 80 order by id desc limit 1) levelStr
</select> </select>

Loading…
Cancel
Save