package com.jeeplus.modules.sg.financial.erpcredit.util;

import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.sg.audit.information.entity.Information;
import com.jeeplus.modules.sg.financial.erpcredit.entity.ErpAccount;
import com.jeeplus.modules.sg.financial.erpcredit.entity.ErpCredit;
import com.jeeplus.modules.sg.financial.expense.entity.Expense;
import com.jeeplus.modules.sg.financial.settlement.entity.MaintainData;
import io.swagger.models.auth.In;

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

/**
 * 费用入账工具类
 */
public class CostAccountUnits {

    public static final String BEFORE_2020 = "1";//项目年份判断：2020年以前项目
    public static final String AFTER_2020 = "0";//2020及以后项目

    public static final String OVER_PAY_AMOUNT = "1"; //应付金额<实付金额 时费用状态
    public static final String PAY_LESS_AMOUNT = "2"; //应付金额>实付金额 时费用状态

    public static final String OVER_PAY_LIST_KEY = "OVERPAY";//多付钱项目列表
    public static final String PAY_LESS_LIST_KEY = "PAYLESS";//少付钱项目列表


    /**
     * 验证项目的费用入账情况，即应付金额与实付金额的比较。然后返回一个异常情况的map
     * @param erpCredits
     * @param expenses  费用入账列表
     * @param informationList 甲供材列表
     * @param maintainDatas  概预算列表
     * @return
     */
    public static Map<String,List<ErpCredit>> getJudgeMap(List<ErpCredit> erpCredits, List<Expense> expenses,List<Information> informationList,List<MaintainData> maintainDatas){
        //根据费用入账批次号判断项目时间为2020前后，并赋予状态
        judgeTime(expenses);
        //获得几个以项目id为key的map
        Map<String,Expense> expenseMap = new HashMap<>();
        Map<String,Information> informationMap = new HashMap<>();
        Map<String,MaintainData> maintainDataMap = new HashMap<>();
        for(Expense expense:expenses){
            expenseMap.put(expense.getProjectId(),expense);
        }
        for(Information information:informationList){
            informationMap.put(information.getProjectId(),information);
        }
        for(MaintainData data:maintainDatas){
            maintainDataMap.put(data.getProjectId(),data);
        }
        //判断设计费、监理费付款情况
        judgeDesignSupervisionAmount(erpCredits,expenseMap,maintainDataMap);
        //判断施工费付款情况
        judgeConstructionAmount(erpCredits,expenseMap,informationMap);
        //整理有付款情况问题的list
        Map<String,List<ErpCredit>> map = new HashMap<>();
        List<ErpCredit> overpayList = new ArrayList<>();
        List<ErpCredit> paylessList = new ArrayList<>();
        for(ErpCredit credit:erpCredits){
            if(OVER_PAY_AMOUNT.equals(credit.getDesignStatus())||OVER_PAY_AMOUNT.equals(credit.getSupervisorStatus())||
                    OVER_PAY_AMOUNT.equals(credit.getConstructionStatus())){
                overpayList.add(credit);
            }
            if(PAY_LESS_AMOUNT.equals(credit.getDesignStatus())||PAY_LESS_AMOUNT.equals(credit.getSupervisorStatus())||
                    PAY_LESS_AMOUNT.equals(credit.getConstructionStatus())){
                paylessList.add(credit);
            }
        }
        map.put(OVER_PAY_LIST_KEY,overpayList);
        map.put(PAY_LESS_LIST_KEY,paylessList);
        return map;
    }

