package com.yfd.platform.modules.basedata.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.modules.auxcontrol.mapper.DeviceWorkDataMapper;
import com.yfd.platform.modules.basedata.domain.WeatherLog;
import com.yfd.platform.modules.basedata.mapper.WeatherLogMapper;
import com.yfd.platform.modules.basedata.service.IWeatherLogService;
import com.yfd.platform.system.service.ISysDictionaryItemsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 微气象数据日志表 服务实现类
 * </p>
 *
 *
 * @since 2023-04-27
 */
@Service
public class WeatherLogServiceImpl extends ServiceImpl<WeatherLogMapper, WeatherLog> implements IWeatherLogService {

    @Resource
    private DeviceWorkDataMapper deviceWorkDataMapper;

    /**********************************
     * 用途说明: 查询环境信息
     * 参数说明 stationId
     * 返回值说明: java.util.Map<java.lang.String,java.lang.Object>
     ***********************************/
    @Override
    public Map<String, Object> getWeatherLogList(String stationId) {
        List<Map<String, Object>> deviceWorkData = deviceWorkDataMapper.getDeviceWorkData(stationId);
        Map<String, Object> map = new HashMap<>();
        for (Map<String, Object> deviceWorkDatum : deviceWorkData) {
            map.put(deviceWorkDatum.get("itemcode").toString(), deviceWorkDatum.get("value"));
        }
        return map;
    }
}
