Forráskód Böngészése

暂时只开放剖宫产记录

rengb 4 éve
szülő
commit
e34cef1b39

+ 45 - 0
structure-center/src/main/java/com/lantone/structure/controller/StructureController.java

@@ -10,7 +10,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 
 @Api(value = "后结构化接口", tags = { "后结构化接口" })
 @RestController
@@ -26,4 +32,43 @@ public class StructureController {
         return RespDTO.onSuc(structureFacade.analysis(analysisVO));
     }
 
+    @ApiOperation(value = "解析")
+    @PostMapping("analysisTest")
+    public RespDTO<AnalysisDTO> analysisTest(@RequestParam("file") MultipartFile file, String type) {
+        AnalysisVO analysisVO = new AnalysisVO();
+        analysisVO.setType(type);
+        StringBuffer sbf = new StringBuffer();
+        InputStream is = null;
+        InputStreamReader ir = null;
+        BufferedReader br = null;
+        try {
+            is = file.getInputStream();
+            ir = new InputStreamReader(is);
+            br = new BufferedReader(ir);
+            String line = null;
+            while ((line = br.readLine()) != null) {
+                sbf.append(line);
+            }
+        } catch (Exception e) {
+
+        } finally {
+            try {
+                if (br != null) {
+                    br.close();
+                }
+                if (ir != null) {
+                    ir.close();
+                }
+                if (is != null) {
+                    is.close();
+                }
+            } catch (Exception e) {
+
+            }
+        }
+        analysisVO.setText(sbf.toString());
+        return RespDTO.onSuc(structureFacade.analysis(analysisVO));
+    }
+
+
 }

+ 5 - 0
structure-center/src/main/resources/bootstrap.yml

@@ -14,6 +14,11 @@ spring:
   profiles:
     active: local
 
+  servlet:
+    multipart:
+      max-request-size: 1MB
+      max-file-size: 1MB
+
 logging:
   config: classpath:logback-spring.xml