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(value = "tbDeskTopIncidentDailyRepository")
public class TbDeskTopIncidentDailyRepository extends DataRepositoryJDBC {
	protected final Logger log = LoggerFactory.getLogger(TbDeskTopIncidentDailyRepository.class);

	public TbDeskTopIncidentDailyRepository() {
		this.masterTable = "rts..Tb_DeskTop_IncidentDaily";// 表名
	}

	/**
	 * 查询工单类型比例
	 * 
	 * @param paramMap
	 * @return
	 */
	public List<Map<String, Object>> queryWorkOrderTypeRate(Map<String, Object> paramMap) {
		List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
		String sql = "select t1.typecode ,t2.typename ,t1.quantity from (("
				+ " select typecode,sum(quantity) quantity from rts..Tb_DeskTop_IncidentDaily"
				+ " where organcode = '01' group by typecode )t1 inner join "
				+ " (select typecode ,typename from HM_wygl_new_1853..Tb_HSPR_IncidentType "
				+ " group by typecode ,typename)t2 on t1.typecode = t2.typecode)";
		resultList = this.jdbcTemp.queryForList(sql);
		return resultList;

	}

	/**
	 * 查询本日有偿工单数，本日有偿工单应收收入
	 * 
	 * @param paramMap
	 * @return
	 */
	public List<Map<String, Object>> queryFeesquantityData(Map<String, Object> paramMap) {
		List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();

		String sql = "select sum(feesquantity) feesquantity,sum(fees) fees from rts..Tb_DeskTop_IncidentDaily where organcode = '01'";

		resultList = this.jdbcTemp.queryForList(sql);

		return resultList;
	}
}
