package com.huatek.busi.util;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;


public class Sanbizhi {


    public static void main(String [] args ){

        System.out.println("--------中/低温过热故障数据-----------");
        System.out.println(getSanBiZhiResult("181","262","210","528","0","0","0"));
        System.out.println(getSanBiZhiResult("160","130",	"33",	"96",	"0","0","0"));


        System.out.println("---------局部放电-----------");
        System.out.println(getSanBiZhiResult("980","73","58","12","0" ,"0","0"));
        System.out.println(getSanBiZhiResult("650",	"53","34","20","0","0","0"));

        System.out.println("---------高能放电-----------");
        System.out.println(getSanBiZhiResult("60","40","10","110","70" ,"0","0"));
        System.out.println(getSanBiZhiResult("420","200","14","230","180","0","0"));


        System.out.println("---------高温过热-----------");
        System.out.println(getSanBiZhiResult("70.40", 	"69.50", 	"28.90", 	"241.20","10.40","0","0"));
        System.out.println(getSanBiZhiResult("90.00", 	"149.00", 	"32.40", 	"486.00","19.20","0","0"));


        System.out.println("---------低能放电-----------");
        System.out.println(getSanBiZhiResult("345.00", 	"112.25", 	"27.50", 	"51.50", 	"58.75","0","0"));
        System.out.println(getSanBiZhiResult("565.00", 	"93.00", 	"34.00", 	"47.00", 	"0.00","0","0"));

        System.out.println("---------高能放电-----------");
        System.out.println(getSanBiZhiResult("60.00", 	"40.00", 	"10.00", 	"110.00", "70.00","0","0"));
        System.out.println(getSanBiZhiResult("420.00", "200.00", 	"14.00", 	"230.00", "180.00","0","0"));


        System.out.println("---------九比值-----------");
        System.out.println(getSanBiZhiResult("240.58",	"115.3",	"28.57",	"2.83",	"0",	"314.75",	"957.49"));


    }


