package com.chinacreator.process.dao;

import java.sql.SQLException;

import org.apache.commons.lang.math.NumberUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.chinacreator.process.util.DataSource;
import com.frameworkset.common.poolman.SQLExecutor;

@Component
public class WotvAiqyDao{
	
	private static Logger logger = Logger.getLogger(WotvAiqyDao.class);
	
	
	public int queryData() throws SQLException{
		String sql = "select count(1) count from TD_WOTVAIQY_RECEIVEAD where inserttime>=trunc(sysdate)-1 and inserttime<trunc(sysdate)";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql));
	}
	
	public int querySMS(String logdate)throws SQLException{
		String sql = "SELECT count(1) FROM TL_WOTVAIQY_SMS_LOG  where  logdate=?";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql,logdate));
	}
	
	public void insert(String logdate,String userid,String status) {
		String sql = "insert into TL_WOTVAIQY_SMS_LOG(logdate,smstime,userid,status) values(?,sysdate,?,?)";
		try {
			SQLExecutor.insertWithDBName(DataSource.NET3G, sql, logdate,userid,status);
		} catch (SQLException e) {
			logger.error("insert TL_WOTVAIQY_SMS_LOG 失败", e);
		}
	}
	
  
}