Эх сурвалжийг харах

保存电签证书空指针

cr 1 өдөр өмнө
parent
commit
73b0b0bd5c

+ 33 - 31
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/SignPfxFilePreServiceImpl.java

@@ -132,39 +132,41 @@ public class SignPfxFilePreServiceImpl implements ISignPfxFilePreService {
             if (table != null) {
                 dqids = table.getElementsByAttribute("dqid");
             }
-            for (Element element : dqids) {
-                String dqid = element.attr("dqid");
-                Elements x11 = element.getElementsByAttribute("x1");
-                if (x11 != null && x11.size() >= 1) {
-                    Element element1 = x11.get(x11.size() - 1);
-                    int x1 = Func.toInt(element1.attr("x1"));
-                    int y1 = Func.toInt(element1.attr("y1"));
-                    Row row = sheet.getRow(y1 - 1);
-                    if (row != null) {
-                        Cell cell = row.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(Short.valueOf("1"));//设置字体大小
-                            redFont.setFontName(oldfontAt.getFontName());//设置字体
-                            String CellValue = cell.getStringCellValue().trim();
+            if (dqids != null) {
+                for (Element element : dqids) {
+                    String dqid = element.attr("dqid");
+                    Elements x11 = element.getElementsByAttribute("x1");
+                    if (x11 != null && x11.size() >= 1) {
+                        Element element1 = x11.get(x11.size() - 1);
+                        int x1 = Func.toInt(element1.attr("x1"));
+                        int y1 = Func.toInt(element1.attr("y1"));
+                        Row row = sheet.getRow(y1 - 1);
+                        if (row != null) {
+                            Cell cell = row.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(Short.valueOf("1"));//设置字体大小
+                                redFont.setFontName(oldfontAt.getFontName());//设置字体
+                                String CellValue = cell.getStringCellValue().trim();
 
-                            CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
-                            newStyle.cloneStyleFrom(cell.getCellStyle());
-                            newStyle.setFont(redFont);
-                            newStyle.setShrinkToFit(true);
-                            cell.setCellStyle(newStyle);
-                            if(dqid.contains("||")){
-                                String[] split = dqid.split("\\|\\|");
-                                for (String singleDqid : split) {
-                                    cell.setCellValue(singleDqid);
-                                    sign.add(singleDqid);
+                                CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+                                newStyle.cloneStyleFrom(cell.getCellStyle());
+                                newStyle.setFont(redFont);
+                                newStyle.setShrinkToFit(true);
+                                cell.setCellStyle(newStyle);
+                                if(dqid.contains("||")){
+                                    String[] split = dqid.split("\\|\\|");
+                                    for (String singleDqid : split) {
+                                        cell.setCellValue(singleDqid);
+                                        sign.add(singleDqid);
+                                    }
+                                }else {
+                                    cell.setCellValue(dqid);
+                                    sign.add(dqid);
                                 }
-                            }else {
-                                cell.setCellValue(dqid);
-                                sign.add(dqid);
                             }
                         }
                     }