浏览代码

添加注释

luqingbin 3 年之前
父节点
当前提交
7a63c1e1ec

+ 133 - 3
README.md

@@ -5,6 +5,136 @@
 
 #### 使用说明
 
-1.  xxxx
-2.  xxxx
-3.  xxxx
+1.  初始化链接服务
+```$java
+YxClient yxClient= new DefaultYxClient(serverUrl, appId, secret);
+```
+2.  调用接口
+
+```
+
+
+ /**
+     * 推送一张视频单或图文单
+     */
+    private void pushOrderTest() {
+        PushOrderRequest orderRequest = new PushOrderRequest();
+
+        orderRequest.setOrderIdThird("C2021232657");
+        orderRequest.setDiagnosisSnThird("C2021232657");
+        orderRequest.setStoreName("一线大药房");
+        orderRequest.setCreateTime(new Date());
+        // 1图文 2为视频
+        orderRequest.setType(2);
+
+        PatientInfo patientInfo = new PatientInfo();
+        orderRequest.setPatientInfo(patientInfo);
+        patientInfo.setName("张三");
+        patientInfo.setAge(1);
+        patientInfo.setSex(1);
+        patientInfo.setKidney(0);
+        patientInfo.setLiver(0);
+        patientInfo.setLactation(0);
+        patientInfo.setMobile("13428841594");
+        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("盒");
+        drugInfo.setInstructions("药品说明书");
+
+        orderRequest.setDrugList(Collections.singletonList(drugInfo));
+        orderRequest.setRpType("01");
+        //------- 指定处方药师部分(可选) -----
+        orderRequest.setPharmacistModel(1);
+        orderRequest.setPharmacistId(20);
+        orderRequest.setDeploymentPharmacistId(28);
+        orderRequest.setDispensingPharmacistId(383);
+        //------- 指定药师部分结束-----
+        PushOrderResponse response = yxClient.execute(orderRequest);
+        System.out.println(response);
+        // 房间进行视频通话的相关的信息
+        RoomInfo data = response.getData();
+    
+
+    /**
+     * 根据处方号发送文本消息
+     */
+    private void sendTextMsg() {
+        TextChatRequest request = new TextChatRequest("C2201121686180076", "医生你好");
+        EmptyResponse response = yxClient.execute(request);
+        // 后续需要合作方的接口等待接收回调
+    }
+
+    /**
+     * 根据处方号发送图片消息
+     */
+    private void sendImageMsg() {
+        ImageChatRequest request = new ImageChatRequest("C2201121686180076",
+                "https://asset.nxk520.com/abc.png");
+        request.setImgWidth(60);
+        request.setImgHeight(110);
+        EmptyResponse response = yxClient.execute(request);
+        // 后续需要合作方的接口等待接收回调
+    }
+
+    /**
+     * 根据处方号发起视频聊天
+     */
+    private void sendLiveMsg() {
+        LiveChatRequest request = new LiveChatRequest("C2201121686180076");
+        EmptyResponse response = yxClient.execute(request);
+        // 后续需要合作方的接口等待接收回调
+    }
+
+    private void sendMediaChatRequest(){
+        MediaChatRequest request = new MediaChatRequest("C2201121686180076");
+        request.setDuration(20);
+        request.setMediaUrl("https://asset.nxk520.com/test.mp4");
+        request.setFileFormat("mp4");
+        EmptyResponse response = yxClient.execute(request);
+    }
+
+    /**
+     * 同步药师资料到一线
+     */
+    private void syncPharmacistInfoTest() {
+        SyncPharmacistInfoRequest request = new SyncPharmacistInfoRequest();
+        request.setPharmacistId(764);
+        request.setPharmacistName("张三");
+        request.setSex(1);
+        request.setRole(2);
+        request.setMobile("16666666666");
+        request.setIdNumber("632323190605260586");
+        request.setAvatar("https://asset.nxk520.com/abc.png");
+        request.setIdFrontImg("https://asset.nxk520.com/abc.png");
+        request.setIdEmblemImg("https://asset.nxk520.com/abc.png");
+        request.setCertificateImg("https://asset.nxk520.com/abc.png");
+        request.setPractitionerCertificateImg("https://asset.nxk520.com/abc.png");
+        request.setIntroduction("药师简介……");
+        SyncPharmacistResponse response = yxClient.execute(request);
+    }
+
+    /**
+     * 注销药师,或启用药师
+     */
+    private void SyncPharmacistStatusTest(){
+
+//        SyncPharmacistStatusRequest request = new SyncPharmacistStatusRequest();
+//        request.setPharmacistId(764);
+//        request.setStatus(0);
+
+// 药师用id & 0 注销,1启用
+        SyncPharmacistStatusRequest request = new SyncPharmacistStatusRequest(764,0);
+        SyncPharmacistResponse response = yxClient.execute(request);
+    }
+
+}
+```
+

+ 6 - 1
src/main/java/com/github/yxyl120/sdk/domain/Chat.java

