Przeglądaj źródła

Merge branch 'giteeMaster'

luqingbin 3 lat temu
rodzic
commit
ee77f93dc8

+ 131 - 3
README.md

@@ -5,6 +5,134 @@
 
 #### 使用说明
 
-1.  xxxx
-2.  xxxx
-3.  xxxx
+1.  初始化链接服务
+```$java
+YxClient yxClient= new DefaultYxClient(serverUrl, appId, secret);
+```
+2.  调用接口
+
+```$java
+
+
+    /**
+     * 推送一张视频单或图文单
+     */
+    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", "医生你好");
+        ChatResponse response = yxClient.execute(request);
+        // 后续需要合作方的接口等待接收回调
+    }
+
+    /**
+     * 根据处方号发送图片消息
+     */
+    private void sendImageMsg() {
+        ImageChatRequest request = new ImageChatRequest("C2201121686180076",
+                "https://asset.nxk520.com/abc.png");
+        request.setImgWidth(60);
+        request.setImgHeight(110);
+        ChatResponse response = yxClient.execute(request);
+        // 后续需要合作方的接口等待接收回调
+    }
+
+    /**
+     * 根据处方号发起视频聊天
+     */
+    private void sendLiveMsg() {
+        LiveChatRequest request = new LiveChatRequest("C2201121686180076");
+        ChatResponse 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");
+        ChatResponse 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.setSignatureImg("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);
+        SyncPharmacistStatusRequest request = new SyncPharmacistStatusRequest(764,0);
+        SyncPharmacistResponse response = yxClient.execute(request);
+    }
+```
+

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

@@ -1,15 +1,23 @@
 package com.github.yxyl120.sdk.domain;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
 
 public class Chat {
 
+    @ApiFieldProperty(value = "消息类型", required = true)
     private int chatType;
 
+    @ApiFieldProperty(value = "消息关联的处方单号", required = true)
     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;
-    }
-}

+ 5 - 7
src/main/java/com/github/yxyl120/sdk/domain/PharmacistUser.java

@@ -1,7 +1,5 @@
 package com.github.yxyl120.sdk.domain;
 
