package com.cku.oa.timedtask.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

import com.cku.oa.show.service.MainShowsService;

/**
 * 
 * 赛事结束 （财务收入签收时点）
 * 
 * @author zhaoxy
 *
 */
@Service
@Transactional(readOnly = true)
public class ShowEndTask extends JobActingService {

	private final Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private MainShowsService mainShowsService;

	@SuppressWarnings("finally")
	@Transactional(readOnly = false)
	int doJob() {
		int count = 0;
		try {
			count = mainShowsService.showEndReceive();
		} catch (Exception e) {
			count = -1;
		} finally {
			logger.info("修改数据,执行条数：" + count);
			return count;
		}
	}

	@Override
	@SuppressWarnings("finally")
	@Transactional(readOnly = false)
	public int executeOnce() {
		int count = 0;
		try {
			SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
			count = mainShowsService.showEndReceive();
		} catch (Exception e) {
			count = -1;
		} finally {
			logger.info("修改数据,执行条数：" + count);
			return count;
		}

	}

}
