|
@@ -39,22 +39,42 @@ public class DeviceTimer {
|
|
@Scheduled(cron = "0 0 0/1 * * ? ")
|
|
@Scheduled(cron = "0 0 0/1 * * ? ")
|
|
private void action() {
|
|
private void action() {
|
|
Date date = new Date(System.currentTimeMillis() - 1000 * 60 * 60); // 1小时前
|
|
Date date = new Date(System.currentTimeMillis() - 1000 * 60 * 60); // 1小时前
|
|
|
|
+
|
|
|
|
+ List<TerminalPort> terminalPortss = portMapper.selectList(null);
|
|
|
|
+ for (TerminalPort terminal : terminalPortss) {
|
|
|
|
+ if (null == terminal.getUpdateTime() || date.after(terminal.getUpdateTime())) {
|
|
|
|
+ terminal.setStatus(0);
|
|
|
|
+ } else {
|
|
|
|
+ terminal.setStatus(1);
|
|
|
|
+ }
|
|
|
|
+ portMapper.updateById(terminal);
|
|
|
|
+ }
|
|
|
|
+ List<Terminal> terminals = terminalMapper.selectList(null);
|
|
|
|
+ for (Terminal terminal : terminals) {
|
|
|
|
+ terminal.setStatus(0);
|
|
|
|
+ terminalMapper.updateById(terminal);
|
|
|
|
+ }
|
|
|
|
+ List<Gateway> geteways = gatewayMapper.selectList(null);
|
|
|
|
+ for (Gateway gateway : geteways) {
|
|
|
|
+ gateway.setStatus(0);
|
|
|
|
+ gatewayMapper.updateById(gateway);
|
|
|
|
+ }
|
|
|
|
+
|
|
List<HeartDto> heartDtos = heartInfoMapper.listHeart();
|
|
List<HeartDto> heartDtos = heartInfoMapper.listHeart();
|
|
for (HeartDto heartDto : heartDtos) {
|
|
for (HeartDto heartDto : heartDtos) {
|
|
-
|
|
|
|
if (date.after(heartDto.getCreateTime())) {
|
|
if (date.after(heartDto.getCreateTime())) {
|
|
//说明一个小时内都没有心跳
|
|
//说明一个小时内都没有心跳
|
|
QueryWrapper<Terminal> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<Terminal> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
Terminal terminal = terminalMapper.selectOne(queryWrapper);
|
|
Terminal terminal = terminalMapper.selectOne(queryWrapper);
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
- terminal.setStatus(1);
|
|
|
|
|
|
+ terminal.setStatus(0);
|
|
terminalMapper.updateById(terminal);
|
|
terminalMapper.updateById(terminal);
|
|
QueryWrapper<TerminalPort> queryWrapper1 = new QueryWrapper<>();
|
|
QueryWrapper<TerminalPort> queryWrapper1 = new QueryWrapper<>();
|
|
queryWrapper1.eq("terminal_id", terminal.getId());
|
|
queryWrapper1.eq("terminal_id", terminal.getId());
|
|
List<TerminalPort> terminalPorts = portMapper.selectList(queryWrapper1);
|
|
List<TerminalPort> terminalPorts = portMapper.selectList(queryWrapper1);
|
|
for (TerminalPort terminalPort : terminalPorts) {
|
|
for (TerminalPort terminalPort : terminalPorts) {
|
|
- terminalPort.setStatus(1);
|
|
|
|
|
|
+ terminalPort.setStatus(0);
|
|
portMapper.updateById(terminalPort);
|
|
portMapper.updateById(terminalPort);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -63,15 +83,15 @@ public class DeviceTimer {
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
Terminal terminal = terminalMapper.selectOne(queryWrapper);
|
|
Terminal terminal = terminalMapper.selectOne(queryWrapper);
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
- terminal.setStatus(0);
|
|
|
|
|
|
+ terminal.setStatus(1);
|
|
terminalMapper.updateById(terminal);
|
|
terminalMapper.updateById(terminal);
|
|
- QueryWrapper<TerminalPort> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
- queryWrapper1.eq("terminal_id", terminal.getId());
|
|
|
|
- List<TerminalPort> terminalPorts = portMapper.selectList(queryWrapper1);
|
|
|
|
- for (TerminalPort terminalPort : terminalPorts) {
|
|
|
|
- terminalPort.setStatus(0);
|
|
|
|
- portMapper.updateById(terminalPort);
|
|
|
|
- }
|
|
|
|
|
|
+// QueryWrapper<TerminalPort> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
+// queryWrapper1.eq("terminal_id", terminal.getId());
|
|
|
|
+// List<TerminalPort> terminalPorts = portMapper.selectList(queryWrapper1);
|
|
|
|
+// for (TerminalPort terminalPort : terminalPorts) {
|
|
|
|
+// terminalPort.setStatus(1);
|
|
|
|
+// portMapper.updateById(terminalPort);
|
|
|
|
+// }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -83,7 +103,7 @@ public class DeviceTimer {
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
Gateway terminal = gatewayMapper.selectOne(queryWrapper);
|
|
Gateway terminal = gatewayMapper.selectOne(queryWrapper);
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
- terminal.setStatus(1);
|
|
|
|
|
|
+ terminal.setStatus(0);
|
|
gatewayMapper.updateById(terminal);
|
|
gatewayMapper.updateById(terminal);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -91,7 +111,7 @@ public class DeviceTimer {
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
queryWrapper.eq("device_code", heartDto.getTerminalCode());
|
|
Gateway terminal = gatewayMapper.selectOne(queryWrapper);
|
|
Gateway terminal = gatewayMapper.selectOne(queryWrapper);
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
if (ObjectUtil.isNotEmpty(terminal)) {
|
|
- terminal.setStatus(0);
|
|
|
|
|
|
+ terminal.setStatus(1);
|
|
gatewayMapper.updateById(terminal);
|
|
gatewayMapper.updateById(terminal);
|
|
}
|
|
}
|
|
}
|
|
}
|