|
|
@@ -1,22 +1,30 @@
|
|
1
|
1
|
package com.ruoyi.wisdomarbitrate.service.impl;
|
|
2
|
2
|
|
|
|
3
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
4
|
+import cn.hutool.core.util.StrUtil;
|
|
3
|
5
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
4
|
6
|
import com.ruoyi.common.enums.UpdateSubmitStatus;
|
|
5
|
7
|
import com.ruoyi.common.enums.YesOrNoEnum;
|
|
|
8
|
+import com.ruoyi.common.utils.ObjectFieldUtils;
|
|
|
9
|
+import com.ruoyi.common.utils.SmsUtils;
|
|
6
|
10
|
import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
|
|
7
|
11
|
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
|
|
12
|
+import com.ruoyi.wisdomarbitrate.domain.SmsSendRecord;
|
|
|
13
|
+import com.ruoyi.wisdomarbitrate.domain.vo.CompareCaseVO;
|
|
8
|
14
|
import com.ruoyi.wisdomarbitrate.domain.vo.UpdateSubmitVO;
|
|
9
|
|
-import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateLogMapper;
|
|
10
|
|
-import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper;
|
|
11
|
|
-import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationLogMapper;
|
|
12
|
|
-import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
|
|
|
15
|
+import com.ruoyi.wisdomarbitrate.mapper.*;
|
|
13
|
16
|
import com.ruoyi.wisdomarbitrate.service.CaseApplicationLogService;
|
|
14
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
18
|
import org.springframework.stereotype.Service;
|
|
16
|
19
|
import org.springframework.transaction.annotation.Transactional;
|
|
17
|
20
|
|
|
|
21
|
+import java.util.Date;
|
|
18
|
22
|
import java.util.List;
|
|
|
23
|
+import java.util.Map;
|
|
19
|
24
|
import java.util.Objects;
|
|
|
25
|
+import java.util.stream.Collectors;
|
|
|
26
|
+
|
|
|
27
|
+import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
|
20
|
28
|
|
|
21
|
29
|
/**
|
|
22
|
30
|
* @author wangqiong
|
|
|
@@ -33,6 +41,8 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
|
|
33
|
41
|
private CaseAffiliateLogMapper caseAffiliateLogMapper;
|
|
34
|
42
|
@Autowired
|
|
35
|
43
|
private CaseAffiliateMapper caseAffiliateMapper;
|
|
|
44
|
+ @Autowired
|
|
|
45
|
+ private SmsRecordMapper smsRecordMapper;
|
|
36
|
46
|
@Override
|
|
37
|
47
|
public int insert(CaseApplication caseApplicationLog) {
|
|
38
|
48
|
return caseApplicationLogMapper.insert(caseApplicationLog);
|
|
|
@@ -70,7 +80,7 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
|
|
70
|
80
|
return AjaxResult.error("案件不存在");
|
|
71
|
81
|
}
|
|
72
|
82
|
// 如果秘书没有审核,将撤销状态改为同意撤销,否则改为撤销
|
|
73
|
|
- if(caseApplication.getUpdateSubmitStatus()!=null && caseApplication.getUpdateSubmitStatus()>UpdateSubmitStatus.REVOKE.getCode()){
|
|
|
83
|
+ if(caseApplication.getUpdateSubmitStatus()!=null && !caseApplication.getUpdateSubmitStatus().equals(UpdateSubmitStatus.AGREE.getCode())){
|
|
74
|
84
|
agreeRevoke(vo);
|
|
75
|
85
|
|
|
76
|
86
|
}else {
|
|
|
@@ -106,20 +116,25 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
|
|
106
|
116
|
vo.setUpdateSubmitStatus(UpdateSubmitStatus.AGREE.getCode());
|
|
107
|
117
|
caseApplicationLogMapper.updateStatus(vo);
|
|
108
|
118
|
// 根据caseLogId查询相关人员表
|
|
109
|
|
- CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
110
|
|
- caseAffiliate.setCaseAppliLogId(caseApplicationLog.getCaseLogId());
|
|
111
|
|
- List<CaseAffiliate> affiliateLogList = caseAffiliateLogMapper.selectCaseAffiliate(caseAffiliate);
|
|
|
119
|
+ List<CaseAffiliate> affiliateLogList = caseAffiliateLogMapper.selectCaseAffiliate(caseApplicationLog.getCaseLogId());
|
|
112
|
120
|
caseApplicationLog.setId(caseApplicationLog.getCaseAppliId());
|
|
113
|
121
|
// 更新案件主表
|
|
114
|
122
|
caseApplicationMapper.updataCaseApplication(caseApplicationLog);
|
|
115
|
123
|
|
|
116
|
124
|
// 更新相关人员主表
|
|
117
|
|
- caseAffiliateMapper.updataCaseAffiliateByCaseId(caseApplicationLog.getCaseAppliId(), affiliateLogList);
|
|
|
125
|
+ if(CollectionUtil.isNotEmpty(affiliateLogList)){
|
|
|
126
|
+ for (CaseAffiliate caseAffiliate : affiliateLogList) {
|
|
|
127
|
+ caseAffiliateMapper.updataCaseAffiliate(caseAffiliate);
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+ // caseAffiliateMapper.updateCaseAffiliateByCaseId(caseApplicationLog.getCaseAppliId(), affiliateLogList);
|
|
118
|
131
|
} else {
|
|
119
|
132
|
// 拒绝,将日志表改版本的状态改为拒绝
|
|
120
|
133
|
vo.setUpdateSubmitStatus(UpdateSubmitStatus.REFUSE.getCode());
|
|
121
|
134
|
caseApplicationLogMapper.updateStatus(vo);
|
|
122
|
|
- // todo 给申请人发送短信
|
|
|
135
|
+ return sendAuditMessage(vo);
|
|
|
136
|
+
|
|
|
137
|
+
|
|
123
|
138
|
// 修改案件表的版本号
|
|
124
|
139
|
// caseApplicationMapper.updateVersionById(vo.getCaseId(),vo.getVersion());
|
|
125
|
140
|
|
|
|
@@ -139,6 +154,7 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
|
|
139
|
154
|
// 拒绝撤销,将日志表改版本的状态改为拒绝撤销
|
|
140
|
155
|
vo.setUpdateSubmitStatus(UpdateSubmitStatus.REFUSE_REVOKE.getCode());
|
|
141
|
156
|
caseApplicationLogMapper.updateStatus(vo);
|
|
|
157
|
+ return sendAuditMessage(vo);
|
|
142
|
158
|
// 修改案件表的版本号
|
|
143
|
159
|
// caseApplicationMapper.updateVersionById(vo.getCaseId(),vo.getVersion());
|
|
144
|
160
|
}
|
|
|
@@ -147,6 +163,150 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
|
|
147
|
163
|
return AjaxResult.success();
|
|
148
|
164
|
}
|
|
149
|
165
|
|
|
|
166
|
+ /**
|
|
|
167
|
+ * 给申请人发送短信
|
|
|
168
|
+ * @param vo
|
|
|
169
|
+ * @return
|
|
|
170
|
+ */
|
|
|
171
|
+ private AjaxResult sendAuditMessage(UpdateSubmitVO vo) {
|
|
|
172
|
+ // 查询申请人
|
|
|
173
|
+ CaseApplication logCase = caseApplicationLogMapper.selectByCaseIdAndVersion(vo.getCaseId(), vo.getVersion());
|
|
|
174
|
+ if(logCase == null){
|
|
|
175
|
+ return AjaxResult.success();
|
|
|
176
|
+ }
|
|
|
177
|
+ CaseAffiliate caseAffiliate = caseAffiliateLogMapper.selectCaseAffiliateByIdentityType(logCase.getCaseLogId(), 1);
|
|
|
178
|
+ if(caseAffiliate == null){
|
|
|
179
|
+ return AjaxResult.success();
|
|
|
180
|
+ }
|
|
|
181
|
+
|
|
|
182
|
+ // todo 给申请人发送短信
|
|
|
183
|
+ SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
|
|
|
184
|
+ request.setTemplateId("1996949");
|
|
|
185
|
+ request.setPhone(caseAffiliate.getContactTelphone());
|
|
|
186
|
+ request.setTemplateParamSet(new String[]{caseAffiliate.getName(), logCase.getCaseNum(),vo.getReason()});
|
|
|
187
|
+ Boolean aBoolean = SmsUtils.sendSms(request);
|
|
|
188
|
+ //保存短信发送记录
|
|
|
189
|
+ SmsSendRecord smsSendRecord = new SmsSendRecord();
|
|
|
190
|
+ smsSendRecord.setCaseId(caseAffiliate.getCaseAppliId());
|
|
|
191
|
+ CaseApplication caseApplication = new CaseApplication();
|
|
|
192
|
+ caseApplication.setId(caseAffiliate.getCaseAppliId());
|
|
|
193
|
+ caseApplication = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
|
194
|
+ smsSendRecord.setCaseNum(caseApplication.getCaseNum());
|
|
|
195
|
+ smsSendRecord.setPhone(request.getPhone());
|
|
|
196
|
+ smsSendRecord.setSendTime(new Date());
|
|
|
197
|
+ // 1996949 审核案件结果通知 尊敬的{1}用户,您的{2}仲裁案件,审核未通过,理由为{3},请知晓,如非本人操作,请忽略本短信
|
|
|
198
|
+ String content = "尊敬的" + caseAffiliate.getName() + ",您的"+logCase.getCaseNum()+"仲裁案件,审核未通过,理由为"+vo.getReason()+",请知晓,如非本人操作,请忽略本短信。";
|
|
|
199
|
+ smsSendRecord.setSendContent(content);
|
|
|
200
|
+ smsSendRecord.setCreateBy(getUsername());
|
|
|
201
|
+ if (aBoolean) {
|
|
|
202
|
+ smsSendRecord.setSendStatus(1);
|
|
|
203
|
+ } else {
|
|
|
204
|
+ smsSendRecord.setSendStatus(0);
|
|
|
205
|
+ }
|
|
|
206
|
+ smsRecordMapper.saveSmsSendRecord(smsSendRecord);
|
|
|
207
|
+ return AjaxResult.success();
|
|
|
208
|
+ }
|
|
|
209
|
+
|
|
|
210
|
+ @Override
|
|
|
211
|
+ public AjaxResult selectCompareCase(UpdateSubmitVO vo) {
|
|
|
212
|
+ // 查询当前版本号和上一个版本号的案件
|
|
|
213
|
+ CaseApplication afterCase = caseApplicationLogMapper.selectByCaseIdAndVersion(vo.getCaseId(), vo.getVersion());
|
|
|
214
|
+ CaseApplication beforeCase = caseApplicationLogMapper.selectByCaseIdAndVersion(vo.getCaseId(), vo.getVersion() - 1);
|
|
|
215
|
+ // 查询案件关联人员
|
|
|
216
|
+ beforeCase.setCaseAffiliates(caseAffiliateLogMapper.selectCaseAffiliate(beforeCase.getCaseLogId()));
|
|
|
217
|
+ afterCase.setCaseAffiliates(caseAffiliateLogMapper.selectCaseAffiliate(afterCase.getCaseLogId()));
|
|
|
218
|
+ CompareCaseVO compareCaseVO = new CompareCaseVO();
|
|
|
219
|
+ compareCaseVO.setBeforeCase(beforeCase);
|
|
|
220
|
+ compareCaseVO.setAfterCase(afterCase);
|
|
|
221
|
+ // 对比两个版本修改的字段
|
|
|
222
|
+ String[] columns = {"caseLogId","caseSubjectAmount", "caseName"};
|
|
|
223
|
+ String[] affiliateColumns = {"identityNum", "workAddress"};
|
|
|
224
|
+ StringBuilder changeColumn = new StringBuilder();
|
|
|
225
|
+ for (String column : columns) {
|
|
|
226
|
+ String beforeValue = ObjectFieldUtils.getValue(beforeCase, column);
|
|
|
227
|
+ String afterValue = ObjectFieldUtils.getValue(afterCase, column);
|
|
|
228
|
+ if (StrUtil.isEmpty(beforeValue) && StrUtil.isNotEmpty(afterValue)) {
|
|
|
229
|
+ changeColumn.append(column).append(",");
|
|
|
230
|
+ continue;
|
|
|
231
|
+ }
|
|
|
232
|
+ if (StrUtil.isNotEmpty(beforeValue) && StrUtil.isEmpty(afterValue)) {
|
|
|
233
|
+ changeColumn.append(column).append(",");
|
|
|
234
|
+ continue;
|
|
|
235
|
+ }
|
|
|
236
|
+ if (StrUtil.isNotEmpty(beforeValue) && StrUtil.isNotEmpty(afterValue) && !Objects.equals(beforeValue, afterValue)) {
|
|
|
237
|
+ changeColumn.append(column).append(",");
|
|
|
238
|
+ continue;
|
|
|
239
|
+
|
|
|
240
|
+ }
|
|
|
241
|
+
|
|
|
242
|
+ }
|
|
|
243
|
+ List<CaseAffiliate> beforeCaseCaseAffiliates = beforeCase.getCaseAffiliates();
|
|
|
244
|
+ List<CaseAffiliate> afterCaseCaseAffiliates = afterCase.getCaseAffiliates();
|
|
|
245
|
+ Map<Integer, CaseAffiliate> beforeCaseCaseAffiliateMap = null;
|
|
|
246
|
+ if (CollectionUtil.isNotEmpty(beforeCaseCaseAffiliates)) {
|
|
|
247
|
+ // 转为map
|
|
|
248
|
+ beforeCaseCaseAffiliateMap = beforeCaseCaseAffiliates.stream().collect(Collectors.toMap(CaseAffiliate::getIdentityType, v -> v, (n1, n2) -> n2));
|
|
|
249
|
+ }
|
|
|
250
|
+ StringBuilder affiliateChangeColumn;
|
|
|
251
|
+ // 如果上一个版本和现版本有一个为空,那么所有字段都修改
|
|
|
252
|
+ if (beforeCaseCaseAffiliates != null && afterCaseCaseAffiliates == null) {
|
|
|
253
|
+ affiliateChangeColumn = new StringBuilder();
|
|
|
254
|
+ for (String column : affiliateColumns) {
|
|
|
255
|
+
|
|
|
256
|
+ affiliateChangeColumn.append(column).append(",");
|
|
|
257
|
+ }
|
|
|
258
|
+
|
|
|
259
|
+ }
|
|
|
260
|
+ else if (beforeCaseCaseAffiliates == null && afterCaseCaseAffiliates != null) {
|
|
|
261
|
+ affiliateChangeColumn = new StringBuilder();
|
|
|
262
|
+ for (String column : affiliateColumns) {
|
|
|
263
|
+
|
|
|
264
|
+ affiliateChangeColumn.append(column).append(",");
|
|
|
265
|
+ }
|
|
|
266
|
+ } else if (beforeCaseCaseAffiliates != null && afterCaseCaseAffiliates != null) {
|
|
|
267
|
+ for (CaseAffiliate afterCaseCaseAffiliate : afterCaseCaseAffiliates) {
|
|
|
268
|
+ // 找到相同身份类型的数据,进行对比
|
|
|
269
|
+ affiliateChangeColumn = new StringBuilder();
|
|
|
270
|
+ int identityType = afterCaseCaseAffiliate.getIdentityType();
|
|
|
271
|
+ if (beforeCaseCaseAffiliateMap != null && beforeCaseCaseAffiliateMap.containsKey(identityType)) {
|
|
|
272
|
+ CaseAffiliate beforeCaseCaseAffiliate = beforeCaseCaseAffiliateMap.get(identityType);
|
|
|
273
|
+ for (String column : affiliateColumns) {
|
|
|
274
|
+ String beforeValue = ObjectFieldUtils.getValue(beforeCaseCaseAffiliate, column);
|
|
|
275
|
+ String afterValue = ObjectFieldUtils.getValue(afterCaseCaseAffiliate, column);
|
|
|
276
|
+ if (StrUtil.isEmpty(beforeValue) && StrUtil.isNotEmpty(afterValue)) {
|
|
|
277
|
+ affiliateChangeColumn.append(column).append(",");
|
|
|
278
|
+ continue;
|
|
|
279
|
+ }
|
|
|
280
|
+ if (StrUtil.isNotEmpty(beforeValue) && StrUtil.isEmpty(afterValue)) {
|
|
|
281
|
+ affiliateChangeColumn.append(column).append(",");
|
|
|
282
|
+ continue;
|
|
|
283
|
+ }
|
|
|
284
|
+ if (StrUtil.isNotEmpty(beforeValue) && StrUtil.isNotEmpty(afterValue) && !Objects.equals(beforeValue, afterValue)) {
|
|
|
285
|
+ affiliateChangeColumn.append(column).append(",");
|
|
|
286
|
+ continue;
|
|
|
287
|
+
|
|
|
288
|
+ }
|
|
|
289
|
+
|
|
|
290
|
+ }
|
|
|
291
|
+
|
|
|
292
|
+
|
|
|
293
|
+ } else {
|
|
|
294
|
+ for (String column : affiliateColumns) {
|
|
|
295
|
+
|
|
|
296
|
+ affiliateChangeColumn.append(column).append(",");
|
|
|
297
|
+ }
|
|
|
298
|
+ }
|
|
|
299
|
+ afterCaseCaseAffiliate.setChangeColumn(affiliateChangeColumn.toString());
|
|
|
300
|
+
|
|
|
301
|
+ }
|
|
|
302
|
+
|
|
|
303
|
+
|
|
|
304
|
+ }
|
|
|
305
|
+ compareCaseVO.setChangeColumn(changeColumn.toString());
|
|
|
306
|
+
|
|
|
307
|
+ return AjaxResult.success(compareCaseVO);
|
|
|
308
|
+ }
|
|
|
309
|
+
|
|
150
|
310
|
/**
|
|
151
|
311
|
* 同意撤销
|
|
152
|
312
|
* @param vo
|
|
|
@@ -161,14 +321,17 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
|
|
161
|
321
|
vo.setUpdateSubmitStatus(UpdateSubmitStatus.AGREE_REVOKE.getCode());
|
|
162
|
322
|
caseApplicationLogMapper.updateStatus(vo);
|
|
163
|
323
|
// 根据caseLogId查询相关人员表
|
|
164
|
|
- CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
165
|
|
- caseAffiliate.setCaseAppliLogId(caseApplicationLog.getCaseLogId());
|
|
166
|
|
- List<CaseAffiliate> affiliateLogList = caseAffiliateLogMapper.selectCaseAffiliate(caseAffiliate);
|
|
|
324
|
+ List<CaseAffiliate> affiliateLogList = caseAffiliateLogMapper.selectCaseAffiliate(caseApplicationLog.getCaseLogId());
|
|
167
|
325
|
caseApplicationLog.setId(caseApplicationLog.getCaseAppliId());
|
|
168
|
326
|
// 更新案件主表
|
|
169
|
327
|
caseApplicationMapper.updataCaseApplication(caseApplicationLog);
|
|
170
|
328
|
|
|
171
|
329
|
// 更新相关人员主表
|
|
172
|
|
- caseAffiliateMapper.updataCaseAffiliateByCaseId(caseApplicationLog.getCaseAppliId(), affiliateLogList);
|
|
|
330
|
+ if(CollectionUtil.isNotEmpty(affiliateLogList)){
|
|
|
331
|
+ for (CaseAffiliate caseAffiliate : affiliateLogList) {
|
|
|
332
|
+ caseAffiliateMapper.updataCaseAffiliate(caseAffiliate);
|
|
|
333
|
+ }
|
|
|
334
|
+ }
|
|
|
335
|
+ // caseAffiliateMapper.updateCaseAffiliateByCaseId(caseApplicationLog.getCaseAppliId(), affiliateLogList);
|
|
173
|
336
|
}
|
|
174
|
337
|
}
|