1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.dy.rtuMw.server.msCenter;
 
import com.dy.common.util.DateTime;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
/**
 * @Author: liurunyu
 * @Date: 2025/2/12 15:35
 * @Description
 */
//使起作用,本类注解@Component,并在PipIrrMwRtuApplication注解@EnableScheduling
//@Component
public class TestMsResource {
 
    // 设置定时十秒一次
    @Scheduled(cron = "0/5 * * * * ?")
    public void test1() throws Exception {
        MsObj msObj = new MsObj() ;
        msObj.put("name", "开阀");
        msObj.put("clientId", 1233445345);
        msObj.put("clientName", "张三");
        msObj.put("clientAddress", "北京市");
        msObj.put("icCardNo", "123456789");
        msObj.put("rtuAddr", "123456789");
        msObj.put("intakeId", 987654321);
        msObj.put("dt", DateTime.yyyy_MM_dd_HH_mm_ss());
        MsCenterUnit.getInstance().pushMs(msObj);
    }
 
    // 设置定时十秒一次
    @Scheduled(cron = "0/6 * * * * ?")
    public void test2() throws Exception {
        MsObj msObj = new MsObj() ;
        msObj.put("name", "报警");
        msObj.put("rtuAddr","123456789");
        msObj.put("intakeId", 1233445345);
        msObj.put("alarm", "水表超量程");
        msObj.put("dt", DateTime.yyyy_MM_dd_HH_mm_ss());
        MsCenterUnit.getInstance().pushMs(msObj);
    }
 
}