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

import com.jeeplus.common.utils.excel.ImportExcel;
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 PROJECTNAME = "架空线路";
    public static final String SHEET_FBFXJJ = "分部分项工程量清单计价表";
    public static final String SHEET_HZB = "工程项目竣工结算汇总表";
    public static final String SHEET_CSB = "措施项目清单计价表（一）";
    public static final String SHEET_QTFY = "其他项目清单计价表";
    public static final String SHEET_GFQD = "规费项目清单计价表";
    public static final String SHEET_GCHZ = "架空线路工程费用汇总表";
    public static final String SHEET_FBRCG = "发包人采购材料设备计价表";
    public static final String SHEET_FBRCG1 = "发包人采购材料(设备)计价表";
    public static final String SHEET_CBRCG = "承包人采购设备计价表";
    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 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 MX_TSF = "1 土石方";
    public static final String MX_GZW = "2 构筑物";
    public static final String MX_FZGC = "3 辅助工程";
    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= "电缆防火";
    public static final String MX_TSJSY = "5 调试及试验";
    public static final String MX_DLJC = "6 电缆监测（控）系统";

    public static final String RATIO_RGTC = "人工调差系数";
    public static final String RATIO_CLTC = "材料调差系数";
    public static final String RATIO_JXTC = "机械调差系数";
    public static final String RATIO_CCRGTC = "拆除人工调差系数";
    public static final String RATIO_CCCLTC = "拆除材料调差系数";
    public static final String RATIO_CCJXTC = "拆除机械调差系数";

    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_HJ = "合计";
    public static final String QT_XJ = "小计";
    public static final String BZZSSL = "补增值税税率调整差额";
    public static final String KJJGCC = "扣减甲供材超供材料费";
    public static final String KJYJSG = "扣夜间施工增加费";
    public static final String GCJS = "工程结算价";
    public static final String TBJG = "竣工结算价合计";
    public static final String TBJG1 = "投标报价";
    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 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 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 JS_FBFX="分部分项工程费";
    public static final String JS_CBRF="承包人采购设备费";
    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_BZZS="补增值税税率调整差额";
    public static final String JS_KJJG="扣减甲供材超供材料费";
    public static final String JS_GCJS="工程结算价";
    public static final String JS_REASON="数据核验正确";



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

    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[] 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 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.equals(CS_LS)){
                lsRate = importExcel.getDouble(i+1,3);
            }
            if(type.equals(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 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;
     }

    /**
     * 获取电缆安装工程措施费率
     */
    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;
            }
        }
        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.equals(CS_LS)){
                lsRate = importExcel.getDouble(i+1,3);
            }
            if(type.equals(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[] 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.equals(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;
    }

    /**
     *电缆建筑获取规费率
     */
    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.equals(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;
            }
        }
        double totalRate = 0.00;
        double wxzyRate = 0.00;
        for (int i = azRow; i < lastRow; i++) {
            String type = importExcel.getValue(i + 1, 1);
            if (type.equals(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;
    }

    /**
     * 获取其他费用
     */
    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;
    }

    /**
     * 获取发包人安装费
     * @param importExcel
     * @return
     */
    public static double getFbrAzFee(ImportExcel importExcel){
        int lastRow = importExcel.getLastDataRowNum();
        double d = 0.00;
        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;
    }


    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.equals(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(BashInfo.TBJG) || type.equals(BashInfo.GCJS)){
                gcjs = importExcel.getDouble(i+1,2);
            }
        }
        return  gcjs;

    }
    /*
     获取《工程项目竣工结算汇总表》匹配数据
    */
    public static Map<String,Object[]> getCompletionWorks(ImportExcel importExcel){
        Map<String,Object[]> map  = new LinkedHashMap<String, Object[]>();
        int lastDataRowNum =  importExcel.getLastDataRowNum();
        String key="";
        double val=0.0;
        String text = "";
        Object[] objects;
        for (int i = 2; i < lastDataRowNum; i++) {
            objects = new Object[2];
            key =  importExcel.getValue(i+1,1);
            if(key.contains(BashInfo.JS_SJ)){
                key=BashInfo.JS_SJ;
            }
            switch (key){
                case BashInfo.JS_FBFX:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_CBRF:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_CSXM:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_QTXM:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_GF:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_SJ:

                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_FBRF:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_JGJS:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_BZZS:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_KJJG:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
                case BashInfo.JS_GCJS:
                    val = importExcel.getDouble(i+1,2);
                    text=importExcel.getValue(i+1,3);
                    objects[0] = val;
                    objects[1] = text;
                    map.put(key, objects);
                    break;
            }
        }
        return  map;
    }
}