    /**
     * 判断设计费、监理费付款情况
     * @param creditList
     * @param expenseMap
     * @param dataMap
     */
    private static void judgeDesignSupervisionAmount(List<ErpCredit> creditList,Map<String,Expense> expenseMap,Map<String,MaintainData> dataMap){
        for(ErpCredit credit:creditList){
            String projectId = credit.getItemId();
            Expense expense = expenseMap.get(projectId);
            MaintainData maintainData = dataMap.get(projectId);

            Double investment = Double.valueOf(maintainData.getInvestment());//发文总投资
            //概算总金额 概预算中金额相加除10000取两位小数
            Double estimateTotal = DoubleUtil.round2(DoubleUtil.add(maintainData.getDesignFee(),maintainData.getBuildingFee(),maintainData.getEquipmentFee(),
                    maintainData.getMaterialFee(),maintainData.getInstallFee(),maintainData.getSupervisionFee(),maintainData.getPreliminaryWorkFee(),
                    maintainData.getDamages(),maintainData.getManagementFee())/10000);
            double texRate = 1.06; //设计费(监理费)含税应付金额--》不含税应付金额 需要乘以的系数，2020后为1.06，以前为/1.06
            if(BEFORE_2020.equals(expense.getStatus())){
                texRate = 1/1.06;
            }
            double designFee = maintainData.getDesignFee();//概算中设计费
            double designCost = expense.getDesignCost();//设计费合同折扣
            double designTypicalCost = expense.getDesignTypeicalCost();//设计费典型折扣
            double documentDesignFee = expense.getDocumentDesignCost();//发文中设计费金额（不含税）
            double designFeePayable; //设计费应付金额

            double supervisionFee = maintainData.getSupervisionFee();//概算中监理费
            double supervisionCost = expense.getSupervisionCost();//监理费合同折扣
            double supervisionTypicalCost = expense.getSupervisionTypeicalCost();//监理费典型折扣
            double documentSupervisionFee = expense.getDocumentSupervisionCost();//发文中监理费金额（不含税）
            double supervisionFeePayable;//监理费应付金额

            //判断概算总金额与发文总投资相差是否超过0.01
            if(Math.abs(DoubleUtil.sub(investment,estimateTotal))<=0.01){
                designFeePayable = designFee*designCost*designTypicalCost*texRate;
                supervisionFeePayable = supervisionFee*supervisionCost*supervisionTypicalCost*texRate;
            }else{
                designFeePayable = documentDesignFee*designCost*designTypicalCost*texRate;
                supervisionFeePayable = documentSupervisionFee*supervisionCost*supervisionTypicalCost*texRate;
            }
            credit.setDesignFeePayable(DoubleUtil.round2(designFeePayable));
            credit.setSupervisorFeePayable(DoubleUtil.round2(supervisionFeePayable));

            Double actuallyPaidDesign = credit.getOtherDesignFee();//实付设计费
            if(Math.abs(DoubleUtil.sub(actuallyPaidDesign,designFeePayable))<=0.01){

            }else if(actuallyPaidDesign>designFeePayable){
                credit.setDesignStatus(OVER_PAY_AMOUNT);
            }else{
                credit.setDesignStatus(PAY_LESS_AMOUNT);
            }
            Double actuallyPaidSupervision = credit.getOtherSupervisorFee();
            if(Math.abs(DoubleUtil.sub(actuallyPaidSupervision,supervisionFeePayable))<=0.01){

            }else if(actuallyPaidSupervision>supervisionFeePayable){
                credit.setSupervisorStatus(OVER_PAY_AMOUNT);
            }else{
                credit.setSupervisorStatus(PAY_LESS_AMOUNT);
            }

        }
    }

    /**
     * 判断施工费付款情况
     * @param creditList
     * @param expenseMap
     * @param informationMap
     */
    private static void judgeConstructionAmount(List<ErpCredit> creditList,Map<String,Expense> expenseMap,Map<String,Information> informationMap){
        for(ErpCredit credit:creditList){
            String projectId = credit.getItemId();
            Expense expense = expenseMap.get(projectId);
            Information info = informationMap.get(projectId);

//            Double settlementPrice = info.getSettlementPrice();//结算审定施工费
//            Double constructionCost = expense.getConstructionCost();//施工费合同折扣
//            Double construnctionPayable = settlementPrice*constructionCost/1.09;//施工费应付金额（不含税）

            Double construnctionPayable = Double.parseDouble(info.getSuggestedAmount());

            credit.setConstructionFeePayable(DoubleUtil.round2(construnctionPayable));

            Double actuallyPaid = credit.getConsTotalFee();//实付施工费费
            if(Math.abs(DoubleUtil.sub(actuallyPaid,construnctionPayable))<=0.01){

            }else if(actuallyPaid>construnctionPayable){
                credit.setConstructionStatus(OVER_PAY_AMOUNT);
            }else{
                credit.setConstructionStatus(PAY_LESS_AMOUNT);
            }
        }

    }
    /**
     * 判断项目年份，并设置状态
     * 判断逻辑：项目批次号前4位，如果为数字前大于2020，则为2020年以后， 剩余为以前
     * @param expenseList
     */
    private static void judgeTime(List<Expense> expenseList){
        if(expenseList==null||expenseList.size()==0){
            return;
        }
        for(Expense expense:expenseList){
            expense.setStatus(BEFORE_2020);
            String projectBatch = expense.getProjectBatch();
            if(StringUtils.isNotBlank(projectBatch)&&projectBatch.length()>=4){
                String yearStr = projectBatch.substring(0,4);
                try {
                    Integer year = Integer.parseInt(yearStr);
                    if(year>=2020){
                        expense.setStatus(AFTER_2020);
                    }
                } catch (NumberFormatException e) {
                }
            }
        }
    }


//    public static List<Expense> getQCExpense(List<ErpCredit> erpCredits,List<Expense> expenses){
//        List<Expense> expenseList = new ArrayList<Expense>();
//        boolean flag = false;
//        for (Expense expense:expenses){
//            flag = false;
//            for (ErpCredit erpCredit1:erpCredits){
//                if (expense.getProjectId().equals(erpCredit1.getItemId())){
//                    flag = true;
//                    break;
//                }
//            }
//            if (flag){
//                expenseList.add(expense);
//            }
//        }
//        return getOneErpListJudge(expenseList);
//    }



