Commit c2d05035 zshaohui

黑灯工厂 增加定时任务

1 个父辈 b4db2d79
...@@ -14,8 +14,8 @@ import org.springframework.scheduling.annotation.EnableAsync; ...@@ -14,8 +14,8 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
//@EnableAsync @EnableAsync
//@EnableScheduling @EnableScheduling
@EnableKafka @EnableKafka
@RestController @RestController
@SpringBootApplication @SpringBootApplication
......
...@@ -49,6 +49,7 @@ public class KafkaService { ...@@ -49,6 +49,7 @@ public class KafkaService {
*/ */
@Scheduled(fixedRate = 1000 * 60 * 1) @Scheduled(fixedRate = 1000 * 60 * 1)
public void setMachineStatus() { public void setMachineStatus() {
log.info("发送设备状态开始");
Collection<Storage> storages = dataCache.getAllStorage().values(); Collection<Storage> storages = dataCache.getAllStorage().values();
List<String> machineIdList = getMachineIdList(); List<String> machineIdList = getMachineIdList();
for (String machineId : machineIdList) { for (String machineId : machineIdList) {
...@@ -108,6 +109,7 @@ public class KafkaService { ...@@ -108,6 +109,7 @@ public class KafkaService {
log.info("返回结果为:" + JSON.toJSONString(future)); log.info("返回结果为:" + JSON.toJSONString(future));
statusMap.put(machineId,currentStatus); statusMap.put(machineId,currentStatus);
} }
log.info("发送设备状态结束");
} }
...@@ -116,7 +118,7 @@ public class KafkaService { ...@@ -116,7 +118,7 @@ public class KafkaService {
*/ */
@Scheduled(fixedRate = 1000 * 60 * 5) @Scheduled(fixedRate = 1000 * 60 * 5)
public void setHeartbeat() { public void setHeartbeat() {
log.info("发送心跳开始");
//根据machineId,找到设备状态,是否正常 //根据machineId,找到设备状态,是否正常
Collection<Storage> storages = dataCache.getAllStorage().values(); Collection<Storage> storages = dataCache.getAllStorage().values();
List<String> machineIdList = getMachineIdList(); List<String> machineIdList = getMachineIdList();
...@@ -153,6 +155,7 @@ public class KafkaService { ...@@ -153,6 +155,7 @@ public class KafkaService {
log.info("返回结果为:" + JSON.toJSONString(future)); log.info("返回结果为:" + JSON.toJSONString(future));
} }
} }
log.info("发送心跳结束");
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!