package com.ruoyi.ems.service.impl;

import com.ruoyi.ems.domain.CaMeterD;
import com.ruoyi.ems.mapper.CaMeterDMapper;
import com.ruoyi.ems.service.ICaMeterDService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 碳计量日Service业务层处理
 */
@Service
public class CaMeterDServiceImpl implements ICaMeterDService {

    @Autowired
    private CaMeterDMapper caMeterDMapper;

    @Override
    public CaMeterD selectCaMeterDById(Long id) {
        return caMeterDMapper.selectCaMeterDById(id);
    }

    /**
     * 根据时间类型查询列表（分页用）
     */
    @Override
    public List<CaMeterD> selectCaMeterDListByTimeType(CaMeterD caMeterD, String timeType) {
        if (timeType == null) {
            timeType = "year";
        }
        switch (timeType) {
            case "month":
                return caMeterDMapper.selectCaMeterDListByMonth(caMeterD);
            case "year":
                return caMeterDMapper.selectCaMeterDListByYear(caMeterD);
            case "day":
            default:
                return caMeterDMapper.selectCaMeterDList(caMeterD);
        }
    }

    /**
     * 根据时间类型查询汇总（统计用）
     */
    @Override
    public List<CaMeterD> selectSumCaMeterDListByTimeType(CaMeterD caMeterD, String timeType) {
        if (timeType == null) {
            timeType = "year";
        }
        switch (timeType) {
            case "month":
                return caMeterDMapper.selectSumCaMeterDListByMonth(caMeterD);
            case "year":
                return caMeterDMapper.selectSumCaMeterDListByYear(caMeterD);
            case "day":
            default:
                return caMeterDMapper.selectSumCaMeterDList(caMeterD);
        }
    }

    @Override
    public List<CaMeterD> selectAvgCaMeterDList(CaMeterD caMeterD) {
        return caMeterDMapper.selectAvgCaMeterDList(caMeterD);
    }

    @Override
    public int insertCaMeterD(CaMeterD caMeterD) {
        return caMeterDMapper.insertCaMeterD(caMeterD);
    }

    @Override
    public int updateCaMeterD(CaMeterD caMeterD) {
        return caMeterDMapper.updateCaMeterD(caMeterD);
    }

    @Override
    public int deleteCaMeterDByIds(Long[] ids) {
        return caMeterDMapper.deleteCaMeterDByIds(ids);
    }
}