Browse Source

fix 修改接口

DYH2020 1 năm trước cách đây
mục cha
commit
068dabbcf1

+ 69 - 10
consumer/src/main/java/com/ywt/controller/Consumer.java

@@ -1,27 +1,86 @@
 package com.ywt.controller;
 
-import com.ywt.gapi.mq.ExecuteGRPCRequest;
-import com.ywt.gapi.mq.ExecuteGRPCResponse;
-import com.ywt.gapi.mq.MQExecutorService;
+import com.ywt.gapi.taihe.biz.GetScreeningTableRequest;
+import com.ywt.gapi.taihe.biz.GetScreeningTableResponse;
+import com.ywt.gapi.taihe.biz.TaiheBizService;
+import com.ywt.outpatient.api.mri.Question;
+import com.ywt.outpatient.api.mri.QuestionOption;
+import com.ywt.outpatient.api.mri.ScreeningTable;
+import com.ywt.outpatient.api.resp.BaseResponse2;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 @RestController
-public class Consumer{
+public class Consumer {
+
     @DubboReference
-    private MQExecutorService mqExecutorService;
+    private TaiheBizService taiheBizServiceBlockingStub;
 
 
     @GetMapping("/tri")
-    public void tri(){
+    public void tri() {
         try {
             System.out.println(1111);
-            ExecuteGRPCRequest request = ExecuteGRPCRequest.newBuilder().setMethod("21").build();
-            ExecuteGRPCResponse response =  mqExecutorService.executeGRPC(request);
-            System.out.println("Receive result ======> " + response.getMsgId());
-        }catch (Exception e){
+            GetScreeningTableRequest getScreeningTableRequest = GetScreeningTableRequest.newBuilder()
+                    .setUserId(13140)
+                    .build();
+            GetScreeningTableResponse response = taiheBizServiceBlockingStub.getScreeningTable(getScreeningTableRequest);
+            if (response.getCode() == BaseResponse2.SUCCEED) {
+                ScreeningTable resp = new ScreeningTable();
+                com.ywt.gapi.taihe.biz.ScreeningTable table = response.getScreeningTable();
+                if (table != null) {
+                    com.ywt.gapi.taihe.biz.PatientInfo info = table.getPatientInfo();
+                    com.ywt.outpatient.api.mri.PatientInfo patientInfo = new com.ywt.outpatient.api.mri.PatientInfo();
+                    if (info != null) {
+                        patientInfo.setPatientName(info.getPatientName());
+                        patientInfo.setSex(info.getSex());
+                        patientInfo.setBirthday(info.getBirthday());
+                        patientInfo.setPatientMobile(info.getPatientMobile());
+                        patientInfo.setAddress(info.getAddress());
+                    }
+                    List<Question> questions = table.getQuestionsList().stream()
+                            .map(question -> {
+                                com.ywt.outpatient.api.mri.Question q = new com.ywt.outpatient.api.mri.Question();
+                                q.setQuestionId(question.getQuestionId());
+                                q.setCategory(question.getCategory());
+                                q.setOptions(convertGrpcDefObj2Model(question.getOptionsList()));
+                                return q;
+                            })
+                            .collect(Collectors.toList());
+                    resp.setPatientInfo(patientInfo);
+                    resp.setQuestions(questions);
+                    resp.setTableId(table.getTableId());
+                }
+                System.out.println("Receive resp ======> " + resp);
+            }
+            System.out.println("Receive result ======> " + response.getMsg());
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
+
+    private List<QuestionOption> convertGrpcDefObj2Model(List<com.ywt.gapi.taihe.biz.QuestionOption> list) {
+        return list.stream()
+                .map(questionOption -> {
+                    QuestionOption option = new QuestionOption();
+                    List<com.ywt.gapi.taihe.biz.QuestionOption> subList = questionOption.getChildrenList();
+                    List<QuestionOption> children = new LinkedList<>();
+                    if (subList != null && !subList.isEmpty()) {
+                        children = convertGrpcDefObj2Model(subList);
+                    }
+                    option.setId(questionOption.getId());
+                    option.setName(questionOption.getName());
+                    option.setValue1(questionOption.getValue1());
+                    option.setValue2(questionOption.getValue2());
+                    option.setValue3(questionOption.getValue3());
+                    option.setChildren(children);
+                    return option;
+                })
+                .collect(Collectors.toList());
+    }
 }

+ 7 - 0
ywt-platform-outpatient-rpc/pom.xml

@@ -73,6 +73,13 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
         </plugins>
     </build>

+ 7 - 1
ywt-platform-outpatient-web/pom.xml

@@ -128,9 +128,15 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
         </plugins>
     </build>
 
-
 </project>

+ 5 - 5
ywt-platform-outpatient-web/src/main/java/com/ywt/OutpatientFrontServiceApplication.java

@@ -13,11 +13,11 @@ import org.springframework.web.client.RestTemplate;
 
 @SpringBootApplication
 @EnableDubbo
-@RibbonClients(
-        value = {
-                @RibbonClient(name = "",configuration = RibbonConfiguration.class)
-        }
-)
+//@RibbonClients(
+//        value = {
+//                @RibbonClient(name = "stocks-nacos",configuration = RibbonConfiguration.class)
+//        }
+//)
 public class OutpatientFrontServiceApplication {
 
     public static void main(String[] args) {