diff --git a/src/main/java/com/xkrs/common/StaticScheduleTask.java b/src/main/java/com/xkrs/common/StaticScheduleTask.java new file mode 100644 index 0000000..397510b --- /dev/null +++ b/src/main/java/com/xkrs/common/StaticScheduleTask.java @@ -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 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 map = new HashMap<>(); + map.put("switchState", "0"); + sendHttpPost(url, new ObjectMapper().writeValueAsString(map)); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file