فهرست منبع

冠状问诊bean添加

rengb 5 سال پیش
والد
کامیت
db0cee0adf
30فایلهای تغییر یافته به همراه1984 افزوده شده و 4 حذف شده
  1. 25 0
      mrqcman-service/.gitignore
  2. 24 0
      znwz-service/src/main/java/com/diagbot/dto/SaveInquiryDTO.java
  3. 67 0
      znwz-service/src/main/java/com/diagbot/entity/Client.java
  4. 47 0
      znwz-service/src/main/java/com/diagbot/entity/Constants.java
  5. 159 0
      znwz-service/src/main/java/com/diagbot/entity/InquiryDetail.java
  6. 250 0
      znwz-service/src/main/java/com/diagbot/entity/InquiryInfo.java
  7. 53 0
      znwz-service/src/main/java/com/diagbot/entity/JSONResponseBean.java
  8. 142 0
      znwz-service/src/main/java/com/diagbot/entity/Request.java
  9. 120 0
      znwz-service/src/main/java/com/diagbot/entity/Response.java
  10. 29 0
      znwz-service/src/main/java/com/diagbot/entity/SystemHeader.java
  11. 14 0
      znwz-service/src/main/java/com/diagbot/facade/InquiryDetailFacade.java
  12. 65 0
      znwz-service/src/main/java/com/diagbot/facade/InquiryInfoFacade.java
  13. 16 0
      znwz-service/src/main/java/com/diagbot/mapper/InquiryDetailMapper.java
  14. 16 0
      znwz-service/src/main/java/com/diagbot/mapper/InquiryInfoMapper.java
  15. 16 0
      znwz-service/src/main/java/com/diagbot/service/InquiryDetailService.java
  16. 16 0
      znwz-service/src/main/java/com/diagbot/service/InquiryInfoService.java
  17. 20 0
      znwz-service/src/main/java/com/diagbot/service/impl/InquiryDetailServiceImpl.java
  18. 20 0
      znwz-service/src/main/java/com/diagbot/service/impl/InquiryInfoServiceImpl.java
  19. 95 0
      znwz-service/src/main/java/com/diagbot/util/AESUtils.java
  20. 69 0
      znwz-service/src/main/java/com/diagbot/util/Demo.java
  21. 139 0
      znwz-service/src/main/java/com/diagbot/util/JSONUtils.java
  22. 118 0
      znwz-service/src/main/java/com/diagbot/util/MessageDigestUtil.java
  23. 118 0
      znwz-service/src/main/java/com/diagbot/util/OpenApiUtils.java
  24. 126 0
      znwz-service/src/main/java/com/diagbot/util/SignUtil.java
  25. 26 0
      znwz-service/src/main/java/com/diagbot/vo/SaveInquiryDetailVO.java
  26. 104 0
      znwz-service/src/main/java/com/diagbot/vo/SaveInquiryVO.java
  27. 41 0
      znwz-service/src/main/java/com/diagbot/web/InquiryInfoController.java
  28. 19 0
      znwz-service/src/main/resources/mapper/InquiryDetailMapper.xml
  29. 26 0
      znwz-service/src/main/resources/mapper/InquiryInfoMapper.xml
  30. 4 4
      znwz-service/src/test/java/com/diagbot/CodeGeneration.java

+ 25 - 0
mrqcman-service/.gitignore

@@ -0,0 +1,25 @@
+/target/
+!.mvn/wrapper/maven-wrapper.jar
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/build/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/

+ 24 - 0
znwz-service/src/main/java/com/diagbot/dto/SaveInquiryDTO.java

@@ -0,0 +1,24 @@
+package com.diagbot.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2018/11/19 18:56
+ */
+@ApiModel(value = "问诊记录保存接口出参")
+@Getter
+@Setter
+public class SaveInquiryDTO {
+
+    /**
+     * 纳里返回的url
+     */
+    @ApiModelProperty(value = "纳里返回的url")
+    private String body;
+
+}

+ 67 - 0
znwz-service/src/main/java/com/diagbot/entity/Client.java

