|
@@ -5,9 +5,11 @@ import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.sop.business.bean.report.QualityAnalyseReportBean;
|
|
|
import com.qmth.sop.business.service.QualityAnalyseReportService;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
+import com.qmth.sop.common.enums.QualityProblemReasonEnum;
|
|
|
import com.qmth.sop.common.util.Result;
|
|
|
import com.qmth.sop.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -15,9 +17,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Api(tags = "质量监控分析Controller")
|
|
|
@RestController
|
|
@@ -40,6 +41,8 @@ public class QualityAnalyseReportController {
|
|
|
|
|
|
public static final String IN_FLUENCE_DEGREE_D_RATE_TOTAL = "influenceDegreeDRateTotal";
|
|
|
|
|
|
+ public static final String REASON_RATE_TOTAL = "reasonRateTotal";
|
|
|
+
|
|
|
@Resource
|
|
|
QualityAnalyseReportService qualityAnalyseReportService;
|
|
|
|
|
@@ -61,7 +64,41 @@ public class QualityAnalyseReportController {
|
|
|
@RequestMapping(value = "/type/report", method = RequestMethod.POST)
|
|
|
@ApiResponses({ @ApiResponse(code = 200, message = "质量监控分析报表", response = QualityAnalyseReportBean.class) })
|
|
|
public Result typeReport(@ApiParam(value = "服务单元id", required = true) @RequestParam Long serviceId) {
|
|
|
- return ResultUtil.ok();
|
|
|
+ List<QualityAnalyseReportBean> qualityAnalyseReportBeanList = qualityAnalyseReportService.reasonQualityReport(
|
|
|
+ serviceId);
|
|
|
+ Integer total = qualityAnalyseReportBeanList.stream().mapToInt(s -> s.getReasonSum()).sum();
|
|
|
+ if (!CollectionUtils.isEmpty(qualityAnalyseReportBeanList)) {
|
|
|
+ Set<QualityProblemReasonEnum> qualityAnalyseReportBeanAddSet = new LinkedHashSet<>();
|
|
|
+ QualityProblemReasonEnum[] qualityProblemReasonEnums = QualityProblemReasonEnum.values();
|
|
|
+ for (QualityProblemReasonEnum q : qualityProblemReasonEnums) {
|
|
|
+ List<QualityAnalyseReportBean> tempList = qualityAnalyseReportBeanList.stream()
|
|
|
+ .filter(x -> q == x.getReason()).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(tempList)) {
|
|
|
+ qualityAnalyseReportBeanAddSet.add(q);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ qualityAnalyseReportBeanList.stream().peek(s -> {
|
|
|
+ s.setNull();
|
|
|
+ for (QualityProblemReasonEnum q : qualityProblemReasonEnums) {
|
|
|
+ if (q == s.getReason()) {
|
|
|
+ BigDecimal reasonRate = new BigDecimal(s.getReasonSum());
|
|
|
+ reasonRate = reasonRate.divide(new BigDecimal(total), 2, BigDecimal.ROUND_HALF_UP)
|
|
|
+ .multiply(SystemConstant.RATE).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ s.setReasonRate(reasonRate);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ qualityAnalyseReportBeanAddSet.stream()
|
|
|
+ .peek(s -> qualityAnalyseReportBeanList.add(new QualityAnalyseReportBean(s)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ Double reasonRateTotal = qualityAnalyseReportBeanList.stream().mapToDouble(s -> s.getReasonRate().doubleValue())
|
|
|
+ .sum();
|
|
|
+ return ResultUtil.ok(
|
|
|
+ new ImmutableMap.Builder<String, Object>().put(ResourceSecurityReportController.TOTAL, total)
|
|
|
+ .put(REASON_RATE_TOTAL, new BigDecimal(reasonRateTotal))
|
|
|
+ .put(ResourceSecurityReportController.RECORDS, qualityAnalyseReportBeanList).build());
|
|
|
}
|
|
|
|
|
|
/**
|