|
@@ -1,15 +1,17 @@
|
|
|
package cn.com.qmth.stmms.ms.commons.constant;
|
|
|
|
|
|
+import cn.com.qmth.stmms.ms.commons.threadPool.MyThreadPool;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.concurrent.Callable;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -26,6 +28,9 @@ public class ArbitrateCallback {
|
|
|
public int MAX_DISTANCE = 2 //仲裁档位
|
|
|
, SUM_DISTANCE = 2 * 2 + 1;//最大落差档位和
|
|
|
|
|
|
+ @Autowired
|
|
|
+ MyThreadPool myThreadPool;
|
|
|
+
|
|
|
/**
|
|
|
* 自动打回算法
|
|
|
*
|
|
@@ -33,15 +38,21 @@ public class ArbitrateCallback {
|
|
|
* @param maxDistance
|
|
|
* @return
|
|
|
*/
|
|
|
- @Async
|
|
|
- public List<Distance> judge(Map<Long, String> levelsMap, int maxDistance, ArbitrateResult ar) {
|
|
|
- MAX_DISTANCE = maxDistance;
|
|
|
- SUM_DISTANCE = MAX_DISTANCE * 2 + 1;
|
|
|
- List<Distance> result = judge(levelsMap, ar);
|
|
|
- if (Objects.nonNull(result)) {
|
|
|
- LOGGER.info("LEVELS:{},设置的隔档档位为:{},设置的最大落差值和为:{},需要打回的档位为:{}", levelsMap.values().stream().collect(Collectors.toList()), MAX_DISTANCE, SUM_DISTANCE, JSONObject.toJSONString(result));
|
|
|
- }
|
|
|
- return result;
|
|
|
+ public void judge(Map<Long, String> levelsMap, int maxDistance, ArbitrateResult ar) {
|
|
|
+ myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<List<Distance>>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Distance> call() throws Exception {
|
|
|
+ MAX_DISTANCE = maxDistance;
|
|
|
+ SUM_DISTANCE = MAX_DISTANCE * 2 + 1;
|
|
|
+ List<Distance> result = judge(levelsMap, ar);
|
|
|
+ if (Objects.nonNull(result)) {
|
|
|
+ LOGGER.info("LEVELS:{},设置的隔档档位为:{},设置的最大落差值和为:{},需要打回的档位为:{}", levelsMap.values().stream().collect(Collectors.toList()), MAX_DISTANCE, SUM_DISTANCE, JSONObject.toJSONString(result));
|
|
|
+ }
|
|
|
+ ar.callback(result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -52,22 +63,28 @@ public class ArbitrateCallback {
|
|
|
* @param ar
|
|
|
* @return
|
|
|
*/
|
|
|
- @Async
|
|
|
- public List<Distance> judge(Map<Long, String> levelsMap, String paperLevel, ArbitrateResult ar) {
|
|
|
- List<Distance> result = new ArrayList<>();
|
|
|
- char p = paperLevel.charAt(0);
|
|
|
- levelsMap.forEach((k, v) -> {
|
|
|
- char c = v.charAt(0);
|
|
|
- Distance d = new Distance(c, k);
|
|
|
- d.distance = Math.abs(c - p);
|
|
|
- result.add(d);
|
|
|
- LOGGER.info("计算档位偏差值:{}", JSONObject.toJSONString(d));
|
|
|
+// @Async
|
|
|
+ public void judge(Map<Long, String> levelsMap, String paperLevel, ArbitrateResult ar) {
|
|
|
+ myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<List<Distance>>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Distance> call() throws Exception {
|
|
|
+ List<Distance> result = new ArrayList<>();
|
|
|
+ char p = paperLevel.charAt(0);
|
|
|
+ levelsMap.forEach((k, v) -> {
|
|
|
+ char c = v.charAt(0);
|
|
|
+ Distance d = new Distance(c, k);
|
|
|
+ d.distance = Math.abs(c - p);
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ ar.callback(result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
});
|
|
|
- if (Objects.nonNull(result)) {
|
|
|
- LOGGER.info("LEVELS:{},paperLevel为:{},档位落差为:{}", levelsMap.values().stream().collect(Collectors.toList()), paperLevel, JSONObject.toJSONString(result));
|
|
|
- }
|
|
|
- ar.callback(result);
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -93,7 +110,6 @@ public class ArbitrateCallback {
|
|
|
}
|
|
|
LOGGER.info("计算档位最大落差档位和档位和:{}", JSONObject.toJSONString(d));
|
|
|
});
|
|
|
- ar.callback(result);
|
|
|
return result;
|
|
|
}
|
|
|
|