Browse Source

初始化请求

luqingbin 3 years ago
parent
commit
1f32c714e0
28 changed files with 968 additions and 929 deletions
  1. 4 3
      pom.xml
  2. 0 39
      src/main/java/com/github/yxyl120/opensdk/Utils/SignUtils.java
  3. 0 36
      src/main/java/com/github/yxyl120/opensdk/YxClient.java
  4. 0 15
      src/main/java/com/github/yxyl120/opensdk/YxException.java
  5. 0 18
      src/main/java/com/github/yxyl120/opensdk/domain/JsonResponse.java
  6. 0 100
      src/main/java/com/github/yxyl120/opensdk/domain/RequestParameter.java
  7. 0 159
      src/main/java/com/github/yxyl120/opensdk/domain/order/DrugInfo.java
  8. 0 486
      src/main/java/com/github/yxyl120/opensdk/domain/order/OrderInfo.java
  9. 0 24
      src/main/java/com/github/yxyl120/opensdk/domain/order/RespondOder.java
  10. 113 0
      src/main/java/com/github/yxyl120/sdk/DefaultYxClient.java
  11. 1 1
      src/main/java/com/github/yxyl120/sdk/Utils/AesUtil.java
  12. 18 15
      src/main/java/com/github/yxyl120/sdk/Utils/CheckRequestUtils.java
  13. 6 3
      src/main/java/com/github/yxyl120/sdk/Utils/HttpUtils.java
  14. 9 0
      src/main/java/com/github/yxyl120/sdk/YxClient.java
  15. 36 0
      src/main/java/com/github/yxyl120/sdk/YxException.java
  16. 3 3
      src/main/java/com/github/yxyl120/sdk/annotation/ApiFieldProperty.java
  17. 32 0
      src/main/java/com/github/yxyl120/sdk/annotation/Encrypted.java
  18. 14 0
      src/main/java/com/github/yxyl120/sdk/annotation/Valid.java
  19. 140 0
      src/main/java/com/github/yxyl120/sdk/domain/order/DrugInfo.java
  20. 207 0
      src/main/java/com/github/yxyl120/sdk/domain/order/PatientInfo.java
  21. 6 5
      src/main/java/com/github/yxyl120/sdk/enums/ResponseCode.java
  22. 11 0
      src/main/java/com/github/yxyl120/sdk/request/AbsRequest.java
  23. 221 0
      src/main/java/com/github/yxyl120/sdk/request/PushOrderRequest.java
  24. 32 0
      src/main/java/com/github/yxyl120/sdk/request/YxRequest.java
  25. 29 0
      src/main/java/com/github/yxyl120/sdk/response/AbstractResponse.java
  26. 11 0
      src/main/java/com/github/yxyl120/sdk/response/PushOrderResponse.java
  27. 48 22
      src/test/java/APITest.java
  28. 27 0
      src/test/java/test/dateTest.java

+ 4 - 3
pom.xml

@@ -11,9 +11,10 @@
 
     <dependencies>
         <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.4</version>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <version>5.2.15.RELEASE</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>commons-codec</groupId>

+ 0 - 39
src/main/java/com/github/yxyl120/opensdk/Utils/SignUtils.java

@@ -1,39 +0,0 @@
-package com.github.yxyl120.opensdk.Utils;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.yxyl120.opensdk.YxException;
-import com.github.yxyl120.opensdk.domain.RequestParameter;
-import org.apache.commons.codec.digest.DigestUtils;
-
-import java.nio.charset.Charset;
-import java.util.LinkedList;
-import java.util.List;
-
-public class SignUtils {
-    private static final Charset UTF_8 = Charset.forName("UTF-8");
-
-    public static String sign(RequestParameter parameter) throws YxException {
-        try {
-            long timestamp = System.currentTimeMillis();
-            parameter.setTimestamp(timestamp);
-
-            List<String> list = new LinkedList<>();
-
-            list.add(parameter.getAct_id());
-            list.add(parameter.getManu_id());
-            list.add(parameter.getApp_id());
-            list.add(String.valueOf(timestamp));
-            // 大于等于1.0之后的版本需要将传参也带上进行签名
-            if (parameter.getVersion() >= 1.0) {
-                ObjectMapper mapper = new ObjectMapper();
-                list.add(mapper.writeValueAsString(parameter.getData()));
-            }
-            byte[] bytes = String.join("&", list).getBytes(UTF_8);
-            return DigestUtils.md5Hex(bytes).toUpperCase();
-        } catch (Exception ex) {
-            throw new YxException("签名失败", ex);
-        }
-    }
-
-
-}

+ 0 - 36
src/main/java/com/github/yxyl120/opensdk/YxClient.java

@@ -1,36 +0,0 @@
-package com.github.yxyl120.opensdk;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.yxyl120.opensdk.Utils.HttpUtils;
-import com.github.yxyl120.opensdk.Utils.ParameterCheckUtils;
-import com.github.yxyl120.opensdk.Utils.SignUtils;
-import com.github.yxyl120.opensdk.domain.RequestParameter;
-import com.github.yxyl120.opensdk.domain.order.OrderInfo;
-
-public class YxClient {
-
-    /**
-     * 推送订单到一线平台
-     *
-     * @param api       接口
-     * @param parameter 接口参数
-     * @return 推送结果
-     * @throws YxException
-     */
-    public static String pushOrder(String api, RequestParameter<OrderInfo> parameter) throws YxException {
-        ParameterCheckUtils.checkParameters(parameter);
-        String sign = SignUtils.sign(parameter);
-        parameter.setSig(sign);
-        return HttpUtils.post(api, toJson(parameter));
-    }
-
-    private static String toJson(Object object) {
-        ObjectMapper mapper = new ObjectMapper();
-        try {
-            return mapper.writeValueAsString(object);
-        } catch (JsonProcessingException e) {
-            return "";
-        }
-    }
-}

+ 0 - 15
src/main/java/com/github/yxyl120/opensdk/YxException.java

@@ -1,15 +0,0 @@
-package com.github.yxyl120.opensdk;
-
-public class YxException extends Exception {
-
-    public YxException() {
-    }
-
-    public YxException(String message) {
-        super(message);
-    }
-
-    public YxException(String msg, Throwable throwable) {
-        super(msg, throwable);
-    }
-}

+ 0 - 18
src/main/java/com/github/yxyl120/opensdk/domain/JsonResponse.java

@@ -1,18 +0,0 @@
-package com.github.yxyl120.opensdk.domain;
-
-import java.io.Serializable;
-
-public class JsonResponse<T> implements Serializable {
-    /**
-     * 结果的描述
-     */
-    private String msg;
-    /**
-     * 操作结果识别码
-     */
-    private Integer code;
-    /**
-     * 返回的结果对象
-     */
-    private T data;
-}

+ 0 - 100
src/main/java/com/github/yxyl120/opensdk/domain/RequestParameter.java

