package com.jeeplus.modules.sg.managementcenter.project.util;
import com.jeeplus.modules.sg.managementcenter.project.entity.Project1;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.utils.UserUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Row;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public  class ProExcelInfo {

    public static String[] PRO_TYPE={"配网资本","配网成本"};
    public static String[] PRO_NAME={"配电运检室","经研所","新区"};
    public static String[] PRO_CLARIFICAITON = {"施工单位自行交底","项目经理组织交底"};
    public static String[] PRO_POWERSCOPE={"670","67001+","67002+","67002-","67003-","68101-"};
    public static String[] PRO_PROJECT_TYPE={"配变改造","配变新增","电缆项目","杆线项目","混合项目","纯自动化","纯土建","井盖维修","环网柜更换","箱变更换","其他特殊类"};//项目类型
    public static String[] PRO_FLAG = {"是","否"};
    public static String[] PRO_PRE_JUDGEMENT = {"行政政处（城区道路）","民事政处/行政政处（公路/水利）","无","农村政处"};//政策初步判断
    public static String[] PRO_FLAG_CIVIL = {"可能有土建","无土建","含土建","纯土建"};//是否含土建
    public static String[] PRO_STEEL_TUBE = {"无","压桩","灌注桩"};//钢管杆基础类类型
    public static String[] PRO_EQU_TYPE = {"无","环网柜","箱变","干变","其他","DTU","分支箱"};//设备改造类型
    public static String[] PRO_DRAWING_WORK = {"带电作业","停电作业","非涉电作业","未标注"};//图纸标注的带点作业情况
    public static String[] PRO_TWO_THREE = {"二遥","三遥","混合"};//二或三
    public static String[] PRO_PHONE_STYLE = {"光纤","公网","专网","混合"};//通信方式
    public static String[] PRO_STAY_AREA={"集中","就地","混合"};//柱开集中或就业地
    public static String[] PRO_RING_NETWORK = {"户内","户外","混合"};//环网柜
    public static String[] PRO_ITEM_TYPE = {"资本项目","成本项目"};//项目类型

    public static String[] PRO_LINGTING = {"配电新区","配电工区"};//运行单位

    public final static String[] SYS_ROLE = {"项目经理","配网工程专职"};//
    /**
     * 获取表格数据
     * @param importUtil 导入
     * @return List<ErpAccount> 导入表格数据
     */
    public static List<Project1> getProjectUtil(ImportUtil importUtil)  {
        int lastRow = importUtil.getLastDataRowNum();
        List<Project1> list = new ArrayList<Project1>();
        Project1 project = null;
        String costEstimate="";//费用估算
        for(int i=2; i<=lastRow;i++){
            project = new Project1();
            Row row = importUtil.getRow(i);
            String requireName= (String) importUtil.getCellValue(row,5);
            if(StringUtils.isNotBlank(requireName)) {
                project.setRequireName(requireName);//需求项目名称
                project.setType((String)importUtil.getCellValue(row,1));//类型
                project.setDemandUnit((String)importUtil.getCellValue(row,2));//需求提出单位
                project.setBdzName((String)importUtil.getCellValue(row,3));//变电站名称
                project.setLineName((String)importUtil.getCellValue(row,4));//线路名称
                project.setReserveNumber((String) importUtil.getCellValue(row,6));//储备编号
                project.setProjectId((String)importUtil.getCellValue(row,7));//工程编号
                project.setProjectName((String)importUtil.getCellValue(row,8));//项目名称
                project.setProjectNumber((String)importUtil.getCellValue(row,9));//项目定义号
                project.setProjectManageRole((String)importUtil.getCellValue(row,10));//项目经理角色
                project.setDistributionEngineering((String)importUtil.getCellValue(row,11));//配网工程专职角色
                project.setDistributionMaterials((String)importUtil.getCellValue(row,12));//配网物资专职角色
                project.setDistributionSystem((String)importUtil.getCellValue(row,13));//配网系统专职角色
                project.setDistributionPolicy((String)importUtil.getCellValue(row,14));//配网政策处理专职角色
                project.setManagementLeader((String)importUtil.getCellValue(row,15));//项目管理中心领导角色'
                project.setSkillByFull((String)importUtil.getCellValue(row,16));//项目管理中心技经专职
                project.setRunUnit((String)importUtil.getCellValue(row,17));//运行单位
                project.setRunUnitRole((String)importUtil.getCellValue(row,18));//运行单位角色(储备）
                project.setRunUnitInspectionRole((String)importUtil.getCellValue(row,19));//运行单位角色（运检）
                project.setThroughResearchRole((String)importUtil.getCellValue(row,20));//经研所角色

                project.setConstructionContractUnit((String)importUtil.getCellValue(row,21));//施工合同单位
                costEstimate = (String) importUtil.getCellValue(row,22);
                if (null!=costEstimate&&!costEstimate.equals("")){
                    project.setConstructionContractRate(Double.parseDouble(costEstimate));//施工合同率
                }
                project.setConstructionContractSub((String)importUtil.getCellValue(row,23));//施工分包单位
                project.setConstructionUnit((String)importUtil.getCellValue(row,24));//施工单位
                project.setConstructionUnitRole((String)importUtil.getCellValue(row,25));//施工单位角色
                project.setConstructionUnitManage((String)importUtil.getCellValue(row,26));//施工单位项目经理
                project.setConstructionUnitLeader((String)importUtil.getCellValue(row,27));//施工单位领导
                project.setConstructionSkillByFull((String)importUtil.getCellValue(row,28));//施工单位技经专职
                project.setDesignUnit((String)importUtil.getCellValue(row,29));//设计单位
                project.setDesignUnitManage((String)importUtil.getCellValue(row,30));//设计单位项目领导
                project.setDesignUnitLeader((String)importUtil.getCellValue(row,31));//设计单位领导
                project.setClarificaitonType((String)importUtil.getCellValue(row,32));//交底类型
                project.setBulidClassificationResons((String)importUtil.getCellValue(row,33));//建设理由分类
                project.setBulbidResons((String)importUtil.getCellValue(row,34));//建设理由
                project.setAsicEquipment((String)importUtil.getCellValue(row,35));//设备基本状况
                project.setRunTheClass((String)importUtil.getCellValue(row,36));//运行班
                project.setProjectTeam((String)importUtil.getCellValue(row,36));//项目组
                costEstimate = (String) importUtil.getCellValue(row,37);
                if (null!=costEstimate&&!costEstimate.equals("")){
                    project.setCostEstimate(Double.parseDouble(costEstimate));//费用估算
                }
                project.setWhetherRheUpwind((String)importUtil.getCellValue(row,38));//是否迎风期度夏项目
                project.setSureDaDate((String)importUtil.getCellValue(row,39));//确定下达时间
                project.setTextRemark((String)importUtil.getCellValue(row,40));//备注
                project.setPowerLine((String)importUtil.getCellValue(row,41));//停电线路
                project.setPowerScope((String)importUtil.getCellValue(row,42));//停电范围
                project.setProjectType((String)importUtil.getCellValue(row,43));//项目类型
                project.setPowerFlagPackage((String)importUtil.getCellValue(row,44));//是否为停电打包项目
                project.setPreliminaryJudgment((String)importUtil.getCellValue(row,45));//证处初步判断
                project.setFlagCivilEngineering((String)importUtil.getCellValue(row,46));//是否含土建
                project.setSteelTubePole((String)importUtil.getCellValue(row,47));//钢管杆基础类型
                project.setFlagApprovalPlanning((String)importUtil.getCellValue(row,48));//是否需要规划报批
                project.setEquCreateType((String)importUtil.getCellValue(row,49));//设备改造类型
                project.setEquCreateSize((String)importUtil.getCellValue(row,50));//间隔数
                project.setFlagNewEquName((String)importUtil.getCellValue(row,51));//是否新设备命名
                project.setIncludeBdzNews((String)importUtil.getCellValue(row,52));//是否含变电站新闻格投运
                project.setFlagNoElectrical((String)importUtil.getCellValue(row,53));//是否非射电电气施工
                project.setDrawingsWork((String)importUtil.getCellValue(row,54));//图纸标注的带点作业情况
                project.setFlagAutomation((String)importUtil.getCellValue(row,55));//是否含自动化
                project.setTwoAndThreeRemote((String)importUtil.getCellValue(row,56));//二遥或三
                project.setPhoneStyle((String)importUtil.getCellValue(row,57));//通信方式
                project.setStayOpenArea((String)importUtil.getCellValue(row,58));//柱开集中或就业地
                project.setRingNetworkCabinet((String)importUtil.getCellValue(row,59));//环网柜
                project.setAutomatedRemarks((String)importUtil.getCellValue(row,60));//自动化备注
                project.setStationDtu((String)importUtil.getCellValue(row,61));//站房dtu
                project.setRezkey("0");
                list.add(project);
            }
        }
        return list;
    }

    //验证表格数据是否正确
    public static Boolean getProjectUtilFlag(ImportUtil importUtil){
        Boolean flag = false;
        Row row = importUtil.getRow(1);
        String indexFive =  (String)importUtil.getCellValue(row,5);
        String indexSix = (String)importUtil.getCellValue(row,6);
        String indexNine = (String)importUtil.getCellValue(row,9);
        if (!indexFive.contains("项目")){
            flag = true;
        }
        if (!indexSix.contains("储备")){
            flag = true;
        }
        if (!indexNine.contains("号")){
            flag = true;
        }
        return flag;
    }

    /*
        对值进行验证 配网工程专职验证
     */
    public static String getJudgeValue(List<Project1> projects, List<String> users){
        Boolean flag = false;
        String str = "";
        boolean judgeLoginName = false;
        for (Project1 project : projects){
            if(null== project.getBdzName()||"".equals(project.getBdzName())){//变电站名称
                str+="变电站名称不能为空";
            }
            if (null== project.getLineName()||"".equals(project.getLineName())){//线路名称
                str+="线路名称不能为空";
            }
            if (null== project.getProjectManageRole()||"".equals(project.getProjectManageRole())){
                str+="配网项目经理不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getProjectManageRole());
                if (judgeLoginName){
                    str+="配网项目经理不存在;";
                }
            }
            if (null== project.getDistributionEngineering()||"".equals(project.getDistributionEngineering())){//配网工程专职角色
                str+="配网工程专职不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getDistributionEngineering());
                if (judgeLoginName){
                    str+="配网工程专职不存在;";
                }
            }
            if (null== project.getDistributionMaterials()||"".equals(project.getDistributionMaterials())){//配网物资专职角色
                str+="配网物资专职不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getDistributionMaterials());
                if (judgeLoginName){
                    str+="配网物资专职不存在;";
                }
            }
            if (null== project.getDistributionSystem()||"".equals(project.getDistributionSystem())){//配网系统专职角色
                str+="配网系统专职角色为空;";
            }else {
               judgeLoginName = getJudgeLoginName(users, project.getDistributionSystem());
                if (judgeLoginName){
                    str+="配网系统专职不存在;";
                }
            }
            if (null== project.getDistributionPolicy()||"".equals(project.getDistributionPolicy())){//配网政策处理专职角色
                str+="配网政策处理专职不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getDistributionPolicy());
                if (judgeLoginName){
                    str+="配网政策处理专职不存在;";
                }
            }
            if (null== project.getManagementLeader()||"".equals(project.getManagementLeader())){//项目管理中心领导角色
                str+="项目管理中心领导不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getManagementLeader());
                if (judgeLoginName){
                    str+="项目管理中心领导不存在;";
                }
            }
            if (null== project.getRunUnit()||"".equals(project.getRunUnit())){//运行单位
                str+="运行单位不能为空;";
            }else {
                flag = getJudge(project.getRunUnit(),PRO_LINGTING);
                if (flag){
                    str+="运行单位填写有误;";
                }
            }
            if (null== project.getRunUnitRole()||"".equals(project.getRunUnitRole())){//运行单位角色
                str+="运行单位储备专职不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getRunUnitRole());
                if (judgeLoginName){
                    str+="运行单位储备专职不存在;";
                }
            }
            if (null== project.getRunUnitInspectionRole()){
                str+="运行单位运检不能为空";
            }
/*            if (null==project.getThroughResearchRole()||"".equals(project.getThroughResearchRole())){//经研所角色
                str+="经研所角色不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getThroughResearchRole());
                if (judgeLoginName){
                    str+="经研所角色不存在;";
                }
            }*/
            if (null== project.getConstructionUnit()||"".equals(project.getConstructionUnit())){//施工单位
                str+="施工单位不能为空;";
            }
            if (null== project.getConstructionUnitRole()||"".equals(project.getConstructionUnitRole())){//施工单位:施工单位角色
                str+="施工单位物质专职不能为空;";
            }else {
               judgeLoginName = getJudgeLoginName(users, project.getConstructionUnitRole());
                if (judgeLoginName){
                    str+="施工单位物资专职不存在;";
                }
            }
            if (null== project.getConstructionUnitManage()||"".equals(project.getConstructionUnitManage())){//施工单位:施工单位角色
                str+="施工单位项目经理不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getConstructionUnitManage());
                if (judgeLoginName){
                    str+="施工单位项目经理不存在;";
                }
            }
            if (null== project.getConstructionUnitLeader()||"".equals(project.getConstructionUnitLeader())){//施工单位:施工单位角色
                str+="施工单位领导不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getConstructionUnitLeader());
                if (judgeLoginName){
                    str+="施工单位领导不存在;";
                }
            }
            if (null== project.getDesignUnit()||"".equals(project.getDesignUnit())){//设计单位
                str+="设计单位不能为空;";
            }
            if (null== project.getDesignUnitManage()||"".equals(project.getDesignUnitManage())){//设计单位角色
                str+="设计单位人员不能为空;";
            }else {
                judgeLoginName = getJudgeLoginName(users, project.getDesignUnitManage());
                if (judgeLoginName){
                    str+="设计单位人员不存在;";
                }
            }
            if (null== project.getDesignUnitLeader()||"".equals(project.getDesignUnitLeader())){//设计单位
                str+="设计单位领导不能为空;";
            }/*else {
                judgeLoginName = getJudgeLoginName(users, project.getDesignUnitLeader());
                if (judgeLoginName){
                    str+="设计单位领导不存在;";
                }
            }*/
            if (null!= project.getType()){//类型
                flag = getJudge(project.getType(), PRO_TYPE);
                if (flag){
                    str+="类型填写有误;";
                }
            }
            if (null!= project.getDemandUnit()){//需求提出单位
                flag = getJudge(project.getDemandUnit(),PRO_NAME);
                if (flag){
                    str+="需求提出单位填写有误;";
                }
            }
//            if (null==project.getRunUnit()||"".equals(project.getRunUnit())){//设计单位
//                str+="运行单位不能为空;";
//            }else {
//                judgeLoginName = getJudge(project.getRunUnit(), PRO_LINGTING);
//                if (judgeLoginName){
//                    str+="运行单位填写有误;";
//                }
//            }
            if (null== project.getClarificaitonType()||"".equals(project.getClarificaitonType())){//交底类型
                    str+="交底类型不能为空;";
            }else {
                flag = getJudge(project.getClarificaitonType(),PRO_CLARIFICAITON);
                if (flag){
                    str+="交底类型填写有误;";
                }
            }
            if (null== project.getPowerScope()||"".equals(project.getPowerScope())){//停电范围
                str+="停电范围不能为空;";
            }/*else {
                String[] split = project.getPowerScope().split(";");
                for (int i = 0; i <split.length; i++) {
                    flag = getJudge(split[i], PRO_POWERSCOPE);
                    if (flag){
                        str+="停单范围填写有误;";
                    }
                }
            }*/
            if (null== project.getProjectType()||"".equals(project.getProjectType())){//项目类型
                str+="项目类型填写不能为空;";
            }else {
                flag = getJudge(project.getProjectType(), PRO_PROJECT_TYPE);
                if (flag){
                    str+="项目类型填写有误;";
                }
            }
            if (null!= project.getPowerFlagPackage()){//是否为停电打包项目
                flag = getJudge(project.getPowerFlagPackage(), PRO_FLAG);
                if (flag){
                    str+="是否为停电打包项目填写有误;";
                }
            }
            if (null== project.getPreliminaryJudgment()||"".equals(project.getPreliminaryJudgment())){//政策初步判断
                str+="政策初步判断不能为空;";
            }else {
                flag = getJudge(project.getPreliminaryJudgment(), PRO_PRE_JUDGEMENT);
                if (flag){
                    str+="政策初步判断填写有误;";
                }
            }
            if (null== project.getFlagCivilEngineering()||"".equals(project.getFlagCivilEngineering())){//是否含土建
                str+="是否含土建填写不能为空;";
            }else {
                flag = getJudge(project.getFlagCivilEngineering(),PRO_FLAG_CIVIL);
                if (flag){
                    str+="是否含土建填写有误;";
                }
            }
            if (null== project.getSteelTubePole()||"".equals(project.getSteelTubePole())){//钢管杆基础类类型
                str+="钢管杆基础类类型填写不能为空;";
            }else {
                flag = getJudge(project.getSteelTubePole(),PRO_STEEL_TUBE);
                if (flag){
                    str+="钢管杆基础类类型填写有误;";
                }
            }
            if (null== project.getFlagApprovalPlanning()||"".equals(project.getFlagApprovalPlanning())){//是否需要规划报批
                str+="是否需要规划报批填写不能为空;";
            }else {
                flag = getJudge(project.getFlagApprovalPlanning(),PRO_FLAG);
                if (flag){
                    str+="是否需要规划报批填写有误;";
                }
            }
            if (null== project.getEquCreateType()||"".equals(project.getEquCreateType())){//设备改造类型
                str+="设备改造类型填写有误;";
            }else {
                flag = getJudge(project.getEquCreateType(),PRO_EQU_TYPE);
                if (flag){
                    str+="设备改造类型填写有误;";
                }else {
                    if (!project.getEquCreateType().equals("无")){
                        if (null == project.getEquCreateSize() || "".equals(project.getEquCreateSize())){
                            str+="改造设备尺寸及间隔数不能为空;";
                        }
                    }
                }
            }
            if (null== project.getFlagNewEquName()||"".equals(project.getFlagNewEquName())){//是否含新设备命名
                str+="是否含新设备命名填写不能为空;";
            }else {
                flag = getJudge(project.getFlagNewEquName(),PRO_FLAG);
                if (flag){
                    str+="是否含新设备命名填写有误;";
                }
            }
            if (null== project.getIncludeBdzNews()||"".equals(project.getIncludeBdzNews())){//是否含变电站新间间隔投运
                    str+="是否含变电站新间间隔投运填写不能为空;";
            }else {
                flag = getJudge(project.getIncludeBdzNews(),PRO_FLAG);
                if (flag){
                    str+="是否含变电站新间间隔投运填写有误;";
                }
            }
            if (null== project.getFlagNoElectrical()||"".equals(project.getFlagNoElectrical())){//是否含非设电电气施工
                str+="是否含非设电电气施工填写不能为空;";
            }else {
                flag = getJudge(project.getFlagNoElectrical(),PRO_FLAG);
                if (flag){
                    str+="是否含非设电电气施工填写有误;";
                }
            }
            if (null== project.getDrawingsWork()||"".equals(project.getDrawingsWork())){//图纸标注的带点作业情况
                str+="图纸标注的带点作业情况填写不能为空;";
            }else {
                flag = getJudge(project.getDrawingsWork(),PRO_DRAWING_WORK);
                if (flag){
                    str+="图纸标注的带点作业情况填写有误;";
                }
            }
            //自动化
            if (null== project.getFlagAutomation() || "".equals(project.getFlagAutomation())){//是否含自动化
                    str+="是否含自动化填写不能为空;;";
            }else {
                flag = getJudge(project.getFlagAutomation(),PRO_FLAG);
                if (flag){
                    str+="是否含自动化填写有误;";
                }else {
                    if (project.getFlagAutomation().equals("是")){
                        //二遥或三摇
                        if (null == project.getTwoAndThreeRemote()|| "".equals(project.getTwoAndThreeRemote())){
                            str+="二摇或三摇填写不能为空;";
                        }else {
                            flag = getJudge(project.getTwoAndThreeRemote(),PRO_TWO_THREE);
                            if (flag){
                                str+="二摇或三摇填写有误;";
                            }
                        }
                        //通讯方式
                        if (null == project.getPhoneStyle() || "".equals(project.getPhoneStyle())){
                            str+="通讯方式填写有误;";
                        }else {
                            flag = getJudge(project.getPhoneStyle(),PRO_PHONE_STYLE);
                            if (flag){
                                str+="通信方式填写有误;";
                            }
                        }
                        boolean flag1=true;
                        //柱开集中或就业地
                        if (null!= project.getStayOpenArea()&&!"".equals(project.getStayOpenArea())){//柱开集中或就业地
                            flag = getJudge(project.getStayOpenArea(),PRO_STAY_AREA);
                            if (flag){
                                str+="柱开集中或就业地填写有误;";
                            }
                            flag1 = false;
                        }
                        if (null!= project.getRingNetworkCabinet()&&!"".equals(project.getRingNetworkCabinet())){//环网柜
                            flag = getJudge(project.getRingNetworkCabinet(),PRO_RING_NETWORK);
                            if (flag){
                                str+="环网柜填写有误;";
                            }
                            flag1 = false;
                        }
                        if (flag1){
                            str +="柱开和环网柜必填之其中之一;";
                        }
                    }
                }
            }
            boolean flag2 = false;
            if (null!= project.getTwoAndThreeRemote()){
                if (project.getTwoAndThreeRemote().equals("混合")){
                    flag2 = true;
                }
            }
            if (null!= project.getPhoneStyle()){
                if (project.getPhoneStyle().equals("混合")){
                    flag2 = true;
                }
            }
            if (null!= project.getStayOpenArea()){
                if (project.getStayOpenArea().equals("混合")){
                    flag2 = true;
                }
            }
            if (null!= project.getRingNetworkCabinet()){
                if (project.getRingNetworkCabinet().equals("混合")){
                    flag2 = true;
                }
            }
            if (flag2){
                if (null== project.getAutomatedRemarks()||"".equals(project.getAutomatedRemarks())){
                    str+="自动化备注不能为空;";
                }
            }
            if (!"".equals(str)){
                str+="：错误项目为：["+ project.getRequireName()+"]";
                return str;
            }
        }
        return str;
    }

    //对登录人进行验证
    public static boolean getJudgeLoginName(List<String> users,String string){
        boolean flag = true;
        for (String user:users){
            if (string.equals(user)){
                flag = false;
                break;
            }
        }
        return flag;
    }

    public static Boolean getJudge(String name,String[] strings){
        boolean flag = true;
        if (null!=name){
            for (String str:strings){
                if (str.equals(name)){
                    flag = false;
                    break;
                }
            }
        }
        return flag;
    }

    public static Boolean getJudgeCheck(String[] strings){
        boolean flag = false;
        for (String str:strings){
            if (null==str){
                flag = true;
                break;
            }
        }
        return flag;
    }
    /**
     * 生成随机数
     * @return
     */
    public static String getStatus(){
        int machineId = 1;
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if (hashCodeV<0){
            hashCodeV=-hashCodeV;
        }
        return  (machineId+String.format("%015d",hashCodeV));
    }

    //进行导入角色筛选 项目经理
    public static List<Project1> getSureProjectsManager(List<Project1> projects){
        String loginName = UserUtils.getUser().getLoginName();
        if ("admin".equals(loginName)){
            return projects;
        }
        String name = UserUtils.getUser().getName();
        for (int i = 0; i < projects.size(); i++) {
            if (null!= projects.get(i).getProjectManageRole()){//项目经理角色
                if (!name.equals(projects.get(i).getProjectManageRole())){
                    projects.remove(i);
                    i--;
                }
            }
        }
        return projects;
    }

    /**
     * @param projectsManager 项目经理操作的集合
     * @param projectList 数据库中查到的集合
     * @return 去掉数据库中不存在的数据
     */
    public static List<Project1> getSureManagerProject(List<Project1> projectsManager, List<Project1> projectList){
        String requireName = "";//需求项目名称
        boolean flag = false;//开关
        for (int i = 0; i < projectsManager.size(); i++) {
            requireName = projectsManager.get(i).getRequireName();
            flag = true;
            for (Project1 project : projectList){
                if (project.getRequireName().equals(requireName)){
                    flag = false;
                    break;
                }
            }
            if (flag){
                projectsManager.remove(i);
                i--;
            }
        }
        return projectsManager;
    }

    //判断导入角色名
    public static String getJudgeRole(User user){
        if (user.getRoleList().size()>1){
            return "3";
        }
        //如果是项目经理导入的
        if ("项目经理".equals(user.getRoleList().get(0).getName())){
           return "1";
        }
        if ("配网工程专职".equals(user.getRoleList().get(0).getName())){
            return "0";
        }
        return "2";
    }

    public static boolean getFlagUpdate(Project1 project){
        if (!project.getStatus().equals("0")||!project.getAcquisitionStatus().equals("0")
            ||!project.getConstructionStatus().equals("0")
            || project.getEarlyMaterial()!=0|| project.getPreConstruction()!=0){
            if (project.getStatus().equals("3")&& project.getAcquisitionStatus().equals("3")
                    && project.getConstructionStatus().equals("3")
                    && project.getEarlyMaterial()==3 && project.getPreConstruction()==3){
                return false;
            }
            return true;
        }
        return false;
    }
}
