package com.xmomen.module.schedule;


import com.xmomen.framework.support.SpringContextUtil;
import com.xmomen.module.order.model.CreatePurchase;
import com.xmomen.module.order.service.PurchaseService;
import com.xmomen.module.stockdaily.service.StockDailyService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created by Jeng on 2016/2/23.
 */
@Component(value = "stockDailyJob")
public class StockDailyJob implements Job {

    // 注入StockDailyService
    StockDailyService stockDailyService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        // 如果stockDailyService为空，则从Spring上下文中获取
        if (stockDailyService == null) {
            stockDailyService = (StockDailyService) SpringContextUtil.getApplicationContext().getBean(StockDailyService.class);
            // 调用createStockDaily方法
            stockDailyService.createStockDaily();
        }
    }
}