@@ -0,0 +1,67 @@
+
+package com.diagbot.entity;
+
+import com.diagbot.util.AESUtils;
+import com.diagbot.util.JSONUtils;
+import com.diagbot.util.MessageDigestUtil;
+import com.diagbot.util.OpenApiUtils;
+import com.diagbot.util.SignUtil;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.UUID;
+
+/**
+ * Client
+ */
+public class Client {
+
+    private String apiUrl;
+    private String appKey;
+    private String appSecret;
+    private String encodingAesKey;
+
+    public Client(String apiUrl, String appKey, String appSecret, String encodingAesKey) {
+        this.apiUrl = apiUrl;
+        this.appKey = appKey;
+        this.appSecret = appSecret;
+        this.encodingAesKey = encodingAesKey;
+    }
+
+    /**
+     * 发送请求
+     *
+     * @param request request对象
+     * @return Response
+     * @throws Exception
+     */
+    public Response execute(Request request) throws Exception {
+        request.setApiUrl(this.apiUrl);
+        request.setAppKey(this.appKey);
+        request.setAppSecret(this.appSecret);
+        request.setEncodingAesKey(this.encodingAesKey);
+        request.addHeader(SystemHeader.X_CA_KEY, request.getAppKey());
+        request.addHeader(SystemHeader.X_CA_NONCE, UUID.randomUUID().toString());
+        request.addHeader(SystemHeader.X_CA_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
+        String jsonStr = JSONUtils.toString(request.getBodys());
+        String encryptStr;
+        if (StringUtils.isNotEmpty(request.getEncodingAesKey())) {
+            encryptStr = AESUtils.encrypt(jsonStr, request.getEncodingAesKey());
+        } else {
+            encryptStr = jsonStr;
+        }
+        String contentMd5 = MessageDigestUtil.base64AndMD5(encryptStr);
+        request.addHeader(SystemHeader.X_CONTENT_MD5, contentMd5);
+        String signature = SignUtil.sign(request.getAppSecret(), request.getHeaders());
+        request.addHeader(SystemHeader.X_CA_SIGNATURE, signature);
+        request.setStringBody(encryptStr);
+        return OpenApiUtils.post(request);
+    }
+
+    public static void main(String[] args) throws Exception {
+        String body = "[1]";
+        String encryptStr = AESUtils.encrypt(body, "1234567890123456");
+        String contentMd5 = MessageDigestUtil.base64AndMD5(encryptStr.getBytes());
+        System.out.println(contentMd5);
+
+    }
+}

+ 47 - 0
znwz-service/src/main/java/com/diagbot/entity/Constants.java

@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.diagbot.entity;
+
+/**
+ * 通用常量
+ */
+public class Constants {
+    //签名算法HmacSha256
+    public static final String HMAC_SHA256 = "HmacSHA256";
+    //编码UTF-8
+    public static final String ENCODING = "UTF-8";
+    //UserAgent
+    public static final String USER_AGENT = "demo/aliyun/java";
+    //换行符
+    public static final String LF = "\n";
+    //串联符
+    public static final String SPE1 = ",";
+    //示意符
+    public static final String SPE2 = ":";
+    //连接符
+    public static final String SPE3 = "&";
+    //赋值符
+    public static final String SPE4 = "=";
+    //问号符
+    public static final String SPE5 = "?";
+    //默认请求超时时间,单位毫秒
+    public static final int DEFAULT_TIMEOUT = 1000;
+    //参与签名的系统Header前缀,只有指定前缀的Header才会参与到签名中
+    public static final String CA_HEADER_TO_SIGN_PREFIX_SYSTEM = "X-Ca-";
+}

+ 159 - 0
znwz-service/src/main/java/com/diagbot/entity/InquiryDetail.java

@@ -0,0 +1,159 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 问诊记录-明细表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+@TableName("znwz_inquiry_detail")
+public class InquiryDetail implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private LocalDateTime gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private LocalDateTime gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 问诊记录id
+     */
+    private Long inquiryId;
+
+    /**
+     * 问题
+     */
+    private String question;
+
+    /**
+     * 答案
+     */
+    private String answer;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+    public LocalDateTime getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(LocalDateTime gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+    public LocalDateTime getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(LocalDateTime gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+    public Long getInquiryId() {
+        return inquiryId;
+    }
+
+    public void setInquiryId(Long inquiryId) {
+        this.inquiryId = inquiryId;
+    }
+    public String getQuestion() {
+        return question;
+    }
+
+    public void setQuestion(String question) {
+        this.question = question;
+    }
+    public String getAnswer() {
+        return answer;
+    }
+
+    public void setAnswer(String answer) {
+        this.answer = answer;
+    }
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    @Override
+    public String toString() {
+        return "InquiryDetail{" +
+            "id=" + id +
+            ", isDeleted=" + isDeleted +
+            ", gmtCreate=" + gmtCreate +
+            ", gmtModified=" + gmtModified +
+            ", creator=" + creator +
+            ", modifier=" + modifier +
+            ", inquiryId=" + inquiryId +
+            ", question=" + question +
+            ", answer=" + answer +
+            ", remark=" + remark +
+        "}";
+    }
+}

+ 250 - 0
znwz-service/src/main/java/com/diagbot/entity/InquiryInfo.java

@@ -0,0 +1,250 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 问诊记录-主表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+@TableName("znwz_inquiry_info")
+public class InquiryInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private LocalDateTime gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private LocalDateTime gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 公众号appid
+     */
+    private String appId;
+
+    /**
+     * 医院名称
+     */
+    private String organName;
+
+    /**
+     * 医生所在科室名称
+     */
+    private String department;
+
+    /**
+     * 医生ID
+     */
+    private String doctorId;
+
+    /**
+     * 医生名称
+     */
+    private String doctorName;
+
+    /**
+     * 用户在纳里的ID
+     */
+    private String mpiId;
+
+    /**
+     * 用户名称
+     */
+    private String patientName;
+
+    /**
+     * 用户年龄
+     */
+    private Integer patientAge;
+
+    /**
+     * 用户性别
+     */
+    private String patientSex;
+
+    /**
+     * 诊断
+     */
+    private String diagnosis;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+    public LocalDateTime getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(LocalDateTime gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+    public LocalDateTime getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(LocalDateTime gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+    public String getDepartment() {
+        return department;
+    }
+
+    public void setDepartment(String department) {
+        this.department = department;
+    }
+    public String getDoctorId() {
+        return doctorId;
+    }
+
+    public void setDoctorId(String doctorId) {
+        this.doctorId = doctorId;
+    }
+    public String getDoctorName() {
+        return doctorName;
+    }
+
+    public void setDoctorName(String doctorName) {
+        this.doctorName = doctorName;
+    }
+    public String getMpiId() {
+        return mpiId;
+    }
+
+    public void setMpiId(String mpiId) {
+        this.mpiId = mpiId;
+    }
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+    public Integer getPatientAge() {
+        return patientAge;
+    }
+
+    public void setPatientAge(Integer patientAge) {
+        this.patientAge = patientAge;
+    }
+    public String getPatientSex() {
+        return patientSex;
+    }
+
+    public void setPatientSex(String patientSex) {
+        this.patientSex = patientSex;
+    }
+    public String getDiagnosis() {
+        return diagnosis;
+    }
+
+    public void setDiagnosis(String diagnosis) {
+        this.diagnosis = diagnosis;
+    }
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    @Override
+    public String toString() {
+        return "InquiryInfo{" +
+            "id=" + id +
+            ", isDeleted=" + isDeleted +
+            ", gmtCreate=" + gmtCreate +
+            ", gmtModified=" + gmtModified +
+            ", creator=" + creator +
+            ", modifier=" + modifier +
+            ", appId=" + appId +
+            ", organName=" + organName +
+            ", department=" + department +
+            ", doctorId=" + doctorId +
+            ", doctorName=" + doctorName +
+            ", mpiId=" + mpiId +
+            ", patientName=" + patientName +
+            ", patientAge=" + patientAge +
+            ", patientSex=" + patientSex +
+            ", diagnosis=" + diagnosis +
+            ", remark=" + remark +
+        "}";
+    }
+}

+ 53 - 0
znwz-service/src/main/java/com/diagbot/entity/JSONResponseBean.java

@@ -0,0 +1,53 @@
+package com.diagbot.entity;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class JSONResponseBean {
+	private int code = 200;
+	private String msg;
+	private Object body;
+	private Map<String, Object> properties;
+	
+	public int getCode() {
+		return code;
+	}
+	
+	public void setCode(int code) {
+		this.code = code;
+	}
+	
+	public String getMsg() {
+		return msg;
+	}
+	
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+	
+	public Object getBody() {
+		return body;
+	}
+	
+	public void setBody(Object body) {
+		this.body = body;
+	}
+	
+	public Map<String, Object> getProperties() {
+		return properties;
+	}
+	
+	public Object getProperty(String nm){
+		if(properties == null || properties.isEmpty()){
+			return null;
+		}
+		return properties.get(nm);
+	}
+	
+	public void setProperty(String name, Object val){
+		if(properties == null){
+			properties = new HashMap<>();
+		}
+		properties.put(name, val);
+	}
+}

+ 142 - 0
znwz-service/src/main/java/com/diagbot/entity/Request.java

@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.diagbot.entity;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Request
+ */
+public class Request {
+
+    public Request() {
+    }
+
+    public Request(String serviceId, String method, List<Object> bodys) {
+        this.appKey = appKey;
+        this.appSecret = appSecret;
+        this.bodys=bodys;
+        headers = new HashMap<>();
+        headers.put(SystemHeader.X_CA_KEY, appKey);
+        headers.put(SystemHeader.X_SERVICE_ID, serviceId);
+        headers.put(SystemHeader.X_SERVICE_METHOD, method);
+    }
+    /**
+     * (必选)服务请求地址
+     */
+    private String apiUrl;
+
+
+
+    /**
+     * (必选)APP KEY
+     */
+    private String appKey;
+
+    /**
+     * (必选)APP密钥
+     */
+    private String appSecret;
+
+    private String encodingAesKey;
+
+
+    /**
+     * (必选) HTTP头
+     */
+    private Map<String, String> headers;
+    
+
+
+    /**
+     * (必选)请求参数
+     */
+    private List<Object> bodys;
+
+    /**
+     * (可选)字符串Body体
+     */
+    private String stringBody;
+
+
+    public String getAppKey() {
+        return appKey;
+    }
+
+    public void setAppKey(String appKey) {
+        this.appKey = appKey;
+    }
+
+    public String getAppSecret() {
+        return appSecret;
+    }
+
+    public void setAppSecret(String appSecret) {
+        this.appSecret = appSecret;
+    }
+
+
+    public Map<String, String> getHeaders() {
+        return headers;
+    }
+
+    public void setHeaders(Map<String, String> headers) {
+        this.headers = headers;
+    }
+
+    public List<Object> getBodys() {
+        return bodys;
+    }
+
+    public void setBodys(List<Object> bodys) {
+        this.bodys = bodys;
+    }
+
+    public String getStringBody() {
+        return stringBody;
+    }
+
+    public void setStringBody(String stringBody) {
+        this.stringBody = stringBody;
+    }
+
+    public String getEncodingAesKey() {
+        return encodingAesKey;
+    }
+
+    public void setEncodingAesKey(String encodingAesKey) {
+        this.encodingAesKey = encodingAesKey;
+    }
+
+    public String getApiUrl() {
+        return apiUrl;
+    }
+
+    public void setApiUrl(String apiUrl) {
+        this.apiUrl = apiUrl;
+    }
+    public void addHeader(String name, String value){
+        if(headers==null){
+            headers = new HashMap<>();
+        }
+        headers.put(name, value);
+    }
+}

+ 120 - 0
znwz-service/src/main/java/com/diagbot/entity/Response.java

@@ -0,0 +1,120 @@
+package com.diagbot.entity;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Response {
+    /**
+     * http 请求状态码
+     */
+    private int statusCode;
+    private String contentType;
+    /**
+     * 请求唯一 ID,请求一旦进入 API 网关应用后,API 网关就会生成请求 ID 并通过响应头返回给客户端,
+     * 建议客户端与后端服务都记录此请求 ID,可用于问题排查与跟踪。
+     */
+    private String requestId;
+    /**
+     * API网关会将服务端的StringToSign放到HTTP应答的Header中返回到客户端,Key为:X-Ca-Error-Message
+     * 只需要将本地计算的StringToSign与服务端返回的StringToSign进行对比即可找到问题;
+     * 如果服务端与客户端的签名串是一致的,请检查用于签名计算的密钥是否正确;
+     */
+    private String caErrorMsg;
+    /**
+     * 业务接口返回的错误信息
+     */
+    private String errorMessage;
+    private Map<String, String> headers;
+    private String body;
+    private JSONResponseBean jsonResponseBean;
+
+    public boolean isSuccess() {
+        return (200 == statusCode && jsonResponseBean != null && 200 == jsonResponseBean.getCode());
+    }
+
+    public Response() {
+
+    }
+
+    public int getStatusCode() {
+        return statusCode;
+    }
+
+    public void setStatusCode(int statusCode) {
+        this.statusCode = statusCode;
+    }
+
+    public String getContentType() {
+        return contentType;
+    }
+
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public void setRequestId(String requestId) {
+        this.requestId = requestId;
+    }
+
+    public String getErrorMessage() {
+        if (jsonResponseBean != null && !"200".equals(jsonResponseBean.getCode())) {
+            return jsonResponseBean.getMsg();
+        }
+        return null;
+    }
+
+    public void setErrorMessage(String errorMessage) {
+        this.errorMessage = errorMessage;
+    }
+
+    public Map<String, String> getHeaders() {
+        return headers;
+    }
+
+    public String getHeader(String key) {
+        if (null != headers) {
+            return headers.get(key);
+        } else {
+            return null;
+        }
+    }
+
+    public void setHeaders(Map<String, String> headers) {
+        this.headers = headers;
+    }
+
+    public void setHeader(String key, String value) {
+        if (null == this.headers) {
+            this.headers = new HashMap<String, String>();
+        }
+        this.headers.put(key, value);
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public void setBody(String body) {
+        this.body = body;
+    }
+
+    public JSONResponseBean getJsonResponseBean() {
+        return jsonResponseBean;
+    }
+
+    public void setJsonResponseBean(JSONResponseBean jsonResponseBean) {
+        this.jsonResponseBean = jsonResponseBean;
+    }
+
+    public String getCaErrorMsg() {
+        return caErrorMsg;
+    }
+
+    public void setCaErrorMsg(String caErrorMsg) {
+        this.caErrorMsg = caErrorMsg;
+    }
+}

+ 29 - 0
znwz-service/src/main/java/com/diagbot/entity/SystemHeader.java

@@ -0,0 +1,29 @@
+
+package com.diagbot.entity;
+
+/**
+ * 系统HTTP头常量
+ */
+public class SystemHeader {
+    //签名Header
+    public static final String X_CA_SIGNATURE = "X-Ca-Signature";
+    //所有参与签名的Header
+    public static final String X_CA_SIGNATURE_HEADERS = "X-Ca-Signature-Headers";
+    //请求时间戳
+    public static final String X_CA_TIMESTAMP = "X-Ca-Timestamp";
+    //请求放重放Nonce,15分钟内保持唯一,建议使用UUID
+    public static final String X_CA_NONCE = "X-Ca-Nonce";
+    //APP KEY
+    public static final String X_CA_KEY = "X-Ca-Key";
+    //服务id
+    public static final String X_SERVICE_ID = "X-Service-Id";
+    //具体method
+    public static final String X_SERVICE_METHOD = "X-Service-Method";
+    //MD5加密的请求体信息
+    public static final String X_CONTENT_MD5 = "X-Content-MD5";
+
+    //MD5加密的请求体信息
+    public static final String X_CA_REQUESTID = "X-Ca-RequestId";
+    //API网关会将服务端的StringToSign放到HTTP应答的Header中返回到客户端,Key为:X-Ca-Error-Message
+    public static final String X_CA_ERROR_MESSAGE = "X-Ca-Error-Message";
+}

+ 14 - 0
znwz-service/src/main/java/com/diagbot/facade/InquiryDetailFacade.java

@@ -0,0 +1,14 @@
+package com.diagbot.facade;
+
+import com.diagbot.service.impl.InquiryDetailServiceImpl;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2020/2/1 23:34
+ */
+@Component
+public class InquiryDetailFacade extends InquiryDetailServiceImpl {
+
+}

+ 65 - 0
znwz-service/src/main/java/com/diagbot/facade/InquiryInfoFacade.java

@@ -0,0 +1,65 @@
+package com.diagbot.facade;
+
+import com.diagbot.dto.SaveInquiryDTO;
+import com.diagbot.entity.Request;
+import com.diagbot.service.impl.InquiryInfoServiceImpl;
+import com.diagbot.vo.SaveInquiryVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2020/2/1 23:33
+ */
+@Component
+public class InquiryInfoFacade extends InquiryInfoServiceImpl {
+
+    @Autowired
+    private InquiryDetailFacade inquiryDetailFacade;
+
+
+    public SaveInquiryDTO saveInquiry(SaveInquiryVO saveInquiryVO){
+
+
+
+        return null;
+    }
+
+
+    public static 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());
+            details.add(detail);
+        });
+
+        Map<String, Object> body = new HashMap<>();
+        body.put("details", details);
+        body.put("doctorId", saveInquiryVO.getDoctorId());
+        body.put("mpiId", saveInquiryVO.getMpiId());
+        body.put("appId", saveInquiryVO.getAppId());
+        body.put("diagnosis", saveInquiryVO.getDiagnosis());
+
+        bodyList.add(body);
+
+        //X-Service-Id对应的值
+        String serviceId = "consult.questionRecordService";
+        //X-Service-Method对应的值
+        String method = "saveQuestionRecord";
+        return new Request(serviceId, method, bodyList);
+    }
+
+
+
+
+}

