package com.pqs9900.util;

import com.njcn.pojo.data.OfflLog;
import com.njcn.utils.ClearPathUtil;
import com.pqs9900.pojo.HisData.*;
import com.njcn.utils.BitConverter;
import com.njcn.utils.PubUtils;
import com.pqs9900.service.HisData.*;
import com.pqs9900.service.configuration.ManaDeviceService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ReflectionUtils;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Future;
import java.util.stream.Collectors;


@Component
public class Homeostasis {

    // 日志记录
    private static final Logger logger = LoggerFactory.getLogger(Homeostasis.class);
    private String strFilePath;//读取文件路径
    private String binName;
    private float pt;//PT变比
    private float ct;//CT变比
    private int lineindex;//监测点ID
    private int allCount = 0;
    private int realCount = 0;

    @Autowired
    DataFlickerService dataFlickerService;

    @Autowired
    DataFlucService dataFlucService;


    @Autowired
    DataPltService dataPltService;

    @Autowired
    DataHarmPhasicIService dataHarmPhasicIService;

    @Autowired
    DataHarmPhasicVService dataHarmPhasicVService;

    @Autowired
    DataHarmpowerPService dataHarmpowerPService;

    @Autowired
    DataHarmpowerQService dataHarmpowerQService;

    @Autowired
    DataHarmpowerSService dataHarmpowerSService;

    @Autowired
    DataHarmrateIService dataHarmrateIService;

    @Autowired
    DataHarmrateVService dataHarmrateVService;

    @Autowired
    DataVService dataVService;

    @Autowired
    DataIService dataIService;

    @Autowired
    DataInHarmIService dataInHarmIService;

    @Autowired
    DataInHarmVService dataInHarmVService;

    @Autowired
    private ManaDeviceService manaDeviceService;


    /****************************************************
     * 稳态数据解析
     * @param strFilePath 读取稳态数据路径
     * @param pt 所选择监测点PT变比
     * @param ct 所选择监测点CT变比
     * @param lineindex 所选择监测点ID
     * @param wiringMode 接线方式 接线方式(0:星形接线；1:三角形接线；2:V形接线；)
     ****************************************************/
    public void AnalyseFileView(String strFilePath, float pt, float ct, int lineindex,int wiringMode,String name) {

        if (strFilePath != "") {
            this.strFilePath = strFilePath;
            this.binName = name;
            this.pt = pt;
            this.ct = ct;
            this.lineindex = lineindex;
            coefficientPt = pt / 1000;//Pt系数

            File file = new File(strFilePath);
            // 判断文件是否存在
            if (file.isFile() && file.exists()) {
                FileHead fileHead = ReadFileHead();//读取头文件
                if (fileHead != null) {
                    if (fileHead.nNum != 0 && fileHead.length != 0) {
                        List<TimeBuf> ListTimeBuf = ReadTimeBuf(fileHead);//获取时间区域

                        //解析成功并更新字段
                        List<TimeBuf> tmpListTimeBuf = new ArrayList<>();
                        tmpListTimeBuf = ListTimeBuf;//幅值给需要排序
                        Collections.sort(tmpListTimeBuf);
                        Date start = getDataTime(tmpListTimeBuf.get(0).getRtcTime()).get(0);//new Date((long) tmpListTimeBuf.get(0).getRtcTime() * 1000);
                        Date end = getDataTime(ListTimeBuf.get(tmpListTimeBuf.size() - 1).getRtcTime()).get(0);//new Date((long) ListTimeBuf.get(tmpListTimeBuf.size() - 1).getRtcTime() * 1000);
                        Calendar c = Calendar.getInstance();
                        c.setTime(start);
                        String year = Integer.toString(c.get(Calendar.YEAR));
                        //TODO 增加縂條目數 ListTimeBuf。size +更新時間
                        allCount = ListTimeBuf.size();
                        realCount = 0;
                        manaDeviceService.updateOFFlog(start, end, year, 4, name, lineindex, new Date(), allCount, realCount, null);
                        TargetBuf targetBuf = ReadTargetBuf(fileHead);//获取每个指标偏移量

                        GetPqdDataValue(ListTimeBuf, targetBuf,wiringMode);//获取所有的原始数据
                        manaDeviceService.updateOFFlog(start, end, year, 1, name, lineindex, new Date(), allCount, realCount, null);
                    } else {
                        //解析失败处理
                        manaDeviceService.updateOFFlog(null, null, null, 2, name, lineindex, new Date(), 0, 0, null);
                        logger.error("文件头长度不满足要求!");
                    }
                } else {
                    //解析失败处理
                    manaDeviceService.updateOFFlog(null, null, null, 5, name, lineindex, new Date(), 0, 0, null);
                    logger.error("文件头不能为空!");
                }
            } else {
                //文件不存在处理
                manaDeviceService.updateOFFlog(null, null, null, 3, name, lineindex, new Date(), 0, 0, null);
                logger.error("找不到指定的文件!");
            }
        } else {
            //文件不存在处理
            manaDeviceService.updateOFFlog(null, null, null, 3, name, lineindex, new Date(), 0, 0, null);
            logger.error("文件名不能为空");
        }
    }

    /*********************************
     *****  时间记录体
     *********************************/
    public class TimeBuf implements Comparable<TimeBuf> {
        /// <summary>
        /// RTC时间
        /// </summary>
        private int rtcTime;
        /// <summary>
        /// 时间记录体类型
        /// </summary>
        private short timeType;
        /// <summary>
        /// 数据长度
        /// </summary>
        private int dataLen;
        /// <summary>
        /// 数据位置,如果为日报表、统计数据则为第一组数据的位置，其余为数据的位置
        /// </summary>
        private long dataPos;
        /// <summary>
        /// 触发原因,如果为统计数据则无触发原因
        /// </summary>
        private short reason;
        /// <summary>
        /// 16位的CRC校验
        /// </summary>
        private short cRC;

        public int getRtcTime() {
            return rtcTime;
        }

        public void setRtcTime(int rtcTime) {
            this.rtcTime = rtcTime;
        }

        public short getTimeType() {
            return timeType;
        }

        public void setTimeType(short timeType) {
            this.timeType = timeType;
        }

        public int getDataLen() {
            return dataLen;
        }

        public void setDataLen(int dataLen) {
            this.dataLen = dataLen;
        }

        public long getDataPos() {
            return dataPos;
        }

        public void setDataPos(int dataPos) {
            this.dataPos = dataPos;
        }

        public short getReason() {
            return reason;
        }

        public void setReason(short reason) {
            this.reason = reason;
        }

        public short getcRC() {
            return cRC;
        }

        public void setcRC(short cRC) {
            this.cRC = cRC;
        }

        @Override
        public int compareTo(TimeBuf o) {
            return this.rtcTime - o.rtcTime;
        }
    }

    /*********************************
     *****  文件头类
     ***** 用于记录时间在文件中的位置
     *********************************/
    public class FileHead {
        /// <summary>
        /// 文件中包含的数据个数
        /// </summary>
        private int nNum;
        /// <summary>
        /// 文件中时间所在的二进制区域位置
        /// </summary>
        private long timePos;
        /// <summary>
        /// 时间所在的二进制区域长度
        /// </summary>
        private int length;
        /// <summary>
        /// 16位的CRC校验
        /// </summary>
        private int cRC;

        public int getnNum() {
            return nNum;
        }

        public void setnNum(int nNum) {
            this.nNum = nNum;
        }

        public long getTimePos() {
            return timePos;
        }

        public void setTimePos(int timePos) {
            this.timePos = timePos;
        }

        public int getLength() {
            return length;
        }

        public void setLength(int length) {
            this.length = length;
        }

        public int getcRC() {
            return cRC;
        }

        public void setcRC(int cRC) {
            this.cRC = cRC;
        }


    }

    /*********************************
     *****  所有指标的偏移量
     ***** 用于每种指标的偏移量
     *********************************/
    private int iHARMNUM = 50;
    private int iHALF_HARMNUM = 25;
    private int iMAX_DATA_NUM = 8 * iHARMNUM + 8 + 2 * 4 + 3 * 3 + 11 + 2 * 6 + 2 + 2 * 4 + 2 * 8 * iHARMNUM + 8 * iHALF_HARMNUM + 4 * 3 + 3 * 4 * iHALF_HARMNUM;

    public class TargetBuf {
        /// <summary>
        /// 数据个数
        /// </summary>
        private int dataNum;
        /// <summary>
        /// 数据区的起始位置
        /// </summary>
        private List<Long> dataPos = new ArrayList<>();
        /// <summary>
        /// 16位的CRC校验
        /// </summary>
        private int cRC;

        public int getDataNum() {
            return dataNum;
        }

        public void setDataNum(int dataNum) {
            this.dataNum = dataNum;
        }

        public List<Long> getDataPos() {
            return dataPos;
        }

        public void setDataPos(List<Long> dataPos) {
            this.dataPos = dataPos;
        }

        public int getcRC() {
            return cRC;
        }

        public void setcRC(int cRC) {
            this.cRC = cRC;
        }
    }

    /*********************************
     *****  读取文件头结构体的大小
     *********************************/
    private int GetFileHeadSize() {
        int nLen = 3 * Integer.SIZE / 8 + Short.SIZE / 8;
        return nLen;
    }

    /*********************************
     *****  读取文件时间结构体的大小
     *********************************/
    private int GetTimeBufSize() {
        int nLen = 3 * Integer.SIZE / 8 + 3 * Short.SIZE / 8;
        return nLen;
    }

    /*********************************
     *****  读取指标的偏移量大小
     *********************************/
    public int GetTargetBufSize() {
        int nLen = iMAX_DATA_NUM * Integer.SIZE / 8 + 2 * Short.SIZE / 8;
        return nLen;
    }

    public static void main(String[] args) {
        String strFileName = "C:"+File.separator+"Users"+File.separator+"Lenovo"+File.separator+"Desktop"+File.separator+"110kV强蛟变#1主变10kV侧长山E909"+File.separator+"110kV强蛟变#1主变10kV侧长山E909.bin";
        Homeostasis homeostasis = new Homeostasis();
        homeostasis.AnalyseFileView(strFileName, 1f, 1f, 11521,2,null);
    }

    /*********************************
     ***** 读取偏移的byte
     *********************************/
    private byte[] ReadFileOffset(int nSize, long Offset) {
        byte[] bArray = new byte[nSize];
        RandomAccessFile raf = null;
        try {
            /******************************************
             * model各个参数详解
             * r 代表以只读方式打开指定文件
             * rw 以读写方式打开指定文件
             * rws 读写方式打开，并对内容或元数据都同步写入底层存储设备
             * rwd 读写方式打开，对文件内容的更新同步更新至底层存储设备
             * ******************************************/
            strFilePath= ClearPathUtil.cleanString(strFilePath);
            raf = new RandomAccessFile(strFilePath, "r");
            //获取RandomAccessFile对象文件指针的位置，初始位置是0
            raf.seek(Offset);//移动文件指针位置
            //用于保存实际读取的字节数
            raf.read(bArray);
        } catch (Exception e) {
            logger.error("读取BIN文件出错：" + e.getMessage());
        } finally {
            if (raf != null) {
                try {
                    raf.close();
                } catch (IOException e) {
                    logger.error("回收资源异常，异常为："+e.toString());
                }
            }
        }
        return bArray;
    }

    /*********************************
     ***** 将文件头写入文件头区
     *********************************/
    private FileHead ReadFileHead() {
        FileHead fileHead = new FileHead();
        int nSize = GetFileHeadSize();//获取文件头结构体的大小
        long Offset = 28;//从28个位置进行读取
        byte[] bArray = ReadFileOffset(nSize, Offset);
        if (bArray != null) {
            int iStep = 0;
            fileHead.nNum = BitConverter.byte4ToInt(bArray, iStep);
            iStep += Integer.SIZE / 8;
            fileHead.timePos = BitConverter.byte4ToLong(bArray, iStep);
            iStep += Integer.SIZE / 8;
            fileHead.length = BitConverter.byte4ToInt(bArray, iStep);
            iStep += Integer.SIZE / 8;
            fileHead.cRC = BitConverter.byte2ToInt(bArray, iStep);
        }
        return fileHead;
    }

