package cn.com.countrygarden.bi.main.repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.sunshine.common.repository.DataRepositoryJDBC;

/**
 * 每日实收统计表
 * 
 * @author huangzhengjun
 *
 */
@Repository("commAmountDailyRepository")
public class CommAmountDailyRepository extends DataRepositoryJDBC {
	protected final Logger log = LoggerFactory.getLogger(CommAmountDailyRepository.class);

	public CommAmountDailyRepository() {
		this.masterTable = "rts.dbo.Tb_DeskTop_CommAmountDaily";// 表名
	}

	/**
	 * 查询一个月内集团的每日实收统计 <br>
	 * and StatDate>(convert(char(10),getdate()-7,120))--查询七天 and
	 * DateDiff(MONTH,StatDate,getdate())=0 --查询本月1号到现在的数据
	 * 
	 * @param paramMap
	 * @return
	 */
	public List<Map<String, Object>> queryCommAmoutDaily(Map<String, Object> paramMap) {
		List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
		String sql = "select t2.organname ,t1.organcode ,t1.amount,t1.statdate from "
				+ "(select organcode , isnull(sum(amount),0) as amount,StatDate as statdate"
				+ " from rts.dbo.Tb_DeskTop_CommAmountDaily where typecode = '0101' and commid='0' and OrganCode='01' "
				+ " and DateDiff(MONTH,StatDate,getdate())=0 group by organcode,StatDate ) t1 "
				+ " inner join  HM_wygl_new_1853.dbo.Tb_Sys_Organ t2 on t1.organcode = t2.organcode";
		resultList = this.jdbcTemp.queryForList(sql);
		return resultList;
	}
}
