package com.jiayue.passback.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.passback.entity.WeatherStationStatusData;
import com.jiayue.passback.mapper.WeatherStationStatusDataMapper;
import com.jiayue.passback.service.WeatherStationInfoService;
import com.jiayue.passback.service.WeatherStationStatusDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
@Slf4j
public class WeatherStationStatusDataServiceImpl extends ServiceImpl<WeatherStationStatusDataMapper, WeatherStationStatusData> implements WeatherStationStatusDataService {
    @Autowired
    private WeatherStationInfoService weatherStationInfoService;
    @Override
    public Map<String, Object> GenerateData(Date date) {
        Map<String, Object> map = new HashMap<>();
        List<WeatherStationStatusData> list = new ArrayList<>();

        List<WeatherStationStatusData> weatherStationStatusDataList = list(lambdaQuery().eq(WeatherStationStatusData::getTime, date).eq(WeatherStationStatusData::getEquipmentNo,weatherStationInfoService.weatherStationInfoId()).getWrapper());

            if (weatherStationStatusDataList.size() > 0) {
            list.add(weatherStationStatusDataList.get(0));
        }

        map.put(WeatherStationStatusData.class.getSimpleName(), list);
        log.info("获取气象站记录数{}", list.size());
        return map;
    }
}
