package com.sifang.modules.customer.constant;

import com.sifang.modules.sunshine.SystemSetting.utils.StringUtil;

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

public class PartnerConstants {
    //资方
    public static final String PARTNER_ID_YX = "01";//越秀

    public static final String PARTNER_ID_GF = "03";//广发
    public static final String PARTNER_ID_HR = "04";//华融

    private static String[][] hrFiCode = {
            {"A1","身份证正反面照片","1"},
            {"A2","房产证明","1"},
            {"A4","银行卡照片","1"},
            {"A6","共签人关系证明材料","1"},
            {"B1","屋顶电站照片（无人机俯瞰照片）","-1"},
            {"B2","屋顶电站照片","1"},
            {"B3","房屋建筑照片","1"},
            {"B4","电站现场照片","3"},
            {"B5","组件铭牌照片","3"},
            {"B6","逆变器铭牌照片","3"},
            {"B7","水槽细节照片","3"},
            {"B8","落水管照片","3"},
            {"B9","项目施工验收单（自检单）","3"},
            {"B10","假梁-斜梁方向","3"},
            {"B11","其他补充照片","3"},
            {"D1","发电截图","3"},
            {"D2","购售电合同","3"},
            {"D8","屋顶租赁合同","3"},
            {"D14","项目公司备案证","3"},
            {"D15","并网后其他材料","3"}
    };

    private static Map<String, String> hrFileCode = new HashMap<>();
    public static Map<String, String> getHrFileCode() {
        if (hrFileCode.isEmpty()) {
            for (String[] code : hrFiCode) {
                hrFileCode.put(code[0],code[1]);
            }
        }
        return hrFileCode;
    }

    public static String queryHrFileCode(String val) {
        String key = "";
        for (Map.Entry<String, String> m :getHrFileCode().entrySet())  {
            if (m.getValue().equals(val)) {
                key = m.getKey();
                break;
            }
        }
        return key;
    }

    private static List<HRFileCode> hrFileCodeList = new ArrayList<>();
    private static List<HRFileCode> hrFileCodeBWList = new ArrayList<>();

    public static List<HRFileCode> getHrFileCodeList(String step) {
        List<HRFileCode> list;
        if ("3".equals(step)) {
            list = hrFileCodeBWList;
        }else {
            list = hrFileCodeList;
        }
        if (list.isEmpty()) {
            for (String[] code : hrFiCode) {
                if (!"3".equals(step)){
                    if (StringUtil.isNotBlank(step) && !step.equals(code[2])) {
                        continue;
                    }
                }
                HRFileCode hc = new HRFileCode();
                hc.setCode(code[0]);
                hc.setName(code[1]);
                hc.setStep(code[2]);
                list.add(hc);
            }
        }
        return list;
    }


    //华融 附件编码转化为文字描述
    public static List<String> hrFileCodeToRemarks(String codes) {
        String[] fileCodeList = codes.split(";");
        List<String> remarks = new ArrayList<>();
        for (String fileCode : fileCodeList) {
            remarks.add(getHrFileCode().get(fileCode));
        }
        return remarks;
    }

}
