|
|
|
@ -0,0 +1,38 @@ |
|
|
|
package com.topsail.influxdb.schdule; |
|
|
|
|
|
|
|
import com.topsail.influxdb.rabbitmq.service.AmqpService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
@Component |
|
|
|
public class ScheduledMessageProducer { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AmqpService amqpService; |
|
|
|
|
|
|
|
// 使用cron表达式,每分钟的第10秒执行 |
|
|
|
@Scheduled(cron = "40 * * * * ?") |
|
|
|
public void pushCronMessage3() { |
|
|
|
try { |
|
|
|
String message="{\"deviceType\":1,\"hardwareVersions\":\"1.24.1.1\",\"iMSI\":\"460087939303126\",\"iccid\":\"898604F9262380193126\",\"imei\":\"865074051888625\",\"softwareVersions\":\"1.1.6.8\"}"; |
|
|
|
amqpService.SendMessage("testOneQ3", message); |
|
|
|
System.out.println("设备基础信息:Cron定时消息: " + LocalDateTime.now()); |
|
|
|
}catch (Exception e){ |
|
|
|
System.out.println("设备基础信息:Cron定时消息: 失败" +e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
@Scheduled(cron = "40 * * * * ?") |
|
|
|
public void pushCronMessage2() { |
|
|
|
try { |
|
|
|
String message="{\"alarmType\":\"0\",\"batteryLevel\":100,\"dataBody\":\"{\\\"CSQ\\\":31,\\\"IMEI\\\":\\\"865074051888625\\\",\\\"alarm\\\":0,\\\"alarms_dat\\\":\\\"\\\",\\\"bat_level\\\":100,\\\"dev_model\\\":12,\\\"dev_type\\\":1,\\\"samp_time\\\":\\\"2000/1/1 1:1:7\\\",\\\"sensor_dat\\\":\\\"℃,MPa|null,0.0000\\\"}\",\"dataGroupNum\":2,\"devModel\":12,\"deviceType\":1,\"deviceid\":\"15208214865074051888625\",\"imei\":\"865074051888625\",\"passNum\":1,\"platformType\":\"AEP\",\"protocol\":\"mqtt\",\"sampTime\":\"2000/1/1 1:1:7\",\"sampleData\":\"0,0.0000\",\"sendTime\":\"20251229163715\",\"singalStrength\":31,\"sourcetype\":\"new_top\",\"time\":\"2025-12-29 16:37:15\",\"unit\":\"℃,MPa\",\"userName\":\"topsail\"}"; |
|
|
|
amqpService.SendMessage("testOneQ2", message); |
|
|
|
System.out.println("设备数据:Cron定时消息: " + LocalDateTime.now()); |
|
|
|
}catch (Exception e){ |
|
|
|
System.out.println("设备数据:Cron定时消息: 失败" +e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|