浏览代码

修改BUG

liuyc 3 年之前
父节点
当前提交
0f9a105249

+ 9 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/ProjectAssignmentWbstreeDTO.java

@@ -49,4 +49,13 @@ public class ProjectAssignmentWbstreeDTO extends ProjectAssignmentWbstree {
     private String wbsTreeIds;
 
 
+    @JsonProperty(value = "wbsPrivateProjectTableName")
+    @ApiModelProperty(name = "wbsPrivateProjectTableName", value = "wbs私有库表名(用于后续入参)", required = true)
+    private String wbsPrivateProjectTableName;
+
+
+
+
+
+
 }

+ 4 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ProjectAssignmentWbstree.java

@@ -3,8 +3,10 @@ package org.springblade.manager.entity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 import org.springblade.core.mp.base.BaseEntity;
 
 
@@ -19,6 +21,8 @@ import org.springblade.core.mp.base.BaseEntity;
 @Data
 @TableName("m_project_assignment_wbstree")
 @EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
 public class ProjectAssignmentWbstree extends BaseEntity {
     private static final long serialVersionUID = 1L;
 

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeMapper.xml

@@ -69,7 +69,7 @@
     </insert>
 
     <insert id="insertToNewWbsTreeTable">
-        INSERT INTO #{tableName}(
+        INSERT INTO ${tableName}(
         id,wbs_id,tenant_id,parent_id,ancestors,dept_category,dept_name,full_name,sort,remark,`type`,
         table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
         unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name)

+ 6 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -231,9 +231,10 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
         String tableName = "m_wbs_tree_" + pawDTO.getProjectId() + "_" + DateUtil.time();
         //初始化创建wbs项目级私有节点表
         wbsTreeMapper.createWbsTreeTable(tableName);
-        //获取节点ids,查询出所有节点树
+        //此处返回表名,用于后续接口入参
+        pawDTO.setWbsPrivateProjectTableName(tableName);
+        //获取节点ids,查询出所需节点树
         List<WbsTree> list = findAllNodeList(wbsTreeIds);
-
         if (list != null) {
             list.forEach(System.out::print);
             //新增节点
@@ -243,10 +244,12 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     System.out.println("新增节点成功,节点id: ----- " + wbsTree.getId());
                 }
             }
-
         }
         //初始化创建合同段私有wbs树
 
+
+
+
         return true;
     }
 

+ 34 - 0
blade-service/blade-manager/src/main/test/TestDemo.java

@@ -0,0 +1,34 @@
+import org.apache.commons.lang.StringUtils;
+import org.junit.Test;
+import org.springblade.core.tool.utils.DigestUtil;
+import org.springblade.manager.entity.WbsTree;
+import org.springframework.util.DigestUtils;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestDemo {
+
+
+    @Test
+    public void testDemo() {
+        String password = "10470c3b4b1fed12c3baac014be15fac67c6e815";
+        String s = DigestUtils.md5DigestAsHex(password.getBytes());
+        System.out.println(s);
+    }
+
+    @Test
+    public void testDemo2() {
+        String[] ids = {"1", "2", "3"};
+        List<WbsTree> idList = new ArrayList<>();
+        for (String id : ids) {
+            WbsTree wbsTree = new WbsTree();
+            wbsTree.setId(Long.valueOf(id));
+            idList.add(wbsTree);
+        }
+        System.out.println(idList);
+    }
+
+
+}

+ 303 - 0
blade-service/blade-manager/src/main/test/WbsExcelUtil.java

