浏览代码

项目计划安排

Enford 5 年之前
父节点
当前提交
c335d25676

+ 79 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/util/ImportProUtil.java

@@ -0,0 +1,79 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util;
+
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.modules.sg.managementcenter.constructionProject.entity.ConstructionProject;
+import com.jeeplus.modules.sg.managementcenter.constructionProject.util.ImportUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Row;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public  class ImportProUtil {
+    /**
+     * 获取表格数据
+     * @param importUtil
+     * @return List<MaterialProjectMapper> 导入表格数据
+     */
+    public static List<ConstructionProject> getProjectUtil(com.jeeplus.modules.sg.managementcenter.constructionProject.util.ImportUtil importUtil)  {
+        int lastRow = importUtil.getLastDataRowNum();
+        List<ConstructionProject> list = new ArrayList<ConstructionProject>();
+        ConstructionProject constructionProject = null;
+        String projectName="";
+        for(int i=2; i<=lastRow;i++){
+            constructionProject = new ConstructionProject();
+            Row row = importUtil.getRow(i);
+            projectName = (String) importUtil.getCellValue(row,8);
+            if(StringUtils.isNotBlank(projectName)) {
+                constructionProject.setProjectName(projectName);
+                constructionProject.setCityCompany((String)importUtil.getCellValue(row,1));//  市公司
+                constructionProject.setCountyCompany((String)importUtil.getCellValue(row,2));//  县公司
+                constructionProject.setProjectNature((String)importUtil.getCellValue(row,3));//  项目性质
+                constructionProject.setPowerSupplyArea((String)importUtil.getCellValue(row,4));//  供电区域
+                constructionProject.setGridNumber((String)importUtil.getCellValue(row,5));//  网格编号
+                constructionProject.setCellNumber((String)importUtil.getCellValue(row,6));//  单元格编号
+                constructionProject.setReserveNumber((String)importUtil.getCellValue(row,7));//  项目储备编号
+                constructionProject.setProjectNumber((String)importUtil.getCellValue(row,9));//  项目定义号
+                constructionProject.setSubstationName((String)importUtil.getCellValue(row,10));//  变电站名称
+                constructionProject.setLineName((String)importUtil.getCellValue(row,11));//  线路名称
+                constructionProject.setProjectType((String)importUtil.getCellValue(row,12));//  项目类型
+                constructionProject.setInstructions((String)importUtil.getCellValue(row,13));//  说明
+                constructionProject.setWorkAreaNote((String)importUtil.getCellValue(row,14));//  工区备注
+//                constructionProject.setContructiveContent((String)importUtil.getCellValue(row,15));//  建设必要性内容
+//                constructionProject.setCostEstimate(ImportProUtil.getDouble(importUtil,row,16));//  费用估算
+//                constructionProject.setWhetherGraceProject((String)importUtil.getCellValue(row,17));///  是否迎风度夏项目
+//                constructionProject.setProjectNote((String)importUtil.getCellValue(row,18));//  项目备注
+//                constructionProject.setConstructionUnit((String)importUtil.getCellValue(row,19));//  施工单位
+                constructionProject.setProjectStatus("0");
+                list.add(constructionProject);
+            }
+        }
+        return list;
+    }
+    //验证表格数据是否正确
+    public static Boolean getMaterialProjectFlag(com.jeeplus.modules.sg.managementcenter.constructionProject.util.ImportUtil importUtil){
+        Boolean flag = false;
+        Row row = importUtil.getRow(0);
+        String index =  (String)importUtil.getCellValue(row,0);
+        String two = (String)importUtil.getCellValue(row,1);
+        if (!index.contains("储备")){
+            flag = true;
+        }
+        if (!two.contains("项目")){
+            flag = true;
+        }
+        return flag;
+    }
+    /**
+     *获取excel double类型的值
+     */
+    private static double getDouble(ImportUtil importUtil, Row row, int col){
+        double d = 0.00;
+        Object o = importUtil.getCellValue(row,col);
+        if(!o.equals("")){
+            d = Double.parseDouble(o.toString());
+        }
+        return d;
+    }
+}

+ 394 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/util/ImportUtil.java