+ 16 - 0
znwz-service/src/main/java/com/diagbot/mapper/InquiryDetailMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.InquiryDetail;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 问诊记录-明细表 Mapper 接口
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+public interface InquiryDetailMapper extends BaseMapper<InquiryDetail> {
+
+}

+ 16 - 0
znwz-service/src/main/java/com/diagbot/mapper/InquiryInfoMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.InquiryInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 问诊记录-主表 Mapper 接口
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+public interface InquiryInfoMapper extends BaseMapper<InquiryInfo> {
+
+}

+ 16 - 0
znwz-service/src/main/java/com/diagbot/service/InquiryDetailService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.InquiryDetail;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 问诊记录-明细表 服务类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+public interface InquiryDetailService extends IService<InquiryDetail> {
+
+}

+ 16 - 0
znwz-service/src/main/java/com/diagbot/service/InquiryInfoService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.InquiryInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 问诊记录-主表 服务类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+public interface InquiryInfoService extends IService<InquiryInfo> {
+
+}

+ 20 - 0
znwz-service/src/main/java/com/diagbot/service/impl/InquiryDetailServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.InquiryDetail;
+import com.diagbot.mapper.InquiryDetailMapper;
+import com.diagbot.service.InquiryDetailService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 问诊记录-明细表 服务实现类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+@Service
+public class InquiryDetailServiceImpl extends ServiceImpl<InquiryDetailMapper, InquiryDetail> implements InquiryDetailService {
+
+}

