|
|
@@ -4,6 +4,8 @@ import com.usoftchina.smartschool.device.biometric.BiometricDeviceService;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.po.FaceGate;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.po.HealthStatus;
|
|
|
import com.usoftchina.smartschool.device.client.biometric.service.FaceGateService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
@@ -22,25 +24,22 @@ public class GateScheduler {
|
|
|
private FaceGateService faceGateService;
|
|
|
@Autowired
|
|
|
private BiometricDeviceService deviceService;
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(GateScheduler.class);
|
|
|
|
|
|
@Scheduled(fixedDelay = 120000)
|
|
|
public void pingDevice() {
|
|
|
List<FaceGate> faceGates = faceGateService.findAll();
|
|
|
if (!CollectionUtils.isEmpty(faceGates)) {
|
|
|
- try {
|
|
|
- faceGates.parallelStream().forEach(faceGate -> {
|
|
|
- boolean success = deviceService.ping(faceGate);
|
|
|
- if (success) {
|
|
|
- faceGate.setLastActiveTime(new Date());
|
|
|
- faceGate.setStatus(HealthStatus.HEALTHY.getValue());
|
|
|
- } else {
|
|
|
- faceGate.setStatus(HealthStatus.UN_HEALTHY.getValue());
|
|
|
- }
|
|
|
- faceGateService.save(faceGate);
|
|
|
- });
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ faceGates.parallelStream().forEach(faceGate -> {
|
|
|
+ boolean success = deviceService.ping(faceGate);
|
|
|
+ if (success) {
|
|
|
+ faceGate.setLastActiveTime(new Date());
|
|
|
+ faceGate.setStatus(HealthStatus.HEALTHY.getValue());
|
|
|
+ } else {
|
|
|
+ faceGate.setStatus(HealthStatus.UN_HEALTHY.getValue());
|
|
|
+ }
|
|
|
+ faceGateService.save(faceGate);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|