|
@@ -1,11 +1,25 @@
|
|
|
package cn.com.qmth.stmms.ms.admin.api;
|
|
|
|
|
|
+import cn.com.qmth.stmms.ms.commons.utils.SqlUtil;
|
|
|
+import cn.com.qmth.stmms.ms.core.domain.Level;
|
|
|
+import cn.com.qmth.stmms.ms.core.domain.MarkStage;
|
|
|
+import cn.com.qmth.stmms.ms.core.domain.task.MarkTask;
|
|
|
+import cn.com.qmth.stmms.ms.core.repository.LevelRepo;
|
|
|
+import cn.com.qmth.stmms.ms.core.repository.MarkTaskRepo;
|
|
|
import cn.com.qmth.stmms.ms.core.vo.Subject;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
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.persistence.criteria.Predicate;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @Description: 质量分析报表controller
|
|
|
* @Param:
|
|
@@ -18,6 +32,15 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("api/quality")
|
|
|
public class QualityAnalyseController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LevelRepo levelRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SqlUtil sqlUtil;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ MarkTaskRepo markTaskRepo;
|
|
|
+
|
|
|
/**
|
|
|
* 档位占比报表
|
|
|
*
|
|
@@ -29,17 +52,78 @@ public class QualityAnalyseController {
|
|
|
*/
|
|
|
// @ApiOperation(value = "档位占比报表接口")
|
|
|
@RequestMapping(value = "levelsPropReport", method = RequestMethod.GET)
|
|
|
- public void levelsPropReport(
|
|
|
-// @ApiParam(value = "workId", required = true)
|
|
|
+ public Object levelsPropReport(
|
|
|
@RequestParam Long workId,
|
|
|
// @ApiParam(value = "科目", required = true)
|
|
|
- @RequestParam Subject subject,
|
|
|
+ @RequestParam(required = false) Subject subject,
|
|
|
// @ApiParam(value = "考点", required = true)
|
|
|
- @RequestParam String areaCode,
|
|
|
+ @RequestParam(required = false) String areaCode,
|
|
|
// @ApiParam(value = "开始时间", required = false)
|
|
|
@RequestParam(required = false) String startTime,
|
|
|
-// @ApiParam(value = "结束时间", required = false)
|
|
|
@RequestParam(required = false) String endTime) {
|
|
|
+ List fList = new ArrayList();
|
|
|
+ List<Level> levels = levelRepo.findByWorkId(workId);
|
|
|
+ levels.forEach(l -> {
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
+ sql.append(" SELECT ");
|
|
|
+ sql.append(" mu.id markerId, ");
|
|
|
+ sql.append(" mu.name markerName, ");
|
|
|
+ sql.append(" SUM(IF(mt.result = '" + l.getCode() + "', 1, 0)) levelCount, ");
|
|
|
+ sql.append(" COUNT(1) total ");
|
|
|
+ sql.append(" FROM ");
|
|
|
+ sql.append(" mark_user mu ");
|
|
|
+ sql.append(" LEFT JOIN ");
|
|
|
+ sql.append(" (SELECT ");
|
|
|
+ sql.append(" m.* ");
|
|
|
+ sql.append(" FROM ");
|
|
|
+ sql.append(" mark_task m ");
|
|
|
+ sql.append(" left join paper p on m.paper_id = p.id ");
|
|
|
+ sql.append(" WHERE ");
|
|
|
+ sql.append(" stage = " + MarkStage.LEVEL.ordinal() + " ");
|
|
|
+ if (!Objects.isNull(areaCode)) {
|
|
|
+ sql.append(" and p.area_code = " + areaCode);
|
|
|
+ }
|
|
|
+ if (!Objects.isNull(startTime)) {
|
|
|
+ sql.append(" and m.updated_on >= '" + startTime + "'");
|
|
|
+ }
|
|
|
+ if (!Objects.isNull(endTime)) {
|
|
|
+ sql.append(" and m.updated_on <= '" + endTime + "'");
|
|
|
+ }
|
|
|
+ sql.append(" ) mt ON mu.work_id = mt.work_id ");
|
|
|
+ sql.append(" AND mu.subject = mt.subject ");
|
|
|
+ sql.append(" AND mu.id = mt.marker_id ");
|
|
|
+ sql.append(" WHERE ");
|
|
|
+ sql.append(" mu.work_id = " + workId + " AND mu.subject = '" + subject.toString() + "' ");
|
|
|
+ sql.append(" AND mu.role = 'MARKER' ");
|
|
|
+ sql.append(" GROUP BY mu.id , mu.name ");
|
|
|
+ sql.append(" ORDER BY mu.id ");
|
|
|
+
|
|
|
+ List list = sqlUtil.execSqlForMap(sql.toString());
|
|
|
+ Map map = new HashMap();
|
|
|
+ List<Map> data = new ArrayList();
|
|
|
+ map.put("name", l.getCode());
|
|
|
+ for (Object o : list) {
|
|
|
+ Map m = (Map) o;
|
|
|
+ //该档任务数
|
|
|
+ BigDecimal levelCount = BigDecimal.valueOf(Long.parseLong(m.get("levelCount").toString()));
|
|
|
+ //总任务数
|
|
|
+ BigDecimal total = BigDecimal.valueOf(Long.parseLong(m.get("total").toString()));
|
|
|
+ //占比
|
|
|
+ BigDecimal propBig = BigDecimal.ZERO.compareTo(total) == 0 ? BigDecimal.ZERO : levelCount.divide(total, 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double prop = propBig.doubleValue();
|
|
|
+ Map temp = new HashMap();
|
|
|
+ temp.put("markerId", m.get("markerId"));
|
|
|
+ temp.put("markerName", m.get("markerName"));
|
|
|
+ temp.put("prop", prop * 100);
|
|
|
+ data.add(temp);
|
|
|
+ }
|
|
|
+ //排序
|
|
|
+ Collections.sort(data, Comparator.comparing(o -> o.get("markerId").toString()));
|
|
|
+ map.put("data", data);
|
|
|
+ fList.add(map);
|
|
|
+ });
|
|
|
+
|
|
|
+ return fList;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -51,21 +135,48 @@ public class QualityAnalyseController {
|
|
|
* @param areaCode
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
+ * @return
|
|
|
*/
|
|
|
// @ApiOperation(value = "打回次数报表接口")
|
|
|
@RequestMapping(value = "callbackReport", method = RequestMethod.GET)
|
|
|
- public void callbackReport(
|
|
|
+ public List callbackReport(
|
|
|
// @ApiParam(value = "workId", required = true)
|
|
|
@RequestParam Long workId,
|
|
|
-// @ApiParam(value = "科目", required = true)
|
|
|
- @RequestParam Subject subject,
|
|
|
-// @ApiParam(value = "考点", required = true)
|
|
|
- @RequestParam String areaCode,
|
|
|
+// @ApiParam(value = "科目", required = false)
|
|
|
+ @RequestParam(required = false) Subject subject,
|
|
|
+// @ApiParam(value = "考点", required = false)
|
|
|
+ @RequestParam(required = false) String areaCode,
|
|
|
// @ApiParam(value = "开始时间", required = false)
|
|
|
@RequestParam(required = false) String startTime,
|
|
|
// @ApiParam(value = "结束时间", required = false)
|
|
|
@RequestParam(required = false) String endTime) {
|
|
|
-
|
|
|
+ List list = null;
|
|
|
+ Specification<MarkTask> specification = (root, query, builder) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(builder.equal(root.get("workId"), workId));
|
|
|
+ if (Objects.nonNull(subject)) {
|
|
|
+ predicates.add(builder.equal(root.get("subject"), subject));
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(areaCode)) {
|
|
|
+ predicates.add(builder.equal(root.get("paper").get("areaCode"), areaCode));
|
|
|
+ }
|
|
|
+ return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+ List<MarkTask> markTasks = markTaskRepo.findAll(specification);
|
|
|
+ if (Objects.nonNull(markTasks) && markTasks.size() > 0) {
|
|
|
+ Set<Long> markerIdSet = markTasks.stream().map(o -> o.getMarkerId()).collect(Collectors.toSet());
|
|
|
+ Object o = StringUtils.join(markerIdSet.toArray(), ",");
|
|
|
+ String sql = new StringBuffer("select t.create_user_name as userName, count(t.create_user_id) as sumCount from mark_log t where t.oper_type BETWEEN 10 and 12 and t.create_user_id in (").append(o).append(")").toString();
|
|
|
+ if (Objects.nonNull(startTime)) {
|
|
|
+ sql = sqlUtil.sqlConditionAnd(sql, new String[]{"t.create_time"}, new String[]{startTime}, new String[]{">="});
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(endTime)) {
|
|
|
+ sql = sqlUtil.sqlConditionAnd(sql, new String[]{"t.create_time"}, new String[]{endTime}, new String[]{"<="});
|
|
|
+ }
|
|
|
+ sql = sqlUtil.sqlGroupBy(sql, "t.create_user_name");
|
|
|
+ list = sqlUtil.execSqlForMap(sql);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -83,9 +194,9 @@ public class QualityAnalyseController {
|
|
|
// @ApiParam(value = "workId", required = true)
|
|
|
@RequestParam Long workId,
|
|
|
// @ApiParam(value = "科目", required = true)
|
|
|
- @RequestParam Subject subject,
|
|
|
+ @RequestParam(required = false) Subject subject,
|
|
|
// @ApiParam(value = "考点", required = true)
|
|
|
- @RequestParam String areaCode,
|
|
|
+ @RequestParam(required = false) String areaCode,
|
|
|
// @ApiParam(value = "开始时间", required = false)
|
|
|
@RequestParam(required = false) String startTime,
|
|
|
// @ApiParam(value = "结束时间", required = false)
|