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); } }