|
@@ -3,16 +3,14 @@ package cn.com.qmth.stmms.ms.marking.service;
|
|
|
import cn.com.qmth.stmms.ms.core.cache.ParamCache;
|
|
|
import cn.com.qmth.stmms.ms.core.domain.Level;
|
|
|
import cn.com.qmth.stmms.ms.core.domain.task.MarkTaskLevel;
|
|
|
+import cn.com.qmth.stmms.ms.core.domain.task.MarkTaskRoughLevel;
|
|
|
import cn.com.qmth.stmms.ms.core.domain.user.MarkUser;
|
|
|
-import cn.com.qmth.stmms.ms.core.repository.LevelRepo;
|
|
|
import cn.com.qmth.stmms.ms.core.repository.MarkUserRepo;
|
|
|
+import cn.com.qmth.stmms.ms.marking.service.arbitration.ArbitrationService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.DoubleStream;
|
|
|
import java.util.stream.Stream;
|
|
@@ -26,17 +24,23 @@ public class DetermineLevelService {
|
|
|
|
|
|
public enum DeterType {
|
|
|
/**
|
|
|
- * 多数
|
|
|
+ * 过半定档
|
|
|
*/
|
|
|
MAJORITY,
|
|
|
/**
|
|
|
* 权重
|
|
|
*/
|
|
|
- WEIGHT
|
|
|
+ WEIGHT,
|
|
|
+ /**
|
|
|
+ * 仲裁
|
|
|
+ */
|
|
|
+ ARBITRATE,
|
|
|
+ /**
|
|
|
+ * 打回
|
|
|
+ */
|
|
|
+ REJECT
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- private LevelRepo levelRepo;
|
|
|
@Autowired
|
|
|
private MarkUserRepo markUserRepo;
|
|
|
|
|
@@ -50,18 +54,20 @@ public class DetermineLevelService {
|
|
|
// 是否过半定档(1:是)
|
|
|
boolean majority = Optional.ofNullable(ParamCache.levelConfigMap.get(String.valueOf(String.valueOf(workId))).getMajority()).orElse(1) == 1;
|
|
|
DeterResult majorityResult = null;
|
|
|
- DeterResult weightResult = null;
|
|
|
+ DeterResult weightResult;
|
|
|
+ // 开启过半定档
|
|
|
if (majority) {
|
|
|
MarkTaskLevel[] tasks = markTasks.toArray(new MarkTaskLevel[0]);
|
|
|
majorityResult = calcMajority(tasks);
|
|
|
}
|
|
|
- weightResult = calcWeight(workId, levels, markTasks);
|
|
|
-
|
|
|
+ // 有过半档位
|
|
|
if (majorityResult != null) {
|
|
|
// 是否取优(过半定档和权重,取最优值)
|
|
|
boolean takeBest = Optional.ofNullable(ParamCache.levelConfigMap.get(String.valueOf(String.valueOf(workId))).getTakeBest()).orElse(1) == 1;
|
|
|
if (takeBest) {
|
|
|
Map<String, Integer> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, Level::getLevelValue));
|
|
|
+
|
|
|
+ weightResult = calcWeight(workId, levels, markTasks);
|
|
|
// 取优
|
|
|
int majorityLevelValue = levelMap.get(majorityResult.getResult());
|
|
|
int weightLevelValue = levelMap.get(weightResult.getResult());
|
|
@@ -74,8 +80,29 @@ public class DetermineLevelService {
|
|
|
} else {
|
|
|
return majorityResult;
|
|
|
}
|
|
|
- } else {
|
|
|
- return weightResult;
|
|
|
+ }
|
|
|
+ // 无过半档位或者未开启过半定档
|
|
|
+ else {
|
|
|
+ // 仲裁档位差
|
|
|
+ int deviation = ParamCache.levelConfigMap.get(String.valueOf(workId)).getDeviation();
|
|
|
+ // 超过仲裁档位差
|
|
|
+ Set<Integer> sources = markTasks.stream().map(MarkTaskLevel::getLevelValue).collect(Collectors.toSet());
|
|
|
+ if (ArbitrationService.overDeviation(deviation, sources)) {
|
|
|
+ boolean autoCallBack = ParamCache.levelConfigMap.get(String.valueOf(workId)).getAutoCallback() == 1;
|
|
|
+ // 开启自动打回
|
|
|
+ if (autoCallBack) {
|
|
|
+ int cumulateError = ParamCache.levelConfigMap.get(String.valueOf(workId)).getCumulativeError();
|
|
|
+ List<String> markerIds = ArbitrationService.calcCumulateLevel(cumulateError, markTasks);
|
|
|
+ // 不是所有评卷员累计误差都大于累计误差值
|
|
|
+ if (markerIds.size() != markTasks.size()) {
|
|
|
+ return new DeterResult(null, DeterType.REJECT, markerIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 打回科组长
|
|
|
+ return new DeterResult(null, DeterType.ARBITRATE);
|
|
|
+ } else {
|
|
|
+ return calcWeight(workId, levels, markTasks);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -99,10 +126,11 @@ public class DetermineLevelService {
|
|
|
double[] weights = new double[tasks.length];
|
|
|
for (int i = 0; i < tasks.length; i++) {
|
|
|
String levelResult = tasks[i].getResult();
|
|
|
- Level level = levels.stream().filter(m -> m.getCode().equals(levelResult)).findFirst().orElse(null);
|
|
|
- if (level == null) {
|
|
|
+ Optional<Level> levelOptional = levels.stream().filter(m -> m.getCode().equals(levelResult)).findFirst();
|
|
|
+ if (!levelOptional.isPresent()) {
|
|
|
throw new RuntimeException("无此档位");
|
|
|
}
|
|
|
+ Level level = levelOptional.get();
|
|
|
MarkUser marker = markUserRepo.findOne(tasks[i].getMarkerId());
|
|
|
double markerWeight = marker.getWeight();
|
|
|
values[i] = level.getWeight() * markerWeight;
|
|
@@ -110,7 +138,10 @@ public class DetermineLevelService {
|
|
|
}
|
|
|
int avg = (int) Math.round(DoubleStream.of(values).sum() / DoubleStream.of(weights).sum());
|
|
|
Optional<Level> levelOptional = levels.stream().filter(o -> o.getMaxScore() >= avg && o.getMinScore() <= avg).findFirst();
|
|
|
- Level level = levelOptional.orElse(null);
|
|
|
+ Level level = null;
|
|
|
+ if (levelOptional.isPresent()) {
|
|
|
+ level = levelOptional.get();
|
|
|
+ }
|
|
|
if (level == null) {
|
|
|
levels = levels.stream().sorted(Comparator.comparing(Level::getMaxScore).reversed()).collect(Collectors.toList());
|
|
|
if (avg > levels.get(0).getMaxScore()) {
|
|
@@ -136,7 +167,7 @@ public class DetermineLevelService {
|
|
|
.collect(Collectors.groupingBy(MarkTaskLevel::getResult, Collectors.counting()))
|
|
|
.entrySet()
|
|
|
.stream()
|
|
|
- .max(Comparator.comparing(Map.Entry::getValue));
|
|
|
+ .max(Map.Entry.comparingByValue());
|
|
|
if (optional.isPresent()) {
|
|
|
Map.Entry<String, Long> entry = optional.get();
|
|
|
if (entry.getValue() > tasks.length / 2) {
|
|
@@ -150,12 +181,19 @@ public class DetermineLevelService {
|
|
|
class DeterResult {
|
|
|
private String result;
|
|
|
private DetermineLevelService.DeterType deterType;
|
|
|
+ private List<String> rejectTasks;
|
|
|
|
|
|
public DeterResult(String result, DetermineLevelService.DeterType deterType) {
|
|
|
this.result = result;
|
|
|
this.deterType = deterType;
|
|
|
}
|
|
|
|
|
|
+ public DeterResult(String result, DetermineLevelService.DeterType deterType, List<String> rejectTasks) {
|
|
|
+ this.result = result;
|
|
|
+ this.deterType = deterType;
|
|
|
+ this.rejectTasks = rejectTasks;
|
|
|
+ }
|
|
|
+
|
|
|
public String getResult() {
|
|
|
return result;
|
|
|
}
|
|
@@ -171,4 +209,12 @@ class DeterResult {
|
|
|
public void setDeterType(DetermineLevelService.DeterType deterType) {
|
|
|
this.deterType = deterType;
|
|
|
}
|
|
|
+
|
|
|
+ public List<String> getRejectTasks() {
|
|
|
+ return rejectTasks;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setRejectTasks(List<String> rejectTasks) {
|
|
|
+ this.rejectTasks = rejectTasks;
|
|
|
+ }
|
|
|
}
|