    ////sanbizhi
    public static  Map<String,String> getSanBiZhiResult(String H2,String CH4,String C2H6,String C2H4,String C2H2,String CO,String CO2)
    {
        Map<String,String> mapResult = new HashMap<>();

        Double _C2H2 =Double.valueOf(C2H2);
        Double _C2H4 =Double.valueOf(C2H4);
        Double _C2H6 =Double.valueOf(C2H6);
        Double _CH4 =Double.valueOf(CH4);
        Double _H2 =Double.valueOf(H2);

        //如果分母为0直接计算九比值
        if(_C2H4 == 0.0 || _H2 == 0.0 || _C2H6 == 0.0){
            ////九比值故障码提示信息
            mapResult = getJiuBiZhiCodeMsgResult(H2,CH4,C2H6,C2H4,C2H2,CO,CO2);
            return mapResult ;
        }        
        
        
        double  C2H2_C2H4 = 0.0;
        if(_C2H4>0) {
            C2H2_C2H4 = div(_C2H2, _C2H4, 2);
        }

        double  CH4_H2 = 0.0;
        if(_H2>0){
            CH4_H2 = div(_CH4,_H2,2);
        }

        double  C2H4_C2H6 = 0.0 ;
        if(_C2H6>0){
            C2H4_C2H6 = div(_C2H4,_C2H6,2);
        }

        String C2H2_C2H4_Code = "";
        String CH4_H2_Code = "";
        String C2H4_C2H6_Code = "";

        if(C2H2_C2H4<0.1){
            C2H2_C2H4_Code = "0";
        }else if(C2H2_C2H4>= 0.1 && C2H2_C2H4 <1  ){
            C2H2_C2H4_Code = "1";
        }else if(C2H2_C2H4>= 1 && C2H2_C2H4 <3  ) {
            C2H2_C2H4_Code = "1";
        }else {     ////    >=3
            C2H2_C2H4_Code = "2";
        }


        if(CH4_H2<0.1){
            CH4_H2_Code = "1";
        }else if(CH4_H2>= 0.1 && CH4_H2 <1  ){
            CH4_H2_Code = "0";
        }else if(CH4_H2>= 1 && CH4_H2 <3  ) {
            CH4_H2_Code = "2";
        }else {     ////    >=3
            CH4_H2_Code = "2";
        }

        if(C2H4_C2H6<0.1){
            C2H4_C2H6_Code = "0";
        }else if(C2H4_C2H6>= 0.1 && C2H4_C2H6 <1  ){
            C2H4_C2H6_Code = "0";
        }else if(C2H4_C2H6>= 1 && C2H4_C2H6 <3  ) {
            C2H4_C2H6_Code = "1";
        }else {     ////    >=3
            C2H4_C2H6_Code = "2";
        }


        String sanBiZhiCode = C2H2_C2H4_Code+CH4_H2_Code+C2H4_C2H6_Code ;
        String[] sanBiZhiCodeMsg = getSanBiZhiCodeMsgResult(C2H2_C2H4_Code+CH4_H2_Code+C2H4_C2H6_Code).split("@@");

        if(sanBiZhiCodeMsg[0].length()>0){
            mapResult.put("code",sanBiZhiCode);
            mapResult.put("codemsg",sanBiZhiCodeMsg[0]);
            mapResult.put("discription",sanBiZhiCodeMsg[1]);
            
            
            //// 变压器油过热，且当热点温度高于400℃时 (中温、高温过热)
            if(sanBiZhiCode.contains("021") ||sanBiZhiCode.contains("002") ||sanBiZhiCode.contains("012") ||sanBiZhiCode.contains("022")  ){
                String tempValue = getTemperater_A(_C2H2,_C2H6);
                mapResult.put("estimate_temperater","系统预估温度："+ tempValue);
            }
            Double _CO =Double.valueOf(CO);
            Double _CO2 =Double.valueOf(CO2);
            if(_CO != 0d){
            	  Double _C02_CO_Value = _CO2/_CO ;
            	  if(_C02_CO_Value < 0 ||  _C02_CO_Value >10 ){
                      if(sanBiZhiCode.equals("020") || sanBiZhiCode.equals("001")){
                          String tempValue = getTemperater_Down300( _C2H4, _C2H6, _CO2 , _CO);
                          mapResult.put("hotspot_temperater","系统预估绝缘低热点温度："+ tempValue);
                      }
                      ////
                      if(sanBiZhiCode.contains("021") ||sanBiZhiCode.contains("002") ||sanBiZhiCode.contains("012") ||sanBiZhiCode.contains("022") ){
                          String tempValue = getTemperater_Up300( _C2H4, _C2H6, _CO2 , _CO);
                          mapResult.put("hotspot_temperater","系统预估绝缘低热点温度："+ tempValue);
                      }
                  } 
            }

        }else {
            ////九比值故障码提示信息
            mapResult = getJiuBiZhiCodeMsgResult(H2,CH4,C2H6,C2H4,C2H2,CO,CO2);

        }
        
        return mapResult ;
    }

