package com.shining.cloud.serviceImpl.RealTimeInfo;

import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;
import java.util.DoubleSummaryStatistics;
import java.util.List;

import javax.annotation.Resource;

import cn.hutool.core.util.StrUtil;
import com.google.gson.JsonObject;
import com.njcn.mapper.configuration.LineMapper;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.configuration.Line;
import com.njcn.utils.AppConfig;
import com.njcn.utils.SocketClient;
import com.njcn.utils.redis.JedisManager;
import com.shining.cloud.pojo.RealTimeInfo.*;
import com.shining.cloud.service.RealTimeInfo.VersionService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.njcn.utils.UserUtil;
import com.shining.cloud.mapper.RealTimeInfo.RealTimeInfoMapper;
import com.shining.cloud.service.RealTimeInfo.RealTimeInfoService;

/**
 * @description: 监测点信息列表Impl
 * @author: denghuajun
 * @time: 2019-12-16 10:28:40
 **/
@Service
public class RealTimeInfoServiceImpl implements RealTimeInfoService {
    @Resource
    RealTimeInfoMapper realTimeInfoMapper;
    @Resource
    UserUtil userUtil;
    @Autowired
    private VersionService versionService;
    @Autowired
    private LineMapper lineMapper;
    @Autowired
    private AppConfig appConfig;
    @Autowired
    private SocketClient socketClient;
    @Autowired
    private JedisManager jedisManager;


    @Override
    public LineBaseInfo getLineBaseInfo(int lineIndex) {
        return realTimeInfoMapper.getLineBaseInfo(lineIndex);
    }

