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