|
@@ -0,0 +1,75 @@
|
|
|
+package com.qmth.sop.server.api;
|
|
|
+
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
+import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.sop.business.bean.report.FlowMsgReferReportBean;
|
|
|
+import com.qmth.sop.business.service.FlowMsgReferReportService;
|
|
|
+import com.qmth.sop.common.contant.SystemConstant;
|
|
|
+import com.qmth.sop.common.enums.MessageTypeEnum;
|
|
|
+import com.qmth.sop.common.util.Result;
|
|
|
+import com.qmth.sop.common.util.ResultUtil;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+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;
|
|
|
+
|
|
|
+@Api(tags = "流程检查统计Controller")
|
|
|
+@RestController
|
|
|
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_FLOW_MSG_REFER)
|
|
|
+public class FlowMsgReferReportController {
|
|
|
+
|
|
|
+ public static final String TOTAL = "total";
|
|
|
+
|
|
|
+ public static final String READ_RATE = "readRate";
|
|
|
+
|
|
|
+ public static final String UN_READ_RATE = "unReadRate";
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ FlowMsgReferReportService flowMsgReferReportService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "大区经理查阅统计")
|
|
|
+ @RequestMapping(value = "/area_manager/report", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({ @ApiResponse(code = 200, message = "流程查阅提醒报表", response = FlowMsgReferReportBean.class) })
|
|
|
+ public Result areaManagerCountReport(@ApiParam(value = "服务单元id", required = true) @RequestParam Long serviceId) {
|
|
|
+ return ResultUtil.ok(
|
|
|
+ this.calculateRate(flowMsgReferReportService.FlowMsgReport(serviceId, MessageTypeEnum.OFFICE_SOP)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "区域协调人查阅统计")
|
|
|
+ @RequestMapping(value = "/regional_coordinator/report", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({ @ApiResponse(code = 200, message = "流程查阅提醒报表", response = FlowMsgReferReportBean.class) })
|
|
|
+ public Result regionalCoordinatorCountReport(
|
|
|
+ @ApiParam(value = "服务单元id", required = true) @RequestParam Long serviceId) {
|
|
|
+ return ResultUtil.ok(
|
|
|
+ this.calculateRate(flowMsgReferReportService.FlowMsgReport(serviceId, MessageTypeEnum.CLOUD_MARK_SOP)));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算比率
|
|
|
+ *
|
|
|
+ * @param flowMsgReferReportBeanList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ protected Map<String, Object> calculateRate(List<FlowMsgReferReportBean> flowMsgReferReportBeanList) {
|
|
|
+ Integer sum = flowMsgReferReportBeanList.stream().mapToInt(s -> s.getSum()).sum();
|
|
|
+ Integer readSum = flowMsgReferReportBeanList.stream().mapToInt(s -> s.getReadMsg()).sum();
|
|
|
+ Integer unReadSum = flowMsgReferReportBeanList.stream().mapToInt(s -> s.getUnReadMsg()).sum();
|
|
|
+ BigDecimal readRate = new BigDecimal(readSum);
|
|
|
+ BigDecimal unReadRate = new BigDecimal(unReadSum);
|
|
|
+ if (Objects.nonNull(sum) && sum.intValue() > 0) {
|
|
|
+ readRate = readRate.divide(new BigDecimal(sum), 2, BigDecimal.ROUND_HALF_UP).multiply(SystemConstant.RATE)
|
|
|
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ unReadRate = unReadRate.divide(new BigDecimal(sum), 2, BigDecimal.ROUND_HALF_UP)
|
|
|
+ .multiply(SystemConstant.RATE).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ return ImmutableMap.of(TOTAL, sum, READ_RATE, readRate, UN_READ_RATE, unReadRate,
|
|
|
+ ResourceSecurityReportController.RECORDS, flowMsgReferReportBeanList);
|
|
|
+ }
|
|
|
+}
|