|
@@ -5,8 +5,8 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -20,67 +20,45 @@ import java.util.stream.Collectors;
|
|
public class ArbitrateCallback {
|
|
public class ArbitrateCallback {
|
|
private static Logger LOGGER = LoggerFactory.getLogger(ArbitrateCallback.class);
|
|
private static Logger LOGGER = LoggerFactory.getLogger(ArbitrateCallback.class);
|
|
|
|
|
|
- public static char[] LEVELS = null;//各评卷员评选的档位数组
|
|
|
|
-
|
|
|
|
public static int MAX_DISTANCE = 2 //仲裁档位
|
|
public static int MAX_DISTANCE = 2 //仲裁档位
|
|
, SUM_DISTANCE = 2 * 2 + 1;//最大落差档位和
|
|
, SUM_DISTANCE = 2 * 2 + 1;//最大落差档位和
|
|
|
|
|
|
/**
|
|
/**
|
|
* 自动打回算法
|
|
* 自动打回算法
|
|
*
|
|
*
|
|
- * @param levelList
|
|
|
|
|
|
+ * @param levelsMap
|
|
* @param maxDistance
|
|
* @param maxDistance
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static List<String> judge(List<String> levelList, int maxDistance) {
|
|
|
|
|
|
+ public static List<Distance> judge(Map<Long, String> levelsMap, int maxDistance) {
|
|
MAX_DISTANCE = maxDistance;
|
|
MAX_DISTANCE = maxDistance;
|
|
SUM_DISTANCE = MAX_DISTANCE * 2 + 1;
|
|
SUM_DISTANCE = MAX_DISTANCE * 2 + 1;
|
|
- List<String> resultList = null;
|
|
|
|
- Collections.sort(levelList);
|
|
|
|
- LEVELS = new char[levelList.size()];
|
|
|
|
- for (int i = 0; i < levelList.size(); i++) {
|
|
|
|
- LEVELS[i] = levelList.get(i).charAt(0);
|
|
|
|
- }
|
|
|
|
- List<Distance> result = judge(LEVELS);
|
|
|
|
|
|
+ List<Distance> result = judge(levelsMap);
|
|
if (Objects.nonNull(result)) {
|
|
if (Objects.nonNull(result)) {
|
|
- resultList = result.stream().map(o -> String.valueOf(o.c)).collect(Collectors.toList());
|
|
|
|
- LOGGER.info("LEVELS:{},设置的隔档档位为:{},设置的最大落差值和为:{},需要打回的档位为:{}", LEVELS, MAX_DISTANCE, SUM_DISTANCE, JSONObject.toJSONString(result));
|
|
|
|
- }
|
|
|
|
- return resultList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 计算每个档位和试卷档位的落差
|
|
|
|
- *
|
|
|
|
- * @param levelList
|
|
|
|
- * @param paperLevel
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public static List<Distance> judge(List<String> levelList, String paperLevel) {
|
|
|
|
- List<Distance> result = null;
|
|
|
|
- Collections.sort(levelList);
|
|
|
|
- LEVELS = new char[levelList.size()];
|
|
|
|
- for (int i = 0; i < levelList.size(); i++) {
|
|
|
|
- LEVELS[i] = levelList.get(i).charAt(0);
|
|
|
|
|
|
+ LOGGER.info("LEVELS:{},设置的隔档档位为:{},设置的最大落差值和为:{},需要打回的档位为:{}", levelsMap.values().stream().collect(Collectors.toList()), MAX_DISTANCE, SUM_DISTANCE, JSONObject.toJSONString(result));
|
|
}
|
|
}
|
|
- result = judge(LEVELS, paperLevel);
|
|
|
|
- LOGGER.info("LEVELS:{},paperLevel为:{},档位落差为:{}", LEVELS, paperLevel, JSONObject.toJSONString(result));
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 计算档位偏差值
|
|
* 计算档位偏差值
|
|
*
|
|
*
|
|
- * @param levels
|
|
|
|
|
|
+ * @param levelsMap
|
|
|
|
+ * @param paperLevel
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static List<Distance> judge(char[] levels, String paperLevel) {
|
|
|
|
|
|
+ public static List<Distance> judge(Map<Long, String> levelsMap, String paperLevel) {
|
|
List<Distance> result = new ArrayList<>();
|
|
List<Distance> result = new ArrayList<>();
|
|
char p = paperLevel.charAt(0);
|
|
char p = paperLevel.charAt(0);
|
|
- for (char c : levels) {
|
|
|
|
- Distance d = new Distance(c);
|
|
|
|
|
|
+ levelsMap.forEach((k, v) -> {
|
|
|
|
+ char c = v.charAt(0);
|
|
|
|
+ Distance d = new Distance(c, k);
|
|
d.distance = Math.abs(c - p);
|
|
d.distance = Math.abs(c - p);
|
|
result.add(d);
|
|
result.add(d);
|
|
|
|
+ LOGGER.info("计算档位偏差值:{}", JSONObject.toJSONString(d));
|
|
|
|
+ });
|
|
|
|
+ if (Objects.nonNull(result)) {
|
|
|
|
+ LOGGER.info("LEVELS:{},paperLevel为:{},档位落差为:{}", levelsMap.values().stream().collect(Collectors.toList()), paperLevel, JSONObject.toJSONString(result));
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -88,40 +66,44 @@ public class ArbitrateCallback {
|
|
/**
|
|
/**
|
|
* 计算档位最大落差档位和档位和
|
|
* 计算档位最大落差档位和档位和
|
|
*
|
|
*
|
|
- * @param levels
|
|
|
|
|
|
+ * @param levelsMap
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static List<Distance> judge(char[] levels) {
|
|
|
|
|
|
+ public static List<Distance> judge(Map<Long, String> levelsMap) {
|
|
List<Distance> result = new ArrayList<>();
|
|
List<Distance> result = new ArrayList<>();
|
|
- for (char c : levels) {
|
|
|
|
- Distance d = new Distance(c);
|
|
|
|
- for (char other : levels) {
|
|
|
|
|
|
+ levelsMap.forEach((k, v) -> {
|
|
|
|
+ char c = v.charAt(0);
|
|
|
|
+ Distance d = new Distance(c, k);
|
|
|
|
+ levelsMap.forEach((k1, v1) -> {
|
|
|
|
+ char other = v1.charAt(0);
|
|
int distance = Math.abs(c - other);
|
|
int distance = Math.abs(c - other);
|
|
d.max = Math.max(d.max, distance);
|
|
d.max = Math.max(d.max, distance);
|
|
d.sum += distance;
|
|
d.sum += distance;
|
|
- }
|
|
|
|
|
|
+ });
|
|
if (d.max >= MAX_DISTANCE && d.sum >= SUM_DISTANCE) {
|
|
if (d.max >= MAX_DISTANCE && d.sum >= SUM_DISTANCE) {
|
|
result.add(d);
|
|
result.add(d);
|
|
}
|
|
}
|
|
- LOGGER.info("档位:{}", JSONObject.toJSONString(d));
|
|
|
|
- }
|
|
|
|
|
|
+ LOGGER.info("计算档位最大落差档位和档位和:{}", JSONObject.toJSONString(d));
|
|
|
|
+ });
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 档位计算类[档位,最大档位落差,最大档位落差和,档位偏差值]
|
|
* 档位计算类[档位,最大档位落差,最大档位落差和,档位偏差值]
|
|
*/
|
|
*/
|
|
- static class Distance {
|
|
|
|
|
|
+ public static class Distance {
|
|
char c;
|
|
char c;
|
|
int max;
|
|
int max;
|
|
int sum;
|
|
int sum;
|
|
int distance;
|
|
int distance;
|
|
|
|
+ Long markId;
|
|
|
|
|
|
- public Distance(char c) {
|
|
|
|
|
|
+ public Distance(char c, Long markId) {
|
|
this.c = c;
|
|
this.c = c;
|
|
this.max = 0;
|
|
this.max = 0;
|
|
this.sum = 0;
|
|
this.sum = 0;
|
|
this.distance = 0;
|
|
this.distance = 0;
|
|
|
|
+ this.markId = markId;
|
|
}
|
|
}
|
|
|
|
|
|
public char getC() {
|
|
public char getC() {
|
|
@@ -155,5 +137,13 @@ public class ArbitrateCallback {
|
|
public void setDistance(int distance) {
|
|
public void setDistance(int distance) {
|
|
this.distance = distance;
|
|
this.distance = distance;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public Long getMarkId() {
|
|
|
|
+ return markId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setMarkId(Long markId) {
|
|
|
|
+ this.markId = markId;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|