    /*********************************
     ***** 将文件时间写入时间区
     *********************************/
    private List<TimeBuf> ReadTimeBuf(FileHead fileHead) {
        List<TimeBuf> listFileHead = new ArrayList<>();//返回数据
        int nSize = fileHead.length;//获取文件头结构体的大小
        long Offset = fileHead.timePos;//读取位置设置
        byte[] bArray = ReadFileOffset(nSize, Offset);
        if (bArray != null) {
            int iStep = 0;
            int iBlockSize = GetTimeBufSize();//时间结构体大小
            for (int i = 0; i < fileHead.nNum; i++) {
                TimeBuf timeBuf = new TimeBuf();
                timeBuf.rtcTime = BitConverter.byte4ToInt(bArray, iStep) - 8 * 60 * 60;
                iStep += Integer.SIZE / 8;
                timeBuf.timeType = BitConverter.byte2ToUnsignedShort(bArray, iStep);
                iStep += Short.SIZE / 8;
                timeBuf.dataLen = BitConverter.byte4ToInt(bArray, iStep);
                iStep += Integer.SIZE / 8;
                timeBuf.dataPos = BitConverter.byte4ToLong(bArray, iStep);
                iStep += Integer.SIZE / 8;
                timeBuf.reason = BitConverter.byte2ToUnsignedShort(bArray, iStep);
                iStep += Short.SIZE / 8;
                timeBuf.cRC = BitConverter.byte2ToUnsignedShort(bArray, iStep);
                iStep += Short.SIZE / 8;
                listFileHead.add(timeBuf);
            }
        }

       /*//针对所有数据进行排序
       Collections.sort(listFileHead, new Comparator<TimeBuf>(){
                *//*
         * int compare(Person p1, Person p2) 返回一个基本类型的整型，
         * 返回负数表示：p1 小于p2，
         * 返回0 表示：p1和p2相等，
         * 返回正数表示：p1大于p2
         *//*
                public int compare(TimeBuf p1, TimeBuf p2) {
                    //按照TimeBuf的rtcTime进行升序排列
                    if(p1.rtcTime > p2.rtcTime){
                        return 1;
                    }
                    if(p1.rtcTime == p2.rtcTime){
                        return 0;
                    }
                    return -1;
                }
            });*/
        return listFileHead;
    }

    /*********************************
     ***** 将指标偏移量填写到
     *********************************/
    private TargetBuf ReadTargetBuf(FileHead fileHead) {
        TargetBuf targetBuf = new TargetBuf();//返回数据
        int nSize = GetTargetBufSize();//获取指标偏移量
        long Offset = fileHead.timePos + fileHead.length;//读取位置设置
        byte[] bArray = ReadFileOffset(nSize, Offset);
        if (bArray != null) {
            int iStep = 0;
            targetBuf.dataNum = BitConverter.byte2ToInt(bArray, iStep);
            iStep += Short.SIZE / 8;
            for (int i = 0; i < targetBuf.dataNum; i++) {
                //long lPos=BitConverter.byte4ToLong(bArray, iStep);
                targetBuf.dataPos.add(BitConverter.byte4ToLong(bArray, iStep));
                iStep += Integer.SIZE / 8;
            }
            targetBuf.cRC = BitConverter.byte2ToInt(bArray, iStep);
        }
        return targetBuf;
    }

    /******************************************
     * 按时间分区获取所有指标的Byte[]
     * 再把这些数据解析入库
     * @param ListTimeBuf 所有时间列表
     * @param targetBuf 原始二进制
     * @param wiringMode 接线方式(0:星形接线；1:三角形接线；2:V形接线；)
     ******************************************/
    private int iReadLength = 1024;//读取长度

    private void GetPqdDataValue(List<TimeBuf> ListTimeBuf, TargetBuf targetBuf,int wiringMode){
        //遍历所有的时间间隔
        //int nSize = iMAX_DATA_NUM * 4 * 4;//总长度为1770 * 每个指标字节数 *（最大，最小，平均，Cp95值）

        /******************************************
         * 修改此处读取数据时间的长度
         * 暂定为1440长度读取
         ******************************************/
        //循环次数（时间区总长度/获取点数）
        int nCyclicTimes = (int) Math.ceil(ListTimeBuf.size() / (double) iReadLength);
        //实际标志（默认长度）
        int iRealReadLength = iReadLength;
        //上一次读取的长度，为了偏移时候使用
        int iLastReadLength = 0;

        long Offset = targetBuf.dataPos.get(0);//获取第一个时间的偏移
        byte[] bArray;
        List<byte[]> listData = new ArrayList();//数据集合
        RandomAccessFile raf = null;
        for (int i = 0; i < nCyclicTimes; i++) {
            //清理数据
            listData.clear();
            /******************************************
             * 最后一组
             * 循环需要改变长度
             ******************************************/
            if (i == nCyclicTimes - 1) {
                iRealReadLength = ListTimeBuf.size() - i * iReadLength;
            }

            try {
                strFilePath= ClearPathUtil.cleanString(strFilePath);
                raf = new RandomAccessFile(strFilePath, "r");
                /******************************************
                 * 获取RandomAccessFile对象文件指针的位置，初始位置是0
                 * 初始化指针的位置，默认第一次为获取的，之后每次根据实际长度进行偏移
                 ******************************************/
                Offset += iLastReadLength * 4;
                //上一次读取数据长度
                iLastReadLength = iRealReadLength;
                raf.seek(Offset);//移动文件指针位置（每个指标需要4个字节存储）

                /**********************************************************
                 *iMAX_DATA_NUM * 4 表示所有的指标最大、最小、平均、CP95值
                 * -1的原因是因为假如8段只需要跳7次
                 **********************************************************/
                for (int j = 0; j < iMAX_DATA_NUM * 4; j++) {
                    bArray = new byte[4 * iRealReadLength];//获取总长度(长度*4)
                    raf.read(bArray);
                    listData.add(bArray);
                    if (j != (iMAX_DATA_NUM * 4) - 1 && nCyclicTimes != 1) {
                        //需要跳过的长度
                        raf.skipBytes((ListTimeBuf.size() - iRealReadLength) * 4);//跳过的字节数（总长度减去已经读取的长度）
                    }
                }
                AnalyGroupData(ListTimeBuf, listData, i, iRealReadLength, wiringMode);
            } catch (Exception e) {
                logger.error("读取BIN文件出错：" + e.getMessage());
            } finally {
                if (raf != null) {
                    try {
                        raf.close();
                    } catch (IOException e) {
                        logger.error("回收资源异常，异常为："+e.toString());
                    }
                }
            }
        }
    }

    /****************************
     *RTC时间转换成两个时间算法
     * @return
     *****************************/
    private String strFormat = "yyyy-MM-dd HH:mm:ss";

    private List<Date> ListDate = new ArrayList<>();