    //得到 2020年项目
//    public static List<Expense> getOneErpListJudge(List<Expense> expenses){
//        String projectBatch = "";
////        List<Expense> expensesList = new ArrayList<Expense>();
//        boolean yearJudgment = false;
//        for (Expense expense:expenses){
//            projectBatch = expense.getProjectBatch();
//            if (null!=projectBatch&&!"".equals(projectBatch)){
//               yearJudgment = getYearJudgment(projectBatch);
//               if (yearJudgment){
//                  expense.setStatus("0");
//               }else {
//                   expense.setStatus("1");
//               }
//            }
//        }
//        return expenses;
//    }
//
//    //判断项目时间
//    public static boolean getYearJudgment(String projectBatch){
//        Integer yearNumber = 2020;
//        if (projectBatch.length()>=4){
//            projectBatch = projectBatch.substring(0,4);
//            yearNumber = new Integer(projectBatch);
//            if (yearNumber>=2020){
//                return true;
//            }
//        }
//        return false;
//    }


    //2020之前的项目费用入账判断(无问题)设计费 实际付款金额
//    public static Map<String,List<ErpCredit>> getJudgeDesign(List<ErpCredit> erpCredits, List<Expense> expenses){
//        Map<String,List<ErpCredit>> designMap = new HashMap<String, List<ErpCredit>>();
//        //若应付金额（不含税价）=实付金额（不含税价）,差异若在0.01则忽略不计，则费用入账核实无问题 集合
//        List<ErpCredit> erpCredits1 = new ArrayList<ErpCredit>();
//        //若应付金额（不含税价）>实付金额（不含税价）,需要进入人工判断，若人工判断通过，则费用入账核实无问题，若人工判断不通过则费用入账核实存在问题；
//        List<ErpCredit> erpCredits2 = new ArrayList<ErpCredit>();
//        //若应付金额（不含税价）<实付金额（不含税价）,需要导出差异情况，同时费用入账核实存在问题
//        List<ErpCredit> erpCredits3 = new ArrayList<ErpCredit>();
//        Double otherDesignFee = 0.0;//=ERP明细账生成数据中设计费入账金额(不含税价)
//        for (ErpCredit erpCredit:erpCredits){
//            otherDesignFee = erpCredit.getOtherDesignFee();
//            for (Expense expense:expenses){
//                if (erpCredit.getItemId().equals(expense.getProjectId())){
//                    erpCredit.setDesignFeePayable(expense.getDesignFeePayable());//设计费应付金额
//                    //若应付金额（不含税价）=实付金额（不含税价）,差异若在0.01则忽略不计，则费用入账核实无问题
//                    if (expense.getDesignFeePayable()>= otherDesignFee-0.01 && expense.getDesignFeePayable()<= otherDesignFee+0.01){
//                        erpCredits1.add(erpCredit);//无问题
//                    }else if (expense.getDesignFeePayable()>otherDesignFee){
//                        erpCredit.setDesignStatus("2");
//                        erpCredit.setDesignFeePayable(expense.getDesignFeePayable());
//                        erpCredits2.add(erpCredit);//存在问题
//                    }else {
//                        erpCredit.setDesignStatus("1");
//                        erpCredit.setDesignFeePayable(expense.getDesignFeePayable());
//                        erpCredits3.add(erpCredit);//<存在问题
//                    }
//                    break;
//                }
//            }
//        }
//        designMap.put("designNoProblem",erpCredits1);//无问题
//        designMap.put("designThanProblem",erpCredits2);//人工判断
//        designMap.put("designYesProblem",erpCredits3);//存在问题导出
//        return designMap;
//    }
//
//    //项目费用入账判断设计费 设计费应付金额
//    public static List<Expense> getJudgeDesignActual(List<Expense> expenses, List<MaintainData> maintainDatas){
//        double investment = 0.0;    //发文总投资
//        double estimateTotal = 0.0;//概算总金额
//        double designFee = 0.0;//概预算中设计费设计费
//        double designCost = 0.0;//设计费合同则扣
//        double designTypeicalCost =0.0;//设计费典型设计折扣
//        double documentDesignCost = 0.0;//发文中设计费金额（不含税）
//        double designFeePayable = 0.0;//设计费应付金额 不含税价
//        List<Expense> expenseList = new ArrayList<Expense>();
//        for (Expense expense:expenses){
//            designCost = expense.getDesignCost();
//            designTypeicalCost = expense.getDesignTypeicalCost();
//            documentDesignCost = expense.getDocumentDesignCost();//发文中设计费金额（不含税）
//            for (MaintainData maintainData:maintainDatas){
//                //项目定义号相同
//               if (expense.getProjectId().equals(maintainData.getProjectId())){
//                   investment = Double.valueOf(maintainData.getInvestment());//发文总投资
//                   estimateTotal = maintainData.getDesignFee()+maintainData.getBuildingFee()+maintainData.getEquipmentFee()+maintainData.getMaterialFee()+maintainData
//                           .getInstallFee()+maintainData.getSupervisionFee()+maintainData.getPreliminaryWorkFee()+maintainData.getDamages()+maintainData.getManagementFee();
//                   estimateTotal = estimateTotal/10000;//发文总金额（----------------------------------------）
//                    if (expense.getStatus().equals("1")){//2020年之前项目
//                        if (investment<=estimateTotal+0.01 && investment>=estimateTotal-0.01){
//                            designFee = maintainData.getDesignFee();//该预算中设计费
//                            designFeePayable = designFee*designCost*designTypeicalCost/1.06;//不含税价
//                        }else {
//                            designFeePayable =  documentDesignCost*designCost*designTypeicalCost/1.06;//不换税价
//                        }
//                    }else {//2020年之后项目
//                        if (investment<=estimateTotal+0.01 && investment>=estimateTotal-0.01){
//                            designFee = maintainData.getDesignFee();//该预算中设计费
//                            designFeePayable = designFee*designCost*designTypeicalCost*1.06;
//                        }else {
//                            designFeePayable =  documentDesignCost*designCost*designTypeicalCost*1.06;
//                        }
//                    }
//                   expense.setDesignFeePayable(designFeePayable);//设计费应付金额
//                   expenseList.add(expense);
//                   break;
//               }
//            }
//        }
//        return expenses;
//    }
//
//
//    //2020之前的项目费用入账判断(无问题)监理费 实际付款金额
//    public static Map<String,List<ErpCredit>> getJudgeSupervisorFee(List<ErpCredit> erpCredits, List<Expense> expenses){
//        Map<String,List<ErpCredit>> supervisorFeeMap = new HashMap<String, List<ErpCredit>>();
//        //若应付金额（不含税价）=实付金额（不含税价）,差异若在0.01则忽略不计，则费用入账核实无问题 集合
//        List<ErpCredit> erpCredits1 = new ArrayList<ErpCredit>();
//        //若应付金额（不含税价）>实付金额（不含税价）,需要进入人工判断，若人工判断通过，则费用入账核实无问题，若人工判断不通过则费用入账核实存在问题；
//        List<ErpCredit> erpCredits2 = new ArrayList<ErpCredit>();
//        //若应付金额（不含税价）<实付金额（不含税价）,需要导出差异情况，同时费用入账核实存在问题
//        List<ErpCredit> erpCredits3 = new ArrayList<ErpCredit>();
//        Double otherSupervisorFee = 0.0;//=ERP明细账生成数据中监理费入账金额(不含税价)
//        for (ErpCredit erpCredit:erpCredits){
//            otherSupervisorFee = erpCredit.getOtherSupervisorFee();
//            for (Expense expense:expenses){
//                if (erpCredit.getItemId().equals(expense.getProjectId())){
//                    erpCredit.setSupervisorFeePayable(expense.getSupervisorFeePayable());//监理费
//                    //若应付金额（不含税价）=实付金额（不含税价）,差异若在0.01则忽略不计，则费用入账核实无问题
//                    if (expense.getSupervisorFeePayable()>= otherSupervisorFee-0.01 && expense.getSupervisorFeePayable()<= otherSupervisorFee+0.01){
//                        erpCredits1.add(erpCredit);//无问题
//                    }else if (expense.getSupervisorFeePayable()>otherSupervisorFee){
//                        erpCredit.setSupervisorStatus("2");
//                        erpCredit.setSupervisorFeePayable(expense.getSupervisorFeePayable());
//                        erpCredits2.add(erpCredit);//存在问题
//                    }else {
//                        erpCredit.setSupervisorStatus("1");
//                        erpCredit.setSupervisorFeePayable(expense.getSupervisorFeePayable());
//                        erpCredits3.add(erpCredit);//<存在问题
//                    }
//                    break;
//                }
//            }
//        }
//        supervisorFeeMap.put("supervisorNoProblem",erpCredits1);//无问题
//        supervisorFeeMap.put("supervisorThanProblem",erpCredits2);//人工判断
//        supervisorFeeMap.put("supervisorYesProblem",erpCredits3);//存在问题导出
//        return supervisorFeeMap;
//    }
//
//    //项目费用入账判断监理费 监理费应付金额
//    public static List<Expense> getJudgeSupervisorFeeActual(List<Expense> expenses, List<MaintainData> maintainDatas){
//        double investment = 0.0;    //发文总投资
//        double estimateTotal = 0.0;//概算总金额
//        double supervisionFee = 0.0;//概预算中监理费
//        double supervisionCost = 0.0;//监理费合同则扣
//        double supervisionTypeicalCost =0.0;//监理费典型设计折扣
//        double documentSupervisionCost = 0.0;//发文中监理费金额（不含税）
//        double supervisorFeePayable = 0.0;//监理费应付金额
//        List<Expense> expenseList = new ArrayList<Expense>();
//        for (Expense expense:expenses){
//            supervisionCost = expense.getSupervisionCost();//监理费合同则扣
//            supervisionTypeicalCost = expense.getSupervisionTypeicalCost();//监理费典型设计折扣
//            documentSupervisionCost = expense.getDocumentSupervisionCost();//监理费应付金额 不含税价
//            for (MaintainData maintainData:maintainDatas){
//                //项目定义号相同
//                if (expense.getProjectId().equals(maintainData.getProjectId())){
//                    investment = Double.valueOf(maintainData.getInvestment());//发文总投资
//                    estimateTotal = maintainData.getDesignFee()+maintainData.getBuildingFee()+maintainData.getEquipmentFee()+maintainData.getMaterialFee()+maintainData
//                            .getInstallFee()+maintainData.getSupervisionFee()+maintainData.getPreliminaryWorkFee()+maintainData.getDamages()+maintainData.getManagementFee();
//                    estimateTotal = estimateTotal/10000;//发文总金额（----------------------------------------）
//                    if (expense.getStatus().equals("1")){//2020年之前项目
//                        if (investment<=estimateTotal+0.01 && investment>=estimateTotal-0.01){
//                            supervisionFee = maintainData.getSupervisionFee();//概预算中监理费金额
//                            supervisorFeePayable = supervisionFee*supervisionCost*supervisionTypeicalCost/1.06;//不含税价
//                        }else {
//                            supervisorFeePayable =  documentSupervisionCost*supervisionCost*supervisionTypeicalCost/1.06;//不换税价
//                        }
//                    }else {//2020年之后项目
//                        if (investment<=estimateTotal+0.01 && investment>=estimateTotal-0.01){
//                            supervisionFee = maintainData.getSupervisionFee();//概预算中监理费金额
//                            supervisorFeePayable = supervisionFee*supervisionCost*supervisionTypeicalCost*1.06;
//                        }else {
//                            supervisorFeePayable =  documentSupervisionCost*supervisionCost*supervisionTypeicalCost*1.06;
//                        }
//                    }
//                    expense.setSupervisorFeePayable(supervisorFeePayable);//设计费应付金额
//                    expenseList.add(expense);
//                    break;
//                }
//            }
//        }
//        return expenses;
//    }
//
//    //2020之前的项目费用入账判断(无问题)施工费 实际付款金额
//    public static Map<String,List<ErpCredit>> getJudgeConsFee(List<ErpCredit> erpCredits, List<Expense> expenses){
//        Map<String,List<ErpCredit>> consFeeMap = new HashMap<String, List<ErpCredit>>();
//        //若应付金额（不含税价）=实付金额（不含税价）,差异若在0.01则忽略不计，则费用入账核实无问题 集合
//        List<ErpCredit> erpCredits1 = new ArrayList<ErpCredit>();
//        //若应付金额（不含税价）>实付金额（不含税价）,需要进入人工判断，若人工判断通过，则费用入账核实无问题，若人工判断不通过则费用入账核实存在问题；
//        List<ErpCredit> erpCredits2 = new ArrayList<ErpCredit>();
//        //若应付金额（不含税价）<实付金额（不含税价）,需要导出差异情况，同时费用入账核实存在问题
//        List<ErpCredit> erpCredits3 = new ArrayList<ErpCredit>();
//        Double consTotalFee = 0.0;//=ERP明细账生成数据中监理费入账金额(不含税价)
//        for (ErpCredit erpCredit:erpCredits){
//            consTotalFee = erpCredit.getConsTotalFee();
//            for (Expense expense:expenses){
//                if (erpCredit.getItemId().equals(expense.getProjectId())){
//                    //施工费
//                    erpCredit.setConstructionFeePayable(expense.getConstructionFeePayable());
//                    //若应付金额（不含税价）=实付金额（不含税价）,差异若在0.01则忽略不计，则费用入账核实无问题
//                    if (expense.getConstructionFeePayable()>= consTotalFee-0.01 && expense.getSupervisorFeePayable()<= consTotalFee+0.01){
//                        erpCredits1.add(erpCredit);//无问题
//                    }else if (expense.getConstructionFeePayable()>consTotalFee){
//                        erpCredit.setConstructionStatus("2");
//                        erpCredit.setConstructionFeePayable(expense.getConstructionFeePayable());
//                        erpCredits2.add(erpCredit);//存在问题
//                    }else {
//                        erpCredit.setConstructionStatus("1");
//                        erpCredit.setConstructionFeePayable(expense.getConstructionFeePayable());
//                        erpCredits3.add(erpCredit);//<存在问题
//                    }
//                    break;
//                }
//            }
//        }
//        consFeeMap.put("consNoProblem",erpCredits1);//无问题
//        consFeeMap.put("consThanProblem",erpCredits2);//人工判断
//        consFeeMap.put("consYesProblem",erpCredits3);//存在问题导出
//        return consFeeMap;
//    }
//
//    //项目费用入账判断施工费 施工费应付金额
//    public static List<Expense> getJudgeConsFeeActual(List<Information> informationList,List<Expense> expenses){
//        Double constructionFeePayable=0.0;//施工费应付金额
//        Double constructionCost = 0.0; //施工费合同折扣
//        Double settlementPrice = 1.0;//结算审定施工费金额（含税价）
//        for (Expense expense:expenses){
//            settlementPrice = 1.0;
//            constructionFeePayable=0.0;
//            constructionCost = expense.getConstructionCost();//施工合同折扣
//            for (Information information:informationList){
//                if (expense.getProjectId().equals(information.getProjectId())){
//                    //结算审定施工费金额（含税价）如果不为空则赋值
//                    if (null!=information.getSettlementPrice()){
//                        settlementPrice = information.getSettlementPrice();
//                    }
//                    //2020年前的项目
//                    if (expense.getStatus().equals("1")){
//                        constructionFeePayable = constructionCost*settlementPrice/1.09;
//                    }else {//2020后的项目
//                        constructionFeePayable = constructionCost*settlementPrice/1.09;
//                    }
//                    expense.setConstructionFeePayable(constructionFeePayable);
//                    break;
//                }
//            }
//        }
//        return expenses;
//    }

