hongchuangyanfa 2 سال پیش
والد
کامیت
fb2f7a4700
1فایلهای تغییر یافته به همراه149 افزوده شده و 113 حذف شده
  1. 149 113
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

+ 149 - 113
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1049,7 +1049,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     @Override
     public R getBussPdfInfo(Long pkeyId) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-       // String file_path = "/Users/hongchuangyanfa/Desktop/";
+        //String file_path = "/Users/hongchuangyanfa/Desktop/";
 
         WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
                 .eq(WbsTreeContract::getPKeyId, pkeyId));
@@ -1096,12 +1096,33 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             if (xx == all) {
                 int fisRow = mergedCell.getFirstRow();
                 int firsrCol = mergedCell.getFirstColumn();
+
                 Cell cell = sheet.getRow(fisRow).getCell(firsrCol);
                 short fontIndex = cell.getCellStyle().getFontIndex();
-                Font fontAt = workbook.getFontAt(fontIndex);
-                short fontHeightInPoints = fontAt.getFontHeightInPoints();
+
+                Font oldfontAt = workbook.getFontAt(fontIndex);
+
+                Font redFont = workbook.createFont();
+                redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
+                redFont.setFontName(oldfontAt.getFontName());//设置字体
+
+                CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+                newStyle.cloneStyleFrom(cell.getCellStyle());
+
+
+
+                short fontHeightInPoints = redFont.getFontHeightInPoints();
                 if (fontHeightInPoints >= 14 && StringUtils.isEmpty(cell.getStringCellValue()) && fisRow<=8) {
-                    cell.setCellValue(projectInfo.getProjectName());
+
+                    String title=projectInfo.getProjectName();
+                    if(title.length()>=44){
+                        sheet.getRow(fisRow).setHeight((short)900);
+                        newStyle.setWrapText(true);
+                    }
+                    redFont.setBold(true);
+                    newStyle.setFont(redFont);
+                    cell.setCellStyle(newStyle);
+                    cell.setCellValue(title);
                     break;
                 }
             }
