package com.moral.task; import java.time.LocalDateTime; import java.util.List; import java.util.Map; import javax.annotation.Resource; import com.moral.service.AlarmService; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @Component public class AlarmTableInsertTask { private static transient Logger logger = LoggerFactory.getLogger(AlarmTableInsertTask.class); @Resource private AlarmService alarmService; @XxlJob("alarmDaily") public ReturnT insertAlarmDailyTable(String param) { int count = alarmService.insertAlarmDaily(); if(count>0){ return new ReturnT(200, "插入天表成功"); }else { return new ReturnT(200, "插入天表成功"); } } @XxlJob("createAlarmSubTable") public ReturnT createAlarmSubTable(String param) { LocalDateTime time = LocalDateTime.now().plusMonths(1); String year = time.getYear() + ""; String month = time.getMonthValue() + ""; if (time.getMonthValue() < 10) { month = "0" + time.getMonthValue(); } alarmService.createTable(year + month); ReturnT returnT = new ReturnT(200, "创建alarm年月分表成功"); return returnT; } }