+ 20 - 0
znwz-service/src/main/java/com/diagbot/service/impl/InquiryInfoServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.InquiryInfo;
+import com.diagbot.mapper.InquiryInfoMapper;
+import com.diagbot.service.InquiryInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 问诊记录-主表 服务实现类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2020-02-01
+ */
+@Service
+public class InquiryInfoServiceImpl extends ServiceImpl<InquiryInfoMapper, InquiryInfo> implements InquiryInfoService {
+
+}

+ 95 - 0
znwz-service/src/main/java/com/diagbot/util/AESUtils.java

@@ -0,0 +1,95 @@
+package com.diagbot.util;
+
+import com.diagbot.entity.Constants;
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.Key;
+
+public class AESUtils {
+
+    private static final String KEY_ALGORITHM = "AES";
+    private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
+
+    public static byte[] initSecretKey() throws Exception {
+        KeyGenerator kg = KeyGenerator.getInstance(KEY_ALGORITHM);
+        kg.init(128);
+        SecretKey secretKey = kg.generateKey();
+
+        return secretKey.getEncoded();
+    }
+
+    public static Key toKey(byte[] key) {
+        return new SecretKeySpec(key, KEY_ALGORITHM);
+    }
+
+    public static String encrypt(String data, String key) throws Exception {
+        return Base64.encodeBase64String(encrypt(data.getBytes(Constants.ENCODING), toKey(key.getBytes()), DEFAULT_CIPHER_ALGORITHM));
+    }
+
+    public static String decrypt(String data, String key) throws Exception {
+        return new String(decrypt(Base64.decodeBase64(data.getBytes(Constants.ENCODING)), toKey(key.getBytes()), DEFAULT_CIPHER_ALGORITHM));
+    }
+
+    public static byte[] encrypt(byte[] data, Key key) throws Exception {
+        return encrypt(data, key, DEFAULT_CIPHER_ALGORITHM);
+    }
+
+    public static byte[] encrypt(byte[] data, byte[] key) throws Exception {
+        return encrypt(data, toKey(key), DEFAULT_CIPHER_ALGORITHM);
+    }
+
+    public static byte[] encrypt(byte[] data, Key key, String cipherAlgorithm) throws Exception {
+        Cipher cipher = Cipher.getInstance(cipherAlgorithm);
+        cipher.init(Cipher.ENCRYPT_MODE, key);
+        return cipher.doFinal(data);
+    }
+
+    public static byte[] decrypt(byte[] data, byte[] key) throws Exception {
+        return decrypt(data, key, DEFAULT_CIPHER_ALGORITHM);
+    }
+
+    public static byte[] decrypt(byte[] data, Key key) throws Exception {
+        return decrypt(data, key, DEFAULT_CIPHER_ALGORITHM);
+    }
+
+    public static byte[] decrypt(byte[] data, byte[] key, String cipherAlgorithm) throws Exception {
+        Key k = toKey(key);
+        return decrypt(data, k, cipherAlgorithm);
+    }
+
+    public static byte[] decrypt(byte[] data, Key key, String cipherAlgorithm) throws Exception {
+        Cipher cipher = Cipher.getInstance(cipherAlgorithm);
+        cipher.init(Cipher.DECRYPT_MODE, key);
+        return cipher.doFinal(data);
+    }
+
+    private static String showByteArray(byte[] data) {
+        if (null == data) {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder("{");
+        for (byte b : data) {
+            sb.append(b).append(",");
+        }
+        sb.deleteCharAt(sb.length() - 1);
+        sb.append("}");
+        return sb.toString();
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        String original = "[1]";
+        String key = "1234567890123456";
+        System.out.println("original: " + original);
+        String encrypt = encrypt(original, key);
+        System.out.println("encrypt: " + encrypt + ", key: " + key);
+        String decrypt = decrypt(encrypt, key);
+        System.out.println("decrypt: " + decrypt);
+
+    }
+
+}

+ 69 - 0
znwz-service/src/main/java/com/diagbot/util/Demo.java

@@ -0,0 +1,69 @@
+package com.diagbot.util;
+
+import com.diagbot.entity.Client;
+import com.diagbot.entity.JSONResponseBean;
+import com.diagbot.entity.Request;
+import com.diagbot.entity.Response;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Demo {
+
+    public static void main(String[] args) throws Exception {
+        //必填 apiUrl
+        String apiUrl = "http://116.62.170.131:8096/openapi-devtest/gateway";
+        //必填
+        String appKey = "ngari5e34e52511dc394f";
+        //必填
+        String appSecret = "11dc394fc05518c1";
+        //如果开启加密,则必填
+        String encodingAesKey = "";
+        Client client = new Client(apiUrl, appKey, appSecret, encodingAesKey);
+
+        //调用相应的接口请求
+        Response response = client.execute(getltcs());
+        System.out.println(JSONUtils.toString(response));
+        if (response.isSuccess()) {
+            //接口返回的结果
+            JSONResponseBean result = response.getJsonResponseBean();
+            System.out.println(JSONUtils.toString(result));
+        } else {
+            System.out.println(response.getCaErrorMsg());
+            System.out.println(response.getErrorMessage());
+        }
+
+    }
+
+    public static Request getltcs() {
+        //入参赋值,注意最外层是个json数组
+        List bodyList = new ArrayList<>();
+
+        List<Map<String, Object>> details = new ArrayList<>();
+        Map<String, Object> detail1 = new HashMap<>();
+        detail1.put("question", "问题1");
+        detail1.put("answer", "答案1");
+        Map<String, Object> detail2 = new HashMap<>();
+        detail2.put("question", "问题2");
+        detail2.put("answer", "答案2");
+        details.add(detail1);
+        details.add(detail2);
+
+        Map<String, Object> body = new HashMap<>();
+        body.put("details", details);
+        body.put("doctorId", 1182);
+        body.put("mpiId", "2c90818958b4f5f10158b50289020001");
+        body.put("appId", "wx6a80dd109228fd4b");
+        body.put("diagnosis", "Summary");
+
+        bodyList.add(body);
+
+        //X-Service-Id对应的值
+        String serviceId = "consult.questionRecordService";
+        //X-Service-Method对应的值
+        String method = "saveQuestionRecord";
+        return new Request(serviceId, method, bodyList);
+    }
+}

+ 139 - 0
znwz-service/src/main/java/com/diagbot/util/JSONUtils.java

@@ -0,0 +1,139 @@
+package com.diagbot.util;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.text.SimpleDateFormat;
+
+public class JSONUtils {
+	private static ObjectMapper mapper =  new ObjectMapper();
+
+	static{
+		mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+		mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
+		mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+
+		mapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING,true);
+		mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+		mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
+		mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+		mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+	}
+
+	public static <T> T parse(String value, Class<T> clz){
+
+		if (StringUtils.isEmpty(value)) {
+			return null;
+		}
+		try {
+			return mapper.readValue(value, clz);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public static <T> T parse(byte[] bytes, Class<T> clz){
+		try {
+			return mapper.readValue(bytes, clz);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+
+	public static <T> T parse(InputStream ins, Class<T> clz){
+		try {
+			return mapper.readValue(ins, clz);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+
+	public static <T> T  parse(Reader reader, Class<T> clz){
+		try {
+			return mapper.readValue(reader, clz);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	@SuppressWarnings("unchecked")
+	public static <T> T update(String value, T object) {
+		try {
+			return (T) mapper.readerForUpdating(object).readValue(value);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public static String writeValueAsString(Object o){
+		try {
+			return mapper.writeValueAsString(o);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public static void write(OutputStream outs, Object o){
+		try {
+			mapper.writeValue(outs,o);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+    }
+
+	public static void write(Writer writer, Object o){
+		try {
+			mapper.writeValue(writer,o);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public static String toString(Object o){
+		try {
+			return mapper.writeValueAsString(o);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public static String toString(Object o, Class<?> clz){
+		try {
+			return mapper.writerFor(clz).writeValueAsString(o);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public static byte[] toBytes(Object o){
+		try {
+			return mapper.writeValueAsBytes(o);
+		}
+		catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+}

+ 118 - 0
znwz-service/src/main/java/com/diagbot/util/MessageDigestUtil.java

@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.diagbot.util;
+
+import com.diagbot.entity.Constants;
+import org.apache.commons.codec.binary.Base64;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * 消息摘要工具
+ */
+public class MessageDigestUtil {
+    /**
+     * 先进行MD5摘要再进行Base64编码获取摘要字符串
+     *
+     * @param str
+     * @return
+     */
+    public static String base64AndMD5(String str) {
+        if (str == null) {
+            throw new IllegalArgumentException("inStr can not be null");
+        }
+        return base64AndMD5(toBytes(str));
+    }
+
+    /**
+     * 先进行MD5摘要再进行Base64编码获取摘要字符串
+     *
+     * @return
+     */
+    public static String base64AndMD5(byte[] bytes) {
+        if (bytes == null) {
+            throw new IllegalArgumentException("bytes can not be null");
+        }
+        try {
+            final MessageDigest md = MessageDigest.getInstance("MD5");
+            md.reset();
+            md.update(bytes);
+            final Base64 base64 = new Base64();
+            final byte[] enbytes = base64.encode(md.digest());
+            return new String(enbytes);
+        } catch (final NoSuchAlgorithmException e) {
+            throw new IllegalArgumentException("unknown algorithm MD5");
+        }
+    }
+
+    /**
+     * UTF-8编码转换为ISO-9959-1
+     *
+     * @param str
+     * @return
+     */
+    public static String utf8ToIso88591(String str) {
+        if (str == null) {
+            return str;
+        }
+
+        try {
+            return new String(str.getBytes("UTF-8"), "ISO-8859-1");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * ISO-9959-1编码转换为UTF-8
+     *
+     * @param str
+     * @return
+     */
+    public static String iso88591ToUtf8(String str) {
+        if (str == null) {
+            return str;
+        }
+
+        try {
+            return new String(str.getBytes("ISO-8859-1"), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * String转换为字节数组
+     *
+     * @param str
+     * @return
+     */
+    private static byte[] toBytes(final String str) {
+        if (str == null) {
+            return null;
+        }
+        try {
+            return str.getBytes(Constants.ENCODING);
+        } catch (final UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+}

+ 118 - 0
znwz-service/src/main/java/com/diagbot/util/OpenApiUtils.java

@@ -0,0 +1,118 @@
+package com.diagbot.util;
+
+import com.diagbot.entity.JSONResponseBean;
+import com.diagbot.entity.Request;
+import com.diagbot.entity.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.Map;
+
+public class OpenApiUtils {
+    public static Response post(Request request) throws Exception {
+        return convert(doPost(request));
+    }
+
+    /**
+     * post form
+     *
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    private static HttpResponse doPost(Request request)
+            throws Exception {
+        HttpClient httpClient = wrapClient(request.getApiUrl());
+
+        HttpPost httpPost = new HttpPost(request.getApiUrl());
+        for (Map.Entry<String, String> e : request.getHeaders().entrySet()) {
+            httpPost.addHeader(e.getKey(), e.getValue());
+        }
+        if (request.getBodys() != null || StringUtils.isNotEmpty(request.getStringBody())) {
+            if (StringUtils.isNotEmpty(request.getStringBody())) {
+                httpPost.setEntity(new StringEntity(request.getStringBody(), ContentType.APPLICATION_JSON));
+            } else {
+                httpPost.setEntity(new StringEntity(JSONUtils.toString(request.getBodys()), ContentType.APPLICATION_JSON));
+            }
+        }
+        return httpClient.execute(httpPost);
+    }
+
+    private static HttpClient wrapClient(String host) {
+        HttpClient httpClient = new DefaultHttpClient();
+        if (host.startsWith("https://")) {
+            sslClient(httpClient);
+        }
+        return httpClient;
+    }
+
+    private static void sslClient(HttpClient httpClient) {
+        try {
+            SSLContext ctx = SSLContext.getInstance("TLS");
+            X509TrustManager tm = new X509TrustManager() {
+                public X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+
+                public void checkClientTrusted(X509Certificate[] xcs, String str) {
+
+                }
+
+                public void checkServerTrusted(X509Certificate[] xcs, String str) {
+
+                }
+            };
+            ctx.init(null, new TrustManager[] { tm }, null);
+            SSLSocketFactory ssf = new SSLSocketFactory(ctx);
+            ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+            ClientConnectionManager ccm = httpClient.getConnectionManager();
+            SchemeRegistry registry = ccm.getSchemeRegistry();
+            registry.register(new Scheme("https", 443, ssf));
+        } catch (KeyManagementException ex) {
+            throw new RuntimeException(ex);
+        } catch (NoSuchAlgorithmException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    private static Response convert(HttpResponse response) throws IOException {
+        Response res = new Response();
+
+        if (null != response) {
+            res.setStatusCode(response.getStatusLine().getStatusCode());
+            for (Header header : response.getAllHeaders()) {
+                res.setHeader(header.getName(), MessageDigestUtil.iso88591ToUtf8(header.getValue()));
+            }
+            res.setContentType(res.getHeader("Content-Type"));
+            res.setRequestId(res.getHeader("X-Ca-Request-Id"));
+            res.setBody(EntityUtils.toString(response.getEntity()));
+            res.setJsonResponseBean(JSONUtils.parse(res.getBody(), JSONResponseBean.class));
+            res.setCaErrorMsg(res.getHeader("X-Ca-Error-Message"));
+
+        } else {
+            //服务器无回应
+            res.setStatusCode(500);
+            res.setErrorMessage("No Response");
+        }
+
+        return res;
+    }
+}

+ 126 - 0
znwz-service/src/main/java/com/diagbot/util/SignUtil.java

@@ -0,0 +1,126 @@
+
+package com.diagbot.util;
+
+
+import com.diagbot.entity.Constants;
+import com.diagbot.entity.SystemHeader;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.UUID;
+
+/**
+ * 签名工具
+ */
+public class SignUtil {
+    /**
+     * 需要参与签名的请求头
+     */
+    private static final List<String> SIGN_HEADER_LIST = Arrays.asList("X-Service-Id","X-Service-Method","X-Ca-Key",
+            "X-Ca-Nonce","X-Ca-Timestamp","X-Content-MD5");
+    /**
+     * 计算签名
+     *
+     * @param secret APP密钥
+     * @param headers 请求头参数
+     * @return 签名后的字符串
+     */
+    public static String sign(String secret,
+                              Map<String, String> headers) {
+        try {
+            Mac hmacSha256 = Mac.getInstance(Constants.HMAC_SHA256);
+            byte[] keyBytes = secret.getBytes(Constants.ENCODING);
+            hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, Constants.HMAC_SHA256));
+//            String contentMd5 = MessageDigestUtil.base64AndMD5(bodyContent);
+
+            return new String(Base64.encodeBase64(
+                    hmacSha256.doFinal((buildHeaders(headers, SIGN_HEADER_LIST))
+                            .getBytes(Constants.ENCODING))),
+                    Constants.ENCODING);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * 构建待签名Http头
+     *
+     * @param headers 请求中所有的Http头
+     * @param signHeaderList 自定义参与签名Header前缀
+     * @return 待签名Http头
+     */
+    public static String buildHeaders(Map<String, String> headers, List<String> signHeaderList) {
+
+    	List<String> sbList=new ArrayList<>();
+    	if (null != signHeaderList) {
+    		Collections.sort(signHeaderList);
+    		if (null != headers) {
+    			Map<String, String> sortMap = new TreeMap<String, String>();
+    			sortMap.putAll(headers);
+    			StringBuilder signHeadersStringBuilder = new StringBuilder();
+    			for (Map.Entry<String, String> header : sortMap.entrySet()) {
+                    if (isHeaderToSign(header.getKey(), signHeaderList)) {
+                        StringBuilder sb = new StringBuilder();
+                    	sb.append(header.getKey().toLowerCase());
+                    	sb.append(Constants.SPE2);
+                        if (!StringUtils.isBlank(header.getValue())) {
+                        	sb.append(header.getValue());
+                        }
+                        sbList.add(sb.toString());
+                        if (0 < signHeadersStringBuilder.length()) {
+                        	signHeadersStringBuilder.append(Constants.SPE1);
+                        }
+                        signHeadersStringBuilder.append(header.getKey().toLowerCase());
+                    }
+                }
+    			headers.put(SystemHeader.X_CA_SIGNATURE_HEADERS, signHeadersStringBuilder.toString());
+    		}
+    	}
+        return StringUtils.join(sbList,Constants.SPE3);
+    }
+
+    /**
+     * Http头是否参与签名 return
+     */
+    private static boolean isHeaderToSign(String headerName, List<String> signHeaderList) {
+        if (StringUtils.isBlank(headerName)) {
+            return false;
+        }
+
+        if (headerName.startsWith(Constants.CA_HEADER_TO_SIGN_PREFIX_SYSTEM)) {
+            return true;
+        }
+
+        if (null != signHeaderList) {
+            for (String signHeaderPrefix : signHeaderList) {
+                if (headerName.equalsIgnoreCase(signHeaderPrefix)) {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    public static void main(String[] args) {
+        String secret = "1234567890123456";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("X-Service-Id", "eh.organ");
+        headers.put("X-Service-Method", "");
+        headers.put("X-Ca-Key", "hello");
+        headers.put("X-Ca-Timestamp", String.valueOf(System.currentTimeMillis()));
+        headers.put("X-Ca-Nonce", UUID.randomUUID().toString());
+        headers.put(SystemHeader.X_CONTENT_MD5, UUID.randomUUID().toString());
+        System.out.println(sign(secret, headers));
+
+    }
+}

+ 26 - 0
znwz-service/src/main/java/com/diagbot/vo/SaveInquiryDetailVO.java

@@ -0,0 +1,26 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author rengb
+ * @Description
+ * @time 2018年11月23日下午2:29:43
+ */
+@Getter
+@Setter
+public class SaveInquiryDetailVO {
+
+    /**
+     * 问题
+     */
+    private String question;
+
+    /**
+     * 答案
+     */
+    private String answer;
+
+
+}

+ 104 - 0
znwz-service/src/main/java/com/diagbot/vo/SaveInquiryVO.java

@@ -0,0 +1,104 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2018/11/19 18:58
+ */
+@ApiModel(value = "问诊记录保存接口传参")
+@Getter
+@Setter
+public class SaveInquiryVO {
+
+    /**
+     * 公众号appid
+     */
+    @ApiModelProperty(value = "公众号appid", required = true)
+    @NotBlank(message = "公众号appid必传")
+    private String appId;
+
+    /**
+     * 医院名称
+     */
+    @ApiModelProperty(value = "医院名称", required = true)
+    @NotBlank(message = "医院名称必传")
+    private String organName;
+
+    /**
+     * 医生所在科室名称
+     */
+    @ApiModelProperty(value = "医生所在科室名称", required = true)
+    @NotBlank(message = "医生所在科室名称必传")
+    private String department;
+
+    /**
+     * 医生ID
+     */
+    @ApiModelProperty(value = "医生ID", required = true)
+    @NotBlank(message = "医生ID必传")
+    private String doctorId;
+
+    /**
+     * 医生名称
+     */
+    @ApiModelProperty(value = "医生名称", required = true)
+    @NotBlank(message = "医生名称必传")
+    private String doctorName;
+
+    /**
+     * 用户ID
+     */
+    @ApiModelProperty(value = "用户ID", required = true)
+    @NotBlank(message = "用户ID必传")
+    private String mpiId;
+
+    /**
+     * 用户名称
+     */
+    @ApiModelProperty(value = "用户名称", required = true)
+    @NotBlank(message = "用户名称必传")
+    private String patientName;
+
+    /**
+     * 用户年龄
+     */
+    @ApiModelProperty(value = "用户年龄", required = true)
+    @NotNull(message = "用户年龄必传")
+    private Integer patientAge;
+
+    /**
+     * 用户性别
+     */
+    @ApiModelProperty(value = "用户性别", required = true)
+    @NotBlank(message = "用户性别必传")
+    private String patientSex;
+
+    /**
+     * 诊断
+     */
+    @ApiModelProperty(value = "诊断", required = true)
+    @NotBlank(message = "诊断必传")
+    private String diagnosis;
+
+
+    /**
+     * 问诊明细
+     */
+    @Valid
+    @ApiModelProperty(value = "问诊明细", required = true)
+    @NotEmpty(message = "问诊明细不能为空")
+    private List<SaveInquiryDetailVO> detailList;
+
+
+}

+ 41 - 0
znwz-service/src/main/java/com/diagbot/web/InquiryInfoController.java

@@ -0,0 +1,41 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.SaveInquiryDTO;
+import com.diagbot.facade.InquiryInfoFacade;
+import com.diagbot.vo.SaveInquiryVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+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;
+
+import javax.validation.Valid;
+
+/**
+ * @author rengb
+ * @since 2018-11-23
+ */
+@RestController
+@RequestMapping("/inquiryInfo")
+@Api(value = "问诊记录API", tags = { "问诊-问诊记录API" })
+@SuppressWarnings("unchecked")
+public class InquiryInfoController {
+
+    @Autowired
+    private InquiryInfoFacade inquiryInfoFacade;
+
+    @ApiOperation(value = "问诊记录保存[by:rengb]")
+    @PostMapping("/saveInquiry")
+    @SysLogger("saveInquiry")
+    @Transactional
+    public RespDTO<SaveInquiryDTO> saveInquiry(@Valid @RequestBody SaveInquiryVO saveInquiryVO) {
+        return RespDTO.onSuc(inquiryInfoFacade.saveInquiry(saveInquiryVO));
+    }
+
+
+}

+ 19 - 0
znwz-service/src/main/resources/mapper/InquiryDetailMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.InquiryDetailMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.InquiryDetail">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="inquiry_id" property="inquiryId" />
+        <result column="question" property="question" />
+        <result column="answer" property="answer" />
+        <result column="remark" property="remark" />
+    </resultMap>
+
+</mapper>

+ 26 - 0
znwz-service/src/main/resources/mapper/InquiryInfoMapper.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.InquiryInfoMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.InquiryInfo">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="app_id" property="appId" />
+        <result column="organ_name" property="organName" />
+        <result column="department" property="department" />
+        <result column="doctor_id" property="doctorId" />
+        <result column="doctor_name" property="doctorName" />
+        <result column="mpi_id" property="mpiId" />
+        <result column="patient_name" property="patientName" />
+        <result column="patient_age" property="patientAge" />
+        <result column="patient_sex" property="patientSex" />
+        <result column="diagnosis" property="diagnosis" />
+        <result column="remark" property="remark" />
+    </resultMap>
+
+</mapper>

+ 4 - 4
znwz-service/src/test/java/com/diagbot/CodeGeneration.java

@@ -48,15 +48,15 @@ public class CodeGeneration {
         dsc.setDbType(DbType.MYSQL);
         dsc.setDriverName("com.mysql.cj.jdbc.Driver");
         dsc.setUsername("root");
-        dsc.setPassword("root");
-        dsc.setUrl("jdbc:mysql://127.0.0.1:3306/sys-log?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8");
+        dsc.setPassword("lantone");
+        dsc.setUrl("jdbc:mysql://192.168.2.236:3306/sys-znwz?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8");
         mpg.setDataSource(dsc);
 
         // 策略配置
         StrategyConfig strategy = new StrategyConfig();
-//        strategy.setTablePrefix(new String[] { "sys_" });// 此处可以修改为您的表前缀
+        strategy.setTablePrefix(new String[] { "znwz_" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "sys_log" }); // 需要生成的表
+        strategy.setInclude(new String[] { "znwz_inquiry_info","znwz_inquiry_detail" }); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);