Bläddra i källkod

Merge branch 'bgy' of SH-Arbitrate/Mediation-Backend into dev

bgy 2 år sedan
förälder
incheckning
376e86cc28

+ 44
- 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/flow/MsCaseFlowRoleSmsRelated.java Visa fil

@@ -0,0 +1,44 @@
1
+package com.ruoyi.system.domain.entity.flow;
2
+
3
+import java.util.Date;
4
+import javax.persistence.*;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+import lombok.ToString;
8
+
9
+@Getter
10
+@Setter
11
+@ToString
12
+@Table(name = "ms_case_flow_role_sms_related")
13
+public class MsCaseFlowRoleSmsRelated {
14
+    /**
15
+     * id
16
+     */
17
+    @Id
18
+    @GeneratedValue(generator = "JDBC")
19
+    private Integer id;
20
+
21
+    /**
22
+     * 案件流程id
23
+     */
24
+    @Column(name = "flow_id")
25
+    private Integer flowId;
26
+
27
+    /**
28
+     * 用户角色id
29
+     */
30
+    @Column(name = "receive_role_id")
31
+    private Long receiveRoleId;
32
+
33
+    /**
34
+     * 短信模版id
35
+     */
36
+    @Column(name = "sms_template_id")
37
+    private Long smsTemplateId;
38
+
39
+    /**
40
+     * 创建时间
41
+     */
42
+    @Column(name = "create_time")
43
+    private Date createTime;
44
+}

+ 39
- 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowRoleSmsRelatedVO.java Visa fil

@@ -0,0 +1,39 @@
1
+package com.ruoyi.system.domain.vo.flow;
2
+
3
+import com.alibaba.fastjson2.JSONObject;
4
+import lombok.AllArgsConstructor;
5
+import lombok.Builder;
6
+import lombok.Data;
7
+import lombok.NoArgsConstructor;
8
+
9
+import java.util.List;
10
+
11
+@AllArgsConstructor
12
+@NoArgsConstructor
13
+@Builder
14
+@Data
15
+public class MsCaseFlowRoleSmsRelatedVO {
16
+    /**
17
+     * 主键id
18
+     */
19
+    private Integer id;
20
+
21
+    /**
22
+     * 流程节点id
23
+     */
24
+    private Integer flowId;
25
+
26
+
27
+    /**
28
+     * 短信模版id
29
+     */
30
+    private Long smsTemplateId;
31
+    /**
32
+     * 发送短信的角色id
33
+     */
34
+    private List<Long> receiveRoleIds;
35
+    /**
36
+     * 接收短信角色名称
37
+     */
38
+    public List<JSONObject> receiveRoleNames;
39
+}

+ 13
- 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowVO.java Visa fil

@@ -1,5 +1,6 @@
1 1
 package com.ruoyi.system.domain.vo.flow;
2 2
 
3
+import com.alibaba.fastjson2.JSONObject;
3 4
 import lombok.AllArgsConstructor;
4 5
 import lombok.Builder;
5 6
 import lombok.Data;
@@ -64,5 +65,16 @@ public class MsCaseFlowVO {
64 65
      * svg图片路径
65 66
      */
66 67
     private String fileName;
67
-
68
+    /**
69
+     * 短信模版id
70
+     */
71
+    private Long smsTemplateId;
72
+    /**
73
+     * 发送短信的角色id
74
+     */
75
+    private List<Long> receiveRoleIds;
76
+    /**
77
+     * 接收短信角色名称
78
+     */
79
+    public List<JSONObject> receiveRoleNames;
68 80
 }

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/flow/MsCaseFlowRoleSmsRelatedMapper.java Visa fil

@@ -0,0 +1,7 @@
1
+package com.ruoyi.system.mapper.flow;
2
+
3
+import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated;
4
+import tk.mybatis.mapper.common.Mapper;
5
+
6
+public interface MsCaseFlowRoleSmsRelatedMapper extends Mapper<MsCaseFlowRoleSmsRelated> {
7
+}

