/*
 * 文 件 名:  WeatherServiceImpl
 * 版    权:  华设设计集团股份有限公司
 * 描    述:  <描述>
 * 修 改 人:  lvwenbin
 * 修改时间:  2025/5/22
 * 跟踪单号:  <跟踪单号>
 * 修改单号:  <修改单号>
 * 修改内容:  <修改内容>
 */
package com.ruoyi.ems.service.impl;

import com.huashe.common.domain.model.WeatherForecast;
import com.huashe.common.domain.model.WeatherRt;
import com.ruoyi.ems.mapper.AdmWeatherForecastMapper;
import com.ruoyi.ems.mapper.AdmWeatherRtMapper;
import com.ruoyi.ems.service.IWeatherService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 天气服务
 * <功能详细描述>
 *
 * @author lvwenbin
 * @version [版本号, 2025/5/22]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Service
public class WeatherServiceImpl implements IWeatherService {
    private static final Logger log = LoggerFactory.getLogger(WeatherServiceImpl.class);

    @Resource
    private AdmWeatherRtMapper weatherRtMapper;

    @Resource
    private AdmWeatherForecastMapper weatherForecastMapper;

    @Override
    public WeatherRt getWeatherRt(String adcode) {
        return weatherRtMapper.getNewByAdcode(adcode);
    }

    @Override
    public void mergeRt(WeatherRt weatherRt) {
        weatherRtMapper.merge(weatherRt);
    }

    @Override
    public List<WeatherRt> getWeatherHis(String adcode, String startTime, String endTime) {
        return weatherRtMapper.getByTime(adcode, startTime, endTime);
    }

    @Override
    public List<WeatherForecast> getWeatherForecast(String adcode, String startTime, String endTime) {
        return weatherForecastMapper.getByAdcode(adcode, startTime, endTime);
    }

    @Override
    public int deleteForecastByAdcode(String adcode) {
        return weatherForecastMapper.deleteByAdcode(adcode);
    }

    @Override
    public void insertForecastBacth(List<WeatherForecast> forecasts) {
        weatherForecastMapper.insertBatch(forecasts);
    }
}