package com.template.services.impl;

import com.github.pagehelper.PageInfo;
import com.template.mapper.DriverStockMapper;
import com.template.model.tongji.*;
import com.template.services.DriverStockService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DriverStockServiceImpl implements DriverStockService {

    @Autowired
    public DriverStockMapper driverStockMapper;

    // 年级统计
    @Override
    public List<Tj> getClassTj(){
        return driverStockMapper.getClassTj();
    }

    // 访客统计
    public List<Tj> getVisitorTj(LocalDateTime start, LocalDateTime end){
        return driverStockMapper.getVisitorTj(start,end);
    }

    // 能耗总量统计
    public List<TjFloat> getEnergyTj(){
        return driverStockMapper.getEnergyTj();
    }

    // 每栋楼电费月统计
    public List<TjFloat> getEnergyMonth(@Param("date") String date,@Param("type") Integer type){
        return driverStockMapper.getEnergyMonth(date,type);
    }

    // 近12天水电统计
    public List<TjFloat> getEnergyDay(@Param("date") String date,@Param("type") Integer type){
        return driverStockMapper.getEnergyDay(date, type);
    }

    // 总设备数
    public List<TjFloat> getTotalDevice(){
        return driverStockMapper.getTotalDevice();
    }

    // 在线设备数
    public List<TjFloat> getOnlineDevice(@Param("date") String date){
        return driverStockMapper.getOnlineDevice(date);
    }

    public PageInfo<MeterPage> getMeterDetail(@Param("meterType") Integer meterType){
        List<MeterPage> list = driverStockMapper.getMeterDetail(meterType);
        PageInfo<MeterPage> meterPageInfo = new PageInfo<>(list);
        return meterPageInfo;
    }

    // 用户结构
    public List<Tj> getUserComp(){
        return driverStockMapper.getUserComp();
    }

    // 用户汇总学生
    public PageInfo<userPage> getUserPage(String key,Integer identityId){
        List<userPage> list = driverStockMapper.getUserPage(key,identityId);
        PageInfo<userPage> meterPageInfo = new PageInfo<>(list);
        return meterPageInfo;
    }

    // 教学成果
    public List<Tj> getScorePer(@Param("examName") String examName,@Param("updateUser") String updateUser){
        return driverStockMapper.getScorePer(examName,updateUser);
    }

    // 考试名称
    public List<Tj> getExamName(){
        return driverStockMapper.getExamName();
    }

    // 教师评分
    public Tj getTeacherExam(@Param("cardNo") String cardNo){
        List<Tj> list = driverStockMapper.getTeacherExam(cardNo);
        if (!list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}
