Selaa lähdekoodia

心理测试纳里对接

zhaops 5 vuotta sitten
vanhempi
commit
b64bb19579

+ 92 - 67
xlcs-service/src/main/java/com/diagbot/facade/InquiryInfoFacade.java

@@ -5,14 +5,19 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.diagbot.dto.InquiryDTO;
 import com.diagbot.dto.InquiryPatDTO;
 import com.diagbot.dto.SaveInquiryDTO;
+import com.diagbot.entity.Client;
 import com.diagbot.entity.InquiryDetail;
 import com.diagbot.entity.InquiryInfo;
+import com.diagbot.entity.JSONResponseBean;
+import com.diagbot.entity.Request;
+import com.diagbot.entity.Response;
 import com.diagbot.enums.IdTypeEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.service.impl.InquiryDetailServiceImpl;
 import com.diagbot.service.impl.InquiryInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
+import com.diagbot.util.FastJsonUtils;
 import com.diagbot.util.GsonUtil;
 import com.diagbot.util.HttpUtils;
 import com.diagbot.util.IdCard;
@@ -32,8 +37,11 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description:
@@ -67,12 +75,6 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
         }
 
         SaveInquiryDTO saveInquiryDTO = new SaveInquiryDTO();
-        //        List<String> naliRetList = getUrl(saveInquiryVO);
-        //        String retUrl = naliRetList.get(0);
-        //        saveInquiryDTO.setBody(retUrl);
-        //        saveInquiryDTO.setResponse(naliRetList.get(1));
-        //        saveInquiryDTO.setRequest(naliRetList.get(2));
-        //        saveInquiryDTO.setRequestBodys(naliRetList.get(3));
 
         Date now = DateUtil.now();
         InquiryInfo inquiryInfo = null;
@@ -114,12 +116,14 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
                     .set(StringUtil.isNotBlank(saveInquiryVO.getPhone()), "phone", saveInquiryVO.getPhone())
                     .set(StringUtil.isNotBlank(saveInquiryVO.getPersonnel()), "personnel", saveInquiryVO.getPersonnel())
                     .set(StringUtil.isNotBlank(saveInquiryVO.getAnxietyPoint()), "anxiety_point", saveInquiryVO.getAnxietyPoint())
+                    .set(StringUtil.isNotBlank(saveInquiryVO.getAnxietyRange()), "anxiety_range", saveInquiryVO.getAnxietyRange())
                     .set(StringUtil.isNotBlank(saveInquiryVO.getAnxietyJudge()), "anxiety_judge", saveInquiryVO.getAnxietyJudge())
                     .set(StringUtil.isNotBlank(saveInquiryVO.getAnxietyAdvise()), "anxiety_advise", saveInquiryVO.getAnxietyAdvise())
                     .set(StringUtil.isNotBlank(saveInquiryVO.getDepressionPoint()), "depression_point", saveInquiryVO.getDepressionPoint())
+                    .set(StringUtil.isNotBlank(saveInquiryVO.getDepressionRange()), "depression_range", saveInquiryVO.getDepressionRange())
                     .set(StringUtil.isNotBlank(saveInquiryVO.getDepressionJudge()), "depression_judge", saveInquiryVO.getDepressionJudge())
                     .set(StringUtil.isNotBlank(saveInquiryVO.getDepressionAdvise()), "depression_advise", saveInquiryVO.getDepressionAdvise())
-                    .set("user_id", saveInquiryVO.getUserId())
+                    .set("mpi_id", saveInquiryVO.getMpiId())
                     .set("app_id", saveInquiryVO.getAppId())
                     .eq("id", inquiryInfo.getId())
             );
@@ -132,6 +136,7 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
             );
         }
         Long id = inquiryInfo.getId();
+        saveInquiryVO.setInquiryId(id);
         List<InquiryDetail> inquiryDetailList = Lists.newArrayList();
         for (SaveInquiryDetailVO saveInquiryDetailVO : saveInquiryVO.getDetailList()) {
             InquiryDetail inquiryDetail = new InquiryDetail();
@@ -151,6 +156,18 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
         // 保存记录表
         optInfoFacade.saveOptOnfo(hospitalVO, "2");
 
+        //邵逸夫医院 心理测试 对接纳里时,返回url
+        if (saveInquiryVO.getHospitalCode().equals("邵逸夫医院")
+                && saveInquiryVO.getFrom().equals("5")
+                && saveInquiryVO.getDest().equals("1")) {
+            List<String> naliRetList = getUrl(saveInquiryVO);
+            String retUrl = naliRetList.get(0);
+            saveInquiryDTO.setBody(retUrl);
+            saveInquiryDTO.setResponse(naliRetList.get(1));
+            saveInquiryDTO.setRequest(naliRetList.get(2));
+            saveInquiryDTO.setRequestBodys(naliRetList.get(3));
+        }
+
         return saveInquiryDTO;
     }
 
