Browse Source

调用nlp返回结果

zhoutg 5 years ago
parent
commit
a9f3b8bc57

+ 4 - 0
config-server/src/main/resources/shared/ltkg-service-dev.yml

@@ -47,3 +47,7 @@ spring:
 mybatis:
   type-aliases-package: com.diagbot.entity
   mapper-locations: classpath:mapper/**/*.xml
+
+nlprel:
+  server:
+    address: http://192.168.3.150:3456

+ 5 - 1
config-server/src/main/resources/shared/ltkg-service-local.yml

@@ -46,4 +46,8 @@ spring:
 #mybatis
 mybatis:
   type-aliases-package: com.diagbot.entity
-  mapper-locations: classpath:mapper/**/*.xml
+  mapper-locations: classpath:mapper/**/*.xml
+
+nlprel:
+  server:
+    address: http://192.168.3.150:3456

+ 4 - 0
config-server/src/main/resources/shared/ltkg-service-pre.yml

@@ -47,3 +47,7 @@ spring:
 mybatis:
   type-aliases-package: com.diagbot.entity
   mapper-locations: classpath:mapper/**/*.xml
+
+nlprel:
+  server:
+    address: http://192.168.3.150:3456

+ 4 - 0
config-server/src/main/resources/shared/ltkg-service-pro.yml

@@ -47,3 +47,7 @@ spring:
 mybatis:
   type-aliases-package: com.diagbot.entity
   mapper-locations: classpath:mapper/**/*.xml
+
+nlprel:
+  server:
+    address: http://192.168.3.150:3456

+ 4 - 0
config-server/src/main/resources/shared/ltkg-service-test.yml

@@ -47,3 +47,7 @@ spring:
 mybatis:
   type-aliases-package: com.diagbot.entity
   mapper-locations: classpath:mapper/**/*.xml
+
+nlprel:
+  server:
+    address: http://192.168.3.150:3456

+ 19 - 0
ltkg-service/src/main/java/com/diagbot/client/NLPServiceClient.java

@@ -0,0 +1,19 @@
+package com.diagbot.client;
+
+import com.diagbot.client.hystrix.NLPServiceHystrix;
+import com.diagbot.vo.NlpVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * @Description:调用NLP对接层服务
+ * @Author:zhoutg
+ * @time: 2019/4/2 15:31
+ */
+@FeignClient(name = "NLPREL", url = "${nlprel.server.address}", fallback = NLPServiceHystrix.class)
+public interface NLPServiceClient {
+
+    @PostMapping(value = "/api/mr_info_ex/entity_predict")
+    String getNlp(@RequestBody NlpVO nlpVO);
+}

+ 23 - 0
ltkg-service/src/main/java/com/diagbot/client/hystrix/NLPServiceHystrix.java

@@ -0,0 +1,23 @@
+package com.diagbot.client.hystrix;
+
+import com.diagbot.client.NLPServiceClient;
+import com.diagbot.vo.NlpVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * @Description:调用NLP对接层服务
+ * @Author:zhoutg
+ * @time: 2019/4/2 15:36
+ */
+@Component
+@Slf4j
+public class NLPServiceHystrix implements NLPServiceClient {
+
+    @Override
+    public String getNlp(NlpVO nlpVO) {
+        log.error("【hystrix】调用{}异常", "getNlp");
+        return null;
+    }
+}

+ 21 - 0
ltkg-service/src/main/java/com/diagbot/facade/NlpFacade.java

@@ -0,0 +1,21 @@
+package com.diagbot.facade;
+
+import com.diagbot.client.NLPServiceClient;
+import com.diagbot.vo.NlpVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description: NLP实体识别和关系抽取API业务层
+ * @author: zhoutg
+ * @time: 2018/8/6 9:11
+ */
+@Component
+public class NlpFacade {
+    @Autowired
+    NLPServiceClient nlpServiceClient;
+
+    public String getNlp(NlpVO nlpVO) {
+        return nlpServiceClient.getNlp(nlpVO);
+    }
+}

+ 18 - 0
ltkg-service/src/main/java/com/diagbot/vo/NlpContent.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: zhoutg
+ * @time: 2020/3/16 9:47
+ */
+@Getter
+@Setter
+public class NlpContent {
+    private String medical_text_type;
+    private String content;
+    private String title;
+    private String detail_title;
+}

+ 17 - 0
ltkg-service/src/main/java/com/diagbot/vo/NlpVO.java

@@ -0,0 +1,17 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: zhoutg
+ * @time: 2020/3/16 9:47
+ */
+@Getter
+@Setter
+public class NlpVO {
+    private List<NlpContent> data;
+}

+ 39 - 0
ltkg-service/src/main/java/com/diagbot/web/NlpController.java

@@ -0,0 +1,39 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.NlpFacade;
+import com.diagbot.vo.NlpVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+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.RestController;
+
+/**
+ * @Description: nlp控制层
+ * @author: zhoutg
+ * @time: 2018/8/30 10:12
+ */
+@RestController
+@RequestMapping("/nlp")
+@Api(value = "NLP实体识别和关系抽取API", tags = { "NLP实体识别和关系抽取API" })
+@SuppressWarnings("unchecked")
+@Slf4j
+public class NlpController {
+
+    @Autowired
+    private NlpFacade nlpFacade;
+
+    @ApiOperation(value = "获取实体识别和关系抽取结果[zhoutg]", notes = "")
+    @PostMapping("/getNlp")
+    @SysLogger("getNlp")
+    public RespDTO<String> getNlp(@RequestBody NlpVO nlpVO) {
+        return RespDTO.onSuc(nlpFacade.getNlp(nlpVO));
+    }
+
+}
+