package com.jeeplus.modules.sg.overheadline.util;

import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.sg.overheadline.entity.JkxlAdjustFee;
import com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee;
import com.jeeplus.modules.sg.overheadline.entity.Settlement;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class BashInfo {
    public static final String PROJECT_JKXL = "1"; //架空线路项目类型编号
    public static final String PROJECT_DLXL = "2"; //电缆线路项目类型编号
    public static final String PROJECT_BDZ = "3"; //变电站项目类型编号

    public static final String BZDWBS = "20000000";
    public static final String JKXLWBS = "30000000";
    public static final String DLWBS = "40000000";

    public static final String PROJECTNAME = "架空线路";
    public static final String SHEET_FBFXJJ = "分部分项工程量清单计价表";
    public static final String SHEET_HZB = "工程项目竣工结算汇总表";
    public static final String SHEET_HZB1 = "工程项目投标报价汇总表";
    public static final String SHEET_HZB2 = "工程项目最高投标限价汇总表";
    public static final String SHEET_HZB3 = "工程项目结算价汇总表";
    public static final String SHEET_CSB = "措施项目清单计价表（一）";
    public static final String SHEET_CSB1 = "措施项目清单计价表一";
    public static final String SHEET_CSB2 = "措施项目清单计价表（二）";
    public static final String SHEET_QTFY = "其他项目清单计价表";
    public static final String SHEET_GFQD = "规费项目清单计价表";
    public static final String SHEET_GCHZ = "架空线路工程费用汇总表";
    public static final String SHEET_GCHZ1 = "架空线路工程结算汇总表";
    public static final String SHEET_FBRCG = "发包人采购材料设备计价表";
    public static final String SHEET_FBRCG1 = "发包人采购材料(设备)计价表";
    public static final String SHEET_FBRCG2 = "发包人采购材料计价表";
    public static final String SHEET_ZBRCG = "招标人采购材料(设备)计价表";
    public static final String SHEET_ZBRCG1 = "招标人采购材料设备计价表";
    public static final String SHEET_CBRCG = "承包人采购设备计价表";
    public static final String SHEET_TBRCG = "投标人采购设备计价表";
    public static final String SHEET_JZFBFXJJ = "建筑分部分项工程量清单计价表";
    public static final String SHEET_AZFBFXJJ = "安装分部分项工程量清单计价表";
    public static final String SHEET_JZHZB = "电缆线路建筑工程费用汇总表";
    public static final String SHEET_HZHZB = "电缆线路安装工程费用汇总表";
    public static final String SHEET_ZYRG = "主要工日价格表";

    public static final String JCGC = "1 基础工程";
    public static final String GTGC = "2 杆塔工程";
    public static final String JDGC = "3 接地工程";
    public static final String JXGC = "4 架线工程";
    public static final String FJAZGC = "5 附件安装工程";
    public static final String FZGC = "6 辅助工程";
    public static final String CS = "7 措施项目";

    public static final String MX_TSF = "1 土石方";
    public static final String MX_GZW = "2 构筑物";
    public static final String MX_FZGC = "3 辅助工程";
    public static final String MX_CSXM = "4 措施项目";
    public static final String MX_DLQ = "1 电缆桥、支架制作安装";
    public static final String MX_DLFS = "2 电缆敷设";
    public static final String MX_DLFJ = "3 电缆附件";
    public static final String MX_DLFH= "4 电缆防火";
    public static final String MX_TSJSY = "5 调试及试验";
    public static final String MX_DLJC = "6 电缆监测（控）系统";


    public static final String MX_FHGL = "1 复合光缆线路";
    public static final String MX_JKGL = "2 架空光缆/音频电缆线路";
    public static final String MX_JMGL = "3 直埋光缆/音频电缆线路";
    public static final String MX_GDGL= "4 管道光缆线路／音频电缆线路";


    public static final String CS_LS = "临时设施费";
    public static final String CS_AQWM = "安全文明施工费";
    public static final String GF_WXZY = "危险作业意外伤害保险费";
    public static final String QT_SGCDZY = "施工场地租用费";
    public static final String QT_ZBDL = "招标代理";
    public static final String QT_CBRSB = "承包人采购设备费";
    public static final String QT_HJ = "合计";
    public static final String QT_XJ = "小计";
    public static final String CSXM2 = "措施项目（二）";
    public static final String GCJS = "工程结算价";
    public static final String TBJG = "竣工结算价合计";
    public static final String TBJG1 = "投标报价";
    public static final String TBJG2 = "最终结算价";
    public static final String TBJG3 = "最高投标限价";
    public static final String TBJG4 = "最终工程造价";
    public static final String TBJG5 = "下浮后造价";
    public static final String CE = "差额";
    public static final String CS_JZ = "建筑措施项目";
    public static final String CS_AZ = "安装措施项目";
    public static final String GF_AZ = "安装规费项目";
    public static final String GF_JZ = "建筑规费项目";
    public static final String FBR_JZ = "建筑";
    public static final String FBR_AZ = "安装";



    public static final String DLJZ = "电缆建筑";
    public static final String DLAZ = "电缆安装";

    public static final String HZ_JCGC = "基础工程";
    public static final String HZ_GTGC = "杆塔工程";
    public static final String HZ_JDGC = "接地工程";
    public static final String HZ_JXGC = "架线工程";
    public static final String HZ_FJAZGC = "附件安装工程";
    public static final String HZ_FZ = "辅助工程";
    public static final String HZ_CH = "措施项目";


    public static final String HZ_TSF = "土石方";
    public static final String HZ_GZW = "构筑物";
    public static final String HZ_FZGC= "辅助工程";
    public static final String HZ_DLQ = "电缆桥、支架制作安装";
    public static final String HZ_DLFS = "电缆敷设";
    public static final String HZ_DLFJ = "电缆附件";
    public static final String HZ_DLFH= "电缆防火";
    public static final String HZ_TSJSY = "调试及试验";
    public static final String HZ_DLJC = "电缆监测（控）系统";
    public static final String HZ_JZGC = "建筑工程";
    public static final String HZ_JZGCF = "建筑工程费";
    public static final String HZ_AZGC = "安装工程";
    public static final String HZ_AZGCF = "安装工程费";

    public static final String HZ_FHGL = "复合光缆线路";
    public static final String HZ_JKGL = "架空光缆/音频电缆线路";
    public static final String HZ_JMGL = "直埋光缆/音频电缆线路";
    public static final String HZ_GDGL= "管道光缆线路/音频电缆线路";


    public static final String TZ_RGF = "人工费";
    public static final String TZ_CBRCG = "承包分采购";
    public static final String TZ_FBRCG = "发包人采购";
    public static final String TZ_JX = "机械费";
    public static final String TZ_CSF1 = "措施费-1";
    public static final String TZ_CSF2 = "措施费-2";
    public static final String TZ_CSF3 = "措施费二";
    public static final String TZ_QTF = "其他费";
    public static final String TZ_GF = "规费";
    public static final String TZ_SF = "税费";
    public static final String TZ_ZJGC = "直接工程费";


    public static final String JS_FBFX="分部分项工程费";
    public static final String JS_CBRF="承包人采购设备费";
    public static final String JS_TBRF="投标人采购设备费";
    public static final String JS_CSXM="措施项目费";
    public static final String JS_QTXM="其他项目费";
    public static final String JS_GF="规费";
    public static final String JS_SJ="税金";
    public static final String JS_FBRF="发包人采购材料费";
    public static final String JS_JGJS="竣工结算价合计";
    public static final String JS_GCJS="工程结算价";

    public static final String INVALIDFORMAT = "文件格式错误";
    public static final String NUMBERERROR = "结算书数据异常";



    //架空线路主体模块WBSID
    public static final String[] WBSIDS = {"39100000","39200000","39300000","39400000","39500000","39600000"};
    public static final String[] WBSOTHIDS = {"34120000","34220000"};

    public static final String[] HZ_ALL = {HZ_JCGC,HZ_GTGC,HZ_JDGC,HZ_JXGC,HZ_FJAZGC,HZ_FZ};
    public static final String[] MX_ALL ={JCGC,GTGC,JDGC,JXGC,FJAZGC,FZGC};


    //电缆项目
    public static final String[] JZWBSIDS = {"49110000","49120000","49130000"};
    public static final String[] AZWBSIDS = {"49310000","49320000","49330000","49340000","49350000","49360000"};
    public static final String[] DLOTHIDS = {"44120000","44220000"};
    public static final String[] HZ_JZ = {HZ_TSF,HZ_GZW,HZ_FZGC};
    public static final String[] HZ_AZ = {HZ_DLQ,HZ_DLFS,HZ_DLFJ,HZ_DLFH,HZ_TSJSY,HZ_DLJC};
    public static final String[] MX_JZ = {MX_TSF,MX_GZW,MX_FZGC};
    public static final String[] MX_AZ = {MX_DLQ,MX_DLFS,MX_DLFJ,MX_DLFH,MX_TSJSY,MX_DLJC};


    //通信线路
    public static final String[] JZTXWBSIDS = {"69110000","69120000"};
    public static final String[] AZTXWBSIDS = {"69310000","69320000","69330000","69340000"};
    public static final String[] TXHZ_JZ = {HZ_TSF,HZ_GZW};
    public static final String[] TXHZ_AZ = {HZ_FHGL,HZ_JKGL,HZ_JMGL,HZ_GDGL};
    public static final String[] TXMX_JZ = {MX_TSF,MX_GZW};
    public static final String[] TXMX_AZ = {MX_FHGL,MX_JKGL,MX_JMGL,MX_GDGL};



    /**
     *获取架线工程措施费率
     */
    public static double[] getCsRate(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double lsRate = 0.00;
        double aqRate = 0.00;
        double totalRate = 0.00;
        for(int i=2;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.contains(CS_LS)){
                lsRate = importExcel.getDouble(i+1,3);
            }
            if(type.contains(CS_AQWM)){
                aqRate = importExcel.getDouble(i+1,3);
            }
            totalRate += importExcel.getDouble(i+1,3);
        }
        double[] rate = new double[2];
        rate[0] = (lsRate+aqRate)/100;
        rate[1] = (totalRate-lsRate-aqRate)/100;
        return  rate;
    }

    /**
     * 获取架线工程措施费除两项和
     */
    public static double getCsFee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double lsRate = 0.00;
        double aqRate = 0.00;
        double totalRate = 0.00;
        for(int i=2;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            String type1 = importExcel.getValue(i+1,0);
            if(type.contains(CS_LS)){
                lsRate = importExcel.getDouble(i+1,4);
            }
            if(type.contains(CS_AQWM)){
                aqRate = importExcel.getDouble(i+1,4);
            }
            if(type1.equals(QT_HJ)){
                totalRate = importExcel.getDouble(i+1,4);
            }
        }
        double d = totalRate-lsRate-aqRate;
        return d;
    }

    /**
     * 获取建筑工程措施费率
     * 代码逻辑：获取“安装措施项目”前的费率和
     * 这里默认如果建筑安装都有建筑排前面
     */
     public static double getJzRate(ImportExcel importExcel){
         int lastRow = importExcel.getLastDataRowNum();
         double rate = 0.00;
         for(int i=2;i<lastRow;i++){
             String type = importExcel.getValue(i+1,1);
             if(type.equals(CS_AZ)){
                 break;
             }
             rate += importExcel.getDouble(i+1,3);
         }
       return rate/100;
     }

    /**
     * 架空线路规费合计
     * @param importExcel
     * @return
     */
    public static double getJkCs(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        List list = new ArrayList();
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,0);
            list.add(type);
        }
        if(!list.contains(QT_HJ)){
            for(int i=0;i<lastRow;i++){
                String type = importExcel.getValue(i+1,0);
                if(type.equals("")){
                    continue;
                }
                if(type.equals(QT_XJ)){
                    d = importExcel.getDouble(i+1,4);
                }
            }
        }else {
            for (int i = 0; i < lastRow; i++) {
                String type = importExcel.getValue(i + 1, 0);
                if (type.equals("")) {
                    continue;
                }
                if (type.equals(QT_HJ)) {
                    d = importExcel.getDouble(i + 1, 4);
                    break;
                }
            }
        }
        return d;
    }

    /**
     * 架空线路规费合计
     * @param importExcel
     * @return
     */
    public static double getJkGf(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        List list = new ArrayList();
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,0);
            list.add(type);
        }
        if(!list.contains(QT_HJ)){
            for(int i=0;i<lastRow;i++){
                String type = importExcel.getValue(i+1,0);
                if(type.equals("")){
                    continue;
                }
                if(type.equals(QT_XJ)){
                    d = importExcel.getDouble(i+1,4);
                }
            }
        }else {
            for (int i = 0; i < lastRow; i++) {
                String type = importExcel.getValue(i + 1, 0);
                if (type.equals("")) {
                    continue;
                }
                if (type.equals(QT_HJ)) {
                    d = importExcel.getDouble(i + 1, 4);
                    break;
                }
            }
        }
        return d;
    }

    /**
     * 获取安装工程措施费率
     * 代码逻辑：从“安装措施费”行往下找所有费率，将“临时设施费”和“安全文明施工费”费率放一起，剩余费率放一起
     */
    public static double[] getAzRate(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        int azRow = 0;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals(CS_AZ)){
                azRow = i+1;
                break;
            }
        }
        if(azRow == 0){
            return new double[2];
        }
        double lsRate = 0.00;
        double aqRate = 0.00;
        double totalRate = 0.00;
        for(int i=azRow;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.contains(CS_LS)){
                lsRate = importExcel.getDouble(i+1,3);
            }
            if(type.contains(CS_AQWM)){
                aqRate = importExcel.getDouble(i+1,3);
            }
            totalRate += importExcel.getDouble(i+1,3);
        }
        double[] rate = new double[2];
        rate[0] = (lsRate+aqRate)/100;
        rate[1] = (totalRate-lsRate-aqRate)/100;
        return  rate;
    }

    /**
     * 获取电缆建筑措施费
     */
    public static double[] getJzCsfee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        int azRow = 0;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals(CS_AZ)){
                azRow = i+1;
                break;
            }
        }
        double lsRate = 0.00;
        double ls = 0.00;
        double aqRate = 0.00;
        double aq = 0.00;
        double totalRate = 0.00;
        for(int i=0;i<azRow+1;i++){
            String type = importExcel.getValue(i+1,1);
            String type1 = importExcel.getValue(i+1,0);
            if(type.contains(CS_LS)){
                lsRate = importExcel.getDouble(i+1,3);
                ls = importExcel.getDouble(i+1,4);
            }
            if(type.contains(CS_AQWM)){
                aqRate = importExcel.getDouble(i+1,3);
                aq = importExcel.getDouble(i+1,4);
            }
            if(type1.equals(QT_XJ)){
                totalRate = importExcel.getDouble(i+1,4);
            }
        }
        double[] d = new double[2];
         d[0] = (lsRate + aqRate)/100;
         d[1] = totalRate - ls - aq;
        return d;
    }

    /**
     * 获取安装措施费中除去“临时设施费”、“安全文明施工费”以外金额合计
     * 代码逻辑：找到“安装措施项目”，往下找“临时设施费“、”安全文明施工费“、”小计“，
     * 返回“小计” - “临时设施费” - “安全文明施工费”结果
     */
    public static double getAzCsfee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        int azRow = 0;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals(CS_AZ)){
                azRow = i+1;
                break;
            }
        }
        if(azRow == 0){
            return 0.00;
        }
        double lsRate = 0.00;
        double aqRate = 0.00;
        double totalRate = 0.00;
        for(int i=azRow;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            String type1 = importExcel.getValue(i+1,0);
            if(type.contains(CS_LS)){
                lsRate = importExcel.getDouble(i+1,4);
            }
            if(type.contains(CS_AQWM)){
                aqRate = importExcel.getDouble(i+1,4);
            }
            if(type1.equals(QT_XJ)){
                totalRate = importExcel.getDouble(i+1,4);
            }
        }
        double d = totalRate - lsRate - aqRate;
        return d;
    }



    /**
     *架空线路获取规费率
     */
    public static double[] getGfRate(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        double totalRate = 0.00;
        double wxzyRate = 0.00;
        for (int i = 2; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 1);
            if (type.contains(GF_WXZY)) {
                wxzyRate = importExcel.getDouble(i + 1, 3);
            }
            if (!importExcel.getValue(i + 1, 2).equals("")) {
                totalRate += importExcel.getDouble(i + 1, 3);
            }
        }
        double[] rate = new double[2];
        rate[0] = wxzyRate / 100;
        rate[1] = (totalRate - wxzyRate) / 100;
        return rate;
    }

    /**
     *获取建筑部分规费费率
     *代码逻辑：查看《规费项目清单计价表》页签B列，在“安装规费项目”行前进行操作（这样写代码即默认页签中建筑相关信息在安装信息之前）
     *查找“危险作业意外伤害保险费”，同时查找所有C列不为空的费率累加
     * 返回数组，[0]为“危险作业意外伤害保险费”费率，[1]为剩余费率和
     */
    public static double[] getJzGfRate(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        double totalRate = 0.00;
        double wxzyRate = 0.00;
        for (int i = 2; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 1);
            if (type.contains(GF_WXZY)) {
                wxzyRate = importExcel.getDouble(i + 1, 3);
            }
            if (!importExcel.getValue(i + 1, 2).equals("")) {
                totalRate += importExcel.getDouble(i + 1, 3);
            }
            if(type.equals(GF_AZ)){
                break;
            }
        }
        double[] rate = new double[2];
        rate[0] = wxzyRate / 100;
        rate[1] = (totalRate - wxzyRate) / 100;
        return rate;
    }

    /**
     *电缆安装获取规费率
     */
    public static double[] getAzGfRate(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        int azRow = 0;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals(GF_AZ)){
                azRow = i+1;
                break;
            }
        }
        if(azRow == 0){
            return new double[2];
        }
        double totalRate = 0.00;
        double wxzyRate = 0.00;
        for (int i = azRow; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 1);
            if (type.contains(GF_WXZY)) {
                wxzyRate = importExcel.getDouble(i + 1, 3);
            }
            if (!importExcel.getValue(i + 1, 2).equals("")) {
                totalRate += importExcel.getDouble(i + 1, 3);
            }
        }
        double[] rate = new double[2];
        rate[0] = wxzyRate / 100;
        rate[1] = (totalRate - wxzyRate) / 100;
        return rate;
    }

    /**
     * 获取建筑部分规费
     * 代码逻辑：查看《规费项目清单计价表》页签B列，如果没有找到值为“建筑规费项目”的单元格，返回0，
     * 若找到返回A列第一个小计值
     * @param importExcel
     * @return
     */
    public static double getJzGf(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        List list = new ArrayList();
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            list.add(type);
        }
        if(!list.contains(GF_JZ)){
            return d;
        }
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,0);
            if(type.equals("")){
                continue;
            }
            if(type.equals(QT_XJ)){
                d = importExcel.getDouble(i+1,4);
                break;
            }
        }
        return d;
    }

    /**
     *获取安装部分规费
     * 代码逻辑：查看《规费项目清单计价表》页签B列，如果没有找到值为“安装规费项目”的单元格，返回0，
     * 若找到返回A列最后一个小计值
     */
    public static double getAzGf(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        int azRow = 0;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals(GF_AZ)){
                azRow = i+1;
                break;
            }
        }
        if(azRow == 0){
            return 0.00;
        }
        double totalRate = 0.00;
        for (int i = azRow; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 0);
            if (type.equals(QT_XJ)) {
                totalRate = importExcel.getDouble(i + 1, 4);
            }
        }

        return totalRate;
    }

    /**
     * 建筑措施费合计
     * 代码逻辑：查找第二列文字，如果存在有值为“建筑措施项目”，则判断存在建筑措施费，获取第一个“小计”的值
     * @param importExcel
     * @return
     */
    public static double getJzCs(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        List list = new ArrayList();
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            list.add(type);
        }
        if(!list.contains(CS_JZ)){
            return d;
        }
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,0);
            if(type.equals("")){
                continue;
            }
            if(type.equals(QT_XJ)){
                d = importExcel.getDouble(i+1,4);
                break;
            }
        }
        return d;
    }

    /**
     *安装措施费合计
     * 查找第二列“安装措施项目”，如果存在，从该行往下找，找到最后一个“小计”行的值
     * 这里默认安装措施费出现在文档后面
     */
    public static double getAzCs(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        int azRow = 0;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals(CS_AZ)){
                azRow = i+1;
                break;
            }
        }
        if(azRow == 0){
            return 0.00;
        }
        double totalRate = 0.00;
        for (int i = azRow; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 0);
            if (type.equals(QT_XJ)) {
                totalRate = importExcel.getDouble(i + 1, 4);
            }
        }

        return totalRate;
    }

    /**
     * 获取其他费用
     * 代码逻辑：查看《其他费用清单计价表》页签B列，查找“施工场地租用费”、“招标代理”，查找A列“合计“金额
     * 获得其他费用列表，其中[0]为“施工场地租用费”，[1]为“招标代理”费用，[2]为剩余其他费用
     */
    public static double[] getQtFees(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        double cdFree = 0.00;
        double zbFree = 0.00;
        double totalFree = 0.00;
        for(int i=2;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            String type1 = importExcel.getValue(i+1,0);
            if(type.equals(QT_SGCDZY)){
                cdFree = importExcel.getDouble(i+1,2);
                continue;
            }
            if(type.contains(QT_ZBDL)){
                zbFree = importExcel.getDouble(i+1,2);
                continue;
            }
            if(type1.equals(QT_HJ)){
                totalFree = importExcel.getDouble(i+1,2);
                continue;
            }
        }
        double[] rate = new double[3];
        rate[0] = cdFree;
        rate[1] = zbFree;
        rate[2] = totalFree-cdFree-zbFree;
        return  rate;
    }


    /**
     * 获取建筑部分承包人采购设备费
     * 代码逻辑：查看承包人采购设备计价表页签B列，如果没有找到值为“建筑”的单元格，返回0，
     * 若找到返回A列第一个小计值
     * @param importExcel
     * @return
     */
    public static double getFbrJzFee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        List list = new ArrayList();
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            list.add(type);
        }
        if(!list.contains(FBR_JZ)){
            return d;
        }
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,0);
            if(type.equals("")){
                continue;
            }
            if(type.equals(QT_XJ)){
                d = importExcel.getDouble(i+1,6);
                break;
            }
        }
        return d;
    }


    public static  boolean getFlag(double[] totalFee,double[] zjgcFee){
        for(int i=0;i<totalFee.length;i++){
            if(totalFee[i]<zjgcFee[i]){
                return false;
            }
        }
        return true;
    }

