|
@@ -100,33 +100,38 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
List<String> ids = (List<String>) (List) data.subList(0, Integer.min(data.size(), size));
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(Integer.min(data.size(), size));
|
|
|
ids.forEach(x -> RunnableUtils.start(() -> {
|
|
|
- JSONObject xx = mongoTemplate.findById(x, JSONObject.class, "parkQueue");
|
|
|
- if (xx == null) {
|
|
|
+ JSONObject params = null;
|
|
|
+ try {
|
|
|
+ JSONObject xx = mongoTemplate.findById(x, JSONObject.class, "parkQueue");
|
|
|
+ if (xx == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Instant start = Instant.now();
|
|
|
+ params = xx.getJSONObject("data");
|
|
|
+ if (x.startsWith("parkInfo")) {
|
|
|
+ this.parkInfo(params);
|
|
|
+ } else if (x.startsWith("parkSpace")) {
|
|
|
+ this.parkSpace(params);
|
|
|
+ } else if (x.startsWith("parkIn")) {
|
|
|
+ this.parkIn(params);
|
|
|
+ } else if (x.startsWith("parkOut")) {
|
|
|
+ this.parkOut(params);
|
|
|
+ } else if (x.startsWith("parkOrder")) {
|
|
|
+ this.parkOrder(params);
|
|
|
+ } else if (x.startsWith("parkCharge")) {
|
|
|
+ this.parkCharge(params);
|
|
|
+ } else if (x.startsWith("parkServiceInfo")) {
|
|
|
+ this.parkServiceInfo(params);
|
|
|
+ }
|
|
|
+ // 处理完成删除当前document
|
|
|
+ mongoTemplate.remove(xx, "parkQueue");
|
|
|
+ Instant end = Instant.now();
|
|
|
+ log.info("当前执行:" + x + " 执行时间:" + Duration.between(start, end).toMillis() + "毫秒 当前可用线程数:" + RunnableUtils.getActiveNum());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("执行队列出现异常:{} 参数:{}", e, params);
|
|
|
+ } finally {
|
|
|
countDownLatch.countDown();
|
|
|
- return;
|
|
|
}
|
|
|
- Instant start = Instant.now();
|
|
|
- JSONObject params = xx.getJSONObject("data");
|
|
|
- if (x.startsWith("parkInfo")) {
|
|
|
- this.parkInfo(params);
|
|
|
- } else if (x.startsWith("parkSpace")) {
|
|
|
- this.parkSpace(params);
|
|
|
- } else if (x.startsWith("parkIn")) {
|
|
|
- this.parkIn(params);
|
|
|
- } else if (x.startsWith("parkOut")) {
|
|
|
- this.parkOut(params);
|
|
|
- } else if (x.startsWith("parkOrder")) {
|
|
|
- this.parkOrder(params);
|
|
|
- } else if (x.startsWith("parkCharge")) {
|
|
|
- this.parkCharge(params);
|
|
|
- } else if (x.startsWith("parkServiceInfo")) {
|
|
|
- this.parkServiceInfo(params);
|
|
|
- }
|
|
|
- // 处理完成删除当前document
|
|
|
- mongoTemplate.remove(xx, "parkQueue");
|
|
|
- countDownLatch.countDown();
|
|
|
- Instant end = Instant.now();
|
|
|
- log.info("当前执行:" + x + " 执行时间:" + Duration.between(start, end).toMillis() + "毫秒 当前可用线程数:" + RunnableUtils.getActiveNum());
|
|
|
}));
|
|
|
countDownLatch.await();
|
|
|
// 删除本批次处理的id
|