package com.jiayue.ipp.idp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.ipp.common.data.entity.ForecastPowerShortTerm;
import com.jiayue.ipp.common.data.entity.ForecastPowerUltraShortTerm;
import com.jiayue.ipp.idp.mapper.ForecastPowerShortTermMapper;
import com.jiayue.ipp.idp.service.ForecastPowerShortTermService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * idp_forecast_power_short_term
 *
 * @author whc
 * @date 2022-03-18 15:48:55
 */
@Service
public class ForecastPowerShortTermServiceImpl extends ServiceImpl<ForecastPowerShortTermMapper, ForecastPowerShortTerm> implements ForecastPowerShortTermService {


    @Override
    public List<ForecastPowerShortTerm> findByStationCodeAndStartTimeAndEndTime(String stationCode, Date startTime, Date endTime) {
        QueryWrapper<ForecastPowerShortTerm> wrapper = new QueryWrapper<>();
        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }
        if (startTime != null && !startTime.equals("") && endTime != null && !endTime.equals("")) {
            wrapper.between("forecast_time", startTime, endTime);
        }

        return baseMapper.selectList(wrapper);
    }
    @Override
    public List<ForecastPowerShortTerm> findByStationCodeAndStartTimeAndEndTimeAndForecastManufactor(String stationCode, Date startTime, Date endTime,String forecastManufactor) {
        QueryWrapper<ForecastPowerShortTerm> wrapper = new QueryWrapper<>();
        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }
        if (startTime != null && !startTime.equals("") && endTime != null && !endTime.equals("")) {
            wrapper.between("forecast_time", startTime, endTime);
        }
        if (forecastManufactor != null && !forecastManufactor.equals("")) {
            wrapper.eq("forecast_manufactor", forecastManufactor);
        }
        return baseMapper.selectList(wrapper);
    }

}
