package com.ssm.task;

import com.ssm.manage.dao.MemberLoginRecordingDao;
import com.ssm.manage.mapper.SmsMessagesMapper;
import com.ssm.manage.mapper.StaffLoginRecordingMapper;
import com.ssm.manage.service.SsmAccountTradeRecordService;
import com.ssm.manage.service.SsmCashService;
import com.ssm.manage.service.SsmCourseService;
import com.ssm.manage.service.SsmRechargeService;
import com.ssm.manage.utils.DateUtils;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@DisallowConcurrentExecution
public class SsmDayCreateTableTask extends QuartzJobBean {
    @Autowired
    private SsmRechargeService ssmRechargeService;
    @Autowired
    private SsmAccountTradeRecordService ssmAccountTradeRecordService;
    @Autowired
    private SsmCourseService ssmCourseService;
    @Autowired
    private SsmCashService ssmCashService;
    @Autowired
    private SmsMessagesMapper smsMessagesMapper;

    @Autowired
    private StaffLoginRecordingMapper staffLoginRecordingMapper;

    @Autowired
    private MemberLoginRecordingDao memberLoginRecordingDao;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        ssmRechargeService.createTable();
        ssmRechargeService.createTable1();
        ssmCourseService.createTable();
        ssmCashService.createTable();
        ssmAccountTradeRecordService.createTable();
        String date = DateUtils.YMFormat(DateUtils.diffMonth(new Date(), 1));
        smsMessagesMapper.createTable(date);
        memberLoginRecordingDao.createTable(date);
        staffLoginRecordingMapper.createTable(date);
        System.out.println("+++++++++++++++++++++++++当前时间："+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+"+++++++++++++++++++++++++++++++++++++++++++++++");

    }
}
