销毁房间等接口

This commit is contained in:
18792927508
2023-11-09 17:24:07 +08:00
parent 1f41b4903b
commit 1242497d6f
9 changed files with 226 additions and 32 deletions
@@ -3,18 +3,14 @@ package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.annotation.Anonymous;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@@ -248,4 +244,14 @@ public class SysUserController extends BaseController
{ {
return success(deptService.selectDeptTreeList(dept)); return success(deptService.selectDeptTreeList(dept));
} }
/**
* 根据userId获取用户信息
* @param userId
* @return
*/
@Anonymous
@GetMapping("/generateUserSign")
public AjaxResult generateUserSign(@RequestParam(required = true) Long userId){
return AjaxResult.success(userService.selectUserById(userId));
}
} }
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@@ -375,4 +376,16 @@ public class CaseApplicationController extends BaseController {
return caseApplicationService.reservedConference(reservedConferenceVO); return caseApplicationService.reservedConference(reservedConferenceVO);
} }
/**
* 腾讯云销毁房间回调
* @param body
* @param request
* @return
*/
@Anonymous
@PostMapping("/destroyRoomBack")
public AjaxResult destroyRoomBack( @RequestBody String body, HttpServletRequest request) {
caseApplicationService.destroyRoomBack(body,request);
return success();
}
} }
@@ -135,8 +135,17 @@ public class CaseAffiliate extends BaseEntity {
/** 送达电子邮件 */ /** 送达电子邮件 */
private String sendEmail; private String sendEmail;
private String userId;
private String applicantAgentUserId; private String applicantAgentUserId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getApplicantAgentUserId() { public String getApplicantAgentUserId() {
return applicantAgentUserId; return applicantAgentUserId;
} }
@@ -0,0 +1,40 @@
package com.ruoyi.wisdomarbitrate.domain;
import lombok.Data;
/**
* @author wangqiong
* @description 预定会议
* @Version 1.0
* @date 2023-11-09 16:51
*/
@Data
public class ReservedConference {
/**
* id
*/
private String id;
/**
* 案件id
*/
private Long caseId;
/**
* 房间号
*/
private String roomId;
/**
* 预定会议开始时间
*/
private String scheduleStartTime;
/**
* 预定会议结束时间
*/
private String scheduleEndTime;
public ReservedConference( Long caseId, String roomId, String scheduleStartTime, String scheduleEndTime) {
this.caseId = caseId;
this.roomId = roomId;
this.scheduleStartTime = scheduleStartTime;
this.scheduleEndTime = scheduleEndTime;
}
}
@@ -0,0 +1,37 @@
package com.ruoyi.wisdomarbitrate.mapper;
import com.ruoyi.wisdomarbitrate.domain.ReservedConference;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author wangqiong
* @description 预约会议Mapper接口
* @Version 1.0
* @date 2023-11-09 16:51
*/
@Repository
public interface ReservedConferenceMapper {
/**
* 根据案件id查询预约会议列表
* @param caseId
* @return
*/
List<ReservedConference> selectListByCaseId(@Param("caseId")Long caseId);
/**
* 新增
* @param reservedConference
*/
void insert(ReservedConference reservedConference);
/**
* 根据房间号删除
* @param roomId
*/
void deleteByRoomId(@Param("roomId")String roomId);
}
@@ -8,6 +8,7 @@ import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount; import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
public interface ICaseApplicationService { public interface ICaseApplicationService {
@@ -94,4 +95,12 @@ public interface ICaseApplicationService {
* @throws Exception * @throws Exception
*/ */
AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception; AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception;
/**
* 腾讯云销毁房间回调
* @param body
* @param request
* @return
*/
void destroyRoomBack(String body, HttpServletRequest request);
} }
@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson; import com.google.gson.Gson;
@@ -45,6 +46,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.*; import java.io.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@@ -55,7 +58,6 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -102,6 +104,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
private SmsRecordMapper smsRecordMapper; private SmsRecordMapper smsRecordMapper;
@Autowired @Autowired
private DeptIdentifyMapper deptIdentifyMapper; private DeptIdentifyMapper deptIdentifyMapper;
@Autowired
private ReservedConferenceMapper reservedConferenceMapper;
// 手机号正则 // 手机号正则
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}$"); 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}$");
@@ -1872,13 +1876,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseApplication.setId(messageVO.getId()); caseApplication.setId(messageVO.getId());
CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication); CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
String returnResult = "短信发送成功"; String returnResult = "短信发送成功";
//发送短信通知 //todo 需要申请模板,申请人,被申请人发送短信通知
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
request.setTemplateId("1952136"); request.setTemplateId("1952136");
for (CaseAffiliate caseAffiliate : caseAffiliates) { for (CaseAffiliate caseAffiliate : caseAffiliates) {
request.setPhone(caseAffiliate.getContactTelphone()); request.setPhone(caseAffiliate.getContactTelphone());
request.setTemplateParamSet(new String[]{caseAffiliate.getName(), caseApplicationselect.getCaseNum(), messageVO.getRoomNo()}); request.setTemplateParamSet(new String[]{caseAffiliate.getName(), caseApplicationselect.getCaseNum(), messageVO.getRoomNo()+caseAffiliate.getUserId()});
// 1948332 普通短信 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请在微信内打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。 // 1952136 普通短信 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请在浏览器打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。
Boolean aBoolean = SmsUtils.sendSms(request); Boolean aBoolean = SmsUtils.sendSms(request);
//保存短信发送记录 //保存短信发送记录
SmsSendRecord smsSendRecord = new SmsSendRecord(); SmsSendRecord smsSendRecord = new SmsSendRecord();
@@ -1886,7 +1890,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
smsSendRecord.setCaseNum(caseApplicationselect.getCaseNum()); smsSendRecord.setCaseNum(caseApplicationselect.getCaseNum());
smsSendRecord.setPhone(request.getPhone()); smsSendRecord.setPhone(request.getPhone());
smsSendRecord.setSendTime(new Date()); smsSendRecord.setSendTime(new Date());
String content = "尊敬的" + caseAffiliate.getName() + "用户,您的" + caseApplicationselect.getCaseNum() + "仲裁案件,开庭审理房间号为" + messageVO.getRoomNo() + ",请在微信内打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。"; String content = "尊敬的" + caseAffiliate.getName() + "用户,您的" + caseApplicationselect.getCaseNum() + "仲裁案件,开庭审理房间号为" + messageVO.getRoomNo()+caseAffiliate.getUserId() + ",请在微信内打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。";
smsSendRecord.setSendContent(content); smsSendRecord.setSendContent(content);
String userName; String userName;
@@ -1905,7 +1909,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
} }
return returnResult; return returnResult;
} }
@Override @Override
public SealSignRecord selectSignUrl(CaseApplication caseApplication) throws EsignDemoException { public SealSignRecord selectSignUrl(CaseApplication caseApplication) throws EsignDemoException {
SealSignRecord sealSignRecord = new SealSignRecord(); SealSignRecord sealSignRecord = new SealSignRecord();
@@ -2467,24 +2470,28 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
@Transactional @Transactional
@Override @Override
public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception { public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception {
// 生成administrator的userSig // 创建房间必须拿administrator生成usersig,否则调用腾讯云接口报7004,生成administrator的userSig
String administrator = "administrator"; String administrator = "administrator";
String userSign = generateUserSign(administrator); String userSign = generateUserSign(administrator);
if (StrUtil.isEmpty(userSign)) { if (StrUtil.isEmpty(userSign)) {
return AjaxResult.error("生成userSign失败"); return AjaxResult.error("生成userSign失败");
} }
int random = ThreadLocalRandom.current().nextInt(0, 214748364); Integer scheduleStartTime = reservedConferenceVO.getScheduleStartTime();
Integer scheduleEndTime = reservedConferenceVO.getScheduleEndTime();
Random rand = new Random();
int random = rand.nextInt(214748365);
String url="https://roomkit.trtc.tencent-cloud.com/room_api/v1/roomctl/create?usersig=" + userSign + "&identifier=" + administrator + "&sdkappid=" + sdkAppId + "&random=" +random + "&contenttype=json"; String url="https://roomkit.trtc.tencent-cloud.com/room_api/v1/roomctl/create?usersig=" + userSign + "&identifier=" + administrator + "&sdkappid=" + sdkAppId + "&random=" +random + "&contenttype=json";
HttpPost post = new HttpPost(url); HttpPost post = new HttpPost(url);
String result = ""; String result = "";
//添加参数 //添加参数
JSONObject bodyParams = new JSONObject(); JSONObject bodyParams = new JSONObject();
JSONObject roomParams = new JSONObject();
bodyParams.put("ownerId", reservedConferenceVO.getOwnerId()); bodyParams.put("ownerId", reservedConferenceVO.getOwnerId());
bodyParams.put("roomId", reservedConferenceVO.getRoomId()); bodyParams.put("roomId", reservedConferenceVO.getRoomId());
bodyParams.put("scheduleStartTime", reservedConferenceVO.getScheduleStartTime()); bodyParams.put("scheduleStartTime", scheduleStartTime);
bodyParams.put("scheduleEndTime", reservedConferenceVO.getScheduleEndTime()); bodyParams.put("scheduleEndTime",scheduleEndTime);
roomParams.put("roomType", 1);
bodyParams.put("roomInfo", roomParams);
StringEntity postingString = new StringEntity(bodyParams.toString()); StringEntity postingString = new StringEntity(bodyParams.toString());
post.setEntity(postingString); post.setEntity(postingString);
CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpClient client = HttpClients.createDefault();
@@ -2496,24 +2503,60 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
result = EntityUtils.toString(entity, "UTF-8"); result = EntityUtils.toString(entity, "UTF-8");
if (StrUtil.isNotEmpty(result)) { if (StrUtil.isNotEmpty(result)) {
JSONObject resJson = JSONObject.parseObject(result); JSONObject resJson = JSONObject.parseObject(result);
if ((int) resJson.get("errorCode") == 0 ) { switch ((int) resJson.get("errorCode")) {
// 绑定房间号和案件id case 0:
caseApplicationMapper.bindCaseId(reservedConferenceVO.getCaseId(),reservedConferenceVO.getRoomId()); // todo 不需要绑定,以后删 绑定房间号和案件id
return AjaxResult.success("预约会议成功"); caseApplicationMapper.bindCaseId(reservedConferenceVO.getCaseId(), reservedConferenceVO.getRoomId());
} else if((int) resJson.get("errorCode") == 42003){ String format = "yyyy-MM-dd HH:mm:ss"; // 目标格式
return AjaxResult.error("请求频繁"); Date startDate = new Date(scheduleStartTime);
}else if((int) resJson.get("errorCode") == 84005){ Date endDate = new Date(scheduleEndTime);
return AjaxResult.error("房间号已被占用"); SimpleDateFormat sdf = new SimpleDateFormat(format);
}else { String startFormat = sdf.format(startDate);
return AjaxResult.error("预约会议失败"); String endFormat = sdf.format(endDate);
// 新增预约会议表
ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(), reservedConferenceVO.getRoomId(),
startFormat, endFormat);
reservedConferenceMapper.insert(conference);
return AjaxResult.success("预约会议成功");
case 42002:
return AjaxResult.error("预定会议无效");
case 42003:
return AjaxResult.error("预定会议必须是会议场景");
case 84005:
return AjaxResult.error("房间号已被占用");
default:
return AjaxResult.error("预约会议失败");
} }
}else { } else {
return AjaxResult.error("预约会议失败"); return AjaxResult.error("预约会议失败");
} }
} }
/**
* 销毁房间回调
* @param body
* @param request
*/
@Override
public void destroyRoomBack(String body, HttpServletRequest request) {
JSONObject jsonObject = (JSONObject) JSON.parse(body);
// 事件类型
Integer eventType = jsonObject.getInteger("EventType");
// 事件信息
String eventInfo = jsonObject.getString("EventInfo");
JSONObject eventInfoJson = (JSONObject) JSON.parse(eventInfo);
// 104 退出房间事件
if (eventType == 104) {
// 删除预定会议表
reservedConferenceMapper.deleteByRoomId(eventInfoJson.getString("RoomId"));
}
}
} }
@@ -29,6 +29,7 @@
<result property="residenAffili" column="residen_affili" /> <result property="residenAffili" column="residen_affili" />
<result property="appliAgentTitle" column="appli_agent_title" /> <result property="appliAgentTitle" column="appli_agent_title" />
<result property="userId" column="user_id" />
</resultMap> </resultMap>
@@ -37,8 +38,9 @@
c.work_address ,c.work_telphone ,c.name_agent, c.identity_num_agent ,c.contact_telphone_agent ,c.contact_address_agent, c.work_address ,c.work_telphone ,c.name_agent, c.identity_num_agent ,c.contact_telphone_agent ,c.contact_address_agent,
c.comp_legal_person,c.comp_legalper_post,c.respon_sex,c.respon_birth, c.comp_legal_person,c.comp_legalper_post,c.respon_sex,c.respon_birth,
c.residen_affili,c.appli_agent_title, c.residen_affili,c.appli_agent_title,
c.track_num,c.application_organ_id,c.application_organ_name c.track_num,c.application_organ_id,c.application_organ_name,s.user_id
from case_affiliate c from case_affiliate c
left join sys_user s on c.identity_num=s.id_card
<where> <where>
<if test="caseAppliId != null "> <if test="caseAppliId != null ">
AND c.case_appli_id = #{caseAppliId} AND c.case_appli_id = #{caseAppliId}
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.ReservedConferenceMapper">
<resultMap type="com.ruoyi.wisdomarbitrate.domain.ReservedConference" id="BaseResult">
<id property="id" column="id" />
<result property="caseId" column="case_id" />
<result property="roomId" column="room_id" />
<result property="scheduleStartTime" column="schedule_start_time" />
<result property="scheduleEndTime" column="schedule_end_time" />
</resultMap>
<insert id="insert">
insert into reserved_conference(
case_id,
room_id,
schedule_start_time,
schedule_end_time
)values(
#{caseId},
#{roomId},
#{scheduleStartTime},
#{scheduleEndTime}
)
</insert>
<delete id="deleteByRoomId">
delete from reserved_conference where room_id=#{roomId}
</delete>
<select id="selectListByCaseId" resultMap="BaseResult">
select * from reserved_conference where case_id=#{caseId}
</select>
</mapper>