@@ -1122,90 +1143,98 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         if (val.indexOf("__") >= 0) {
                             String[] DataVal = val.split("__");
                             String[] xy = DataVal[1].split("_");
-
-                            Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
-
-                            if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
-                                int x1 = 0;
-                                int x2 = 0;
-                                int y1 = 0;
-                                int y2 = 0;
-
-                                if (data.html().indexOf("el-tooltip") >= 0) {
-                                    x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
-                                    x2 = Integer.parseInt(data.children().get(0).children().get(0).attr("x2"));
-                                    y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
-                                } else {
-                                    x1 = Integer.parseInt(data.children().get(0).attr("x1"));
-                                    y1 = Integer.parseInt(data.children().get(0).attr("y1"));
-                                }
-                                if (x1 == 0) {
-                                    x1 = 1;
-                                }
-                                String myData = DataInfo.get(val) + "";
-                                if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
-                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-                                    sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
-                                    SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
-                                    if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
-
-                                        myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
-                                        String[] dataVal = myData.split(",");
-
-                                        Date Start_dataStr = sdf.parse(dataVal[0]);
-                                        Date end_dataStr = sdf.parse(dataVal[1]);
-                                        String StartDate = formatStr.format(Start_dataStr);
-                                        String endDate = formatStr.format(end_dataStr);
-                                        if (StartDate.equals(endDate)) {
-                                            myData = StartDate;
-                                        } else {
-                                            myData = StartDate + "-" + endDate;
-                                        }
-                                    } else {
-                                        String[] dataStr = myData.split("T")[0].split("-");
-                                        myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
-                                    }
-                                }
-                                //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
-                                if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
-
-                                    InputStream imageIn = CommonUtil.getOSSInputStream(myData);
-                                    byte[] bytes = IOUtils.toByteArray(imageIn);
-                                    // 这里根据实际需求选择图片类型
-                                    int pictureIdx = workbook.addPicture(bytes, 6);
-
-                                    CreationHelper helper = workbook.getCreationHelper();
-                                    ClientAnchor anchor = helper.createClientAnchor();
-                                    anchor.setCol1(x1); // param1是列号
-                                    anchor.setCol2(x2);
-                                    anchor.setRow1(y1); // param2是行号
-                                    anchor.setRow2(y2); // param2是行号
-                                    //
-                                    Drawing drawing = sheet.createDrawingPatriarch();
-                                    anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
-                                    // 插入图片
-                                    Picture pict = drawing.createPicture(anchor, pictureIdx); // 调整图片占单元格百分比的大小,1.0就是100%
-                                    pict.resize(1, 1);
-                                    FileUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
-
-                                } else if (myData.equals("1") && data.html().indexOf("hc-form-checkbox-group") >= 0) {
-                                    Row row = sheet.getRow(y1 - 1);
-                                    if(row!=null){
-                                        Cell cell = row.getCell(x1 - 1);
-                                        if(cell!=null || ObjectUtils.isNotEmpty(cell)) {
-                                            String exceVal = cell.getStringCellValue().replaceAll(" ", "");
-                                            short fontIndex = cell.getCellStyle().getFontIndex();
-                                            Font fontAt = workbook.getFontAt(fontIndex);
-                                            fontAt.setFontName("EUDC");
-                                            cell.setCellValue(exceVal.replace("□", "\u2611"));
-                                        }
-                                    }
-                                } else {
-                                    Row row = sheet.getRow(y1 - 1);
-                                    if(row!=null){
-                                        Cell cell = row.getCell(x1 - 1);
-                                        if(cell!=null || ObjectUtils.isNotEmpty(cell)){
-                                            cell.setCellValue(myData);
+                            if (Integer.parseInt(xy[0])<trs.size()) {
+                                Element ytzData = trs.get(Integer.parseInt(xy[0]));
+                                if (ytzData != null) {
+                                    Elements tdsx = ytzData.select("td");
+                                    if (Integer.parseInt(xy[1]) < tdsx.size()) {
+                                        Element data = ytzData.select("td").get(Integer.parseInt(xy[1]));
+                                        if (data != null) {
+                                            if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
+                                                int x1 = 0;
+                                                int x2 = 0;
+                                                int y1 = 0;
+                                                int y2 = 0;
+
+                                                if (data.html().indexOf("el-tooltip") >= 0) {
+                                                    x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
+                                                    x2 = Integer.parseInt(data.children().get(0).children().get(0).attr("x2"));
+                                                    y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
+                                                } else {
+                                                    x1 = Integer.parseInt(data.children().get(0).attr("x1"));
+                                                    y1 = Integer.parseInt(data.children().get(0).attr("y1"));
+                                                }
+                                                if (x1 == 0) {
+                                                    x1 = 1;
+                                                }
+                                                String myData = DataInfo.get(val) + "";
+                                                if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
+                                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+                                                    sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
+                                                    SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
+                                                    if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
+
+                                                        myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
+                                                        String[] dataVal = myData.split(",");
+
+                                                        Date Start_dataStr = sdf.parse(dataVal[0]);
+                                                        Date end_dataStr = sdf.parse(dataVal[1]);
+                                                        String StartDate = formatStr.format(Start_dataStr);
+                                                        String endDate = formatStr.format(end_dataStr);
+                                                        if (StartDate.equals(endDate)) {
+                                                            myData = StartDate;
+                                                        } else {
+                                                            myData = StartDate + "-" + endDate;
+                                                        }
+                                                    } else {
+                                                        String[] dataStr = myData.split("T")[0].split("-");
+                                                        myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
+                                                    }
+                                                }
+                                                //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
+                                                if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
+
+                                                    InputStream imageIn = CommonUtil.getOSSInputStream(myData);
+                                                    byte[] bytes = IOUtils.toByteArray(imageIn);
+                                                    // 这里根据实际需求选择图片类型
+                                                    int pictureIdx = workbook.addPicture(bytes, 6);
+
+                                                    CreationHelper helper = workbook.getCreationHelper();
+                                                    ClientAnchor anchor = helper.createClientAnchor();
+                                                    anchor.setCol1(x1); // param1是列号
+                                                    anchor.setCol2(x2);
+                                                    anchor.setRow1(y1); // param2是行号
+                                                    anchor.setRow2(y2); // param2是行号
+                                                    //
+                                                    Drawing drawing = sheet.createDrawingPatriarch();
+                                                    anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
+                                                    // 插入图片
+                                                    Picture pict = drawing.createPicture(anchor, pictureIdx); // 调整图片占单元格百分比的大小,1.0就是100%
+                                                    pict.resize(1, 1);
+                                                    FileUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
+
+                                                } else if (myData.equals("1") && data.html().indexOf("hc-form-checkbox-group") >= 0) {
+                                                    Row row = sheet.getRow(y1 - 1);
+                                                    if (row != null) {
+                                                        Cell cell = row.getCell(x1 - 1);
+                                                        if (cell != null || ObjectUtils.isNotEmpty(cell)) {
+                                                            String exceVal = cell.getStringCellValue().replaceAll(" ", "");
+                                                            short fontIndex = cell.getCellStyle().getFontIndex();
+                                                            Font fontAt = workbook.getFontAt(fontIndex);
+                                                            fontAt.setFontName("EUDC");
+                                                            cell.setCellValue(exceVal.replace("□", "\u2611"));
+                                                        }
+                                                    }
+                                                } else {
+                                                    Row row = sheet.getRow(y1 - 1);
+                                                    if (row != null) {
+                                                        Cell cell = row.getCell(x1 - 1);
+                                                        if (cell != null || ObjectUtils.isNotEmpty(cell)) {
+                                                            cell.setCellValue(myData);
+                                                        }
+                                                    }
+                                                }
+                                            }
                                         }
                                     }
                                 }