    @Override
    public RealTimeInfo getRealTimeInfo(int lineIndex) {
        RealTimeInfo realTimeInfo = new RealTimeInfo();
        try {

            Integer status = realTimeInfoMapper.isDown(lineIndex);
            if(status == null || status ==0){
                return realTimeInfo;
            }

            //建立socket并发送请求
            String host = lineMapper.getNodeIpbylineIndex(Long.valueOf(lineIndex));
            Integer port = Integer.valueOf(appConfig.getSocketPort());
            RealTimeRVO realTimeRVO = new RealTimeRVO();
            String devType = realTimeInfoMapper.devType(lineIndex);
            if (devType.indexOf("V_300") != -1) {
                realTimeRVO.setType(211);
            } else {
                realTimeRVO.setType(210);
            }
            realTimeRVO.setLineid(lineIndex);
            cn.hutool.json.JSONObject jsonLen = new cn.hutool.json.JSONObject(realTimeRVO);
            Integer len = jsonLen.toString().length();
            RealTimeVO realTimeVO = new RealTimeVO();
            realTimeVO.setLen(len.toString());
            realTimeVO.setData(realTimeRVO);
            cn.hutool.json.JSONObject json = new cn.hutool.json.JSONObject(realTimeVO);
            String str = json.toString();
            System.out.println("客户端请求消息:"+str);
            String realJsonStr = socketClient.sentLineRealTime(str, host, port);
            System.out.println("客户端接收消息:"+realJsonStr);
            if(StrUtil.isBlank(realJsonStr)){
                String time = realTimeInfoMapper.getUpdateTime(lineIndex);
                realTimeInfo = realTimeInfoMapper.getRealTimeInfo(lineIndex,time);
                if(realTimeInfo == null){
                    realTimeInfo = new RealTimeInfo();
                }else {
                    //进行存redis操作
                }
            }else {
                JSONObject jsonObject = JSONObject.fromObject(realJsonStr);
                //获取resultCode 当resultCode =10000时获取实时数据，否则默认
                String resultCode = jsonObject.getString("resultcode");
                Line line = new Line();
                line.setLineIndex(Long.valueOf(lineIndex));
                line = lineMapper.selectByPrimaryKey(line);
                float iMax = line.getCt1();
                double vMax = (float) line.getPt1() * 1.2 / 1000;
                realTimeInfo.setiMax(String.valueOf(iMax));
                realTimeInfo.setvMax(String.valueOf(vMax));
                if (resultCode.equals("10000")) {
                    String jsonStr = jsonObject.get("resultmsg").toString();
                    JSONObject jsonObjectData = JSONObject.fromObject(jsonStr);
                    //获取实时数据
                    String jsonData = jsonObjectData.getString(String.valueOf(lineIndex));
                    //时间
                    JSONObject jsonObjects = JSONObject.fromObject(jsonData);
                    Long timeid = jsonObjects.getLong("TIME");
                    List<String> getV = jsonObjects.getJSONArray("V");
                    realTimeInfo.setLineIndex(lineIndex);
                    realTimeInfo.setTimeId(new Date(timeid));
                    List<String> getI = jsonObjects.getJSONArray("I");
                    if (getV.size() > 0) {
                        for (int i = 0; i < getV.size(); i++) {
                            JSONObject jsonObjectV = JSONObject.fromObject(getV.get(i));
                            if (jsonObjectV.getString("SEQ").equals("A")) {  //A相
                                realTimeInfo.setRmsVA(String.valueOf(Math.round(jsonObjectV.getDouble("VRMS") * 1000) / 1000f));
                                realTimeInfo.setBaseWaveVA(String.valueOf(Math.round(jsonObjectV.getDouble("V1") * 1000) / 1000f));
                                realTimeInfo.setBaseWavePhaseVA(String.valueOf(Math.round(jsonObjectV.getDouble("V_ANGLE") * 1000) / 1000f));
                                realTimeInfo.setVUDevA(String.valueOf(Math.round(jsonObjectV.getDouble("DELTA_V") * 1000) / 1000f));
                                realTimeInfo.setThdVA(String.valueOf(Math.round(jsonObjectV.getDouble("VTHD") * 100 * 1000) / 1000f));
                            } else if (jsonObjectV.getString("SEQ").equals("B")) { //B相
                                realTimeInfo.setRmsVB(String.valueOf(Math.round(jsonObjectV.getDouble("VRMS") * 1000) / 1000f));
                                realTimeInfo.setBaseWaveVB(String.valueOf(Math.round(jsonObjectV.getDouble("V1") * 1000) / 1000f));
                                realTimeInfo.setBaseWavePhaseVB(String.valueOf(Math.round(jsonObjectV.getDouble("V_ANGLE") * 1000) / 1000f));
                                realTimeInfo.setVUDevB(String.valueOf(Math.round(jsonObjectV.getDouble("DELTA_V") * 1000) / 1000f));
                                realTimeInfo.setThdVB(String.valueOf(Math.round(jsonObjectV.getDouble("VTHD") * 100 * 1000) / 1000f));
                            } else if (jsonObjectV.getString("SEQ").equals("C")) { //C相
                                realTimeInfo.setRmsVC(String.valueOf(Math.round(jsonObjectV.getDouble("VRMS") * 1000) / 1000f));
                                realTimeInfo.setBaseWaveVC(String.valueOf(Math.round(jsonObjectV.getDouble("V1") * 1000) / 1000f));
                                realTimeInfo.setBaseWavePhaseVC(String.valueOf(Math.round(jsonObjectV.getDouble("V_ANGLE") * 1000) / 1000f));
                                realTimeInfo.setVUDevC(String.valueOf(Math.round(jsonObjectV.getDouble("DELTA_V") * 1000) / 1000f));
                                realTimeInfo.setThdVC(String.valueOf(Math.round(jsonObjectV.getDouble("VTHD") * 100 * 1000) / 1000f));
                            }

                        }
                    }
                    if (getI.size() > 0) {
                        for (int i = 0; i < getI.size(); i++) {
                            JSONObject jsonObjectI = JSONObject.fromObject(getI.get(i));
                            if (jsonObjectI.getString("SEQ").equals("A")) {  //A相
                                realTimeInfo.setRmsIA(String.valueOf(Math.round(jsonObjectI.getDouble("IRMS") * 1000) / 1000f));
                                realTimeInfo.setBaseWaveIA(String.valueOf(Math.round(jsonObjectI.getDouble("I1") * 1000) / 1000f));
                                realTimeInfo.setBaseWavePhaseIA(String.valueOf(Math.round(jsonObjectI.getDouble("I_ANGLE") * 1000) / 1000f));
                            } else if (jsonObjectI.getString("SEQ").equals("B")) { //B相
                                realTimeInfo.setRmsIB(String.valueOf(Math.round(jsonObjectI.getDouble("IRMS") * 1000) / 1000f));
                                realTimeInfo.setBaseWaveIB(String.valueOf(Math.round(jsonObjectI.getDouble("I1") * 1000) / 1000f));
                                realTimeInfo.setBaseWavePhaseIB(String.valueOf(Math.round(jsonObjectI.getDouble("I_ANGLE") * 1000) / 1000f));
                            } else if (jsonObjectI.getString("SEQ").equals("C")) { //C相
                                realTimeInfo.setRmsIC(String.valueOf(Math.round(jsonObjectI.getDouble("IRMS") * 1000) / 1000f));
                                realTimeInfo.setBaseWaveIC(String.valueOf(Math.round(jsonObjectI.getDouble("I1") * 1000) / 1000f));
                                realTimeInfo.setBaseWavePhaseIC(String.valueOf(Math.round(jsonObjectI.getDouble("I_ANGLE") * 1000) / 1000f));
                            }
                        }
                    }

                    //进行存redis操作
                    String key = "realTimeData_"+lineIndex;
                    jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY,key);
                    jedisManager.saveValueByKey(RedisDB.SHORT_TIME_QUERY,key,jsonData,RedisDB.SHORT_TIME);

                } else {
                    String time = realTimeInfoMapper.getUpdateTime(lineIndex);
                    realTimeInfo = realTimeInfoMapper.getRealTimeInfo(lineIndex,time);
                    if(realTimeInfo == null){
                        realTimeInfo = new RealTimeInfo();
                    }else {
                        //进行存redis操作

                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
            return realTimeInfo;
        }
        return realTimeInfo;
    }

    @Override
    public LineInfo getLineId(String userIndex) {
        LineInfo lineInfo = new LineInfo();
        try {
            List<Integer> lines = userUtil.ApplistLine(userIndex);
            if (lines == null || lines.size() == 0) {
                return null;
            }
            lineInfo = realTimeInfoMapper.getLineId(lines);
        } catch (Exception e) {
            return null;
        }
        return lineInfo;
    }


    private String getAvg(List<String> avg) {
        float getAvg = 0;
        float getSum = 0;
        try {
            if (avg.size() > 0) {
                for (int i = 0; i < avg.size(); i++) {
                    getSum += Float.parseFloat(avg.get(i));
                }
                getAvg = getSum / avg.size();
            } else {
                getAvg = 0;
            }
        } catch (Exception e) {
            getAvg = 0;
        }
        return String.valueOf(Math.round(getAvg * 1000) / 1000f);
    }


    @Override
    public HarmRateIAndV getHarmRateIAndV(int lineIndex) {
        HarmRateIAndV harmRateIAndV = new HarmRateIAndV();
        HarmRateV harmRateV = new HarmRateV();
        HarmRateI harmRateI = new HarmRateI();
        try {
            String result = "";
            result = versionService.getInfoBySocket(lineIndex);
            JSONObject jsonObject = JSONObject.fromObject(result);
            //获取实时数据
            String resultCode = jsonObject.getString("resultcode");

            if (resultCode.equals("10000")) {
                String jsonStr = jsonObject.get("resultmsg").toString();
                JSONObject jsonObjectData = JSONObject.fromObject(jsonStr);
                //获取实时数据
                String jsonData = jsonObjectData.getString(String.valueOf(lineIndex));
                //时间
                JSONObject jsonObjects = JSONObject.fromObject(jsonData);
                List<String> getV = jsonObjects.getJSONArray("V");
                List<String> getI = jsonObjects.getJSONArray("I");

                if (getV.size() > 0) {
                    List<String> getV2 = new ArrayList<>();
                    List<String> getV3 = new ArrayList<>();
                    List<String> getV4 = new ArrayList<>();
                    List<String> getV5 = new ArrayList<>();
                    List<String> getV6 = new ArrayList<>();
                    List<String> getV7 = new ArrayList<>();
                    List<String> getV8 = new ArrayList<>();
                    List<String> getV9 = new ArrayList<>();
                    List<String> getV10 = new ArrayList<>();
                    List<String> getV11 = new ArrayList<>();
                    List<String> getV12 = new ArrayList<>();
                    List<String> getV13 = new ArrayList<>();
                    List<String> getV14 = new ArrayList<>();
                    List<String> getV15 = new ArrayList<>();
                    List<String> getV16 = new ArrayList<>();
                    List<String> getV17 = new ArrayList<>();
                    List<String> getV18 = new ArrayList<>();
                    List<String> getV19 = new ArrayList<>();
                    List<String> getV20 = new ArrayList<>();
                    List<String> getV21 = new ArrayList<>();
                    List<String> getV22 = new ArrayList<>();
                    List<String> getV23 = new ArrayList<>();
                    List<String> getV24 = new ArrayList<>();
                    List<String> getV25 = new ArrayList<>();
                    for (int i = 0; i < getV.size(); i++) {
                        JSONObject jsonObjectV = JSONObject.fromObject(getV.get(i));
                        if (jsonObjectV.getString("SEQ").equals("A")) {  //A相
                            getV2.add(String.valueOf(Math.round(jsonObjectV.getDouble("V2") * 1000) / 1000f));
                            getV3.add(String.valueOf(Math.round(jsonObjectV.getDouble("V3") * 1000) / 1000f));
                            getV4.add(String.valueOf(Math.round(jsonObjectV.getDouble("V4") * 1000) / 1000f));
                            getV5.add(String.valueOf(Math.round(jsonObjectV.getDouble("V5") * 1000) / 1000f));
                            getV6.add(String.valueOf(Math.round(jsonObjectV.getDouble("V6") * 1000) / 1000f));
                            getV7.add(String.valueOf(Math.round(jsonObjectV.getDouble("V7") * 1000) / 1000f));
                            getV8.add(String.valueOf(Math.round(jsonObjectV.getDouble("V8") * 1000) / 1000f));
                            getV9.add(String.valueOf(Math.round(jsonObjectV.getDouble("V9") * 1000) / 1000f));
                            getV10.add(String.valueOf(Math.round(jsonObjectV.getDouble("V10") * 1000) / 1000f));
                            getV11.add(String.valueOf(Math.round(jsonObjectV.getDouble("V11") * 1000) / 1000f));
                            getV12.add(String.valueOf(Math.round(jsonObjectV.getDouble("V12") * 1000) / 1000f));
                            getV13.add(String.valueOf(Math.round(jsonObjectV.getDouble("V13") * 1000) / 1000f));
                            getV14.add(String.valueOf(Math.round(jsonObjectV.getDouble("V14") * 1000) / 1000f));
                            getV15.add(String.valueOf(Math.round(jsonObjectV.getDouble("V15") * 1000) / 1000f));
                            getV16.add(String.valueOf(Math.round(jsonObjectV.getDouble("V16") * 1000) / 1000f));
                            getV17.add(String.valueOf(Math.round(jsonObjectV.getDouble("V17") * 1000) / 1000f));
                            getV18.add(String.valueOf(Math.round(jsonObjectV.getDouble("V18") * 1000) / 1000f));
                            getV19.add(String.valueOf(Math.round(jsonObjectV.getDouble("V19") * 1000) / 1000f));
                            getV20.add(String.valueOf(Math.round(jsonObjectV.getDouble("V20") * 1000) / 1000f));
                            getV21.add(String.valueOf(Math.round(jsonObjectV.getDouble("V21") * 1000) / 1000f));
                            getV22.add(String.valueOf(Math.round(jsonObjectV.getDouble("V22") * 1000) / 1000f));
                            getV23.add(String.valueOf(Math.round(jsonObjectV.getDouble("V23") * 1000) / 1000f));
                            getV24.add(String.valueOf(Math.round(jsonObjectV.getDouble("V24") * 1000) / 1000f));
                            getV25.add(String.valueOf(Math.round(jsonObjectV.getDouble("V25") * 1000) / 1000f));
                        } else if (jsonObjectV.getString("SEQ").equals("B")) { //B相
                            getV2.add(String.valueOf(Math.round(jsonObjectV.getDouble("V2") * 1000) / 1000f));
                            getV3.add(String.valueOf(Math.round(jsonObjectV.getDouble("V3") * 1000) / 1000f));
                            getV4.add(String.valueOf(Math.round(jsonObjectV.getDouble("V4") * 1000) / 1000f));
                            getV5.add(String.valueOf(Math.round(jsonObjectV.getDouble("V5") * 1000) / 1000f));
                            getV6.add(String.valueOf(Math.round(jsonObjectV.getDouble("V6") * 1000) / 1000f));
                            getV7.add(String.valueOf(Math.round(jsonObjectV.getDouble("V7") * 1000) / 1000f));
                            getV8.add(String.valueOf(Math.round(jsonObjectV.getDouble("V8") * 1000) / 1000f));
                            getV9.add(String.valueOf(Math.round(jsonObjectV.getDouble("V9") * 1000) / 1000f));
                            getV10.add(String.valueOf(Math.round(jsonObjectV.getDouble("V10") * 1000) / 1000f));
                            getV11.add(String.valueOf(Math.round(jsonObjectV.getDouble("V11") * 1000) / 1000f));
                            getV12.add(String.valueOf(Math.round(jsonObjectV.getDouble("V12") * 1000) / 1000f));
                            getV13.add(String.valueOf(Math.round(jsonObjectV.getDouble("V13") * 1000) / 1000f));
                            getV14.add(String.valueOf(Math.round(jsonObjectV.getDouble("V14") * 1000) / 1000f));
                            getV15.add(String.valueOf(Math.round(jsonObjectV.getDouble("V15") * 1000) / 1000f));
                            getV16.add(String.valueOf(Math.round(jsonObjectV.getDouble("V16") * 1000) / 1000f));
                            getV17.add(String.valueOf(Math.round(jsonObjectV.getDouble("V17") * 1000) / 1000f));
                            getV18.add(String.valueOf(Math.round(jsonObjectV.getDouble("V18") * 1000) / 1000f));
                            getV19.add(String.valueOf(Math.round(jsonObjectV.getDouble("V19") * 1000) / 1000f));
                            getV20.add(String.valueOf(Math.round(jsonObjectV.getDouble("V20") * 1000) / 1000f));
                            getV21.add(String.valueOf(Math.round(jsonObjectV.getDouble("V21") * 1000) / 1000f));
                            getV22.add(String.valueOf(Math.round(jsonObjectV.getDouble("V22") * 1000) / 1000f));
                            getV23.add(String.valueOf(Math.round(jsonObjectV.getDouble("V23") * 1000) / 1000f));
                            getV24.add(String.valueOf(Math.round(jsonObjectV.getDouble("V24") * 1000) / 1000f));
                            getV25.add(String.valueOf(Math.round(jsonObjectV.getDouble("V25") * 1000) / 1000f));
                        } else if (jsonObjectV.getString("SEQ").equals("C")) { //C相
                            getV2.add(String.valueOf(Math.round(jsonObjectV.getDouble("V2") * 1000) / 1000f));
                            getV3.add(String.valueOf(Math.round(jsonObjectV.getDouble("V3") * 1000) / 1000f));
                            getV4.add(String.valueOf(Math.round(jsonObjectV.getDouble("V4") * 1000) / 1000f));
                            getV5.add(String.valueOf(Math.round(jsonObjectV.getDouble("V5") * 1000) / 1000f));
                            getV6.add(String.valueOf(Math.round(jsonObjectV.getDouble("V6") * 1000) / 1000f));
                            getV7.add(String.valueOf(Math.round(jsonObjectV.getDouble("V7") * 1000) / 1000f));
                            getV8.add(String.valueOf(Math.round(jsonObjectV.getDouble("V8") * 1000) / 1000f));
                            getV9.add(String.valueOf(Math.round(jsonObjectV.getDouble("V9") * 1000) / 1000f));
                            getV10.add(String.valueOf(Math.round(jsonObjectV.getDouble("V10") * 1000) / 1000f));
                            getV11.add(String.valueOf(Math.round(jsonObjectV.getDouble("V11") * 1000) / 1000f));
                            getV12.add(String.valueOf(Math.round(jsonObjectV.getDouble("V12") * 1000) / 1000f));
                            getV13.add(String.valueOf(Math.round(jsonObjectV.getDouble("V13") * 1000) / 1000f));
                            getV14.add(String.valueOf(Math.round(jsonObjectV.getDouble("V14") * 1000) / 1000f));
                            getV15.add(String.valueOf(Math.round(jsonObjectV.getDouble("V15") * 1000) / 1000f));
                            getV16.add(String.valueOf(Math.round(jsonObjectV.getDouble("V16") * 1000) / 1000f));
                            getV17.add(String.valueOf(Math.round(jsonObjectV.getDouble("V17") * 1000) / 1000f));
                            getV18.add(String.valueOf(Math.round(jsonObjectV.getDouble("V18") * 1000) / 1000f));
                            getV19.add(String.valueOf(Math.round(jsonObjectV.getDouble("V19") * 1000) / 1000f));
                            getV20.add(String.valueOf(Math.round(jsonObjectV.getDouble("V20") * 1000) / 1000f));
                            getV21.add(String.valueOf(Math.round(jsonObjectV.getDouble("V21") * 1000) / 1000f));
                            getV22.add(String.valueOf(Math.round(jsonObjectV.getDouble("V22") * 1000) / 1000f));
                            getV23.add(String.valueOf(Math.round(jsonObjectV.getDouble("V23") * 1000) / 1000f));
                            getV24.add(String.valueOf(Math.round(jsonObjectV.getDouble("V24") * 1000) / 1000f));
                            getV25.add(String.valueOf(Math.round(jsonObjectV.getDouble("V25") * 1000) / 1000f));
                        }
                    }
                    harmRateV.setV2(getAvg(getV2));
                    harmRateV.setV3(getAvg(getV3));
                    harmRateV.setV4(getAvg(getV4));
                    harmRateV.setV5(getAvg(getV5));
                    harmRateV.setV6(getAvg(getV6));
                    harmRateV.setV7(getAvg(getV7));
                    harmRateV.setV8(getAvg(getV8));
                    harmRateV.setV9(getAvg(getV9));
                    harmRateV.setV10(getAvg(getV10));
                    harmRateV.setV11(getAvg(getV11));
                    harmRateV.setV12(getAvg(getV12));
                    harmRateV.setV13(getAvg(getV13));
                    harmRateV.setV14(getAvg(getV14));
                    harmRateV.setV15(getAvg(getV15));
                    harmRateV.setV16(getAvg(getV16));
                    harmRateV.setV17(getAvg(getV17));
                    harmRateV.setV18(getAvg(getV18));
                    harmRateV.setV19(getAvg(getV19));
                    harmRateV.setV20(getAvg(getV20));
                    harmRateV.setV21(getAvg(getV21));
                    harmRateV.setV22(getAvg(getV22));
                    harmRateV.setV23(getAvg(getV23));
                    harmRateV.setV24(getAvg(getV24));
                    harmRateV.setV25(getAvg(getV25));
                }
                if (getI.size() > 0) {
                    List<String> getI2 = new ArrayList<>();
                    List<String> getI3 = new ArrayList<>();
                    List<String> getI4 = new ArrayList<>();
                    List<String> getI5 = new ArrayList<>();
                    List<String> getI6 = new ArrayList<>();
                    List<String> getI7 = new ArrayList<>();
                    List<String> getI8 = new ArrayList<>();
                    List<String> getI9 = new ArrayList<>();
                    List<String> getI10 = new ArrayList<>();
                    List<String> getI11 = new ArrayList<>();
                    List<String> getI12 = new ArrayList<>();
                    List<String> getI13 = new ArrayList<>();
                    List<String> getI14 = new ArrayList<>();
                    List<String> getI15 = new ArrayList<>();
                    List<String> getI16 = new ArrayList<>();
                    List<String> getI17 = new ArrayList<>();
                    List<String> getI18 = new ArrayList<>();
                    List<String> getI19 = new ArrayList<>();
                    List<String> getI20 = new ArrayList<>();
                    List<String> getI21 = new ArrayList<>();
                    List<String> getI22 = new ArrayList<>();
                    List<String> getI23 = new ArrayList<>();
                    List<String> getI24 = new ArrayList<>();
                    List<String> getI25 = new ArrayList<>();
                    for (int i = 0; i < getI.size(); i++) {
                        JSONObject jsonObjectI = JSONObject.fromObject(getI.get(i));
                        if (jsonObjectI.getString("SEQ").equals("A")) {  //A相
                            getI2.add(String.valueOf(Math.round(jsonObjectI.getDouble("I2") * 1000) / 1000f));
                            getI3.add(String.valueOf(Math.round(jsonObjectI.getDouble("I3") * 1000) / 1000f));
                            getI4.add(String.valueOf(Math.round(jsonObjectI.getDouble("I4") * 1000) / 1000f));
                            getI5.add(String.valueOf(Math.round(jsonObjectI.getDouble("I5") * 1000) / 1000f));
                            getI6.add(String.valueOf(Math.round(jsonObjectI.getDouble("I6") * 1000) / 1000f));
                            getI7.add(String.valueOf(Math.round(jsonObjectI.getDouble("I7") * 1000) / 1000f));
                            getI8.add(String.valueOf(Math.round(jsonObjectI.getDouble("I8") * 1000) / 1000f));
                            getI9.add(String.valueOf(Math.round(jsonObjectI.getDouble("I9") * 1000) / 1000f));
                            getI10.add(String.valueOf(Math.round(jsonObjectI.getDouble("I10") * 1000) / 1000f));
                            getI11.add(String.valueOf(Math.round(jsonObjectI.getDouble("I11") * 1000) / 1000f));
                            getI12.add(String.valueOf(Math.round(jsonObjectI.getDouble("I12") * 1000) / 1000f));
                            getI13.add(String.valueOf(Math.round(jsonObjectI.getDouble("I13") * 1000) / 1000f));
                            getI14.add(String.valueOf(Math.round(jsonObjectI.getDouble("I14") * 1000) / 1000f));
                            getI15.add(String.valueOf(Math.round(jsonObjectI.getDouble("I15") * 1000) / 1000f));
                            getI16.add(String.valueOf(Math.round(jsonObjectI.getDouble("I16") * 1000) / 1000f));
                            getI17.add(String.valueOf(Math.round(jsonObjectI.getDouble("I17") * 1000) / 1000f));
                            getI18.add(String.valueOf(Math.round(jsonObjectI.getDouble("I18") * 1000) / 1000f));
                            getI19.add(String.valueOf(Math.round(jsonObjectI.getDouble("I19") * 1000) / 1000f));
                            getI20.add(String.valueOf(Math.round(jsonObjectI.getDouble("I20") * 1000) / 1000f));
                            getI21.add(String.valueOf(Math.round(jsonObjectI.getDouble("I21") * 1000) / 1000f));
                            getI22.add(String.valueOf(Math.round(jsonObjectI.getDouble("I22") * 1000) / 1000f));
                            getI23.add(String.valueOf(Math.round(jsonObjectI.getDouble("I23") * 1000) / 1000f));
                            getI24.add(String.valueOf(Math.round(jsonObjectI.getDouble("I24") * 1000) / 1000f));
                            getI25.add(String.valueOf(Math.round(jsonObjectI.getDouble("I25") * 1000) / 1000f));
                        } else if (jsonObjectI.getString("SEQ").equals("B")) { //B相
                            getI2.add(String.valueOf(Math.round(jsonObjectI.getDouble("I2") * 1000) / 1000f));
                            getI3.add(String.valueOf(Math.round(jsonObjectI.getDouble("I3") * 1000) / 1000f));
                            getI4.add(String.valueOf(Math.round(jsonObjectI.getDouble("I4") * 1000) / 1000f));
                            getI5.add(String.valueOf(Math.round(jsonObjectI.getDouble("I5") * 1000) / 1000f));
                            getI6.add(String.valueOf(Math.round(jsonObjectI.getDouble("I6") * 1000) / 1000f));
                            getI7.add(String.valueOf(Math.round(jsonObjectI.getDouble("I7") * 1000) / 1000f));
                            getI8.add(String.valueOf(Math.round(jsonObjectI.getDouble("I8") * 1000) / 1000f));
                            getI9.add(String.valueOf(Math.round(jsonObjectI.getDouble("I9") * 1000) / 1000f));
                            getI10.add(String.valueOf(Math.round(jsonObjectI.getDouble("I10") * 1000) / 1000f));
                            getI11.add(String.valueOf(Math.round(jsonObjectI.getDouble("I11") * 1000) / 1000f));
                            getI12.add(String.valueOf(Math.round(jsonObjectI.getDouble("I12") * 1000) / 1000f));
                            getI13.add(String.valueOf(Math.round(jsonObjectI.getDouble("I13") * 1000) / 1000f));
                            getI14.add(String.valueOf(Math.round(jsonObjectI.getDouble("I14") * 1000) / 1000f));
                            getI15.add(String.valueOf(Math.round(jsonObjectI.getDouble("I15") * 1000) / 1000f));
                            getI16.add(String.valueOf(Math.round(jsonObjectI.getDouble("I16") * 1000) / 1000f));
                            getI17.add(String.valueOf(Math.round(jsonObjectI.getDouble("I17") * 1000) / 1000f));
                            getI18.add(String.valueOf(Math.round(jsonObjectI.getDouble("I18") * 1000) / 1000f));
                            getI19.add(String.valueOf(Math.round(jsonObjectI.getDouble("I19") * 1000) / 1000f));
                            getI20.add(String.valueOf(Math.round(jsonObjectI.getDouble("I20") * 1000) / 1000f));
                            getI21.add(String.valueOf(Math.round(jsonObjectI.getDouble("I21") * 1000) / 1000f));
                            getI22.add(String.valueOf(Math.round(jsonObjectI.getDouble("I22") * 1000) / 1000f));
                            getI23.add(String.valueOf(Math.round(jsonObjectI.getDouble("I23") * 1000) / 1000f));
                            getI24.add(String.valueOf(Math.round(jsonObjectI.getDouble("I24") * 1000) / 1000f));
                            getI25.add(String.valueOf(Math.round(jsonObjectI.getDouble("I25") * 1000) / 1000f));
                        } else if (jsonObjectI.getString("SEQ").equals("C")) { //C相
                            getI2.add(String.valueOf(Math.round(jsonObjectI.getDouble("I2") * 1000) / 1000f));
                            getI3.add(String.valueOf(Math.round(jsonObjectI.getDouble("I3") * 1000) / 1000f));
                            getI4.add(String.valueOf(Math.round(jsonObjectI.getDouble("I4") * 1000) / 1000f));
                            getI5.add(String.valueOf(Math.round(jsonObjectI.getDouble("I5") * 1000) / 1000f));
                            getI6.add(String.valueOf(Math.round(jsonObjectI.getDouble("I6") * 1000) / 1000f));
                            getI7.add(String.valueOf(Math.round(jsonObjectI.getDouble("I7") * 1000) / 1000f));
                            getI8.add(String.valueOf(Math.round(jsonObjectI.getDouble("I8") * 1000) / 1000f));
                            getI9.add(String.valueOf(Math.round(jsonObjectI.getDouble("I9") * 1000) / 1000f));
                            getI10.add(String.valueOf(Math.round(jsonObjectI.getDouble("I10") * 1000) / 1000f));
                            getI11.add(String.valueOf(Math.round(jsonObjectI.getDouble("I11") * 1000) / 1000f));
                            getI12.add(String.valueOf(Math.round(jsonObjectI.getDouble("I12") * 1000) / 1000f));
                            getI13.add(String.valueOf(Math.round(jsonObjectI.getDouble("I13") * 1000) / 1000f));
                            getI14.add(String.valueOf(Math.round(jsonObjectI.getDouble("I14") * 1000) / 1000f));
                            getI15.add(String.valueOf(Math.round(jsonObjectI.getDouble("I15") * 1000) / 1000f));
                            getI16.add(String.valueOf(Math.round(jsonObjectI.getDouble("I16") * 1000) / 1000f));
                            getI17.add(String.valueOf(Math.round(jsonObjectI.getDouble("I17") * 1000) / 1000f));
                            getI18.add(String.valueOf(Math.round(jsonObjectI.getDouble("I18") * 1000) / 1000f));
                            getI19.add(String.valueOf(Math.round(jsonObjectI.getDouble("I19") * 1000) / 1000f));
                            getI20.add(String.valueOf(Math.round(jsonObjectI.getDouble("I20") * 1000) / 1000f));
                            getI21.add(String.valueOf(Math.round(jsonObjectI.getDouble("I21") * 1000) / 1000f));
                            getI22.add(String.valueOf(Math.round(jsonObjectI.getDouble("I22") * 1000) / 1000f));
                            getI23.add(String.valueOf(Math.round(jsonObjectI.getDouble("I23") * 1000) / 1000f));
                            getI24.add(String.valueOf(Math.round(jsonObjectI.getDouble("I24") * 1000) / 1000f));
                            getI25.add(String.valueOf(Math.round(jsonObjectI.getDouble("I25") * 1000) / 1000f));
                        }
                    }
                    harmRateI.setI2(getAvg(getI2));
                    harmRateI.setI3(getAvg(getI3));
                    harmRateI.setI4(getAvg(getI4));
                    harmRateI.setI5(getAvg(getI5));
                    harmRateI.setI6(getAvg(getI6));
                    harmRateI.setI7(getAvg(getI7));
                    harmRateI.setI8(getAvg(getI8));
                    harmRateI.setI9(getAvg(getI9));
                    harmRateI.setI10(getAvg(getI10));
                    harmRateI.setI11(getAvg(getI11));
                    harmRateI.setI12(getAvg(getI12));
                    harmRateI.setI13(getAvg(getI13));
                    harmRateI.setI14(getAvg(getI14));
                    harmRateI.setI15(getAvg(getI15));
                    harmRateI.setI16(getAvg(getI16));
                    harmRateI.setI17(getAvg(getI17));
                    harmRateI.setI18(getAvg(getI18));
                    harmRateI.setI19(getAvg(getI19));
                    harmRateI.setI20(getAvg(getI20));
                    harmRateI.setI21(getAvg(getI21));
                    harmRateI.setI22(getAvg(getI22));
                    harmRateI.setI23(getAvg(getI23));
                    harmRateI.setI24(getAvg(getI24));
                    harmRateI.setI25(getAvg(getI25));
                }
                harmRateIAndV.setHarmRateI(harmRateI);
                harmRateIAndV.setIharm(realTimeInfoMapper.getIharm(lineIndex));
                harmRateIAndV.setHarmRateV(harmRateV);
                harmRateIAndV.setVharm(realTimeInfoMapper.getUharm(lineIndex));
            } else {
                harmRateIAndV.setHarmRateI(harmRateI);
                harmRateIAndV.setIharm(realTimeInfoMapper.getIharm(lineIndex));
                harmRateIAndV.setHarmRateV(harmRateV);
                harmRateIAndV.setVharm(realTimeInfoMapper.getUharm(lineIndex));
            }
        } catch (Exception e) {
            harmRateIAndV.setHarmRateV(harmRateV);
            harmRateIAndV.setVharm(realTimeInfoMapper.getUharm(lineIndex));
            harmRateIAndV.setHarmRateI(harmRateI);
            harmRateIAndV.setIharm(realTimeInfoMapper.getIharm(lineIndex));
        }

        return harmRateIAndV;
    }


    @Override
    public synchronized HarmRateIAndV getRInfo(int lineIndex) {
        HarmRateIAndV harmRateIAndV = null;
        harmRateIAndV = getHarmRateIAndV(lineIndex);
        return harmRateIAndV;

    }

    @Override
    public HarmRateIAndV RealRedisData(int lineIndex, int type) throws Exception {
        HarmRateIAndV harmRateIAndV = new HarmRateIAndV();
        harmRateIAndV.setIharm(realTimeInfoMapper.getIharm(lineIndex));
        harmRateIAndV.setVharm(realTimeInfoMapper.getUharm(lineIndex));
        HarmRateV harmRateV = new HarmRateV();
        HarmRateI harmRateI = new HarmRateI();
        String key = "realTimeData_"+lineIndex;
        String jsonstr = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY,key);
        if(StrUtil.isBlank(jsonstr)){
            String time = realTimeInfoMapper.getUpdateTime(lineIndex);
            if(type == 1){
                harmRateIAndV.setHarmRateV(realTimeInfoMapper.getHarmRateV(lineIndex,time));
            }else {
                harmRateIAndV.setHarmRateI(realTimeInfoMapper.getHarmRateI(lineIndex,time));
            }
            return harmRateIAndV;
        }
        JSONObject jsonObjects = JSONObject.fromObject(jsonstr);
        if(type == 1){
            List<String> getV = jsonObjects.getJSONArray("V");
            if (getV.size() > 0) {
                List<String> getV2 = new ArrayList<>();
                List<String> getV3 = new ArrayList<>();
                List<String> getV4 = new ArrayList<>();
                List<String> getV5 = new ArrayList<>();
                List<String> getV6 = new ArrayList<>();
                List<String> getV7 = new ArrayList<>();
                List<String> getV8 = new ArrayList<>();
                List<String> getV9 = new ArrayList<>();
                List<String> getV10 = new ArrayList<>();
                List<String> getV11 = new ArrayList<>();
                List<String> getV12 = new ArrayList<>();
                List<String> getV13 = new ArrayList<>();
                List<String> getV14 = new ArrayList<>();
                List<String> getV15 = new ArrayList<>();
                List<String> getV16 = new ArrayList<>();
                List<String> getV17 = new ArrayList<>();
                List<String> getV18 = new ArrayList<>();
                List<String> getV19 = new ArrayList<>();
                List<String> getV20 = new ArrayList<>();
                List<String> getV21 = new ArrayList<>();
                List<String> getV22 = new ArrayList<>();
                List<String> getV23 = new ArrayList<>();
                List<String> getV24 = new ArrayList<>();
                List<String> getV25 = new ArrayList<>();
                for (int i = 0; i < getV.size(); i++) {
                    JSONObject jsonObjectV = JSONObject.fromObject(getV.get(i));
                    if (jsonObjectV.getString("SEQ").equals("A")) {  //A相
                        getV2.add(String.valueOf(Math.round(jsonObjectV.getDouble("V2") * 1000) / 1000f));
                        getV3.add(String.valueOf(Math.round(jsonObjectV.getDouble("V3") * 1000) / 1000f));
                        getV4.add(String.valueOf(Math.round(jsonObjectV.getDouble("V4") * 1000) / 1000f));
                        getV5.add(String.valueOf(Math.round(jsonObjectV.getDouble("V5") * 1000) / 1000f));
                        getV6.add(String.valueOf(Math.round(jsonObjectV.getDouble("V6") * 1000) / 1000f));
                        getV7.add(String.valueOf(Math.round(jsonObjectV.getDouble("V7") * 1000) / 1000f));
                        getV8.add(String.valueOf(Math.round(jsonObjectV.getDouble("V8") * 1000) / 1000f));
                        getV9.add(String.valueOf(Math.round(jsonObjectV.getDouble("V9") * 1000) / 1000f));
                        getV10.add(String.valueOf(Math.round(jsonObjectV.getDouble("V10") * 1000) / 1000f));
                        getV11.add(String.valueOf(Math.round(jsonObjectV.getDouble("V11") * 1000) / 1000f));
                        getV12.add(String.valueOf(Math.round(jsonObjectV.getDouble("V12") * 1000) / 1000f));
                        getV13.add(String.valueOf(Math.round(jsonObjectV.getDouble("V13") * 1000) / 1000f));
                        getV14.add(String.valueOf(Math.round(jsonObjectV.getDouble("V14") * 1000) / 1000f));
                        getV15.add(String.valueOf(Math.round(jsonObjectV.getDouble("V15") * 1000) / 1000f));
                        getV16.add(String.valueOf(Math.round(jsonObjectV.getDouble("V16") * 1000) / 1000f));
                        getV17.add(String.valueOf(Math.round(jsonObjectV.getDouble("V17") * 1000) / 1000f));
                        getV18.add(String.valueOf(Math.round(jsonObjectV.getDouble("V18") * 1000) / 1000f));
                        getV19.add(String.valueOf(Math.round(jsonObjectV.getDouble("V19") * 1000) / 1000f));
                        getV20.add(String.valueOf(Math.round(jsonObjectV.getDouble("V20") * 1000) / 1000f));
                        getV21.add(String.valueOf(Math.round(jsonObjectV.getDouble("V21") * 1000) / 1000f));
                        getV22.add(String.valueOf(Math.round(jsonObjectV.getDouble("V22") * 1000) / 1000f));
                        getV23.add(String.valueOf(Math.round(jsonObjectV.getDouble("V23") * 1000) / 1000f));
                        getV24.add(String.valueOf(Math.round(jsonObjectV.getDouble("V24") * 1000) / 1000f));
                        getV25.add(String.valueOf(Math.round(jsonObjectV.getDouble("V25") * 1000) / 1000f));
                    } else if (jsonObjectV.getString("SEQ").equals("B")) { //B相
                        getV2.add(String.valueOf(Math.round(jsonObjectV.getDouble("V2") * 1000) / 1000f));
                        getV3.add(String.valueOf(Math.round(jsonObjectV.getDouble("V3") * 1000) / 1000f));
                        getV4.add(String.valueOf(Math.round(jsonObjectV.getDouble("V4") * 1000) / 1000f));
                        getV5.add(String.valueOf(Math.round(jsonObjectV.getDouble("V5") * 1000) / 1000f));
                        getV6.add(String.valueOf(Math.round(jsonObjectV.getDouble("V6") * 1000) / 1000f));
                        getV7.add(String.valueOf(Math.round(jsonObjectV.getDouble("V7") * 1000) / 1000f));
                        getV8.add(String.valueOf(Math.round(jsonObjectV.getDouble("V8") * 1000) / 1000f));
                        getV9.add(String.valueOf(Math.round(jsonObjectV.getDouble("V9") * 1000) / 1000f));
                        getV10.add(String.valueOf(Math.round(jsonObjectV.getDouble("V10") * 1000) / 1000f));
                        getV11.add(String.valueOf(Math.round(jsonObjectV.getDouble("V11") * 1000) / 1000f));
                        getV12.add(String.valueOf(Math.round(jsonObjectV.getDouble("V12") * 1000) / 1000f));
                        getV13.add(String.valueOf(Math.round(jsonObjectV.getDouble("V13") * 1000) / 1000f));
                        getV14.add(String.valueOf(Math.round(jsonObjectV.getDouble("V14") * 1000) / 1000f));
                        getV15.add(String.valueOf(Math.round(jsonObjectV.getDouble("V15") * 1000) / 1000f));
                        getV16.add(String.valueOf(Math.round(jsonObjectV.getDouble("V16") * 1000) / 1000f));
                        getV17.add(String.valueOf(Math.round(jsonObjectV.getDouble("V17") * 1000) / 1000f));
                        getV18.add(String.valueOf(Math.round(jsonObjectV.getDouble("V18") * 1000) / 1000f));
                        getV19.add(String.valueOf(Math.round(jsonObjectV.getDouble("V19") * 1000) / 1000f));
                        getV20.add(String.valueOf(Math.round(jsonObjectV.getDouble("V20") * 1000) / 1000f));
                        getV21.add(String.valueOf(Math.round(jsonObjectV.getDouble("V21") * 1000) / 1000f));
                        getV22.add(String.valueOf(Math.round(jsonObjectV.getDouble("V22") * 1000) / 1000f));
                        getV23.add(String.valueOf(Math.round(jsonObjectV.getDouble("V23") * 1000) / 1000f));
                        getV24.add(String.valueOf(Math.round(jsonObjectV.getDouble("V24") * 1000) / 1000f));
                        getV25.add(String.valueOf(Math.round(jsonObjectV.getDouble("V25") * 1000) / 1000f));
                    } else if (jsonObjectV.getString("SEQ").equals("C")) { //C相
                        getV2.add(String.valueOf(Math.round(jsonObjectV.getDouble("V2") * 1000) / 1000f));
                        getV3.add(String.valueOf(Math.round(jsonObjectV.getDouble("V3") * 1000) / 1000f));
                        getV4.add(String.valueOf(Math.round(jsonObjectV.getDouble("V4") * 1000) / 1000f));
                        getV5.add(String.valueOf(Math.round(jsonObjectV.getDouble("V5") * 1000) / 1000f));
                        getV6.add(String.valueOf(Math.round(jsonObjectV.getDouble("V6") * 1000) / 1000f));
                        getV7.add(String.valueOf(Math.round(jsonObjectV.getDouble("V7") * 1000) / 1000f));
                        getV8.add(String.valueOf(Math.round(jsonObjectV.getDouble("V8") * 1000) / 1000f));
                        getV9.add(String.valueOf(Math.round(jsonObjectV.getDouble("V9") * 1000) / 1000f));
                        getV10.add(String.valueOf(Math.round(jsonObjectV.getDouble("V10") * 1000) / 1000f));
                        getV11.add(String.valueOf(Math.round(jsonObjectV.getDouble("V11") * 1000) / 1000f));
                        getV12.add(String.valueOf(Math.round(jsonObjectV.getDouble("V12") * 1000) / 1000f));
                        getV13.add(String.valueOf(Math.round(jsonObjectV.getDouble("V13") * 1000) / 1000f));
                        getV14.add(String.valueOf(Math.round(jsonObjectV.getDouble("V14") * 1000) / 1000f));
                        getV15.add(String.valueOf(Math.round(jsonObjectV.getDouble("V15") * 1000) / 1000f));
                        getV16.add(String.valueOf(Math.round(jsonObjectV.getDouble("V16") * 1000) / 1000f));
                        getV17.add(String.valueOf(Math.round(jsonObjectV.getDouble("V17") * 1000) / 1000f));
                        getV18.add(String.valueOf(Math.round(jsonObjectV.getDouble("V18") * 1000) / 1000f));
                        getV19.add(String.valueOf(Math.round(jsonObjectV.getDouble("V19") * 1000) / 1000f));
                        getV20.add(String.valueOf(Math.round(jsonObjectV.getDouble("V20") * 1000) / 1000f));
                        getV21.add(String.valueOf(Math.round(jsonObjectV.getDouble("V21") * 1000) / 1000f));
                        getV22.add(String.valueOf(Math.round(jsonObjectV.getDouble("V22") * 1000) / 1000f));
                        getV23.add(String.valueOf(Math.round(jsonObjectV.getDouble("V23") * 1000) / 1000f));
                        getV24.add(String.valueOf(Math.round(jsonObjectV.getDouble("V24") * 1000) / 1000f));
                        getV25.add(String.valueOf(Math.round(jsonObjectV.getDouble("V25") * 1000) / 1000f));
                    }
                }
                harmRateV.setV2(getAvg(getV2));
                harmRateV.setV3(getAvg(getV3));
                harmRateV.setV4(getAvg(getV4));
                harmRateV.setV5(getAvg(getV5));
                harmRateV.setV6(getAvg(getV6));
                harmRateV.setV7(getAvg(getV7));
                harmRateV.setV8(getAvg(getV8));
                harmRateV.setV9(getAvg(getV9));
                harmRateV.setV10(getAvg(getV10));
                harmRateV.setV11(getAvg(getV11));
                harmRateV.setV12(getAvg(getV12));
                harmRateV.setV13(getAvg(getV13));
                harmRateV.setV14(getAvg(getV14));
                harmRateV.setV15(getAvg(getV15));
                harmRateV.setV16(getAvg(getV16));
                harmRateV.setV17(getAvg(getV17));
                harmRateV.setV18(getAvg(getV18));
                harmRateV.setV19(getAvg(getV19));
                harmRateV.setV20(getAvg(getV20));
                harmRateV.setV21(getAvg(getV21));
                harmRateV.setV22(getAvg(getV22));
                harmRateV.setV23(getAvg(getV23));
                harmRateV.setV24(getAvg(getV24));
                harmRateV.setV25(getAvg(getV25));
            }
            harmRateIAndV.setHarmRateV(harmRateV);
        }else {
            List<String> getI = jsonObjects.getJSONArray("I");
            if (getI.size() > 0) {
                List<String> getI2 = new ArrayList<>();
                List<String> getI3 = new ArrayList<>();
                List<String> getI4 = new ArrayList<>();
                List<String> getI5 = new ArrayList<>();
                List<String> getI6 = new ArrayList<>();
                List<String> getI7 = new ArrayList<>();
                List<String> getI8 = new ArrayList<>();
                List<String> getI9 = new ArrayList<>();
                List<String> getI10 = new ArrayList<>();
                List<String> getI11 = new ArrayList<>();
                List<String> getI12 = new ArrayList<>();
                List<String> getI13 = new ArrayList<>();
                List<String> getI14 = new ArrayList<>();
                List<String> getI15 = new ArrayList<>();
                List<String> getI16 = new ArrayList<>();
                List<String> getI17 = new ArrayList<>();
                List<String> getI18 = new ArrayList<>();
                List<String> getI19 = new ArrayList<>();
                List<String> getI20 = new ArrayList<>();
                List<String> getI21 = new ArrayList<>();
                List<String> getI22 = new ArrayList<>();
                List<String> getI23 = new ArrayList<>();
                List<String> getI24 = new ArrayList<>();
                List<String> getI25 = new ArrayList<>();
                for (int i = 0; i < getI.size(); i++) {
                    JSONObject jsonObjectI = JSONObject.fromObject(getI.get(i));
                    if (jsonObjectI.getString("SEQ").equals("A")) {  //A相
                        getI2.add(String.valueOf(Math.round(jsonObjectI.getDouble("I2") * 1000) / 1000f));
                        getI3.add(String.valueOf(Math.round(jsonObjectI.getDouble("I3") * 1000) / 1000f));
                        getI4.add(String.valueOf(Math.round(jsonObjectI.getDouble("I4") * 1000) / 1000f));
                        getI5.add(String.valueOf(Math.round(jsonObjectI.getDouble("I5") * 1000) / 1000f));
                        getI6.add(String.valueOf(Math.round(jsonObjectI.getDouble("I6") * 1000) / 1000f));
                        getI7.add(String.valueOf(Math.round(jsonObjectI.getDouble("I7") * 1000) / 1000f));
                        getI8.add(String.valueOf(Math.round(jsonObjectI.getDouble("I8") * 1000) / 1000f));
                        getI9.add(String.valueOf(Math.round(jsonObjectI.getDouble("I9") * 1000) / 1000f));
                        getI10.add(String.valueOf(Math.round(jsonObjectI.getDouble("I10") * 1000) / 1000f));
                        getI11.add(String.valueOf(Math.round(jsonObjectI.getDouble("I11") * 1000) / 1000f));
                        getI12.add(String.valueOf(Math.round(jsonObjectI.getDouble("I12") * 1000) / 1000f));
                        getI13.add(String.valueOf(Math.round(jsonObjectI.getDouble("I13") * 1000) / 1000f));
                        getI14.add(String.valueOf(Math.round(jsonObjectI.getDouble("I14") * 1000) / 1000f));
                        getI15.add(String.valueOf(Math.round(jsonObjectI.getDouble("I15") * 1000) / 1000f));
                        getI16.add(String.valueOf(Math.round(jsonObjectI.getDouble("I16") * 1000) / 1000f));
                        getI17.add(String.valueOf(Math.round(jsonObjectI.getDouble("I17") * 1000) / 1000f));
                        getI18.add(String.valueOf(Math.round(jsonObjectI.getDouble("I18") * 1000) / 1000f));
                        getI19.add(String.valueOf(Math.round(jsonObjectI.getDouble("I19") * 1000) / 1000f));
                        getI20.add(String.valueOf(Math.round(jsonObjectI.getDouble("I20") * 1000) / 1000f));
                        getI21.add(String.valueOf(Math.round(jsonObjectI.getDouble("I21") * 1000) / 1000f));
                        getI22.add(String.valueOf(Math.round(jsonObjectI.getDouble("I22") * 1000) / 1000f));
                        getI23.add(String.valueOf(Math.round(jsonObjectI.getDouble("I23") * 1000) / 1000f));
                        getI24.add(String.valueOf(Math.round(jsonObjectI.getDouble("I24") * 1000) / 1000f));
                        getI25.add(String.valueOf(Math.round(jsonObjectI.getDouble("I25") * 1000) / 1000f));
                    } else if (jsonObjectI.getString("SEQ").equals("B")) { //B相
                        getI2.add(String.valueOf(Math.round(jsonObjectI.getDouble("I2") * 1000) / 1000f));
                        getI3.add(String.valueOf(Math.round(jsonObjectI.getDouble("I3") * 1000) / 1000f));
                        getI4.add(String.valueOf(Math.round(jsonObjectI.getDouble("I4") * 1000) / 1000f));
                        getI5.add(String.valueOf(Math.round(jsonObjectI.getDouble("I5") * 1000) / 1000f));
                        getI6.add(String.valueOf(Math.round(jsonObjectI.getDouble("I6") * 1000) / 1000f));
                        getI7.add(String.valueOf(Math.round(jsonObjectI.getDouble("I7") * 1000) / 1000f));
                        getI8.add(String.valueOf(Math.round(jsonObjectI.getDouble("I8") * 1000) / 1000f));
                        getI9.add(String.valueOf(Math.round(jsonObjectI.getDouble("I9") * 1000) / 1000f));
                        getI10.add(String.valueOf(Math.round(jsonObjectI.getDouble("I10") * 1000) / 1000f));
                        getI11.add(String.valueOf(Math.round(jsonObjectI.getDouble("I11") * 1000) / 1000f));
                        getI12.add(String.valueOf(Math.round(jsonObjectI.getDouble("I12") * 1000) / 1000f));
                        getI13.add(String.valueOf(Math.round(jsonObjectI.getDouble("I13") * 1000) / 1000f));
                        getI14.add(String.valueOf(Math.round(jsonObjectI.getDouble("I14") * 1000) / 1000f));
                        getI15.add(String.valueOf(Math.round(jsonObjectI.getDouble("I15") * 1000) / 1000f));
                        getI16.add(String.valueOf(Math.round(jsonObjectI.getDouble("I16") * 1000) / 1000f));
                        getI17.add(String.valueOf(Math.round(jsonObjectI.getDouble("I17") * 1000) / 1000f));
                        getI18.add(String.valueOf(Math.round(jsonObjectI.getDouble("I18") * 1000) / 1000f));
                        getI19.add(String.valueOf(Math.round(jsonObjectI.getDouble("I19") * 1000) / 1000f));
                        getI20.add(String.valueOf(Math.round(jsonObjectI.getDouble("I20") * 1000) / 1000f));
                        getI21.add(String.valueOf(Math.round(jsonObjectI.getDouble("I21") * 1000) / 1000f));
                        getI22.add(String.valueOf(Math.round(jsonObjectI.getDouble("I22") * 1000) / 1000f));
                        getI23.add(String.valueOf(Math.round(jsonObjectI.getDouble("I23") * 1000) / 1000f));
                        getI24.add(String.valueOf(Math.round(jsonObjectI.getDouble("I24") * 1000) / 1000f));
                        getI25.add(String.valueOf(Math.round(jsonObjectI.getDouble("I25") * 1000) / 1000f));
                    } else if (jsonObjectI.getString("SEQ").equals("C")) { //C相
                        getI2.add(String.valueOf(Math.round(jsonObjectI.getDouble("I2") * 1000) / 1000f));
                        getI3.add(String.valueOf(Math.round(jsonObjectI.getDouble("I3") * 1000) / 1000f));
                        getI4.add(String.valueOf(Math.round(jsonObjectI.getDouble("I4") * 1000) / 1000f));
                        getI5.add(String.valueOf(Math.round(jsonObjectI.getDouble("I5") * 1000) / 1000f));
                        getI6.add(String.valueOf(Math.round(jsonObjectI.getDouble("I6") * 1000) / 1000f));
                        getI7.add(String.valueOf(Math.round(jsonObjectI.getDouble("I7") * 1000) / 1000f));
                        getI8.add(String.valueOf(Math.round(jsonObjectI.getDouble("I8") * 1000) / 1000f));
                        getI9.add(String.valueOf(Math.round(jsonObjectI.getDouble("I9") * 1000) / 1000f));
                        getI10.add(String.valueOf(Math.round(jsonObjectI.getDouble("I10") * 1000) / 1000f));
                        getI11.add(String.valueOf(Math.round(jsonObjectI.getDouble("I11") * 1000) / 1000f));
                        getI12.add(String.valueOf(Math.round(jsonObjectI.getDouble("I12") * 1000) / 1000f));
                        getI13.add(String.valueOf(Math.round(jsonObjectI.getDouble("I13") * 1000) / 1000f));
                        getI14.add(String.valueOf(Math.round(jsonObjectI.getDouble("I14") * 1000) / 1000f));
                        getI15.add(String.valueOf(Math.round(jsonObjectI.getDouble("I15") * 1000) / 1000f));
                        getI16.add(String.valueOf(Math.round(jsonObjectI.getDouble("I16") * 1000) / 1000f));
                        getI17.add(String.valueOf(Math.round(jsonObjectI.getDouble("I17") * 1000) / 1000f));
                        getI18.add(String.valueOf(Math.round(jsonObjectI.getDouble("I18") * 1000) / 1000f));
                        getI19.add(String.valueOf(Math.round(jsonObjectI.getDouble("I19") * 1000) / 1000f));
                        getI20.add(String.valueOf(Math.round(jsonObjectI.getDouble("I20") * 1000) / 1000f));
                        getI21.add(String.valueOf(Math.round(jsonObjectI.getDouble("I21") * 1000) / 1000f));
                        getI22.add(String.valueOf(Math.round(jsonObjectI.getDouble("I22") * 1000) / 1000f));
                        getI23.add(String.valueOf(Math.round(jsonObjectI.getDouble("I23") * 1000) / 1000f));
                        getI24.add(String.valueOf(Math.round(jsonObjectI.getDouble("I24") * 1000) / 1000f));
                        getI25.add(String.valueOf(Math.round(jsonObjectI.getDouble("I25") * 1000) / 1000f));
                    }
                }
                harmRateI.setI2(getAvg(getI2));
                harmRateI.setI3(getAvg(getI3));
                harmRateI.setI4(getAvg(getI4));
                harmRateI.setI5(getAvg(getI5));
                harmRateI.setI6(getAvg(getI6));
                harmRateI.setI7(getAvg(getI7));
                harmRateI.setI8(getAvg(getI8));
                harmRateI.setI9(getAvg(getI9));
                harmRateI.setI10(getAvg(getI10));
                harmRateI.setI11(getAvg(getI11));
                harmRateI.setI12(getAvg(getI12));
                harmRateI.setI13(getAvg(getI13));
                harmRateI.setI14(getAvg(getI14));
                harmRateI.setI15(getAvg(getI15));
                harmRateI.setI16(getAvg(getI16));
                harmRateI.setI17(getAvg(getI17));
                harmRateI.setI18(getAvg(getI18));
                harmRateI.setI19(getAvg(getI19));
                harmRateI.setI20(getAvg(getI20));
                harmRateI.setI21(getAvg(getI21));
                harmRateI.setI22(getAvg(getI22));
                harmRateI.setI23(getAvg(getI23));
                harmRateI.setI24(getAvg(getI24));
                harmRateI.setI25(getAvg(getI25));
            }
            harmRateIAndV.setHarmRateI(harmRateI);
        }
        return harmRateIAndV;
    }



}
