package com.ho.business.service.impl;

import com.ho.business.entity.ElecMeterValue;
import com.ho.business.mapper.ElecMeterValueMapper;
import com.ho.business.service.ElecMeterValueService;
import com.ho.business.vo.req.bigScreen.CommonBigScreenReq;
import com.ho.business.vo.req.carbin.ElecMeterReq;
import com.ho.business.vo.resp.profit.DayProfitType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description 耗能电表数据操作
 * Author yule
 * Date 2022/11/1 18:52
 */
@Service
public class ElecMeterValueServiceImpl implements ElecMeterValueService {


    @Autowired
    ElecMeterValueMapper elecMeterValueMapper;

    @Override
    public BigDecimal selectSumByType(Integer stationId, Integer type, String beginTime, String endTime,Integer srcId) {
        BigDecimal sum = elecMeterValueMapper.selectSumByType(stationId, type, beginTime, endTime,srcId);
        return sum == null ? BigDecimal.ZERO:sum;
    }

    //按日期和类型删除
    @Override
    public int deleteByDay(String day, List<Integer> typeList) {
        int i = elecMeterValueMapper.deleteByDay(day, typeList);
        return i;
    }

    @Override
    public int deleteByStationAndDay(Integer stationId, String transDayStr, List<Integer> typeList) {
        return elecMeterValueMapper.deleteByStationAndDay(stationId, transDayStr, typeList);
    }

    //批量插入
    @Override
    public int insertBatch(List<ElecMeterValue> list) {
        int i = 0;
        if (list != null && !list.isEmpty()) {
            i = elecMeterValueMapper.insertBatch(list);
        }
        return i;
    }

    @Override
    public List<ElecMeterValue> selectList(Integer stationId, List<Integer> typeList, String beginTime, String endTime) {
        List<ElecMeterValue> elecMeterValues = elecMeterValueMapper.selectList(stationId, typeList, beginTime, endTime);
        return elecMeterValues;
    }

    @Override
    public List<ElecMeterValue> selectAllList(Integer stationId, List<Integer> typeList, String beginTime, String endTime, List<Integer> deviceTypeList) {
        List<ElecMeterValue> elecMeterValues = elecMeterValueMapper.selectAllList(stationId, typeList, beginTime, endTime,deviceTypeList);
        return elecMeterValues;
    }

    @Override
    public int insert(ElecMeterValue elecMeterValue) {
        int i = elecMeterValueMapper.insertSelective(elecMeterValue);
        return i;
    }

    @Override
    public List<ElecMeterValue> selectListByStationAndSrcId(ElecMeterReq elecMeterReq) {
        return elecMeterValueMapper.selectListByStationAndSrcId(elecMeterReq);
    }

    @Override
    public BigDecimal selectSumValue(Integer stationId, Integer type,Integer srcId) {
        BigDecimal sum = elecMeterValueMapper.selectSumValue(stationId, type,srcId);
        return sum == null ? BigDecimal.ZERO:sum;
    }

    @Override
    public List<ElecMeterValue> selectListByStationIds(List<Integer> stationId, Integer typeList, String beginTime, String endTime) {
        List<ElecMeterValue> elecMeterValues = elecMeterValueMapper.selectListByStationIds(stationId, typeList, beginTime, endTime);
        return elecMeterValues;
    }

    @Override
    public List<ElecMeterValue> selectByStationIdsAndTime(List<Integer> stationId, String beginTime, String endTime,Integer srcId) {
        List<ElecMeterValue> elecMeterValues = elecMeterValueMapper.selectByStationIdsAndTime(stationId, beginTime, endTime,srcId);
        return elecMeterValues;
    }

    @Override
    public List<ElecMeterValue> selectGroupByDay(CommonBigScreenReq req) {
        return elecMeterValueMapper.selectGroupByDay(req);
    }

    @Override
    public List<DayProfitType> getElec(String begin, String end, Integer groupId, Integer type,List<Integer> stationIds) {
        return elecMeterValueMapper.getElec(begin,end,groupId,type,stationIds);
    }
}
