package org.ts.ddcs.DataItemTemplate.DataItemTemplateSzy2012;

import org.ts.ddcs.DataItemTemplate.DataItemTemplate;

import org.ts.ddcs.Entity.WaterEntity;
import org.ts.ddcs.Tool.BytesHelp;

import java.math.BigDecimal;

/**
 * AFN C0  C 10
 * 自报 水质参数
 */
@SuppressWarnings("all")
public class DataItemTemplateC0_WaterQuality extends DataItemTemplate {
    @Override
    public byte[] Stream(byte[] data) {
        byte[] remain = data;
        if (remain.length < 4) {
            return remain;
        }
        int count = 0;
        this.valueBuff = new byte[4];
        this.valueBuff[0] = remain[3];
        this.valueBuff[1] = remain[2];
        this.valueBuff[2] = remain[1];
        this.valueBuff[3] = remain[0];
        count += 4;
        String value = BytesHelp.byte2HexStr(this.valueBuff);
        if (this.sqlColumn.equals("WT")) {
            //水温
            String sv = value.substring(0, value.length() - 1) + "." + value.substring(value.length() - 1, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("PH")) {
            //pH 值
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("DOX")) {
            //溶解氧
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CODMN")) {
            //高锰酸盐指数
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("COND")) {
            //电导率
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(value));
        } else if (this.sqlColumn.equals("ORP")) {
            //氧化还原电位
            String sv = value.substring(0, value.length() - 1) + "." + value.substring(value.length() - 1, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("TURB")) {
            //浊度
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(value));
        } else if (this.sqlColumn.equals("CODCR")) {
            //化学需氧量
            String sv = value.substring(0, value.length() - 1) + "." + value.substring(value.length() - 1, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CODCR_5D")) {
            //五日生化需氧量
            String sv = value.substring(0, value.length() - 1) + "." + value.substring(value.length() - 1, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("NH3N")) {
            //氨氮
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("TN")) {
            //总氮
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CU")) {
            //铜
            String sv = value.substring(0, value.length() - 4) + "." + value.substring(value.length() - 4, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("ZN")) {
            //锌
            String sv = value.substring(0, value.length() - 4) + "." + value.substring(value.length() - 4, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("F")) {
            //氟化物
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("SE")) {
            //硒
            String sv = value.substring(0, value.length() - 5) + "." + value.substring(value.length() - 5, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("ARS")) {
            //砷
            String sv = value.substring(0, value.length() - 5) + "." + value.substring(value.length() - 5, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("HG")) {
            //汞
            String sv = value.substring(0, value.length() - 5) + "." + value.substring(value.length() - 5, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CD")) {
            //镉
            String sv = value.substring(0, value.length() - 5) + "." + value.substring(value.length() - 5, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CR6")) {
            //六价铬
            String sv = value.substring(0, value.length() - 3) + "." + value.substring(value.length() - 3, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("PB")) {
            //铅
            String sv = value.substring(0, value.length() - 5) + "." + value.substring(value.length() - 5, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CYN")) {
            //氰化物
            String sv = value.substring(0, value.length() - 3) + "." + value.substring(value.length() - 3, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("VH")) {
            //挥发酚
            String sv = value.substring(0, value.length() - 3) + "." + value.substring(value.length() - 3, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("C6H5OH")) {
            //苯酚
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("COS")) {
            //硫化物
            String sv = value.substring(0, value.length() - 3) + "." + value.substring(value.length() - 3, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("EPEC")) {
            //粪大肠菌群
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(value));
        } else if (this.sqlColumn.equals("NaSO4")) {
            //硫酸盐
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CL")) {
            //氯化物
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("NO3")) {
            //硝酸盐氮
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("FE")) {
            //铁
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("MN")) {
            //锰
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("OIL")) {
            //石油类
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("AS")) {
            //阴离子表面活性剂
            String sv = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("SIXSIXSIX")) {
            //六六六
            String sv = value.substring(0, value.length() - 6) + "." + value.substring(value.length() - 6, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("DDT")) {
            //滴滴涕
            String sv = value.substring(0, value.length() - 6) + "." + value.substring(value.length() - 6, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("OCPs")) {
            //有机氯农药
            String sv = value.substring(0, value.length() - 6) + "." + value.substring(value.length() - 6, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("TP")) {
            //总磷
            String sv = value.substring(0, value.length() - 3) + "." + value.substring(value.length() - 3, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        } else if (this.sqlColumn.equals("CHLA")) {
            //叶绿素
            String sv = value.substring(0, value.length() - 3) + "." + value.substring(value.length() - 3, value.length());
            this.bigDecimalValue = BigDecimal.valueOf(Double.parseDouble(sv));
        }
        if (remain.length - count > 0) {
            remain = BytesHelp.subBytes(remain, count, remain.length - count);
        } else {
            remain = new byte[0];
        }
        this.macth = true;
        return remain;
    }

    @Override
    public void SetEntity(Object entity) {
        WaterEntity waterEntity = (WaterEntity) entity;
        if (this.sqlColumn.equals("WT")) {
            //水温
            waterEntity.setWT(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("PH")) {
            //pH 值
            waterEntity.setPH(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("DOX")) {
            //溶解氧
            waterEntity.setDOX(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CODMN")) {
            //高锰酸盐指数
            waterEntity.setCODMN(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("COND")) {
            //电导率
            waterEntity.setCOND(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("ORP")) {
            //氧化还原电位
            waterEntity.setORP(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("TURB")) {
            //浊度
            waterEntity.setTURB(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CODCR")) {
            //化学需氧量
            waterEntity.setCODCR(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CODCR_5D")) {
            //五日生化需氧量
            waterEntity.setCODCR_5D(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("NH3N")) {
            //氨氮
            waterEntity.setNH3N(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("TN")) {
            //总氮
            waterEntity.setTN(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CU")) {
            //铜
            waterEntity.setCU(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("ZN")) {
            //锌
            waterEntity.setZN(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("F")) {
            //氟化物
            waterEntity.setF(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("SE")) {
            //硒
            waterEntity.setSE(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("ARS")) {
            //砷
            waterEntity.setARS(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("HG")) {
            //汞
            waterEntity.setHG(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CD")) {
            //镉
            waterEntity.setCD(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CR6")) {
            //六价铬
            waterEntity.setCR6(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("PB")) {
            //铅
            waterEntity.setPB(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CYN")) {
            //氰化物
            waterEntity.setCYN(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("VH")) {
            //挥发酚
            waterEntity.setVH(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("C6H5OH")) {
            //苯酚
            waterEntity.setC6H5OH(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("COS")) {
            //硫化物
            waterEntity.setCOS(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("EPEC")) {
            //粪大肠菌群
            waterEntity.setEPEC(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("NaSO4")) {
            //硫酸盐
            waterEntity.setNaSO4(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CL")) {
            //氯化物
            waterEntity.setCL(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("NO3")) {
            //硝酸盐氮
            waterEntity.setNO3(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("FE")) {
            //铁
            waterEntity.setFE(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("MN")) {
            //锰
            waterEntity.setMN(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("OIL")) {
            //石油类
            waterEntity.setOIL(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("AS")) {
            //阴离子表面活性剂
            waterEntity.setAS(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("SIXSIXSIX")) {
            //六六六
            waterEntity.setSIXSIXSIX(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("DDT")) {
            //滴滴涕
            waterEntity.setDDT(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("OCPs")) {
            //有机氯农药
            waterEntity.setOCPs(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("TP")) {
            //总磷
            waterEntity.setTP(this.bigDecimalValue);
        } else if (this.sqlColumn.equals("CHLA")) {
            //叶绿素
            waterEntity.setCHLA(this.bigDecimalValue);
        }
    }
}
