From 1242497d6f9264f3ab60f889e0ab8e34d561a391 Mon Sep 17 00:00:00 2001 From: 18792927508 <1322446236@qq.com> Date: Thu, 9 Nov 2023 17:24:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E6=AF=81=E6=88=BF=E9=97=B4=E7=AD=89?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/SysUserController.java | 22 +++-- .../CaseApplicationController.java | 13 +++ .../wisdomarbitrate/domain/CaseAffiliate.java | 9 ++ .../domain/ReservedConference.java | 40 +++++++++ .../mapper/ReservedConferenceMapper.java | 37 ++++++++ .../service/ICaseApplicationService.java | 9 ++ .../impl/CaseApplicationServiceImpl.java | 89 ++++++++++++++----- .../wisdomarbitrate/CaseAffiliateMapper.xml | 4 +- .../ReservedConferenceMapper.xml | 35 ++++++++ 9 files changed, 226 insertions(+), 32 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ReservedConference.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ReservedConferenceMapper.java create mode 100644 ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ReservedConferenceMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 0252bf8..269418e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -3,18 +3,14 @@ package com.ruoyi.web.controller.system; import java.util.List; import java.util.stream.Collectors; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -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.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; @@ -248,4 +244,14 @@ public class SysUserController extends BaseController { 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)); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java index c7b1c3b..73d4fac 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import com.ruoyi.common.utils.poi.ExcelUtil; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -375,4 +376,16 @@ public class CaseApplicationController extends BaseController { 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(); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java index abd91aa..d0a5104 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java @@ -135,8 +135,17 @@ public class CaseAffiliate extends BaseEntity { /** 送达电子邮件 */ private String sendEmail; + private String userId; private String applicantAgentUserId; + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + public String getApplicantAgentUserId() { return applicantAgentUserId; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ReservedConference.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ReservedConference.java new file mode 100644 index 0000000..d25769b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ReservedConference.java @@ -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; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ReservedConferenceMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ReservedConferenceMapper.java new file mode 100644 index 0000000..b8a8cfe --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ReservedConferenceMapper.java @@ -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 selectListByCaseId(@Param("caseId")Long caseId); + + /** + * 新增 + * @param reservedConference + */ + void insert(ReservedConference reservedConference); + + /** + * 根据房间号删除 + * @param roomId + */ + void deleteByRoomId(@Param("roomId")String roomId); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java index e925c11..ea63cf2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java @@ -8,6 +8,7 @@ import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO; import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import java.util.List; public interface ICaseApplicationService { @@ -94,4 +95,12 @@ public interface ICaseApplicationService { * @throws Exception */ AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception; + + /** + * 腾讯云销毁房间回调 + * @param body + * @param request + * @return + */ + void destroyRoomBack(String body, HttpServletRequest request); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java index e7056eb..9da0bb7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java @@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; @@ -45,6 +46,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; @@ -55,7 +58,6 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.ZoneId; import java.util.*; -import java.util.concurrent.ThreadLocalRandom; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -102,6 +104,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { private SmsRecordMapper smsRecordMapper; @Autowired 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}$"); @@ -1872,13 +1876,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { caseApplication.setId(messageVO.getId()); CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication); String returnResult = "短信发送成功"; - //发送短信通知 + //todo 需要申请模板,申请人,被申请人发送短信通知 SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); request.setTemplateId("1952136"); for (CaseAffiliate caseAffiliate : caseAffiliates) { request.setPhone(caseAffiliate.getContactTelphone()); - request.setTemplateParamSet(new String[]{caseAffiliate.getName(), caseApplicationselect.getCaseNum(), messageVO.getRoomNo()}); - // 1948332 普通短信 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请在微信内打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。 + request.setTemplateParamSet(new String[]{caseAffiliate.getName(), caseApplicationselect.getCaseNum(), messageVO.getRoomNo()+caseAffiliate.getUserId()}); + // 1952136 普通短信 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请在浏览器打开https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 请知晓,如非本人操作,请忽略本短信。 Boolean aBoolean = SmsUtils.sendSms(request); //保存短信发送记录 SmsSendRecord smsSendRecord = new SmsSendRecord(); @@ -1886,7 +1890,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { smsSendRecord.setCaseNum(caseApplicationselect.getCaseNum()); smsSendRecord.setPhone(request.getPhone()); 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); String userName; @@ -1905,7 +1909,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { } return returnResult; } - @Override public SealSignRecord selectSignUrl(CaseApplication caseApplication) throws EsignDemoException { SealSignRecord sealSignRecord = new SealSignRecord(); @@ -2467,24 +2470,28 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { @Transactional @Override public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception { - // 生成administrator的userSig + // 创建房间必须拿administrator生成usersig,否则调用腾讯云接口报7004,生成administrator的userSig String administrator = "administrator"; String userSign = generateUserSign(administrator); if (StrUtil.isEmpty(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"; HttpPost post = new HttpPost(url); String result = ""; - - //添加参数 JSONObject bodyParams = new JSONObject(); + JSONObject roomParams = new JSONObject(); bodyParams.put("ownerId", reservedConferenceVO.getOwnerId()); bodyParams.put("roomId", reservedConferenceVO.getRoomId()); - bodyParams.put("scheduleStartTime", reservedConferenceVO.getScheduleStartTime()); - bodyParams.put("scheduleEndTime", reservedConferenceVO.getScheduleEndTime()); + bodyParams.put("scheduleStartTime", scheduleStartTime); + bodyParams.put("scheduleEndTime",scheduleEndTime); + roomParams.put("roomType", 1); + bodyParams.put("roomInfo", roomParams); StringEntity postingString = new StringEntity(bodyParams.toString()); post.setEntity(postingString); CloseableHttpClient client = HttpClients.createDefault(); @@ -2496,24 +2503,60 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { result = EntityUtils.toString(entity, "UTF-8"); if (StrUtil.isNotEmpty(result)) { JSONObject resJson = JSONObject.parseObject(result); - if ((int) resJson.get("errorCode") == 0 ) { - // 绑定房间号和案件id - caseApplicationMapper.bindCaseId(reservedConferenceVO.getCaseId(),reservedConferenceVO.getRoomId()); - return AjaxResult.success("预约会议成功"); - } else if((int) resJson.get("errorCode") == 42003){ - return AjaxResult.error("请求频繁"); - }else if((int) resJson.get("errorCode") == 84005){ - return AjaxResult.error("房间号已被占用"); - }else { - return AjaxResult.error("预约会议失败"); + switch ((int) resJson.get("errorCode")) { + case 0: + // todo 不需要绑定,以后删 绑定房间号和案件id + caseApplicationMapper.bindCaseId(reservedConferenceVO.getCaseId(), reservedConferenceVO.getRoomId()); + String format = "yyyy-MM-dd HH:mm:ss"; // 目标格式 + Date startDate = new Date(scheduleStartTime); + Date endDate = new Date(scheduleEndTime); + SimpleDateFormat sdf = new SimpleDateFormat(format); + String startFormat = sdf.format(startDate); + 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("预约会议失败"); } } + /** + * 销毁房间回调 + * @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")); + } + + } + } + diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml index dc2bae1..6b19a3f 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml @@ -29,6 +29,7 @@ + @@ -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.comp_legal_person,c.comp_legalper_post,c.respon_sex,c.respon_birth, 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 + left join sys_user s on c.identity_num=s.id_card AND c.case_appli_id = #{caseAppliId} diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ReservedConferenceMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ReservedConferenceMapper.xml new file mode 100644 index 0000000..205eb0f --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ReservedConferenceMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + insert into reserved_conference( + case_id, + room_id, + schedule_start_time, + schedule_end_time + )values( + #{caseId}, + #{roomId}, + #{scheduleStartTime}, + #{scheduleEndTime} + ) + + + delete from reserved_conference where room_id=#{roomId} + + + + + \ No newline at end of file -- 2.54.0