package cn.wise.sc.energy.power.plant.business.domain;

import cn.hutool.core.codec.Base64Decoder;
import cn.hutool.core.codec.Base64Encoder;
import com.alibaba.fastjson.JSON;
import com.spring4all.spring.boot.starter.hbase.api.RowMapper;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

import java.util.NavigableMap;
import java.util.Set;

/**
 * @description:
 * @author: qh
 * @create: 2020-08-24 16:37
 **/
@Deprecated
public class OscillogramTagsMapper implements RowMapper<Oscillogram> {

    private static byte[] COLUMNFAMILY = "tags".getBytes();
    private static byte[] TIMESPAN = "TimeSpan".getBytes();
    private static byte[] DATATYPE = "DataType".getBytes();
    private static byte[] DIRECTION = "Direction".getBytes();
    private static byte[] GENERATIONFREQ = "GenerationFreq".getBytes();
    private static byte[] KKSCODE = "KKSCode".getBytes();
    private static byte[] PARTTYPE = "PartType".getBytes();
    private static byte[] POLENUM = "PoleNum".getBytes();
    private static byte[] RECORDFLAG = "RecordFlag".getBytes();
    private static byte[] SIGNALTYPE = "Signaltype".getBytes();
    private static byte[] STARTTIME = "StartTime".getBytes();

    @Override
    public Oscillogram mapRow(Result result, int rowNum) throws Exception {

        String timeSpan = Bytes.toString(result.getValue(COLUMNFAMILY, TIMESPAN));
        String dataType = Bytes.toString(result.getValue(COLUMNFAMILY, DATATYPE));
        String direction = Bytes.toString(result.getValue(COLUMNFAMILY, DIRECTION));
        String generationFreq = Bytes.toString(result.getValue(COLUMNFAMILY, GENERATIONFREQ));
        String kKSCode = Bytes.toString(result.getValue(COLUMNFAMILY, GENERATIONFREQ));
        String partType = Bytes.toString(result.getValue(COLUMNFAMILY, PARTTYPE));
        String poleNum = Bytes.toString(result.getValue(COLUMNFAMILY, POLENUM));
        String recordFlag = Bytes.toString(result.getValue(COLUMNFAMILY, RECORDFLAG));
        String signaltype = Bytes.toString(result.getValue(COLUMNFAMILY, SIGNALTYPE));
        String startTime = Bytes.toString(result.getValue(COLUMNFAMILY, STARTTIME));

        Oscillogram oscillogram = new Oscillogram();
        oscillogram.setTimeSpan(Long.parseLong(timeSpan));
        oscillogram.setRecordFlag(Integer.parseInt(recordFlag));
        oscillogram.setRowKey(Base64Encoder.encode(result.getRow()));
        oscillogram.setPeriod(0);
        oscillogram.setGenerationFreq(Integer.parseInt(generationFreq));
        oscillogram.setPoleNum(Integer.parseInt(poleNum));
        return oscillogram;
    }
}
