package io.renren.modules.aspen.utils;

import com.opencsv.CSVReader;
import io.renren.modules.aspen.entity.TElecdashboardRealtimeEntity;
import io.renren.modules.aspen.entity.base.TElecdashboard;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;

/**
 * 电厂大屏数据抓取工具
 *
 * @author Wang Zi Wen
 * @email wangggziwen@163.com
 * @date 2022/09/01 09:54:38
 */
public class DashboardDataPullUtils {

    /**
     * 抓取csv数据
     */
    public void getCsvData1(){
        String csvFile = "C://elecdashboard/elecDashboardData1.csv";
        CSVReader reader = null;
        try {
            reader = new CSVReader(new FileReader(csvFile));
            String[] line;
            int i = 0;
            while ((line = reader.readNext()) != null) {
                i++;
                if (i == 3) {
                    System.out.println("第" + i + "行");
                    for (int j = 2; j < 7; j++) {
                        System.out.println("第" + (j + 1) + "格:" + line[j]);
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    public void getCsvData2(){
        String csvFile = "C://elecdashboard/elecDashboardData2.csv";
        CSVReader reader = null;
        try {
            reader = new CSVReader(new FileReader(csvFile));
            String[] line;
            int i = 0;
            while ((line = reader.readNext()) != null) {
                i++;
                if (i == 3) {
                    System.out.println("第" + i + "行");
                    for (int j = 1; j < 6; j++) {
                        System.out.println("第" + (j + 1) + "格:" + line[j]);
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    public void getCsvData3(){
        String csvFile = "C://elecdashboard/elecDashboardData3.csv";
        CSVReader reader = null;
        try {
            reader = new CSVReader(new FileReader(csvFile));
            String[] line;
            int i = 0;
            while ((line = reader.readNext()) != null) {
                i++;
                if (i == 2) {
                    System.out.println("第" + i + "行");
                    for (int j = 2; j < 5; j++) {
                        System.out.println("第" + (j + 1) + "列: " + line[j]);
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 抓取excel数据
     *
     * @param TElecDashboard 电厂大屏数据
     * @return 电厂大屏数据
     */
    public TElecdashboard getExcelData(TElecdashboard TElecDashboard) {
        // 设置对象创建时间
        TElecDashboard.setPullDate(new Date());
//        // 判断电厂大屏数据类型
//        if (TElecDashboard instanceof TElecdashboardRealtimeEntity) {   // 抓取实时数据
//
//        } else if (TElecDashboard instanceof TElecdashboradDayEntity) { // 抓取每日数据
//
//        }
        // excel对象
        Workbook workbook = null;
        try {
            // 文件读取路径
            String filePath = "C://elecdashboard/elecDashboardData.xlsx";
            // 文件输入流
            InputStream inputStream = new FileInputStream(filePath);
            // 根据文件后缀名，决定excel（workbook）对象的具体实现
            if (filePath.substring(filePath.lastIndexOf(".") + 1).equals("xls")) {
                workbook = new HSSFWorkbook(inputStream);
            } else if (filePath.substring(filePath.lastIndexOf(".") + 1).equals("xlsx")){
                workbook = new XSSFWorkbook(inputStream);
            }
            // 根据sheet index，获取sheet对象
            Sheet sheet1 = workbook.getSheetAt(0);  // 数据监控
            Sheet sheet2 = workbook.getSheetAt(1);  // 蒸汽平衡
            Sheet sheet3 = workbook.getSheetAt(2);  // 环保监控
            //========================================电厂大屏数据第一页：数据监控========================================
            // 发电机
            String gtg1PowerGenLevel = this.getCellData(true, sheet1, 2, 2);  // 1#GTG发电水平
            String gtg1Efficiency = this.getCellData(true, sheet1, 3, 2);     // 1#GTG效率（百分比）
            String gtg2PowerGenLevel = this.getCellData(true, sheet1, 2, 3);  // 2#GTG发电水平
            String gtg2Efficiency = this.getCellData(true, sheet1, 3, 3);     // 2#GTG效率（百分比）
            String gtg3PowerGenLevel = this.getCellData(true, sheet1, 2, 4);  // 3#GTG发电水平
            String gtg3Efficiency = this.getCellData(true, sheet1, 3, 4);     // 3#GTG效率（百分比）
            String stgPowerGenLevel = this.getCellData(true, sheet1, 2, 5);   // STG发电水平
            String stgEfficiency = this.getCellData(true, sheet1, 3, 5);      // STG效率（百分比）
            String totalPowerGen = this.getCellData(true, sheet1, 2, 6);      // 总发电量
            TElecDashboard.setGtg1PowerGenLevel(gtg1PowerGenLevel);
            TElecDashboard.setGtg1Efficiency(gtg1Efficiency);
            TElecDashboard.setGtg2PowerGenLevel(gtg2PowerGenLevel);
            TElecDashboard.setGtg2Efficiency(gtg2Efficiency);
            TElecDashboard.setGtg3PowerGenLevel(gtg3PowerGenLevel);
            TElecDashboard.setGtg3Efficiency(gtg3Efficiency);
            TElecDashboard.setStgPowerGenLevel(stgPowerGenLevel);
            TElecDashboard.setStgEfficiency(stgEfficiency);
            TElecDashboard.setTotalPowerGen(totalPowerGen);
            // 蒸汽
            String steamHhp = this.getCellData(true, sheet1, 6, 2);    // 蒸汽HHP
            String steamHp = this.getCellData(true, sheet1, 6, 3);     // 蒸汽HP
            String steamMp = this.getCellData(true, sheet1, 6, 4);     // 蒸汽MP
            String steamLp = this.getCellData(true, sheet1, 6, 5);     // 蒸汽LP
            TElecDashboard.setSteamHhp(steamHhp);
            TElecDashboard.setSteamHp(steamHp);
            TElecDashboard.setSteamMp(steamMp);
            TElecDashboard.setSteamLp(steamLp);
            // 天然气
            String gasRealTime = this.getCellData(true, sheet1, 9, 2);    // 瞬时量
            String gasLeft = this.getCellData(true, sheet1, 9, 3);        // 日剩余量
            String gasUsed = this.getCellData(true, sheet1, 9, 4);        // 日消耗量（实际）
            String gasPlan = this.getCellData(true, sheet1, 9, 5);        // 日消耗量（计划）
            String gasElec = this.getCellData(true, sheet1, 11, 2);       // 电厂
            String gasSynGas = this.getCellData(true, sheet1, 11, 3);     // 合成气
            String gasU2 = this.getCellData(true, sheet1, 11, 4);         // U2
            String gasStyrene = this.getCellData(true, sheet1, 11, 5);    // 苯乙烯
            TElecDashboard.setGasRealTime(gasRealTime);
            TElecDashboard.setGasLeft(gasLeft);
            TElecDashboard.setGasUsed(gasUsed);
            TElecDashboard.setGasPlan(gasPlan);
            TElecDashboard.setGasElec(gasElec);
            TElecDashboard.setGasSynGas(gasSynGas);
            TElecDashboard.setGasU2(gasU2);
            TElecDashboard.setGasStyrene(gasStyrene);
            // 电量
            String elecPowerGen = this.getCellData(true, sheet1, 14, 2);    // 昨日发电量
            String elecPowerSwitch = this.getCellData(true, sheet1, 14, 3); // 倒电量
            String elecUsed = this.getCellData(true, sheet1, 14, 4);        // 每日用电量
            String elecDiff = this.getCellData(true, sheet1, 14, 5);        // 每日峰谷差
            String elecBycUsed = this.getCellData(true, sheet1, 16, 2);     // BYC用电量
            String elecBocUsed = this.getCellData(true, sheet1, 16, 3);     // BOC用电量
            TElecDashboard.setElecPowerGen(elecPowerGen);
            TElecDashboard.setElecPowerSwitch(elecPowerSwitch);
            TElecDashboard.setElecUsed(elecUsed);
            TElecDashboard.setElecDiff(elecDiff);
            TElecDashboard.setElecBycUsed(elecBycUsed);
            TElecDashboard.setElecBocUsed(elecBocUsed);
            // 煤耗
            String carbonUsed = this.getCellData(true, sheet1, 19, 2);        // 每日煤耗量
            String carbonRealTime = this.getCellData(true, sheet1, 19, 3);    // 瞬时煤耗量
            TElecDashboard.setCarbonUsed(carbonUsed);
            TElecDashboard.setCarbonRealTime(carbonRealTime);
            // SUB
            String sub = this.getCellData(true, sheet1, 22, 2);               // SUB
            String subFurnaceLoad = this.getCellData(true, sheet1, 22, 3);    // SUB开工锅炉负荷（百分比）
            TElecDashboard.setSub(sub);
            TElecDashboard.setSubFurnaceLoad(subFurnaceLoad);
            //========================================电厂大屏数据第二页：蒸汽平衡=======================================
            // HHP
            String hhpPphhp = this.getCellData(true, sheet2, 2, 1);   // HHP PPHHP
            String hhpAaae = this.getCellData(true, sheet2, 2, 2);    // HHP AA/AE
            String hhpGaa = this.getCellData(true, sheet2, 2, 3);     // HHP GAA
            String hhpSyn = this.getCellData(true, sheet2, 2, 4);     // HHP SYN
            String hhpP3802 = this.getCellData(true, sheet2, 2, 5);   // HHP P3802
            TElecDashboard.setHhpPphhp(hhpPphhp);
            TElecDashboard.setHhpAaae(hhpAaae);
            TElecDashboard.setHhpGaa(hhpGaa);
            TElecDashboard.setHhpSyn(hhpSyn);
            TElecDashboard.setHhpP3802(hhpP3802);
            // HP
            String hpLpg = this.getCellData(true, sheet2, 5, 1);          // HP LPG（百分比）
            String hpSub = this.getCellData(true, sheet2, 5, 2);          // HP SUB（百分比）
            String hpNg = this.getCellData(true, sheet2, 5, 3);           // HP NG
            String hpJ1501 = this.getCellData(true, sheet2, 5, 4);        // HP J1501（百分比）
            String hpJ1504In = this.getCellData(true, sheet2, 5, 5);      // HP J1504入
            String hpJ1504Out = this.getCellData(true, sheet2, 5, 6);     // HP J1504出
            String hpUser = this.getCellData(true, sheet2, 5, 7);         // HP HP用户
            TElecDashboard.setHpLpg(hpLpg);
            TElecDashboard.setHpSub(hpSub);
            TElecDashboard.setHpNg(hpNg);
            TElecDashboard.setHpJ1501(hpJ1501);
            TElecDashboard.setHpJ1504In(hpJ1504In);
            TElecDashboard.setHpJ1504Out(hpJ1504Out);
            TElecDashboard.setHpUser(hpUser);
            // MP
            String mpNcipmp = this.getCellData(true, sheet2, 8, 1);   // MP NCI MP
            String mp150511 = this.getCellData(true, sheet2, 8, 2);   // MP 15051_2（百分比）
            String mp150512 = this.getCellData(true, sheet2, 8, 3);   // MP 15051_2（百分比）
            String mpPpmp = this.getCellData(true, sheet2, 8, 4);     // MP PPMP
            String mpP9801In = this.getCellData(true, sheet2, 8, 5);  // MP P9801入
            String mpP9801Out = this.getCellData(true, sheet2, 8, 6); // MP P9801出
            String mpJ1502 = this.getCellData(true, sheet2, 8, 7);    // MP J1502（百分比）
            String mpUser = this.getCellData(true, sheet2, 8, 8);     // MP MP用户
            TElecDashboard.setMpNcipMp(mpNcipmp);
            TElecDashboard.setMp150511(mp150511);
            TElecDashboard.setMp150512(mp150512);
            TElecDashboard.setMpPpMp(mpPpmp);
            TElecDashboard.setMpP9801In(mpP9801In);
            TElecDashboard.setMpP9801Out(mpP9801Out);
            TElecDashboard.setMpJ1502(mpJ1502);
            TElecDashboard.setMpUser(mpUser);
            // LP
            String lpPpLp = this.getCellData(true, sheet2, 11, 1);        // LP PP LP
            String lpEmpty = this.getCellData(true, sheet2, 11, 2);       // LP防空
            String lpMpLetdown = this.getCellData(true, sheet2, 11, 3);   // LP MP LETDOWN
            String lpJ1509 = this.getCellData(true, sheet2, 11, 4);       // LP J1509（百分比）
            String lpJ1503 = this.getCellData(true, sheet2, 11, 5);       // LP J1503（百分比）
            String lpLdpeTs = this.getCellData(true, sheet2, 11, 6);      // LP LDPE TS
            String lpLdpeDm = this.getCellData(true, sheet2, 11, 7);      // LP LDPE DM
            String lpUser = this.getCellData(true, sheet2, 11, 8);        // LP用户
            TElecDashboard.setLpPpLp(lpPpLp);
            TElecDashboard.setLpEmpty(lpEmpty);
            TElecDashboard.setLpMpLetdown(lpMpLetdown);
            TElecDashboard.setLpJ1509(lpJ1509);
            TElecDashboard.setLpJ1503(lpJ1503);
            TElecDashboard.setLpLdpeTs(lpLdpeTs);
            TElecDashboard.setLpLdpeDm(lpLdpeDm);
            TElecDashboard.setLpUser(lpUser);
            // BCC
            String bccSyn = this.getCellData(true, sheet2, 14, 1);    // BCC SYN
            String bccYpc = this.getCellData(true, sheet2, 14, 2);    // BCC YPC
            TElecDashboard.setBccSyn(bccSyn);
            TElecDashboard.setBccYpc(bccYpc);
            //========================================电厂大屏数据第三页：环保监控=======================================
            // HRSG
            String hrsg1SmokeConvert = this.getCellData(true, sheet3, 2, 2);  // HRSG 1# 烟尘折算
            String hrsg1So2Convert = this.getCellData(true, sheet3, 2, 3);    // HRSG 1# SO2 折算
            String hrsg1NoxConvert = this.getCellData(true, sheet3, 2, 4);    // HRSG 1# NOx 折算
            String hrsg2SmokeConvert = this.getCellData(true, sheet3, 3, 2);  // HRSG 2# 烟尘折算
            String hrsg2So2Convert = this.getCellData(true, sheet3, 3, 3);    // HRSG 2# SO2 折算
            String hrsg2NoxConvert = this.getCellData(true, sheet3, 3, 4);    // HRSG 2# NOx 折算
            String hrsg3SmokeConvert = this.getCellData(true, sheet3, 4, 2);  // HRSG 3# 烟尘折算
            String hrsg3So2Convert = this.getCellData(true, sheet3, 4, 3);    // HRSG 3# SO2 折算
            String hrsg3NoxConvert = this.getCellData(true, sheet3, 4, 4);    // HRSG 3# NOx 折算
            TElecDashboard.setHrsg1SmokeConvert(hrsg1SmokeConvert);
            TElecDashboard.setHrsg1So2Convert(hrsg1So2Convert);
            TElecDashboard.setHrsg1NoxConvert(hrsg1NoxConvert);
            TElecDashboard.setHrsg2SmokeConvert(hrsg2SmokeConvert);
            TElecDashboard.setHrsg2So2Convert(hrsg2So2Convert);
            TElecDashboard.setHrsg2NoxConvert(hrsg2NoxConvert);
            TElecDashboard.setHrsg3SmokeConvert(hrsg3SmokeConvert);
            TElecDashboard.setHrsg3So2Convert(hrsg3So2Convert);
            TElecDashboard.setHrsg3NoxConvert(hrsg3NoxConvert);
            // Rain Water
            String rainPh = this.getCellData(true, sheet3, 7, 2);   // 雨水 PH
            String rainCod = this.getCellData(true, sheet3, 7, 3);  // 雨水 COD
            TElecDashboard.setRainPh(rainPh);
            TElecDashboard.setRainCod(rainCod);
            // Waste Water
            String wastePh = this.getCellData(true, sheet3, 10, 2);     // 废水 PH
            String wasteCod = this.getCellData(true, sheet3, 10, 3);    // 废水 COD
            TElecDashboard.setWastePh(wastePh);
            TElecDashboard.setWasteCod(wasteCod);
            // 1# GTG
            String gtg45ha1 = this.getCellData(false, sheet3, 12, 3);   // 1#GTG 45HA1
            String gtg45ha2 = this.getCellData(false, sheet3, 13, 3);   // 1#GTG 45HA2
            String gtg45ha3 = this.getCellData(false, sheet3, 14, 3);   // 1#GTG 45HA3
            String gtg45ha4 = this.getCellData(false, sheet3, 15, 3);   // 1#GTG 45HA4
            String gtg45ha5 = this.getCellData(false, sheet3, 16, 3);   // 1#GTG 45HA5
            String gtg45ha6 = this.getCellData(false, sheet3, 17, 3);   // 1#GTG 45HA6
            String gtg45ha7 = this.getCellData(false, sheet3, 18, 3);   // 1#GTG 45HA7
            String gtg45ha8 = this.getCellData(false, sheet3, 19, 3);   // 1#GTG 45HA8
            String gtg45ha9 = this.getCellData(false, sheet3, 20, 3);   // 1#GTG 45HA9
            String gtg45ht1 = this.getCellData(false, sheet3, 21, 3);   // 1#GTG 45HT1
            String gtg45ht2 = this.getCellData(false, sheet3, 22, 3);   // 1#GTG 45HT2
            String gtg45ht3 = this.getCellData(false, sheet3, 23, 3);   // 1#GTG 45HT3
            String gtg45ht4 = this.getCellData(false, sheet3, 24, 3);   // 1#GTG 45HT4
            String gtg45ht5 = this.getCellData(false, sheet3, 25, 3);   // 1#GTG 45HT5
            String gtg45ht6 = this.getCellData(false, sheet3, 26, 3);   // 1#GTG 45HT6
            TElecDashboard.setGtg45ha1(gtg45ha1);
            TElecDashboard.setGtg45ha2(gtg45ha2);
            TElecDashboard.setGtg45ha3(gtg45ha3);
            TElecDashboard.setGtg45ha4(gtg45ha4);
            TElecDashboard.setGtg45ha5(gtg45ha5);
            TElecDashboard.setGtg45ha6(gtg45ha6);
            TElecDashboard.setGtg45ha7(gtg45ha7);
            TElecDashboard.setGtg45ha8(gtg45ha8);
            TElecDashboard.setGtg45ha9(gtg45ha9);
            TElecDashboard.setGtg45ht1(gtg45ht1);
            TElecDashboard.setGtg45ht2(gtg45ht2);
            TElecDashboard.setGtg45ht3(gtg45ht3);
            TElecDashboard.setGtg45ht4(gtg45ht4);
            TElecDashboard.setGtg45ht5(gtg45ht5);
            TElecDashboard.setGtg45ht6(gtg45ht6);
            // BP
            String qt61001 = this.getCellData(false, sheet3, 28, 3); // BP QT61001
            String qt61002 = this.getCellData(false, sheet3, 29, 3); // BP QT61002
            String qt61003 = this.getCellData(false, sheet3, 30, 3); // BP QT61003
            String qt61004 = this.getCellData(false, sheet3, 31, 3); // BP QT61004
            String qt61005 = this.getCellData(false, sheet3, 32, 3); // BP QT61005
            String qt61101 = this.getCellData(false, sheet3, 33, 3); // BP QT61101
            String qt61102 = this.getCellData(false, sheet3, 34, 3); // BP QT61102
            String qt61103 = this.getCellData(false, sheet3, 35, 3); // BP QT61103
            String qt61104 = this.getCellData(false, sheet3, 36, 3); // BP QT61104
            String qt61105 = this.getCellData(false, sheet3, 37, 3); // BP QT61105
            String qt76001 = this.getCellData(false, sheet3, 38, 3); // BP QT76001
            String qt76002 = this.getCellData(false, sheet3, 39, 3); // BP QT76002
            String qt76041 = this.getCellData(false, sheet3, 40, 3); // BP QT76041
            String qt80001 = this.getCellData(false, sheet3, 41, 3); // BP QT80001
            String qt80002 = this.getCellData(false, sheet3, 42, 3); // BP QT80002
            String qt80003 = this.getCellData(false, sheet3, 43, 3); // BP QT80003
            String qt91001 = this.getCellData(false, sheet3, 44, 3); // BP QT91001
            String qt91002 = this.getCellData(false, sheet3, 45, 3); // BP QT91002
            String qt91003 = this.getCellData(false, sheet3, 46, 3); // BP QT91003
            String qt91004 = this.getCellData(false, sheet3, 47, 3); // BP QT91004
            String qt91005 = this.getCellData(false, sheet3, 48, 3); // BP QT91005
            String qt91006 = this.getCellData(false, sheet3, 49, 3); // BP QT91006
            String qt91011 = this.getCellData(false, sheet3, 50, 3); // BP QT91011
            String qt91012 = this.getCellData(false, sheet3, 51, 3); // BP QT91012
            String qt91013 = this.getCellData(false, sheet3, 52, 3); // BP QT91013
            String at83001 = this.getCellData(false, sheet3, 53, 3); // BP AT83001
            String at83002 = this.getCellData(false, sheet3, 54, 3); // BP AT83002
            String at83003 = this.getCellData(false, sheet3, 55, 3); // BP AT83003
            String at83004 = this.getCellData(false, sheet3, 56, 3); // BP AT83004
            String qt12001 = this.getCellData(false, sheet3, 57, 3); // BP QT12001
            String qt12501 = this.getCellData(false, sheet3, 58, 3); // BP QT12501
            String qt12502 = this.getCellData(false, sheet3, 59, 3); // BP QT12502
            String qt22001 = this.getCellData(false, sheet3, 60, 3); // BP QT22001
            String qt22501 = this.getCellData(false, sheet3, 61, 3); // BP QT22501
            String qt22502 = this.getCellData(false, sheet3, 62, 3); // BP QT22502
            String qt32001 = this.getCellData(false, sheet3, 63, 3); // BP QT32001
            String qt32002 = this.getCellData(false, sheet3, 64, 3); // BP QT32002
            String qt32005 = this.getCellData(false, sheet3, 65, 3); // BP QT32005
            String qt32003 = this.getCellData(false, sheet3, 66, 3); // BP QT32003
            String qt32004 = this.getCellData(false, sheet3, 67, 3); // BP QT32004
            String ai82002 = this.getCellData(false, sheet3, 68, 3); // BP AI82002
            String ai82003 = this.getCellData(false, sheet3, 69, 3); // BP AI82003
            String ai82004 = this.getCellData(false, sheet3, 70, 3); // BP AI82004
            String ai82005 = this.getCellData(false, sheet3, 71, 3); // BP AI82005
            String ai82006 = this.getCellData(false, sheet3, 72, 3); // BP AI82006
            String ai82007 = this.getCellData(false, sheet3, 73, 3); // BP AI82007
            String ai82008 = this.getCellData(false, sheet3, 74, 3); // BP AI82008
            String ai82009 = this.getCellData(false, sheet3, 75, 3); // BP AI82009
            String ai82010 = this.getCellData(false, sheet3, 76, 3); // BP AI82010
            String ai82011 = this.getCellData(false, sheet3, 77, 3); // BP AI82011
            String ai82101 = this.getCellData(false, sheet3, 78, 3); // BP AI82101
            String ai82102 = this.getCellData(false, sheet3, 79, 3); // BP AI82102
            String ai82103 = this.getCellData(false, sheet3, 80, 3); // BP AI82103
            String ai82104 = this.getCellData(false, sheet3, 81, 3); // BP AI82104
            String ai82105 = this.getCellData(false, sheet3, 82, 3); // BP AI82105
            String ai82106 = this.getCellData(false, sheet3, 83, 3); // BP AI82106
            String ai82107 = this.getCellData(false, sheet3, 84, 3); // BP AI82107
            String ai82108 = this.getCellData(false, sheet3, 85, 3); // BP AI82108
            String ai82109 = this.getCellData(false, sheet3, 86, 3); // BP AI82109
            String ai82110 = this.getCellData(false, sheet3, 87, 3); // BP AI82110
            String ai82111 = this.getCellData(false, sheet3, 88, 3); // BP AI82111
            String ai82112 = this.getCellData(false, sheet3, 89, 3); // BP AI82112
            String ai82113 = this.getCellData(false, sheet3, 90, 3); // BP AI82113
            TElecDashboard.setQt61001(qt61001);
            TElecDashboard.setQt61002(qt61002);
            TElecDashboard.setQt61003(qt61003);
            TElecDashboard.setQt61004(qt61004);
            TElecDashboard.setQt61005(qt61005);
            TElecDashboard.setQt61101(qt61101);
            TElecDashboard.setQt61102(qt61102);
            TElecDashboard.setQt61103(qt61103);
            TElecDashboard.setQt61104(qt61104);
            TElecDashboard.setQt61105(qt61105);
            TElecDashboard.setQt76001(qt76001);
            TElecDashboard.setQt76002(qt76002);
            TElecDashboard.setQt76041(qt76041);
            TElecDashboard.setQt80001(qt80001);
            TElecDashboard.setQt80002(qt80002);
            TElecDashboard.setQt80003(qt80003);
            TElecDashboard.setQt91001(qt91001);
            TElecDashboard.setQt91002(qt91002);
            TElecDashboard.setQt91003(qt91003);
            TElecDashboard.setQt91004(qt91004);
            TElecDashboard.setQt91005(qt91005);
            TElecDashboard.setQt91006(qt91006);
            TElecDashboard.setQt91011(qt91011);
            TElecDashboard.setQt91012(qt91012);
            TElecDashboard.setQt91013(qt91013);
            TElecDashboard.setAt83001(at83001);
            TElecDashboard.setAt83002(at83002);
            TElecDashboard.setAt83003(at83003);
            TElecDashboard.setAt83004(at83004);
            TElecDashboard.setQt12001(qt12001);
            TElecDashboard.setQt12501(qt12501);
            TElecDashboard.setQt12502(qt12502);
            TElecDashboard.setQt22001(qt22001);
            TElecDashboard.setQt22501(qt22501);
            TElecDashboard.setQt22502(qt22502);
            TElecDashboard.setQt32001(qt32001);
            TElecDashboard.setQt32002(qt32002);
            TElecDashboard.setQt32005(qt32005);
            TElecDashboard.setQt32003(qt32003);
            TElecDashboard.setQt32004(qt32004);
            TElecDashboard.setAi82002(ai82002);
            TElecDashboard.setAi82003(ai82003);
            TElecDashboard.setAi82004(ai82004);
            TElecDashboard.setAi82005(ai82005);
            TElecDashboard.setAi82006(ai82006);
            TElecDashboard.setAi82007(ai82007);
            TElecDashboard.setAi82008(ai82008);
            TElecDashboard.setAi82009(ai82009);
            TElecDashboard.setAi82010(ai82010);
            TElecDashboard.setAi82011(ai82011);
            TElecDashboard.setAi82101(ai82101);
            TElecDashboard.setAi82102(ai82102);
            TElecDashboard.setAi82103(ai82103);
            TElecDashboard.setAi82104(ai82104);
            TElecDashboard.setAi82105(ai82105);
            TElecDashboard.setAi82106(ai82106);
            TElecDashboard.setAi82107(ai82107);
            TElecDashboard.setAi82108(ai82108);
            TElecDashboard.setAi82109(ai82109);
            TElecDashboard.setAi82110(ai82110);
            TElecDashboard.setAi82111(ai82111);
            TElecDashboard.setAi82112(ai82112);
            TElecDashboard.setAi82113(ai82113);
            // 1# HRSG
            String hrsg1Ai82201 = this.getCellData(false, sheet3, 92, 3);      // 1# HRSG AI82201
            String hrsg1Ai82202 = this.getCellData(false, sheet3, 93, 3);      // 1# HRSG AI82202
            String hrsg1Ai82203 = this.getCellData(false, sheet3, 94, 3);      // 1# HRSG AI82203
            String hrsg1Ai82204 = this.getCellData(false, sheet3, 95, 3);      // 1# HRSG AI82204
            String hrsg1Ai82205 = this.getCellData(false, sheet3, 96, 3);      // 1# HRSG AI82205
            String hrsg1Ai82206 = this.getCellData(false, sheet3, 97, 3);      // 1# HRSG AI82206
            String hrsg1Ai82207 = this.getCellData(false, sheet3, 98, 3);      // 1# HRSG AI82207
            String hrsg1Ai82208 = this.getCellData(false, sheet3, 99, 3);      // 1# HRSG AI82208
            String hrsg1Ai82209 = this.getCellData(false, sheet3, 100, 3);     // 1# HRSG AI82209
            String hrsg1Ai82210 = this.getCellData(false, sheet3, 101, 3);     // 1# HRSG AI82210
            String hrsg1Ai82211 = this.getCellData(false, sheet3, 102, 3);     // 1# HRSG AI82211
            String hrsg1Ai82212 = this.getCellData(false, sheet3, 103, 3);     // 1# HRSG AI82212
            String hrsg1Air12551 = this.getCellData(false, sheet3, 104,3);     // 1# HRSG AIR12551
            String hrsg1Air12552 = this.getCellData(false, sheet3, 105,3);     // 1# HRSG AIR12552
            String hrsg1Air12553 = this.getCellData(false, sheet3, 106,3);     // 1# HRSG AIR12553
            String hrsg1Air12554 = this.getCellData(false, sheet3, 107,3);     // 1# HRSG AIR12554
            String hrsg1Air12555 = this.getCellData(false, sheet3, 108,3);     // 1# HRSG AIR12555
            String hrsg1Air12556 = this.getCellData(false, sheet3, 109,3);     // 1# HRSG AIR12556
            String hrsg1Air12557 = this.getCellData(false, sheet3, 110,3);     // 1# HRSG AIR12557
            String hrsg1Air12558 = this.getCellData(false, sheet3, 111,3);     // 1# HRSG AIR12558
            TElecDashboard.setHrsg1Ai82201(hrsg1Ai82201);
            TElecDashboard.setHrsg1Ai82202(hrsg1Ai82202);
            TElecDashboard.setHrsg1Ai82203(hrsg1Ai82203);
            TElecDashboard.setHrsg1Ai82204(hrsg1Ai82204);
            TElecDashboard.setHrsg1Ai82205(hrsg1Ai82205);
            TElecDashboard.setHrsg1Ai82206(hrsg1Ai82206);
            TElecDashboard.setHrsg1Ai82207(hrsg1Ai82207);
            TElecDashboard.setHrsg1Ai82208(hrsg1Ai82208);
            TElecDashboard.setHrsg1Ai82209(hrsg1Ai82209);
            TElecDashboard.setHrsg1Ai82210(hrsg1Ai82210);
            TElecDashboard.setHrsg1Ai82211(hrsg1Ai82211);
            TElecDashboard.setHrsg1Ai82212(hrsg1Ai82212);
            TElecDashboard.setHrsg1Air12551(hrsg1Air12551);
            TElecDashboard.setHrsg1Air12552(hrsg1Air12552);
            TElecDashboard.setHrsg1Air12553(hrsg1Air12553);
            TElecDashboard.setHrsg1Air12554(hrsg1Air12554);
            TElecDashboard.setHrsg1Air12555(hrsg1Air12555);
            TElecDashboard.setHrsg1Air12556(hrsg1Air12556);
            TElecDashboard.setHrsg1Air12557(hrsg1Air12557);
            TElecDashboard.setHrsg1Air12558(hrsg1Air12558);
            // 2# HRSG
            String hrsg2Ai82301 = this.getCellData(false, sheet3, 113, 3);     // 2# HRSG AI82301
            String hrsg2Ai82302 = this.getCellData(false, sheet3, 114, 3);     // 2# HRSG AI82302
            String hrsg2Ai82303 = this.getCellData(false, sheet3, 115, 3);     // 2# HRSG AI82303
            String hrsg2Ai82304 = this.getCellData(false, sheet3, 116, 3);     // 2# HRSG AI82304
            String hrsg2Ai82305 = this.getCellData(false, sheet3, 117, 3);     // 2# HRSG AI82305
            String hrsg2Ai82306 = this.getCellData(false, sheet3, 118, 3);     // 2# HRSG AI82306
            String hrsg2Ai82307 = this.getCellData(false, sheet3, 119, 3);     // 2# HRSG AI82307
            String hrsg2Ai82308 = this.getCellData(false, sheet3, 120, 3);     // 2# HRSG AI82308
            String hrsg2Ai82309 = this.getCellData(false, sheet3, 121, 3);     // 2# HRSG AI82309
            String hrsg2Ai82310 = this.getCellData(false, sheet3, 122, 3);     // 2# HRSG AI82310
            String hrsg2Ai82311 = this.getCellData(false, sheet3, 123, 3);     // 2# HRSG AI82311
            String hrsg2Ai82312 = this.getCellData(false, sheet3, 124, 3);     // 2# HRSG AI82312
            String hrsg2Air22551 = this.getCellData(false, sheet3, 125, 3);    // 2# HRSG AIR22551
            String hrsg2Air22552 = this.getCellData(false, sheet3, 126, 3);    // 2# HRSG AIR22552
            String hrsg2Air22553 = this.getCellData(false, sheet3, 127, 3);    // 2# HRSG AIR22553
            String hrsg2Air22554 = this.getCellData(false, sheet3, 128, 3);    // 2# HRSG AIR22554
            String hrsg2Air22555 = this.getCellData(false, sheet3, 129, 3);    // 2# HRSG AIR22555
            String hrsg2Air22556 = this.getCellData(false, sheet3, 130, 3);    // 2# HRSG AIR22556
            String hrsg2Air22557 = this.getCellData(false, sheet3, 131, 3);    // 2# HRSG AIR22557
            String hrsg2Air22558 = this.getCellData(false, sheet3, 132, 3);    // 2# HRSG AIR22558
            String hrsg2Qi22240 = this.getCellData(false, sheet3, 133, 3);     // 2# HRSG QI22240
            String hrsg2Qi22241 = this.getCellData(false, sheet3, 134, 3);     // 2# HRSG QI22241
            String hrsg2Qi22242 = this.getCellData(false, sheet3, 135, 3);     // 2# HRSG QI22242
            TElecDashboard.setHrsg2Ai82301(hrsg2Ai82301);
            TElecDashboard.setHrsg2Ai82302(hrsg2Ai82302);
            TElecDashboard.setHrsg2Ai82303(hrsg2Ai82303);
            TElecDashboard.setHrsg2Ai82304(hrsg2Ai82304);
            TElecDashboard.setHrsg2Ai82305(hrsg2Ai82305);
            TElecDashboard.setHrsg2Ai82306(hrsg2Ai82306);
            TElecDashboard.setHrsg2Ai82307(hrsg2Ai82307);
            TElecDashboard.setHrsg2Ai82308(hrsg2Ai82308);
            TElecDashboard.setHrsg2Ai82309(hrsg2Ai82309);
            TElecDashboard.setHrsg2Ai82310(hrsg2Ai82310);
            TElecDashboard.setHrsg2Ai82311(hrsg2Ai82311);
            TElecDashboard.setHrsg2Ai82312(hrsg2Ai82312);
            TElecDashboard.setHrsg2Air22551(hrsg2Air22551);
            TElecDashboard.setHrsg2Air22552(hrsg2Air22552);
            TElecDashboard.setHrsg2Air22553(hrsg2Air22553);
            TElecDashboard.setHrsg2Air22554(hrsg2Air22554);
            TElecDashboard.setHrsg2Air22555(hrsg2Air22555);
            TElecDashboard.setHrsg2Air22556(hrsg2Air22556);
            TElecDashboard.setHrsg2Air22557(hrsg2Air22557);
            TElecDashboard.setHrsg2Air22558(hrsg2Air22558);
            TElecDashboard.setHrsg2Qi22240(hrsg2Qi22240);
            TElecDashboard.setHrsg2Qi22241(hrsg2Qi22241);
            TElecDashboard.setHrsg2Qi22242(hrsg2Qi22242);
            // 3# HRSG
            String hrsg3Ai82401 = this.getCellData(false, sheet3, 137, 3);;    // 3# HRSG AI82401
            String hrsg3Ai82402 = this.getCellData(false, sheet3, 138, 3);;    // 3# HRSG AI82402
            String hrsg3Ai82403 = this.getCellData(false, sheet3, 139, 3);;    // 3# HRSG AI82403
            String hrsg3Ai82404 = this.getCellData(false, sheet3, 140, 3);;    // 3# HRSG AI82404
            String hrsg3Ai82405 = this.getCellData(false, sheet3, 141, 3);;    // 3# HRSG AI82405
            String hrsg3Ai82406 = this.getCellData(false, sheet3, 142, 3);;    // 3# HRSG AI82406
            String hrsg3Ai82407 = this.getCellData(false, sheet3, 143, 3);;    // 3# HRSG AI82407
            String hrsg3Ai82408 = this.getCellData(false, sheet3, 144, 3);;    // 3# HRSG AI82408
            String hrsg3Ai82409 = this.getCellData(false, sheet3, 145, 3);;    // 3# HRSG AI82409
            String hrsg3Ai82410 = this.getCellData(false, sheet3, 146, 3);;    // 3# HRSG AI82410
            String hrsg3Ai82411 = this.getCellData(false, sheet3, 147, 3);;    // 3# HRSG AI82411
            String hrsg3Ai82412 = this.getCellData(false, sheet3, 148, 3);;    // 3# HRSG AI82412
            String hrsg3Air32551 = this.getCellData(false, sheet3, 149, 3);;   // 3# HRSG AIR32551
            String hrsg3Air32552 = this.getCellData(false, sheet3, 150, 3);;   // 3# HRSG AIR32552
            String hrsg3Air32553 = this.getCellData(false, sheet3, 151, 3);;   // 3# HRSG AIR32553
            String hrsg3Air32554 = this.getCellData(false, sheet3, 152, 3);;   // 3# HRSG AIR32554
            String hrsg3Air32555 = this.getCellData(false, sheet3, 153, 3);;   // 3# HRSG AIR32555
            String hrsg3Air32556 = this.getCellData(false, sheet3, 154, 3);;   // 3# HRSG AIR32556
            String hrsg3Air32557 = this.getCellData(false, sheet3, 155, 3);;   // 3# HRSG AIR32557
            String hrsg3Air32558 = this.getCellData(false, sheet3, 156, 3);;   // 3# HRSG AIR32558
            String hrsg3Qi32240 = this.getCellData(false, sheet3, 157, 3);;    // 3# HRSG QI32240
            String hrsg3Qi32241 = this.getCellData(false, sheet3, 158, 3);;    // 3# HRSG QI32241
            String hrsg3Qi32242 = this.getCellData(false, sheet3, 159, 3);;    // 3# HRSG QI32242
            TElecDashboard.setHrsg3Ai82401(hrsg3Ai82401);
            TElecDashboard.setHrsg3Ai82402(hrsg3Ai82402);
            TElecDashboard.setHrsg3Ai82403(hrsg3Ai82403);
            TElecDashboard.setHrsg3Ai82404(hrsg3Ai82404);
            TElecDashboard.setHrsg3Ai82405(hrsg3Ai82405);
            TElecDashboard.setHrsg3Ai82406(hrsg3Ai82406);
            TElecDashboard.setHrsg3Ai82407(hrsg3Ai82407);
            TElecDashboard.setHrsg3Ai82408(hrsg3Ai82408);
            TElecDashboard.setHrsg3Ai82409(hrsg3Ai82409);
            TElecDashboard.setHrsg3Ai82410(hrsg3Ai82410);
            TElecDashboard.setHrsg3Ai82411(hrsg3Ai82411);
            TElecDashboard.setHrsg3Ai82412(hrsg3Ai82412);
            TElecDashboard.setHrsg3Air32551(hrsg3Air32551);
            TElecDashboard.setHrsg3Air32552(hrsg3Air32552);
            TElecDashboard.setHrsg3Air32553(hrsg3Air32553);
            TElecDashboard.setHrsg3Air32554(hrsg3Air32554);
            TElecDashboard.setHrsg3Air32555(hrsg3Air32555);
            TElecDashboard.setHrsg3Air32556(hrsg3Air32556);
            TElecDashboard.setHrsg3Air32557(hrsg3Air32557);
            TElecDashboard.setHrsg3Air32558(hrsg3Air32558);
            TElecDashboard.setHrsg3Qi32240(hrsg3Qi32240);
            TElecDashboard.setHrsg3Qi32241(hrsg3Qi32241);
            TElecDashboard.setHrsg3Qi32242(hrsg3Qi32242);
            // 控制台打印电厂大屏数据
            System.out.println(TElecDashboard.toString());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                workbook.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return TElecDashboard;
    }

    /**
     * 抓取单元格数据
     * 如果单元格数据为空，返回空字符串
     *
     * @param sheet excel的sheet对象
     * @param rowIndex 行下标
     * @param cellIndex 列下标
     * @return 单元格数据
     */
    private String getCellData(boolean isString, Sheet sheet, int rowIndex, int cellIndex) {
        // 单元格数据
        String cellValue = "";
        try {
            // 根据行下标，获取行对象
            Row row = sheet.getRow(rowIndex);
            // 根据列下表，获取单元格对象，如果单元格的值为空，则返回null
            Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
            if (cell != null) {
                if (isString) {
                    // 设置单元格格式
                    cell.setCellType(CellType.STRING);
                } else {
                    // 设置单元格格式
                    cell.setCellType(CellType.FORMULA);
                }
                // 判断excel单元格格式
                if (cell.getCellType() == CellType.FORMULA) {
                    cellValue = null;
                } else {
                    // 获取单元格数据
                    String value = cell.getStringCellValue();
                    cellValue = value.equals("#NAME?") ? null : value;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return cellValue;
        }
    }
}