    /////jiubizhi
    public  static String getSanBiZhiCodeMsgResult(String codeValue) {

//        附件表6（三比值故障代码）
//        范围	 C2H2/C2H4	CH4/H2	C2H4/C2H6
//        ＜0.1	      0	      1	      0
//        ≥0.1--＜1	  1	      0	      0
//        ≥1--＜3	  1	      2	      1
//        ≥3	      2	      2	      2

//        if(codeValue.equals("000")){
//            return "无故障@@自然老化";
//        }
        if(codeValue.equals("001")){
            return "低温过热＜150℃@@一般性的绝缘导线过热";
        }
        if(codeValue.equals("020")){
            return "低温过热150--300℃@@引线夹件螺丝松动";
        }
        if(codeValue.equals("021")){
            return "中温过热300℃--700℃@@铁芯局部过热";
        }
        if(codeValue.equals("002") ||codeValue.equals("012") ||codeValue.equals("022") ){
            return "高温过热＞700℃@@热点温度增加，从铁芯中的小热点，铁芯短路，由于涡流引起的铜过热，接头或接触不良、焊接不良（形成丝炭）及铁芯、和外壳的环流、铁芯多点接地。";
        }
        if(codeValue.equals("010")){
            return "局部放电@@由于不完全浸渍引起含气孔穴中的放电，或过分饱和或高温度引起的孔穴中的放电。";
        }
        if(codeValue.equals("101")||codeValue.equals("100") ||codeValue.equals("102") ||codeValue.equals("110") ||codeValue.equals("111")   ||codeValue.equals("112") ){
            return "高能放电@@引线对为固定的直接连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电，悬浮电位之间火花放电";
        }
        if(codeValue.equals("120")||codeValue.equals("121") ||codeValue.equals("122")){
            return "高能放电兼过热@@引线对为固定的直接连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电，悬浮电位之间火花放电";
        }
        if(codeValue.equals("200")||codeValue.equals("201") ||codeValue.equals("202") ||codeValue.equals("210")||codeValue.equals("211") ||codeValue.equals("212")  ){
            return "低能放电@@引线时电位未固定的部件之间连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电或悬浮之间火花放电。";
        }
        if(codeValue.equals("220")||codeValue.equals("221") ||codeValue.equals("222")  ){
            return "低能放电兼过热@@引线时电位未固定的部件之间连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电或悬浮之间火花放电。";
        }
        if(codeValue.equals("100")||codeValue.equals("101") ||codeValue.equals("102")
                ||codeValue.equals("110")||codeValue.equals("111")||codeValue.equals("112")){
            return "电弧放电@@绕组匝间，层间短路，相间闪络，分接头引线间油隙闪络，引线对箱壳放电，绕组熔断，分接开关飞弧，因环路电流引起电弧，引对对接地待放电等。";
        }
        if(codeValue.equals("120")||codeValue.equals("121") ||codeValue.equals("122")){
            return "电弧放电兼过热@@绕组匝间，层间短路，相间闪络，分接头引线间油隙闪络，引线对箱壳放电，绕组熔断，分接开关飞弧，因环路电流引起电弧，引对对接地待放电等。";
        }
        return "";

    }


