package com.ruoyi.ems.service.impl;

import com.huashe.common.utils.DateUtils;
import com.ruoyi.ems.domain.EnergyMeter;
import com.ruoyi.ems.domain.WaterMeterH;
import com.ruoyi.ems.mapper.WaterMeterHMapper;
import com.ruoyi.ems.model.QueryMeter;
import com.ruoyi.ems.service.IWaterMeterHService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用水计量-小时Service业务层处理
 *
 * @author ruoyi
 * @date 2024-12-03
 */
@Service
public class WaterMeterHServiceImpl implements IWaterMeterHService {
    @Autowired
    private WaterMeterHMapper waterMeterHMapper;

    @Override
    public int insertBatch(List<WaterMeterH> list) {
        return waterMeterHMapper.insertBatch(list);
    }

    /**
     * 新增用水计量-小时
     *
     * @param waterMeterH 用水计量-小时
     * @return 结果
     */
    @Override
    public int insertWaterMeterH(WaterMeterH waterMeterH) {
        waterMeterH.setCreateTime(DateUtils.getNowDate());
        return waterMeterHMapper.insertWaterMeterH(waterMeterH);
    }

    /**
     * 修改用水计量-小时
     *
     * @param waterMeterH 用水计量-小时
     * @return 结果
     */
    @Override
    public int updateWaterMeterH(WaterMeterH waterMeterH) {
        return waterMeterHMapper.updateWaterMeterH(waterMeterH);
    }

    /**
     * 删除用水计量-小时信息
     *
     * @param date 日期
     * @return 结果
     */
    @Override
    public int deleteWaterMeterHByDate(String date) {
        return waterMeterHMapper.deleteWaterMeterHByDate(date);
    }

    @Override
    public WaterMeterH selectLatelyItem(String deviceCode) {
        return waterMeterHMapper.selectLatelyItem(deviceCode);
    }

    @Override
    public EnergyMeter qryWaterMeterByDate(String dataRange, String areaCode) {
        return waterMeterHMapper.qryWaterMeterByDate(new WaterMeterH(){{
            setStartRecTime(dataRange);
            setAreaCode(areaCode);
        }});
    }

    @Override
    public List<WaterMeterH> qryTimeIndexWaterMeterByDay(String dataRange, Integer timeIndex) {
        return waterMeterHMapper.qryTimeIndexWaterMeterByDay(dataRange);
    }

    @Override
    public List<WaterMeterH> qryDateWaterMeterByDay(String dataRange) {
        return waterMeterHMapper.qryDateWaterMeterByDay(dataRange);
    }

    @Override
    public List<WaterMeterH> qryDateWaterMeterByYear(String dataRange) {
        return waterMeterHMapper.qryDateWaterMeterByYear(dataRange);
    }

    @Override
    public EnergyMeter selectWaterDayAvg(QueryMeter queryMeter) {
        return waterMeterHMapper.selectWaterDayAvg(queryMeter);
    }
}
