package com.zt.plat.module.qms.iot.tcpserver.publisher;

import cn.hutool.extra.spring.SpringUtil;
import com.zt.plat.module.qms.iot.tcpserver.core.EventConstant;
import com.zt.plat.module.qms.iot.tcpserver.event.HygrothermographEvent;
import com.zt.plat.module.qms.iot.tcpserver.pojo.Hygrothermograph;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * <b>HygrothermographPublisher</b>
 * <p>更新历史：</p>
 * <pre> 版本         更新时间            更新者        更新内容
 * V1.0      2021-10-18          王兴荣         Add</pre>
 * <b>Copyright (C)  云南志者竟成科技有限公司</b> 
 * @author 王兴荣 &lt;xingrong_wang@will-way.cn&gt;
 * @version V1.0 
 * @since 2021-10-18
 */
public class HygrothermographPublisher {

    /**
     * 发布事件
     * @param deviceId 设备id
     * @param tenantId 租户id
     * @param temperature 温度
     * @param humidity 湿度
     */
    public static void publishEvent(Long deviceId, String tenantId, Integer temperature, Integer humidity) {
        Hygrothermograph hygrothermograph = new Hygrothermograph();
        hygrothermograph.setDevid(deviceId);
        hygrothermograph.setTenantId(tenantId);
        hygrothermograph.setTstamp(new Date());
        hygrothermograph.setTemperature(temperature);
        hygrothermograph.setHumidity(humidity);
        Map<String, Object> event = new HashMap<>(16);
        event.put(EventConstant.EVENT_HYGROTHERMOGRAPH, hygrothermograph);
        SpringUtil.publishEvent(new HygrothermographEvent(event));
    }
}