@@ -0,0 +1,394 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.Reflections;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.sys.entity.Area;
+import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 导入Excel文件(支持“XLS”和“XLSX”格式)
+ * @author jeeplus
+ * @version 2016-03-10
+ */
+public class ImportUtil {
+
+	private static Logger log = LoggerFactory.getLogger(ImportUtil.class);
+
+	/**
+	 * 工作薄对象
+	 */
+	private Workbook wb;
+
+	/**
+	 * 工作表对象
+	 */
+	private Sheet sheet;
+
+	/**
+	 * 标题行号
+	 */
+	private int headerNum;
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件,读取第一个工作表
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(String fileName, int headerNum)
+			throws InvalidFormatException, IOException {
+		this(new File(fileName), headerNum);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件对象,读取第一个工作表
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(File file, int headerNum)
+			throws InvalidFormatException, IOException {
+		this(file, headerNum, 0);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(String fileName, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		this(new File(fileName), headerNum, sheetIndex);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件对象
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(File file, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		this(file.getName(), new FileInputStream(file), headerNum, sheetIndex);
+	}
+
+	/**
+	 * 构造函数
+	 * @param file 导入文件对象
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(MultipartFile multipartFile, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		this(multipartFile.getOriginalFilename(), multipartFile.getInputStream(), headerNum, sheetIndex);
+	}
+
+	/**
+	 * 构造函数
+	 * @param path 导入文件对象
+	 * @param headerNum 标题行号,数据行号=标题行号+1
+	 * @param sheetIndex 工作表编号
+	 * @throws InvalidFormatException
+	 * @throws IOException
+	 */
+	public ImportUtil(String fileName, InputStream is, int headerNum, int sheetIndex)
+			throws InvalidFormatException, IOException {
+		if (StringUtils.isBlank(fileName)){
+			throw new RuntimeException("导入文档为空!");
+		}else if(fileName.toLowerCase().endsWith("xls")){    
+			this.wb = new HSSFWorkbook(is);    
+        }else if(fileName.toLowerCase().endsWith("xlsx")){  
+        	this.wb = new XSSFWorkbook(is);
+        }else{  
+        	throw new RuntimeException("文档格式不正确!");
+        }  
+		if (this.wb.getNumberOfSheets()<sheetIndex){
+			throw new RuntimeException("文档中没有工作表!");
+		}
+		this.sheet = this.wb.getSheetAt(sheetIndex);
+		this.headerNum = headerNum;
+		log.debug("Initialize success.");
+	}
+	
+	/**
+	 * 获取行对象
+	 * @param rownum
+	 * @return
+	 */
+	public Row getRow(int rownum){
+		return this.sheet.getRow(rownum);
+	}
+
+	/**
+	 * 获取数据行号
+	 * @return
+	 */
+	public int getDataRowNum(){
+		return headerNum+1;
+	}
+	
+	/**
+	 * 获取最后一个数据行号
+	 * @return
+	 */
+	public int getLastDataRowNum(){
+		return this.sheet.getLastRowNum()+headerNum;
+	}
+	
+	/**
+	 * 获取最后一个列号
+	 * @return
+	 */
+	public int getLastCellNum(){
+		return this.getRow(headerNum).getLastCellNum();
+	}
+	
+	/**
+	 * 获取单元格值
+	 * @param row 获取的行
+	 * @param column 获取单元格列号
+	 * @return 单元格值
+	 */
+	public Object getCellValue(Row row, int column) {
+		Object val = "";
+		try {
+			Cell cell = row.getCell(column);
+			if (cell != null) {
+				if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+					// val = cell.getNumericCellValue();
+					// 当excel 中的数据为数值或日期是需要特殊处理
+					if (HSSFDateUtil.isCellDateFormatted(cell)) {
+						double d = cell.getNumericCellValue();
+						Date date = HSSFDateUtil.getJavaDate(d);
+						SimpleDateFormat dformat = new SimpleDateFormat(
+								"yyyy-MM-dd");
+						val = dformat.format(date);
+					} else {
+						NumberFormat nf = NumberFormat.getInstance();
+						nf.setGroupingUsed(false);// true时的格式:1,234,567,890
+						val = nf.format(cell.getNumericCellValue());// 数值类型的数据为double,所以需要转换一下
+					}
+				} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
+					val = cell.getStringCellValue();
+				} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+					val = cell.getCellFormula();
+				} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
+					val = cell.getBooleanCellValue();
+				} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
+					val = cell.getErrorCellValue();
+				}
+			}
+		} catch (Exception e) {
+			return val;
+		}
+		return val;
+	}
+	
+	/**
+	 * 获取导入数据列表
+	 * @param cls 导入对象类型
+	 * @param groups 导入分组
+	 */
+	public <E> List<E> getDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException{
+		List<Object[]> annotationList = Lists.newArrayList();
+		// Get annotation field 
+		Field[] fs = cls.getDeclaredFields();
+		for (Field f : fs){
+			ExcelField ef = f.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==2)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, f});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, f});
+				}
+			}
+		}
+		// Get annotation method
+		Method[] ms = cls.getDeclaredMethods();
+		for (Method m : ms){
+			ExcelField ef = m.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==2)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, m});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, m});
+				}
+			}
+		}
+		// Field sorting
+		Collections.sort(annotationList, new Comparator<Object[]>() {
+			public int compare(Object[] o1, Object[] o2) {
+				return new Integer(((ExcelField)o1[0]).sort()).compareTo(
+						new Integer(((ExcelField)o2[0]).sort()));
+			};
+		});
+		//log.debug("Import column count:"+annotationList.size());
+		// Get excel data
+		List<E> dataList = Lists.newArrayList();
+		for (int i = this.getDataRowNum(); i < this.getLastDataRowNum(); i++) {
+			E e = (E)cls.newInstance();
+			int column = 0;
+			Row row = this.getRow(i);
+			StringBuilder sb = new StringBuilder();
+			for (Object[] os : annotationList){
+				Object val = this.getCellValue(row, column++);
+				if (val != null){
+					ExcelField ef = (ExcelField)os[0];
+					// If is dict type, get dict value
+					if (StringUtils.isNotBlank(ef.dictType())){
+						val = DictUtils.getDictValue(val.toString(), ef.dictType(), "");
+						//log.debug("Dictionary type value: ["+i+","+colunm+"] " + val);
+					}
+					// Get param type and type cast
+					Class<?> valType = Class.class;
+					if (os[1] instanceof Field){
+						valType = ((Field)os[1]).getType();
+					}else if (os[1] instanceof Method){
+						Method method = ((Method)os[1]);
+						if ("get".equals(method.getName().substring(0, 3))){
+							valType = method.getReturnType();
+						}else if("set".equals(method.getName().substring(0, 3))){
+							valType = ((Method)os[1]).getParameterTypes()[0];
+						}
+					}
+					//log.debug("Import value type: ["+i+","+column+"] " + valType);
+					try {
+						//如果导入的java对象,需要在这里自己进行变换。
+						if (valType == String.class){
+							String s = String.valueOf(val.toString());
+							if(StringUtils.endsWith(s, ".0")){
+								val = StringUtils.substringBefore(s, ".0");
+							}else{
+								val = String.valueOf(val.toString());
+							}
+						}else if (valType == Integer.class){
+							val = Double.valueOf(val.toString()).intValue();
+						}else if (valType == Long.class){
+							val = Double.valueOf(val.toString()).longValue();
+						}else if (valType == Double.class){
+							val = Double.valueOf(val.toString());
+						}else if (valType == Float.class){
+							val = Float.valueOf(val.toString());
+						}else if (valType == Date.class){
+							SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
+							val=sdf.parse(val.toString()); 
+						}else if (valType == User.class){
+							val = UserUtils.getByUserName(val.toString());
+						}else if (valType == Office.class){
+							val = UserUtils.getByOfficeName(val.toString());
+						}else if (valType == Area.class){
+							val = UserUtils.getByAreaName(val.toString());
+						}else{
+							if (ef.fieldType() != Class.class){
+								val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString());
+							}else{
+								val = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(), 
+										"fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString());
+							}
+						}
+					} catch (Exception ex) {
+						log.info("Get cell value ["+i+","+column+"] error: " + ex.toString());
+						val = null;
+					}
+					// set entity value
+					if (os[1] instanceof Field){
+						Reflections.invokeSetter(e, ((Field)os[1]).getName(), val);
+					}else if (os[1] instanceof Method){
+						String mthodName = ((Method)os[1]).getName();
+						if ("get".equals(mthodName.substring(0, 3))){
+							mthodName = "set"+StringUtils.substringAfter(mthodName, "get");
+						}
+						Reflections.invokeMethod(e, mthodName, new Class[] {valType}, new Object[] {val});
+					}
+				}
+				sb.append(val+", ");
+			}
+			dataList.add(e);
+			log.debug("Read success: ["+i+"] "+sb.toString());
+		}
+		return dataList;
+	}
+
+//	/**
+//	 * 导入测试
+//	 */
+//	public static void main(String[] args) throws Throwable {
+//		
+//		ImportExcel ei = new ImportExcel("target/export.xlsx", 1);
+//		
+//		for (int i = ei.getDataRowNum(); i < ei.getLastDataRowNum(); i++) {
+//			Row row = ei.getRow(i);
+//			for (int j = 0; j < ei.getLastCellNum(); j++) {
+//				Object val = ei.getCellValue(row, j);
+//				System.out.print(val+", ");
+//			}
+//			System.out.print("\n");
+//		}
+//		
+//	}
+}