+ 12
- 1
ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowService.java Visa fil

@@ -1,6 +1,7 @@
1 1
 package com.ruoyi.system.service.flow;
2 2
 
3 3
 import com.ruoyi.common.core.domain.AjaxResult;
4
+import com.ruoyi.system.domain.vo.flow.MsCaseFlowRoleSmsRelatedVO;
4 5
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
5 6
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
6 7
 
@@ -9,18 +10,22 @@ import java.util.Set;
9 10
 public interface CaseFlowService {
10 11
     /**
11 12
      * 查询案件流程节点信息
13
+     *
12 14
      * @param caseFlowSearchVO
13 15
      * @return
14 16
      */
15 17
     Object queryCaseFlowInfo(MsCaseFlowSearchVO caseFlowSearchVO);
18
+
16 19
     /**
17 20
      * 查询案件流程信息
21
+     *
18 22
      * @return
19 23
      */
20 24
     AjaxResult selectCaseFlow();
21 25
 
22 26
     /**
23 27
      * 新增或编辑案件流程节点信息
28
+     *
24 29
      * @param caseFlowVO
25 30
      * @return
26 31
      */
@@ -28,6 +33,7 @@ public interface CaseFlowService {
28 33
 
29 34
     /**
30 35
      * 删除案件流程节点信息
36
+     *
31 37
      * @param caseFlowVO
32 38
      * @return
33 39
      */
@@ -35,6 +41,7 @@ public interface CaseFlowService {
35 41
 
36 42
     /**
37 43
      * 排序案件流程节点
44
+     *
38 45
      * @param caseFlowSearchVO
39 46
      * @return
40 47
      */
@@ -42,10 +49,14 @@ public interface CaseFlowService {
42 49
 
43 50
     /**
44 51
      * 查询用户角色关联的案件状态
52
+     *
45 53
      * @param roles
46 54
      * @return
47 55
      */
48 56
     Set<Integer> getCaseStatusIdByRoleKey(Set<String> roles);
49 57
 
50
-
58
+    /**
59
+     * 查询流程节点接收信息配置记录
60
+     */
61
+    MsCaseFlowRoleSmsRelatedVO queryFlowReceiveRoleSmsRelated(Integer flowId);
51 62
 }

+ 137
- 32
ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java Visa fil

@@ -1,5 +1,6 @@
1 1
 package com.ruoyi.system.service.flow;
2 2
 
3
+import com.alibaba.fastjson2.JSONObject;
3 4
 import com.github.pagehelper.PageHelper;
4 5
 import com.github.pagehelper.PageInfo;
5 6
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -7,12 +8,15 @@ import com.ruoyi.common.core.domain.entity.SysRole;
7 8
 import com.ruoyi.common.core.page.TableDataInfo;
8 9
 import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
9 10
 import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
11
+import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated;
10 12
 import com.ruoyi.system.domain.vo.flow.MsBaseCaseFlow;
13
+import com.ruoyi.system.domain.vo.flow.MsCaseFlowRoleSmsRelatedVO;
11 14
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
12 15
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
13 16
 import com.ruoyi.system.mapper.SysRoleMapper;
14 17
 import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
15 18
 import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper;
19
+import com.ruoyi.system.mapper.flow.MsCaseFlowRoleSmsRelatedMapper;
16 20
 import com.ruoyi.system.util.NewStringUtil;
17 21
 import com.ruoyi.system.util.TableDataUtil;
18 22
 import org.springframework.beans.BeanUtils;
@@ -90,6 +94,30 @@ public class CaseFlowServiceImpl implements CaseFlowService {
90 94
                     MsCaseFlow msCaseFlow1 = msCaseFlowMapper.selectByPrimaryKey(msCaseFlow.getBackFlowId());
91 95
                     temp.setBackFlowName(msCaseFlow1 != null ? msCaseFlow1.getNodeName() : "");
92 96
                 }
97
+                //短信接收角色
98
+                if (msCaseFlow.getId() != null) {
99
+                    Example example1 = new Example(MsCaseFlowRoleSmsRelated.class);
100
+                    Example.Criteria criteria1 = example1.createCriteria();
101
+                    criteria1.andEqualTo("flowId", msCaseFlow.getId());
102
+                    List<MsCaseFlowRoleSmsRelated> msCaseFlowRoleSmsRelateds = msCaseFlowRoleSmsRelatedMapper.selectByExample(example1);
103
+                    List<JSONObject> receiveRoleNames = new ArrayList<>();
104
+                    List<Long> receiveRoleIds = new ArrayList<>();
105
+                    for (int k = 0; k < msCaseFlowRoleSmsRelateds.size(); k++) {
106
+                        MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = msCaseFlowRoleSmsRelateds.get(k);
107
+                        if (msCaseFlowRoleSmsRelated.getReceiveRoleId() != null) {
108
+                            SysRole sysRole = sysRoleMapper.selectRoleById(msCaseFlowRoleSmsRelated.getReceiveRoleId());
109
+                            if (sysRole != null) {
110
+                                JSONObject jsonObject = new JSONObject();
111
+                                jsonObject.put("roleId", sysRole.getRoleId());
112
+                                jsonObject.put("roleName", sysRole.getRoleName());
113
+                                receiveRoleNames.add(jsonObject);
114
+                                receiveRoleIds.add(sysRole.getRoleId());
115
+                            }
116
+                        }
117
+                    }
118
+                    temp.setReceiveRoleIds(receiveRoleIds);
119
+                    temp.setReceiveRoleNames(receiveRoleNames);
120
+                }
93 121
                 list.add(temp);
94 122
             }
95 123
             TableDataInfo tableDataInfo = TableDataUtil.rebuildTableDataInfo(list, total);
@@ -134,15 +162,16 @@ public class CaseFlowServiceImpl implements CaseFlowService {
134 162
 
135 163
     /**
136 164
      * 本地图片装64
165
+     *
137 166
      * @param imgPath
138 167
      * @return
139 168
      * @throws Exception
140 169
      */
141
-    public static String convertToBase64( String imgPath)  {
170
+    public static String convertToBase64(String imgPath) {
142 171
         byte[] data = null;
143 172
         // 读取图片字节数组
144 173
         try {
145
-            imgPath=imgPath.replace("/profile/upload", "/home/ruoyi/uploadPath/upload/");
174
+            imgPath = imgPath.replace("/profile/upload", "/home/ruoyi/uploadPath/upload/");
146 175
             InputStream in = Files.newInputStream(Paths.get(imgPath));
147 176
             data = new byte[in.available()];
148 177
             in.read(data);
@@ -153,6 +182,7 @@ public class CaseFlowServiceImpl implements CaseFlowService {
153 182
         // 返回Base64编码过的字节数组字符串
154 183
         return Base64.getEncoder().encodeToString(Objects.requireNonNull(data));
155 184
     }
185
+
156 186
     /**
157 187
      * 新增或编辑案件流程节点信息
158 188
      *
@@ -161,40 +191,78 @@ public class CaseFlowServiceImpl implements CaseFlowService {
161 191
      */
162 192
     @Override
163 193
     public Boolean saveCaseFlow(MsCaseFlowVO caseFlowVO) {
164
-
165
-        if (caseFlowVO.getId() != null) {
166
-            //更新案件流程信息
167
-            MsCaseFlow msCaseFlow = new MsCaseFlow();
168
-            BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
169
-            int i = msCaseFlowMapper.updateByPrimaryKey(msCaseFlow);
170
-            if (i > 0) {
171
-                //更新流程节点和角色之间的关系
172
-                updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
173
-                return true;
174
-            }
175
-        } else {
176
-            int sort = 1;
177
-            Example example = new Example(MsCaseFlow.class);
178
-            example.setOrderByClause("sort DESC limit 1");
179
-            Example.Criteria criteria = example.createCriteria();
180
-            List<MsCaseFlow> msCaseFlows = msCaseFlowMapper.selectByExample(example);
181
-            if (msCaseFlows != null && msCaseFlows.size() > 0) {
182
-                sort = msCaseFlows.get(0).getSort() + 1;
183
-            }
184
-            //新增案件流程信息
185
-            MsCaseFlow msCaseFlow = new MsCaseFlow();
186
-            BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
187
-            msCaseFlow.setSort(sort);
188
-            int insert = msCaseFlowMapper.insert(msCaseFlow);
189
-            if (insert > 0) {
190
-                //更新流程节点和角色之间的关系
191
-                updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
192
-                return true;
194
+        try {
195
+            if (caseFlowVO.getId() != null) {
196
+                //更新案件流程信息
197
+                MsCaseFlow msCaseFlow = new MsCaseFlow();
198
+                BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
199
+                int i = msCaseFlowMapper.updateByPrimaryKey(msCaseFlow);
200
+                if (i > 0) {
201
+                    //更新流程节点和角色之间的关系
202
+                    updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
203
+                    //更新流程节点和短信模板之间的关系
204
+                    updateFlowMessageRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getReceiveRoleIds(), caseFlowVO.getSmsTemplateId());
205
+                    return true;
206
+                } else {
207
+                    return false;
208
+                }
209
+            } else {
210
+                int sort = 1;
211
+                Example example = new Example(MsCaseFlow.class);
212
+                example.setOrderByClause("sort DESC limit 1");
213
+                Example.Criteria criteria = example.createCriteria();
214
+                List<MsCaseFlow> msCaseFlows = msCaseFlowMapper.selectByExample(example);
215
+                if (msCaseFlows != null && msCaseFlows.size() > 0) {
216
+                    sort = msCaseFlows.get(0).getSort() + 1;
217
+                }
218
+                //新增案件流程信息
219
+                MsCaseFlow msCaseFlow = new MsCaseFlow();
220
+                BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
221
+                msCaseFlow.setSort(sort);
222
+                int insert = msCaseFlowMapper.insert(msCaseFlow);
223
+                if (insert > 0) {
224
+                    //更新流程节点和角色之间的关系
225
+                    updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds());
226
+                    //更新流程节点和短信模板之间的关系
227
+                    updateFlowMessageRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getReceiveRoleIds(), caseFlowVO.getSmsTemplateId());
228
+                    return true;
229
+                }
193 230
             }
231
+        } catch (Exception e) {
232
+            e.printStackTrace();
194 233
         }
195 234
         return false;
196 235
     }
197 236
 
237
+    @Autowired
238
+    MsCaseFlowRoleSmsRelatedMapper msCaseFlowRoleSmsRelatedMapper;
239
+
240
+    /**
241
+     * 更新流程节点和短信模板之间的关系
242
+     *
243
+     * @param flowId
244
+     * @param receiveRoleIds
245
+     * @param smsTemplateId
246
+     */
247
+    private void updateFlowMessageRoleByFlowId(Integer flowId, List<Long> receiveRoleIds, Long smsTemplateId) {
248
+        if (receiveRoleIds != null && receiveRoleIds.size() > 0) {
249
+            //删除历史流程与短信发送设置记录
250
+            Example example = new Example(MsCaseFlowRoleSmsRelated.class);
251
+            example.createCriteria().andEqualTo("flowId", flowId);
252
+            int count = msCaseFlowRoleSmsRelatedMapper.deleteByExample(example);
253
+            //新增流程节点与短信发送设置记录
254
+            for (int i = 0; i < receiveRoleIds.size(); i++) {
255
+                MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = new MsCaseFlowRoleSmsRelated();
256
+                msCaseFlowRoleSmsRelated.setFlowId(flowId);
257
+                msCaseFlowRoleSmsRelated.setReceiveRoleId(receiveRoleIds.get(i));
258
+                msCaseFlowRoleSmsRelated.setSmsTemplateId(smsTemplateId);
259
+                msCaseFlowRoleSmsRelated.setCreateTime(new Date());
260
+                msCaseFlowRoleSmsRelatedMapper.insertSelective(msCaseFlowRoleSmsRelated);
261
+            }
262
+        }
263
+
264
+    }
265
+
198 266
     /**
199 267
      * 更新流程节点和角色之间的关系
200 268
      *
@@ -258,7 +326,6 @@ public class CaseFlowServiceImpl implements CaseFlowService {
258 326
     }
259 327
 
260 328
 
261
-
262 329
     /**
263 330
      * 排序案件流程节点
264 331
      *
@@ -352,6 +419,44 @@ public class CaseFlowServiceImpl implements CaseFlowService {
352 419
         return caseStatusIds;
353 420
     }
354 421
 
422
+    /**
423
+     * 查询流程节点接收信息配置记录
424
+     *
425
+     * @param flowId
426
+     */
427
+    @Override
428
+    public MsCaseFlowRoleSmsRelatedVO queryFlowReceiveRoleSmsRelated(Integer flowId) {
429
+        MsCaseFlowRoleSmsRelatedVO result = new MsCaseFlowRoleSmsRelatedVO();
430
+        //短信接收角色
431
+        if (flowId != null) {
432
+            Example example1 = new Example(MsCaseFlowRoleSmsRelated.class);
433
+            Example.Criteria criteria1 = example1.createCriteria();
434
+            criteria1.andEqualTo("flowId", flowId);
435
+            List<MsCaseFlowRoleSmsRelated> msCaseFlowRoleSmsRelateds = msCaseFlowRoleSmsRelatedMapper.selectByExample(example1);
436
+            List<JSONObject> receiveRoleNames = new ArrayList<>();
437
+            List<Long> receiveRoleIds = new ArrayList<>();
438
+            for (int k = 0; k < msCaseFlowRoleSmsRelateds.size(); k++) {
439
+                MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = msCaseFlowRoleSmsRelateds.get(k);
440
+                if (k == 0) {
441
+                    BeanUtils.copyProperties(msCaseFlowRoleSmsRelated, result);
442
+                }
443
+                if (msCaseFlowRoleSmsRelated.getReceiveRoleId() != null) {
444
+                    SysRole sysRole = sysRoleMapper.selectRoleById(msCaseFlowRoleSmsRelated.getReceiveRoleId());
445
+                    if (sysRole != null) {
446
+                        JSONObject jsonObject = new JSONObject();
447
+                        jsonObject.put("roleId", sysRole.getRoleId());
448
+                        jsonObject.put("roleName", sysRole.getRoleName());
449
+                        receiveRoleNames.add(jsonObject);
450
+                        receiveRoleIds.add(sysRole.getRoleId());
451
+                    }
452
+                }
453
+            }
454
+            result.setReceiveRoleIds(receiveRoleIds);
455
+            result.setReceiveRoleNames(receiveRoleNames);
456
+        }
457
+        return result;
458
+    }
459
+
355 460
     /**
356 461
      * 查询角色的案件状态id
357 462
      *

+ 14
- 0
ruoyi-system/src/main/resources/com/ruoyi/system/mapper/flow/MsCaseFlowRoleSmsRelatedMapper.xml Visa fil

@@ -0,0 +1,14 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.ruoyi.system.mapper.flow.MsCaseFlowRoleSmsRelatedMapper">
4
+  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated">
5
+    <!--
6
+      WARNING - @mbg.generated
7
+    -->
8
+    <id column="id" jdbcType="INTEGER" property="id" />
9
+    <result column="flow_id" jdbcType="INTEGER" property="flowId" />
10
+    <result column="receive_role_id" jdbcType="BIGINT" property="receiveRoleId" />
11
+    <result column="sms_template_id" jdbcType="BIGINT" property="smsTemplateId" />
12
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
13
+  </resultMap>
14
+</mapper>