@@ -173,64 +190,72 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
     }
 
 
-//    private List<String> getUrl(SaveInquiryVO saveInquiryVO) {
-//        List<String> ret = Lists.newArrayList();
-//        String retUrl = null;
-//        Request request = null;
-//        Response response = null;
-//        try {
-//            String encodingAesKey = "";
-//            Client client = new Client(apiUrl, appKey, appSecret, encodingAesKey);
-//            request = getltcs(saveInquiryVO);
-//            response = client.execute(request);
-//            log.info("request:" + FastJsonUtils.getBeanToJson(request));
-//            log.info("requestBodys:" + FastJsonUtils.getBeanToJson(request.getBodys()));
-//            log.info("response:" + FastJsonUtils.getBeanToJson(response));
-//            if (response.isSuccess()) {
-//                JSONResponseBean result = response.getJsonResponseBean();
-//                retUrl = result.getBody().toString();
-//            }
-//        } catch (Exception e) {
-//        }
-//        ret.add(retUrl);
-//        ret.add(FastJsonUtils.getBeanToJson(response));
-//        ret.add(FastJsonUtils.getBeanToJson(request));
-//        ret.add(FastJsonUtils.getBeanToJson(request.getBodys()));
-//        return ret;
-//    }
-//
-//    private Request getltcs(SaveInquiryVO saveInquiryVO) {
-//        List bodyList = new ArrayList<>();
-//
-//        List<Map<String, Object>> details = new ArrayList<>();
-//        saveInquiryVO.getDetailList().forEach(i -> {
-//            Map<String, Object> detail = new HashMap<>();
-//            detail.put("question", i.getQuestion());
-//            detail.put("answer", i.getAnswer());
-//            List<Map<String, Object>> optionMapList = Lists.newArrayList();
-//            i.getOptions().forEach(option -> {
-//                optionMapList.add(FastJsonUtils.getJsonToMap(option));
-//            });
-//            detail.put("options", optionMapList);
-//            details.add(detail);
-//        });
-//
-//        Map<String, Object> body = new HashMap<>();
-//        body.put("details", details);
-//        body.put("doctorId", Integer.parseInt(saveInquiryVO.getDoctorId()));
-//        body.put("mpiId", saveInquiryVO.getMpiId());
-//        body.put("appId", saveInquiryVO.getAppId());
-//        body.put("fromId", saveInquiryVO.getFrom());
-//        body.put("sources", "langtong");
-//        body.put("supplement", saveInquiryVO.getSupplement());
-//        body.put("pushList", saveInquiryVO.getPushList());
-//        body.put("inquiryId", saveInquiryVO.getInquiryId());
-//        bodyList.add(body);
-//
-//        //X-Service-Id对应的值
-//        String serviceId = "consult.questionRecordService";
-//        //X-Service-Method对应的值
-//        String method = "saveQuestionRecord";
-//        return new Request(serviceId, method, bodyList);
-//    }
+    private List<String> getUrl(SaveInquiryVO saveInquiryVO) {
+        List<String> ret = Lists.newArrayList();
+        String retUrl = null;
+        Request request = null;
+        Response response = null;
+        try {
+            String encodingAesKey = "";
+            Client client = new Client(apiUrl, appKey, appSecret, encodingAesKey);
+            request = getltcs(saveInquiryVO);
+            response = client.execute(request);
+            log.info("request:" + FastJsonUtils.getBeanToJson(request));
+            log.info("requestBodys:" + FastJsonUtils.getBeanToJson(request.getBodys()));
+            log.info("response:" + FastJsonUtils.getBeanToJson(response));
+            if (response.isSuccess()) {
+                JSONResponseBean result = response.getJsonResponseBean();
+                retUrl = result.getBody().toString();
+            }
+        } catch (Exception e) {
+        }
+        ret.add(retUrl);
+        ret.add(FastJsonUtils.getBeanToJson(response));
+        ret.add(FastJsonUtils.getBeanToJson(request));
+        ret.add(FastJsonUtils.getBeanToJson(request.getBodys()));
+        return ret;
+    }
+
+    private Request getltcs(SaveInquiryVO saveInquiryVO) {
+        List bodyList = new ArrayList<>();
+
+        List<Map<String, Object>> details = new ArrayList<>();
+        saveInquiryVO.getDetailList().forEach(i -> {
+            Map<String, Object> detail = new HashMap<>();
+            detail.put("question", i.getQuestion());
+            detail.put("answer", i.getAnswer());
+            List<Map<String, Object>> optionMapList = Lists.newArrayList();
+            if (ListUtil.isNotEmpty(i.getOptions())) {
+                i.getOptions().forEach(option -> {
+                    optionMapList.add(FastJsonUtils.getJsonToMap(FastJsonUtils.getBeanToJson(option)));
+                });
+            }
+            detail.put("options", optionMapList);
+            details.add(detail);
+        });
+
+        Map<String, Object> body = new HashMap<>();
+        body.put("details", details);
+        body.put("mpiId", saveInquiryVO.getMpiId());
+        body.put("appId", saveInquiryVO.getAppId());
+        body.put("fromId", saveInquiryVO.getFrom());
+        body.put("sources", "langtong");
+        body.put("inquiryId", saveInquiryVO.getInquiryId());
+        body.put("anxietyPoint", saveInquiryVO.getAnxietyPoint());
+        body.put("anxietyRange", saveInquiryVO.getAnxietyRange());
+        body.put("anxietyJudge", saveInquiryVO.getAnxietyJudge());
+        body.put("anxietyAdvise", saveInquiryVO.getAnxietyAdvise());
+        body.put("depressionPoint", saveInquiryVO.getDepressionPoint());
+        body.put("depressionRange", saveInquiryVO.getDepressionRange());
+        body.put("depressionJudge", saveInquiryVO.getDepressionJudge());
+        body.put("depressionAdvise", saveInquiryVO.getDepressionAdvise());
+
+        bodyList.add(body);
+
+        //X-Service-Id对应的值
+        String serviceId = "consult.questionRecordService";
+        //X-Service-Method对应的值
+        String method = "saveQuestionRecord";
+        return new Request(serviceId, method, bodyList);
+    }
 }