@@ -1,100 +0,0 @@
-package com.github.yxyl120.opensdk.domain;
-
-import com.github.yxyl120.opensdk.annotation.ApiFieldProperty;
-
-public class RequestParameter<T> {
-
-    /**
-     * 操作码
-     */
-    @ApiFieldProperty(notes = "操作码")
-    private String act_id;
-    /**
-     * 为对接厂商提供的编码
-     */
-    @ApiFieldProperty(notes = "为对接厂商提供的编码")
-    private String manu_id;
-    /**
-     * 分配给厂商对接的互联网医院编码
-     */
-    @ApiFieldProperty(notes = "分配给厂商对接的互联网医院编码")
-    private String app_id;
-
-    @ApiFieldProperty(notes = "接口版本")
-    private double version;
-
-
-    /**
-     * 请求的时间戳
-     */
-    @ApiFieldProperty(notes = "请求的时间戳")
-    private long timestamp;
-    /**
-     * 签名结果
-     */
-    @ApiFieldProperty(notes = "签名结果",required = false)
-    private String sig;
-
-    @ApiFieldProperty(notes = "本次提交的数据参数", multipartField = true)
-    private T data;
-
-    public RequestParameter() {
-
-    }
-
-    public String getAct_id() {
-        return act_id;
-    }
-
-    public void setAct_id(String act_id) {
-        this.act_id = act_id;
-    }
-
-    public String getManu_id() {
-        return manu_id;
-    }
-
-    public void setManu_id(String manu_id) {
-        this.manu_id = manu_id;
-    }
-
-    public String getApp_id() {
-        return app_id;
-    }
-
-    public void setApp_id(String app_id) {
-        this.app_id = app_id;
-    }
-
-    public double getVersion() {
-        return version;
-    }
-
-    public void setVersion(double version) {
-        this.version = version;
-    }
-
-    public long getTimestamp() {
-        return timestamp;
-    }
-
-    public void setTimestamp(long timestamp) {
-        this.timestamp = timestamp;
-    }
-
-    public String getSig() {
-        return sig;
-    }
-
-    public void setSig(String sig) {
-        this.sig = sig;
-    }
-
-    public T getData() {
-        return data;
-    }
-
-    public void setData(T data) {
-        this.data = data;
-    }
-}

+ 0 - 159
src/main/java/com/github/yxyl120/opensdk/domain/order/DrugInfo.java

@@ -1,159 +0,0 @@
-package com.github.yxyl120.opensdk.domain.order;
-
-import com.github.yxyl120.opensdk.annotation.ApiFieldProperty;
-
-public class DrugInfo {
-    /**
-     * 药品名称(通用名)
-     */
-    @ApiFieldProperty( notes = "药品名称(通用名)")
-    private String drug_common_name;
-
-    /**
-     * 药品规格
-     */
-    @ApiFieldProperty( notes = "药品规格")
-    private String drug_specification;
-
-    /**
-     * 使用方法
-     */
-    @ApiFieldProperty( notes = "使用方法", required = false)
-    private String usage_method;
-
-    /**
-     * 药品频次
-     */
-    @ApiFieldProperty( notes = "药品频次", required = false)
-    private String usage_frequency_unit;
-
-    /**
-     * 每次用药数量
-     */
-    @ApiFieldProperty( notes = "每次用药数量", required = false)
-    private String usage_per_use_count;
-
-    /**
-     * 每次用药单位
-     */
-    @ApiFieldProperty( notes = "每次用药单位", required = false)
-    private String usage_per_use_unit;
-
-    /**
-     * 天数
-     */
-    @ApiFieldProperty( notes = "天数", required = false)
-    private String usage_days;
-
-    /**
-     * 药品数量
-     */
-    @ApiFieldProperty( notes = "药品数量")
-    private String sale_amount;
-
-    /**
-     * 药品数量单位
-     */
-    @ApiFieldProperty( notes = "药品数量单位", required = false)
-    private String sale_unit;
-
-    /**
-     * 药品说明书
-     */
-    @ApiFieldProperty( notes = "药品说明书", required = false)
-    private String instructions;
-
-    /**
-     * 药品产品批准文号              
-     */
-    @ApiFieldProperty( notes = "药品产品批准文号")
-    private String approval_number;
-
-    public String getDrug_common_name() {
-        return drug_common_name;
-    }
-
-    public void setDrug_common_name(String drug_common_name) {
-        this.drug_common_name = drug_common_name;
-    }
-
-    public String getDrug_specification() {
-        return drug_specification;
-    }
-
-    public void setDrug_specification(String drug_specification) {
-        this.drug_specification = drug_specification;
-    }
-
-    public String getUsage_method() {
-        return usage_method;
-    }
-
-    public void setUsage_method(String usage_method) {
-        this.usage_method = usage_method;
-    }
-
-    public String getUsage_frequency_unit() {
-        return usage_frequency_unit;
-    }
-
-    public void setUsage_frequency_unit(String usage_frequency_unit) {
-        this.usage_frequency_unit = usage_frequency_unit;
-    }
-
-    public String getUsage_per_use_count() {
-        return usage_per_use_count;
-    }
-
-    public void setUsage_per_use_count(String usage_per_use_count) {
-        this.usage_per_use_count = usage_per_use_count;
-    }
-
-    public String getUsage_per_use_unit() {
-        return usage_per_use_unit;
-    }
-
-    public void setUsage_per_use_unit(String usage_per_use_unit) {
-        this.usage_per_use_unit = usage_per_use_unit;
-    }
-
-    public String getUsage_days() {
-        return usage_days;
-    }
-
-    public void setUsage_days(String usage_days) {
-        this.usage_days = usage_days;
-    }
-
-    public String getSale_amount() {
-        return sale_amount;
-    }
-
-    public void setSale_amount(String sale_amount) {
-        this.sale_amount = sale_amount;
-    }
-
-    public String getSale_unit() {
-        return sale_unit;
-    }
-
-    public void setSale_unit(String sale_unit) {
-        this.sale_unit = sale_unit;
-    }
-
-    public String getInstructions() {
-        return instructions;
-    }
-
-    public void setInstructions(String instructions) {
-        this.instructions = instructions;
-    }
-
-    public String getApproval_number() {
-        return approval_number;
-    }
-
-    public void setApproval_number(String approval_number) {
-        this.approval_number = approval_number;
-    }
-}

+ 0 - 486
src/main/java/com/github/yxyl120/opensdk/domain/order/OrderInfo.java

