添加火点审核开关计划任务
1、早上八点打开火点审核开关 2、晚上十点关闭火点审核开关
This commit is contained in:
parent
09617afc3e
commit
fac3ab9d2f
45
src/main/java/com/xkrs/common/StaticScheduleTask.java
Normal file
45
src/main/java/com/xkrs/common/StaticScheduleTask.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.xkrs.common;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xkrs.utils.WDHttpClientUtils.sendHttpPost;
|
||||
|
||||
/**
|
||||
* 火点审核开关计划任务
|
||||
*/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class StaticScheduleTask {
|
||||
|
||||
//早上八点打开火点审核开关
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
private void openVerifySwitch() {
|
||||
try {
|
||||
String url = "http://118.24.27.47:6801/updateswitchstate";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("switchState", "1");
|
||||
sendHttpPost(url, new ObjectMapper().writeValueAsString(map));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//晚上十点关闭火点审核开关
|
||||
@Scheduled(cron = "0 0 22 * * ?")
|
||||
private void closeVerifySwitch() {
|
||||
try {
|
||||
String url = "http://118.24.27.47:6801/updateswitchstate";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("switchState", "0");
|
||||
sendHttpPost(url, new ObjectMapper().writeValueAsString(map));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user