    /////jiubizhi
    public static Map<String,String> getJiuBiZhiCodeMsgResult(String H2,String CH4,String C2H6,String C2H4,String C2H2,String CO,String CO2)
    {
        Double _H2 =Double.valueOf(H2);
        Double _CH4 =Double.valueOf(CH4);
        Double _C2H6 =Double.valueOf(C2H6);
        Double _C2H4 =Double.valueOf(C2H4);
        Double _C2H2 =Double.valueOf(C2H2);
        Double _CO =Double.valueOf(CO);
        Double _CO2 =Double.valueOf(CO2);

        Double _C1_C2 = _CO+_CO2+_CH4+_C2H2+_C2H4+_C2H6 ;
        Double _H2_C1_C2 = _H2 + _CO+_CO2+_CH4+_C2H2+_C2H4+_C2H6;

        Integer Code_Col1=0;
        Integer Code_Col2=0;
        Integer Code_Col3=0;
        Integer Code_Col4=0;
        Integer Code_Col5=0;
        Integer Code_Col6=0;
        Integer Code_Col7=0;
        Integer Code_Col8=0;



        ////1  CH4/H2
        double  CH4_H2 = 0.0;
        if(_H2>0) {
            CH4_H2 = div(_CH4, _H2, 2);

            if(CH4_H2>=0.1 && CH4_H2<0.97){
                Code_Col1++;
            }
            if(CH4_H2>=0.03 && CH4_H2<0.75){
                Code_Col2++;
            }
            if(CH4_H2>=0.01 && CH4_H2<0.96){
                Code_Col3++;
            }
            if(CH4_H2>=1.6 && CH4_H2<3.5){
                Code_Col4++;
            }
            if(CH4_H2>=1.05 && CH4_H2<2.48){
                Code_Col5++;
            }
            if(CH4_H2>=0.37 && CH4_H2<8.4){
                Code_Col6++;
            }
            if(CH4_H2>=0.75 && CH4_H2<24.2){
                Code_Col7++;
            }
            if(CH4_H2>=0.62 && CH4_H2<3.2){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_H2 == 0.0){
        	 Code_Col8++;
        }


        ////2  C2H2/C2H4
        double  C2H2_C2H4 = 0.0;
        if(_C2H4>0) {
            C2H2_C2H4 = div(_C2H2, _C2H4, 2);

            if(C2H2_C2H4>=0.1 && C2H2_C2H4<2.91){
                Code_Col1++;
            }
            if(C2H2_C2H4>=0.11 && C2H2_C2H4<2.63){
                Code_Col2++;
            }
            if(C2H2_C2H4>=3.02 && C2H2_C2H4<20.0){
                Code_Col3++;
            }
            if(C2H2_C2H4>=3.13 && C2H2_C2H4<18.46){
                Code_Col4++;
            }
            if(C2H2_C2H4>=0.1 && C2H2_C2H4<2.81){
                Code_Col5++;
            }
            if(C2H2_C2H4>=0 && C2H2_C2H4<0.1){
                Code_Col6++;
            }
            if(C2H2_C2H4>=0 && C2H2_C2H4<0.1){
                Code_Col7++;
            }
            if(C2H2_C2H4>=0 && C2H2_C2H4<0.1){
                Code_Col8++;
            }
        }        
        //分母为0时，取最大值
        if(_C2H4 == 0.0){
        	 Code_Col8++;
        }

        ////3  C2H4/C2H6
        double  C2H4_C2H6 = 0.0;
        if(_C2H6>0) {
            C2H4_C2H6 = div(_C2H4, _C2H6, 2);

            if(C2H4_C2H6>=3.4 && C2H4_C2H6<50){
                Code_Col1++;
            }
            if(C2H4_C2H6>=0.24 && C2H4_C2H6<11.6){
                Code_Col2++;
            }
            if(C2H4_C2H6>=3.2 && C2H4_C2H6<65.2){
                Code_Col3++;
            }
            if(C2H4_C2H6>=0.08 && C2H4_C2H6<11.5){
                Code_Col4++;
            }
            if(C2H4_C2H6>=0.2 && C2H4_C2H6<18.0){
                Code_Col5++;
            }
            if(C2H4_C2H6>=3.07 && C2H4_C2H6<17.1){
                Code_Col6++;
            }
            if(C2H4_C2H6>=1.25 && C2H4_C2H6<3.0){
                Code_Col7++;
            }
            if(C2H4_C2H6>=0.12 && C2H4_C2H6<0.95){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_C2H6 == 0.0){
        	 Code_Col8++;
        }


        ////4  C2H2/C1+C2/%
        double  C2H2_C1_C2 = 0.0;

        if(_C1_C2>0) {
            C2H2_C1_C2 = div(_C2H2, _C1_C2, 2);

            if(C2H2_C1_C2>=4.4 && C2H2_C1_C2<67.4){
                Code_Col1++;
            }
            if(C2H2_C1_C2>=3.5 && C2H2_C1_C2<56.5){
                Code_Col2++;
            }
            if(C2H2_C1_C2>=4.4 && C2H2_C1_C2<67.4){
                Code_Col3++;
            }
            if(C2H2_C1_C2>=17.2 && C2H2_C1_C2<89.4){
                Code_Col4++;
            }
            if(C2H2_C1_C2>=1.7 && C2H2_C1_C2<60.7){
                Code_Col5++;
            }
            if(C2H2_C1_C2>=0 && C2H2_C1_C2<5.99){
                Code_Col6++;
            }
            if(C2H2_C1_C2>=0 && C2H2_C1_C2<4.2){
                Code_Col7++;
            }
            if(C2H2_C1_C2>=0 && C2H2_C1_C2<3){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_C1_C2 == 0.0){
        	 Code_Col8++;
        }

        ////5  H2/H2+C1+C2/%
        double  H2_H2_C1_C2 = 0.0;

        if(_H2_C1_C2>0) {
            H2_H2_C1_C2 = div(_H2, _H2_C1_C2, 2);

            if(H2_H2_C1_C2>=3.3 && H2_H2_C1_C2<87.6){
                Code_Col1++;
            }
            if(H2_H2_C1_C2>=5.9 && H2_H2_C1_C2<81.4){
                Code_Col2++;
            }
            if(H2_H2_C1_C2>=6.3 && H2_H2_C1_C2<59.7){
                Code_Col3++;
            }
            if(H2_H2_C1_C2>=11.1 && H2_H2_C1_C2<37.3){
                Code_Col4++;
            }
            if(H2_H2_C1_C2>=0 && H2_H2_C1_C2<31.3){
                Code_Col5++;
            }
            if(H2_H2_C1_C2>=0 && H2_H2_C1_C2<60.5){
                Code_Col6++;
            }
            if(H2_H2_C1_C2>=0 && H2_H2_C1_C2<40.8){
                Code_Col7++;
            }
            if(H2_H2_C1_C2>=0 && H2_H2_C1_C2<40.3){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_H2_C1_C2 == 0.0){
        	 Code_Col8++;
        }

        ////6  C2H4/C1+C2/%
        double  C2H4_C1_C2 = 0.0;

        if(_C1_C2>0) {
            C2H4_C1_C2 = div(_C2H4, _C1_C2, 2);

            if(C2H4_C1_C2>=21.3 && C2H4_C1_C2<66){
                Code_Col1++;
            }
            if(C2H4_C1_C2>=21.5 && C2H4_C1_C2<45.2){
                Code_Col2++;
            }
            if(C2H4_C1_C2>=0 && C2H4_C1_C2<20){
                Code_Col3++;
            }
            if(C2H4_C1_C2>=2.4 && C2H4_C1_C2<18.2){
                Code_Col4++;
            }
            if(C2H4_C1_C2>=8.8 && C2H4_C1_C2<57.6){
                Code_Col5++;
            }
            if(C2H4_C1_C2>=46.1 && C2H4_C1_C2<92.0){
                Code_Col6++;
            }
            if(C2H4_C1_C2>=31.6 && C2H4_C1_C2<53.4){
                Code_Col7++;
            }
            if(C2H4_C1_C2>=15.9 && C2H4_C1_C2<30.3){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_C1_C2 == 0.0){
        	 Code_Col8++;
        }


        ////7  CH4/C1+C2/%
        double  CH4_C1_C2 = 0.0;

        if(_C1_C2>0) {
            CH4_C1_C2 = div(_CH4, _C1_C2, 2);

            if(CH4_C1_C2>=6.0 && CH4_C1_C2<74){
                Code_Col1++;
            }
            if(CH4_C1_C2>=17.9 && CH4_C1_C2<43.7){
                Code_Col2++;
            }
            if(CH4_C1_C2>=0 && CH4_C1_C2<39.5){
                Code_Col3++;
            }
            if(CH4_C1_C2>=20 && CH4_C1_C2<23){
                Code_Col4++;
            }
            if(CH4_C1_C2>=12.6 && CH4_C1_C2<81.4){
                Code_Col5++;
            }
            if(CH4_C1_C2>=4.7 && CH4_C1_C2<70.3){
                Code_Col6++;
            }
            if(CH4_C1_C2>=17.2 && CH4_C1_C2<53.8){
                Code_Col7++;
            }
            if(CH4_C1_C2>=17.2 && CH4_C1_C2<85.6){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_C1_C2 == 0.0){
        	 Code_Col8++;
        }
        
        
        ////8  C2H6/C1+C2/%
        double  C2H6_C1_C2 = 0.0;

        if(_C1_C2>0) {
            C2H6_C1_C2 = div(_C2H6, _C1_C2, 2);

            if(C2H6_C1_C2>=0 && C2H6_C1_C2<15.2){
                Code_Col1++;
            }
            if(C2H6_C1_C2>=1.8 && C2H6_C1_C2<72){
                Code_Col2++;
            }
            if(C2H6_C1_C2>=0 && C2H6_C1_C2<13.0){
                Code_Col3++;
            }
            if(C2H6_C1_C2>=1.9 && C2H6_C1_C2<32.0){
                Code_Col4++;
            }
            if(C2H6_C1_C2>=0 && C2H6_C1_C2<44.0){
                Code_Col5++;
            }
            if(C2H6_C1_C2>=3.4 && C2H6_C1_C2<16.8){
                Code_Col6++;
            }
            if(C2H6_C1_C2>=12.6 && C2H6_C1_C2<38.0){
                Code_Col7++;
            }
            if(C2H6_C1_C2>=17 && C2H6_C1_C2<42.0){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_C1_C2 == 0.0){
        	 Code_Col8++;
        }


        ////9  C2H6/C1+C2/%
        double  CH4C2H4_C1_C2 = 0.0;
        double _CH4C2H4 = _CH4+_C2H4;

        if(_C1_C2>0) {
            CH4C2H4_C1_C2 = div(_CH4C2H4, _C1_C2, 2);

            if(CH4C2H4_C1_C2>=37.6 && CH4C2H4_C1_C2<86.7){
                Code_Col1++;
            }
            if(CH4C2H4_C1_C2>=41.7 && CH4C2H4_C1_C2<72.0){
                Code_Col2++;
            }
            if(CH4C2H4_C1_C2>=22.6 && CH4C2H4_C1_C2<82.8){
                Code_Col3++;
            }
            if(CH4C2H4_C1_C2>=22.7 && CH4C2H4_C1_C2<41.7){
                Code_Col4++;
            }
            if(CH4C2H4_C1_C2>=34.0 && CH4C2H4_C1_C2<91.0){
                Code_Col5++;
            }
            if(CH4C2H4_C1_C2>=79.7 && CH4C2H4_C1_C2<98.2){
                Code_Col6++;
            }
            if(CH4C2H4_C1_C2>=35.0 && CH4C2H4_C1_C2<87.0){
                Code_Col7++;
            }
            if(CH4C2H4_C1_C2>=34.5 && CH4C2H4_C1_C2<74.0){
                Code_Col8++;
            }
        }
        //分母为0时，取最大值
        if(_C1_C2 == 0.0){
        	 Code_Col8++;
        }


        Map<String,Integer> mapCode = new  HashMap<String,Integer>();
        mapCode.put("Code_Col1",Code_Col1);
        mapCode.put("Code_Col2",Code_Col2);
        mapCode.put("Code_Col3",Code_Col3);
        mapCode.put("Code_Col4",Code_Col4);
        mapCode.put("Code_Col5",Code_Col5);
        mapCode.put("Code_Col6",Code_Col6);
        mapCode.put("Code_Col7",Code_Col7);
        mapCode.put("Code_Col8",Code_Col8);

        String _codeName ="";
        Integer _code_Count=0;
        ////查找出现频率最高的一组
        for (String key : mapCode.keySet()) {

            Integer _tempCount=  mapCode.get(key);
            if(_tempCount>_code_Count){
                _code_Count = _tempCount;
                _codeName = key;
            }
            ////System.out.println("key= "+ key + " and value= " + mapCode.get(key));
        }

        ////返回结果
        Map<String,String> _codeMsg =  getjiuBiZhiCode_Msg(_codeName);
        if(_codeMsg.size()>0){
            return _codeMsg ;
        }else {
            _codeMsg.put("code","");
            _codeMsg.put("codemsg","无法判断的故障");
            _codeMsg.put("discription","");
            return  _codeMsg;
        }
    }


    ////获取 九比值 提示的信息
    public static Map<String,String> getjiuBiZhiCode_Msg(String _codeName){

//        String result ="";
        String Code_Col1_Msg="高能量放电";
        String Code_Col2_Msg="高能量放电";
        String Code_Col3_Msg="低能量放电";
        String Code_Col4_Msg="低能量放电兼过热";
        String Code_Col5_Msg="高能量放电兼过热";
        String Code_Col6_Msg="高温过热";
        String Code_Col7_Msg="中温过热";
        String Code_Col8_Msg="低温过热";

        Map<String,String> mapResult = new HashMap<>();


        if(_codeName.equals("Code_Col1")){
            mapResult.put("code","102");
            mapResult.put("codemsg",Code_Col1_Msg);
            mapResult.put("discription","引线对为固定的直接连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电，悬浮电位之间火花放电");
            return mapResult;
        }
        else if(_codeName.equals("Code_Col2")){
            mapResult.put("code","112,110,101,100");
            mapResult.put("codemsg",Code_Col2_Msg);
            mapResult.put("discription","引线对为固定的直接连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电，悬浮电位之间火花放电");
            return mapResult;
            // result = Code_Col2_Msg;
        }
        else if(_codeName.equals("Code_Col3")){
            mapResult.put("code","202,212,200");
            mapResult.put("codemsg",Code_Col3_Msg);
            mapResult.put("discription","引线时电位未固定的部件之间连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电或悬浮之间火花放电。");
            return mapResult;
        }
        else if(_codeName.equals("Code_Col4")){
            mapResult.put("code","220,222");
            mapResult.put("codemsg",Code_Col4_Msg);
            mapResult.put("discription","引线时电位未固定的部件之间连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电或悬浮之间火花放电。");
            return mapResult;
        }
        else if(_codeName.equals("Code_Col5")){
            mapResult.put("code","120,121,122");
            mapResult.put("codemsg",Code_Col5_Msg);
            mapResult.put("discription","引线对为固定的直接连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电，悬浮电位之间火花放电。");
            return mapResult;
        }
        else if(_codeName.equals("Code_Col6")){
            mapResult.put("code","022,002");
            mapResult.put("codemsg",Code_Col6_Msg);
            mapResult.put("discription","热点温度增加，从铁芯中的小热点，铁芯短路，由于涡流引起的铜过热，接头或接触不良、焊接不良（形成丝炭）及铁芯、和外壳的环流、铁芯多点接地。");
            return mapResult;
        }
        else if(_codeName.equals("Code_Col7")){
            mapResult.put("code","021");
            mapResult.put("codemsg",Code_Col7_Msg);
            mapResult.put("discription","铁芯局部过热。");
            return mapResult;
        }
        else if(_codeName.equals("Code_Col8")){
            mapResult.put("code","020,001");
            mapResult.put("codemsg",Code_Col8_Msg);
            mapResult.put("discription","一般性的绝缘导线过热。引线夹件螺丝松动。");
            return mapResult;
        }
        else {
            return null ;
        }

    }



    public static double div(double d1, double d2,int len) {// 进行除法运算
        BigDecimal b1 = new BigDecimal(d1);
        BigDecimal b2 = new BigDecimal(d2);
        return b1.divide(b2,len,BigDecimal.ROUND_HALF_UP).doubleValue();
    }


    //////三比值确定故障后，进一步推断出故障的估算温度
    public  static String getTemperater_A(Double _C2H4,Double _C2H6){
        // A  C2H4/C2H6
        Double T = 322 * Math.log10(_C2H4/_C2H6) + 525;
        DecimalFormat dformt   = new DecimalFormat("######0.00");
        return  dformt.format(T);
    }

    //////三比值确定故障后，进一步推断出故障的估算温度
    public  static String getTemperater_Down300(Double _C2H4,Double _C2H6,Double _CO2 ,Double _CO){

        //// 如果co2/co 低于0或高于10，则认为可能存在纤维分解故障，即固体绝缘的劣化. 进行以下计算
        // B-- 300℃ 以下 CO2/CO
        Double T_Down300 = -241 * Math.log10(_CO2/_CO) + 373;
        DecimalFormat dformt   = new DecimalFormat("######0.00");
        return  dformt.format(T_Down300);
    }

    //////三比值确定故障后，进一步推断出故障的估算温度
    public  static String getTemperater_Up300(Double _C2H4,Double _C2H6,Double _CO2 ,Double _CO){

        //// 如果co2/co 低于0或高于10，则认为可能存在纤维分解故障，即固体绝缘的劣化. 进行以下计算
        // B-- 300℃ 以上 CO2/CO
        Double T_Up300 = -1196 * Math.log10(_CO2/_CO) + 660;
        DecimalFormat dformt   = new DecimalFormat("######0.00");
        return  dformt.format(T_Up300);
    }



}