+ 309 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/util/RecursiveUtil.java

@@ -0,0 +1,309 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util;
+
+import com.jeeplus.modules.sg.managementcenter.constructionProject.entity.ConstructionProjectTemporary;
+import com.jeeplus.modules.sg.managementcenter.project.entity.Project1;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+/*8
+    递归类
+ */
+public class RecursiveUtil {
+
+    //获取级联的工程------------增加入库操作
+    public static List<Project1> getAllProjectRecursive(List<Project1> projects, List<String> projectNumbers){
+        List<Project1> sureProject = getDuplicateRemoval(projects);//确定的project集合
+        List<Project1> duplicateRemoval = getDuplicateRemoval(projects);//备用集合
+        List<Project1> areProject = getThereAreProject(sureProject, projectNumbers);//查找项目定义号的工程
+        HashSet<String> hashSetAll = getProjectScopeList(areProject);//获取去重的停电线路
+        getRecursive(duplicateRemoval,hashSetAll);//递归
+        List<Project1> returnProject = getReturnProject(sureProject, hashSetAll);
+        return returnProject;
+    }
+    //其他
+    public static List<Project1> getAllProjectNo(List<Project1> projects, List<String> projectNumbers){
+        List<Project1> projectList = getDuplicateRemoval(projects);//确定集合
+        List<Project1> duplicateRemoval = getDuplicateRemoval(projects);
+        List<Project1> noNoProject = getNoNoProject(projectList, projectNumbers);//主用
+        List<Project1> noNoProject11 = getNoNoProject(duplicateRemoval, projectNumbers);//备用
+        HashSet<String> projectScopeList = getProjectScopeList(noNoProject11);
+        getRecursive(noNoProject11,projectScopeList);
+        List<Project1> returnProject = getReturnProject(noNoProject, projectScopeList);
+        return returnProject;
+    }
+
+    public static List<Project1> getNoNoProject(List<Project1> projects, List<String> projectNumbers){
+        for (int i = 0; i < projects.size(); i++) {
+            for (String string:projectNumbers){
+                if (projects.get(i).getProjectNumber().equals(string)){
+                    projects.remove(i);
+                    i--;
+                    break;
+                }
+            }
+        }
+        return projects;
+    }
+    //获取确定的list<project>集合
+    public static List<Project1> getReturnProject(List<Project1> projects, HashSet<String> hashSetAll){
+        List<Project1> projectList = new ArrayList<Project1>();
+        for (Project1 project : projects){
+            for (String string:hashSetAll){
+                if (project.getPowerScope().contains(string)){
+                    projectList.add(project);
+                    break;
+                }
+            }
+        }
+        return projectList;
+    }
+
+    //递归
+    public static void getRecursive(List<Project1> projects, HashSet<String> hashSetAll){
+        HashSet<String> hashSet = new HashSet<String>();
+        for (String string:hashSetAll){
+            for (int i = 0; i < projects.size(); i++) {
+                if (projects.get(i).getPowerScope().contains(string)){
+                    getSplice(projects.get(i).getPowerScope(),hashSet);
+                    projects.remove(i);
+                    i--;
+                }
+            }
+        }
+        if (!hashSet.isEmpty()){
+            for (String has:hashSet){
+                hashSetAll.add(has);
+            }
+            getRecursive(projects,hashSetAll);
+        }
+    }
+    public static void getSplice(String powerScope,HashSet<String> strings){
+        String[] splice = null;
+        if (powerScope.contains(";")){
+            splice = powerScope.split(";");
+            for (String str:splice){
+                strings.add(str);
+            }
+        }else if(powerScope.contains(";")){
+            splice = powerScope.split(";");
+            for (String str:splice){
+                strings.add(str);
+            }
+        }else if (powerScope.contains(",")){
+            splice = powerScope.split(",");
+            for (String str:splice){
+                strings.add(str);
+            }
+        }else if (powerScope.contains(",")){
+            splice = powerScope.split(",");
+            for (String str:splice){
+                strings.add(str);
+            }
+        }else {
+            strings.add(powerScope);
+        }
+    }
+
+    //获取当前搜索项目定义号的停电范围
+    public static HashSet<String> getProjectScopeList(List<Project1> areProject){
+        HashSet<String> setProject = new HashSet<String>();
+        String[] arrayProject = null;
+        String projectScope = "";
+        for (Project1 project : areProject){
+            if (null!= project.getPowerScope()){
+                projectScope = project.getPowerScope();
+                if (projectScope.contains(";")){
+                    arrayProject = projectScope.split(";");
+                    for (String str:arrayProject){
+                        setProject.add(str);
+                    }
+                }else if (projectScope.contains(";")){
+                    arrayProject = projectScope.split(";");
+                    for (String str:arrayProject){
+                        setProject.add(str);
+                    }
+                }else if (projectScope.contains(",")){
+                    arrayProject = projectScope.split(",");
+                    for (String str:arrayProject){
+                        setProject.add(str);
+                    }
+                }else if (projectScope.contains(",")){
+                    arrayProject = projectScope.split(",");
+                    for (String str:arrayProject){
+                        setProject.add(str);
+                    }
+                }else {
+                    setProject.add(projectScope);
+                }
+            }
+        }
+        return setProject;
+    }
+    //获取查找的集合
+    public static List<Project1> getThereAreProject(List<Project1> projects, List<String> projectNumbers){
+        List<Project1> projectList = new ArrayList<Project1>();
+        for (String string:projectNumbers){
+            for (Project1 project : projects){
+                if (string.equals(project.getProjectNumber())){
+                    projectList.add(project);
+                    break;
+                }
+            }
+        }
+        return projectList;
+    }
+    //list project去重
+    public static List<Project1> getDuplicateRemoval(List<Project1> projects){
+        List<Project1> projectList = new ArrayList<Project1>();
+        boolean flag = false;
+        String projectNumber = "";
+        String newProjectNumber = "";
+        for(Project1 project : projects){
+            if (null!= project.getProjectNumber()&&!"".equals(project.getProjectNumber())){
+                flag = true;
+                projectNumber = project.getProjectNumber();
+                for (Project1 newProject : projectList){
+                    if (null!= newProject.getProjectNumber()&&!"".equals(newProject.getProjectNumber())){
+                        newProjectNumber = newProject.getProjectNumber();
+                        if (projectNumber.equals(newProjectNumber)){
+                            flag = false;
+                            break;
+                        }
+                    }
+                }
+                if (flag){
+                    projectList.add(project);
+                }
+            }
+        }
+        return projectList;
+    }
+    //获取级联的工程------------
+    //添加操作项目--------!
+        public static List<ConstructionProjectTemporary> getAddPlanList(List<ConstructionProjectTemporary> constructionProjectTemporaries,String ids[]){
+            //获取移动操作的数据--父级
+            List<ConstructionProjectTemporary> constructionProjectParent = new ArrayList<ConstructionProjectTemporary>();
+            //获取移动操作的数据--子集
+            List<ConstructionProjectTemporary> constructionProjectChild = new ArrayList<ConstructionProjectTemporary>();
+            for (String id:ids){
+                for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectTemporaries){
+                    if (id.equals(constructionProjectTemporary.getId())){
+                        if ("0".equals(constructionProjectTemporary.getParentId())){
+                            constructionProjectParent.add(constructionProjectTemporary);
+                        }else {
+                            constructionProjectChild.add(constructionProjectTemporary);
+                        }
+                        break;
+                    }
+                }
+            }
+            if (null!=constructionProjectParent && constructionProjectParent.size()>0){
+                for (ConstructionProjectTemporary projectTemporary:constructionProjectParent){
+                    for (ConstructionProjectTemporary temporary:constructionProjectTemporaries){
+                        if (temporary.getParentId().contains(projectTemporary.getId())){
+                            constructionProjectChild.add(temporary);
+                        }
+                    }
+                }
+            }
+            //去重
+            List<ConstructionProjectTemporary> qcConstruction = getQcConstruction(constructionProjectChild);//主
+            List<ConstructionProjectTemporary> qcConstructionCopy = getQcConstruction(constructionProjectChild);//备用
+            HashSet<String> hashSet = getHashSet(qcConstruction);//获取奴前存在的开关
+            getConstructionRecurse(qcConstructionCopy,hashSet);
+            //获取最终的集合
+            List<ConstructionProjectTemporary> returnConstructionProjectTemporary = getReturnConstructionProjectTemporary(constructionProjectTemporaries, hashSet);
+            //父类添加进入
+            for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectParent){
+                returnConstructionProjectTemporary.add(constructionProjectTemporary);
+            }
+            return returnConstructionProjectTemporary;
+        }
+        //获取确定的list<project>集合
+        public static List<ConstructionProjectTemporary> getReturnConstructionProjectTemporary(List<ConstructionProjectTemporary> constructionProjectTemporaries,HashSet<String> hashSetAll){
+            List<ConstructionProjectTemporary> constructionProjectTemporaryList = new ArrayList<ConstructionProjectTemporary>();
+            for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectTemporaries){
+               if (!"0".equals(constructionProjectTemporary.getParentId())){
+                   for (String string:hashSetAll){
+                       if (constructionProjectTemporary.getPowerScope().contains(string)){
+                           constructionProjectTemporaryList.add(constructionProjectTemporary);
+                           break;
+                       }
+                   }
+               }
+            }
+            return constructionProjectTemporaryList;
+        }
+        //递归
+        public static void getConstructionRecurse(List<ConstructionProjectTemporary> constructionProjectTemporaries,HashSet<String> hashSet){
+            HashSet<String> stringHashSet = new HashSet<String>();
+            for (String s:stringHashSet){
+                for (int i = 0; i < constructionProjectTemporaries.size(); i++) {
+                    if (constructionProjectTemporaries.get(i).getPowerScope().contains(s)){
+                        getSplice(constructionProjectTemporaries.get(i).getPowerScope(),stringHashSet);
+                        constructionProjectTemporaries.remove(i);
+                        i--;
+                    }
+                }
+            }
+            if (!stringHashSet.isEmpty()){
+                for (String string:stringHashSet){
+                    hashSet.add(string);
+                }
+                getConstructionRecurse(constructionProjectTemporaries,hashSet);
+            }
+        }
+
+        //获取目前的开关
+        public static HashSet<String> getHashSet(List<ConstructionProjectTemporary> constructionProjectTemporaries){
+            HashSet<String> stringHashSet = new HashSet<String>();
+            String[] powerScopes = null;
+            for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectTemporaries){
+                if (null!=constructionProjectTemporary.getPowerScope()){
+                    if (constructionProjectTemporary.getPowerScope().equals(";")){
+                        powerScopes = constructionProjectTemporary.getPowerScope().split(";");
+                        for (String power:powerScopes){
+                            stringHashSet.add(power);
+                        }
+                    }else if (constructionProjectTemporary.getPowerScope().equals(";")){
+                        powerScopes = constructionProjectTemporary.getPowerScope().split(";");
+                        for (String power:powerScopes){
+                            stringHashSet.add(power);
+                        }
+                    }else if (constructionProjectTemporary.getPowerScope().equals(",")){
+                        powerScopes = constructionProjectTemporary.getPowerScope().split(",");
+                        for (String power:powerScopes){
+                            stringHashSet.add(power);
+                        }
+                    }else if (constructionProjectTemporary.getPowerScope().equals(",")){
+                        powerScopes = constructionProjectTemporary.getPowerScope().split(",");
+                        for (String power:powerScopes){
+                            stringHashSet.add(power);
+                        }
+                    }else {
+                        stringHashSet.add(constructionProjectTemporary.getPowerScope());
+                    }
+                }
+            }
+            return stringHashSet;
+        }
+        //去重
+        public static List<ConstructionProjectTemporary> getQcConstruction(List<ConstructionProjectTemporary> constructionProjectTemporaries){
+            List<ConstructionProjectTemporary> constructionProjectTemporaryList = new ArrayList<ConstructionProjectTemporary>();
+            boolean flag = false;
+            for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectTemporaries){
+                flag = true;
+                for (ConstructionProjectTemporary projectTemporary:constructionProjectTemporaryList){
+                    if (constructionProjectTemporary.getId().equals(projectTemporary.getId())){
+                        flag = false;
+                    }
+                }
+                if (flag){
+                    constructionProjectTemporaryList.add(constructionProjectTemporary);
+                }
+            }
+            return constructionProjectTemporaryList;
+        }
+    //添加操作项目--------!
+}

