/**
 * 版权所有 ©2021 莱欧有限公司
 * 工程名：yearBooks
 * 文件名：MainShowDao.java
 * 创建日期：2021年10月28日 下午4:27:23
 * 作者：mt.W
 */
package com.lion.dao;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import jodd.util.StringUtil;


/**
 * 类描述   
 * @author mt.W
 * @since 2021年10月28日
 */
@Repository
public class MainShowDao {

	@Autowired
	private JdbcTemplate jdbc;
	
	public List<Map<String, Object>> getItemOrgdeptRecord(String tableName,String year){
		String sql = "select * from "+tableName + " where year = '"+year+"' ";
		return jdbc.queryForList(sql);
	}
	public List<Map<String,Object>> getItemOrgdeptSumItem(String tableName,String c){
		String sql = "select year,sum("+c+") count from "+tableName +" group by year order by year limit 7 ";
		return jdbc.queryForList(sql);
	}
	public List<Map<String,Object>> getItemOrgdeptSumItem(String tableName,String c,String id){
		String sql = "select year,sum("+c+") count from "+tableName;
		if(StringUtil.isNotEmpty(id)){
			sql += " where typeId = '"+id+"' ";
		}
		sql += " group by year order by year limit 7  ";
		return jdbc.queryForList(sql);
	}
	public List<Map<String,Object>> getFruitRecord(String year){
		String sql = "select * from zzy_sg where year = '"+year+"' ";
		return jdbc.queryForList(sql);
	}
}
