|
@@ -1,13 +1,8 @@
|
|
package cn.com.qmth.stmms.ms.marking.service.arbitration;
|
|
package cn.com.qmth.stmms.ms.marking.service.arbitration;
|
|
|
|
|
|
|
|
|
|
-import java.util.Comparator;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Optional;
|
|
|
|
import java.util.OptionalInt;
|
|
import java.util.OptionalInt;
|
|
-import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.IntStream;
|
|
import java.util.stream.IntStream;
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 仲裁
|
|
* 仲裁
|
|
@@ -17,23 +12,24 @@ public class ArbitrationService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 仲裁,如果两两差值大于误差,或不存在相同数大于半数,就判定仲裁,返回true
|
|
* 仲裁,如果两两差值大于误差,或不存在相同数大于半数,就判定仲裁,返回true
|
|
|
|
+ *
|
|
* @param deviation 误差
|
|
* @param deviation 误差
|
|
* @param sources
|
|
* @param sources
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static boolean arbitrate(int deviation, int...sources){
|
|
|
|
|
|
+ public static boolean arbitrate(int deviation, int... sources) {
|
|
|
|
|
|
- int[] values = new int[(int)Math.pow(sources.length,2)];
|
|
|
|
|
|
+ int[] values = new int[(int) Math.pow(sources.length, 2)];
|
|
int i = 0;
|
|
int i = 0;
|
|
- for(int source : sources){
|
|
|
|
- for(int inner : sources){
|
|
|
|
|
|
+ for (int source : sources) {
|
|
|
|
+ for (int inner : sources) {
|
|
values[i] = Math.abs(source - inner);
|
|
values[i] = Math.abs(source - inner);
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
OptionalInt optionalInt = IntStream.of(values).max();
|
|
OptionalInt optionalInt = IntStream.of(values).max();
|
|
int max = optionalInt.orElse(0);
|
|
int max = optionalInt.orElse(0);
|
|
- if(max > deviation){
|
|
|
|
|
|
+ if (max >= deviation) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|