Browse Source

调整代码

Levi 3 years ago
parent
commit
228fe6640a

+ 6 - 4
src/main/java/com/ebei/screen/service/impl/ParkSystemServiceImpl.java

@@ -100,14 +100,14 @@ 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 params = null;
+                JSONObject xx = null;
                 try {
-                    JSONObject xx = mongoTemplate.findById(x, JSONObject.class, "parkQueue");
+                    xx = mongoTemplate.findById(x, JSONObject.class, "parkQueue");
                     if (xx == null) {
                         return;
                     }
                     Instant start = Instant.now();
-                    params = xx.getJSONObject("data");
+                    JSONObject params = xx.getJSONObject("data");
                     if (x.startsWith("parkInfo")) {
                         this.parkInfo(params);
                     } else if (x.startsWith("parkSpace")) {
@@ -128,7 +128,9 @@ public class ParkSystemServiceImpl implements ParkSystemService {
                     Instant end = Instant.now();
                     log.info("当前执行:" + x + " 执行时间:" + Duration.between(start, end).toMillis() + "毫秒 当前可用线程数:" + RunnableUtils.getActiveNum());
                 } catch (Exception e) {
-                    log.info("执行队列出现异常:{} 参数:{}", e, params);
+                    // 删除异常数据
+                    mongoTemplate.remove(xx, "parkQueue");
+                    log.info("执行队列出现异常:{} 参数:{}", e, xx);
                 } finally {
                     countDownLatch.countDown();
                 }