Ver código fonte

Merge remote-tracking branch 'origin/release' into release

lwhhszx 2 anos atrás
pai
commit
93f02bd2a2

+ 15 - 6
PAS/src/main/java/cn/cslg/pas/controller/PatentInstructionController.java

@@ -26,6 +26,7 @@ import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -84,12 +85,20 @@ public class PatentInstructionController {
     @Operation(summary = "获取说明书文件流")
     public void pdfFile(String patentNo, Integer type, HttpServletResponse response) {
         try {
-            PatentInstruction patentInstruction = patentInstructionService.getPatentInstructionByPatentNoAndType(patentNo, type);
-            if (patentInstruction != null) {
-                response.setHeader("Content-Disposition", "attachment;filename=" + patentInstruction.getFileName());
-                ServletOutputStream out = response.getOutputStream();
-                out.write(FileUtil.readBytes(fileUtils.getSystemPath(patentInstruction.getUrl())));
-                IoUtil.close(out);
+            List<PatentInstruction> patentInstruction = patentInstructionService.getPatentInstructionByPatentNoAndType2(patentNo, type);
+            if (patentInstruction != null && patentInstruction.size() != 0) {
+                if (type ==2 ) {
+                    response.setHeader("Content-Disposition", "attachment;filename=" + patentInstruction.get(patentInstruction.size()-1).getFileName());
+                    ServletOutputStream out = response.getOutputStream();
+                    out.write(FileUtil.readBytes(fileUtils.getSystemPath(patentInstruction.get(patentInstruction.size()-1).getUrl())));
+                    IoUtil.close(out);
+                } else if (type == 1) {
+                    response.setHeader("Content-Disposition", "attachment;filename=" + patentInstruction.get(0).getFileName());
+                    ServletOutputStream out = response.getOutputStream();
+                    out.write(FileUtil.readBytes(fileUtils.getSystemPath(patentInstruction.get(0).getUrl())));
+                    IoUtil.close(out);
+                }
+
             }
         } catch (Exception e) {
             e.printStackTrace();

+ 36 - 3
PAS/src/main/java/cn/cslg/pas/service/PatentInstructionService.java

@@ -31,6 +31,8 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 /**
@@ -65,9 +67,20 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
     }
 
     public List<PatentInstruction> getPatentInstructionByPatentNo(String patentNo) {
-        LambdaQueryWrapper<PatentInstruction> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(PatentInstruction::getPatentNo, patentNo);
-        return this.list(queryWrapper);
+        StringBuilder str = new StringBuilder(patentNo);
+        Matcher matcher = Pattern.compile("[A-Za-z]").matcher(str.reverse());
+        String patentNoByProcess;
+        if (matcher.find()) {
+            StringBuilder reverse = new StringBuilder(str.substring(matcher.start() + 1, str.length())).reverse();
+            patentNoByProcess = reverse.toString();
+            LambdaQueryWrapper<PatentInstruction> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.like(PatentInstruction::getPatentNo, patentNoByProcess);
+            return this.list(queryWrapper);
+        } else {
+            LambdaQueryWrapper<PatentInstruction> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(PatentInstruction::getPatentNo, patentNo);
+            return this.list(queryWrapper);
+        }
     }
 
     public List<PatentInstruction> getPatentInstructionByPatentNo(List<String> patentNo) {
@@ -86,6 +99,26 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
         return this.getOne(queryWrapper);
     }
 
+    public List<PatentInstruction> getPatentInstructionByPatentNoAndType2(String patentNo, Integer type) {
+        StringBuilder str = new StringBuilder(patentNo);
+        Matcher matcher = Pattern.compile("[A-Za-z]").matcher(str.reverse());
+        String patentNoByProcess;
+        if (matcher.find()) {
+            StringBuilder reverse = new StringBuilder(str.substring(matcher.start() + 1, str.length())).reverse();
+            patentNoByProcess = reverse.toString();
+            LambdaQueryWrapper<PatentInstruction> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(PatentInstruction::getType, type);
+            queryWrapper.like(PatentInstruction::getPatentNo, patentNoByProcess);
+            return this.list(queryWrapper);
+        } else {
+            LambdaQueryWrapper<PatentInstruction> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(PatentInstruction::getType, type);
+            queryWrapper.eq(PatentInstruction::getPatentNo, patentNo);
+            return this.list(queryWrapper);
+        }
+    }
+
+
     @Async("singleThreadAsyncTaskExecutor")
     @Transactional(rollbackFor = Exception.class)
     public void batchUpload(String url, Integer type, String remark, Integer userId) {

+ 4 - 5
PAS/src/main/java/cn/cslg/pas/service/PatentSimpleFamilyService.java

@@ -39,12 +39,11 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
         LambdaQueryWrapper<PatentSimpleFamily> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(PatentSimpleFamily::getId, ids);
         queryWrapper.eq(PatentSimpleFamily::getType, type);
-        PatentSimpleFamily  patentSimpleFamily =new PatentSimpleFamily();
-        List<PatentSimpleFamily> patentSimpleFamilies =this.list(queryWrapper);
-        if(patentSimpleFamilies!=null&&patentSimpleFamilies.size()!=0){
-             patentSimpleFamily =patentSimpleFamilies.get(0);
+        List<PatentSimpleFamily> patentSimpleFamilies = this.list(queryWrapper);
+        if (patentSimpleFamilies.size() == 0) {
+            return null;
         }
-        return patentSimpleFamily;
+        return patentSimpleFamilies.get(0);
     }
 
     public List<PatentSimpleFamily> getPatentSimpleFamilyByIds(List<Integer> ids) {