Parcourir la source

Merge branch 'wq' of SH-Arbitrate/Arbitrate-Backend into dev

wangqiong123 il y a 2 ans
Parent
révision
a9ddcaecf9

+ 14
- 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java Voir le fichier

@@ -3,18 +3,14 @@ package com.ruoyi.web.controller.system;
3 3
 import java.util.List;
4 4
 import java.util.stream.Collectors;
5 5
 import javax.servlet.http.HttpServletResponse;
6
+
7
+import cn.hutool.core.util.StrUtil;
8
+import com.ruoyi.common.annotation.Anonymous;
6 9
 import org.apache.commons.lang3.ArrayUtils;
7 10
 import org.springframework.beans.factory.annotation.Autowired;
8 11
 import org.springframework.security.access.prepost.PreAuthorize;
9 12
 import org.springframework.validation.annotation.Validated;
10
-import org.springframework.web.bind.annotation.DeleteMapping;
11
-import org.springframework.web.bind.annotation.GetMapping;
12
-import org.springframework.web.bind.annotation.PathVariable;
13
-import org.springframework.web.bind.annotation.PostMapping;
14
-import org.springframework.web.bind.annotation.PutMapping;
15
-import org.springframework.web.bind.annotation.RequestBody;
16
-import org.springframework.web.bind.annotation.RequestMapping;
17
-import org.springframework.web.bind.annotation.RestController;
13
+import org.springframework.web.bind.annotation.*;
18 14
 import org.springframework.web.multipart.MultipartFile;
19 15
 import com.ruoyi.common.annotation.Log;
20 16
 import com.ruoyi.common.core.controller.BaseController;
@@ -248,4 +244,14 @@ public class SysUserController extends BaseController
248 244
     {
249 245
         return success(deptService.selectDeptTreeList(dept));
250 246
     }
247
+    /**
248
+     * 根据userId获取用户信息
249
+     * @param userId
250
+     * @return
251
+     */
252
+    @Anonymous
253
+    @GetMapping("/generateUserSign")
254
+    public AjaxResult generateUserSign(@RequestParam(required = true) Long userId){
255
+        return AjaxResult.success(userService.selectUserById(userId));
256
+    }
251 257
 }

+ 13
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java Voir le fichier

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
23 23
 import com.ruoyi.common.utils.poi.ExcelUtil;
24 24
 import org.springframework.web.multipart.MultipartFile;
25 25
 
26
+import javax.servlet.http.HttpServletRequest;
26 27
 import javax.servlet.http.HttpServletResponse;
27 28
 import java.util.List;
28 29
 
@@ -375,4 +376,16 @@ public class CaseApplicationController extends BaseController {
375 376
         return caseApplicationService.reservedConference(reservedConferenceVO);
376 377
     }
377 378
 
379
+    /**
380
+     * 腾讯云销毁房间回调
381
+     * @param body
382
+     * @param request
383
+     * @return
384
+     */
385
+    @Anonymous
386
+    @PostMapping("/destroyRoomBack")
387
+    public AjaxResult destroyRoomBack(  @RequestBody String body, HttpServletRequest request) {
388
+        caseApplicationService.destroyRoomBack(body,request);
389
+        return success();
390
+    }
378 391
 }

+ 9
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseAffiliate.java Voir le fichier