@@ -8,8 +8,13 @@ public class Chat {
 
     private String orderSn;
 
+    public Chat(int chatType, String orderSn) {
+        this.chatType = chatType;
+        this.orderSn = orderSn;
+    }
+
     @JsonIgnore
-    private String api ="/api/open/sendTextChat";
+    private String api ="/api/open/receivePatientMessage";
 
     @JsonIgnore
     public String getApi() {

+ 0 - 40
src/main/java/com/github/yxyl120/sdk/domain/ImageChat.java

@@ -1,40 +0,0 @@
-package com.github.yxyl120.sdk.domain;
-
-public class ImageChat extends Chat {
-
-    private String imgUrl;
-
-    private Integer imgWidth;
-
-    private Integer imgHeight;
-
-    public ImageChat(String orderSn, String imgUrl) {
-        this.imgUrl = imgUrl;
-        this.setChatType(2);
-        this.setOrderSn(orderSn);
-    }
-
-    public String getImgUrl() {
-        return imgUrl;
-    }
-
-    public void setImgUrl(String imgUrl) {
-        this.imgUrl = imgUrl;
-    }
-
-    public Integer getImgWidth() {
-        return imgWidth;
-    }
-
-    public void setImgWidth(Integer imgWidth) {
-        this.imgWidth = imgWidth;
-    }
-
-    public Integer getImgHeight() {
-        return imgHeight;
-    }
-
-    public void setImgHeight(Integer imgHeight) {
-        this.imgHeight = imgHeight;
-    }
-}

+ 0 - 23
src/main/java/com/github/yxyl120/sdk/domain/LiveChat.java

@@ -1,23 +0,0 @@
-package com.github.yxyl120.sdk.domain;
-
-public class LiveChat extends Chat {
-
-    /**
-     * 发起的时间戳
-     */
-    private long timeStamp;
-
-    public LiveChat(String orderSn) {
-        this.timeStamp = System.currentTimeMillis();
-        this.setChatType(4);
-        this.setOrderSn(orderSn);
-    }
-
-    public long getTimeStamp() {
-        return timeStamp;
-    }
-
-    public void setTimeStamp(long timeStamp) {
-        this.timeStamp = timeStamp;
-    }
-}

+ 0 - 26
src/main/java/com/github/yxyl120/sdk/domain/TextChat.java

@@ -1,26 +0,0 @@
-package com.github.yxyl120.sdk.domain;
-
-public class TextChat extends Chat {
-
-    private String content;
-
-    /**
-     * 文本消息
-     *
-     * @param orderSn 订单号
-     * @param content 内容
-     */
-    public TextChat(String orderSn, String content) {
-        this.content = content;
-        this.setOrderSn(orderSn);
-        this.setChatType(1);
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-}

+ 34 - 3
src/main/java/com/github/yxyl120/sdk/request/ImageChatRequest.java

@@ -1,6 +1,6 @@
 package com.github.yxyl120.sdk.request;
 
-import com.github.yxyl120.sdk.domain.ImageChat;
+import com.github.yxyl120.sdk.domain.Chat;
 import com.github.yxyl120.sdk.response.EmptyResponse;
 
 import java.util.Map;
@@ -8,10 +8,17 @@ import java.util.Map;
 /**
  * 发送图片消息到医生
  */
-public class ImageChatRequest extends ImageChat implements YxRequest<EmptyResponse> {
+public class ImageChatRequest extends Chat implements YxRequest<EmptyResponse> {
+
+    private String imgUrl;
+
+    private Integer imgWidth;
+
+    private Integer imgHeight;
 
     public ImageChatRequest(String orderSn, String imgUrl) {
-        super(orderSn, imgUrl);
+        super(2,orderSn);
+        this.imgUrl = imgUrl;
     }
 
     @Override
@@ -23,4 +30,28 @@ public class ImageChatRequest extends ImageChat implements YxRequest<EmptyRespon
     public Class<EmptyResponse> getResponseClass() {
         return EmptyResponse.class;
     }
+
+    public String getImgUrl() {
+        return imgUrl;
+    }
+
+    public void setImgUrl(String imgUrl) {
+        this.imgUrl = imgUrl;
+    }
+
+    public Integer getImgWidth() {
+        return imgWidth;
+    }
+
+    public void setImgWidth(Integer imgWidth) {
+        this.imgWidth = imgWidth;
+    }
+
+    public Integer getImgHeight() {
+        return imgHeight;
+    }
+
+    public void setImgHeight(Integer imgHeight) {
+        this.imgHeight = imgHeight;
+    }
 }

+ 11 - 3
src/main/java/com/github/yxyl120/sdk/request/LiveChatRequest.java

@@ -1,6 +1,6 @@
 package com.github.yxyl120.sdk.request;
 
-import com.github.yxyl120.sdk.domain.LiveChat;
+import com.github.yxyl120.sdk.domain.Chat;
 import com.github.yxyl120.sdk.response.EmptyResponse;
 
 import java.util.Map;
@@ -8,10 +8,15 @@ import java.util.Map;
 /**
  * 发起视频聊天
  */
-public class LiveChatRequest extends LiveChat implements YxRequest<EmptyResponse>{
+public class LiveChatRequest extends Chat implements YxRequest<EmptyResponse>{
+    /**
+     * 发起的时间戳
+     */
+    private long timeStamp;
 
     public LiveChatRequest(String orderSn) {
-        super(orderSn);
+        super(4,orderSn);
+        this.timeStamp = System.currentTimeMillis();
     }
 
     @Override
@@ -24,4 +29,7 @@ public class LiveChatRequest extends LiveChat implements YxRequest<EmptyResponse
         return EmptyResponse.class;
     }
 
+    public long getTimeStamp() {
+        return timeStamp;
+    }
 }

+ 81 - 0
src/main/java/com/github/yxyl120/sdk/request/MediaChatRequest.java

@@ -0,0 +1,81 @@
+package com.github.yxyl120.sdk.request;
+
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+import com.github.yxyl120.sdk.domain.Chat;
+import com.github.yxyl120.sdk.response.EmptyResponse;
+
+import java.util.Map;
+
+/**
+ * 媒体消息请求类
+ */
+public class MediaChatRequest extends Chat implements YxRequest<EmptyResponse> {
+
+    @ApiFieldProperty(value = "媒体播放地址", required = true)
+    private String mediaUrl;
+
+    @ApiFieldProperty("媒体播放的时长,单位秒")
+    private long duration;
+
+    @ApiFieldProperty(value = "媒体类型,arm,hls,mp4等等", required = true)
+    private String fileFormat;
+
+    /**
+     * 构造媒体消息请求
+     *
+     * @param orderSn 一线平台的订单号
+     */
+    public MediaChatRequest(String orderSn) {
+        super(3, orderSn);
+    }
+
+    /**
+     * /**
+     * 构造媒体消息请求
+     *
+     * @param orderSn    一线平台的订单号
+     * @param mediaUrl   媒体地址
+     * @param duration   媒体播放的长度
+     * @param fileFormat 媒体类型
+     */
+    public MediaChatRequest(String orderSn, String mediaUrl, long duration, String fileFormat) {
+        this(orderSn);
+        this.mediaUrl = mediaUrl;
+        this.duration = duration;
+        this.fileFormat = fileFormat;
+    }
+
+    @Override
+    public Map<String, Object> getQueryParam() {
+        return null;
+    }
+
+    @Override
+    public Class<EmptyResponse> getResponseClass() {
+        return EmptyResponse.class;
+    }
+
+    public String getMediaUrl() {
+        return mediaUrl;
+    }
+
+    public void setMediaUrl(String mediaUrl) {
+        this.mediaUrl = mediaUrl;
+    }
+
+    public long getDuration() {
+        return duration;
+    }
+
+    public void setDuration(long duration) {
+        this.duration = duration;
+    }
+
+    public String getFileFormat() {
+        return fileFormat;
+    }
+
+    public void setFileFormat(String fileFormat) {
+        this.fileFormat = fileFormat;
+    }
+}

+ 8 - 3
src/main/java/com/github/yxyl120/sdk/request/TextChatRequest.java

@@ -1,14 +1,19 @@
 package com.github.yxyl120.sdk.request;
 
-import com.github.yxyl120.sdk.domain.TextChat;
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+import com.github.yxyl120.sdk.domain.Chat;
 import com.github.yxyl120.sdk.response.EmptyResponse;
 
 import java.util.Map;
 
-public class TextChatRequest extends TextChat implements YxRequest<EmptyResponse>{
+public class TextChatRequest extends Chat implements YxRequest<EmptyResponse> {
+
+    @ApiFieldProperty(value = "消息内容", required = true)
+    private String content;
 
     public TextChatRequest(String orderSn, String content) {
-        super(orderSn, content);
+        super(1, orderSn);
+        this.content = content;
     }
 
     @Override

+ 15 - 1
src/test/java/com/yxyl120/APITest.java

@@ -26,7 +26,7 @@ public class APITest {
     }
 
     public static void main(String[] args) throws YxException {
-        new APITest().pushOrderTest();
+        new APITest().sendImageMsg();
     }
 
     /**
@@ -66,6 +66,12 @@ public class APITest {
 
         orderRequest.setDrugList(Collections.singletonList(drugInfo));
         orderRequest.setRpType("01");
+        //------- 指定处方药师部分(可选) -----
+        orderRequest.setPharmacistModel(1);
+        orderRequest.setPharmacistId(20);
+        orderRequest.setDeploymentPharmacistId(28);
+        orderRequest.setDispensingPharmacistId(383);
+        //------- 指定药师部分结束-----
 
         PushOrderResponse response = yxClient.execute(orderRequest);
         System.out.println(response);
@@ -103,6 +109,14 @@ public class APITest {
         // 后续需要合作方的接口等待接收回调
     }
 
+    private void sendMediaChatRequest(){
+        MediaChatRequest request = new MediaChatRequest("C2201121686180076");
+        request.setDuration(20);
+        request.setMediaUrl("https://asset.nxk520.com/test.mp4");
+        request.setFileFormat("mp4");
+        EmptyResponse response = yxClient.execute(request);
+    }
+
     /**
      * 同步药师资料到一线
      */