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.ForecastPowerUltraShortTermMapper;
import com.jiayue.ipp.idp.service.ForecastPowerUltraShortTermService;
import org.springframework.stereotype.Service;

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

/**
 * idp_forecast_power_ultra_short_term
 *
 * @author whc
 * @date 2022-03-18 15:48:59
 */
@Service
public class ForecastPowerUltraShortTermServiceImpl extends ServiceImpl<ForecastPowerUltraShortTermMapper, ForecastPowerUltraShortTerm> implements ForecastPowerUltraShortTermService {

    @Override
    public List<ForecastPowerUltraShortTerm> findByStationCodeAndStartTimeAndEndTime(String stationCode, Date startTime, Date endTime) {
        QueryWrapper<ForecastPowerUltraShortTerm> 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);
    }
}