    //方法整合
//    public static Map<String,List<ErpCredit>> getJudgeEnterAccount(List<ErpCredit> erpCredits, List<Expense> expenses,List<Information> informationList,List<MaintainData> maintainDatas){
//        Map<String,List<ErpCredit>> listMap = new HashMap<String, List<ErpCredit>>();
//        //设计费
//        //项目费用入账判断设计费 设计费应付金额
//        List<Expense> judgeDesignActual = getJudgeDesignActual(expenses, maintainDatas);
//        //项目费用入账判断(无问题)设计费 实际付款金额
//        Map<String, List<ErpCredit>> judgeDesign = getJudgeDesign(erpCredits, judgeDesignActual);
//        //监理费
//        List<Expense> judgeSupervisorFeeActual = getJudgeSupervisorFeeActual(expenses, maintainDatas);
//        Map<String, List<ErpCredit>> judgeSupervisorFee = getJudgeSupervisorFee(erpCredits, judgeSupervisorFeeActual);
//        //施工费
//        List<Expense> judgeConsFeeActual = getJudgeConsFeeActual(informationList, expenses);
//        Map<String, List<ErpCredit>> judgeConsFee = getJudgeConsFee(erpCredits, judgeConsFeeActual);
//
//        //获取存在集合的且有问题（应付金额（不含税价）>实付金额（不含税价））
//        List<ErpCredit> designThanProblem = judgeDesign.get("designThanProblem");//获取设计费
//        List<ErpCredit> supervisorThanProblem = judgeSupervisorFee.get("supervisorThanProblem");//获取监理费
//        List<ErpCredit> consThanProblem = judgeConsFee.get("consThanProblem");//获取施工费
//        List<ErpCredit> judgeEnterAccountTwo = getJudgeEnterAccount(designThanProblem, supervisorThanProblem, consThanProblem,"2");
//
//        //若应付金额（不含税价）<实付金额（不含税价）,需要导出差异情况，同时费用入账核实存在问题。
//        List<ErpCredit> designYesProblem = judgeDesign.get("designYesProblem");//获取设计费
//        List<ErpCredit> supervisorYesProblem = judgeSupervisorFee.get("supervisorYesProblem");//获取监理费
//        List<ErpCredit> consYesProblem = judgeConsFee.get("consYesProblem");//获取施工费
//        List<ErpCredit> judgeEnterAccountThree = getJudgeEnterAccount(designYesProblem, supervisorYesProblem, consYesProblem,"1");
//        listMap.put("judgeEnterAccountTwo",judgeEnterAccountTwo);
//        listMap.put("judgeEnterAccountThree",judgeEnterAccountThree);
//        return listMap;
//    }


