添加火点审核开关计划任务

1、早上八点打开火点审核开关
2、晚上十点关闭火点审核开关
This commit is contained in:
liuchengqian 2022-06-07 08:55:49 +08:00
parent 09617afc3e
commit fac3ab9d2f

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