package cn.com.countrygarden.bi.main.dao.performance;

import cn.com.countrygarden.bi.main.model.performance.PerformanceMonthly;
import org.apache.ibatis.annotations.Param;

import java.util.List;

import java.util.Map;

/**
 * 绩效考核月度表
 *
 * @author Max  Date:2018/09/18
 * @version 1.0
 * @since 1.8
 */
public interface PerformanceMonthlyMapper {
    int deleteByPrimaryKey(Long monthId);

    int insertSelective(PerformanceMonthly record);

    PerformanceMonthly selectByPrimaryKey(Long monthId);

    int updateByPrimaryKeySelective(PerformanceMonthly record);

    //通过年，月度，区域，指标查询唯一一条记录
    PerformanceMonthly getSelect(PerformanceMonthly record);

    //得到年/月排名
    List<PerformanceMonthly> getMonthSort(@Param(value = "elementId") long elementId, @Param(value = "year") int year, @Param(value = "month") int month);

    //查询月度区域最新的年、月
    Map<String,Integer> selectOrganYearAndMonth();

    //查询月度城市公司最新的年、月
    Map<String,Integer> selectCompanyYearAndMonth();

    //删除0和1用于计算存储的指标
    int deleteMonthlyAvgScore(@Param(value = "year") int year, @Param(value = "month") int month);

    //计算每个区域的平均分
    int insertMonthAvgScoreRegion(@Param(value = "year") int year, @Param(value = "month") int month);

    //计算每个城市公司的平均分
    int insertMonthAvgScoreCompany(@Param(value = "year") int year, @Param(value = "month") int month);

    //查询本年度最新的月份
    int selectCountMonthByYear(@Param(value = "year") Integer year);
}