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

import cn.com.countrygarden.bi.main.model.performance.PerformanceRecord;
import cn.com.countrygarden.bi.main.model.performance.dto.PerformanceAnalysisRecordDto;
import cn.com.countrygarden.bi.main.model.performance.dto.PerformanceRecordDto;
import org.apache.ibatis.annotations.Param;

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

/**
 * 绩效考核记录Mapper
 *
 * @Author:Wyman
 * @Date:2018/10/19
 */
public interface PerformanceRecordMapper {


    int deleteByPrimaryKey(long recordId);

    int insertSelective(PerformanceRecord record);

    PerformanceRecord selectByPrimaryKey(long recordId);

    int updateByPrimaryKeySelective(PerformanceRecord record);

    //根据年、季度、指标id 获取记录数
    int selectCount(@Param("elementId") long elementId, @Param("year") int year, @Param("quarter") int quarter);

    //根据年、季度、指标id 查询空缺的记录名称
    List<String> selectNotExistAreaName(@Param("elementId") long elementId, @Param("year") int year, @Param("quarter") int quarter, @Param("typeNo") String typeNo);

    List<String> selectMonthlyNotExistAreaName(@Param("elementId") long elementId, @Param("year") int year, @Param("month") int month, @Param("typeNo") String typeNo);

    /**
     * 根据record实体查询记录
     * @param record
     * @return PerformanceRecordDto
     */
    PerformanceRecordDto selectBySelective(@Param("record") PerformanceRecord record);
    /**
     * 根据record实体查询记录
     * @param record
     * @return PerformanceAnalysisRecordDto
     */
    PerformanceAnalysisRecordDto selectBySelective2(@Param("record") PerformanceRecord record);
    /**
     * 根据record实体查询记录
     * @param record
     * @return record_id
     */
    //long selectBySelective3(@Param("record") PerformanceRecord record);
    Integer selectBySelective3(@Param("record") PerformanceRecord record); 
    /**
     * 查出所有的本季度的利润规模
     * @param elementId
     * @param year
     * @param quarter
     * @return
     */
    List<Map<String,String>> selectScope(@Param("elementId")long elementId,@Param("year")int year,@Param("quarter")int quarter);

    //根据年、季度删除所有0和1指标的数据
    int deleteAllRecords(@Param("year") int year, @Param("quarter") int quarter);

    //获取所有指标为1和0的id
    List<Long> selectAllRecordIds(@Param("year") int year, @Param("quarter") int quarter);

    //插入季度的总指标记录
    int insertQuarterlySumRecords(@Param("year") int year, @Param("quarter") int quarter, @Param("typeNo") String typeNo);

    //计算排名
    List<PerformanceRecord> getLastQuarterSort(@Param("element") long elementId, @Param("year") int year, @Param("quarter") int quarter, @Param("typeNo") String typeNo);

    //获得今年有记录的最大季度
    int selectCountQuarterByYear(@Param("year") int year);

    //得到分类地区最新的年，季度
    PerformanceRecord getNewYearQuarterByType(@Param("typeNo") String typeNo);

    //更新利润规模值
    int updateScope(@Param("scope") String scope, @Param("recordId") long recordId);


}