+ 43 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/util/Result.java

@@ -0,0 +1,43 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util;
+
+import java.util.List;
+import java.util.Map;
+
+public class Result {
+    private boolean success;
+    private String  message;
+    private List<Map<String,Object>> mapList;
+    private List<Map<String,Object>> mapListTree;
+
+    public List<Map<String, Object>> getMapListTree() {
+        return mapListTree;
+    }
+
+    public void setMapListTree(List<Map<String, Object>> mapListTree) {
+        this.mapListTree = mapListTree;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public List<Map<String, Object>> getMapList() {
+        return mapList;
+    }
+
+    public void setMapList(List<Map<String, Object>> mapList) {
+        this.mapList = mapList;
+    }
+}

+ 152 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/util/TreeTableUtil.java

@@ -0,0 +1,152 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.modules.sg.managementcenter.constructionProject.entity.ConstructionProject;
+import com.jeeplus.modules.sg.managementcenter.constructionProject.entity.ConstructionProjectTemporary;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class TreeTableUtil {
+    //树生成
+    public static List<Map<String,Object>> getBootstrapTreeTable(List<Map<String,Object>> objects,List<ConstructionProjectTemporary> listTemporary){
+        Map<String,Object> maps = Maps.newHashMap();
+        boolean treeChild = false;
+        for (ConstructionProjectTemporary constructionProjectTemporary:listTemporary){
+            if ("0".equals(constructionProjectTemporary.getParentId())){
+                maps = Maps.newHashMap();
+                treeChild = getTreeChild(maps, listTemporary, constructionProjectTemporary.getId());
+                if (treeChild){
+                    maps.put("id",constructionProjectTemporary.getId());
+                    maps.put("name",constructionProjectTemporary.getProjectName());
+                    objects.add(maps);
+                }
+            }
+        }
+        return objects;
+    }
+    //子集
+    public static boolean  getTreeChild(Map<String,Object> maps,List<ConstructionProjectTemporary> constructionProjectTemporaries,String id){
+        boolean flag = false;
+        List<Map<String,Object>> lists = Lists.newArrayList();
+        Map<String,Object> mapList = null;
+        String[] split = null;//截取多个父类的集合
+        for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectTemporaries){
+            if (constructionProjectTemporary.getParentId().contains(",")){
+                split = constructionProjectTemporary.getParentId().split(",");
+                for (String string:split){
+                    if (string.equals(id)){
+                        mapList = Maps.newHashMap();
+                        mapList.put("id",constructionProjectTemporary.getId());
+                        mapList.put("name",constructionProjectTemporary.getProjectName());
+                        lists.add(mapList);
+                    }
+                }
+            }else {
+                if (constructionProjectTemporary.getParentId().equals(id)){
+                    mapList = Maps.newHashMap();
+                    mapList.put("id",constructionProjectTemporary.getId());
+                    mapList.put("name",constructionProjectTemporary.getProjectName());
+                    lists.add(mapList);
+                }
+            }
+        }
+        if (lists.size()>0){
+            flag = true;
+            maps.put("children",lists);
+        }
+        return flag;
+    }
+//    public static void getTreeChild(Map<String,Object> mapList,List<ConstructionProject> constructionProjects,String lineName){
+//        List<Map<String,Object>> lists = Lists.newArrayList();
+//        Map<String,Object> maps =Maps.newHashMap();
+//        for (ConstructionProject constructionProject:constructionProjects){
+//            if (lineName.equals(constructionProject.getLineName())){
+//                maps = Maps.newHashMap();
+//                maps.put("id",constructionProject.getId());
+//                maps.put("name",constructionProject.getProjectName());
+//                lists.add(maps);
+//            }
+//        }
+//        if (lists.size()>0){
+//            mapList.put("children",lists);
+//        }
+//    }
+    //获取月份
+    public static List<ConstructionProject> getMonths(List<ConstructionProject> constructionProjects,String time){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+        String arrangeTime = "";//安排计划
+        List<ConstructionProject> constructionProjectList = new ArrayList<ConstructionProject>();
+        for (ConstructionProject constructionProject:constructionProjects){
+            if (null!=constructionProject.getArrangeTime()){
+                arrangeTime = sdf.format(constructionProject.getArrangeTime());
+                if (arrangeTime.equals(time)){
+                    constructionProjectList.add(constructionProject);
+                }
+            }
+        }
+        return constructionProjectList;
+    }
+
+    //获取id类型
+    public static String getConstructionId(ConstructionProject constructionProject){
+        String projectId = "";
+        String cid= "";
+        String status = "";//状态默认为0
+        if (null!=constructionProject.getId()&&!"".equals(constructionProject.getId())){
+            cid = constructionProject.getId();
+            projectId = cid.substring(0,cid.length()-4);
+            if (cid.substring(cid.length()-4).equals("time")){
+                status = "time";
+            }
+            if (cid.substring(cid.length()-4).equals("line")){
+                status = "line";
+            }
+        }
+        if ("".equals(status)){
+            constructionProject.setId(constructionProject.getId());
+        }else {
+            constructionProject.setId(projectId);
+        }
+        return status;
+    }
+
+
+    //获取修改的值:
+    public static List<ConstructionProjectTemporary> getUpdateConstruction(List<ConstructionProjectTemporary> constructionProjectTemporaries){
+        for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectTemporaries){
+            //线路修改的状态
+            if ("0".equals(constructionProjectTemporary.getParentId())){
+                    constructionProjectTemporary.setStatus("2");
+//                getUpdateConstructionChild1(constructionProjectTemporaries,constructionProjectTemporary.getId());
+            }else {
+                if ("0".equals(constructionProjectTemporary.getStatus())){
+                    constructionProjectTemporary.setStatus("1");
+//                    getUpdateConstructionChild2(constructionProjectTemporaries,constructionProjectTemporary);
+                }
+            }
+        }
+        return constructionProjectTemporaries;
+    }
+    //线路修改的状态-----01
+    public static void getUpdateConstructionChild1(List<ConstructionProjectTemporary> constructionProjectTemporaries,String id){
+        for (ConstructionProjectTemporary constructionProjectTemporary:constructionProjectTemporaries){
+            if (!"0".equals(constructionProjectTemporary.getParentId())){
+                if (constructionProjectTemporary.getParentId().equals(id)){
+                    constructionProjectTemporary.setStatus("1");
+                }
+            }
+        }
+    }
+    //项目修改的状态----02
+    public static void getUpdateConstructionChild2(List<ConstructionProjectTemporary> constructionProjectTemporaries,ConstructionProjectTemporary constructionProjectTemporary){
+        String parentId = constructionProjectTemporary.getParentId();
+        for (ConstructionProjectTemporary project : constructionProjectTemporaries){
+            if (parentId.equals(project.getId())){
+                project.setStatus("2");
+                break;
+            }
+        }
+    }
+}