@@ -1,486 +0,0 @@
-package com.github.yxyl120.opensdk.domain.order;
-
-import com.github.yxyl120.opensdk.annotation.ApiFieldProperty;
-
-import java.util.ArrayList;
-
-/**
- *
- */
-public class OrderInfo {
-    /**
-     * 药品类型:01西药 02中药
-     */
-    @ApiFieldProperty(notes = "药品类型:01西药 02中药", required = false)
-    private String rp_type;
-
-    /**
-     * 处方单ID(唯一ID)
-     */
-    @ApiFieldProperty(notes = "处方单ID(唯一ID)")
-    private String rp_id;
-
-    /**
-     * 门店ID
-     */
-    @ApiFieldProperty(notes = "门店ID")
-    private String pharmacy_code;
-
-    /**
-     * 门店名称
-     */
-    @ApiFieldProperty(notes = "门店名称")
-    private String pharmacy_name;
-
-    /**
-     * 病情描述(主诉)
-     */
-    @ApiFieldProperty(notes = "病情描述(主诉)")
-    private String chief_complaint;
-
-    /**
-     * 现病史
-     */
-    @ApiFieldProperty(notes = "现病史", required = false)
-    private String now_illness;
-
-    /**
-     * 既往史
-     */
-    @ApiFieldProperty(notes = "既往史", required = false)
-    private String history_illness;
-
-    /**
-     * 患者年龄
-     */
-    @ApiFieldProperty(notes = "患者年龄")
-    private Integer patient_age;
-
-    /**
-     * 患者姓名
-     */
-    @ApiFieldProperty(notes = "患者姓名")
-    private String patient_name;
-
-    /**
-     * 体重
-     */
-    @ApiFieldProperty(notes = "体重", required = false)
-    private Integer weight;
-
-    /**
-     * 对应icd名称
-     */
-    @ApiFieldProperty(notes = "对应icd名称", required = false)
-    private String icd_name;
-
-    /**
-     * 对应icd名称2
-     */
-    @ApiFieldProperty(notes = "对应icd名称2", required = false)
-    private String icd_name2;
-
-    /**
-     * 是否有过敏史(传值:是/否)
-     */
-    @ApiFieldProperty(notes = "是否有过敏史(传值:是/否)")
-    private String is_history_allergic;
-
-    /**
-     * 过敏史
-     */
-    @ApiFieldProperty(notes = "过敏史", required = false)
-    private String history_allergic;
-
-    /**
-     * 肝功能是否异常(传值:是/否)
-     */
-    @ApiFieldProperty(notes = "肝功能是否异常(传值:是/否)")
-    private String liver_unusual;
-
-    /**
-     * 肾功能是否异常(传值:是/否)
-     */
-    @ApiFieldProperty(notes = "肾功能是否异常(传值:是/否)")
-    private String renal_unusual;
-
-    /**
-     * 是否是备孕/怀孕/哺乳期(传值:是/否)
-     */
-    @ApiFieldProperty(notes = "是否是备孕/怀孕/哺乳期(传值:是/否)")
-    private String lactation_flag;
-
-    /**
-     * 患者手机号(通过订单号去订单中心查)
-     */
-    @ApiFieldProperty(notes = "患者手机号(通过订单号去订单中心查)")
-    private String patient_tel;
-
-    /**
-     * 患者性别(传数字,1男
-     */
-    @ApiFieldProperty(notes = "患者性别(传数字,1男,2女)")
-    private String patient_gender;
-
-    /**
-     * 复诊凭证
-     */
-    @ApiFieldProperty(notes = "复诊凭证链接数组", required = false)
-    private ArrayList<String> record_pic;
-
-    /**
-     * 处方开具时间(来互联网医院开方的时间)
-     */
-    @ApiFieldProperty(notes = "处方开具时间(来互联网医院开方的时间)")
-    private String rp_create_time;
-
-    /**
-     * 处方文件格式(传值:png/jpg)
-     */
-    @ApiFieldProperty(notes = "处方文件格式(传值:png/jpg)")
-    private String rp_url_type;
-
-    /**
-     * 药师ID
-     */
-    @ApiFieldProperty(notes = "药师ID", required = false)
-    private String pharmacist_id;
-
-    /**
-     * 药师名称
-     */
-    @ApiFieldProperty(notes = "药师名称", required = false)
-    private String pharmacist_name;
-
-    /**
-     * 药师签名地址
-     */
-    @ApiFieldProperty(notes = "药师签名地址", required = false)
-    private String pharmacist_autograph;
-
-    /**
-     * 发药药师ID
-     */
-    @ApiFieldProperty(notes = "发药药师ID", required = false)
-    private String dispensing_pharmacist_id;
-
-    /**
-     * 发药药师名称
-     */
-    @ApiFieldProperty(notes = "发药药师名称", required = false)
-    private String dispensing_pharmacist_name;
-
-    /**
-     * 发药药师签名地址
-     */
-    @ApiFieldProperty(notes = "发药药师签名地址", required = false)
-    private String dispensing_pharmacist_autograph;
-
-    /**
-     * 配药药师ID
-     */
-    @ApiFieldProperty(notes = "配药药师ID", required = false)
-    private String deployment_pharmacist_id;
-
-    /**
-     * 配药药师名称
-     */
-    @ApiFieldProperty(notes = "配药药师名称", required = false)
-    private String deployment_pharmacist_name;
-
-    /**
-     * 配药药师签名地址
-     */
-    @ApiFieldProperty(notes = "配药药师签名地址", required = false)
-    private String deployment_pharmacist_autograph;
-
-    /**
-     * 是否提供药师审核,0-不使用一线平台的药师审核,1-使用一线平台的药师审核
-     */
-    @ApiFieldProperty(notes = "是否提供药师审核,0-不使用一线平台的药师审核,1-使用一线平台的药师审核", required = false)
-    private Integer is_pharmacist_audit;
-
-    /**
-     * 回调地址,如果填写,审核完处方后自动回调到第三方药房服务接口,参考3.1.4
-     */
-    @ApiFieldProperty(notes = "回调地址,如果填写,审核完处方后自动回调到第三方药房服务接口,参考3.1.4", required = false)
-    private String callback_url;
-
-    /**
-     * 订单药品列表
-     */
-    @ApiFieldProperty(notes = "订单药品列表", multipartField = true)
-    private ArrayList<DrugInfo> drug_list;
-
-    public String getRp_type() {
-        return rp_type;
-    }
-
-    public void setRp_type(String rp_type) {
-        this.rp_type = rp_type;
-    }
-
-    public String getRp_id() {
-        return rp_id;
-    }
-
-    public void setRp_id(String rp_id) {
-        this.rp_id = rp_id;
-    }
-
-    public String getPharmacy_code() {
-        return pharmacy_code;
-    }
-
-    public void setPharmacy_code(String pharmacy_code) {
-        this.pharmacy_code = pharmacy_code;
-    }
-
-    public String getPharmacy_name() {
-        return pharmacy_name;
-    }
-
-    public void setPharmacy_name(String pharmacy_name) {
-        this.pharmacy_name = pharmacy_name;
-    }
-
-    public String getChief_complaint() {
-        return chief_complaint;
-    }
-
-    public void setChief_complaint(String chief_complaint) {
-        this.chief_complaint = chief_complaint;
-    }
-
-    public String getNow_illness() {
-        return now_illness;
-    }
-
-    public void setNow_illness(String now_illness) {
-        this.now_illness = now_illness;
-    }
-
-    public String getHistory_illness() {
-        return history_illness;
-    }
-
-    public void setHistory_illness(String history_illness) {
-        this.history_illness = history_illness;
-    }
-
-    public Integer getPatient_age() {
-        return patient_age;
-    }
-
-    public void setPatient_age(Integer patient_age) {
-        this.patient_age = patient_age;
-    }
-
-    public String getPatient_name() {
-        return patient_name;
-    }
-
-    public void setPatient_name(String patient_name) {
-        this.patient_name = patient_name;
-    }
-
-    public Integer getWeight() {
-        return weight;
-    }
-
-    public void setWeight(Integer weight) {
-        this.weight = weight;
-    }
-
-    public String getIcd_name() {
-        return icd_name;
-    }
-
-    public void setIcd_name(String icd_name) {
-        this.icd_name = icd_name;
-    }
-
-    public String getIcd_name2() {
-        return icd_name2;
-    }
-
-    public void setIcd_name2(String icd_name2) {
-        this.icd_name2 = icd_name2;
-    }
-
-    public String getIs_history_allergic() {
-        return is_history_allergic;
-    }
-
-    public void setIs_history_allergic(String is_history_allergic) {
-        this.is_history_allergic = is_history_allergic;
-    }
-
-    public String getHistory_allergic() {
-        return history_allergic;
-    }
-
-    public void setHistory_allergic(String history_allergic) {
-        this.history_allergic = history_allergic;
-    }
-
-    public String getLiver_unusual() {
-        return liver_unusual;
-    }
-
-    public void setLiver_unusual(String liver_unusual) {
-        this.liver_unusual = liver_unusual;
-    }
-
-    public String getRenal_unusual() {
-        return renal_unusual;
-    }
-
-    public void setRenal_unusual(String renal_unusual) {
-        this.renal_unusual = renal_unusual;
-    }
-
-    public String getLactation_flag() {
-        return lactation_flag;
-    }
-
-    public void setLactation_flag(String lactation_flag) {
-        this.lactation_flag = lactation_flag;
-    }
-
-    public String getPatient_tel() {
-        return patient_tel;
-    }
-
-    public void setPatient_tel(String patient_tel) {
-        this.patient_tel = patient_tel;
-    }
-
-    public String getPatient_gender() {
-        return patient_gender;
-    }
-
-    public void setPatient_gender(String patient_gender) {
-        this.patient_gender = patient_gender;
-    }
-
-    public ArrayList<String> getRecord_pic() {
-        return record_pic;
-    }
-
-    public void setRecord_pic(ArrayList<String> record_pic) {
-        this.record_pic = record_pic;
-    }
-
-    public String getRp_create_time() {
-        return rp_create_time;
-    }
-
-    public void setRp_create_time(String rp_create_time) {
-        this.rp_create_time = rp_create_time;
-    }
-
-    public String getRp_url_type() {
-        return rp_url_type;
-    }
-
-    public void setRp_url_type(String rp_url_type) {
-        this.rp_url_type = rp_url_type;
-    }
-
-    public String getPharmacist_id() {
-        return pharmacist_id;
-    }
-
-    public void setPharmacist_id(String pharmacist_id) {
-        this.pharmacist_id = pharmacist_id;
-    }
-
-    public String getPharmacist_name() {
-        return pharmacist_name;
-    }
-
-    public void setPharmacist_name(String pharmacist_name) {
-        this.pharmacist_name = pharmacist_name;
-    }
-
-    public String getPharmacist_autograph() {
-        return pharmacist_autograph;
-    }
-
-    public void setPharmacist_autograph(String pharmacist_autograph) {
-        this.pharmacist_autograph = pharmacist_autograph;
-    }
-
-    public String getDispensing_pharmacist_id() {
-        return dispensing_pharmacist_id;
-    }
-
-    public void setDispensing_pharmacist_id(String dispensing_pharmacist_id) {
-        this.dispensing_pharmacist_id = dispensing_pharmacist_id;
-    }
-
-    public String getDispensing_pharmacist_name() {
-        return dispensing_pharmacist_name;
-    }
-
-    public void setDispensing_pharmacist_name(String dispensing_pharmacist_name) {
-        this.dispensing_pharmacist_name = dispensing_pharmacist_name;
-    }
-
-    public String getDispensing_pharmacist_autograph() {
-        return dispensing_pharmacist_autograph;
-    }
-
-    public void setDispensing_pharmacist_autograph(String dispensing_pharmacist_autograph) {
-        this.dispensing_pharmacist_autograph = dispensing_pharmacist_autograph;
-    }
-
-    public String getDeployment_pharmacist_id() {
-        return deployment_pharmacist_id;
-    }
-
-    public void setDeployment_pharmacist_id(String deployment_pharmacist_id) {
-        this.deployment_pharmacist_id = deployment_pharmacist_id;
-    }
-
-    public String getDeployment_pharmacist_name() {
-        return deployment_pharmacist_name;
-    }
-
-    public void setDeployment_pharmacist_name(String deployment_pharmacist_name) {
-        this.deployment_pharmacist_name = deployment_pharmacist_name;
-    }
-
-    public String getDeployment_pharmacist_autograph() {
-        return deployment_pharmacist_autograph;
-    }
-
-    public void setDeployment_pharmacist_autograph(String deployment_pharmacist_autograph) {
-        this.deployment_pharmacist_autograph = deployment_pharmacist_autograph;
-    }
-
-    public Integer getIs_pharmacist_audit() {
-        return is_pharmacist_audit;
-    }
-
-    public void setIs_pharmacist_audit(Integer is_pharmacist_audit) {
-        this.is_pharmacist_audit = is_pharmacist_audit;
-    }
-
-    public String getCallback_url() {
-        return callback_url;
-    }
-
-    public void setCallback_url(String callback_url) {
-        this.callback_url = callback_url;
-    }
-
-    public ArrayList<DrugInfo> getDrug_list() {
-        return drug_list;
-    }
-
-    public void setDrug_list(ArrayList<DrugInfo> drug_list) {
-        this.drug_list = drug_list;
-    }
-}

