|
|
@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service.impl;
|
|
3
|
3
|
|
|
4
|
4
|
import cn.hutool.core.collection.CollectionUtil;
|
|
5
|
5
|
import cn.hutool.core.util.StrUtil;
|
|
|
6
|
+import com.alibaba.fastjson.JSON;
|
|
6
|
7
|
import com.alibaba.fastjson.JSONArray;
|
|
7
|
8
|
import com.alibaba.fastjson.JSONObject;
|
|
8
|
9
|
import com.google.gson.Gson;
|
|
|
@@ -45,6 +46,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|
45
|
46
|
import org.springframework.stereotype.Service;
|
|
46
|
47
|
import org.springframework.transaction.annotation.Transactional;
|
|
47
|
48
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
49
|
+
|
|
|
50
|
+import javax.servlet.http.HttpServletRequest;
|
|
48
|
51
|
import java.io.*;
|
|
49
|
52
|
import java.math.BigDecimal;
|
|
50
|
53
|
import java.math.RoundingMode;
|
|
|
@@ -55,7 +58,6 @@ import java.text.SimpleDateFormat;
|
|
55
|
58
|
import java.time.LocalDate;
|
|
56
|
59
|
import java.time.ZoneId;
|
|
57
|
60
|
import java.util.*;
|
|
58
|
|
-import java.util.concurrent.ThreadLocalRandom;
|
|
59
|
61
|
import java.util.regex.Pattern;
|
|
60
|
62
|
import java.util.stream.Collectors;
|
|
61
|
63
|
|
|
|
@@ -102,6 +104,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
102
|
104
|
private SmsRecordMapper smsRecordMapper;
|
|
103
|
105
|
@Autowired
|
|
104
|
106
|
private DeptIdentifyMapper deptIdentifyMapper;
|
|
|
107
|
+ @Autowired
|
|
|
108
|
+ private ReservedConferenceMapper reservedConferenceMapper;
|
|
105
|
109
|
// 手机号正则
|
|
106
|
110
|
private static final Pattern TELEPHONE_REGX = Pattern.compile("^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$");
|
|
107
|
111
|
|
|
|
@@ -1872,13 +1876,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1872
|
1876
|
caseApplication.setId(messageVO.getId());
|
|
1873
|
1877
|
CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
1874
|
1878
|
String returnResult = "短信发送成功";
|
|
1875
|
|
- //发送短信通知
|
|
|
1879
|
+ //todo 需要申请模板,申请人,被申请人发送短信通知
|
|
1876
|
1880
|
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
|
|
1877
|
1881
|
request.setTemplateId("1952136");
|
|
1878
|
1882
|
for (CaseAffiliate caseAffiliate : caseAffiliates) {
|
|
1879
|
1883
|
request.setPhone(caseAffiliate.getContactTelphone());
|
|
1880
|
|
- request.setTemplateParamSet(new String[]{caseAffiliate.getName(), caseApplicationselect.getCaseNum(), messageVO.getRoomNo()});
|
|
1881
|
|
- // 1948332 普通短信 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请在微信内打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。
|
|
|
1884
|
+ request.setTemplateParamSet(new String[]{caseAffiliate.getName(), caseApplicationselect.getCaseNum(), messageVO.getRoomNo()+caseAffiliate.getUserId()});
|
|
|
1885
|
+ // 1952136 普通短信 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请在浏览器打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。
|
|
1882
|
1886
|
Boolean aBoolean = SmsUtils.sendSms(request);
|
|
1883
|
1887
|
//保存短信发送记录
|
|
1884
|
1888
|
SmsSendRecord smsSendRecord = new SmsSendRecord();
|
|
|
@@ -1886,7 +1890,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1886
|
1890
|
smsSendRecord.setCaseNum(caseApplicationselect.getCaseNum());
|
|
1887
|
1891
|
smsSendRecord.setPhone(request.getPhone());
|
|
1888
|
1892
|
smsSendRecord.setSendTime(new Date());
|
|
1889
|
|
- String content = "尊敬的" + caseAffiliate.getName() + "用户,您的" + caseApplicationselect.getCaseNum() + "仲裁案件,开庭审理房间号为" + messageVO.getRoomNo() + ",请在微信内打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。";
|
|
|
1893
|
+ String content = "尊敬的" + caseAffiliate.getName() + "用户,您的" + caseApplicationselect.getCaseNum() + "仲裁案件,开庭审理房间号为" + messageVO.getRoomNo()+caseAffiliate.getUserId() + ",请在微信内打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。";
|
|
1890
|
1894
|
smsSendRecord.setSendContent(content);
|
|
1891
|
1895
|
|
|
1892
|
1896
|
String userName;
|
|
|
@@ -1905,7 +1909,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1905
|
1909
|
}
|
|
1906
|
1910
|
return returnResult;
|
|
1907
|
1911
|
}
|
|
1908
|
|
-
|
|
1909
|
1912
|
@Override
|
|
1910
|
1913
|
public SealSignRecord selectSignUrl(CaseApplication caseApplication) throws EsignDemoException {
|
|
1911
|
1914
|
SealSignRecord sealSignRecord = new SealSignRecord();
|
|
|
@@ -2467,24 +2470,28 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2467
|
2470
|
@Transactional
|
|
2468
|
2471
|
@Override
|
|
2469
|
2472
|
public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception {
|
|
2470
|
|
- // 生成administrator的userSig
|
|
|
2473
|
+ // 创建房间必须拿administrator生成usersig,否则调用腾讯云接口报7004,生成administrator的userSig
|
|
2471
|
2474
|
String administrator = "administrator";
|
|
2472
|
2475
|
String userSign = generateUserSign(administrator);
|
|
2473
|
2476
|
if (StrUtil.isEmpty(userSign)) {
|
|
2474
|
2477
|
return AjaxResult.error("生成userSign失败");
|
|
2475
|
2478
|
}
|
|
2476
|
|
- int random = ThreadLocalRandom.current().nextInt(0, 214748364);
|
|
|
2479
|
+ Integer scheduleStartTime = reservedConferenceVO.getScheduleStartTime();
|
|
|
2480
|
+ Integer scheduleEndTime = reservedConferenceVO.getScheduleEndTime();
|
|
|
2481
|
+ Random rand = new Random();
|
|
|
2482
|
+ int random = rand.nextInt(214748365);
|
|
2477
|
2483
|
String url="https://roomkit.trtc.tencent-cloud.com/room_api/v1/roomctl/create?usersig=" + userSign + "&identifier=" + administrator + "&sdkappid=" + sdkAppId + "&random=" +random + "&contenttype=json";
|
|
2478
|
2484
|
HttpPost post = new HttpPost(url);
|
|
2479
|
2485
|
String result = "";
|
|
2480
|
|
-
|
|
2481
|
|
-
|
|
2482
|
2486
|
//添加参数
|
|
2483
|
2487
|
JSONObject bodyParams = new JSONObject();
|
|
|
2488
|
+ JSONObject roomParams = new JSONObject();
|
|
2484
|
2489
|
bodyParams.put("ownerId", reservedConferenceVO.getOwnerId());
|
|
2485
|
2490
|
bodyParams.put("roomId", reservedConferenceVO.getRoomId());
|
|
2486
|
|
- bodyParams.put("scheduleStartTime", reservedConferenceVO.getScheduleStartTime());
|
|
2487
|
|
- bodyParams.put("scheduleEndTime", reservedConferenceVO.getScheduleEndTime());
|
|
|
2491
|
+ bodyParams.put("scheduleStartTime", scheduleStartTime);
|
|
|
2492
|
+ bodyParams.put("scheduleEndTime",scheduleEndTime);
|
|
|
2493
|
+ roomParams.put("roomType", 1);
|
|
|
2494
|
+ bodyParams.put("roomInfo", roomParams);
|
|
2488
|
2495
|
StringEntity postingString = new StringEntity(bodyParams.toString());
|
|
2489
|
2496
|
post.setEntity(postingString);
|
|
2490
|
2497
|
CloseableHttpClient client = HttpClients.createDefault();
|
|
|
@@ -2496,24 +2503,60 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2496
|
2503
|
result = EntityUtils.toString(entity, "UTF-8");
|
|
2497
|
2504
|
if (StrUtil.isNotEmpty(result)) {
|
|
2498
|
2505
|
JSONObject resJson = JSONObject.parseObject(result);
|
|
2499
|
|
- if ((int) resJson.get("errorCode") == 0 ) {
|
|
2500
|
|
- // 绑定房间号和案件id
|
|
2501
|
|
- caseApplicationMapper.bindCaseId(reservedConferenceVO.getCaseId(),reservedConferenceVO.getRoomId());
|
|
2502
|
|
- return AjaxResult.success("预约会议成功");
|
|
2503
|
|
- } else if((int) resJson.get("errorCode") == 42003){
|
|
2504
|
|
- return AjaxResult.error("请求频繁");
|
|
2505
|
|
- }else if((int) resJson.get("errorCode") == 84005){
|
|
2506
|
|
- return AjaxResult.error("房间号已被占用");
|
|
2507
|
|
- }else {
|
|
2508
|
|
- return AjaxResult.error("预约会议失败");
|
|
|
2506
|
+ switch ((int) resJson.get("errorCode")) {
|
|
|
2507
|
+ case 0:
|
|
|
2508
|
+ // todo 不需要绑定,以后删 绑定房间号和案件id
|
|
|
2509
|
+ caseApplicationMapper.bindCaseId(reservedConferenceVO.getCaseId(), reservedConferenceVO.getRoomId());
|
|
|
2510
|
+ String format = "yyyy-MM-dd HH:mm:ss"; // 目标格式
|
|
|
2511
|
+ Date startDate = new Date(scheduleStartTime);
|
|
|
2512
|
+ Date endDate = new Date(scheduleEndTime);
|
|
|
2513
|
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
|
|
|
2514
|
+ String startFormat = sdf.format(startDate);
|
|
|
2515
|
+ String endFormat = sdf.format(endDate);
|
|
|
2516
|
+ // 新增预约会议表
|
|
|
2517
|
+ ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(), reservedConferenceVO.getRoomId(),
|
|
|
2518
|
+ startFormat, endFormat);
|
|
|
2519
|
+ reservedConferenceMapper.insert(conference);
|
|
|
2520
|
+ return AjaxResult.success("预约会议成功");
|
|
|
2521
|
+
|
|
|
2522
|
+ case 42002:
|
|
|
2523
|
+ return AjaxResult.error("预定会议无效");
|
|
|
2524
|
+ case 42003:
|
|
|
2525
|
+ return AjaxResult.error("预定会议必须是会议场景");
|
|
|
2526
|
+ case 84005:
|
|
|
2527
|
+ return AjaxResult.error("房间号已被占用");
|
|
|
2528
|
+ default:
|
|
|
2529
|
+ return AjaxResult.error("预约会议失败");
|
|
2509
|
2530
|
}
|
|
2510
|
2531
|
|
|
2511
|
|
- }else {
|
|
|
2532
|
+ } else {
|
|
2512
|
2533
|
return AjaxResult.error("预约会议失败");
|
|
2513
|
2534
|
}
|
|
2514
|
2535
|
}
|
|
2515
|
2536
|
|
|
|
2537
|
+ /**
|
|
|
2538
|
+ * 销毁房间回调
|
|
|
2539
|
+ * @param body
|
|
|
2540
|
+ * @param request
|
|
|
2541
|
+ */
|
|
|
2542
|
+ @Override
|
|
|
2543
|
+ public void destroyRoomBack(String body, HttpServletRequest request) {
|
|
|
2544
|
+ JSONObject jsonObject = (JSONObject) JSON.parse(body);
|
|
|
2545
|
+ // 事件类型
|
|
|
2546
|
+ Integer eventType = jsonObject.getInteger("EventType");
|
|
|
2547
|
+ // 事件信息
|
|
|
2548
|
+ String eventInfo = jsonObject.getString("EventInfo");
|
|
|
2549
|
+ JSONObject eventInfoJson = (JSONObject) JSON.parse(eventInfo);
|
|
|
2550
|
+ // 104 退出房间事件
|
|
|
2551
|
+ if (eventType == 104) {
|
|
|
2552
|
+ // 删除预定会议表
|
|
|
2553
|
+ reservedConferenceMapper.deleteByRoomId(eventInfoJson.getString("RoomId"));
|
|
|
2554
|
+ }
|
|
|
2555
|
+
|
|
|
2556
|
+ }
|
|
|
2557
|
+
|
|
2516
|
2558
|
|
|
2517
|
2559
|
}
|
|
2518
|
2560
|
|
|
2519
|
2561
|
|
|
|
2562
|
+
|