package cn.com.countrygarden.bi.main.service.performance.indicators;

import cn.com.countrygarden.bi.main.dao.performance.*;
import cn.com.countrygarden.bi.main.model.performance.dto.PerformanceShowDataDto;
import cn.com.countrygarden.bi.main.service.performance.common.PerformanceAreaService;
import cn.com.countrygarden.bi.main.service.performance.common.PerformanceRecordService;
import cn.com.countrygarden.bi.main.util.ExcelAnalysis;
import cn.com.countrygarden.bi.main.util.PerformancePower;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 所有指标的抽象父类，封装公用的属性和公用方法，符合指标接口规范
 */
public abstract class AbstractIndicatorService<T> implements ComIndicatorService<T> {

    @Autowired
    public PerformanceTypeMapper performanceTypeMapper;

    @Autowired
    public PerformanceElementMapper performanceElementMapper;

    @Autowired
    public PerformanceAreaMapper performanceAreaMapper;

    @Autowired
    public PerformanceRecordMapper performanceRecordMapper;

    @Autowired
    public PerformanceTargetMapper performanceTargetMapper;

    @Autowired
    public PerformanceScoreMapper performanceScoreMapper;

    @Autowired
    public PerformanceStatisticsMapper performanceStatisticsMapper;

    @Autowired
    public ExcelAnalysis ea;

    @Autowired
    public PerformancePower performancePower;

    @Autowired
    public PerformanceAreaService performanceAreaService;

    @Autowired
    public PerformanceRecordService performanceRecordService;

    /**
     * 封装每个指标都需要的填充空缺值和空缺区域的方法
     */
    public PerformanceShowDataDto setVacancyInfo(long elementId, int year, int quarter, String typeNo){

        PerformanceShowDataDto dataDto = new PerformanceShowDataDto();

        //总记录数
        int total = performanceAreaService.getTotalByType(typeNo);
        dataDto.setTotal(total);
        //PageInfo<PerformanceArea> p = new PageInfo<>(organList);//PageInfo这个对象封装了分页的属性

        //查询空缺的区域是没填的
        List<String> vacanHierachyNames = performanceRecordService.getVacancyAreas(elementId,year,quarter,typeNo);
        dataDto.setNameList(vacanHierachyNames);
        //空缺值
        int vacancy = vacanHierachyNames.size();
        dataDto.setVacancy(vacancy);

        return dataDto;

    }

}
