From 35318d8ca8d477670c6157137ed2120a23925f97 Mon Sep 17 00:00:00 2001 From: haown <454902499@qq.com> Date: Tue, 7 Nov 2023 11:33:06 +0800 Subject: [PATCH] =?UTF-8?q?update=3D=3D=3D>:=E4=BF=AE=E6=94=B9=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E9=97=AE=E8=AF=8A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 4 +- .../trtc/v20190722/TLSSigAPIv2.java | 506 +++++++++--------- .../ConsultationInfoController.java | 4 +- .../VideoConsultationController.java | 46 +- .../consultationInfo/ConsultationInfo.java | 1 - .../manage/domain/goodsOrder/GoodsOrder.java | 6 + .../manage/dto/chatrecord/ChatRecordDTO.java | 5 + .../consultationInfo/ConsultationInfoDTO.java | 2 +- .../ConsultationInfoMapper.java | 4 +- .../IConsultationInfoService.java | 11 +- .../impl/ConsultationInfoServiceImpl.java | 90 +++- .../Impl/MessagePushServiceImpl.java | 15 +- .../impl/ScreeningRecordServiceImpl.java | 1 - .../ConsultationInfoMapper.xml | 6 +- .../manage/goodsOrder/GoodsOrderMapper.xml | 11 +- 15 files changed, 403 insertions(+), 309 deletions(-) rename {xinelu-nurse-applet/src/main/java/com/xinelu/applet => xinelu-nurse-manage/src/main/java/com/xinelu/manage}/dto/consultationInfo/ConsultationInfoDTO.java (99%) rename {xinelu-nurse-applet/src/main/java/com/xinelu/applet => xinelu-nurse-manage/src/main/java/com/xinelu/manage}/mapper/consultationInfo/ConsultationInfoMapper.java (95%) rename {xinelu-nurse-applet/src/main/java/com/xinelu/applet => xinelu-nurse-manage/src/main/java/com/xinelu/manage}/service/consultationInfo/IConsultationInfoService.java (92%) rename {xinelu-nurse-applet/src/main/java/com/xinelu/applet => xinelu-nurse-manage/src/main/java/com/xinelu/manage}/service/consultationInfo/impl/ConsultationInfoServiceImpl.java (64%) rename {xinelu-nurse-applet/src/main/resources/mapper/applet => xinelu-nurse-manage/src/main/resources/mapper/manage}/consultationInfo/ConsultationInfoMapper.xml (98%) diff --git a/xinelu-admin/src/main/resources/application.yml b/xinelu-admin/src/main/resources/application.yml index 479d194..042ab35 100644 --- a/xinelu-admin/src/main/resources/application.yml +++ b/xinelu-admin/src/main/resources/application.yml @@ -258,8 +258,8 @@ fd: trtc: sdkappid: 1600006944 sdksecretkey: 6ddbc3e7e4aa128b52898df27a35f8f3d5acdca6f34ffa17b87ebc33e83314f1 - secretid: AKIDjKo7GF2g9PQJ7KMBpGUTFrFZP7cw2upY - secretkey: c1HajkZCdrrhLsDRUL1XotpeUAkAOSM7 + secretid: AKIDYxAAwVrPveKvQuO2zwojOxRpCTflkz9E + secretkey: 540sfPH5obKxVxwW4Xt8KTfmS4b2Nfu4 # 微信小程序参数配置信息 applet-chat-config: diff --git a/xinelu-common/src/main/java/com/xinelu/common/utils/tencentcloudapi/trtc/v20190722/TLSSigAPIv2.java b/xinelu-common/src/main/java/com/xinelu/common/utils/tencentcloudapi/trtc/v20190722/TLSSigAPIv2.java index 6a05466..ed2070e 100644 --- a/xinelu-common/src/main/java/com/xinelu/common/utils/tencentcloudapi/trtc/v20190722/TLSSigAPIv2.java +++ b/xinelu-common/src/main/java/com/xinelu/common/utils/tencentcloudapi/trtc/v20190722/TLSSigAPIv2.java @@ -11,208 +11,208 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; public class TLSSigAPIv2 { - final private long sdkappid; - final private String key; + final private long sdkappid; + final private String key; - public TLSSigAPIv2(long sdkappid, String key) { - this.sdkappid = sdkappid; - this.key = key; - } + public TLSSigAPIv2(long sdkappid, String key) { + this.sdkappid = sdkappid; + this.key = key; + } - /** - * 【功能说明】用于签发 TRTC 和 IM 服务中必须要使用的 UserSig 鉴权票据 - *

