package com.jiayue.passback.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.passback.entity.PowerStationStatusData;
import com.jiayue.passback.mapper.PowerStationStatusDataMapper;
import com.jiayue.passback.service.PowerStationStatusDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
@Slf4j
public class PowerStationStatusDataServiceImpl extends ServiceImpl<PowerStationStatusDataMapper, PowerStationStatusData> implements PowerStationStatusDataService {

    @Override
    public Map<String, Object> GenerateData(Date date) {
        Map<String, Object> map = new HashMap<>();
        List<PowerStationStatusData> list = new ArrayList<>();

        List<PowerStationStatusData> powerStationStatusDataList = list(lambdaQuery().eq(PowerStationStatusData::getTime, date).getWrapper());

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

        map.put(PowerStationStatusData.class.getSimpleName(), list);
        log.info("获取实际功率、可用功率、理论功率、限电记录数{}", list.size());
        return map;
    }

}