@@ -0,0 +1,303 @@
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class WbsExcelUtil {
+    public static void main(String[] args) {
+        WbsExcelUtil excelUtil = new WbsExcelUtil();
+        //读取excel数据
+        ArrayList<Map<String, String>> result = excelUtil.readExcelToObj("D:\\Download\\WBS划分模板1.xls");
+        for (Map<String, String> map : result) {
+            System.out.println("输出:" + map);
+        }
+    }
+
+    /**
+     * 读取excel数据
+     *
+     * @param path
+     */
+    public ArrayList<Map<String, String>> readExcelToObj(String path) {
+
+        Workbook wb = null;
+        ArrayList<Map<String, String>> result = null;
+        try {
+            wb = WorkbookFactory.create(new File(path));
+            result = readExcel(wb, 0, 1, 0);
+        } catch (InvalidFormatException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    /**
+     * 读取excel文件
+     *
+     * @param wb
+     * @param sheetIndex    sheet页下标:从0开始
+     * @param startReadLine 开始读取的行:从0开始
+     * @param tailLine      去除最后读取的行
+     */
+    private ArrayList<Map<String, String>> readExcel(Workbook wb, int sheetIndex, int startReadLine, int tailLine) {
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        Row row = null;
+        ArrayList<Map<String, String>> result = new ArrayList<Map<String, String>>();
+        for (int i = startReadLine; i < sheet.getLastRowNum() - tailLine + 1; i++) {
+
+            row = sheet.getRow(i);
+            Map<String, String> map = new HashMap<String, String>();
+            for (Cell c : row) {
+                String returnStr = "";
+                boolean isMerge = isMergedRegion(sheet, i, c.getColumnIndex());
+                //判断是否具有合并单元格
+                if (isMerge) {
+                    String rs = getMergedRegionValue(sheet, row.getRowNum(), c.getColumnIndex());
+//                    System.out.print(rs + "------ ");
+                    returnStr = rs;
+                } else {
+//                    System.out.print(c.getRichStringCellValue()+"++++ ");
+                    returnStr = c.getRichStringCellValue().getString();
+                }
+                if (c.getColumnIndex() == 0) {
+                    map.put("1", returnStr);
+                } else if (c.getColumnIndex() == 1) {
+                    map.put("2", returnStr);
+                } else if (c.getColumnIndex() == 2) {
+                    map.put("3", returnStr);
+                } else if (c.getColumnIndex() == 3) {
+                    map.put("4", returnStr);
+                } else if (c.getColumnIndex() == 4) {
+                    map.put("5", returnStr);
+                } else if (c.getColumnIndex() == 5) {
+                    map.put("6", returnStr);
+                }
+            }
+            result.add(map);
+        }
+        return result;
+    }
+
+    /**
+     * 获取合并单元格的值
+     *
+     * @param sheet
+     * @param row
+     * @param column
+     * @return
+     */
+    public String getMergedRegionValue(Sheet sheet, int row, int column) {
+        int sheetMergeCount = sheet.getNumMergedRegions();
+        for (int i = 0; i < sheetMergeCount; i++) {
+            CellRangeAddress ca = sheet.getMergedRegion(i);
+            int firstColumn = ca.getFirstColumn();
+            int lastColumn = ca.getLastColumn();
+            int firstRow = ca.getFirstRow();
+            int lastRow = ca.getLastRow();
+            if (row >= firstRow && row <= lastRow) {
+                if (column >= firstColumn && column <= lastColumn) {
+                    Row fRow = sheet.getRow(firstRow);
+                    Cell fCell = fRow.getCell(firstColumn);
+                    return getCellValue(fCell);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 判断合并了行
+     *
+     * @param sheet
+     * @param row
+     * @param column
+     * @return
+     */
+    private boolean isMergedRow(Sheet sheet, int row, int column) {
+        int sheetMergeCount = sheet.getNumMergedRegions();
+        for (int i = 0; i < sheetMergeCount; i++) {
+            CellRangeAddress range = sheet.getMergedRegion(i);
+            int firstColumn = range.getFirstColumn();
+            int lastColumn = range.getLastColumn();
+            int firstRow = range.getFirstRow();
+            int lastRow = range.getLastRow();
+            if (row == firstRow && row == lastRow) {
+                if (column >= firstColumn && column <= lastColumn) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 判断指定的单元格是否是合并单元格
+     *
+     * @param sheet
+     * @param row    行下标
+     * @param column 列下标
+     * @return
+     */
+    private boolean isMergedRegion(Sheet sheet, int row, int column) {
+        int sheetMergeCount = sheet.getNumMergedRegions();
+        for (int i = 0; i < sheetMergeCount; i++) {
+            CellRangeAddress range = sheet.getMergedRegion(i);
+            int firstColumn = range.getFirstColumn();
+            int lastColumn = range.getLastColumn();
+            int firstRow = range.getFirstRow();
+            int lastRow = range.getLastRow();
+            if (row >= firstRow && row <= lastRow) {
+                if (column >= firstColumn && column <= lastColumn) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 判断sheet页中是否含有合并单元格
+     *
+     * @param sheet
+     * @return
+     */
+    private boolean hasMerged(Sheet sheet) {
+        return sheet.getNumMergedRegions() > 0 ? true : false;
+    }
+
+    /**
+     * 合并单元格
+     *
+     * @param sheet
+     * @param firstRow 开始行
+     * @param lastRow  结束行
+     * @param firstCol 开始列
+     * @param lastCol  结束列
+     */
+    private void mergeRegion(Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) {
+        sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol));
+    }
+
+    /**
+     * 获取单元格的值
+     *
+     * @param cell
+     * @return
+     */
+    public String getCellValue(Cell cell) {
+
+        if (cell == null) return "";
+
+        if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
+
+            return cell.getStringCellValue();
+
+        } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
+
+            return String.valueOf(cell.getBooleanCellValue());
+
+        } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+
+            return cell.getCellFormula();
+
+        } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+
+            return String.valueOf(cell.getNumericCellValue());
+
+        }
+        return "";
+    }
+
+    /**
+     * 从excel读取内容
+     */
+    public static void readContent(String fileName) {
+        boolean isE2007 = false;    //判断是否是excel2007格式
+        if (fileName.endsWith("xlsx"))
+            isE2007 = true;
+        try {
+            InputStream input = new FileInputStream(fileName);  //建立输入流
+            Workbook wb = null;
+            //根据文件格式(2003或者2007)来初始化
+            if (isE2007)
+                wb = new XSSFWorkbook(input);
+            else
+                wb = new HSSFWorkbook(input);
+            Sheet sheet = wb.getSheetAt(0);     //获得第一个表单
+            Iterator<Row> rows = sheet.rowIterator(); //获得第一个表单的迭代器
+            while (rows.hasNext()) {
+                Row row = rows.next();  //获得行数据
+                System.out.println("Row #" + row.getRowNum());  //获得行号从0开始
+                Iterator<Cell> cells = row.cellIterator();    //获得第一行的迭代器
+                while (cells.hasNext()) {
+                    Cell cell = cells.next();
+                    System.out.println("Cell #" + cell.getColumnIndex());
+                    switch (cell.getCellType()) {   //根据cell中的类型来输出数据
+                        case HSSFCell.CELL_TYPE_NUMERIC:
+                            System.out.println(cell.getNumericCellValue());
+                            break;
+                        case HSSFCell.CELL_TYPE_STRING:
+                            System.out.println(cell.getStringCellValue());
+                            break;
+                        case HSSFCell.CELL_TYPE_BOOLEAN:
+                            System.out.println(cell.getBooleanCellValue());
+                            break;
+                        case HSSFCell.CELL_TYPE_FORMULA:
+                            System.out.println(cell.getCellFormula());
+                            break;
+                        default:
+                            System.out.println("unsuported sell type=======" + cell.getCellType());
+                            break;
+                    }
+                }
+            }
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    /**
+     * 获取path路径
+     *
+     * @param file
+     * @return
+     * @throws IOException
+     */
+    public static File convert(MultipartFile file) throws IOException {
+        File convFile = new File(file.getOriginalFilename());
+        convFile.createNewFile();
+        try (InputStream is = file.getInputStream()) {
+            Files.copy(is, convFile.toPath());
+        }
+        return convFile;
+    }
+
+    /**
+     * 获取path路径
+     *
+     * @param file
+     * @return
+     * @throws IOException
+     */
+    public static File convert1(MultipartFile file) throws IOException {
+        File convFile = new File(file.getOriginalFilename());
+        convFile.createNewFile();
+        FileOutputStream fos = new FileOutputStream(convFile);
+        fos.write(file.getBytes());
+        fos.close();
+        return convFile;
+
+    }
+}