Newer
Older
newfiber-data-adapter / src / main / java / org / springnewfiber / dataadapter / entity / PtReceiveBaseModel.java
package org.springnewfiber.dataadapter.entity;

import com.google.common.collect.Sets;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import java.util.Set;

/**
 * 对接产品化,,通用接受mq
 */
@Data
public class PtReceiveBaseModel implements Serializable {
    public static final Set<String> constantSet = Sets.newHashSet(RealTimeConsstant.st, RealTimeConsstant.tt, RealTimeConsstant.ut);
    public static final Set<String> XFconstantSet = Sets.newHashSet(RealTimeConsstant.xfst, RealTimeConsstant.xftt, RealTimeConsstant.xfstnm);

    /**
     * 站点标识符
     */
    private String st;
    /**
     * 传感器标识符
     */
    @Deprecated
    private String sn;
    /**
     * 观测时间
     */
    private Date tt;

    /**
     * 上报时间
     */
    private Date ut;
    /**
     * 具体数据
     */
    private Map<String, MqNodeData> dataMap;

    /**
     * 数据转换
     *
     * @param rtuReportData
     * @param elementItemLoader
     * @return
     */
//    public static PtReceiveBaseModel rtuSl6512014ConvertModel(RtuReportData rtuReportData, ElementItemLoader elementItemLoader) {
//        Map<String, Object> metaData = rtuReportData.getMap();
//        Map<String, Object> objectMap = Maps.newHashMap(metaData);
//        PtReceiveBaseModel model = new PtReceiveBaseModel();
//        Date tt = SaveDbContext.strToDate(objectMap.get(SaveDbContext.MapConstant.TT).toString());
//        Date ut = SaveDbContext.strToDate(objectMap.get(SaveDbContext.MapConstant.UT).toString());
//        model.setSt(objectMap.get(SaveDbContext.MapConstant.ST).toString());
//        model.setTt(tt);
//        model.setUt(ut);
//        objectMap.remove(SaveDbContext.MapConstant.ST);
//        objectMap.remove(SaveDbContext.MapConstant.TT);
//        objectMap.remove(SaveDbContext.MapConstant.UT);
//        Map<String, BigDecimal> receiveMap = Maps.newHashMap();
//        rtuReportData.getReportResult().getErrorSet().forEach(i -> {
//            ElementItem elementItem = elementItemLoader.getCodeMap().get(i);
//            receiveMap.put(i, elementItem == null ? new BigDecimal(MysqlSaveToConfigHandle.CountAsciiVarHandle.defultExceptionValue) : new BigDecimal(elementItem.getExceptionValue()));
//        });
//        objectMap.putAll(receiveMap);
//        model.setDataMap(objectMap);
//        return model;
//    }
    public interface RealTimeConsstant {
        String tt = "tt";
        String ut = "ut";
        String st = "st";
        String sn = "sn";
        String xfst = "stcd";
        String xftt = "tm";
        String xfstnm = "stnm";
    }
}