@@ -135,8 +135,17 @@ public class CaseAffiliate   extends BaseEntity {
135 135
 
136 136
     /** 送达电子邮件 */
137 137
     private String sendEmail;
138
+    private String userId;
138 139
     private String applicantAgentUserId;
139 140
 
141
+    public String getUserId() {
142
+        return userId;
143
+    }
144
+
145
+    public void setUserId(String userId) {
146
+        this.userId = userId;
147
+    }
148
+
140 149
     public String getApplicantAgentUserId() {
141 150
         return applicantAgentUserId;
142 151
     }

+ 40
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/ReservedConference.java Voir le fichier

@@ -0,0 +1,40 @@
1
+package com.ruoyi.wisdomarbitrate.domain;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @author wangqiong
7
+ * @description 预定会议
8
+ * @Version 1.0
9
+ * @date 2023-11-09 16:51
10
+ */
11
+@Data
12
+public class ReservedConference {
13
+    /**
14
+     * id
15
+     */
16
+    private String id;
17
+    /**
18
+     * 案件id
19
+     */
20
+    private Long caseId;
21
+    /**
22
+     * 房间号
23
+     */
24
+    private String roomId;
25
+    /**
26
+     * 预定会议开始时间
27
+     */
28
+    private String scheduleStartTime;
29
+    /**
30
+     * 预定会议结束时间
31
+     */
32
+    private String scheduleEndTime;
33
+
34
+    public ReservedConference( Long caseId, String roomId, String scheduleStartTime, String scheduleEndTime) {
35
+        this.caseId = caseId;
36
+        this.roomId = roomId;
37
+        this.scheduleStartTime = scheduleStartTime;
38
+        this.scheduleEndTime = scheduleEndTime;
39
+    }
40
+}

+ 37
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ReservedConferenceMapper.java Voir le fichier

@@ -0,0 +1,37 @@
1
+package com.ruoyi.wisdomarbitrate.mapper;
2
+
3
+import com.ruoyi.wisdomarbitrate.domain.ReservedConference;
4
+import org.springframework.data.repository.query.Param;
5
+import org.springframework.stereotype.Repository;
6
+
7
+
8
+import java.util.List;
9
+
10
+
11
+/**
12
+ * @author wangqiong
13
+ * @description 预约会议Mapper接口
14
+ * @Version 1.0
15
+ * @date 2023-11-09 16:51
16
+ */
17
+@Repository
18
+public interface ReservedConferenceMapper {
19
+    /**
20
+     * 根据案件id查询预约会议列表
21
+     * @param caseId
22
+     * @return
23
+     */
24
+    List<ReservedConference> selectListByCaseId(@Param("caseId")Long caseId);
25
+
26
+    /**
27
+     * 新增
28
+     * @param reservedConference
29
+     */
30
+    void insert(ReservedConference reservedConference);
31
+
32
+    /**
33
+     * 根据房间号删除
34
+     * @param roomId
35
+     */
36
+    void deleteByRoomId(@Param("roomId")String roomId);
37
+}

+ 9
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java Voir le fichier

@@ -8,6 +8,7 @@ import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
8 8
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
9 9
 import org.springframework.web.multipart.MultipartFile;
10 10
 
11
+import javax.servlet.http.HttpServletRequest;
11 12
 import java.util.List;
12 13
 
13 14
 public interface ICaseApplicationService {
@@ -94,4 +95,12 @@ public interface ICaseApplicationService {
94 95
      * @throws Exception
95 96
      */
96 97
      AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) throws Exception;
98
+
99
+    /**
100
+     * 腾讯云销毁房间回调
101
+     * @param body
102
+     * @param request
103
+     * @return
104
+     */
105
+    void destroyRoomBack(String body, HttpServletRequest request);
97 106
 }

+ 66
- 23
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java Voir le fichier

@@ -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
+

+ 3
- 1
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml Voir le fichier

@@ -29,6 +29,7 @@
29 29
 
30 30
         <result property="residenAffili"    column="residen_affili"   />
31 31
         <result property="appliAgentTitle"    column="appli_agent_title"   />
32
+        <result property="userId"    column="user_id"   />
32 33
 
33 34
     </resultMap>
34 35
 
@@ -37,8 +38,9 @@
37 38
         c.work_address ,c.work_telphone ,c.name_agent, c.identity_num_agent ,c.contact_telphone_agent ,c.contact_address_agent,
38 39
         c.comp_legal_person,c.comp_legalper_post,c.respon_sex,c.respon_birth,
39 40
         c.residen_affili,c.appli_agent_title,
40
-        c.track_num,c.application_organ_id,c.application_organ_name
41
+        c.track_num,c.application_organ_id,c.application_organ_name,s.user_id
41 42
         from case_affiliate c
43
+        left join sys_user s on c.identity_num=s.id_card
42 44
         <where>
43 45
             <if test="caseAppliId != null ">
44 46
                 AND c.case_appli_id = #{caseAppliId}

+ 35
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ReservedConferenceMapper.xml Voir le fichier

@@ -0,0 +1,35 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.ReservedConferenceMapper">
6
+    <resultMap type="com.ruoyi.wisdomarbitrate.domain.ReservedConference" id="BaseResult">
7
+        <id     property="id"       column="id"      />
8
+        <result property="caseId"     column="case_id"    />
9
+        <result property="roomId"     column="room_id"    />
10
+        <result property="scheduleStartTime"        column="schedule_start_time"        />
11
+        <result property="scheduleEndTime"  column="schedule_end_time"  />
12
+
13
+    </resultMap>
14
+    <insert id="insert">
15
+        insert into reserved_conference(
16
+        case_id,
17
+        room_id,
18
+        schedule_start_time,
19
+        schedule_end_time
20
+        )values(
21
+                #{caseId},
22
+                #{roomId},
23
+                #{scheduleStartTime},
24
+                #{scheduleEndTime}
25
+        )
26
+    </insert>
27
+    <delete id="deleteByRoomId">
28
+        delete from reserved_conference where room_id=#{roomId}
29
+    </delete>
30
+    <select id="selectListByCaseId" resultMap="BaseResult">
31
+        select * from reserved_conference where case_id=#{caseId}
32
+    </select>
33
+
34
+
35
+</mapper>