-import java.io.Serializable;
-
 public class PharmacistUser {
 
     /**
@@ -12,7 +10,7 @@ public class PharmacistUser {
     /**
      * 合作平台的用户id
      */
-    private Serializable userIdThree;
+    private String userIdThird;
 
     /**
      * 用户姓名
@@ -46,12 +44,12 @@ public class PharmacistUser {
         this.userId = userId;
     }
 
-    public Serializable getUserIdThree() {
-        return userIdThree;
+    public String getUserIdThird() {
+        return userIdThird;
     }
 
-    public void setUserIdThree(Serializable userIdThree) {
-        this.userIdThree = userIdThree;
+    public void setUserIdThird(String userIdThird) {
+        this.userIdThird = userIdThird;
     }
 
     public String getName() {

+ 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;
-    }
-}

+ 37 - 5
src/main/java/com/github/yxyl120/sdk/request/ImageChatRequest.java

@@ -1,6 +1,7 @@
 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.ChatResponse;
 import com.github.yxyl120.sdk.response.EmptyResponse;
 
 import java.util.Map;
@@ -8,10 +9,17 @@ import java.util.Map;
 /**
  * 发送图片消息到医生
  */
-public class ImageChatRequest extends ImageChat implements YxRequest<EmptyResponse> {
+public class ImageChatRequest extends Chat implements YxRequest<ChatResponse> {
+
+    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
@@ -20,7 +28,31 @@ public class ImageChatRequest extends ImageChat implements YxRequest<EmptyRespon
     }
 
     @Override
-    public Class<EmptyResponse> getResponseClass() {
-        return EmptyResponse.class;
+    public Class<ChatResponse> getResponseClass() {
+        return ChatResponse.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;
     }
 }

+ 14 - 5
src/main/java/com/github/yxyl120/sdk/request/LiveChatRequest.java

@@ -1,6 +1,7 @@
 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.ChatResponse;
 import com.github.yxyl120.sdk.response.EmptyResponse;
 
 import java.util.Map;
@@ -8,10 +9,15 @@ import java.util.Map;
 /**
  * 发起视频聊天
  */
-public class LiveChatRequest extends LiveChat implements YxRequest<EmptyResponse>{
+public class LiveChatRequest extends Chat implements YxRequest<ChatResponse>{
+    /**
+     * 发起的时间戳
+     */
+    private long timeStamp;
 
     public LiveChatRequest(String orderSn) {
-        super(orderSn);
+        super(4,orderSn);
+        this.timeStamp = System.currentTimeMillis();
     }
 
     @Override
@@ -20,8 +26,11 @@ public class LiveChatRequest extends LiveChat implements YxRequest<EmptyResponse
     }
 
     @Override
-    public Class<EmptyResponse> getResponseClass() {
-        return EmptyResponse.class;
+    public Class<ChatResponse> getResponseClass() {
+        return ChatResponse.class;
     }
 
+    public long getTimeStamp() {
+        return timeStamp;
+    }
 }

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

@@ -0,0 +1,82 @@
+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.ChatResponse;
+import com.github.yxyl120.sdk.response.EmptyResponse;
+
+import java.util.Map;
+
+/**
+ * 媒体消息请求类
+ */
+public class MediaChatRequest extends Chat implements YxRequest<ChatResponse> {
+
+    @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<ChatResponse> getResponseClass() {
+        return ChatResponse.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;
+    }
+}

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

@@ -40,6 +40,9 @@ public class SyncPharmacistInfoRequest extends AbsRequest implements YxRequest<S
     @ApiFieldProperty(value = "药师药师资格证")
     private String certificateImg;
 
+    @ApiFieldProperty(value = "药师药师手写签名图片",required = true)
+    private String signatureImg;
+
     @ApiFieldProperty(value = "药师性别", required = true)
     private Integer sex;
 
@@ -156,4 +159,12 @@ public class SyncPharmacistInfoRequest extends AbsRequest implements YxRequest<S
     public void setRole(Integer role) {
         this.role = role;
     }
+
+    public String getSignatureImg() {
+        return signatureImg;
+    }
+
+    public void setSignatureImg(String signatureImg) {
+        this.signatureImg = signatureImg;
+    }
 }

+ 19 - 6
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.response.EmptyResponse;
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+import com.github.yxyl120.sdk.domain.Chat;
+import com.github.yxyl120.sdk.response.ChatResponse;
 
 import java.util.Map;
 
-public class TextChatRequest extends TextChat implements YxRequest<EmptyResponse>{
+public class TextChatRequest extends Chat implements YxRequest<ChatResponse> {
+
+    @ApiFieldProperty(value = "消息内容", required = true)
+    private String content;
 
     public TextChatRequest(String orderSn, String content) {
-        super(orderSn, content);
+        super(1, orderSn);
+        this.content = content;
     }
 
     @Override
@@ -17,7 +22,15 @@ public class TextChatRequest extends TextChat implements YxRequest<EmptyResponse
     }
 
     @Override
-    public Class<EmptyResponse> getResponseClass() {
-        return EmptyResponse.class;
+    public Class<ChatResponse> getResponseClass() {
+        return ChatResponse.class;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
     }
 }

+ 40 - 0
src/main/java/com/github/yxyl120/sdk/response/ChatResponse.java

@@ -0,0 +1,40 @@
+package com.github.yxyl120.sdk.response;
+
+import com.github.yxyl120.sdk.annotation.ApiFieldProperty;
+
+public class ChatResponse extends AbstractResponse {
+
+    @ApiFieldProperty("合作方的处方单号")
+    private String orderSnThird;
+
+    @ApiFieldProperty("一线平台的处方单号")
+    private String orderSn;
+
+    @ApiFieldProperty("消息id")
+    private String msgId;
+
+
+    public String getOrderSnThird() {
+        return orderSnThird;
+    }
+
+    public void setOrderSnThird(String orderSnThird) {
+        this.orderSnThird = orderSnThird;
+    }
+
+    public String getOrderSn() {
+        return orderSn;
+    }
+
+    public void setOrderSn(String orderSn) {
+        this.orderSn = orderSn;
+    }
+
+    public String getMsgId() {
+        return msgId;
+    }
+
+    public void setMsgId(String msgId) {
+        this.msgId = msgId;
+    }
+}

+ 20 - 4
src/test/java/com/yxyl120/APITest.java

@@ -7,6 +7,7 @@ import com.github.yxyl120.sdk.domain.DrugInfo;
 import com.github.yxyl120.sdk.domain.PatientInfo;
 import com.github.yxyl120.sdk.domain.RoomInfo;
 import com.github.yxyl120.sdk.request.*;
+import com.github.yxyl120.sdk.response.ChatResponse;
 import com.github.yxyl120.sdk.response.EmptyResponse;
 import com.github.yxyl120.sdk.response.PushOrderResponse;
 import com.github.yxyl120.sdk.response.SyncPharmacistResponse;
@@ -35,7 +36,7 @@ public class APITest {
     }
 
     public static void main(String[] args) throws YxException {
-        new APITest().pushOrderTest();
+        new APITest().syncPharmacistInfoTest();
     }
 
     /**
@@ -75,6 +76,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);
@@ -87,7 +94,7 @@ public class APITest {
      */
     private void sendTextMsg() {
         TextChatRequest request = new TextChatRequest("C2201121686180076", "医生你好");
-        EmptyResponse response = yxClient.execute(request);
+        ChatResponse response = yxClient.execute(request);
         // 后续需要合作方的接口等待接收回调
     }
 
@@ -99,7 +106,7 @@ public class APITest {
                 "https://asset.nxk520.com/abc.png");
         request.setImgWidth(60);
         request.setImgHeight(110);
-        EmptyResponse response = yxClient.execute(request);
+        ChatResponse response = yxClient.execute(request);
         // 后续需要合作方的接口等待接收回调
     }
 
@@ -108,10 +115,18 @@ public class APITest {
      */
     private void sendLiveMsg() {
         LiveChatRequest request = new LiveChatRequest("C2201121686180076");
-        EmptyResponse response = yxClient.execute(request);
+        ChatResponse 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");
+        ChatResponse response = yxClient.execute(request);
+    }
+
     /**
      * 同步药师资料到一线
      */
@@ -128,6 +143,7 @@ public class APITest {
         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.setSignatureImg("https://asset.nxk520.com/abc.png");
         request.setIntroduction("药师简介……");
         SyncPharmacistResponse response = yxClient.execute(request);
     }