소스 검색

Excel导入检查合法性逻辑完善、拆分权要保证权要完整性

chendayu 2 년 전
부모
커밋
5a3968d8d8

+ 4 - 1
PAS/src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java

@@ -308,7 +308,10 @@ public class PatentRightUtils {
 
             return patentRights;
         } catch (Exception e) {
-            return new ArrayList<>();
+            e.printStackTrace();
+            ArrayList<PatentRight> patentRights = new ArrayList<>();
+            patentRights.add(new PatentRight().setPatentId(params.getPatentId()).setContent(params.getContent()).setContentOut(params.getContentOut()).setType(1).setSort(0).setParentSort("-1"));
+            return patentRights;
         }
     }
 

+ 12 - 6
PAS/src/main/java/cn/cslg/pas/common/utils/ReadExcelUtils.java

@@ -3,10 +3,7 @@ package cn.cslg.pas.common.utils;
 import cn.cslg.pas.domain.PatentData;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ooxml.POIXMLDocumentPart;
-import org.apache.poi.ss.usermodel.PictureData;
-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.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
 import org.springframework.stereotype.Service;
@@ -61,9 +58,18 @@ public class ReadExcelUtils {
             ThrowException.throwXiaoShiException("文件内容格式不正确,请检查总行数是否有专利内容");
         }
 
+        //获取第一行
         Row firstRow = sheet.getRow(0);
-        if (!firstRow.getCell(0).getStringCellValue().equals("公开(公告)号")) {
-            ThrowException.throwXiaoShiException("文件内容格式不正确,第一列应为【公开(公告)号】");
+        boolean flag = false;
+        //遍历第一行单元格,若第一行有单元格内容是 "公开(公告)号" 则文件合法
+        for (Cell cell : firstRow) {
+            if (cell.getStringCellValue().equals("公开(公告)号")) {
+                flag = true;
+                break;
+            }
+        }
+        if (!flag) {
+            ThrowException.throwXiaoShiException("文件内容格式不正确,第一行抬头未找到【公开(公告)号】");
         }
 
         //返回文件总行数-1(即专利总数量)