- * 【参数说明】 - * - * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。 - * @param expire - UserSig 票据的过期时间,单位是秒,比如 86400 代表生成的 UserSig 票据在一天后就无法再使用了。 - * @return usersig -生成的签名 - */ + /** + * 【功能说明】用于签发 TRTC 和 IM 服务中必须要使用的 UserSig 鉴权票据 + *

+ * 【参数说明】 + * + * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。 + * @param expire - UserSig 票据的过期时间,单位是秒,比如 86400 代表生成的 UserSig 票据在一天后就无法再使用了。 + * @return usersig -生成的签名 + */ - /** - * Function: Used to issue UserSig that is required by the TRTC and IM services. - *

- * Parameter description: - * - * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-). - * @param expire - UserSig expiration time, in seconds. For example, 86400 indicates that the generated UserSig will expire one day after being generated. - * @return usersig - Generated signature. - */ - public String genUserSig(String userid, long expire) { - return genUserSig(userid, expire, null); - } + /** + * Function: Used to issue UserSig that is required by the TRTC and IM services. + *

+ * Parameter description: + * + * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-). + * @param expire - UserSig expiration time, in seconds. For example, 86400 indicates that the generated UserSig will expire one day after being generated. + * @return usersig - Generated signature. + */ + public String genUserSig(String userid, long expire) { + return genUserSig(userid, expire, null); + } - /** - * 【功能说明】 - * 用于签发 TRTC 进房参数中可选的 PrivateMapKey 权限票据。 - * PrivateMapKey 需要跟 UserSig 一起使用,但 PrivateMapKey 比 UserSig 有更强的权限控制能力: - * - UserSig 只能控制某个 UserID 有无使用 TRTC 服务的权限,只要 UserSig 正确,其对应的 UserID 可以进出任意房间。 - * - PrivateMapKey 则是将 UserID 的权限控制的更加严格,包括能不能进入某个房间,能不能在该房间里上行音视频等等。 - * 如果要开启 PrivateMapKey 严格权限位校验,需要在【实时音视频控制台】/【应用管理】/【应用信息】中打开“启动权限密钥”开关。 - *

- * 【参数说明】 - * - * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。 - * @param expire - PrivateMapKey 票据的过期时间,单位是秒,比如 86400 生成的 PrivateMapKey 票据在一天后就无法再使用了。 - * @param roomid - 房间号,用于指定该 userid 可以进入的房间号 - * @param privilegeMap - 权限位,使用了一个字节中的 8 个比特位,分别代表八个具体的功能权限开关: - * - 第 1 位:0000 0001 = 1,创建房间的权限 - * - 第 2 位:0000 0010 = 2,加入房间的权限 - * - 第 3 位:0000 0100 = 4,发送语音的权限 - * - 第 4 位:0000 1000 = 8,接收语音的权限 - * - 第 5 位:0001 0000 = 16,发送视频的权限 - * - 第 6 位:0010 0000 = 32,接收视频的权限 - * - 第 7 位:0100 0000 = 64,发送辅路(也就是屏幕分享)视频的权限 - * - 第 8 位:1000 0000 = 200,接收辅路(也就是屏幕分享)视频的权限 - * - privilegeMap == 1111 1111 == 255 代表该 userid 在该 roomid 房间内的所有功能权限。 - * - privilegeMap == 0010 1010 == 42 代表该 userid 拥有加入房间和接收音视频数据的权限,但不具备其他权限。 - * @return usersig - 生成带userbuf的签名 - */ + /** + * 【功能说明】 + * 用于签发 TRTC 进房参数中可选的 PrivateMapKey 权限票据。 + * PrivateMapKey 需要跟 UserSig 一起使用,但 PrivateMapKey 比 UserSig 有更强的权限控制能力: + * - UserSig 只能控制某个 UserID 有无使用 TRTC 服务的权限,只要 UserSig 正确,其对应的 UserID 可以进出任意房间。 + * - PrivateMapKey 则是将 UserID 的权限控制的更加严格,包括能不能进入某个房间,能不能在该房间里上行音视频等等。 + * 如果要开启 PrivateMapKey 严格权限位校验,需要在【实时音视频控制台】/【应用管理】/【应用信息】中打开“启动权限密钥”开关。 + *

+ * 【参数说明】 + * + * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。 + * @param expire - PrivateMapKey 票据的过期时间,单位是秒,比如 86400 生成的 PrivateMapKey 票据在一天后就无法再使用了。 + * @param roomid - 房间号,用于指定该 userid 可以进入的房间号 + * @param privilegeMap - 权限位,使用了一个字节中的 8 个比特位,分别代表八个具体的功能权限开关: + * - 第 1 位:0000 0001 = 1,创建房间的权限 + * - 第 2 位:0000 0010 = 2,加入房间的权限 + * - 第 3 位:0000 0100 = 4,发送语音的权限 + * - 第 4 位:0000 1000 = 8,接收语音的权限 + * - 第 5 位:0001 0000 = 16,发送视频的权限 + * - 第 6 位:0010 0000 = 32,接收视频的权限 + * - 第 7 位:0100 0000 = 64,发送辅路(也就是屏幕分享)视频的权限 + * - 第 8 位:1000 0000 = 200,接收辅路(也就是屏幕分享)视频的权限 + * - privilegeMap == 1111 1111 == 255 代表该 userid 在该 roomid 房间内的所有功能权限。 + * - privilegeMap == 0010 1010 == 42 代表该 userid 拥有加入房间和接收音视频数据的权限,但不具备其他权限。 + * @return usersig - 生成带userbuf的签名 + */ - /** - * Function: - * Used to issue PrivateMapKey that is optional for room entry. - * PrivateMapKey must be used together with UserSig but with more powerful permission control capabilities. - * - UserSig can only control whether a UserID has permission to use the TRTC service. As long as the UserSig is correct, the user with the corresponding UserID can enter or leave any room. - * - PrivateMapKey specifies more stringent permissions for a UserID, including whether the UserID can be used to enter a specific room and perform audio/video upstreaming in the room. - * To enable stringent PrivateMapKey permission bit verification, you need to enable permission key in TRTC console > Application Management > Application Info. - * - * Parameter description: - * - * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-). - * @param roomid - ID of the room to which the specified UserID can enter. - * @param expire - PrivateMapKey expiration time, in seconds. For example, 86400 indicates that the generated PrivateMapKey will expire one day after being generated. - * @param privilegeMap - Permission bits. Eight bits in the same byte are used as the permission switches of eight specific features: - * - Bit 1: 0000 0001 = 1, permission for room creation - * - Bit 2: 0000 0010 = 2, permission for room entry - * - Bit 3: 0000 0100 = 4, permission for audio sending - * - Bit 4: 0000 1000 = 8, permission for audio receiving - * - Bit 5: 0001 0000 = 16, permission for video sending - * - Bit 6: 0010 0000 = 32, permission for video receiving - * - Bit 7: 0100 0000 = 64, permission for substream video sending (screen sharing) - * - Bit 8: 1000 0000 = 200, permission for substream video receiving (screen sharing) - * - privilegeMap == 1111 1111 == 255: Indicates that the UserID has all feature permissions of the room specified by roomid. - * - privilegeMap == 0010 1010 == 42: Indicates that the UserID has only the permissions to enter the room and receive audio/video data. - * @return usersig - Generate signature with userbuf - */ - public String genPrivateMapKey(String userid, long expire, long roomid, long privilegeMap) { - byte[] userbuf = genUserBuf(userid, roomid, expire, privilegeMap, 0, ""); //生成userbuf - return genUserSig(userid, expire, userbuf); - } + /** + * Function: + * Used to issue PrivateMapKey that is optional for room entry. + * PrivateMapKey must be used together with UserSig but with more powerful permission control capabilities. + * - UserSig can only control whether a UserID has permission to use the TRTC service. As long as the UserSig is correct, the user with the corresponding UserID can enter or leave any room. + * - PrivateMapKey specifies more stringent permissions for a UserID, including whether the UserID can be used to enter a specific room and perform audio/video upstreaming in the room. + * To enable stringent PrivateMapKey permission bit verification, you need to enable permission key in TRTC console > Application Management > Application Info. + * + * Parameter description: + * + * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-). + * @param roomid - ID of the room to which the specified UserID can enter. + * @param expire - PrivateMapKey expiration time, in seconds. For example, 86400 indicates that the generated PrivateMapKey will expire one day after being generated. + * @param privilegeMap - Permission bits. Eight bits in the same byte are used as the permission switches of eight specific features: + * - Bit 1: 0000 0001 = 1, permission for room creation + * - Bit 2: 0000 0010 = 2, permission for room entry + * - Bit 3: 0000 0100 = 4, permission for audio sending + * - Bit 4: 0000 1000 = 8, permission for audio receiving + * - Bit 5: 0001 0000 = 16, permission for video sending + * - Bit 6: 0010 0000 = 32, permission for video receiving + * - Bit 7: 0100 0000 = 64, permission for substream video sending (screen sharing) + * - Bit 8: 1000 0000 = 200, permission for substream video receiving (screen sharing) + * - privilegeMap == 1111 1111 == 255: Indicates that the UserID has all feature permissions of the room specified by roomid. + * - privilegeMap == 0010 1010 == 42: Indicates that the UserID has only the permissions to enter the room and receive audio/video data. + * @return usersig - Generate signature with userbuf + */ + public String genPrivateMapKey(String userid, long expire, long roomid, long privilegeMap) { + byte[] userbuf = genUserBuf(userid, roomid, expire, privilegeMap, 0, ""); //生成userbuf + return genUserSig(userid, expire, userbuf); + } - /** - * 【功能说明】 - * 用于签发 TRTC 进房参数中可选的 PrivateMapKey 权限票据。 - * PrivateMapKey 需要跟 UserSig 一起使用,但 PrivateMapKey 比 UserSig 有更强的权限控制能力: - * - UserSig 只能控制某个 UserID 有无使用 TRTC 服务的权限,只要 UserSig 正确,其对应的 UserID 可以进出任意房间。 - * - PrivateMapKey 则是将 UserID 的权限控制的更加严格,包括能不能进入某个房间,能不能在该房间里上行音视频等等。 - * 如果要开启 PrivateMapKey 严格权限位校验,需要在【实时音视频控制台】/【应用管理】/【应用信息】中打开“启动权限密钥”开关。 - *

- * 【参数说明】 - * - * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。 - * @param expire - PrivateMapKey 票据的过期时间,单位是秒,比如 86400 生成的 PrivateMapKey 票据在一天后就无法再使用了。 - * @param roomstr - 字符串房间号,用于指定该 userid 可以进入的房间号 - * @param privilegeMap - 权限位,使用了一个字节中的 8 个比特位,分别代表八个具体的功能权限开关: - * - 第 1 位:0000 0001 = 1,创建房间的权限 - * - 第 2 位:0000 0010 = 2,加入房间的权限 - * - 第 3 位:0000 0100 = 4,发送语音的权限 - * - 第 4 位:0000 1000 = 8,接收语音的权限 - * - 第 5 位:0001 0000 = 16,发送视频的权限 - * - 第 6 位:0010 0000 = 32,接收视频的权限 - * - 第 7 位:0100 0000 = 64,发送辅路(也就是屏幕分享)视频的权限 - * - 第 8 位:1000 0000 = 200,接收辅路(也就是屏幕分享)视频的权限 - * - privilegeMap == 1111 1111 == 255 代表该 userid 在该 roomid 房间内的所有功能权限。 - * - privilegeMap == 0010 1010 == 42 代表该 userid 拥有加入房间和接收音视频数据的权限,但不具备其他权限。 - * @return usersig - 生成带userbuf的签名 - */ + /** + * 【功能说明】 + * 用于签发 TRTC 进房参数中可选的 PrivateMapKey 权限票据。 + * PrivateMapKey 需要跟 UserSig 一起使用,但 PrivateMapKey 比 UserSig 有更强的权限控制能力: + * - UserSig 只能控制某个 UserID 有无使用 TRTC 服务的权限,只要 UserSig 正确,其对应的 UserID 可以进出任意房间。 + * - PrivateMapKey 则是将 UserID 的权限控制的更加严格,包括能不能进入某个房间,能不能在该房间里上行音视频等等。 + * 如果要开启 PrivateMapKey 严格权限位校验,需要在【实时音视频控制台】/【应用管理】/【应用信息】中打开“启动权限密钥”开关。 + *

+ * 【参数说明】 + * + * @param userid - 用户id,限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。 + * @param expire - PrivateMapKey 票据的过期时间,单位是秒,比如 86400 生成的 PrivateMapKey 票据在一天后就无法再使用了。 + * @param roomstr - 字符串房间号,用于指定该 userid 可以进入的房间号 + * @param privilegeMap - 权限位,使用了一个字节中的 8 个比特位,分别代表八个具体的功能权限开关: + * - 第 1 位:0000 0001 = 1,创建房间的权限 + * - 第 2 位:0000 0010 = 2,加入房间的权限 + * - 第 3 位:0000 0100 = 4,发送语音的权限 + * - 第 4 位:0000 1000 = 8,接收语音的权限 + * - 第 5 位:0001 0000 = 16,发送视频的权限 + * - 第 6 位:0010 0000 = 32,接收视频的权限 + * - 第 7 位:0100 0000 = 64,发送辅路(也就是屏幕分享)视频的权限 + * - 第 8 位:1000 0000 = 200,接收辅路(也就是屏幕分享)视频的权限 + * - privilegeMap == 1111 1111 == 255 代表该 userid 在该 roomid 房间内的所有功能权限。 + * - privilegeMap == 0010 1010 == 42 代表该 userid 拥有加入房间和接收音视频数据的权限,但不具备其他权限。 + * @return usersig - 生成带userbuf的签名 + */ - /** - * Function: - * Used to issue PrivateMapKey that is optional for room entry. - * PrivateMapKey must be used together with UserSig but with more powerful permission control capabilities. - * - UserSig can only control whether a UserID has permission to use the TRTC service. As long as the UserSig is correct, the user with the corresponding UserID can enter or leave any room. - * - PrivateMapKey specifies more stringent permissions for a UserID, including whether the UserID can be used to enter a specific room and perform audio/video upstreaming in the room. - * To enable stringent PrivateMapKey permission bit verification, you need to enable permission key in TRTC console > Application Management > Application Info. - * - * Parameter description: - * - * - * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-). - * @param roomid - ID of the room to which the specified UserID can enter. - * @param expire - PrivateMapKey expiration time, in seconds. For example, 86400 indicates that the generated PrivateMapKey will expire one day after being generated. - * @param privilegeMap - Permission bits. Eight bits in the same byte are used as the permission switches of eight specific features: - * - Bit 1: 0000 0001 = 1, permission for room creation - * - Bit 2: 0000 0010 = 2, permission for room entry - * - Bit 3: 0000 0100 = 4, permission for audio sending - * - Bit 4: 0000 1000 = 8, permission for audio receiving - * - Bit 5: 0001 0000 = 16, permission for video sending - * - Bit 6: 0010 0000 = 32, permission for video receiving - * - Bit 7: 0100 0000 = 64, permission for substream video sending (screen sharing) - * - Bit 8: 1000 0000 = 200, permission for substream video receiving (screen sharing) - * - privilegeMap == 1111 1111 == 255: Indicates that the UserID has all feature permissions of the room specified by roomid. - * - privilegeMap == 0010 1010 == 42: Indicates that the UserID has only the permissions to enter the room and receive audio/video data. - * @return usersig - Generate signature with userbuf - */ - public String genPrivateMapKeyWithStringRoomID(String userid, long expire, String roomstr, long privilegeMap) { - byte[] userbuf = genUserBuf(userid, 0, expire, privilegeMap, 0, roomstr); //生成userbuf - return genUserSig(userid, expire, userbuf); - } + /** + * Function: + * Used to issue PrivateMapKey that is optional for room entry. + * PrivateMapKey must be used together with UserSig but with more powerful permission control capabilities. + * - UserSig can only control whether a UserID has permission to use the TRTC service. As long as the UserSig is correct, the user with the corresponding UserID can enter or leave any room. + * - PrivateMapKey specifies more stringent permissions for a UserID, including whether the UserID can be used to enter a specific room and perform audio/video upstreaming in the room. + * To enable stringent PrivateMapKey permission bit verification, you need to enable permission key in TRTC console > Application Management > Application Info. + * + * Parameter description: + * + * + * @param userid - User ID. The value can be up to 32 bytes in length and contain letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-). + * @param roomid - ID of the room to which the specified UserID can enter. + * @param expire - PrivateMapKey expiration time, in seconds. For example, 86400 indicates that the generated PrivateMapKey will expire one day after being generated. + * @param privilegeMap - Permission bits. Eight bits in the same byte are used as the permission switches of eight specific features: + * - Bit 1: 0000 0001 = 1, permission for room creation + * - Bit 2: 0000 0010 = 2, permission for room entry + * - Bit 3: 0000 0100 = 4, permission for audio sending + * - Bit 4: 0000 1000 = 8, permission for audio receiving + * - Bit 5: 0001 0000 = 16, permission for video sending + * - Bit 6: 0010 0000 = 32, permission for video receiving + * - Bit 7: 0100 0000 = 64, permission for substream video sending (screen sharing) + * - Bit 8: 1000 0000 = 200, permission for substream video receiving (screen sharing) + * - privilegeMap == 1111 1111 == 255: Indicates that the UserID has all feature permissions of the room specified by roomid. + * - privilegeMap == 0010 1010 == 42: Indicates that the UserID has only the permissions to enter the room and receive audio/video data. + * @return usersig - Generate signature with userbuf + */ + public String genPrivateMapKeyWithStringRoomID(String userid, long expire, String roomstr, long privilegeMap) { + byte[] userbuf = genUserBuf(userid, 0, expire, privilegeMap, 0, roomstr); //生成userbuf + return genUserSig(userid, expire, userbuf); + } - private String hmacsha256(String identifier, long currTime, long expire, String base64Userbuf) { - String contentToBeSigned = "TLS.identifier:" + identifier + "\n" - + "TLS.sdkappid:" + sdkappid + "\n" - + "TLS.time:" + currTime + "\n" - + "TLS.expire:" + expire + "\n"; - if (null != base64Userbuf) { - contentToBeSigned += "TLS.userbuf:" + base64Userbuf + "\n"; - } - try { - byte[] byteKey = key.getBytes(StandardCharsets.UTF_8); - Mac hmac = Mac.getInstance("HmacSHA256"); - SecretKeySpec keySpec = new SecretKeySpec(byteKey, "HmacSHA256"); - hmac.init(keySpec); - byte[] byteSig = hmac.doFinal(contentToBeSigned.getBytes(StandardCharsets.UTF_8)); - return (Base64.getEncoder().encodeToString(byteSig)).replaceAll("\\s*", ""); - } catch (NoSuchAlgorithmException | InvalidKeyException e) { - return ""; - } - } + private String hmacsha256(String identifier, long currTime, long expire, String base64Userbuf) { + String contentToBeSigned = "TLS.identifier:" + identifier + "\n" + + "TLS.sdkappid:" + sdkappid + "\n" + + "TLS.time:" + currTime + "\n" + + "TLS.expire:" + expire + "\n"; + if (null != base64Userbuf) { + contentToBeSigned += "TLS.userbuf:" + base64Userbuf + "\n"; + } + try { + byte[] byteKey = key.getBytes(StandardCharsets.UTF_8); + Mac hmac = Mac.getInstance("HmacSHA256"); + SecretKeySpec keySpec = new SecretKeySpec(byteKey, "HmacSHA256"); + hmac.init(keySpec); + byte[] byteSig = hmac.doFinal(contentToBeSigned.getBytes(StandardCharsets.UTF_8)); + return (Base64.getEncoder().encodeToString(byteSig)).replaceAll("\\s*", ""); + } catch (NoSuchAlgorithmException | InvalidKeyException e) { + return ""; + } + } - private String genUserSig(String userid, long expire, byte[] userbuf) { + private String genUserSig(String userid, long expire, byte[] userbuf) { - long currTime = System.currentTimeMillis() / 1000; + long currTime = System.currentTimeMillis() / 1000; - JSONObject sigDoc = new JSONObject(); - sigDoc.put("TLS.ver", "2.0"); - sigDoc.put("TLS.identifier", userid); - sigDoc.put("TLS.sdkappid", sdkappid); - sigDoc.put("TLS.expire", expire); - sigDoc.put("TLS.time", currTime); + JSONObject sigDoc = new JSONObject(); + sigDoc.put("TLS.ver", "2.0"); + sigDoc.put("TLS.identifier", userid); + sigDoc.put("TLS.sdkappid", sdkappid); + sigDoc.put("TLS.expire", expire); + sigDoc.put("TLS.time", currTime); - String base64UserBuf = null; - if (null != userbuf) { - base64UserBuf = Base64.getEncoder().encodeToString(userbuf).replaceAll("\\s*", ""); - sigDoc.put("TLS.userbuf", base64UserBuf); - } - String sig = hmacsha256(userid, currTime, expire, base64UserBuf); - if (sig.length() == 0) { - return ""; - } - sigDoc.put("TLS.sig", sig); - Deflater compressor = new Deflater(); - compressor.setInput(sigDoc.toString().getBytes(StandardCharsets.UTF_8)); - compressor.finish(); - byte[] compressedBytes = new byte[2048]; - int compressedBytesLength = compressor.deflate(compressedBytes); - compressor.end(); - return (new String(Base64URL.base64EncodeUrl(Arrays.copyOfRange(compressedBytes, - 0, compressedBytesLength)))).replaceAll("\\s*", ""); - } + String base64UserBuf = null; + if (null != userbuf) { + base64UserBuf = Base64.getEncoder().encodeToString(userbuf).replaceAll("\\s*", ""); + sigDoc.put("TLS.userbuf", base64UserBuf); + } + String sig = hmacsha256(userid, currTime, expire, base64UserBuf); + if (sig.length() == 0) { + return ""; + } + sigDoc.put("TLS.sig", sig); + Deflater compressor = new Deflater(); + compressor.setInput(sigDoc.toString().getBytes(StandardCharsets.UTF_8)); + compressor.finish(); + byte[] compressedBytes = new byte[2048]; + int compressedBytesLength = compressor.deflate(compressedBytes); + compressor.end(); + return (new String(Base64URL.base64EncodeUrl(Arrays.copyOfRange(compressedBytes, + 0, compressedBytesLength)))).replaceAll("\\s*", ""); + } - public byte[] genUserBuf(String account, long dwAuthID, long dwExpTime, - long dwPrivilegeMap, long dwAccountType, String RoomStr) { - //视频校验位需要用到的字段,按照网络字节序放入buf中 + public byte[] genUserBuf(String account, long dwAuthID, long dwExpTime, + long dwPrivilegeMap, long dwAccountType, String RoomStr) { + //视频校验位需要用到的字段,按照网络字节序放入buf中 /* cVer unsigned char/1 版本号,填0 wAccountLen unsigned short /2 第三方自己的帐号长度 @@ -224,7 +224,7 @@ public class TLSSigAPIv2 { dwAccountType unsigned int/4 第三方帐号类型 */ - //The fields required for the video check digit are placed in buf according to the network byte order. + //The fields required for the video check digit are placed in buf according to the network byte order. /* cVer unsigned char/1 Version number, fill in 0 wAccountLen unsigned short /2 Third party's own account length @@ -235,78 +235,78 @@ public class TLSSigAPIv2 { dwPrivilegeMap unsigned int/4 Permission bits, host 0xff, audience 0xab dwAccountType unsigned int/4 Third-party account type */ - int accountLength = account.length(); - int roomStrLength = RoomStr.length(); - int offset = 0; - int bufLength = 1 + 2 + accountLength + 20 ; - if (roomStrLength > 0) { - bufLength = bufLength + 2 + roomStrLength; - } - byte[] userbuf = new byte[bufLength]; + int accountLength = account.length(); + int roomStrLength = RoomStr.length(); + int offset = 0; + int bufLength = 1 + 2 + accountLength + 20 ; + if (roomStrLength > 0) { + bufLength = bufLength + 2 + roomStrLength; + } + byte[] userbuf = new byte[bufLength]; - //cVer - if (roomStrLength > 0) { - userbuf[offset++] = 1; - } else { - userbuf[offset++] = 0; - } + //cVer + if (roomStrLength > 0) { + userbuf[offset++] = 1; + } else { + userbuf[offset++] = 0; + } - //wAccountLen - userbuf[offset++] = (byte) ((accountLength & 0xFF00) >> 8); - userbuf[offset++] = (byte) (accountLength & 0x00FF); + //wAccountLen + userbuf[offset++] = (byte) ((accountLength & 0xFF00) >> 8); + userbuf[offset++] = (byte) (accountLength & 0x00FF); - //account - for (; offset < 3 + accountLength; ++offset) { - userbuf[offset] = (byte) account.charAt(offset - 3); - } + //account + for (; offset < 3 + accountLength; ++offset) { + userbuf[offset] = (byte) account.charAt(offset - 3); + } - //dwSdkAppid - userbuf[offset++] = (byte) ((sdkappid & 0xFF000000) >> 24); - userbuf[offset++] = (byte) ((sdkappid & 0x00FF0000) >> 16); - userbuf[offset++] = (byte) ((sdkappid & 0x0000FF00) >> 8); - userbuf[offset++] = (byte) (sdkappid & 0x000000FF); + //dwSdkAppid + userbuf[offset++] = (byte) ((sdkappid & 0xFF000000) >> 24); + userbuf[offset++] = (byte) ((sdkappid & 0x00FF0000) >> 16); + userbuf[offset++] = (byte) ((sdkappid & 0x0000FF00) >> 8); + userbuf[offset++] = (byte) (sdkappid & 0x000000FF); - //dwAuthId,房间号 - //dwAuthId, room number - userbuf[offset++] = (byte) ((dwAuthID & 0xFF000000) >> 24); - userbuf[offset++] = (byte) ((dwAuthID & 0x00FF0000) >> 16); - userbuf[offset++] = (byte) ((dwAuthID & 0x0000FF00) >> 8); - userbuf[offset++] = (byte) (dwAuthID & 0x000000FF); + //dwAuthId,房间号 + //dwAuthId, room number + userbuf[offset++] = (byte) ((dwAuthID & 0xFF000000) >> 24); + userbuf[offset++] = (byte) ((dwAuthID & 0x00FF0000) >> 16); + userbuf[offset++] = (byte) ((dwAuthID & 0x0000FF00) >> 8); + userbuf[offset++] = (byte) (dwAuthID & 0x000000FF); - //expire,过期时间,当前时间 + 有效期(单位:秒) - //expire,Expiration time, current time + validity period (unit: seconds) - long currTime = System.currentTimeMillis() / 1000; - long expire = currTime + dwExpTime; - userbuf[offset++] = (byte) ((expire & 0xFF000000) >> 24); - userbuf[offset++] = (byte) ((expire & 0x00FF0000) >> 16); - userbuf[offset++] = (byte) ((expire & 0x0000FF00) >> 8); - userbuf[offset++] = (byte) (expire & 0x000000FF); + //expire,过期时间,当前时间 + 有效期(单位:秒) + //expire,Expiration time, current time + validity period (unit: seconds) + long currTime = System.currentTimeMillis() / 1000; + long expire = currTime + dwExpTime; + userbuf[offset++] = (byte) ((expire & 0xFF000000) >> 24); + userbuf[offset++] = (byte) ((expire & 0x00FF0000) >> 16); + userbuf[offset++] = (byte) ((expire & 0x0000FF00) >> 8); + userbuf[offset++] = (byte) (expire & 0x000000FF); - //dwPrivilegeMap,权限位 - //dwPrivilegeMap,Permission bits - userbuf[offset++] = (byte) ((dwPrivilegeMap & 0xFF000000) >> 24); - userbuf[offset++] = (byte) ((dwPrivilegeMap & 0x00FF0000) >> 16); - userbuf[offset++] = (byte) ((dwPrivilegeMap & 0x0000FF00) >> 8); - userbuf[offset++] = (byte) (dwPrivilegeMap & 0x000000FF); + //dwPrivilegeMap,权限位 + //dwPrivilegeMap,Permission bits + userbuf[offset++] = (byte) ((dwPrivilegeMap & 0xFF000000) >> 24); + userbuf[offset++] = (byte) ((dwPrivilegeMap & 0x00FF0000) >> 16); + userbuf[offset++] = (byte) ((dwPrivilegeMap & 0x0000FF00) >> 8); + userbuf[offset++] = (byte) (dwPrivilegeMap & 0x000000FF); - //dwAccountType,账户类型 - //dwAccountType,account type - userbuf[offset++] = (byte) ((dwAccountType & 0xFF000000) >> 24); - userbuf[offset++] = (byte) ((dwAccountType & 0x00FF0000) >> 16); - userbuf[offset++] = (byte) ((dwAccountType & 0x0000FF00) >> 8); - userbuf[offset++] = (byte) (dwAccountType & 0x000000FF); + //dwAccountType,账户类型 + //dwAccountType,account type + userbuf[offset++] = (byte) ((dwAccountType & 0xFF000000) >> 24); + userbuf[offset++] = (byte) ((dwAccountType & 0x00FF0000) >> 16); + userbuf[offset++] = (byte) ((dwAccountType & 0x0000FF00) >> 8); + userbuf[offset++] = (byte) (dwAccountType & 0x000000FF); - if (roomStrLength > 0) { - //roomStrLen - userbuf[offset++] = (byte) ((roomStrLength & 0xFF00) >> 8); - userbuf[offset++] = (byte) (roomStrLength & 0x00FF); + if (roomStrLength > 0) { + //roomStrLen + userbuf[offset++] = (byte) ((roomStrLength & 0xFF00) >> 8); + userbuf[offset++] = (byte) (roomStrLength & 0x00FF); - //roomStr - for (; offset < bufLength; ++offset) { - userbuf[offset] = (byte) RoomStr.charAt(offset - (bufLength - roomStrLength)); - } - } - return userbuf; - } + //roomStr + for (; offset < bufLength; ++offset) { + userbuf[offset] = (byte) RoomStr.charAt(offset - (bufLength - roomStrLength)); + } + } + return userbuf; + } } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/consultationInfo/ConsultationInfoController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/consultationInfo/ConsultationInfoController.java index 1a3afe0..ec1e3a6 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/consultationInfo/ConsultationInfoController.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/consultationInfo/ConsultationInfoController.java @@ -1,7 +1,7 @@ package com.xinelu.applet.controller.consultationInfo; -import com.xinelu.applet.dto.consultationInfo.ConsultationInfoDTO; -import com.xinelu.applet.service.consultationInfo.IConsultationInfoService; +import com.xinelu.manage.dto.consultationInfo.ConsultationInfoDTO; +import com.xinelu.manage.service.consultationInfo.IConsultationInfoService; import com.xinelu.common.constant.Constants; import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/videoconsultation/VideoConsultationController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/videoconsultation/VideoConsultationController.java index 4734930..e6d535d 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/videoconsultation/VideoConsultationController.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/videoconsultation/VideoConsultationController.java @@ -1,11 +1,7 @@ package com.xinelu.applet.controller.videoconsultation; -import com.xinelu.applet.dto.consultationInfo.ConsultationInfoDTO; -import com.xinelu.applet.service.consultationInfo.IConsultationInfoService; +import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.domain.R; -import com.xinelu.common.core.dto.MessageTemplate; -import com.xinelu.common.enums.MessageContentType; -import com.xinelu.common.socket.WebSocketUtils; import com.xinelu.common.utils.tencentcloudapi.common.Credential; import com.xinelu.common.utils.tencentcloudapi.common.exception.TencentCloudSDKException; import com.xinelu.common.utils.tencentcloudapi.common.profile.ClientProfile; @@ -14,10 +10,9 @@ import com.xinelu.common.utils.tencentcloudapi.trtc.v20190722.TLSSigAPIv2; import com.xinelu.common.utils.tencentcloudapi.trtc.v20190722.TrtcClient; import com.xinelu.common.utils.tencentcloudapi.trtc.v20190722.models.DissolveRoomRequest; import com.xinelu.common.utils.tencentcloudapi.trtc.v20190722.models.DissolveRoomResponse; +import com.xinelu.manage.service.consultationInfo.IConsultationInfoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import java.util.Date; -import java.util.Random; import javax.annotation.Resource; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; @@ -37,6 +32,8 @@ public class VideoConsultationController { @Value("${trtc.sdkappid}") private Long sdkappid; + @Value("${trtc.sdksecretkey}") + private String sdksecretkey; @Value("${trtc.secretid}") private String secretid; @Value("${trtc.secretkey}") @@ -51,33 +48,15 @@ public class VideoConsultationController { @ApiOperation("获取userSig") @GetMapping("getUserSig/{userId}") public R getUserSig(@PathVariable String userId) { - TLSSigAPIv2 sigAPIv2 = new TLSSigAPIv2(sdkappid, secretkey); + TLSSigAPIv2 sigAPIv2 = new TLSSigAPIv2(sdkappid, sdksecretkey); String userSig = sigAPIv2.genUserSig(userId, 36000); return R.ok(userSig); } - @ApiOperation("开始视频") - @GetMapping("start/{consultationInfoId}") - public R start(@PathVariable Long consultationInfoId) { - // 房间号 - Random random = new Random(); - int randomNumber = random.nextInt(900000) + 100000; // 限制范围为 100000-999999 - String roomId = String.valueOf(randomNumber); - if (roomId.length() < 6) { - roomId = "0" + roomId; // 补零 - } - MessageTemplate msg = new MessageTemplate(); - // 根据图文咨询申请主键查询居民主键 - ConsultationInfoDTO consultationInfoDTO = consultationInfoService.selectConsultationInfoById(consultationInfoId); - if (consultationInfoDTO == null) { - return R.fail("生成房间号失败"); - } - msg.setMessage(roomId); - msg.setToKey(String.valueOf(consultationInfoDTO.getPatientId())); - msg.setMsgType(MessageContentType.CONSULTATION.name()); - msg.setSendTime(new Date()); - WebSocketUtils.sendMessage(String.valueOf(consultationInfoDTO.getPatientId()), msg); - return R.ok(roomId); + @ApiOperation("开始视频--医生APP") + @GetMapping("start/{goodsOrderId}") + public AjaxResult start(@PathVariable Long goodsOrderId) { + return consultationInfoService.startConsultation(goodsOrderId); } @@ -95,4 +74,11 @@ public class VideoConsultationController { DissolveRoomResponse resp = client.DissolveRoom(req); return R.ok(resp.getRequestId()); } + + @ApiOperation("小程序通过订单号查询房间号") + @GetMapping("getRoomId/{goodsOrderId}") + public AjaxResult getAppletRoomId(@PathVariable Long goodsOrderId) { + return consultationInfoService.getAppletRoomId(goodsOrderId); + } + } diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/consultationInfo/ConsultationInfo.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/consultationInfo/ConsultationInfo.java index bd06944..4ff282f 100644 --- a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/consultationInfo/ConsultationInfo.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/consultationInfo/ConsultationInfo.java @@ -159,7 +159,6 @@ public class ConsultationInfo extends BaseEntity implements Serializable { */ private Integer delFlag; - @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/goodsOrder/GoodsOrder.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/goodsOrder/GoodsOrder.java index b3ee54a..2763e31 100644 --- a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/goodsOrder/GoodsOrder.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/goodsOrder/GoodsOrder.java @@ -185,6 +185,11 @@ public class GoodsOrder extends BaseDomain implements Serializable { */ private Long consultationInfoId; + /** + * 房间号--视频问诊用 + */ + private String roomId; + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) @@ -207,6 +212,7 @@ public class GoodsOrder extends BaseDomain implements Serializable { .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) + .append("roomId", getRoomId()) .toString(); } } diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/chatrecord/ChatRecordDTO.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/chatrecord/ChatRecordDTO.java index d155cb7..8d8df4e 100644 --- a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/chatrecord/ChatRecordDTO.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/chatrecord/ChatRecordDTO.java @@ -84,6 +84,11 @@ public class ChatRecordDTO extends BaseEntity implements Serializable { @Length(max = 400, message = "消息内容不能超过18位", groups = {Insert.class, Update.class}) private String content; + /** + * 消息内容业务主键,用于点击跳转 + */ + private String contentId; + /** * 标题 */ diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/dto/consultationInfo/ConsultationInfoDTO.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/consultationInfo/ConsultationInfoDTO.java similarity index 99% rename from xinelu-nurse-applet/src/main/java/com/xinelu/applet/dto/consultationInfo/ConsultationInfoDTO.java rename to xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/consultationInfo/ConsultationInfoDTO.java index d2455e2..4052ea0 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/dto/consultationInfo/ConsultationInfoDTO.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/consultationInfo/ConsultationInfoDTO.java @@ -1,4 +1,4 @@ -package com.xinelu.applet.dto.consultationInfo; +package com.xinelu.manage.dto.consultationInfo; import com.fasterxml.jackson.annotation.JsonFormat; import com.xinelu.common.core.domain.BaseEntity; diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/consultationInfo/ConsultationInfoMapper.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/mapper/consultationInfo/ConsultationInfoMapper.java similarity index 95% rename from xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/consultationInfo/ConsultationInfoMapper.java rename to xinelu-nurse-manage/src/main/java/com/xinelu/manage/mapper/consultationInfo/ConsultationInfoMapper.java index 7324afc..103c492 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/consultationInfo/ConsultationInfoMapper.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/mapper/consultationInfo/ConsultationInfoMapper.java @@ -1,6 +1,6 @@ -package com.xinelu.applet.mapper.consultationInfo; +package com.xinelu.manage.mapper.consultationInfo; -import com.xinelu.applet.dto.consultationInfo.ConsultationInfoDTO; +import com.xinelu.manage.dto.consultationInfo.ConsultationInfoDTO; import com.xinelu.manage.domain.consultationInfo.ConsultationInfo; import com.xinelu.manage.vo.consultationInfo.ConsultationInfoVO; import org.apache.ibatis.annotations.Param; diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/consultationInfo/IConsultationInfoService.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/consultationInfo/IConsultationInfoService.java similarity index 92% rename from xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/consultationInfo/IConsultationInfoService.java rename to xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/consultationInfo/IConsultationInfoService.java index e7aa4e3..071b8b1 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/consultationInfo/IConsultationInfoService.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/consultationInfo/IConsultationInfoService.java @@ -1,14 +1,13 @@ -package com.xinelu.applet.service.consultationInfo; +package com.xinelu.manage.service.consultationInfo; -import com.xinelu.applet.dto.consultationInfo.ConsultationInfoDTO; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.exception.file.InvalidExtensionException; import com.xinelu.manage.domain.consultationInfo.ConsultationInfo; +import com.xinelu.manage.dto.consultationInfo.ConsultationInfoDTO; import com.xinelu.manage.vo.consultationInfo.ConsultationInfoVO; -import org.springframework.web.multipart.MultipartFile; - import java.io.IOException; import java.util.List; +import org.springframework.web.multipart.MultipartFile; /** @@ -74,4 +73,8 @@ public interface IConsultationInfoService { * @return 结果 */ public AjaxResult uploadConsultationFile(MultipartFile multipartFile) throws IOException, InvalidExtensionException; + + AjaxResult startConsultation(Long consultationInfoId); + + AjaxResult getAppletRoomId(Long goodsOrderId); } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/consultationInfo/impl/ConsultationInfoServiceImpl.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/consultationInfo/impl/ConsultationInfoServiceImpl.java similarity index 64% rename from xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/consultationInfo/impl/ConsultationInfoServiceImpl.java rename to xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/consultationInfo/impl/ConsultationInfoServiceImpl.java index fdab9fd..7842cc8 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/consultationInfo/impl/ConsultationInfoServiceImpl.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/consultationInfo/impl/ConsultationInfoServiceImpl.java @@ -1,8 +1,6 @@ -package com.xinelu.applet.service.consultationInfo.impl; +package com.xinelu.manage.service.consultationInfo.impl; -import com.xinelu.applet.dto.consultationInfo.ConsultationInfoDTO; -import com.xinelu.applet.mapper.consultationInfo.ConsultationInfoMapper; -import com.xinelu.applet.service.consultationInfo.IConsultationInfoService; +import com.alibaba.fastjson2.JSONObject; import com.xinelu.common.config.XinELuConfig; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.exception.ServiceException; @@ -12,17 +10,26 @@ import com.xinelu.common.utils.bean.BeanUtils; import com.xinelu.common.utils.file.FileUploadUtils; import com.xinelu.common.utils.file.MimeTypeUtils; import com.xinelu.manage.domain.consultationInfo.ConsultationInfo; +import com.xinelu.manage.domain.goodsOrder.GoodsOrder; +import com.xinelu.manage.dto.consultationInfo.ConsultationInfoDTO; +import com.xinelu.manage.mapper.consultationInfo.ConsultationInfoMapper; +import com.xinelu.manage.mapper.goodsOrder.GoodsOrderMapper; +import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; +import com.xinelu.manage.service.consultationInfo.IConsultationInfoService; +import com.xinelu.manage.service.messagepush.MessagePushService; import com.xinelu.manage.vo.consultationInfo.ConsultationInfoVO; +import com.xinelu.manage.vo.patientinfo.PatientInfoVO; +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.Random; +import javax.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import javax.annotation.Resource; -import java.io.IOException; -import java.util.List; - /** * 在线问诊-问诊信息(图文和视频问诊基本信息)Service业务层处理 @@ -38,6 +45,15 @@ public class ConsultationInfoServiceImpl implements IConsultationInfoService { @Resource private XinELuConfig xinYiLuConfig; + @Resource + private GoodsOrderMapper goodsOrderMapper; + + @Resource + private MessagePushService messagePushService; + + @Resource + private PatientInfoMapper patientInfoMapper; + /** * 查询在线问诊-问诊信息(图文和视频问诊基本信息) * @@ -143,4 +159,62 @@ public class ConsultationInfoServiceImpl implements IConsultationInfoService { ajax.put("fileUrl", pictureName); return ajax; } + + @Override public AjaxResult startConsultation(Long goodsOrderId) { + GoodsOrder goodOrder = goodsOrderMapper.selectGoodsOrderById(goodsOrderId); + if (goodOrder == null) { + return AjaxResult.error("未查找到该订单,请联系管理员"); + } + // 根据图文咨询申请主键查询居民主键 + ConsultationInfoDTO consultationInfo = consultationInfoMapper.selectConsultationInfoById(goodOrder.getConsultationInfoId()); + if (consultationInfo == null) { + return AjaxResult.error("生成房间号失败"); + } + String roomId = ""; + if(com.xinelu.common.utils.StringUtils.isNotBlank(goodOrder.getRoomId())) { + roomId = goodOrder.getRoomId(); + } else { + // 房间号 + Random random = new Random(); + int randomNumber = random.nextInt(900000) + 100000; // 限制范围为 100000-999999 + roomId = String.valueOf(randomNumber); + if (roomId.length() < 6) { + roomId = "0" + roomId; // 补零 + } + // 保存房间号 + goodOrder.setRoomId(roomId); + goodsOrderMapper.updateGoodsOrder(goodOrder); + } + PatientInfoVO patient = patientInfoMapper.selectPatientInfoById(goodOrder.getPatientId()); + if (patient == null) { + return AjaxResult.error("未查询到该居民"); + } + + // 给居民推送消息通知 + JSONObject result = new JSONObject() + .fluentPut("patientId", patient.getId()) + .fluentPut("openid", patient.getOpenid()) + .fluentPut("receiveName", patient.getPatientName()) + .fluentPut("sendTitle", "专家视频问诊") + .fluentPut("sendTime", DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date())) + .fluentPut("busType", "") + .fluentPut("sendContent", "专家邀请您进行视频问诊,请及时接听") + .fluentPut("messageType", "1") + .fluentPut("messageCategory", "4") + .fluentPut("cardNo", patient.getCardNo()) + .fluentPut("senderName", consultationInfo.getDoctorName()) + .fluentPut("contentId", goodOrder.getId()) + .fluentPut("sourceType", "1"); + messagePushService.fdApprovePush(result); + return AjaxResult.success(roomId); + } + + @Override + public AjaxResult getAppletRoomId(Long goodsOrderId) { + GoodsOrder order = goodsOrderMapper.selectGoodsOrderById(goodsOrderId); + if (order == null) { + return AjaxResult.error("未查询到订单信息"); + } + return AjaxResult.success(order.getRoomId()); + } } diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/messagepush/Impl/MessagePushServiceImpl.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/messagepush/Impl/MessagePushServiceImpl.java index d2f42a0..1716759 100644 --- a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/messagepush/Impl/MessagePushServiceImpl.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/messagepush/Impl/MessagePushServiceImpl.java @@ -297,6 +297,9 @@ public class MessagePushServiceImpl implements MessagePushService { messageValueEntityMap.put("thing1", new MessageValueEntity(body.getString("senderName"))); messageValueEntityMap.put("time2", new MessageValueEntity(body.getString("sendTime"))); messageValueEntityMap.put("thing3", new MessageValueEntity(body.getString("sendContent"))); + if (body.containsKey("contentId")) { + chatRecord.setContentId(body.getString("contentId")); + } chatRecord.setContent(body.getString("sendContent")); chatRecord.setRecipientName(body.getString("receiveName")); chatRecord.setSenderName(body.getString("senderName")); @@ -306,7 +309,17 @@ public class MessagePushServiceImpl implements MessagePushService { Map paramsMap = new HashMap<>(); paramsMap.put("touser", body.getString("openid")); paramsMap.put("template_id", MessageTemplateType.getFolllowupTypeByCode(body.getString("busType")).getTemplateId()); - paramsMap.put("page", appletPageConfig.getIntegralPageUrl()); + + if (StringUtils.isNotBlank(body.getString("sourceType"))) { + switch (body.getString("sourceType")) { + case "1": // 1:订单页面 + paramsMap.put("page", appletPageConfig.getAppointOrderPageUrl()); + break; + default: + paramsMap.put("page", appletPageConfig.getIntegralPageUrl()); + break; + } + } paramsMap.put("data", messageValueEntityMap); //发送 this.sendPosts(appletAccessToken, paramsMap); diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java index e4b5318..41b8f29 100644 --- a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java @@ -172,7 +172,6 @@ public class ScreeningRecordServiceImpl implements IScreeningRecordService { JSONObject result = new JSONObject(); result.put("patientId", body.getPatientId()); if (flag > 0) { - // TODO 推送提醒 // 组装发送消息通知参数 result.put("openid", registerVo.getOpenid()); result.put("receiveName", registerVo.getPatientName()); diff --git a/xinelu-nurse-applet/src/main/resources/mapper/applet/consultationInfo/ConsultationInfoMapper.xml b/xinelu-nurse-manage/src/main/resources/mapper/manage/consultationInfo/ConsultationInfoMapper.xml similarity index 98% rename from xinelu-nurse-applet/src/main/resources/mapper/applet/consultationInfo/ConsultationInfoMapper.xml rename to xinelu-nurse-manage/src/main/resources/mapper/manage/consultationInfo/ConsultationInfoMapper.xml index 8d602b4..a2aaa28 100644 --- a/xinelu-nurse-applet/src/main/resources/mapper/applet/consultationInfo/ConsultationInfoMapper.xml +++ b/xinelu-nurse-manage/src/main/resources/mapper/manage/consultationInfo/ConsultationInfoMapper.xml @@ -2,7 +2,7 @@ - + @@ -57,7 +57,7 @@ from consultation_info - SELECT ci.id, ci.patient_id, @@ -113,7 +113,7 @@ ORDER BY ci.create_time DESC - select id, patient_id, patient_name, diff --git a/xinelu-nurse-manage/src/main/resources/mapper/manage/goodsOrder/GoodsOrderMapper.xml b/xinelu-nurse-manage/src/main/resources/mapper/manage/goodsOrder/GoodsOrderMapper.xml index 41e4e69..2ec10c3 100644 --- a/xinelu-nurse-manage/src/main/resources/mapper/manage/goodsOrder/GoodsOrderMapper.xml +++ b/xinelu-nurse-manage/src/main/resources/mapper/manage/goodsOrder/GoodsOrderMapper.xml @@ -35,6 +35,7 @@ + @@ -119,7 +120,8 @@ health_consultation_content, health_appoint_date, hospital_person_name, - consultation_info_id + consultation_info_id, + room_id from goods_order @@ -277,6 +279,8 @@ consultation_info_id, + room_id, + #{nurseStationId}, @@ -337,6 +341,8 @@ #{consultationInfoId}, + #{roomId}, + @@ -430,6 +436,9 @@ consultation_info_id = #{consultationInfoId}, + room_id = + #{roomId}, + where id = #{id}