+ 18 - 1
xlcs-service/src/main/java/com/diagbot/vo/SaveInquiryVO.java

@@ -6,6 +6,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
 import java.util.List;
 
 /**
@@ -52,6 +53,9 @@ public class SaveInquiryVO {
     @ApiModelProperty(value = "焦虑症总分")
     private String anxietyPoint;
 
+    @ApiModelProperty(value = "焦虑症分段说明")
+    private String anxietyRange;
+
     @ApiModelProperty(value = "焦虑症判断依据")
     private String anxietyJudge;
 
@@ -61,6 +65,9 @@ public class SaveInquiryVO {
     @ApiModelProperty(value = "抑郁症总分")
     private String depressionPoint;
 
+    @ApiModelProperty(value = "抑郁症分段说明")
+    private String depressionRange;
+
     @ApiModelProperty(value = "抑郁症判断依据")
     private String depressionJudge;
 
@@ -68,8 +75,18 @@ public class SaveInquiryVO {
     private String depressionAdvise;
 
     @ApiModelProperty(value = "用户Id")
-    private String userId;
+    private String mpiId;
 
     @ApiModelProperty(value = "公众号Id")
     private String appId;
+
+    @ApiModelProperty(value = "链接来源 菜单问诊from=1,菜单挂号from=2,公众号问诊from=3,当日挂号from=4,心理测试from=5", required = true)
+    @NotBlank(message = "链接来源必传")
+    private String from;
+
+    @ApiModelProperty(value = "自诊程序产生的ID")
+    private Long inquiryId;
+
+    @ApiModelProperty(value = "对接方 对接纳里dest=1")
+    private String dest;
 }

+ 3 - 1
xlcs-service/src/main/resources/mapper/InquiryInfoMapper.xml

@@ -20,12 +20,14 @@
         <result column="phone" property="phone" />
         <result column="personnel" property="personnel" />
         <result column="anxiety_point" property="anxietyPoint" />
+        <result column="anxiety_range" property="anxietyRange" />
         <result column="anxiety_judge" property="anxietyJudge" />
         <result column="anxiety_advise" property="anxietyAdvise" />
         <result column="depression_point" property="depressionPoint" />
+        <result column="depression_range" property="depressionRange" />
         <result column="depression_judge" property="depressionJudge" />
         <result column="depression_advise" property="depressionAdvise" />
-        <result column="user_id" property="userId" />
+        <result column="mpi_id" property="mpiId" />
         <result column="app_id" property="appId" />
         <result column="remark" property="remark" />
     </resultMap>