package com.jiayue.passback.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.passback.entity.WindTowerStatusData;
import com.jiayue.passback.mapper.WindTowerStatusDataMapper;
import com.jiayue.passback.service.WindTowerInfoService;
import com.jiayue.passback.service.WindTowerStatusDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
@Slf4j
public class WindTowerStatusDataServiceImpl extends ServiceImpl<WindTowerStatusDataMapper, WindTowerStatusData> implements WindTowerStatusDataService {
    @Autowired
    private WindTowerInfoService windTowerInfoService;
    @Override
    public Map<String, Object> GenerateData(Date date) {
        Map<String, Object> map = new HashMap<>();
        List<WindTowerStatusData> list = new ArrayList<>();

        List<WindTowerStatusData> windTowerStatusDataList = list(lambdaQuery().eq(WindTowerStatusData::getTime, date).eq(WindTowerStatusData::getEquipmentNo,windTowerInfoService.WindTowerInfoInfoId()).getWrapper());

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

        map.put(WindTowerStatusData.class.getSimpleName(), list);
        log.info("获取测风塔记录数{}", list.size());
        return map;
    }
}