    private List<Date> getDataTime(int rtcTime) {
        ListDate.clear();//清空时间
        String strTime = PubUtils.timeStamp2Date(rtcTime + "", strFormat);
        //yyyy-MM-dd HH:mm:ss
        SimpleDateFormat sdf = new SimpleDateFormat(strFormat);
        Date date = null;
        try {
            date = sdf.parse(strTime);
        } catch (ParseException e) {
            logger.error("时间转换失败：" + e.getMessage());
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        // 获取 年 ，月 ，日，时，分，秒
        int iYear = calendar.get(Calendar.YEAR);
        int iMonth = calendar.get(Calendar.MONTH);
        int iDate = calendar.get(Calendar.DATE);
        int iHour_Of_Day = calendar.get(Calendar.HOUR_OF_DAY);
        int iMinute = calendar.get(Calendar.MINUTE);
        //int iSecond = calendar.get(Calendar.SECOND);

        //第一种取值方式
        int iFirst_Second = 0;
        //第二种取值方式，分钟%10然后在乘以10
        int iSecond_Minute = iMinute / 10 * 10;//每10分钟获取一组数据
        //第三种取值方式，小时%2然后在乘以2
        int iThird_Hour = iHour_Of_Day / 2 * 2;//每2个小时获取一组数据

        Calendar cal_First = Calendar.getInstance();
        cal_First.set(Calendar.YEAR, iYear);
        cal_First.set(Calendar.MONTH, iMonth);
        cal_First.set(Calendar.DATE, iDate);
        cal_First.set(Calendar.HOUR_OF_DAY, iHour_Of_Day);
        cal_First.set(Calendar.MINUTE, iMinute);
        cal_First.set(Calendar.SECOND, iFirst_Second);

        Calendar cal_Second = Calendar.getInstance();
        cal_Second.set(Calendar.YEAR, iYear);
        cal_Second.set(Calendar.MONTH, iMonth);
        cal_Second.set(Calendar.DATE, iDate);
        cal_Second.set(Calendar.HOUR_OF_DAY, iHour_Of_Day);
        cal_Second.set(Calendar.MINUTE, iSecond_Minute);
        cal_Second.set(Calendar.SECOND, 0);

        Calendar cal_Third = Calendar.getInstance();
        cal_Third.set(Calendar.YEAR, iYear);
        cal_Third.set(Calendar.MONTH, iMonth);
        cal_Third.set(Calendar.DATE, iDate);
        cal_Third.set(Calendar.HOUR_OF_DAY, iThird_Hour);
        cal_Third.set(Calendar.MINUTE, 0);
        cal_Third.set(Calendar.SECOND, 0);
        ListDate.add(cal_First.getTime());
        ListDate.add(cal_Second.getTime());
        ListDate.add(cal_Third.getTime());
        return ListDate;
    }

    /*********************************
     * 通过时间秒毫秒数判断两个时间的间隔
     * @param dt_Start
     * @param dt_End
     * @return
     ********************************/
    private int differentMiniterByMillisecond(Date dt_Start, Date dt_End) {
        if (dt_Start == null || dt_End == null)
            return -1;
        int miniter = (int) ((dt_End.getTime() - dt_Start.getTime()) / (1000 * 60));
        return miniter;
    }

    /****************************
     *清空上次存储的数据
     * @return
     *****************************/
    private void ClearData() {
        ListDataFlicker.clear();
        ListDataFluc.clear();
        ListDataHarmPhasicI.clear();
        ListDataHarmPhasicV.clear();
        ListDataHarmpowerP.clear();
        ListDataHarmpowerQ.clear();
        ListDataHarmpowerS.clear();
        ListDataHarmrateI.clear();
        ListDataHarmrateV.clear();
        ListDataI.clear();
        ListDataInHarmI.clear();
        ListDataInHarmV.clear();
        ListDataPlt.clear();
        ListDataV.clear();
        System.gc();//手动调用GC方法
    }

    /*********************************
     *解析数据入库
     *0-10 		相电压(A、B、C、N)、电流(A、B、C、N)、线电压有效值(AB、BC、CA)
     *11-22	    电压上偏差和电压下偏差(11-13相电压上偏差，14-16线电压上偏差，17-19相电压下偏差，20-22线电压下偏差)
     * 23		频率偏差
     * 24		频率
     * 28		电压不平衡
     * 25		电压零序
     * 26		电压负序
     * 27		电压正序
     * 29		电流零序
     * 30		电流负序
     * 31		电流正序
     * 32		电流不平衡度
     * 33-232	电压谐波幅值（33-82 83-132 133-182 183-232）
     * 233-382	电流谐波幅值（233-282 283-332 333-382）
     * 383-432 	电流零序谐波幅值
     * 433-832 	谐波电压电流相角（433-482 483-532 533-582 583-632 633-682 683-732 733-782 783-832）
     * 833-1032	间谐波幅值（833-857 858-882 883-907 908-932 933-957 958-982 983-1007 1008-1032）
     * 1033-1044 总功率（1033-1035 1036-1038 1039-1041 1042-1044）
     * 1045-1344 谐波功率（1045-1144 1145-1244 1245-1344）
     * 1345-1744 谐波电压、电流含有率（1345-1394 1395-1444 1445-1494 1495-1544 1545-1594 1595-1644 1645-1694 1695-1744）
     * 1745-1752 谐波电压电流畸变率
     * 1753-1756 视在功率因素
     * 1757-1760 位移功率因素
     * 1761-1763 电压波动
     * 1764-1766 短时闪变
     * 1767-1769 长时闪变
     ********************************/
    private List<DataFlicker> ListDataFlicker = new ArrayList<>();
    private List<DataFluc> ListDataFluc = new ArrayList<>();
    private List<DataHarmPhasicI> ListDataHarmPhasicI = new ArrayList<>();
    private List<DataHarmPhasicV> ListDataHarmPhasicV = new ArrayList<>();
    private List<DataHarmpowerP> ListDataHarmpowerP = new ArrayList<>();
    private List<DataHarmpowerQ> ListDataHarmpowerQ = new ArrayList<>();
    private List<DataHarmpowerS> ListDataHarmpowerS = new ArrayList<>();
    private List<DataHarmrateI> ListDataHarmrateI = new ArrayList<>();
    private List<DataHarmrateV> ListDataHarmrateV = new ArrayList<>();
    private List<DataI> ListDataI = new ArrayList<>();
    private List<DataInHarmI> ListDataInHarmI = new ArrayList<>();
    private List<DataInHarmV> ListDataInHarmV = new ArrayList<>();
    private List<DataPlt> ListDataPlt = new ArrayList<>();
    private List<DataV> ListDataV = new ArrayList<>();
    private Date dtLast_10_miniter = null;//最后写入的10分钟数据
    private Date dtLast_2_houser = null;//最后写入的2小时数据

    /************************************************************
     * 按组解析所有数据
     * @param ListTimeBuf 对应的时间格式列表
     * @param listData 该区间时间下所有指标的数据集合
     * @param nCyclicTime 循环次数
     * @param listData iRealReadLength实际长度
     * @return
     **********************************************************/
    private void AnalyGroupData(List<TimeBuf> ListTimeBuf, List<byte[]> listData, int nCyclicTime, int iRealReadLength,int wiringMode) {
        ClearData();//清空List数据
        for (int i = 0; i < iRealReadLength; i++) {
            AnalyData(ListTimeBuf.get(nCyclicTime * iReadLength + i), listData, i, wiringMode);//解析数据
        }

        //把数据写入数据库
        batchHisDataDao(100);


        //TODO 增加實際目數 iRealReadLength +更新時間
        Collections.sort(ListTimeBuf);
        Date start = getDataTime(ListTimeBuf.get(0).getRtcTime()).get(0);//new Date((long) ListTimeBuf.get(0).getRtcTime() * 1000);
        Date end = getDataTime(ListTimeBuf.get(ListTimeBuf.size() - 1).getRtcTime()).get(0);//new Date((long) ListTimeBuf.get(ListTimeBuf.size() - 1).getRtcTime() * 1000);
        Calendar c = Calendar.getInstance();
        c.setTime(start);
        String year = Integer.toString(c.get(Calendar.YEAR));
        realCount = realCount + iRealReadLength;
        manaDeviceService.updateOFFlog(start, end, year, 4, binName, lineindex, new Date(), allCount, realCount, null);

        ClearData();//清空List数据
    }

    /************************************************************
     * 解析所有指标
     * @param timeBuf 对应的时间格式
     * @param listData 该时间下所有指标的数据集合
     * @param iRealReadFlag 实际读取位置的标志
     * @param wiringMode 接线方式
     * @return
     **********************************************************/
    private boolean AnalyData(TimeBuf timeBuf, List<byte[]> listData, int iRealReadFlag,int wiringMode) {
        //listData.add(BitConverter.byte4float(bArray, 0));
        boolean blFlag = true;
        try {
            /*******************************************
             *普通时间把分钟除以10取整数，然后在乘以10，秒则为00
             *长闪时间则把小时除以2取整，然后乘以2，分钟和秒为00
             ********************************************/
            List<Date> ListDate = getDataTime(timeBuf.getRtcTime());
            String strPhasicType = "A";//相别
            int iQualityFlag = 0;//数据标识，默认是0
            //A、B、C、T
            for (int i = 0; i < 4; i++) {
                switch (i) {
                    case 0:
                        strPhasicType = "A";
                        //过滤便携式因为整点导致电压变动、长时闪变、短时闪变因为时间前半部分跟后半部分落在不同分钟上错误数据
                        //电压波动、短时闪变：判断方式为取第五个数据，并且同一组数据只录入一个
                        //长时闪变：判断方式为取第1个数据，并且同一组数据只录入一个
                        if (differentMiniterByMillisecond(ListDate.get(1), ListDate.get(0)) >= 5 && differentMiniterByMillisecond(ListDate.get(1), dtLast_10_miniter) != 0) {
                            //电压变动_间隔时间10分钟
                            AnalyDataFluc(ListDate.get(1), strPhasicType, BitConverter.byte4float(listData.get(1761 * 4), iRealReadFlag * 4), iQualityFlag);
                            //电压波动、电压短时闪变、电压长时闪变_间隔时间10分钟
                            AnalyDataFlicker(ListDate.get(1), strPhasicType, BitConverter.byte4float(listData.get(1761 * 4), iRealReadFlag * 4), BitConverter.byte4float(listData.get(1764 * 4), iRealReadFlag * 4), BitConverter.byte4float(listData.get(1767 * 4), iRealReadFlag * 4), iQualityFlag);
                        }
                        //长时闪变
                        if (differentMiniterByMillisecond(ListDate.get(2), dtLast_2_houser) != 0) {
                            //长时闪变_间隔时间两小时
                            AnalyDataPLT(ListDate.get(2), strPhasicType, BitConverter.byte4float(listData.get(1767 * 4), iRealReadFlag * 4), iQualityFlag);
                        }

                        //电压
                        AnalyDataV(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //电流
                        AnalyDataI(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //电压间谐波幅值
                        AnalyDataInHarmV(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //电流间谐波幅值
                        AnalyDataInHarmI(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //谐波电压含有率
                        AnalyDataHarmrateV(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //谐波电流含有率
                        AnalyDataHarmrateI(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //谐波电压角度
                        AnalyDataHarmPhasicV(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //谐波电流角度
                        AnalyDataHarmPhasicI(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //有功功率
                        AnalyDataHarmpowerP(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //无功功率
                        AnalyDataHarmpowerQ(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        //视在功功率
                        AnalyDataHarmpowerS(ListDate.get(0), strPhasicType, listData, 0, iRealReadFlag, iQualityFlag);
                        break;
                    case 1:
                        strPhasicType = "B";
                        //过滤便携式因为整点导致电压变动、长时闪变、短时闪变因为时间前半部分跟后半部分落在不同分钟上错误数据
                        //电压波动、短时闪变：判断方式为取第五个数据，并且同一组数据只录入一个
                        //长时闪变：判断方式为取第1个数据，并且同一组数据只录入一个
                        if (differentMiniterByMillisecond(ListDate.get(1), ListDate.get(0)) >= 5 && differentMiniterByMillisecond(ListDate.get(1), dtLast_10_miniter) != 0) {
                            //电压变动_间隔时间10分钟
                            AnalyDataFluc(ListDate.get(1), strPhasicType, BitConverter.byte4float(listData.get(1762 * 4), iRealReadFlag * 4), iQualityFlag);
                            //电压波动、电压短时闪变、电压长时闪变_间隔时间10分钟
                            AnalyDataFlicker(ListDate.get(1), strPhasicType, BitConverter.byte4float(listData.get(1762 * 4), iRealReadFlag * 4), BitConverter.byte4float(listData.get(1765 * 4), iRealReadFlag * 4), BitConverter.byte4float(listData.get(1768 * 4), iRealReadFlag * 4), iQualityFlag);
                        }
                        //长时闪变
                        if (differentMiniterByMillisecond(ListDate.get(2), dtLast_2_houser) != 0) {
                            //长时闪变_间隔时间两小时
                            AnalyDataPLT(ListDate.get(2), strPhasicType, BitConverter.byte4float(listData.get(1768 * 4), iRealReadFlag * 4), iQualityFlag);
                        }
                        //电压
                        AnalyDataV(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //电流
                        AnalyDataI(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //电压间谐波幅值
                        AnalyDataInHarmV(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //电流间谐波幅值
                        AnalyDataInHarmI(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //谐波电压含有率
                        AnalyDataHarmrateV(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //谐波电流含有率
                        AnalyDataHarmrateI(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //谐波电压角度
                        AnalyDataHarmPhasicV(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //谐波电流角度
                        AnalyDataHarmPhasicI(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //有功功率
                        AnalyDataHarmpowerP(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //无功功率
                        AnalyDataHarmpowerQ(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        //视在功功率
                        AnalyDataHarmpowerS(ListDate.get(0), strPhasicType, listData, 1, iRealReadFlag, iQualityFlag);
                        break;
                    case 2:
                        strPhasicType = "C";
                        //过滤便携式因为整点导致电压变动、长时闪变、短时闪变因为时间前半部分跟后半部分落在不同分钟上错误数据
                        //电压波动、短时闪变：判断方式为取第五个数据，并且同一组数据只录入一个
                        //长时闪变：判断方式为取第1个数据，并且同一组数据只录入一个
                        if (differentMiniterByMillisecond(ListDate.get(1), ListDate.get(0)) >= 5 && differentMiniterByMillisecond(ListDate.get(1), dtLast_10_miniter) != 0) {
                            //电压变动_间隔时间10分钟
                            AnalyDataFluc(ListDate.get(1), strPhasicType, BitConverter.byte4float(listData.get(1763 * 4), iRealReadFlag * 4), iQualityFlag);
                            //电压波动、电压短时闪变、电压长时闪变_间隔时间10分钟
                            AnalyDataFlicker(ListDate.get(1), strPhasicType, BitConverter.byte4float(listData.get(1763 * 4), iRealReadFlag * 4), BitConverter.byte4float(listData.get(1766 * 4), iRealReadFlag * 4), BitConverter.byte4float(listData.get(1769 * 4), iRealReadFlag * 4), iQualityFlag);
                            //给时间赋值
                            dtLast_10_miniter = ListDate.get(1);
                        }
                        //长时闪变
                        if (differentMiniterByMillisecond(ListDate.get(2), dtLast_2_houser) != 0) {
                            //长时闪变_间隔时间两小时
                            AnalyDataPLT(ListDate.get(2), strPhasicType, BitConverter.byte4float(listData.get(1769 * 4), iRealReadFlag * 4), iQualityFlag);
                            //给时间赋值
                            dtLast_2_houser = ListDate.get(2);
                        }
                        //电压
                        AnalyDataV(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //电流
                        AnalyDataI(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //电压间谐波幅值
                        AnalyDataInHarmV(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //电流间谐波幅值
                        AnalyDataInHarmI(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //谐波电压含有率
                        AnalyDataHarmrateV(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //谐波电流含有率
                        AnalyDataHarmrateI(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //谐波电压角度
                        AnalyDataHarmPhasicV(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //谐波电流角度
                        AnalyDataHarmPhasicI(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //有功功率
                        AnalyDataHarmpowerP(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //无功功率
                        AnalyDataHarmpowerQ(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        //视在功功率
                        AnalyDataHarmpowerS(ListDate.get(0), strPhasicType, listData, 2, iRealReadFlag, iQualityFlag);
                        break;
                    case 3:
                        strPhasicType = "T";
                        //电压
                        AnalyDataVT(ListDate.get(0), strPhasicType, listData, iRealReadFlag, iQualityFlag, wiringMode);
                        //电流
                        AnalyDataI(ListDate.get(0), strPhasicType, listData, iRealReadFlag, iQualityFlag);
                        //有功功率
                        AnalyDataHarmpowerP(ListDate.get(0), strPhasicType, listData, 3, iRealReadFlag, iQualityFlag);
                        //无功功率
                        AnalyDataHarmpowerQ(ListDate.get(0), strPhasicType, listData, 3, iRealReadFlag, iQualityFlag);
                        //视在功功率
                        AnalyDataHarmpowerS(ListDate.get(0), strPhasicType, listData, 3, iRealReadFlag, iQualityFlag);
                        break;
                }
            }
        } catch (Exception e) {
            logger.error("稳态数据解析出错：" + e.getMessage());
        }
        return blFlag;
    }

    /****************************************
     * 电压波动
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param data 数据
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataFluc(Date dateTimeid, String strPhasicType, float data, int iQualityFlag) {

        DataFluc dataFluc = new DataFluc();
        dataFluc.setTimeID(dateTimeid);//时间
        dataFluc.setPhasicType(strPhasicType);//相别
        dataFluc.setLineID(lineindex);//监测点ID
        dataFluc.setFluc(data);
        dataFluc.setFluccf(0f);//电压波动频度
        dataFluc.setQualityFlag(iQualityFlag);
        Boolean blFlag = true;
        //删除list中时间和相别相同的数据
        for (DataFluc dataFluc1 : ListDataFluc) {
            //判断两个时间、相别相同的数据
            if (isSameDate(dataFluc1.getTimeID(), dateTimeid) && dataFluc1.getPhasicType().equals(strPhasicType)) {
                blFlag = false;
                break;
            }
        }
        if (blFlag)
            ListDataFluc.add(dataFluc);
    }

    /****************************************
     * 长时闪变
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param data 数据
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataPLT(Date dateTimeid, String strPhasicType, float data, int iQualityFlag) {
        DataPlt dataPlt = new DataPlt();
        dataPlt.setTimeID(dateTimeid);//时间
        dataPlt.setPhasicType(strPhasicType);//相别
        dataPlt.setLineID(lineindex);//监测点ID
        dataPlt.setPlt(data);
        dataPlt.setQualityFlag(iQualityFlag);
        Boolean blFlag = true;
        //删除list中时间和相别相同的数据
        for (DataPlt dataPlt1 : ListDataPlt) {
            //判断两个时间、相别相同的数据
            if (isSameDate(dataPlt1.getTimeID(), dateTimeid) && dataPlt1.getPhasicType().equals(strPhasicType)) {
                blFlag = false;
                break;
            }
        }
        if (blFlag)
            ListDataPlt.add(dataPlt);
    }

    /****************************************
     * 判断两个时间是否一样
     * @param date1
     * @param date2
     * @return
     ****************************************/
    private boolean isSameDate(Date date1, Date date2) {
        Boolean blFlag = true;
        try {
            SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            //fmt.setTimeZone(new TimeZone()); // 如果需要设置时间区域，可以在这里设置
            blFlag = fmt.format(date1).equals(fmt.format(date2));
        } catch (Exception e) {
            blFlag = false;
        }
        return blFlag;
    }

    /****************************************
     * 电压波动、电压短时闪变、电压长时闪变表
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param data_Fluc 电压波动
     * @param data_Fluc 短时闪变
     * @param data_Plt 长时闪变
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataFlicker(Date dateTimeid, String strPhasicType, float data_Fluc, float data_Pst, float data_Plt, int iQualityFlag) {
        DataFlicker dataFlicker = new DataFlicker();
        dataFlicker.setTimeID(dateTimeid);//时间
        dataFlicker.setPhasicType(strPhasicType);//相别
        dataFlicker.setLineID(lineindex);//监测点ID
        dataFlicker.setFluc(data_Fluc);//电压波动
        dataFlicker.setPst(data_Pst);//短时闪变
        dataFlicker.setPlt(data_Plt);//长时闪变
        dataFlicker.setQualityFlag(iQualityFlag);
        Boolean blFlag = true;
        //删除list中时间和相别相同的数据
        for (DataFlicker dataFlicker1 : ListDataFlicker) {
            //判断两个时间、相别相同的数据
            if (isSameDate(dataFlicker1.getTimeID(), dateTimeid) && dataFlicker1.getPhasicType().equals(strPhasicType)) {
                blFlag = false;
                break;
            }
        }
        if (blFlag)
            ListDataFlicker.add(dataFlicker);
    }


    private int iData_Max = 0, iData_Min = 0, iData_Ave = 0, iData_Cp95 = 0;//最大，最小，平均，Cp95值
    private float coefficientPt = 0f;//PT系数

    /****************************************
     * 电压_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志

     *****************************************/
    private void AnalyDataV(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataV dataV = new DataV();
        dataV.setTimeid(dateTimeid);//时间
        dataV.setPhasicType(strPhasicType);//相别
        dataV.setLineid(lineindex);//监测点ID
        //数据填充区
        iData_Max = 0 + iPos * 4;
        iData_Min = 1 + iPos * 4;
        iData_Ave = 2 + iPos * 4;
        iData_Cp95 = 3 + iPos * 4;
        //相电压有效值
        dataV.setRmsMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * coefficientPt);
        dataV.setRmsMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * coefficientPt);
        dataV.setRms(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * coefficientPt);
        dataV.setRmsCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * coefficientPt);

        //相电压上偏差
        iData_Max = 0 + (iPos + 11) * 4;
        iData_Min = 1 + (iPos + 11) * 4;
        iData_Ave = 2 + (iPos + 11) * 4;
        iData_Cp95 = 3 + (iPos + 11) * 4;
        dataV.setVuDevMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
        dataV.setVuDevMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
        dataV.setVuDev(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
        dataV.setVuDevCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));
        //相电压下偏差
        iData_Max = 0 + (iPos + 17) * 4;
        iData_Min = 1 + (iPos + 17) * 4;
        iData_Ave = 2 + (iPos + 17) * 4;
        iData_Cp95 = 3 + (iPos + 17) * 4;
        dataV.setVlDevMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
        dataV.setVlDevMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
        dataV.setVlDev(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
        dataV.setVlDevCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));

        //谐波含量
        int iThd = iPos;
//        //假如是B、C两相的时候需要互换结果
//        switch (iPos) {
//            case 1:
//                iThd = 2;
//                break;
//            case 2:
//                iThd = 1;
//                break;
//        }

        iData_Max = 0 + (iThd + 1745) * 4;
        iData_Min = 1 + (iThd + 1745) * 4;
        iData_Ave = 2 + (iThd + 1745) * 4;
        iData_Cp95 = 3 + (iThd + 1745) * 4;
        dataV.setVThdMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
        dataV.setVThdMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
        dataV.setVThd(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
        dataV.setVThdCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));

        //基波电压有效值
        for (int i = 0; i < 50; i++) {
            String strV_Max = "v" + (i + 1) + "Max";
            String strV_Min = "v" + (i + 1) + "Min";
            String strV_Avg = "v" + (i + 1);
            String strV_Cp95 = "v" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 33 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 33 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 33 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 33 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataV.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataV.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataV.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataV.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataV, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * coefficientPt);
                    f_Min.set(dataV, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * coefficientPt);
                    f_Avg.set(dataV, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * coefficientPt);
                    f_Cp95.set(dataV, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * coefficientPt);
                } catch (IllegalAccessException e) {
                    logger.error("解析谐波电压字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析谐波电压字段出错：" + e.getMessage());
            }
        }
        dataV.setQualityflag(iQualityFlag);
        ListDataV.add(dataV);
    }

    /****************************************
     * 电压_T相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     * @param wiringMode 接线方式
     *****************************************/
    private void AnalyDataVT(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iRealReadFlag, int iQualityFlag ,int wiringMode) {
        DataV dataV = new DataV();
        dataV.setTimeid(dateTimeid);//时间
        dataV.setPhasicType(strPhasicType);//相别
        dataV.setLineid(lineindex);//监测点ID
        //线电压有效值
        if(wiringMode == 0){
            //AB
            dataV.setRmsabMax(BitConverter.byte4float(listData.get(0 + 8 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsabMin(BitConverter.byte4float(listData.get(1 + 8 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsab(BitConverter.byte4float(listData.get(2 + 8 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsabCp95(BitConverter.byte4float(listData.get(3 + 8 * 4), iRealReadFlag * 4) * coefficientPt);
            //BC
            dataV.setRmsbcMax(BitConverter.byte4float(listData.get(0 + 9 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsbcMin(BitConverter.byte4float(listData.get(1 + 9 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsbc(BitConverter.byte4float(listData.get(2 + 9 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsbcCp95(BitConverter.byte4float(listData.get(3 + 9 * 4), iRealReadFlag * 4) * coefficientPt);
            //CA
            dataV.setRmscaMax(BitConverter.byte4float(listData.get(0 + 10 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmscaMin(BitConverter.byte4float(listData.get(1 + 10 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsca(BitConverter.byte4float(listData.get(2 + 10 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmscaCp95(BitConverter.byte4float(listData.get(3 + 10 * 4), iRealReadFlag * 4) * coefficientPt);

        }else{
            //AB
            dataV.setRmsabMax(BitConverter.byte4float(listData.get(0 + 0 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsabMin(BitConverter.byte4float(listData.get(1 + 0 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsab(BitConverter.byte4float(listData.get(2 + 0 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsabCp95(BitConverter.byte4float(listData.get(3 + 0 * 4), iRealReadFlag * 4) * coefficientPt);
            //BC
            dataV.setRmsbcMax(BitConverter.byte4float(listData.get(0 + 1 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsbcMin(BitConverter.byte4float(listData.get(1 + 1 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsbc(BitConverter.byte4float(listData.get(2 + 1 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsbcCp95(BitConverter.byte4float(listData.get(3 + 1 * 4), iRealReadFlag * 4) * coefficientPt);
            //CA
            dataV.setRmscaMax(BitConverter.byte4float(listData.get(0 + 2 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmscaMin(BitConverter.byte4float(listData.get(1 + 2 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmsca(BitConverter.byte4float(listData.get(2 + 2 * 4), iRealReadFlag * 4) * coefficientPt);
            dataV.setRmscaCp95(BitConverter.byte4float(listData.get(3 + 2 * 4), iRealReadFlag * 4) * coefficientPt);
        }

        //频率
        dataV.setFreqMax(BitConverter.byte4float(listData.get(0 + 24 * 4), iRealReadFlag * 4));
        dataV.setFreqMin(BitConverter.byte4float(listData.get(1 + 24 * 4), iRealReadFlag * 4));
        dataV.setFreq(BitConverter.byte4float(listData.get(2 + 24 * 4), iRealReadFlag * 4));
        dataV.setFreqCp95(BitConverter.byte4float(listData.get(3 + 24 * 4), iRealReadFlag * 4));
        //频率偏差
        dataV.setFreqDevMax(BitConverter.byte4float(listData.get(0 + 23 * 4), iRealReadFlag * 4));
        dataV.setFreqDevMin(BitConverter.byte4float(listData.get(1 + 23 * 4), iRealReadFlag * 4));
        dataV.setFreqDev(BitConverter.byte4float(listData.get(2 + 23 * 4), iRealReadFlag * 4));
        dataV.setFreqDevCp95(BitConverter.byte4float(listData.get(3 + 23 * 4), iRealReadFlag * 4));
        //电压不平衡度
        dataV.setVUnbalanceMax(BitConverter.byte4float(listData.get(0 + 28 * 4), iRealReadFlag * 4));
        dataV.setVUnbalanceMin(BitConverter.byte4float(listData.get(1 + 28 * 4), iRealReadFlag * 4));
        dataV.setVUnbalance(BitConverter.byte4float(listData.get(2 + 28 * 4), iRealReadFlag * 4));
        dataV.setVUnbalanceCp95(BitConverter.byte4float(listData.get(3 + 28 * 4), iRealReadFlag * 4));
        //电压正序
        dataV.setVPosMax(BitConverter.byte4float(listData.get(0 + 27 * 4), iRealReadFlag * 4) * coefficientPt);
        dataV.setVPosMin(BitConverter.byte4float(listData.get(1 + 27 * 4), iRealReadFlag * 4) * coefficientPt);
        dataV.setVPos(BitConverter.byte4float(listData.get(2 + 27 * 4), iRealReadFlag * 4) * coefficientPt);
        dataV.setVPosCp95(BitConverter.byte4float(listData.get(3 + 27 * 4), iRealReadFlag * 4) * coefficientPt);
        //电压负序
        dataV.setVNegMax(BitConverter.byte4float(listData.get(0 + 26 * 4), iRealReadFlag * 4) * pt);
        dataV.setVNegMin(BitConverter.byte4float(listData.get(1 + 26 * 4), iRealReadFlag * 4) * pt);
        dataV.setVNeg(BitConverter.byte4float(listData.get(2 + 26 * 4), iRealReadFlag * 4) * pt);
        dataV.setVNegCp95(BitConverter.byte4float(listData.get(3 + 26 * 4), iRealReadFlag * 4) * pt);
        //电压零序
        dataV.setVZeroMax(BitConverter.byte4float(listData.get(0 + 25 * 4), iRealReadFlag * 4) * pt);
        dataV.setVZeroMin(BitConverter.byte4float(listData.get(1 + 25 * 4), iRealReadFlag * 4) * pt);
        dataV.setVZero(BitConverter.byte4float(listData.get(2 + 25 * 4), iRealReadFlag * 4) * pt);
        dataV.setVZeroCp95(BitConverter.byte4float(listData.get(3 + 25 * 4), iRealReadFlag * 4) * pt);
        dataV.setQualityflag(iQualityFlag);
        ListDataV.add(dataV);
    }

    /****************************************
     * 电流_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataI(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataI dataI = new DataI();
        dataI.setTimeid(dateTimeid);//时间
        dataI.setPhasicType(strPhasicType);//相别
        dataI.setLineid(lineindex);//监测点ID
        //数据填充区
        iData_Max = 0 + (iPos + 4) * 4;
        iData_Min = 1 + (iPos + 4) * 4;
        iData_Ave = 2 + (iPos + 4) * 4;
        iData_Cp95 = 3 + (iPos + 4) * 4;
        //电流有效值
        dataI.setRmsMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct);
        dataI.setRmsMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct);
        dataI.setRms(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct);
        dataI.setRmsCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct);

        //谐波电流含量
        iData_Max = 0 + (iPos + 1749) * 4;
        iData_Min = 1 + (iPos + 1749) * 4;
        iData_Ave = 2 + (iPos + 1749) * 4;
        iData_Cp95 = 3 + (iPos + 1749) * 4;
        dataI.setIThdMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
        dataI.setIThdMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
        dataI.setIThd(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
        dataI.setIThdCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));

        //谐波电流幅值有效值
        for (int i = 0; i < 50; i++) {
            String strV_Max = "i" + (i + 1) + "Max";
            String strV_Min = "i" + (i + 1) + "Min";
            String strV_Avg = "i" + (i + 1);
            String strV_Cp95 = "i" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 233 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 233 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 233 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 233 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataI.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataI.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataI.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataI.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataI, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct);
                    f_Min.set(dataI, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct);
                    f_Avg.set(dataI, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct);
                    f_Cp95.set(dataI, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct);
                } catch (IllegalAccessException e) {
                    logger.error("解析谐波电流字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析谐波电流字段出错：" + e.getMessage());
            }
        }
        dataI.setQualityflag(iQualityFlag);
        ListDataI.add(dataI);
    }

    /****************************************
     * 电流_T相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataI(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iRealReadFlag, int iQualityFlag) {
        DataI dataI = new DataI();
        dataI.setTimeid(dateTimeid);//时间
        dataI.setPhasicType(strPhasicType);//相别
        dataI.setLineid(lineindex);//监测点ID
        //电流不平衡度
        dataI.setIUnbalanceMax(BitConverter.byte4float(listData.get(0 + 32 * 4), iRealReadFlag * 4));
        dataI.setIUnbalanceMin(BitConverter.byte4float(listData.get(1 + 32 * 4), iRealReadFlag * 4));
        dataI.setIUnbalance(BitConverter.byte4float(listData.get(2 + 32 * 4), iRealReadFlag * 4));
        dataI.setIUnbalance(BitConverter.byte4float(listData.get(3 + 32 * 4), iRealReadFlag * 4));
        //电流正序
        dataI.setIPosMax(BitConverter.byte4float(listData.get(0 + 31 * 4), iRealReadFlag * 4) * ct);
        dataI.setIPosMin(BitConverter.byte4float(listData.get(1 + 31 * 4), iRealReadFlag * 4) * ct);
        dataI.setIPos(BitConverter.byte4float(listData.get(2 + 31 * 4), iRealReadFlag * 4) * ct);
        dataI.setIPosCp95(BitConverter.byte4float(listData.get(3 + 31 * 4), iRealReadFlag * 4) * ct);
        //电流负序
        dataI.setINegMax(BitConverter.byte4float(listData.get(0 + 30 * 4), iRealReadFlag * 4) * ct);
        dataI.setINegMin(BitConverter.byte4float(listData.get(1 + 30 * 4), iRealReadFlag * 4) * ct);
        dataI.setINeg(BitConverter.byte4float(listData.get(2 + 30 * 4), iRealReadFlag * 4) * ct);
        dataI.setINegCp95(BitConverter.byte4float(listData.get(3 + 30 * 4), iRealReadFlag * 4) * ct);
        //电流零序
        dataI.setIZeroMax(BitConverter.byte4float(listData.get(0 + 29 * 4), iRealReadFlag * 4) * ct);
        dataI.setIZeroMin(BitConverter.byte4float(listData.get(1 + 29 * 4), iRealReadFlag * 4) * ct);
        dataI.setIZero(BitConverter.byte4float(listData.get(2 + 29 * 4), iRealReadFlag * 4) * ct);
        dataI.setIZeroCp95(BitConverter.byte4float(listData.get(3 + 29 * 4), iRealReadFlag * 4) * ct);

        dataI.setQualityflag(iQualityFlag);
        ListDataI.add(dataI);
    }

    /****************************************
     * 电压间谐波幅值_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataInHarmV(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataInHarmV dataInHarmV = new DataInHarmV();
        dataInHarmV.setTimeID(dateTimeid);//时间
        dataInHarmV.setPhasicType(strPhasicType);//相别
        dataInHarmV.setLineID(lineindex);//监测点ID

        //电压间谐波幅值
        for (int i = 0; i < 50; i++) {
            String strV_Max = "v" + (i + 1) + "Max";
            String strV_Min = "v" + (i + 1) + "Min";
            String strV_Avg = "v" + (i + 1);
            String strV_Cp95 = "v" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 833 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 833 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 833 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 833 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataInHarmV.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataInHarmV.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataInHarmV.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataInHarmV.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataInHarmV, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * pt);
                    f_Min.set(dataInHarmV, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * pt);
                    f_Avg.set(dataInHarmV, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * pt);
                    f_Cp95.set(dataInHarmV, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * pt);
                } catch (IllegalAccessException e) {
                    logger.error("解析电压间谐波幅值字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析电压间谐波幅值字段出错：" + e.getMessage());
            }
        }
        dataInHarmV.setQualityFlag(iQualityFlag);
        ListDataInHarmV.add(dataInHarmV);
    }

    /****************************************
     * 电流间谐波幅值_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataInHarmI(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataInHarmI dataInHarmI = new DataInHarmI();
        dataInHarmI.setTimeID(dateTimeid);//时间
        dataInHarmI.setPhasicType(strPhasicType);//相别
        dataInHarmI.setLineID(lineindex);//监测点ID

        //电压间谐波幅值
        for (int i = 0; i < 50; i++) {
            String strV_Max = "i" + (i + 1) + "Max";
            String strV_Min = "i" + (i + 1) + "Min";
            String strV_Avg = "i" + (i + 1);
            String strV_Cp95 = "i" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 933 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 933 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 933 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 933 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataInHarmI.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataInHarmI.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataInHarmI.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataInHarmI.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataInHarmI, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * 100);
                    f_Min.set(dataInHarmI, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * 100);
                    f_Avg.set(dataInHarmI, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * 100);
                    f_Cp95.set(dataInHarmI, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * 100);
                } catch (IllegalAccessException e) {
                    logger.error("解析电流间谐波幅值字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析电流间谐波幅值字段出错：" + e.getMessage());
            }
        }
        dataInHarmI.setQualityFlag(iQualityFlag);
        ListDataInHarmI.add(dataInHarmI);
    }

    /****************************************
     * 谐波电压含有率_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataHarmrateV(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataHarmrateV dataHarmrateV = new DataHarmrateV();
        dataHarmrateV.setTimeID(dateTimeid);//时间
        dataHarmrateV.setPhasicType(strPhasicType);//相别
        dataHarmrateV.setLineID(lineindex);//监测点ID

        //谐波电压含有率
        for (int i = 0; i < 50; i++) {
            String strV_Max = "v" + (i + 1) + "Max";
            String strV_Min = "v" + (i + 1) + "Min";
            String strV_Avg = "v" + (i + 1);
            String strV_Cp95 = "v" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 1345 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 1345 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 1345 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 1345 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataHarmrateV.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataHarmrateV.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataHarmrateV.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataHarmrateV.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataHarmrateV, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * 100);
                    f_Min.set(dataHarmrateV, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * 100);
                    f_Avg.set(dataHarmrateV, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * 100);
                    f_Cp95.set(dataHarmrateV, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * 100);
                } catch (IllegalAccessException e) {
                    logger.error("解析谐波电压含有率字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析谐波电压含有率字段出错：" + e.getMessage());
            }
        }
        dataHarmrateV.setQualityFlag(iQualityFlag);
        ListDataHarmrateV.add(dataHarmrateV);
    }

    /****************************************
     * 谐波电流含有率_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataHarmrateI(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataHarmrateI dataHarmrateI = new DataHarmrateI();
        dataHarmrateI.setTimeID(dateTimeid);//时间
        dataHarmrateI.setPhasicType(strPhasicType);//相别
        dataHarmrateI.setLineID(lineindex);//监测点ID

        //电压间谐波幅值
        for (int i = 0; i < 50; i++) {
            String strV_Max = "i" + (i + 1) + "Max";
            String strV_Min = "i" + (i + 1) + "Min";
            String strV_Avg = "i" + (i + 1);
            String strV_Cp95 = "i" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 1545 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 1545 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 1545 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 1545 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataHarmrateI.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataHarmrateI.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataHarmrateI.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataHarmrateI.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataHarmrateI, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
                    f_Min.set(dataHarmrateI, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
                    f_Avg.set(dataHarmrateI, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
                    f_Cp95.set(dataHarmrateI, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));
                } catch (IllegalAccessException e) {
                    logger.error("解析谐波电流含有率字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析谐波电流含有率字段出错：" + e.getMessage());
            }
        }
        dataHarmrateI.setQualityFlag(iQualityFlag);
        ListDataHarmrateI.add(dataHarmrateI);
    }

    /****************************************
     * 谐波电压角度_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataHarmPhasicV(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataHarmPhasicV dataHarmPhasicV = new DataHarmPhasicV();
        dataHarmPhasicV.setTimeID(dateTimeid);//时间
        dataHarmPhasicV.setPhasicType(strPhasicType);//相别
        dataHarmPhasicV.setLineID(lineindex);//监测点ID

        //谐波电压角度
        for (int i = 0; i < 50; i++) {
            String strV_Max = "v" + (i + 1) + "Max";
            String strV_Min = "v" + (i + 1) + "Min";
            String strV_Avg = "v" + (i + 1);
            String strV_Cp95 = "v" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 433 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 433 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 433 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 433 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataHarmPhasicV.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataHarmPhasicV.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataHarmPhasicV.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataHarmPhasicV.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataHarmPhasicV, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
                    f_Min.set(dataHarmPhasicV, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
                    f_Avg.set(dataHarmPhasicV, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
                    f_Cp95.set(dataHarmPhasicV, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));
                } catch (IllegalAccessException e) {
                    logger.error("解析谐波电压角度字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析谐波电压角度字段出错：" + e.getMessage());
            }
        }
        dataHarmPhasicV.setQualityFlag(iQualityFlag);
        ListDataHarmPhasicV.add(dataHarmPhasicV);
    }

    /****************************************
     * 谐波电流角度_A、B、C相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataHarmPhasicI(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataHarmPhasicI dataHarmPhasicI = new DataHarmPhasicI();
        dataHarmPhasicI.setTimeID(dateTimeid);//时间
        dataHarmPhasicI.setPhasicType(strPhasicType);//相别
        dataHarmPhasicI.setLineID(lineindex);//监测点ID

        //谐波电流角度
        for (int i = 0; i < 50; i++) {
            String strV_Max = "i" + (i + 1) + "Max";
            String strV_Min = "i" + (i + 1) + "Min";
            String strV_Avg = "i" + (i + 1);
            String strV_Cp95 = "i" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 50 + 633 + i) * 4;
            iData_Min = 1 + (iPos * 50 + 633 + i) * 4;
            iData_Ave = 2 + (iPos * 50 + 633 + i) * 4;
            iData_Cp95 = 3 + (iPos * 50 + 633 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataHarmPhasicI.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataHarmPhasicI.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataHarmPhasicI.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataHarmPhasicI.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataHarmPhasicI, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
                    f_Min.set(dataHarmPhasicI, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
                    f_Avg.set(dataHarmPhasicI, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
                    f_Cp95.set(dataHarmPhasicI, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));
                } catch (IllegalAccessException e) {
                    logger.error("解析谐波电流角度字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析谐波电流角度字段出错：" + e.getMessage());
            }
        }
        dataHarmPhasicI.setQualityFlag(iQualityFlag);
        ListDataHarmPhasicI.add(dataHarmPhasicI);
    }


    /****************************************
     * 有功功率_A、B、C、T相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataHarmpowerP(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataHarmpowerP dataHarmpowerP = new DataHarmpowerP();
        dataHarmpowerP.setTimeID(dateTimeid);//时间
        dataHarmpowerP.setPhasicType(strPhasicType);//相别
        dataHarmpowerP.setLineID(lineindex);//监测点ID

        //视在功率因素
        iData_Max = 0 + (iPos + 1753) * 4;
        iData_Min = 1 + (iPos + 1753) * 4;
        iData_Ave = 2 + (iPos + 1753) * 4;
        iData_Cp95 = 3 + (iPos + 1753) * 4;
        dataHarmpowerP.setPfMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
        dataHarmpowerP.setPfMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
        dataHarmpowerP.setPf(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
        dataHarmpowerP.setPfCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));

        //位移功率因素
        iData_Max = 0 + (iPos + 1757) * 4;
        iData_Min = 1 + (iPos + 1757) * 4;
        iData_Ave = 2 + (iPos + 1757) * 4;
        iData_Cp95 = 3 + (iPos + 1757) * 4;
        dataHarmpowerP.setDfMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4));
        dataHarmpowerP.setDfMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4));
        dataHarmpowerP.setDf(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4));
        dataHarmpowerP.setDfCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4));

        //总功率
        iData_Max = 0 + (iPos * 3 + 1033) * 4;
        iData_Min = 1 + (iPos * 3 + 1033) * 4;
        iData_Ave = 2 + (iPos * 3 + 1033) * 4;
        iData_Cp95 = 3 + (iPos * 3 + 1033) * 4;
        dataHarmpowerP.setpMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerP.setpMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerP.setP(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerP.setpCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct * pt / 1000);

        //有功功率
        for (int i = 0; i < 25; i++) {
            String strV_Max = "p" + (i + 1) + "Max";
            String strV_Min = "p" + (i + 1) + "Min";
            String strV_Avg = "p" + (i + 1);
            String strV_Cp95 = "p" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 25 + 1045 + i) * 4;
            iData_Min = 1 + (iPos * 25 + 1045 + i) * 4;
            iData_Ave = 2 + (iPos * 25 + 1045 + i) * 4;
            iData_Cp95 = 3 + (iPos * 25 + 1045 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataHarmpowerP.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataHarmpowerP.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataHarmpowerP.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataHarmpowerP.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataHarmpowerP, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Min.set(dataHarmpowerP, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Avg.set(dataHarmpowerP, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Cp95.set(dataHarmpowerP, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct * pt / 1000);
                } catch (IllegalAccessException e) {
                    logger.error("解析有功功率字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析有功功率字段出错：" + e.getMessage());
            }
        }
        dataHarmpowerP.setQualityFlag(iQualityFlag);
        ListDataHarmpowerP.add(dataHarmpowerP);
    }


    /****************************************
     * 无功功率_A、B、C、T相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataHarmpowerQ(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataHarmpowerQ dataHarmpowerQ = new DataHarmpowerQ();
        dataHarmpowerQ.setTimeID(dateTimeid);//时间
        dataHarmpowerQ.setPhasicType(strPhasicType);//相别
        dataHarmpowerQ.setLineID(lineindex);//监测点ID

        //总功率
        iData_Max = 0 + (iPos * 3 + 1034) * 4;
        iData_Min = 1 + (iPos * 3 + 1034) * 4;
        iData_Ave = 2 + (iPos * 3 + 1034) * 4;
        iData_Cp95 = 3 + (iPos * 3 + 1034) * 4;
        dataHarmpowerQ.setqMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerQ.setqMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerQ.setQ(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerQ.setqCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct * pt / 1000);

        //无功功率
        for (int i = 0; i < 25; i++) {
            String strV_Max = "q" + (i + 1) + "Max";
            String strV_Min = "q" + (i + 1) + "Min";
            String strV_Avg = "q" + (i + 1);
            String strV_Cp95 = "q" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 25 + 1145 + i) * 4;
            iData_Min = 1 + (iPos * 25 + 1145 + i) * 4;
            iData_Ave = 2 + (iPos * 25 + 1145 + i) * 4;
            iData_Cp95 = 3 + (iPos * 25 + 1145 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataHarmpowerQ.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataHarmpowerQ.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataHarmpowerQ.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataHarmpowerQ.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataHarmpowerQ, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Min.set(dataHarmpowerQ, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Avg.set(dataHarmpowerQ, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Cp95.set(dataHarmpowerQ, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct * pt / 1000);
                } catch (IllegalAccessException e) {
                    logger.error("解析无功功率字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析无功功率字段出错：" + e.getMessage());
            }
        }
        dataHarmpowerQ.setQualityFlag(iQualityFlag);
        ListDataHarmpowerQ.add(dataHarmpowerQ);
    }

    /****************************************
     * 视在功率_A、B、C、T相
     * @param dateTimeid 时间
     * @param strPhasicType 相别
     * @param listData 数据集合
     * @param iQualityFlag 数据标志
     *****************************************/
    private void AnalyDataHarmpowerS(Date dateTimeid, String strPhasicType, List<byte[]> listData, int iPos, int iRealReadFlag, int iQualityFlag) {
        DataHarmpowerS dataHarmpowerS = new DataHarmpowerS();
        dataHarmpowerS.setTimeID(dateTimeid);//时间
        dataHarmpowerS.setPhasicType(strPhasicType);//相别
        dataHarmpowerS.setLineID(lineindex);//监测点ID

        //总功率
        iData_Max = 0 + (iPos * 3 + 1035) * 4;
        iData_Min = 1 + (iPos * 3 + 1035) * 4;
        iData_Ave = 2 + (iPos * 3 + 1035) * 4;
        iData_Cp95 = 3 + (iPos * 3 + 1035) * 4;
        dataHarmpowerS.setsMax(BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerS.setsMin(BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerS.setS(BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct * pt / 1000);
        dataHarmpowerS.setsCp95(BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct * pt / 1000);

        //无功功率
        for (int i = 0; i < 25; i++) {
            String strV_Max = "s" + (i + 1) + "Max";
            String strV_Min = "s" + (i + 1) + "Min";
            String strV_Avg = "s" + (i + 1);
            String strV_Cp95 = "s" + (i + 1) + "Cp95";

            iData_Max = 0 + (iPos * 25 + 1245 + i) * 4;
            iData_Min = 1 + (iPos * 25 + 1245 + i) * 4;
            iData_Ave = 2 + (iPos * 25 + 1245 + i) * 4;
            iData_Cp95 = 3 + (iPos * 25 + 1245 + i) * 4;

            Field f_Max = null;
            Field f_Min = null;
            Field f_Avg = null;
            Field f_Cp95 = null;
            try {
                f_Max = dataHarmpowerS.getClass().getDeclaredField(strV_Max);
                ReflectionUtils.makeAccessible(f_Max);

                f_Min = dataHarmpowerS.getClass().getDeclaredField(strV_Min);
                ReflectionUtils.makeAccessible(f_Min);

                f_Avg = dataHarmpowerS.getClass().getDeclaredField(strV_Avg);
                ReflectionUtils.makeAccessible(f_Avg);

                f_Cp95 = dataHarmpowerS.getClass().getDeclaredField(strV_Cp95);
                ReflectionUtils.makeAccessible(f_Cp95);
                try {
                    f_Max.set(dataHarmpowerS, BitConverter.byte4float(listData.get(iData_Max), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Min.set(dataHarmpowerS, BitConverter.byte4float(listData.get(iData_Min), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Avg.set(dataHarmpowerS, BitConverter.byte4float(listData.get(iData_Ave), iRealReadFlag * 4) * ct * pt / 1000);
                    f_Cp95.set(dataHarmpowerS, BitConverter.byte4float(listData.get(iData_Cp95), iRealReadFlag * 4) * ct * pt / 1000);
                } catch (IllegalAccessException e) {
                    logger.error("解析视在功率字段幅值出错：" + e.getMessage());
                }
            } catch (NoSuchFieldException e) {
                logger.error("解析视在功率字段出错：" + e.getMessage());
            }
        }
        dataHarmpowerS.setQualityFlag(iQualityFlag);
        ListDataHarmpowerS.add(dataHarmpowerS);
    }

    public int hisDataDao(List<DataFlicker> ListDataFlicker, List<DataFluc> ListDataFluc,
                          List<DataHarmPhasicI> ListDataHarmPhasicI,
                          List<DataHarmPhasicV> ListDataHarmPhasicV, List<DataHarmpowerP> ListDataHarmpowerP,
                          List<DataHarmpowerQ> ListDataHarmpowerQ, List<DataHarmpowerS> ListDataHarmpowerS,
                          List<DataHarmrateI> ListDataHarmrateI, List<DataHarmrateV> ListDataHarmrateV,
                          List<DataI> ListDataI, List<DataInHarmI> ListDataInHarmI, List<DataInHarmV> ListDataInHarmV,
                          List<DataPlt> ListDataPlt, List<DataV> ListDataV) {
        int flag = 0;
        try {
            //短时闪变
            if (ListDataFlicker != null) {
                try {
                    for (int i = 0; i < ListDataFlicker.size(); i++) {
                        dataFlickerService.saveDataFlicker(ListDataFlicker.get(i));
                    }
                } catch (Exception e) {
                    logger.error("短时闪变导入异常，异常是" + e.toString());
                }
            }
            //电压波动
            if (ListDataFluc != null) {
                try {
                    for (int i = 0; i < ListDataFluc.size(); i++) {
                        dataFlucService.saveDataFluc(ListDataFluc.get(i));
                    }
                } catch (Exception e) {
                    logger.error("电压波动导入异常，异常是" + e.toString());
                }
            }
            //长时闪变
            if (ListDataPlt != null) {
                try {
                    for (int i = 0; i < ListDataPlt.size(); i++) {
                        dataPltService.saveDataPlt(ListDataPlt.get(i));
                    }
                } catch (Exception e) {
                    logger.error("长时闪变导入异常，异常是" + e.toString());
                }
            }
            //谐波电流角度表
            if (ListDataHarmPhasicI != null) {
                try {
                    for (int i = 0; i < ListDataHarmPhasicI.size(); i++) {
                        dataHarmPhasicIService.saveDataHarmPhasicI(ListDataHarmPhasicI.get(i));
                    }
                } catch (Exception e) {
                    logger.error("谐波电流角度表导入异常，异常是" + e.toString());
                }
            }
            //谐波电压角度表
            if (ListDataHarmPhasicV != null) {
                try {
                    for (int i = 0; i < ListDataHarmPhasicV.size(); i++) {
                        dataHarmPhasicVService.saveDataHarmPhasicV(ListDataHarmPhasicV.get(i));
                    }
                } catch (Exception e) {
                    logger.error("谐波电压角度表导入异常，异常是" + e.toString());
                }
            }
            //三相有功功率
            if (ListDataHarmpowerP != null) {
                try {
                    for (int i = 0; i < ListDataHarmpowerP.size(); i++) {
                        dataHarmpowerPService.saveDataHarmpowerP(ListDataHarmpowerP.get(i));
                    }
                } catch (Exception e) {
                    logger.error("三相有功功率导入异常，异常是" + e.toString());
                }
            }
            //三相无功功率
            if (ListDataHarmpowerQ != null) {
                try {
                    for (int i = 0; i < ListDataHarmpowerQ.size(); i++) {
                        dataHarmpowerQService.saveDataHarmpowerQ(ListDataHarmpowerQ.get(i));
                    }
                } catch (Exception e) {
                    logger.error("三相无功功率导入异常，异常是" + e.toString());
                }
            }
            //三相视在功率
            if (ListDataHarmpowerS != null) {
                try {
                    for (int i = 0; i < ListDataHarmpowerS.size(); i++) {
                        dataHarmpowerSService.saveDataHarmpowerS(ListDataHarmpowerS.get(i));
                    }
                } catch (Exception e) {
                    logger.error("三相视在功率导入异常，异常是" + e.toString());
                }
            }
            //谐波电压含有率
            if (ListDataHarmrateV != null) {
                try {
                    for (int i = 0; i < ListDataHarmrateV.size(); i++) {
                        dataHarmrateVService.saveDataHarmrateV(ListDataHarmrateV.get(i));
                    }
                } catch (Exception e) {
                    logger.error("谐波电压含有率导入异常，异常是" + e.toString());
                }
            }
            //谐波电流幅值
            if (ListDataHarmrateI != null) {
                try {
                    for (int i = 0; i < ListDataHarmrateI.size(); i++) {
                        dataHarmrateIService.saveDataHarmrateI(ListDataHarmrateI.get(i));
                    }
                } catch (Exception e) {
                    logger.error("谐波电流幅值导入异常，异常是" + e.toString());
                }
            }
            //电流相关
            if (ListDataI != null) {
                try {
                    for (int i = 0; i < ListDataI.size(); i++) {
                        dataIService.saveDataI(ListDataI.get(i));
                    }
                } catch (Exception e) {
                    logger.error("电流相关导入异常，异常是" + e.toString());
                }
            }
            //电压相关
            if (ListDataV != null) {
                try {
                    for (int i = 0; i < ListDataV.size(); i++) {
                        dataVService.saveDataV(ListDataV.get(i));
                    }
                } catch (Exception e) {
                    logger.error("电压相关导入异常，异常是" + e.toString());
                }
            }
            //电流间谐波幅值表
            if (ListDataInHarmI != null) {
                try {
                    for (int i = 0; i < ListDataInHarmI.size(); i++) {
                        dataInHarmIService.saveDataInHarmI(ListDataInHarmI.get(i));
                    }
                } catch (Exception e) {
                    logger.error("电流简谐波幅值表导入异常，异常是" + e.toString());
                }
            }
            //电压间谐波幅值表
            if (ListDataInHarmV != null) {
                try {
                    for (int i = 0; i < ListDataInHarmV.size(); i++) {
                        dataInHarmVService.saveDataInHarmV(ListDataInHarmV.get(i));
                    }
                } catch (Exception e) {
                    logger.error("电压间谐波幅值表  导入异常，异常是" + e.toString());
                }
            }
            flag = 1;
        } catch (Exception e) {
            flag = 0;
        }
        return flag;
    }

    /***************************************
     * 稳态离线数据入库
     * 批量入库
     * num    每次批量入库的条目数
     * @return 返回入库是否成功
     ***************************************/
    public void batchHisDataDao(int num){
        int nCyclicTimes = 0;//循环次数（总长度/批量入库条目数）
        int fromIndex = 0, toIndex = 0;//获取数据的起始和结束下标

          //短时闪变
            if (ListDataFlicker != null) {
                List<DataFlicker> tmpListDataFlicker = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataFlicker> set = new TreeSet<>(Comparator.comparing(DataFlicker -> DataFlicker.getTimeID()+ DataFlicker.getPhasicType() + DataFlicker.getLineID()));
                set.addAll(ListDataFlicker);
                ListDataFlicker = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataFlicker.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataFlicker.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataFlicker.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataFlicker.addAll(ListDataFlicker.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataFlickerService.insertDataFlicker(tmpListDataFlicker);
                    }
                } catch (Exception e) {
                    //logger.error("短时闪变入库异常，异常是数据是：" + e.toString());
                    logger.error("短时闪变入库异常，异常是数据是：" + tmpListDataFlicker.get(0).getTimeID().toString());
                }
            }
            //电压波动
            if (ListDataFluc != null) {
                List<DataFluc> tmpListDataFluc = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataFluc> set = new TreeSet<>(Comparator.comparing(DataFluc -> DataFluc.getTimeID()+ DataFluc.getPhasicType() + DataFluc.getLineID()));
                set.addAll(ListDataFluc);
                ListDataFluc = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataFluc.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataFluc.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataFluc.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataFluc.addAll(ListDataFluc.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataFlucService.insertDataFluc(tmpListDataFluc);
                    }
                } catch (Exception e) {
                    //logger.error("电压波动导入异常，异常是数据是：" + e.toString());
                    logger.error("电压波动导入异常，异常是数据是：" + tmpListDataFluc.get(0).getTimeID().toString());
                }
            }
            //长时闪变
            if (ListDataPlt != null) {
                List<DataPlt> tmpListDataPlt = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataPlt> set = new TreeSet<>(Comparator.comparing(DataPlt -> DataPlt.getTimeID()+ DataPlt.getPhasicType() + DataPlt.getLineID()));
                set.addAll(ListDataPlt );
                ListDataPlt  = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataPlt.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataPlt.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataPlt.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataPlt.addAll(ListDataPlt.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataPltService.insertDataPlt(tmpListDataPlt);
                    }
                } catch (Exception e) {
                    //logger.error("长时闪变导入异常，异常是数据是：" + e.toString());
                    logger.error("长时闪变导入异常，异常是数据是：" + tmpListDataPlt.get(0).getTimeID().toString());
                }
            }
            //谐波电流角度表
            if (ListDataHarmPhasicI != null) {
                List<DataHarmPhasicI> tmpListDataHarmPhasicI = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataHarmPhasicI> set = new TreeSet<>(Comparator.comparing(DataHarmPhasicI -> DataHarmPhasicI.getTimeID()+ DataHarmPhasicI.getPhasicType() + DataHarmPhasicI.getLineID()));
                set.addAll(ListDataHarmPhasicI );
                ListDataHarmPhasicI  = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataHarmPhasicI.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataHarmPhasicI.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataHarmPhasicI.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataHarmPhasicI.addAll(ListDataHarmPhasicI.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                       dataHarmPhasicIService.insertDataHarmPhasicI(tmpListDataHarmPhasicI);
                    }
                } catch (Exception e) {
                    //logger.error("谐波电流角度表导入异常，异常是数据是：" + e.toString());
                    logger.error("谐波电流角度表导入异常，异常是数据是：" + tmpListDataHarmPhasicI.get(0).getTimeID().toString());
                }
            }
            //谐波电压角度表
            if (ListDataHarmPhasicV != null) {
                List<DataHarmPhasicV> tmpListDataHarmPhasicV = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataHarmPhasicV> set = new TreeSet<>(Comparator.comparing(DataHarmPhasicV -> DataHarmPhasicV.getTimeID()+ DataHarmPhasicV.getPhasicType() + DataHarmPhasicV.getLineID()));
                set.addAll(ListDataHarmPhasicV );
                ListDataHarmPhasicV  = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataHarmPhasicV.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataHarmPhasicV.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataHarmPhasicV.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataHarmPhasicV.addAll(ListDataHarmPhasicV.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataHarmPhasicVService.insertDataHarmPhasicV(tmpListDataHarmPhasicV);
                    }
                } catch (Exception e) {
                    //logger.error("谐波电压角度表导入异常，异常是数据是：" + e.toString());
                    logger.error("谐波电压角度表导入异常，异常是数据是：" + tmpListDataHarmPhasicV.get(0).getTimeID().toString());
                }
            }
            //三相有功功率
            if (ListDataHarmpowerP != null) {
                List<DataHarmpowerP> tmpListDataHarmpowerP = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataHarmpowerP> set = new TreeSet<>(Comparator.comparing(DataHarmpowerP -> DataHarmpowerP.getTimeID()+ DataHarmpowerP.getPhasicType() + DataHarmpowerP.getLineID()));
                set.addAll(ListDataHarmpowerP );
                ListDataHarmpowerP  = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataHarmpowerP.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataHarmpowerP.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataHarmpowerP.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataHarmpowerP.addAll(ListDataHarmpowerP.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataHarmpowerPService.insertDataHarmpowerP(tmpListDataHarmpowerP);
                    }
                } catch (Exception e) {
                    //logger.error("三相有功功率导入异常，异常是数据是：" + e.toString());
                    logger.error("三相有功功率导入异常，异常是数据是：" + tmpListDataHarmpowerP.get(0).getTimeID().toString());
                }
            }
            //三相无功功率
            if (ListDataHarmpowerQ != null) {
                List<DataHarmpowerQ> tmpListDataHarmpowerQ = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataHarmpowerQ> set = new TreeSet<>(Comparator.comparing(DataHarmpowerQ -> DataHarmpowerQ.getTimeID()+ DataHarmpowerQ.getPhasicType() + DataHarmpowerQ.getLineID()));
                set.addAll(ListDataHarmpowerQ );
                ListDataHarmpowerQ  = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataHarmpowerQ.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataHarmpowerQ.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataHarmpowerQ.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataHarmpowerQ.addAll(ListDataHarmpowerQ.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataHarmpowerQService.insertDataHarmpowerQ(tmpListDataHarmpowerQ);
                    }
                } catch (Exception e) {
                    //logger.error("三相无功功率导入异常，异常是数据是：" + e.toString());
                    logger.error("三相无功功率导入异常，异常是数据是：" + tmpListDataHarmpowerQ.get(0).getTimeID().toString());
                }
            }
            //三相视在功率
            if (ListDataHarmpowerS != null) {
                List<DataHarmpowerS> tmpListDataHarmpowerS = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataHarmpowerS> set = new TreeSet<>(Comparator.comparing(DataHarmpowerS -> DataHarmpowerS.getTimeID()+ DataHarmpowerS.getPhasicType() + DataHarmpowerS.getLineID()));
                set.addAll(ListDataHarmpowerS );
                ListDataHarmpowerS  = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataHarmpowerS.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataHarmpowerS.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataHarmpowerS.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataHarmpowerS.addAll(ListDataHarmpowerS.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataHarmpowerSService.insertDataHarmpowerS(tmpListDataHarmpowerS);
                    }
                } catch (Exception e) {
                    //logger.error("三相视在功率导入异常，异常是数据是：" + e.toString());
                    logger.error("三相视在功率导入异常，异常是数据是：" + tmpListDataHarmpowerS.get(0).getTimeID().toString());
                }
            }
            //谐波电压含有率
            if (ListDataHarmrateV != null) {
                List<DataHarmrateV> tmpListDataHarmrateV = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataHarmrateV> set = new TreeSet<>(Comparator.comparing(DataHarmrateV -> DataHarmrateV.getTimeID()+ DataHarmrateV.getPhasicType() + DataHarmrateV.getLineID()));
                set.addAll(ListDataHarmrateV  );
                ListDataHarmrateV   = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataHarmrateV.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataHarmrateV.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataHarmrateV.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataHarmrateV.addAll(ListDataHarmrateV.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataHarmrateVService.insertDataHarmrateV(tmpListDataHarmrateV);
                    }
                } catch (Exception e) {
                    //logger.error("谐波电压含有率导入异常，异常是数据是：" + e.toString());
                    logger.error("谐波电压含有率导入异常，异常是数据是：" + tmpListDataHarmrateV.get(0).getTimeID().toString());
                }
            }
            //谐波电流幅值
            if (ListDataHarmrateI != null) {
                List<DataHarmrateI> tmpListDataHarmrateI = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataHarmrateI> set = new TreeSet<>(Comparator.comparing(DataHarmrateI -> DataHarmrateI.getTimtID()+ DataHarmrateI.getPhasicType() + DataHarmrateI.getLineID()));
                set.addAll(ListDataHarmrateI  );
                ListDataHarmrateI   = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataHarmrateI.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataHarmrateI.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataHarmrateI.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataHarmrateI.addAll(ListDataHarmrateI.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataHarmrateIService.insertDataHarmrateI(tmpListDataHarmrateI);
                    }
                } catch (Exception e) {
                    //logger.error("谐波电流幅值导入异常，异常是数据是：" + e.toString());
                    logger.error("谐波电流幅值导入异常，异常是数据是：" + tmpListDataHarmrateI.get(0).getTimtID().toString());
                }
            }
            //电流相关
            if (ListDataI != null) {
                List<DataI> tmpListDataI = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataI> set = new TreeSet<>(Comparator.comparing(DataI -> DataI.getTimeid()+ DataI.getPhasicType() + DataI.getLineid()));
                set.addAll(ListDataI);
                ListDataI = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataI.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataI.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataI.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataI.addAll(ListDataI.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                       dataIService.insertDataI(tmpListDataI);
                    }
                } catch (Exception e) {
                    //logger.error("电流相关导入异常，异常是数据是：" + e.toString());
                    logger.error("电流相关导入异常，异常是数据是：" + tmpListDataI.get(0).getTimeid().toString());
                }
            }

            //电流间谐波幅值表
            if (ListDataInHarmI != null) {
                List<DataInHarmI> tmpListDataInHarmI = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataInHarmI> set = new TreeSet<>(Comparator.comparing(DataInHarmI -> DataInHarmI.getTimeID()+ DataInHarmI.getPhasicType() + DataInHarmI.getLineID()));
                set.addAll(ListDataInHarmI);
                ListDataInHarmI = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataInHarmI.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataInHarmI.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataInHarmI.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataInHarmI.addAll(ListDataInHarmI.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataInHarmIService.insertDataInHarmI(tmpListDataInHarmI);
                    }
                } catch (Exception e) {
                    //logger.error("电流简谐波幅值表导入异常，异常是数据是：" + e.toString());
                    logger.error("电流简谐波幅值表导入异常，异常是数据是：" + tmpListDataInHarmI.get(0).getTimeID().toString());
                }
            }
            //电压间谐波幅值表
            if (ListDataInHarmV != null) {
                List<DataInHarmV> tmpListDataInHarmV = new ArrayList<>();
                //过滤数组中【时间+类型+监测点ID】相同的数据剔除
                Set<DataInHarmV> set = new TreeSet<>(Comparator.comparing(DataInHarmV -> DataInHarmV.getTimeID()+ DataInHarmV.getPhasicType() + DataInHarmV.getLineID()));
                set.addAll(ListDataInHarmV);
                ListDataInHarmV = new ArrayList<>(set);
                try {
                    nCyclicTimes = (int) Math.ceil(ListDataInHarmV.size() / (double) num);
                    for (int i = 0; i < nCyclicTimes; i++) {
                        tmpListDataInHarmV.clear();
                        //假如是最后一次循环则获取循环到结束
                        fromIndex = i * num;
                        if (i == nCyclicTimes - 1) {
                            toIndex = ListDataInHarmV.size();
                        } else {
                            toIndex = (i + 1) * num;
                        }
                        //可以先按下标截取，再入库
                        tmpListDataInHarmV.addAll(ListDataInHarmV.subList(fromIndex, toIndex));
                        // TODO 做批量入库的操作
                        dataInHarmVService.insertDataInHarmV(tmpListDataInHarmV);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    //logger.error("电压间谐波幅值表，异常是数据是：" + e.toString());
                    logger.error("电压间谐波幅值表，异常是数据是：" + tmpListDataInHarmV.get(0).getTimeID().toString());
                }
            }

             //电压相关
             if (ListDataV != null) {
            List<DataV> tmpListDataV = new ArrayList<>();
            //过滤数组中【时间+类型+监测点ID】相同的数据剔除
            Set<DataV> set = new TreeSet<>(Comparator.comparing(DataV -> DataV.getTimeid()+ DataV.getPhasicType() + DataV.getLineid()));
            set.addAll(ListDataV);
            ListDataV = new ArrayList<>(set);
            try {
                nCyclicTimes = (int) Math.ceil(ListDataV.size() / (double) num);
                for (int i = 0; i < nCyclicTimes; i++) {
                    tmpListDataV.clear();
                    //假如是最后一次循环则获取循环到结束
                    fromIndex = i * num;
                    if (i == nCyclicTimes - 1) {
                        toIndex = ListDataV.size();
                    } else {
                        toIndex = (i + 1) * num;
                    }
                    //可以先按下标截取，再入库
                    tmpListDataV.addAll(ListDataV.subList(fromIndex, toIndex));
                    // TODO 做批量入库的操作
                    dataVService.insertDataV(tmpListDataV);
                }
            } catch (Exception e) {
                //logger.error("电压相关导入异常，异常是数据是：" + e.toString());
                logger.error("电压相关导入异常，异常是数据是：" + tmpListDataV.get(0).getTimeid().toString());
            }
        }



    }

    /***************************************
     * 多线程导入
     * 批量入库
     * num    每次批量入库的条目数
     * @return 返回入库是否成功
     ***************************************/
    private Map SubThread() {
        Map<String, Future> futureMap = new HashMap<>();
        //短时闪变
        if (!CollectionUtils.isEmpty(ListDataFlicker)) {
            Future flickerFuture = dataFlickerService.insertDataFlickerExecutor(ListDataFlicker);
            futureMap.put("短时闪变", flickerFuture);
        }
        //电压波动
        if (!CollectionUtils.isEmpty(ListDataFluc)) {
            Future flucFuture = dataFlucService.insertDataFlucExecutor(ListDataFluc);
            futureMap.put("电压波动", flucFuture);
        }
        //长时闪变
        if (!CollectionUtils.isEmpty(ListDataPlt)) {
            Future pltFuture = dataPltService.insertDataPltExecutor(ListDataPlt);
            futureMap.put("长时闪变", pltFuture);
        }
        //谐波电流角度表
        if (!CollectionUtils.isEmpty(ListDataHarmPhasicI)) {
            Future harmPhasicIFuture = dataHarmPhasicIService.insertDataHarmPhasicIExecutor(ListDataHarmPhasicI);
            futureMap.put("谐波电流角度", harmPhasicIFuture);
        }
        //谐波电压角度表
        if (!CollectionUtils.isEmpty(ListDataHarmPhasicV)) {
            Future harmPhasicVFuture = dataHarmPhasicVService.insertDataHarmPhasicVExecutor(ListDataHarmPhasicV);
            futureMap.put("谐波电压角度", harmPhasicVFuture);
        }
        //三相有功功率
        if (!CollectionUtils.isEmpty(ListDataHarmpowerP)) {
            Future harmpowerPFuture = dataHarmpowerPService.insertDataHarmpowerPExecutor(ListDataHarmpowerP);
            futureMap.put("三相有功功率", harmpowerPFuture);
        }
        //三相无功功率
        if (!CollectionUtils.isEmpty(ListDataHarmpowerQ)) {
            Future harmpowerQFuture = dataHarmpowerQService.insertDataHarmpowerQExecutor(ListDataHarmpowerQ);
            futureMap.put("三相无功功率", harmpowerQFuture);
        }
        //三相视在功率
        if (!CollectionUtils.isEmpty(ListDataHarmpowerS)) {
            Future harmpowerSFuture = dataHarmpowerSService.insertDataHarmpowerSExecutor(ListDataHarmpowerS);
            futureMap.put("三相视在功率", harmpowerSFuture);
        }
        //谐波电压含有率
        if (!CollectionUtils.isEmpty(ListDataHarmrateV)) {
            Future harmrateVFuture = dataHarmrateVService.insertDataHarmrateVExecutor(ListDataHarmrateV);
            futureMap.put("谐波电压含有率", harmrateVFuture);
        }
        //谐波电流幅值
        if (!CollectionUtils.isEmpty(ListDataHarmrateI)) {
            Future harmrateIFuture = dataHarmrateIService.insertDataHarmrateIExecutor(ListDataHarmrateI);
            futureMap.put("谐波电流幅值", harmrateIFuture);
        }
        //电流相关
        if (!CollectionUtils.isEmpty(ListDataI)) {
            Future iFuture = dataIService.insertDataIExecutor(ListDataI);
            futureMap.put("电流相关", iFuture);
        }
        //电压相关
        if (!CollectionUtils.isEmpty(ListDataV)) {
            Future vFuture = dataVService.insertDataVExecutor(ListDataV);
            futureMap.put("电压相关", vFuture);
        }
        //电流间谐波幅值表
        if (!CollectionUtils.isEmpty(ListDataInHarmI)) {
            Future inHarmIFuture = dataInHarmIService.insertDataInHarmIExecutor(ListDataInHarmI);
            futureMap.put("电流间谐波幅值", inHarmIFuture);
        }
        //电压间谐波幅值表
        if (!CollectionUtils.isEmpty(ListDataInHarmV)) {
            Future inHarmVFuture = dataInHarmVService.insertDataInHarmVExecutor(ListDataInHarmV);
            futureMap.put("电压间谐波幅值", inHarmVFuture);
        }
        return futureMap;
    }
}
