xiari před 9 měsíci
rodič
revize
665750a979

+ 1 - 1
ruoyi-server/ruoyi-server-hik/src/main/java/org/dromara/server/hik/event/handler/ConsumptionEventHandler.java

@@ -83,7 +83,7 @@ public class ConsumptionEventHandler implements HikEventHandler {
             // 直接应答成功
             String deptName = "";
             String reason = "";
-            BigDecimal balance = remoteBo.getBalance();
+            BigDecimal balance = BigDecimal.ZERO;
             BigDecimal consumeMoney = remoteBo.getConsumeMoney();
 
             return answerEvent(consumptionEvent, bussiRs, balance, consumeMoney, reason, deptName);

+ 47 - 21
ruoyi-server/ruoyi-server-hik/src/main/java/org/dromara/server/hik/service/impl/SendDeviceServiceImpl.java

@@ -671,13 +671,27 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
     public R<Void> deleteEmpFromDevice(Long termNo) {
         DeviceDto deviceDto = getDeviceDto(termNo);
         List<RemoteUserAccountVo> accountVoList = remoteUserAccountService.getUserAccountVoList();
-        accountVoList.forEach(p -> {
-            threadPoolTaskExecutor.execute(() -> {
-                EmpInfoDto empDto = getEmpInfoDto(p, true, false, false, false, false, false);
-                R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
-                log.info(result.getMsg());
-            });
-        });
+        // 50个 一组
+        if(CollectionUtil.isNotEmpty(accountVoList)){
+            // 50个一组循环一次
+            int size = accountVoList.size();
+            int count = size / 50;
+            for (int i = 0; i <= count; i++) {
+                int start = i * 50;
+                int end = start + 50;
+                if (end > size) {
+                    end = size;
+                }
+                List<RemoteUserAccountVo> subList = accountVoList.subList(start, end);
+                threadPoolTaskExecutor.execute(() -> {
+                    subList.forEach(p -> {
+                        EmpInfoDto empDto = getEmpInfoDto(p, true, false, false, false, false, false);
+                        R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
+                        log.info(result.getMsg());
+                    });
+                });
+            }
+        }
 
         return R.ok();
     }
@@ -847,21 +861,33 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
         if (CollectionUtil.isEmpty(accountVoList)) {
             return R.warn("没有要处理的人员");
         }
-
-        // 处理人员列表
-        accountVoList.forEach(p -> {
-            threadPoolTaskExecutor.execute(() -> {
-                try {//如果过了有效期,则直接删除 deleteUser为true
-                    ResultBoolean obtainBoolean = getResult(p);
-                    // deleteAllCard为true 保证只有一张卡片
-                    EmpInfoDto empDto = getEmpInfoDto(p, obtainBoolean.deleteUser(), obtainBoolean.deleteAllFace(), obtainBoolean.deleteFace(), obtainBoolean.deleteAllCard(), obtainBoolean.deleteCard(), true);
-                    R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
-                    log.info(result.getMsg());
-                } catch (Exception e) {
-                    log.error("处理人员{}异常: {}", p.getUserId(), e.getMessage(), e);
+        if(CollectionUtil.isNotEmpty(accountVoList)){
+            // 50个一组循环一次
+            int size = accountVoList.size();
+            int count = size / 50;
+            for (int i = 0; i <= count; i++) {
+                int start = i * 50;
+                int end = start + 50;
+                if (end > size) {
+                    end = size;
                 }
-            });
-        });
+                List<RemoteUserAccountVo> subList = accountVoList.subList(start, end);
+                threadPoolTaskExecutor.execute(() -> {
+                    subList.forEach(p -> {
+                        try {//如果过了有效期,则直接删除 deleteUser为true
+                            ResultBoolean obtainBoolean = getResult(p);
+                            // deleteAllCard为true 保证只有一张卡片
+                            EmpInfoDto empDto = getEmpInfoDto(p, obtainBoolean.deleteUser(), obtainBoolean.deleteAllFace(), obtainBoolean.deleteFace(), obtainBoolean.deleteAllCard(), obtainBoolean.deleteCard(), true);
+                            R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
+                            log.info(result.getMsg());
+                        } catch (Exception e) {
+                            log.error("处理人员{}异常: {}", p.getUserId(), e.getMessage(), e);
+                        }
+                    });
+                });
+            }
+        }
+
         return R.ok();
     }