+ 0 - 24
src/main/java/com/github/yxyl120/opensdk/domain/order/RespondOder.java

@@ -1,24 +0,0 @@
-package com.github.yxyl120.opensdk.domain.order;
-
-public class RespondOder {
-//     {
-//        "rp_id": "c80f1d2b38abb34ce83967b373bd896d", //处方单ID(唯一ID)
-//        "depart_name": "",   //科室名称
-//        "doctor_name": "汤云霞", //医生名字
-//        "rp_url": null,   //处方图片地址
-//        "diagnose": "",   //诊断
-//        "rp_msg": "已开方",
-//        "audit_reason": null,    //医生拒方原因
-//        "drugInfo": [
-//            {
-//                "drug_name": "阿莫西林胶囊-阿莫仙",   //药品名称
-//                "sale_amount": 2, //药品数量
-//                "drug_specification": "0.5g*24S"//药品规格
-//            }
-//        ],
-//        "create_date": "2021-04-09 14:37:34",
-//        "pharmacy_code": 489,    //药店ID
-//        "pharmacy_name": "康爱多大药房",    //药店名称
-//        "doctor_id": "1133"  //医生ID
-//    }
-}

+ 113 - 0
src/main/java/com/github/yxyl120/sdk/DefaultYxClient.java

@@ -0,0 +1,113 @@
+package com.github.yxyl120.sdk;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.yxyl120.sdk.Utils.CheckRequestUtils;
+import com.github.yxyl120.sdk.Utils.HttpUtils;
+import com.github.yxyl120.sdk.request.YxRequest;
+import com.github.yxyl120.sdk.response.AbstractResponse;
+import org.springframework.util.DigestUtils;
+
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class DefaultYxClient implements YxClient {
+
+    private String serverUrl;
+    private String appId;
+    private String appSecret;
+    private ObjectMapper mapper;
+    private static final String ENC = "UTF-8";
+
+    public DefaultYxClient(String serverUrl, String appId, String appSecret) {
+        this.serverUrl = serverUrl;
+        this.appId = appId;
+        this.appSecret = appSecret;
+        this.mapper = new ObjectMapper();
+    }
+
+    /**
+     * 执行请求
+     *
+     * @param request 入参
+     * @param <T>     返回的类型
+     * @return 返回的实体类
+     */
+    @Override
+    public <T extends AbstractResponse> T execute(YxRequest<T> request) {
+        CheckRequestUtils.doCheck(request);
+        String bodyStr = toJson(request);
+        String url = this.buildUrl(request, bodyStr);
+        String responseBodyStr = HttpUtils.post(url, bodyStr);
+        T readValue = parse(responseBodyStr, request.getResponseClass());
+        if (readValue == null) {
+            throw new YxException("解析数据异常:" + responseBodyStr, 400);
+        }
+        if (readValue.getCode() != SUCCESS_CODE) {
+            throw new YxException(readValue.getMsg(), readValue.getCode());
+        }
+        return readValue;
+    }
+
+    private <T> T parse(String jsonStr, Class<T> tClass) {
+        try {
+            return mapper.readValue(jsonStr, tClass);
+        } catch (JsonProcessingException e) {
+            return null;
+        }
+    }
+
+    private String buildUrl(YxRequest request, String body) {
+        Map<String, Object> pmap = new TreeMap<>();
+        pmap.put("timestamp", System.currentTimeMillis());
+        pmap.put("appId", this.appId);
+        pmap.put("version", "1.0");
+        pmap.put("signMethod", "md5Hex");
+        if (request.getQueryParam() != null && request.getQueryParam().size() > 0) {
+            pmap.putAll(request.getQueryParam());
+        }
+        ArrayList<String> keys = new ArrayList<>(pmap.keySet());
+        Collections.sort(keys);
+
+        StringBuilder buffer = new StringBuilder();
+        try {
+            for (String key : keys) {
+                if (buffer.length() != 0) {
+                    buffer.append('&');
+                }
+                Object value = pmap.get(key);
+                buffer.append(key).append('=').append(obj2URLEncoder(value));
+            }
+        } catch (Exception ignored) {
+        }
+        String query = buffer.toString();
+        buffer.append("&appSecret=")
+                .append(this.appSecret)
+                .append("&body=").append(body);
+        System.out.println(buffer.toString());
+
+        String sign = DigestUtils.md5DigestAsHex(buffer.toString().getBytes(StandardCharsets.UTF_8));
+
+        return this.serverUrl + request.getApi() + "?" + query + "&sign=" + sign;
+    }
+
+    private String obj2URLEncoder(Object object) throws Exception {
+        if (object instanceof String || object instanceof Number) {
+            return URLEncoder.encode(object.toString(), ENC);
+        }
+        return URLEncoder.encode(toJson(object), ENC);
+    }
+
+    private String toJson(Object object) {
+        try {
+            return mapper.writeValueAsString(object);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+}

+ 1 - 1
src/main/java/com/github/yxyl120/opensdk/Utils/AesUtil.java → src/main/java/com/github/yxyl120/sdk/Utils/AesUtil.java

@@ -1,4 +1,4 @@
-package com.github.yxyl120.opensdk.Utils;
+package com.github.yxyl120.sdk.Utils;
 
 import org.apache.commons.codec.binary.Hex;
 

+ 18 - 15
src/main/java/com/github/yxyl120/opensdk/Utils/ParameterCheckUtils.java → src/main/java/com/github/yxyl120/sdk/Utils/CheckRequestUtils.java

@@ -1,46 +1,49 @@
-package com.github.yxyl120.opensdk.Utils;
+package com.github.yxyl120.sdk.Utils;
 
-import com.github.yxyl120.opensdk.YxException;
-import com.github.yxyl120.opensdk.annotation.ApiFieldProperty;
+import com.github.yxyl120.sdk.YxException;
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+import com.github.yxyl120.sdk.annotation.Valid;
 
 import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.Map;
 
-public class ParameterCheckUtils {
+public class CheckRequestUtils {
     /**
      * 用于缓存类的属性字段
      */
     private static final Map<String, Map<Field, ApiFieldProperty>> fieldPropertys = new HashMap<>();
 
-    public static void checkParameters(Object parameter) throws YxException {
+    public static void doCheck(Object parameter) throws YxException {
         if (parameter == null) {
-            throw new YxException("参数不能为空");
+            throw new YxException("参数不能为空", 400);
         }
         String simpleName = parameter.getClass().getName();
         Map<Field, ApiFieldProperty> propertyMap = fieldPropertys.get(simpleName);
         if (null == propertyMap) {
             propertyMap = new HashMap<>();
             for (Field field : parameter.getClass().getDeclaredFields()) {
-                field.setAccessible(true);
-                propertyMap.put(field, field.getAnnotation(ApiFieldProperty.class));
+                ApiFieldProperty fieldAnnotation = field.getAnnotation(ApiFieldProperty.class);
+                if (fieldAnnotation != null) {
+                    field.setAccessible(true);
+                    propertyMap.put(field, fieldAnnotation);
+                }
             }
             fieldPropertys.put(simpleName, propertyMap);
         }
 
         try {
             for (Map.Entry<Field, ApiFieldProperty> entry : propertyMap.entrySet()) {
-                ApiFieldProperty value = entry.getValue();
                 Field key = entry.getKey();
                 String name = key.getType().getName();
-                if (value.required()) {
-                    Object o = key.get(parameter);
-                    if (o == null || ("java.lang.String".equals(name) && isEmpty((String) o))) {
-                        throw new YxException("参数[" + key.getName() + "]不能为空,字段描述:" + value.notes());
+                if (entry.getValue().required()) {
+                    Object value = key.get(parameter);
+                    if (value == null || ("java.lang.String".equals(name) && isEmpty((String) value))) {
+                        throw new YxException("参数[" + key.getName() + "]不能为空,字段描述:" + entry.getValue().notes(), 400);
                     }
                 }
-                if (value.multipartField()) {
-                    checkParameters(key.get(parameter));
+                if (entry.getKey().getAnnotation(Valid.class) != null) {
+                    doCheck(key.get(parameter));
                 }
             }
         } catch (IllegalAccessException ignored) {

+ 6 - 3
src/main/java/com/github/yxyl120/opensdk/Utils/HttpUtils.java → src/main/java/com/github/yxyl120/sdk/Utils/HttpUtils.java

@@ -1,6 +1,6 @@
-package com.github.yxyl120.opensdk.Utils;
+package com.github.yxyl120.sdk.Utils;
 
-import com.github.yxyl120.opensdk.YxException;
+import com.github.yxyl120.sdk.YxException;
 
 import java.io.*;
 import java.net.HttpURLConnection;
@@ -21,6 +21,8 @@ public class HttpUtils {
      * @throws Exception -
      */
     public static String post(String api, String jsonStr) throws YxException {
+        System.out.println(api);
+        System.out.println(jsonStr);
         StringBuilder result = new StringBuilder();
         DataOutputStream out = null;
         BufferedReader bufferedReader = null;
@@ -48,7 +50,8 @@ public class HttpUtils {
                 result.append(getLine);
             }
         } catch (Exception e) {
-            throw new YxException("请求接口" + api + "发生错误", e);
+            e.printStackTrace();
+            throw new YxException("请求接口" + api + "发生错误", e,400);
         } finally {
             close(out);
             close(bufferedReader);

+ 9 - 0
src/main/java/com/github/yxyl120/sdk/YxClient.java

@@ -0,0 +1,9 @@
+package com.github.yxyl120.sdk;
+
+import com.github.yxyl120.sdk.request.YxRequest;
+import com.github.yxyl120.sdk.response.AbstractResponse;
+
+public interface YxClient {
+    int SUCCESS_CODE = 200;
+    <T extends AbstractResponse> T execute(YxRequest<T> request) throws YxException;
+}

+ 36 - 0
src/main/java/com/github/yxyl120/sdk/YxException.java

@@ -0,0 +1,36 @@
+package com.github.yxyl120.sdk;
+
+public class YxException extends RuntimeException {
+    /**
+     * 响应码
+     */
+    private int code;
+
+    public YxException(int code) {
+        this.code = code;
+    }
+
+    public YxException(String message, int code) {
+        super(message);
+        this.code = code;
+    }
+
+    public YxException(String message, Throwable cause, int code) {
+        super(message, cause);
+        this.code = code;
+    }
+
+    public YxException(Throwable cause, int code) {
+        super(cause);
+        this.code = code;
+    }
+
+    public YxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, int code) {
+        super(message, cause, enableSuppression, writableStackTrace);
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
+}

+ 3 - 3
src/main/java/com/github/yxyl120/opensdk/annotation/ApiFieldProperty.java → src/main/java/com/github/yxyl120/sdk/annotation/ApiFieldProperty.java

@@ -1,4 +1,4 @@
-package com.github.yxyl120.opensdk.annotation;
+package com.github.yxyl120.sdk.annotation;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -12,12 +12,12 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 public @interface ApiFieldProperty {
 
+    String value() default "";
     /**
      * 指定是否需要该参数。默认必须
      */
-    boolean required() default true;
+    boolean required() default false;
 
-    boolean multipartField() default false;
     /**
      *
      * @return

+ 32 - 0
src/main/java/com/github/yxyl120/sdk/annotation/Encrypted.java

@@ -0,0 +1,32 @@
+package com.github.yxyl120.sdk.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Encrypted {
+    /**
+     * 入参时是否需要解密
+     *
+     * @return 默认为需要
+     */
+    boolean inDecode() default true;
+
+    /**
+     * 加密方式
+     *
+     * @return -
+     */
+    String type() default "AES";
+
+    /**
+     * 返参时是否需要加密
+     *
+     * @return 默认为需要
+     */
+    boolean outEncode() default true;
+
+}

+ 14 - 0
src/main/java/com/github/yxyl120/sdk/annotation/Valid.java

@@ -0,0 +1,14 @@
+package com.github.yxyl120.sdk.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({ ElementType.FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface Valid {
+}

+ 140 - 0
src/main/java/com/github/yxyl120/sdk/domain/order/DrugInfo.java

@@ -0,0 +1,140 @@
+package com.github.yxyl120.sdk.domain.order;
+
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+
+import java.io.Serializable;
+
+public class DrugInfo implements Serializable{
+
+    @ApiFieldProperty(value = "合作方药品id", required = true)
+    private Serializable drugIdThird;
+
+    @ApiFieldProperty(value = "药品通用名称", required = true)
+    private String drugNameComm;
+
+    @ApiFieldProperty(value = "药品规格", required = true)
+    private String drugSpecification;
+
+    @ApiFieldProperty(value = "药品数量", required = true)
+    private Integer saleAmount;
+
+    @ApiFieldProperty(value = "包装单位,例:盒、瓶", required = true)
+    private String saleUnit;
+
+    @ApiFieldProperty("天数,选填")
+    private Integer usageDays;
+
+    @ApiFieldProperty("用药方法,选填")
+    private String usageName;
+
+    @ApiFieldProperty("使用频次单位,选填")
+    private String freqUnit;
+
+    @ApiFieldProperty("使用频次数量,选填")
+    private String freqTimes;
+
+    @ApiFieldProperty("使用剂量单位,选填")
+    private String doseUnit;
+
+    @ApiFieldProperty("使用剂量数量")
+    private String doseNum;
+
+    @ApiFieldProperty("说明书")
+    private String instructions;
+
+    public Serializable getDrugIdThird() {
+        return drugIdThird;
+    }
+
+    public void setDrugIdThird(Serializable drugIdThird) {
+        this.drugIdThird = drugIdThird;
+    }
+
+    public String getDrugNameComm() {
+        return drugNameComm;
+    }
+
+    public void setDrugNameComm(String drugNameComm) {
+        this.drugNameComm = drugNameComm;
+    }
+
+    public String getDrugSpecification() {
+        return drugSpecification;
+    }
+
+    public void setDrugSpecification(String drugSpecification) {
+        this.drugSpecification = drugSpecification;
+    }
+
+    public Integer getSaleAmount() {
+        return saleAmount;
+    }
+
+    public void setSaleAmount(Integer saleAmount) {
+        this.saleAmount = saleAmount;
+    }
+
+    public String getSaleUnit() {
+        return saleUnit;
+    }
+
+    public void setSaleUnit(String saleUnit) {
+        this.saleUnit = saleUnit;
+    }
+
+    public Integer getUsageDays() {
+        return usageDays;
+    }
+
+    public void setUsageDays(Integer usageDays) {
+        this.usageDays = usageDays;
+    }
+
+    public String getUsageName() {
+        return usageName;
+    }
+
+    public void setUsageName(String usageName) {
+        this.usageName = usageName;
+    }
+
+    public String getFreqUnit() {
+        return freqUnit;
+    }
+
+    public void setFreqUnit(String freqUnit) {
+        this.freqUnit = freqUnit;
+    }
+
+    public String getFreqTimes() {
+        return freqTimes;
+    }
+
+    public void setFreqTimes(String freqTimes) {
+        this.freqTimes = freqTimes;
+    }
+
+    public String getDoseUnit() {
+        return doseUnit;
+    }
+
+    public void setDoseUnit(String doseUnit) {
+        this.doseUnit = doseUnit;
+    }
+
+    public String getDoseNum() {
+        return doseNum;
+    }
+
+    public void setDoseNum(String doseNum) {
+        this.doseNum = doseNum;
+    }
+
+    public String getInstructions() {
+        return instructions;
+    }
+
+    public void setInstructions(String instructions) {
+        this.instructions = instructions;
+    }
+}

+ 207 - 0
src/main/java/com/github/yxyl120/sdk/domain/order/PatientInfo.java

@@ -0,0 +1,207 @@
+package com.github.yxyl120.sdk.domain.order;
+
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+import com.github.yxyl120.sdk.annotation.Encrypted;
+
+import java.io.Serializable;
+
+
+public class PatientInfo implements Serializable {
+    /**
+     * 身份证号码
+     */
+    @Encrypted
+    @ApiFieldProperty("身份证号码")
+    private String idNumber;
+
+    /**
+     * 患者姓名
+     */
+    @ApiFieldProperty(value = "患者姓名", required = true)
+    private String name;
+
+    /**
+     * 患者电话
+     */
+    @Encrypted
+    @ApiFieldProperty("患者电话")
+    private String mobile;
+
+    /**
+     * 患者性别 0 保密 | 1 男 | 2 女
+     */
+    @ApiFieldProperty(value = "患者性别 0 保密 | 1 男 | 2 女", required = true)
+    private Integer sex;
+
+    /**
+     * 患者年龄
+     */
+    @ApiFieldProperty(value = "患者年龄")
+    private Integer age;
+
+    /**
+     * 患者体重
+     */
+    @ApiFieldProperty("患者体重")
+    private String weight;
+
+    /**
+     * 患者生日
+     */
+    @ApiFieldProperty(value = "患者生日。格式:yyyy-MM-dd")
+    private String birthday;
+
+    /**
+     * 患者肾功能 0 异常 | 1 正常
+     */
+    @ApiFieldProperty(value = "患者肾功能 0 异常 | 1 正常", required = true)
+    private Integer kidney;
+
+    /**
+     * 患者肝功能 0 异常 | 1 正常
+     */
+    @ApiFieldProperty(value = "患者肝功能 0 异常 | 1 正常", required = true)
+    private Integer liver;
+
+    /**
+     * 患者是否哺乳 0 否 | 1 是
+     */
+    @ApiFieldProperty(value = "患者是否哺乳 0 否 | 1 是", required = true)
+    private Integer lactation;
+
+    /**
+     * 过敏症描述
+     */
+    @ApiFieldProperty("过敏症描述")
+    private String allergyDesc;
+
+    /**
+     * 现病史
+     */
+    @ApiFieldProperty("现病史")
+    private String nowIllness;
+
+    /**
+     * 既往史
+     */
+    @ApiFieldProperty("既往史")
+    private String historyIllness;
+
+    /**
+     * 主诉 (患者症状)
+     */
+    @ApiFieldProperty(value = "主诉 (患者症状)", required = true)
+    private String mainSuit;
+
+    public String getIdNumber() {
+        return idNumber;
+    }
+
+    public void setIdNumber(String idNumber) {
+        this.idNumber = idNumber;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public Integer getSex() {
+        return sex;
+    }
+
+    public void setSex(Integer sex) {
+        this.sex = sex;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+    public String getWeight() {
+        return weight;
+    }
+
+    public void setWeight(String weight) {
+        this.weight = weight;
+    }
+
+    public String getBirthday() {
+        return birthday;
+    }
+
+    public void setBirthday(String birthday) {
+        this.birthday = birthday;
+    }
+
+    public Integer getKidney() {
+        return kidney;
+    }
+
+    public void setKidney(Integer kidney) {
+        this.kidney = kidney;
+    }
+
+    public Integer getLiver() {
+        return liver;
+    }
+
+    public void setLiver(Integer liver) {
+        this.liver = liver;
+    }
+
+    public Integer getLactation() {
+        return lactation;
+    }
+
+    public void setLactation(Integer lactation) {
+        this.lactation = lactation;
+    }
+
+    public String getAllergyDesc() {
+        return allergyDesc;
+    }
+
+    public void setAllergyDesc(String allergyDesc) {
+        this.allergyDesc = allergyDesc;
+    }
+
+    public String getNowIllness() {
+        return nowIllness;
+    }
+
+    public void setNowIllness(String nowIllness) {
+        this.nowIllness = nowIllness;
+    }
+
+    public String getHistoryIllness() {
+        return historyIllness;
+    }
+
+    public void setHistoryIllness(String historyIllness) {
+        this.historyIllness = historyIllness;
+    }
+
+    public String getMainSuit() {
+        return mainSuit;
+    }
+
+    public void setMainSuit(String mainSuit) {
+        this.mainSuit = mainSuit;
+    }
+}

+ 6 - 5
src/main/java/com/github/yxyl120/opensdk/enums/ResponseCode.java → src/main/java/com/github/yxyl120/sdk/enums/ResponseCode.java

@@ -1,4 +1,4 @@
-package com.github.yxyl120.opensdk.enums;
+package com.github.yxyl120.sdk.enums;
 
 /**
  * 一线服务器返回的响应码与说明
@@ -6,15 +6,16 @@ package com.github.yxyl120.opensdk.enums;
 public enum ResponseCode {
 
     SUCCESS(200, "请求成功"),
-
-    InvalidAppId(201, "appId非法"),
-    InvalidSecret(201, "密钥非法"),
+    InvalidAppId(201, "无效appId"),
+    InvalidSecret(201, "无效密钥,检查是否错误"),
     SignatureExpire(301, "签名过期。Timestamp 和服务器时间相差不得超过五分钟,请检查本地时间是否和标准时间同步"),
     SignatureFailure(302, "签名错误。签名计算错误,请对照调用方式中的签名方法文档检查签名计算过程"),
+    CustomErrorCode(500, "处理业务发生错误"),
     MissingParameter(501, "缺少参数"),
     InvalidParameter(502, "参数错误(包括参数格式、类型等错误)"),
     InvalidParameterValue(503, "参数取值错误"),
-    ServiceError(400, "服务器内部错误");
+    DuplicateRequestError(504, "重复请求错误,数据已录入,订单号必须唯一"),
+    ServiceError(400,"服务器内部错误");
 
     private int code;
 

+ 11 - 0
src/main/java/com/github/yxyl120/sdk/request/AbsRequest.java

@@ -0,0 +1,11 @@
+package com.github.yxyl120.sdk.request;
+
+import java.util.Map;
+
+public class AbsRequest {
+
+    public Map<String, Object> getQueryParam() {
+        return null;
+    }
+
+}

+ 221 - 0
src/main/java/com/github/yxyl120/sdk/request/PushOrderRequest.java

@@ -0,0 +1,221 @@
+package com.github.yxyl120.sdk.request;
+
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+import com.github.yxyl120.sdk.annotation.Valid;
+import com.github.yxyl120.sdk.domain.order.DrugInfo;
+import com.github.yxyl120.sdk.domain.order.PatientInfo;
+import com.github.yxyl120.sdk.response.PushOrderResponse;
+
+import java.util.Date;
+import java.util.List;
+
+public class PushOrderRequest extends AbsRequest implements YxRequest<PushOrderResponse>{
+    /**
+     * 合作方订单id
+     */
+    @ApiFieldProperty(value = "合作方订单id", required = true)
+    private String orderIdThird;
+
+    /**
+     * 合作方问诊单号
+     */
+    @ApiFieldProperty(value = "合作方问诊单号", required = true)
+    private String diagnosisSnThird;
+
+    /**
+     * 处方类型 1 图文 | 2 视频
+     */
+    @ApiFieldProperty(value = "处方类型 1 图文 | 2 视频", required = true)
+    private Integer type;
+
+    /**
+     * 付费类型 0 自费 1 公费 2 医保 3 其他
+     */
+    @ApiFieldProperty(value = "付费类型 0 自费 1 公费 2 医保 3 其他,默认为自费")
+    private Integer paymentType;
+
+    /**
+     * 付费金额
+     */
+    @ApiFieldProperty("付费金额")
+    private Float paymentAmount;
+
+    /**
+     * 处方药类型(01西药、02中药)
+     */
+    @ApiFieldProperty(value = "处方药类型(01西药、02中药)", required = true)
+    private String rpType;
+
+    /**
+     * 患者详情
+     */
+    @Valid
+    @ApiFieldProperty(value = "患者详情", required = true)
+    private PatientInfo patientInfo;
+
+    /**
+     * 药品列表
+     */
+    @Valid
+    @ApiFieldProperty(value = "药品列表", required = true)
+    private List<DrugInfo> drugList;
+
+    /**
+     * 药店ID
+     */
+    @ApiFieldProperty("药店ID")
+    private String storeIdThird;
+
+    /**
+     * 药店名称
+     */
+    @ApiFieldProperty("药店名称")
+    private String storeName;
+
+    /**
+     * 诊断
+     */
+    @ApiFieldProperty("诊断")
+    private List<String> diagnosis;
+
+    /**
+     * 凭证图片 URL json格式 ["1.jpg", "2.jpg"]
+     */
+    @ApiFieldProperty("凭证图片 URL Array格式 [\"1.jpg\", \"2.jpg\"]")
+    private List<String> voucherImg;
+
+    /**
+     * 是否CA签名 0 否 | 1 是
+     */
+    @ApiFieldProperty("是否需要CA电子签名pdf文件,此功能需要药店相关的药师先进行电子签章注册并授权")
+    private String signPDF;
+
+    /**
+     * 创建时间
+     */
+    @ApiFieldProperty(value = "合作方订单创建时间", required = true)
+    private Date createTime;
+    
+    @Override
+    public String getApi() {
+        return "/api/open/receiveOrder";
+    }
+
+
+    @Override
+    public Class<PushOrderResponse> getResponseClass() {
+        return PushOrderResponse.class;
+    }
+
+    public String getOrderIdThird() {
+        return orderIdThird;
+    }
+
+    public void setOrderIdThird(String orderIdThird) {
+        this.orderIdThird = orderIdThird;
+    }
+
+    public String getDiagnosisSnThird() {
+        return diagnosisSnThird;
+    }
+
+    public void setDiagnosisSnThird(String diagnosisSnThird) {
+        this.diagnosisSnThird = diagnosisSnThird;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public Integer getPaymentType() {
+        return paymentType;
+    }
+
+    public void setPaymentType(Integer paymentType) {
+        this.paymentType = paymentType;
+    }
+
+    public Float getPaymentAmount() {
+        return paymentAmount;
+    }
+
+    public void setPaymentAmount(Float paymentAmount) {
+        this.paymentAmount = paymentAmount;
+    }
+
+    public String getRpType() {
+        return rpType;
+    }
+
+    public void setRpType(String rpType) {
+        this.rpType = rpType;
+    }
+
+    public PatientInfo getPatientInfo() {
+        return patientInfo;
+    }
+
+    public void setPatientInfo(PatientInfo patientInfo) {
+        this.patientInfo = patientInfo;
+    }
+
+    public List<DrugInfo> getDrugList() {
+        return drugList;
+    }
+
+    public void setDrugList(List<DrugInfo> drugList) {
+        this.drugList = drugList;
+    }
+
+    public String getStoreIdThird() {
+        return storeIdThird;
+    }
+
+    public void setStoreIdThird(String storeIdThird) {
+        this.storeIdThird = storeIdThird;
+    }
+
+    public String getStoreName() {
+        return storeName;
+    }
+
+    public void setStoreName(String storeName) {
+        this.storeName = storeName;
+    }
+
+    public List<String> getDiagnosis() {
+        return diagnosis;
+    }
+
+    public void setDiagnosis(List<String> diagnosis) {
+        this.diagnosis = diagnosis;
+    }
+
+    public List<String> getVoucherImg() {
+        return voucherImg;
+    }
+
+    public void setVoucherImg(List<String> voucherImg) {
+        this.voucherImg = voucherImg;
+    }
+
+    public String getSignPDF() {
+        return signPDF;
+    }
+
+    public void setSignPDF(String signPDF) {
+        this.signPDF = signPDF;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 32 - 0
src/main/java/com/github/yxyl120/sdk/request/YxRequest.java

@@ -0,0 +1,32 @@
+package com.github.yxyl120.sdk.request;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.github.yxyl120.sdk.response.AbstractResponse;
+
+import java.util.Map;
+
+public interface YxRequest<T extends AbstractResponse> {
+    /**
+     * 接口
+     *
+     * @return 提交此参数的接口
+     */
+    @JsonIgnore
+    String getApi();
+
+    /**
+     * url上传输的查询键值Map
+     *
+     * @return url上的键值Map
+     */
+    @JsonIgnore
+    Map<String, Object> getQueryParam();
+
+    /**
+     * 请求接口返回的结果类型
+     *
+     * @return class
+     */
+    @JsonIgnore
+    Class<T> getResponseClass();
+}

+ 29 - 0
src/main/java/com/github/yxyl120/sdk/response/AbstractResponse.java

@@ -0,0 +1,29 @@
+package com.github.yxyl120.sdk.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AbstractResponse implements Serializable {
+
+    protected int code;
+
+    protected String msg;
+
+    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;
+    }
+}

+ 11 - 0
src/main/java/com/github/yxyl120/sdk/response/PushOrderResponse.java

@@ -0,0 +1,11 @@
+package com.github.yxyl120.sdk.response;
+
+public class PushOrderResponse extends AbstractResponse {
+    @Override
+    public String toString() {
+        return "PushOrderResponse{" +
+                "code=" + code +
+                ", msg='" + msg + '\'' +
+                '}';
+    }
+}

+ 48 - 22
src/test/java/APITest.java

@@ -1,27 +1,53 @@
-import com.github.yxyl120.opensdk.Utils.HttpUtils;
-import com.github.yxyl120.opensdk.YxException;
-import com.github.yxyl120.opensdk.domain.RequestParameter;
-import com.github.yxyl120.opensdk.domain.order.OrderInfo;
+import com.github.yxyl120.sdk.DefaultYxClient;
+import com.github.yxyl120.sdk.YxException;
+import com.github.yxyl120.sdk.domain.order.DrugInfo;
+import com.github.yxyl120.sdk.domain.order.PatientInfo;
+import com.github.yxyl120.sdk.request.PushOrderRequest;
+import com.github.yxyl120.sdk.response.PushOrderResponse;
+
+import java.util.Collections;
+import java.util.Date;
 
 public class APITest {
 
-    public static void main(String[] args) {
-        try {
-            RequestParameter<OrderInfo> parameter = new RequestParameter<>();
-            parameter.setAct_id("uporder");
-            parameter.setManu_id("Y001");
-            parameter.setApp_id("aaaab");
-            parameter.setVersion(1.0);
-            parameter.setData(new OrderInfo());
-            OrderInfo data = parameter.getData();
-            data.setIs_history_allergic("否");
-            data.setPharmacy_code("0");
-            data.setRp_id("dfafefawe");
-
-            String pushOrder = HttpUtils.pushOrder("", parameter);
-            System.out.println(pushOrder);
-        } catch (YxException e) {
-            System.out.println(e.getMessage());
-        }
+    public static void main(String[] args) throws YxException {
+
+        String serverUrl = "http://localhost:8515";
+        String secret = "DB957E8E2F41AB28B65840BD47A76AF2";
+
+        DefaultYxClient yxClient = new DefaultYxClient(serverUrl, "440004901", secret);
+        PushOrderRequest orderRequest = new PushOrderRequest();
+
+        orderRequest.setOrderIdThird("C2021232657");
+        orderRequest.setDiagnosisSnThird("C2021232657");
+        orderRequest.setStoreName("一线大药房");
+        orderRequest.setCreateTime(new Date());
+        orderRequest.setType(2);
+        PatientInfo patientInfo = new PatientInfo();
+        orderRequest.setPatientInfo(patientInfo);
+        patientInfo.setName("张三");
+        patientInfo.setAge(80);
+        patientInfo.setSex(1);
+        patientInfo.setKidney(0);
+        patientInfo.setLiver(0);
+        patientInfo.setLactation(0);
+        patientInfo.setBirthday("2021-12-29");
+
+        patientInfo.setMainSuit("咳嗽");
+        patientInfo.setAllergyDesc("无");
+
+        DrugInfo drugInfo = new DrugInfo();
+        drugInfo.setDrugIdThird(669);
+        drugInfo.setDrugNameComm("乙酰螺旋霉素片");
+        drugInfo.setDrugSpecification("0.1g*12片*2板");
+        drugInfo.setSaleAmount(3);
+        drugInfo.setSaleUnit("盒");
+
+        orderRequest.setDrugList(Collections.singletonList(drugInfo));
+        orderRequest.setRpType("01");
+
+        PushOrderResponse response = yxClient.execute(orderRequest);
+        System.out.println(response);
+
     }
 }

+ 27 - 0
src/test/java/test/dateTest.java

@@ -0,0 +1,27 @@
+package test;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+public class dateTest {
+
+    public static void main(String[] args) {
+//
+
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
+        SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss", Locale.CHINA);
+
+        try {
+            Date parse = dateFormat.parse("1991-13-29 23:59:00");
+            System.out.println(parse);
+            String format = dateFormat.format(parse);
+            System.out.println(format);
+        } catch (ParseException e) {
+
+            e.printStackTrace();
+        }
+
+    }
+}