    //统一list
//    public static List<ErpCredit> getJudgeEnterAccount(List<ErpCredit> erpCredits1,List<ErpCredit> erpCredits2,List<ErpCredit> erpCredits3,String status){
//        List<ErpCredit> list = new ArrayList<ErpCredit>();
//        List<ErpCredit> sureList = new ArrayList<ErpCredit>();
//        for (ErpCredit erpCredit1:erpCredits1){
//            list.add(erpCredit1);
//        }
//        for (ErpCredit erpCredit2:erpCredits2){
//            list.add(erpCredit2);
//        }
//        for (ErpCredit erpCredit3:erpCredits3){
//            list.add(erpCredit3);
//        }
//        boolean flag = true;
//        for (ErpCredit erpCredit:list){
//            flag = true;
//            for (ErpCredit sureErp:sureList){
//                if (erpCredit.getItemId().equals(sureErp.getItemId())){
//                    if (null!=erpCredit.getDesignStatus()){//设计费存在问题
//                      if (erpCredit.getDesignStatus().equals(status)){
//                          sureErp.setDesignStatus(status);
//                          sureErp.setDesignFeePayable(erpCredit.getDesignFeePayable());
//                      }
//                    }
//                    if (null!=erpCredit.getConstructionStatus()){
//                       if (erpCredit.getConstructionStatus().equals(status)){
//                           sureErp.setConstructionStatus(status);
//                           sureErp.setConstructionFeePayable(erpCredit.getConstructionFeePayable());
//                       }
//                    }
//                    if (null!=erpCredit.getSupervisorStatus()){
//                        if (erpCredit.getSupervisorStatus().equals(status)){
//                            sureErp.setSupervisorStatus(status);
//                            sureErp.setSupervisorFeePayable(erpCredit.getSupervisorFeePayable());
//                        }
//                    }
//                    flag = false;
//                }
//            }
//            if (flag){
//                sureList.add(erpCredit);
//            }
//        }
//        return sureList;
//    }
}
