|
|
@@ -34,12 +34,12 @@ import org.dromara.server.hik.service.ISendDeviceService;
|
|
|
import org.dromara.server.hik.utils.DigestHttpUtil;
|
|
|
import org.dromara.server.hik.utils.JsonConfig;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import java.text.MessageFormat;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
|
|
/**
|
|
|
* 向消费机发送信息服务接口实现
|
|
|
@@ -56,8 +56,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
|
|
@RequiredArgsConstructor
|
|
|
public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
private final DigestHttpUtil digestHttpUtil;
|
|
|
- private final ScheduledExecutorService scheduledExecutorService;
|
|
|
private final DefaultConfig defaultConfig;
|
|
|
+ private final ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
|
|
|
@DubboReference
|
|
|
private final RemotePtXfTermService remotePtXfTermService;
|
|
|
@@ -380,8 +380,8 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
if (CollectionUtil.isEmpty(termList)) {
|
|
|
throw new ServiceException("没有要处理的设备");
|
|
|
}
|
|
|
- termList.parallelStream().forEach(p -> {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
+ termList.forEach(p -> {
|
|
|
+ threadPoolTaskExecutor.submit(() -> {
|
|
|
DeviceDto deviceDto = getDeviceDto(p);
|
|
|
R<Void> result = this.createOperatorEmpInfo(deviceDto, empDto);
|
|
|
log.info(result.getMsg());
|
|
|
@@ -426,8 +426,8 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.warn("没有要配置的设备");
|
|
|
}
|
|
|
|
|
|
- termList.parallelStream().forEach(p -> {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
+ termList.forEach(p -> {
|
|
|
+ threadPoolTaskExecutor.submit(() -> {
|
|
|
DeviceDto dto = getDeviceDto(p);
|
|
|
R<Void> result = setHttpHostByDto(dto);
|
|
|
log.info(result.getMsg());
|
|
|
@@ -472,8 +472,8 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
public R<Void> deleteEmpFromDevice(Long termNo) {
|
|
|
DeviceDto deviceDto = getDeviceDto(termNo);
|
|
|
List<RemoteUserAccountVo> accountVoList = remoteUserAccountService.getUserAccountVoList();
|
|
|
- accountVoList.parallelStream().forEach(p -> {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
+ accountVoList.forEach(p -> {
|
|
|
+ threadPoolTaskExecutor.submit(() -> {
|
|
|
EmpInfoDto empDto = getEmpInfoDto(p, true, false, false, false, false);
|
|
|
R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
|
|
|
log.info(result.getMsg());
|
|
|
@@ -496,8 +496,8 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.warn("没有要处理人员的设备");
|
|
|
}
|
|
|
|
|
|
- termList.parallelStream().forEach(p -> {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
+ termList.forEach(p -> {
|
|
|
+ threadPoolTaskExecutor.submit(() -> {
|
|
|
DeviceDto device = getDeviceDto(p);
|
|
|
R<Void> result = createOperatorEmpInfo(device, empInfo);
|
|
|
log.info(result.getMsg());
|
|
|
@@ -520,8 +520,8 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
}
|
|
|
|
|
|
// 并行处理
|
|
|
- termList.parallelStream().forEach(p -> {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
+ termList.forEach(p -> {
|
|
|
+ threadPoolTaskExecutor.submit(() -> {
|
|
|
DeviceDto device = getDeviceDto(p);
|
|
|
accountVoList.parallelStream().forEach(t -> {
|
|
|
EmpInfoDto empInfo = getEmpInfoDto(t, true, false, false, false, false);
|
|
|
@@ -534,7 +534,6 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
}
|
|
|
// endregion
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public R<Void> deleteAllCardByUserNo(DeviceDto device, String userNo) {
|
|
|
CardListDto cardList = new CardListDto();
|
|
|
@@ -570,6 +569,7 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
|
|
|
|
|
|
// region 向消费机上传人员相关
|
|
|
+
|
|
|
@Override
|
|
|
public R<Void> upLoadEmpToDevice(UploadEmpDto uploadEmpDto) {
|
|
|
DeviceDto device = uploadEmpDto.getDevice();
|
|
|
@@ -611,12 +611,17 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
if (CollectionUtil.isEmpty(accountVoList)) {
|
|
|
return R.warn("没有要处理的人员");
|
|
|
}
|
|
|
- // 并行处理人员列表
|
|
|
- accountVoList.parallelStream().forEach(p -> {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
- EmpInfoDto empDto = getEmpInfoDto(p, false, false, false, false, false);
|
|
|
- R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
|
|
|
- log.info(result.getMsg());
|
|
|
+
|
|
|
+ // 处理人员列表
|
|
|
+ accountVoList.forEach(p -> {
|
|
|
+ threadPoolTaskExecutor.submit(() -> {
|
|
|
+ try {
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(p, false, false, false, false, false);
|
|
|
+ R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
|
|
|
+ log.info(result.getMsg());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("处理人员{}异常: {}", p.getUserId(), e.getMessage(), e);
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
return R.ok();
|
|
|
@@ -646,11 +651,11 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.warn("没有要处理的人员");
|
|
|
}
|
|
|
|
|
|
- // 并行处理
|
|
|
- termList.parallelStream().forEach(p -> {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
- DeviceDto device = getDeviceDto(p);
|
|
|
- accountVoList.parallelStream().forEach(t -> {
|
|
|
+ // 循环处理
|
|
|
+ termList.forEach(p -> {
|
|
|
+ DeviceDto device = getDeviceDto(p);
|
|
|
+ accountVoList.forEach(t -> {
|
|
|
+ threadPoolTaskExecutor.submit(()->{
|
|
|
EmpInfoDto empInfo = getEmpInfoDto(t, false, false, false, false, false);
|
|
|
R<Void> result = createOperatorEmpInfo(device, empInfo);
|
|
|
log.info(result.getMsg());
|