|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+package com.ruoyi.wisdomarbitrate.service.mscase.impl;
|
|
|
2
|
+
|
|
|
3
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
4
|
+import cn.hutool.http.HttpUtil;
|
|
|
5
|
+import com.alibaba.fastjson.JSON;
|
|
|
6
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
7
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
8
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
9
|
+import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
10
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
11
|
+import com.ruoyi.common.enums.AnnexTypeEnum;
|
|
|
12
|
+import com.ruoyi.common.utils.PdfUtils;
|
|
|
13
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
14
|
+import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
|
|
|
15
|
+import com.ruoyi.system.mapper.SysRoleMapper;
|
|
|
16
|
+import com.ruoyi.system.mapper.SysUserMapper;
|
|
|
17
|
+import com.ruoyi.wisdomarbitrate.domain.dto.mscase.ReservedConference;
|
|
|
18
|
+import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
|
|
|
19
|
+import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
|
|
|
20
|
+import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
|
|
|
21
|
+import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsReservedConferenceVO;
|
|
|
22
|
+import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseApplicationMapper;
|
|
|
23
|
+import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper;
|
|
|
24
|
+import com.ruoyi.wisdomarbitrate.mapper.mscase.ReservedConferenceMapper;
|
|
|
25
|
+import com.ruoyi.wisdomarbitrate.service.mscase.VideoConferenceService;
|
|
|
26
|
+import com.tencentcloudapi.common.Credential;
|
|
|
27
|
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
|
28
|
+import com.tencentcloudapi.common.profile.ClientProfile;
|
|
|
29
|
+import com.tencentcloudapi.common.profile.HttpProfile;
|
|
|
30
|
+import com.tencentcloudapi.trtc.v20190722.TrtcClient;
|
|
|
31
|
+import com.tencentcloudapi.trtc.v20190722.models.*;
|
|
|
32
|
+import com.tencentyun.TLSSigAPIv2;
|
|
|
33
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
34
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
35
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
36
|
+import org.springframework.stereotype.Service;
|
|
|
37
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
38
|
+import tk.mybatis.mapper.entity.Example;
|
|
|
39
|
+
|
|
|
40
|
+import javax.crypto.Mac;
|
|
|
41
|
+import javax.crypto.spec.SecretKeySpec;
|
|
|
42
|
+import java.io.IOException;
|
|
|
43
|
+import java.nio.file.Paths;
|
|
|
44
|
+import java.util.Base64;
|
|
|
45
|
+import java.util.Date;
|
|
|
46
|
+import java.util.List;
|
|
|
47
|
+import java.util.Map;
|
|
|
48
|
+import java.util.stream.Collectors;
|
|
|
49
|
+
|
|
|
50
|
+import static com.ruoyi.common.core.domain.AjaxResult.success;
|
|
|
51
|
+import static com.ruoyi.common.utils.file.FileUploadUtils.getAbsoluteFile;
|
|
|
52
|
+import static com.ruoyi.common.utils.file.FileUploadUtils.getPathFileName;
|
|
|
53
|
+
|
|
|
54
|
+/**
|
|
|
55
|
+ * @author wangqiong
|
|
|
56
|
+ * @description 视频录制
|
|
|
57
|
+ * @date 2023-10-26 11:45
|
|
|
58
|
+ */
|
|
|
59
|
+@Service
|
|
|
60
|
+@Slf4j
|
|
|
61
|
+public class VideoConferenceServiceImpl implements VideoConferenceService {
|
|
|
62
|
+ // 腾讯云即时通信sdkAppId
|
|
|
63
|
+ @Value("${imConfig.sdkAppId}")
|
|
|
64
|
+ private long sdkAppId;
|
|
|
65
|
+ // 腾讯云即时通信密钥
|
|
|
66
|
+ @Value("${imConfig.sdkSecretKey}")
|
|
|
67
|
+ private String sdkSecretKey;
|
|
|
68
|
+ // 腾讯云个人账户secretId
|
|
|
69
|
+ @Value("${imConfig.secretId}")
|
|
|
70
|
+ private String secretId;
|
|
|
71
|
+ // 腾讯云个人账户密钥
|
|
|
72
|
+ @Value("${imConfig.secretKey}")
|
|
|
73
|
+ private String secretKey;
|
|
|
74
|
+ @Autowired
|
|
|
75
|
+ private MsCaseApplicationMapper caseApplicationMapper;
|
|
|
76
|
+ @Autowired
|
|
|
77
|
+ private MsCaseAttachMapper caseAttachMapper;
|
|
|
78
|
+ @Autowired
|
|
|
79
|
+ private SysRoleMapper roleMapper;
|
|
|
80
|
+ @Autowired
|
|
|
81
|
+ private ReservedConferenceMapper reservedConferenceMapper;
|
|
|
82
|
+ @Autowired
|
|
|
83
|
+ private SysUserMapper sysUserMapper;
|
|
|
84
|
+
|
|
|
85
|
+ /**
|
|
|
86
|
+ 视频回调
|
|
|
87
|
+ * @throws Exception
|
|
|
88
|
+ */
|
|
|
89
|
+ @Override
|
|
|
90
|
+ public void videoRollBack(String fileId,String videoUrl,String roomId) {
|
|
|
91
|
+ try {
|
|
|
92
|
+ downloadImage(fileId,videoUrl,roomId);
|
|
|
93
|
+ } catch (IOException e) {
|
|
|
94
|
+ throw new RuntimeException(e);
|
|
|
95
|
+ }
|
|
|
96
|
+
|
|
|
97
|
+ }
|
|
|
98
|
+ /**
|
|
|
99
|
+ * 获取userSign,默认过期时间10小时
|
|
|
100
|
+ *
|
|
|
101
|
+ * @param userId
|
|
|
102
|
+ * @return
|
|
|
103
|
+ */
|
|
|
104
|
+ @Override
|
|
|
105
|
+ public String generateUserSign(String userId) {
|
|
|
106
|
+ TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(sdkAppId, sdkSecretKey);
|
|
|
107
|
+ return tlsSigAPIv2.genUserSig(userId, 60 * 60 * 10);
|
|
|
108
|
+ }
|
|
|
109
|
+ /**
|
|
|
110
|
+ * 预约会议
|
|
|
111
|
+ *
|
|
|
112
|
+ * @param reservedConferenceVO
|
|
|
113
|
+ * @return
|
|
|
114
|
+ * @throws Exception
|
|
|
115
|
+ */
|
|
|
116
|
+ @Transactional
|
|
|
117
|
+ @Override
|
|
|
118
|
+ public AjaxResult reservedConference(MsReservedConferenceVO reservedConferenceVO) {
|
|
|
119
|
+
|
|
|
120
|
+ // 新增预约会议表
|
|
|
121
|
+ ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(), SecurityUtils.getUserId(), reservedConferenceVO.getRoomId(),
|
|
|
122
|
+ reservedConferenceVO.getScheduleStartTime(), reservedConferenceVO.getScheduleEndTime());
|
|
|
123
|
+ reservedConferenceMapper.insert(conference);
|
|
|
124
|
+ return success("预约会议成功");
|
|
|
125
|
+ }
|
|
|
126
|
+
|
|
|
127
|
+ /**
|
|
|
128
|
+ * 根据案件id查询已预约的会议
|
|
|
129
|
+ *
|
|
|
130
|
+ * @param caseId
|
|
|
131
|
+ * @return
|
|
|
132
|
+ */
|
|
|
133
|
+ @Override
|
|
|
134
|
+ @Transactional
|
|
|
135
|
+ public List<ReservedConference> reserveConferenceList(Long caseId) {
|
|
|
136
|
+ List<ReservedConference> reservedConferences = reservedConferenceMapper.selectListByCaseId(caseId);
|
|
|
137
|
+ if (CollectionUtil.isEmpty(reservedConferences)) {
|
|
|
138
|
+ return reservedConferences;
|
|
|
139
|
+ }
|
|
|
140
|
+ Map<Long, String> userIdMap = null;
|
|
|
141
|
+ List<Long> userIds = reservedConferences.stream().map(ReservedConference::getUserId).collect(Collectors.toList());
|
|
|
142
|
+ if (CollectionUtil.isNotEmpty(userIds)) {
|
|
|
143
|
+ // 根据userids查询用户名
|
|
|
144
|
+ List<SysUser> userList = sysUserMapper.selectUserListByIds(userIds);
|
|
|
145
|
+ if (CollectionUtil.isNotEmpty(userList)) {
|
|
|
146
|
+ userIdMap = userList.stream().collect(Collectors.toMap(SysUser::getUserId, SysUser::getUserName));
|
|
|
147
|
+ }
|
|
|
148
|
+ }
|
|
|
149
|
+ for (ReservedConference reservedConference : reservedConferences) {
|
|
|
150
|
+ if (null != reservedConference.getUserId() && null != userIdMap) {
|
|
|
151
|
+ reservedConference.setUserName(userIdMap.get(reservedConference.getUserId()));
|
|
|
152
|
+ }
|
|
|
153
|
+ Date startTime = reservedConference.getScheduleStartTime();
|
|
|
154
|
+ if (null == startTime) {
|
|
|
155
|
+ continue;
|
|
|
156
|
+ }
|
|
|
157
|
+ // 5分钟之内
|
|
|
158
|
+ long beforeMinutes = startTime.getTime() - 1000 * 60 * 5;
|
|
|
159
|
+ if (System.currentTimeMillis() < beforeMinutes) {
|
|
|
160
|
+ reservedConference.setIsBeforeFiveMinutes(true);
|
|
|
161
|
+ } else {
|
|
|
162
|
+ reservedConference.setIsBeforeFiveMinutes(false);
|
|
|
163
|
+ }
|
|
|
164
|
+ }
|
|
|
165
|
+
|
|
|
166
|
+
|
|
|
167
|
+ return reservedConferences;
|
|
|
168
|
+ }
|
|
|
169
|
+ /**
|
|
|
170
|
+ * 生成房间号
|
|
|
171
|
+ */
|
|
|
172
|
+ @Transactional
|
|
|
173
|
+ @Override
|
|
|
174
|
+ public String createRoomId(Long caseId) {
|
|
|
175
|
+ long roomId = generateRoomId();
|
|
|
176
|
+ // 绑定案件与房间号
|
|
|
177
|
+ bindCaseId(caseId, String.valueOf(roomId));
|
|
|
178
|
+ return String.valueOf(roomId);
|
|
|
179
|
+ }
|
|
|
180
|
+
|
|
|
181
|
+ /**
|
|
|
182
|
+ * 获取房间号
|
|
|
183
|
+ *
|
|
|
184
|
+ * @return
|
|
|
185
|
+ */
|
|
|
186
|
+ public Long generateRoomId() {
|
|
|
187
|
+ // 查询最大房间号
|
|
|
188
|
+ Long maxRoomId = caseApplicationMapper.selectMaxRoomId();
|
|
|
189
|
+
|
|
|
190
|
+ if (null == maxRoomId || maxRoomId > 4294967294L/2) {
|
|
|
191
|
+ return 4294967294L/2+1;
|
|
|
192
|
+ } else {
|
|
|
193
|
+ return maxRoomId + 1;
|
|
|
194
|
+ }
|
|
|
195
|
+
|
|
|
196
|
+ }
|
|
|
197
|
+
|
|
|
198
|
+ @Override
|
|
|
199
|
+ public AjaxResult bindCaseId(Long caseId, String roomId) {
|
|
|
200
|
+ MsCaseApplication caseApplication = new MsCaseApplication();
|
|
|
201
|
+ caseApplication.setId(caseId);
|
|
|
202
|
+ caseApplication.setRoomId(roomId);
|
|
|
203
|
+ caseApplicationMapper.updateByPrimaryKeySelective(caseApplication);
|
|
|
204
|
+ return success();
|
|
|
205
|
+ }
|
|
|
206
|
+
|
|
|
207
|
+ /**
|
|
|
208
|
+ * 根据案件id查询会议视频
|
|
|
209
|
+ * @param caseId
|
|
|
210
|
+ * @return
|
|
|
211
|
+ */
|
|
|
212
|
+ @Override
|
|
|
213
|
+ public AjaxResult videoList(Long caseId) {
|
|
|
214
|
+ MsCaseApplicationVO caseApplication = new MsCaseApplicationVO();
|
|
|
215
|
+ caseApplication.setId(caseId);
|
|
|
216
|
+ caseApplication.setAnnexType(AnnexTypeEnum.MEETING_VIDEO.getCode());
|
|
|
217
|
+ List<MsCaseAttach> caseAttachList = caseAttachMapper.queryCaseAttachList(caseApplication);
|
|
|
218
|
+ if(CollectionUtil.isEmpty(caseAttachList)){
|
|
|
219
|
+ return success();
|
|
|
220
|
+ }
|
|
|
221
|
+ return success(caseAttachList);
|
|
|
222
|
+ }
|
|
|
223
|
+
|
|
|
224
|
+ /**
|
|
|
225
|
+ * 开启腾讯云录制
|
|
|
226
|
+ * @param roomId
|
|
|
227
|
+ * @return
|
|
|
228
|
+ */
|
|
|
229
|
+ @Override
|
|
|
230
|
+ public AjaxResult openCloudRecording(long caseId,long roomId) {
|
|
|
231
|
+ try {
|
|
|
232
|
+ String userId="recorder_"+roomId;
|
|
|
233
|
+
|
|
|
234
|
+ Credential cred = new Credential(secretId, secretKey);
|
|
|
235
|
+
|
|
|
236
|
+ // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
|
237
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
238
|
+ httpProfile.setEndpoint("trtc.tencentcloudapi.com");
|
|
|
239
|
+ // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
240
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
241
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
242
|
+ // 实例化要请求产品的client对象,clientProfile是可选的
|
|
|
243
|
+ TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
|
|
|
244
|
+
|
|
|
245
|
+ // 实例化一个请求对象,每个接口都会对应一个request对象
|
|
|
246
|
+ CreateCloudRecordingRequest req = new CreateCloudRecordingRequest();
|
|
|
247
|
+ req.setSdkAppId(sdkAppId); // SdkAppId – TRTC的[SdkAppId](https://cloud.tencent.com/document/product/647/46351#sdkappid),和录制的房间所对应的SdkAppId相同
|
|
|
248
|
+ req.setRoomId(String.valueOf(roomId)); // RoomId – TRTC的[RoomId](https://cloud.tencent.com/document/product/647/46351#roomid),录制的TRTC房间所对应的RoomId
|
|
|
249
|
+ req.setRoomIdType(1L);
|
|
|
250
|
+ /**
|
|
|
251
|
+ * 录制机器人用于进入TRTC房间拉流的[UserId](https://cloud.tencent.com/document/product/647/46351#userid),
|
|
|
252
|
+ * 注意这个UserId不能与其他TRTC房间内的主播或者其他录制任务等已经使用的UserId重复,建议可以把房间ID作为userId的标识的一部分,
|
|
|
253
|
+ * 即录制机器人进入房间的userid应保证独立且唯一
|
|
|
254
|
+ */
|
|
|
255
|
+ req.setUserId(userId);
|
|
|
256
|
+
|
|
|
257
|
+ TLSSigAPIv2 api = new TLSSigAPIv2(sdkAppId, sdkSecretKey);
|
|
|
258
|
+ String userSign = api.genUserSig(userId, 60 * 60 * 10);
|
|
|
259
|
+ req.setUserSig(userSign); // 录制机器人用于进入TRTC房间拉流的用户签名,当前 UserId 对应的验证签名,相当于登录密码
|
|
|
260
|
+ RecordParams recordParams = new RecordParams();
|
|
|
261
|
+ // 混流录制
|
|
|
262
|
+ recordParams.setMaxIdleTime(60L*5); // 5分钟内房间里面没有主播,自动停止录制
|
|
|
263
|
+ recordParams.setStreamType(0L); // 0:录制音频+视频流(默认); 1:仅录制音频流; 2:仅录制视频流
|
|
|
264
|
+ recordParams.setRecordMode(2L); // 1:单流录制,分别录制房间的订阅UserId的音频和视频,将录制文件上传至云存储; 2:混流录制,将房间内订阅UserId的音视频混录成一个音视频文件,将录制文件上传至云存储;
|
|
|
265
|
+ recordParams.setOutputFormat(0L); // 0:(默认)输出文件为hls格式。1:输出文件格式为hls+mp4。2:输出文件格式为hls+aac
|
|
|
266
|
+ MixLayoutParams mixLayoutParams = new MixLayoutParams();
|
|
|
267
|
+ // 布局模式: 1:悬浮布局;2:屏幕分享布局;3:九宫格布局(默认);4:自定义布局;
|
|
|
268
|
+ mixLayoutParams.setMixLayoutMode(3L);
|
|
|
269
|
+ req.setMixLayoutParams(mixLayoutParams);
|
|
|
270
|
+
|
|
|
271
|
+ StorageParams storageParams1 = new StorageParams();
|
|
|
272
|
+ CloudVod cloudVod = new CloudVod();
|
|
|
273
|
+ TencentVod tencentVod = new TencentVod();
|
|
|
274
|
+ tencentVod.setSubAppId(1304001529L);
|
|
|
275
|
+ // 录制的文件永久保存
|
|
|
276
|
+ tencentVod.setExpireTime(0L);
|
|
|
277
|
+ // 录制文件名拼接前缀
|
|
|
278
|
+ tencentVod.setUserDefineRecordId(caseId+"");
|
|
|
279
|
+ cloudVod.setTencentVod(tencentVod); // 腾讯云点播相关参数。
|
|
|
280
|
+ storageParams1.setCloudVod(cloudVod); // 必填】腾讯云云点播的账号信息,目前仅支持存储至腾讯云点播VOD。
|
|
|
281
|
+ req.setRecordParams(recordParams); // 云端录制控制参数
|
|
|
282
|
+ req.setStorageParams(storageParams1); // 云端录制文件上传到云存储的参数(目前只支持使用腾讯云点播作为存储)
|
|
|
283
|
+ // 返回的resp是一个CreateCloudRecordingResponse的实例,与请求对象对应
|
|
|
284
|
+ CreateCloudRecordingResponse resp = client.CreateCloudRecording(req);
|
|
|
285
|
+
|
|
|
286
|
+ return success((JSONObject) JSON.toJSON(resp));
|
|
|
287
|
+ } catch (TencentCloudSDKException e) {
|
|
|
288
|
+ return AjaxResult.error(e.toString());
|
|
|
289
|
+ }
|
|
|
290
|
+ }
|
|
|
291
|
+
|
|
|
292
|
+ @Override
|
|
|
293
|
+ public AjaxResult closeDeleteCloudRecording(String taskId) {
|
|
|
294
|
+
|
|
|
295
|
+ try {
|
|
|
296
|
+ if (taskId != null) {
|
|
|
297
|
+ taskId = taskId.replaceAll(" ", "+");
|
|
|
298
|
+ }
|
|
|
299
|
+ // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
|
|
300
|
+ // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
|
|
301
|
+ // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
|
|
302
|
+ Credential cred = new Credential(secretId, secretKey);
|
|
|
303
|
+ // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
|
304
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
305
|
+ httpProfile.setEndpoint("trtc.tencentcloudapi.com");
|
|
|
306
|
+ // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
307
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
308
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
309
|
+ // 实例化要请求产品的client对象,clientProfile是可选的
|
|
|
310
|
+ TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
|
|
|
311
|
+ // 实例化一个请求对象,每个接口都会对应一个request对象
|
|
|
312
|
+ DeleteCloudRecordingRequest req = new DeleteCloudRecordingRequest();
|
|
|
313
|
+ req.setSdkAppId(sdkAppId); // SdkAppId – TRTC的SDKAppId,和录制的房间所对应的SDKAppId相同
|
|
|
314
|
+ req.setTaskId(taskId); // TaskId – 录制任务的唯一Id,在启动录制成功后会返回
|
|
|
315
|
+ // 返回的resp是一个DeleteCloudRecordingResponse的实例,与请求对象对应
|
|
|
316
|
+ DeleteCloudRecordingResponse resp = client.DeleteCloudRecording(req);
|
|
|
317
|
+ // 输出json格式的字符串回包
|
|
|
318
|
+ return success((JSONObject) JSON.toJSON(resp));
|
|
|
319
|
+ } catch (TencentCloudSDKException e) {
|
|
|
320
|
+ return AjaxResult.error(e.toString());
|
|
|
321
|
+ }
|
|
|
322
|
+
|
|
|
323
|
+ }
|
|
|
324
|
+
|
|
|
325
|
+ /**
|
|
|
326
|
+ * 解散房间
|
|
|
327
|
+ * @param roomId
|
|
|
328
|
+ * @return
|
|
|
329
|
+ */
|
|
|
330
|
+ @Override
|
|
|
331
|
+ public AjaxResult dissolveRoom( Long roomId) {
|
|
|
332
|
+ Credential cred = new Credential(secretId, secretKey);
|
|
|
333
|
+ // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
|
334
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
335
|
+ httpProfile.setEndpoint("trtc.tencentcloudapi.com");
|
|
|
336
|
+ // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
337
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
338
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
339
|
+ // 实例化要请求产品的client对象,clientProfile是可选的
|
|
|
340
|
+ TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
|
|
|
341
|
+ DismissRoomRequest req = new DismissRoomRequest();
|
|
|
342
|
+ req.setSdkAppId(sdkAppId);
|
|
|
343
|
+ req.setRoomId(roomId);
|
|
|
344
|
+ try {
|
|
|
345
|
+ DismissRoomResponse resp = client.DismissRoom(req);
|
|
|
346
|
+ return success((JSONObject) JSON.toJSON(resp));
|
|
|
347
|
+ } catch (TencentCloudSDKException e) {
|
|
|
348
|
+ return AjaxResult.error("解散房间失败");
|
|
|
349
|
+ }
|
|
|
350
|
+
|
|
|
351
|
+ }
|
|
|
352
|
+ /**
|
|
|
353
|
+ * 根据userId查询该用户是否是秘书
|
|
|
354
|
+ * @param userId
|
|
|
355
|
+ * @return
|
|
|
356
|
+ */
|
|
|
357
|
+ @Override
|
|
|
358
|
+ public AjaxResult secretaryRoleByUserId(Long userId) {
|
|
|
359
|
+ List<SysRole> roles = roleMapper.selectRolePermissionByUserId(userId);
|
|
|
360
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
361
|
+ boolean isSecretaryRole=false;
|
|
|
362
|
+ if(CollectionUtil.isNotEmpty(roles)){
|
|
|
363
|
+ for (SysRole role : roles) {
|
|
|
364
|
+ if("法律顾问".equals(role.getRoleName()) || "秘书".equals(role.getRoleName())){
|
|
|
365
|
+ isSecretaryRole=true;
|
|
|
366
|
+ break;
|
|
|
367
|
+ }
|
|
|
368
|
+ }
|
|
|
369
|
+ }
|
|
|
370
|
+ jsonObject.put("isSecretaryRole",isSecretaryRole);
|
|
|
371
|
+ return success(jsonObject);
|
|
|
372
|
+ }
|
|
|
373
|
+
|
|
|
374
|
+ /**
|
|
|
375
|
+ * 根据html字符串转pdf并和案件关联
|
|
|
376
|
+ * @param reservedConferenceVO
|
|
|
377
|
+ * @return
|
|
|
378
|
+ */
|
|
|
379
|
+ @Override
|
|
|
380
|
+ public AjaxResult htmlToPDF(MsReservedConferenceVO reservedConferenceVO) {
|
|
|
381
|
+ String currentFileName = System.currentTimeMillis() + ".pdf";
|
|
|
382
|
+ String fileName = null;
|
|
|
383
|
+ try {
|
|
|
384
|
+ fileName = getPathFileName(RuoYiConfig.getHtml2PDFPath(), currentFileName);
|
|
|
385
|
+ } catch (IOException e) {
|
|
|
386
|
+ throw new RuntimeException(e);
|
|
|
387
|
+ }
|
|
|
388
|
+ String htmlContent = "<html><head> <title>庭审笔录</title></head><body style=\"font-size:12.0pt; font-family:SimSun;\"><h1 align=\"center\">庭审笔录</h1>" +reservedConferenceVO.getHtmlContent()+"</body></html>";
|
|
|
389
|
+ // html转pdf并上传到服务器
|
|
|
390
|
+ boolean convertFlag = PdfUtils.htmlStringConvertToPDF(RuoYiConfig.getHtml2PDFPath() +"/"+ currentFileName, htmlContent);
|
|
|
391
|
+
|
|
|
392
|
+ // 绑定案件
|
|
|
393
|
+ if(convertFlag){
|
|
|
394
|
+ MsCaseAttach caseAttach = MsCaseAttach.builder().caseAppliId(reservedConferenceVO.getCaseId())
|
|
|
395
|
+ .annexName(fileName)
|
|
|
396
|
+ .annexPath(RuoYiConfig.getHtml2PDFPath())
|
|
|
397
|
+ .annexType(7)
|
|
|
398
|
+ .build();
|
|
|
399
|
+ caseAttachMapper.save(caseAttach);
|
|
|
400
|
+ return AjaxResult.success();
|
|
|
401
|
+ }else {
|
|
|
402
|
+ return AjaxResult.error("pdf转换失败");
|
|
|
403
|
+ }
|
|
|
404
|
+ }
|
|
|
405
|
+
|
|
|
406
|
+
|
|
|
407
|
+
|
|
|
408
|
+ /**
|
|
|
409
|
+ * 将视频下载到本地
|
|
|
410
|
+ * @param fileUrl 视频路径
|
|
|
411
|
+ * @return
|
|
|
412
|
+ */
|
|
|
413
|
+ @Transactional
|
|
|
414
|
+ public String downloadImage(String fileId,String fileUrl,String roomId) throws IOException {
|
|
|
415
|
+ String staticAndMksDir = null;
|
|
|
416
|
+ if (fileUrl != null) {
|
|
|
417
|
+ //下载时文件名称
|
|
|
418
|
+ String fileName = fileUrl.substring(fileUrl.lastIndexOf("/"));
|
|
|
419
|
+ fileName = fileName.replace("/", "");
|
|
|
420
|
+ fileName=fileId+fileName;
|
|
|
421
|
+ String absPath = getAbsoluteFile(RuoYiConfig.getVideoUploadPath(), fileName).getAbsolutePath();
|
|
|
422
|
+ staticAndMksDir = Paths.get(absPath).toFile().toString();
|
|
|
423
|
+ long downloadFile = HttpUtil.downloadFile(fileUrl, staticAndMksDir);
|
|
|
424
|
+ if(downloadFile>0) {
|
|
|
425
|
+ Example example = new Example(MsCaseFlowRoleRelated.class);
|
|
|
426
|
+ example.createCriteria().andEqualTo("romId", roomId);
|
|
|
427
|
+ MsCaseApplication caseApplication = caseApplicationMapper.selectOneByExample(example);
|
|
|
428
|
+ if(caseApplication != null) {
|
|
|
429
|
+ String annexName = getPathFileName(RuoYiConfig.getVideoUploadPath(), fileName);
|
|
|
430
|
+ // 存入数据库
|
|
|
431
|
+ MsCaseAttach caseAttach = MsCaseAttach.builder().caseAppliId(caseApplication.getId())
|
|
|
432
|
+ .annexName(fileName)
|
|
|
433
|
+ .annexPath(annexName)
|
|
|
434
|
+ .annexType(AnnexTypeEnum.MEETING_VIDEO.getCode())
|
|
|
435
|
+ .build();
|
|
|
436
|
+ caseAttachMapper.save(caseAttach);
|
|
|
437
|
+ return annexName;
|
|
|
438
|
+ }
|
|
|
439
|
+ }
|
|
|
440
|
+ }
|
|
|
441
|
+ return "";
|
|
|
442
|
+
|
|
|
443
|
+ }
|
|
|
444
|
+ /**
|
|
|
445
|
+ * @param key 回调秘钥
|
|
|
446
|
+ * @param body 入参
|
|
|
447
|
+ * @return 签名 Sign 计算公式中 key 为计算签名 Sign 用的加密密钥。
|
|
|
448
|
+ * @throws Exception
|
|
|
449
|
+ */
|
|
|
450
|
+ private static String getResultSign(String key, String body) throws Exception {
|
|
|
451
|
+ Mac hmacSha256 = Mac.getInstance("HmacSHA256");
|
|
|
452
|
+ SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(), "HmacSHA256");
|
|
|
453
|
+ hmacSha256.init(secret_key);
|
|
|
454
|
+ return Base64.getEncoder().encodeToString(hmacSha256.doFinal(body.getBytes()));
|
|
|
455
|
+ }
|
|
|
456
|
+
|
|
|
457
|
+}
|