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.MeasurePointRunLogsEvent;
import com.zt.plat.module.qms.iot.tcpserver.pojo.MeasurePointRunLogs;

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

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

    /**
     * 发布计量点运行日志事件
     * @param measurePointId 计量点Id
     * @param measurePointCode 计量点编号
     * @param tenantId 租户id
     * @param time C# utc long时间
     * @param content 日志内容
     */
    public static void publishEvent(String measurePointId, String measurePointCode, String tenantId, String utcTime, String content) {
        MeasurePointRunLogs measurePointRunLogs = new MeasurePointRunLogs();
        measurePointRunLogs.setMeasurePointId(measurePointId);
        measurePointRunLogs.setMeasurePointCode(measurePointCode);
        measurePointRunLogs.setTenantId(tenantId);
        measurePointRunLogs.setTime(utcTime);
        measurePointRunLogs.setContent(content);
        Map<String, Object> event = new HashMap<>(16);
        event.put(EventConstant.EVENT_MEASURE_POINT_RUN_LOGS, measurePointRunLogs);
        SpringUtil.publishEvent(new MeasurePointRunLogsEvent(event));
    }
}