//    public static  boolean getFlag(double[] totalFee,double[] zjgcFee){
//        for(int i=0;i<totalFee.length;i++){
//            if(totalFee[i]<zjgcFee[i]){
//                return true;
//            }
//        }
//        return false;
//    }

    /**
     * 获取安装部分承包人采购设备费
     * 代码逻辑：查看承包人采购设备计价表页签B列，如果没有找到值为“安装”的单元格，返回0，
     * 若找到返回A列最后一个小计值
     * @param importExcel
     * @return
     */
    public static double getFbrAzFee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        List list = new ArrayList();
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            list.add(type);
        }
        if(!list.contains(FBR_AZ)){
            return d;
        }
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,0);
            if(type.equals("")){
                continue;
            }
            if(type.equals(QT_XJ)){
                d = importExcel.getDouble(i+1,6);
            }
        }
        return d;
    }

    /**
     * 获取建筑安全文明措施费和费率
     * 代码逻辑：这里默认是存在建筑工程，读取“安全文明施工费”的第3列，第4列金额返回
     * @param importExcel
     * @return
     */
    public static double[] getAqwfJzFee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        double e = 0.00;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals("")){
                continue;
            }
            if(type.contains(CS_AQWM)){
                d = importExcel.getDouble(i+1,3);
                e = importExcel.getDouble(i+1,4);
                break;
            }
        }
        double[] r = new double[2];
        r[0] = d;
        r[1] = e;
        return r;
    }

    /**
     * 安装安全文明措施费
     * @param importExcel
     * @return
     */
    public static double[] getAqwfAzFee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        double e = 0.00;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals("")){
                continue;
            }
            if(type.contains(CS_AQWM)){
                d = importExcel.getDouble(i+1,3);
                e = importExcel.getDouble(i+1,4);
            }
        }
        double[] r = new double[2];
        r[0] = d;
        r[1] = e;
        return r;
    }

    /**
     * 获取工程结算价
     * 代码逻辑：获取最后一个包含竣工结算价相关文字的行的金额
     */
    public static double getGcjsFee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double gcjs = 0.00;
        for(int i=0;i<lastRow;i++){
            String type = importExcel.getValue(i+1,1);
            if(type.equals(TBJG) || type.equals(GCJS) || type.equals(TBJG1) || type.equals(TBJG2) || type.equals(TBJG3)|| type.equals(TBJG4)|| type.equals(TBJG5)){
                gcjs = importExcel.getDouble(i+1,2);
            }
        }
        return  gcjs;

    }

    /**
     * 获取未识别费用
     * 代码逻辑：在税金和竣工结算价中间查找未识别费用
     * 税金以第一个找到为准，后面还有可能有补税什么的
     * 竣工结算价名称不尽相同，我们以最后一个找到为准
     */
    public static List<JkxlAdjustFee> getWsbFee(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        int row1 = 0;
        int row2 = 0;
        List<JkxlAdjustFee> jkxlAdjustFees = new ArrayList<>();
        JkxlAdjustFee jkxlAdjustFee = null;
        for (int i = 0; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 1);
            if (type.contains(JS_SJ)) {
                row1 = i+1;
                break;
            }
        }
        for (int i = 0; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 1);
            if (type.contains("竣工") || type.contains("合计") || type.contains("结算") ||type.contains("投标") || type.contains("工程造价") || type.contains("最高") || type.contains("下浮后造价")) {
                row2 = i+1;
            }
        }
        for (int j = row1; j < row2; j++) {
            String type = importExcel.getValue(j + 1, 1);
            String index = importExcel.getValue(j + 1, 0);
            if(type.equals("")){
                continue;
            }
            if (!type.contains("投标")  && !type.contains("结算") && !type.contains("合计") && !type.contains("发包人") && !type.contains("竣工") && !type.contains("招标人") && !type.contains("税金")&& !type.contains("税额") && !type.contains("工程造价")&& !type.contains("下浮后造价") || type.contains("投标下浮")) {
                 jkxlAdjustFee = new JkxlAdjustFee();
                 double fee = Math.abs(importExcel.getDouble(j+1,2));
                 jkxlAdjustFee.setType(type);
                 jkxlAdjustFee.setFee(fee);
                 jkxlAdjustFees.add(jkxlAdjustFee);
            }
        }
        return jkxlAdjustFees;
    }


    /**
     * 获取补税额
     * 代码逻辑：在税金后读取包含“税金”或“税额”行的金额
     */
    public static double getBtex(ImportExcel importExcel) {
        int lastRow = importExcel.getLastDataRowNum();
        int row = 0;
        double d = 0.00;
        for (int i = 0; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 1);
            if (type.contains(JS_SJ)) {
                row = i+1;
                break;
            }
        }
        for (int j = row; j < lastRow; j++) {
            String type = importExcel.getValue(j + 1, 1);
            if(type.equals("")){
                continue;
            }
            if (type.contains("税金") || type.contains("税额")) {
                d = importExcel.getDouble(j+1,2);
            }
        }
        return d;
    }

    public static boolean getFlag(double d ,double e){
        boolean f = false;
        if(d != 0.00 || e != 0.00){
            f = true;
        }
        return f;
    }


}