@@ -1225,32 +1254,39 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         String key = e.getColKey();
                         String[] keys = key.split("__");
                         String[] trtd = keys[1].split("_");
-                        Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
-                        int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
-                        if (x1 == 0) {
-                            x1 = 1;
-                        }
-                        int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
+                        if (Integer.parseInt(trtd[0])<trs.size()) {
+                            Element ytzData = trs.get(Integer.parseInt(trtd[0]));
+                            if (ytzData != null) {
+                                Elements tdsx = ytzData.select("td");
+                                if (Integer.parseInt(trtd[1])<tdsx.size()) {
+                                    Element data = ytzData.select("td").get(Integer.parseInt(trtd[1]));
+                                    int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
+                                    if (x1 == 0) {
+                                        x1 = 1;
+                                    }
+                                    int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
 
-                        Row row = sheet.getRow(y1 - 1);
-                        if(row!=null){
-                            Cell cell = sheet.getRow(y1-1).getCell(x1-1);
-                            if(cell!=null || ObjectUtils.isNotEmpty(cell)){
-                                short fontIndex = cell.getCellStyle().getFontIndex();
-                                Font oldfontAt = workbook.getFontAt(fontIndex);
-
-                                Font redFont = workbook.createFont();
-                                redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
-                                redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
-                                redFont.setFontName(oldfontAt.getFontName());//设置字体
-
-                                CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
-                                newStyle.cloneStyleFrom(cell.getCellStyle());
-                                newStyle.setFont(redFont);
-                                cell.setCellStyle(newStyle);
-                                cell.setCellValue(e.getId() + "");
+                                    Row row = sheet.getRow(y1 - 1);
+                                    if (row != null) {
+                                        Cell cell = sheet.getRow(y1 - 1).getCell(x1 - 1);
+                                        if (cell != null || ObjectUtils.isNotEmpty(cell)) {
+                                            short fontIndex = cell.getCellStyle().getFontIndex();
+                                            Font oldfontAt = workbook.getFontAt(fontIndex);
+
+                                            Font redFont = workbook.createFont();
+                                            redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
+                                            redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
+                                            redFont.setFontName(oldfontAt.getFontName());//设置字体
+
+                                            CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+                                            newStyle.cloneStyleFrom(cell.getCellStyle());
+                                            newStyle.setFont(redFont);
+                                            cell.setCellStyle(newStyle);
+                                            cell.setCellValue(e.getId() + "");
+                                        }
+                                    }
+                                }
                             }
-
                         }
                     }
                 }
@@ -1316,7 +1352,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     @Override
     public void getBussPdfs(String nodeId, String classify, String contractId, String projectId) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-        //String file_path = "/Users/hongchuangyanfa/Desktop/";
+       // String file_path = "/Users/hongchuangyanfa/Desktop/";
         // 获取有权限的节点信息
         List<AppWbsTreeContractVO> wbsTreeContractList = wbsTreeContractService.searchNodeAllTable(nodeId, classify, contractId, projectId);
         List<String> data = new ArrayList<>();