package com.cpp.web.service.station.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cpp.web.domain.station.ForecastPowerShortTermStation;
import com.cpp.web.mapper.station.ForecastPowerShortTermStationMapper;
import com.cpp.web.service.station.ForecastPowerShortTermStationService;
import org.springframework.stereotype.Service;

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

/**
 * cpp_forecast_power_short_term_his
 *
 * @author tl
 * @date 2024-09-23 15:28:33
 */
@Service
public class ForecastPowerShortTermStationServiceImpl extends ServiceImpl<ForecastPowerShortTermStationMapper, ForecastPowerShortTermStation> implements ForecastPowerShortTermStationService {
    @Override
    public ForecastPowerShortTermStation findByForecastTimeAndForecastHowLongAgoAndStationCodeAndForecastManufactor(Long pointEndTime, int howLongAgo, String stationCode, String forecastManufactor) {
        QueryWrapper<ForecastPowerShortTermStation> wrapper = new QueryWrapper<>();

        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }
        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("forecast_manufactor", forecastManufactor);
        }
        if (pointEndTime != null) {
            wrapper.eq("forecast_time", new Date(pointEndTime));
        }
        wrapper.eq("forecast_how_long_ago", howLongAgo);
        return baseMapper.selectOne(wrapper);
    }

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

    @Override
    public ForecastPowerShortTermStation findByForecastTimeAndForecastHowLongAgoAndStationCode(Long time, int howLongAgo, String stationCode) {
        QueryWrapper<ForecastPowerShortTermStation> wrapper = new QueryWrapper<>();

        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }
        if (time != null) {
            wrapper.eq("forecast_time", new Date(time));
        }
        wrapper.eq("forecast_how_long_ago", howLongAgo);
        return baseMapper.selectOne(wrapper);
    }


    @Override
    public List<ForecastPowerShortTermStation> findByForecastTimeBetweenAndForecastHowLongAgoAndStationCode(Long startTime, Long endTime, Integer howLongAgo, String stationCode) {
        QueryWrapper<ForecastPowerShortTermStation> wrapper = new QueryWrapper<>();

        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }
        if (startTime != null && endTime != null) {
            wrapper.between("forecast_time", new Date(startTime), new Date(endTime));
        }
        wrapper.eq("forecast_how_long_ago", howLongAgo);
        return baseMapper.selectList(wrapper);
    }

//
//    /**
//     * 气象站数据业务层实现类
//     *
//     * @author tl
//     * @date 2022-05-11 18:07:03
//     */
//    @Service
//    public static class ForecastManufactorServiceImpl extends ServiceImpl<ForecastManufactorMapper, ForecastManufactor> implements ForecastManufactorService {
//
//    }
}
