|
|
@@ -1,38 +1,46 @@
|
|
1
|
1
|
package com.ruoyi.wisdomarbitrate.service.mscase.impl;
|
|
2
|
2
|
|
|
|
3
|
+import cn.hutool.core.bean.BeanUtil;
|
|
3
|
4
|
import cn.hutool.core.collection.CollectionUtil;
|
|
4
|
5
|
import cn.hutool.core.util.StrUtil;
|
|
|
6
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
5
|
7
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
8
|
+import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
6
|
9
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
7
|
10
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
8
|
11
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
9
|
12
|
import com.ruoyi.common.exception.ServiceException;
|
|
10
|
|
-import com.ruoyi.common.utils.DateUtils;
|
|
11
|
|
-import com.ruoyi.common.utils.IdWorkerUtil;
|
|
12
|
|
-import com.ruoyi.common.utils.SecurityUtils;
|
|
|
13
|
+import com.ruoyi.common.utils.*;
|
|
13
|
14
|
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
|
|
14
|
15
|
import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
|
|
15
|
|
-import com.ruoyi.system.mapper.SysDeptMapper;
|
|
16
|
|
-import com.ruoyi.system.mapper.SysRoleMapper;
|
|
17
|
|
-import com.ruoyi.system.mapper.SysUserMapper;
|
|
18
|
|
-import com.ruoyi.system.mapper.SysUserRoleMapper;
|
|
|
16
|
+import com.ruoyi.system.mapper.*;
|
|
19
|
17
|
import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
|
|
20
|
18
|
import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper;
|
|
|
19
|
+import com.ruoyi.wisdomarbitrate.domain.dto.template.FatchRule;
|
|
21
|
20
|
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
|
|
|
21
|
+import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
|
|
22
|
22
|
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
|
|
23
|
23
|
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
|
|
24
|
24
|
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
|
|
|
25
|
+import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsColumnValueVO;
|
|
25
|
26
|
import com.ruoyi.wisdomarbitrate.mapper.mscase.*;
|
|
|
27
|
+import com.ruoyi.wisdomarbitrate.mapper.template.FatchRuleMapper;
|
|
26
|
28
|
import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
|
|
|
29
|
+import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
|
|
|
30
|
+import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
|
|
|
31
|
+import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
|
|
|
32
|
+import org.apache.pdfbox.pdmodel.PDDocument;
|
|
27
|
33
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
28
|
34
|
import org.springframework.stereotype.Service;
|
|
29
|
35
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
36
|
+import org.springframework.web.multipart.MultipartFile;
|
|
30
|
37
|
import tk.mybatis.mapper.entity.Example;
|
|
31
|
38
|
|
|
|
39
|
+import java.io.*;
|
|
32
|
40
|
import java.math.BigDecimal;
|
|
33
|
|
-import java.util.ArrayList;
|
|
34
|
|
-import java.util.List;
|
|
35
|
|
-import java.util.Map;
|
|
|
41
|
+import java.math.RoundingMode;
|
|
|
42
|
+import java.text.SimpleDateFormat;
|
|
|
43
|
+import java.util.*;
|
|
36
|
44
|
import java.util.stream.Collectors;
|
|
37
|
45
|
|
|
38
|
46
|
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
|
|
@@ -45,7 +53,7 @@ import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
|
45
|
53
|
* @Created wangqiong
|
|
46
|
54
|
*/
|
|
47
|
55
|
@Service
|
|
48
|
|
-public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
|
56
|
+public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
49
|
57
|
@Autowired
|
|
50
|
58
|
MsCaseApplicationMapper msCaseApplicationMapper;
|
|
51
|
59
|
@Autowired
|
|
|
@@ -59,6 +67,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
59
|
67
|
@Autowired
|
|
60
|
68
|
MsCaseAttachLogMapper msCaseAttachLogMapper;
|
|
61
|
69
|
@Autowired
|
|
|
70
|
+ MsColumnValueMapper columnValueMapper;
|
|
|
71
|
+ @Autowired
|
|
|
72
|
+ MsColumnValueLogMapper columnValueLogMapper;
|
|
|
73
|
+ @Autowired
|
|
62
|
74
|
MsCaseFlowMapper caseFlowMapper;
|
|
63
|
75
|
@Autowired
|
|
64
|
76
|
MsCaseFlowRoleRelatedMapper caseFlowRoleRelatedMapper;
|
|
|
@@ -70,78 +82,109 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
70
|
82
|
SysUserMapper userMapper;
|
|
71
|
83
|
@Autowired
|
|
72
|
84
|
SysUserRoleMapper userRoleMapper;
|
|
|
85
|
+ @Autowired
|
|
|
86
|
+ FatchRuleMapper fatchRuleMapper;
|
|
|
87
|
+ @Autowired
|
|
|
88
|
+ SysDictDataMapper dictDataMapper;
|
|
|
89
|
+ // 案件基本字段
|
|
|
90
|
+ public static final List<String> CASE_BASE_COLUMN = Arrays.asList("caseSubjectAmount", "arbitratClaims", "facts", "requestRule");
|
|
|
91
|
+ public static final SimpleDateFormat yyyymmddFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
73
|
92
|
|
|
74
|
93
|
/**
|
|
75
|
94
|
* 案件列表查询
|
|
|
95
|
+ *
|
|
76
|
96
|
* @param req
|
|
77
|
97
|
* @return
|
|
78
|
98
|
*/
|
|
79
|
99
|
@Override
|
|
80
|
100
|
public List<MsCaseApplicationVO> list(MsCaseApplicationReq req) {
|
|
|
101
|
+ // admin查询所有案件
|
|
|
102
|
+ if (StrUtil.equals(SecurityUtils.getUsername(), "admin")) {
|
|
|
103
|
+ return msCaseApplicationMapper.list(req, null);
|
|
|
104
|
+ }
|
|
81
|
105
|
// 根据用户查询角色
|
|
82
|
106
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
83
|
107
|
List<SysRole> roles = loginUser.getUser().getRoles();
|
|
84
|
|
- if(CollectionUtil.isEmpty(roles)){
|
|
|
108
|
+ if (CollectionUtil.isEmpty(roles)) {
|
|
85
|
109
|
throw new ServiceException("该用户未指定角色");
|
|
86
|
110
|
}
|
|
87
|
111
|
req.setUserName(SecurityUtils.getUsername());
|
|
88
|
112
|
// 根据角色查询关联的案件状态
|
|
89
|
113
|
Example example = new Example(MsCaseFlowRoleRelated.class);
|
|
90
|
|
- example.createCriteria().andIn("roleid",roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
|
91
|
|
- List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList= caseFlowRoleRelatedMapper.selectByExample(example);
|
|
92
|
|
- if(CollectionUtil.isEmpty(caseFlowRoleRelatedList)){
|
|
|
114
|
+ example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
|
|
115
|
+ List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example);
|
|
|
116
|
+ if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) {
|
|
93
|
117
|
throw new ServiceException("该角色为绑定案件流程");
|
|
94
|
118
|
}
|
|
95
|
119
|
Example flowExample = new Example(MsCaseFlow.class);
|
|
96
|
|
- flowExample.createCriteria().andIn("id",caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
|
|
|
120
|
+ flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
|
|
97
|
121
|
List<MsCaseFlow> caseFlows = caseFlowMapper.selectByExample(flowExample);
|
|
98
|
|
- if(CollectionUtil.isEmpty(caseFlows)){
|
|
|
122
|
+ if (CollectionUtil.isEmpty(caseFlows)) {
|
|
99
|
123
|
throw new ServiceException("该角色为绑定案件流程");
|
|
100
|
124
|
}
|
|
101
|
125
|
// 查询案件列表
|
|
102
|
|
- List<MsCaseApplicationVO> caseApplicationList=msCaseApplicationMapper.list(req,caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList()));
|
|
|
126
|
+ List<MsCaseApplicationVO> caseApplicationList = msCaseApplicationMapper.list(req, caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList()));
|
|
103
|
127
|
return caseApplicationList;
|
|
104
|
128
|
}
|
|
105
|
129
|
|
|
|
130
|
+ @Override
|
|
|
131
|
+ public MsCaseApplicationVO selectById(Long id) {
|
|
|
132
|
+ MsCaseApplicationVO vo = new MsCaseApplicationVO();
|
|
|
133
|
+ MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id);
|
|
|
134
|
+ BeanUtil.copyProperties(caseApplication, vo);
|
|
|
135
|
+ // 查询案件相关人员
|
|
|
136
|
+ MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id);
|
|
|
137
|
+ vo.setAffiliate(caseAffiliate);
|
|
|
138
|
+ // 查询附件
|
|
|
139
|
+ List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(id);
|
|
|
140
|
+ vo.setCaseAttachList(caseAttachList);
|
|
|
141
|
+ // 自定义字段
|
|
|
142
|
+ List<MsColumnValueVO> columnValueVOS = columnValueMapper.listByCaseId(id);
|
|
|
143
|
+ vo.setColumnValueList(columnValueVOS);
|
|
|
144
|
+ return vo;
|
|
|
145
|
+ }
|
|
|
146
|
+
|
|
106
|
147
|
/**
|
|
107
|
148
|
* 新增案件
|
|
|
149
|
+ *
|
|
108
|
150
|
* @param caseApplication
|
|
109
|
151
|
* @return
|
|
110
|
152
|
*/
|
|
111
|
153
|
@Transactional
|
|
112
|
154
|
@Override
|
|
113
|
155
|
public int insert(MsCaseApplicationVO caseApplication) {
|
|
114
|
|
- caseApplication.setId(IdWorkerUtil.getId());
|
|
|
156
|
+ if (caseApplication.getId() == null) {
|
|
|
157
|
+ caseApplication.setId(IdWorkerUtil.getId());
|
|
|
158
|
+ }
|
|
115
|
159
|
// 根据用户查询角色
|
|
116
|
160
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
117
|
161
|
List<SysRole> roles = loginUser.getUser().getRoles();
|
|
118
|
|
- if(CollectionUtil.isEmpty(roles)){
|
|
|
162
|
+ if (CollectionUtil.isEmpty(roles)) {
|
|
119
|
163
|
throw new ServiceException("该用户未指定角色");
|
|
120
|
164
|
}
|
|
121
|
165
|
// 根据角色查询关联的案件状态
|
|
122
|
166
|
Example example = new Example(MsCaseFlowRoleRelated.class);
|
|
123
|
|
- example.createCriteria().andIn("roleid",roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
|
124
|
|
- List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList= caseFlowRoleRelatedMapper.selectByExample(example);
|
|
125
|
|
- if(CollectionUtil.isEmpty(caseFlowRoleRelatedList)){
|
|
|
167
|
+ example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
|
|
168
|
+ List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example);
|
|
|
169
|
+ if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) {
|
|
126
|
170
|
throw new ServiceException("该角色为绑定案件流程");
|
|
127
|
171
|
}
|
|
128
|
172
|
Example flowExample = new Example(MsCaseFlow.class);
|
|
129
|
173
|
flowExample.setOrderByClause("sort asc");
|
|
130
|
|
- flowExample.createCriteria().andIn("id",caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
|
|
|
174
|
+ flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
|
|
131
|
175
|
List<MsCaseFlow> caseFlows = caseFlowMapper.selectByExample(flowExample);
|
|
132
|
|
- if(CollectionUtil.isNotEmpty(caseFlows)){
|
|
133
|
|
- caseApplication.setCaseStatusName(caseFlows.get(0).getCaseStatusName());
|
|
134
|
|
- caseApplication.setCaseFlowId(caseFlows.get(0).getId());
|
|
|
176
|
+ MsCaseFlow caseFlow = caseFlows.get(0);
|
|
|
177
|
+ if (CollectionUtil.isNotEmpty(caseFlows)) {
|
|
|
178
|
+ caseApplication.setCaseStatusName(caseFlow.getCaseStatusName());
|
|
|
179
|
+ caseApplication.setCaseFlowId(caseFlow.getId());
|
|
135
|
180
|
}
|
|
136
|
|
-
|
|
|
181
|
+ caseApplication.setCreateTime(new Date());
|
|
137
|
182
|
// 计算仲裁费用
|
|
138
|
|
- if( caseApplication.getCaseSubjectAmount()!=null) {
|
|
139
|
|
- BigDecimal feeRate = new BigDecimal("0.01");
|
|
140
|
|
- BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
141
|
|
- caseApplication.setFeePayable(feePayable);
|
|
142
|
|
- }
|
|
|
183
|
+ setFeePayableMethod(caseApplication);
|
|
143
|
184
|
// 设置批号
|
|
144
|
|
- caseApplication.setBatchNumber(getBatchNumber());
|
|
|
185
|
+ if (StrUtil.isEmpty(caseApplication.getBatchNumber())) {
|
|
|
186
|
+ caseApplication.setBatchNumber(getBatchNumber());
|
|
|
187
|
+ }
|
|
145
|
188
|
// 设置编码
|
|
146
|
189
|
caseApplication.setCaseNum(getCaseNum());
|
|
147
|
190
|
caseApplication.setCreateBy(SecurityUtils.getUsername());
|
|
|
@@ -149,80 +192,478 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
149
|
192
|
caseApplication.setVersion(1);
|
|
150
|
193
|
MsCaseAffiliate affiliate = caseApplication.getAffiliate();
|
|
151
|
194
|
// 保存案件基本信息
|
|
152
|
|
- if(msCaseApplicationMapper.insertSelective(caseApplication)>0){
|
|
|
195
|
+ if (msCaseApplicationMapper.insertSelective(caseApplication) > 0) {
|
|
153
|
196
|
List<MsCaseAttach> caseAttachList = caseApplication.getCaseAttachList();
|
|
154
|
197
|
// 保存案件相关人员
|
|
155
|
|
- if(affiliate !=null) {
|
|
|
198
|
+ if (affiliate != null) {
|
|
156
|
199
|
// 设置申请人
|
|
157
|
|
- if( StrUtil.isNotEmpty(affiliate.getApplicationOrganName())){
|
|
|
200
|
+ if (StrUtil.isNotEmpty(affiliate.getApplicationOrganName())) {
|
|
158
|
201
|
// 组装申请机构
|
|
159
|
202
|
insertDept(affiliate);
|
|
160
|
|
- // 查询申请人角色id
|
|
161
|
|
- Long roleId = roleMapper.selectRoleIdByName("申请人");
|
|
162
|
|
- // 根据代理人手机号去用户表查询,有修改,么有新增
|
|
163
|
|
- SysUser agentUser = userMapper.selectUserByPhone(affiliate.getContactTelphoneAgent());
|
|
164
|
|
- // 代理人为空,新增代理人
|
|
165
|
|
- if(agentUser==null){
|
|
166
|
|
- agentUser = new SysUser();
|
|
167
|
|
- agentUser.setUserName(affiliate.getContactTelphoneAgent());
|
|
168
|
|
- agentUser.setNickName(affiliate.getNameAgent());
|
|
169
|
|
- agentUser.setPhonenumber(affiliate.getContactTelphoneAgent());
|
|
170
|
|
- agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
|
|
171
|
|
- agentUser.setDeptId(Long.valueOf(affiliate.getApplicationOrganId()));
|
|
172
|
|
- userMapper.insertUser(agentUser);
|
|
173
|
|
- userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
|
|
174
|
|
- }else if(null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())){
|
|
175
|
|
- if (null != agentUser.getDept() && StrUtil.isNotEmpty(agentUser.getDept().getDeptName())) {
|
|
176
|
|
- throw new ServiceException( "该申请代理人已在【" + agentUser.getDept().getDeptName() + "】申请机构下存在,请检查填写信息是否正确");
|
|
177
|
|
- } else {
|
|
178
|
|
- throw new ServiceException("该申请代理人已存在,与申请机构不匹配,请检查填写信息是否正确");
|
|
179
|
|
- }
|
|
180
|
|
- }else if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())) {
|
|
181
|
|
- // 同步用户表和案件关联人表的手机号和名称
|
|
182
|
|
- affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber())?agentUser.getPhonenumber():affiliate.getContactTelphoneAgent());
|
|
183
|
|
- affiliate.setNameAgent(agentUser.getNickName());
|
|
184
|
|
- affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail())?agentUser.getEmail():affiliate.getAgentEmail());
|
|
185
|
|
- List<Long> longList = new ArrayList<>();
|
|
186
|
|
- // 新增角色为申请人
|
|
187
|
|
- if (CollectionUtil.isNotEmpty(agentUser.getRoles())) {
|
|
188
|
|
- longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
|
|
189
|
|
- if (!longList.contains(roleId)) {
|
|
190
|
|
- userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
|
|
191
|
|
- }
|
|
192
|
|
- } else {
|
|
193
|
|
- userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
|
|
194
|
|
- }
|
|
|
203
|
+ // 新增申请机构代理人
|
|
|
204
|
+ insertAgentUser(affiliate);
|
|
|
205
|
+ }
|
|
|
206
|
+ // 压缩包导入,则根据身份证号获取性别和出生日期
|
|
|
207
|
+ String identityNum = affiliate.getRespondentIdentityNum();
|
|
|
208
|
+ if (caseApplication.isImportFlag() && StrUtil.isNotEmpty(identityNum)) {
|
|
195
|
209
|
|
|
|
210
|
+ identityNum = identityNum.replace("\n", "");
|
|
|
211
|
+ Map<String, String> identityNumMap = IdCardUtils.getBirAgeSex(identityNum);
|
|
|
212
|
+ String birthday = identityNumMap.get("birthday");
|
|
|
213
|
+ if (StrUtil.isNotEmpty(birthday)) {
|
|
|
214
|
+ Date birthdayDate = null;
|
|
|
215
|
+ try {
|
|
|
216
|
+ birthdayDate = yyyymmddFormat.parse(birthday);
|
|
|
217
|
+ } catch (Exception e) {
|
|
|
218
|
+ e.printStackTrace();
|
|
|
219
|
+ }
|
|
|
220
|
+ affiliate.setRespondentBirth(birthdayDate);
|
|
196
|
221
|
}
|
|
|
222
|
+ //从身份证抓取性别
|
|
|
223
|
+ affiliate.setRespondentSex(identityNumMap.get("sexCode"));
|
|
|
224
|
+ }
|
|
|
225
|
+ if (StrUtil.isNotEmpty(affiliate.getAgentEmail())) {
|
|
|
226
|
+ affiliate.setAgentEmail(affiliate.getAgentEmail().replace("\n", "").replaceAll("\\s", ""));
|
|
|
227
|
+ }
|
|
|
228
|
+ if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) {
|
|
|
229
|
+ affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", ""));
|
|
197
|
230
|
}
|
|
198
|
231
|
affiliate.setCaseAppliId(caseApplication.getId());
|
|
199
|
232
|
msCaseAffiliateMapper.insert(affiliate);
|
|
200
|
233
|
}
|
|
201
|
234
|
// 保存案件附件
|
|
202
|
|
- if(CollectionUtil.isNotEmpty(caseAttachList)){
|
|
|
235
|
+
|
|
|
236
|
+ if (CollectionUtil.isNotEmpty(caseAttachList) && !caseApplication.isImportFlag()) {
|
|
203
|
237
|
for (MsCaseAttach caseAttach : caseAttachList) {
|
|
204
|
238
|
caseAttach.setCaseAppliId(caseApplication.getId());
|
|
205
|
239
|
// 修改案件附件
|
|
206
|
240
|
msCaseAttachMapper.updateCaseAttach(caseAttach);
|
|
207
|
241
|
}
|
|
208
|
|
-// for(MsCaseAttach caseAttach:caseAttachList){
|
|
209
|
|
-// caseAttach.setCaseAppliId(caseApplication.getId());
|
|
210
|
|
-//
|
|
211
|
|
-// }
|
|
212
|
|
-// msCaseAttachMapper.batchSave(caseAttachList);
|
|
213
|
242
|
}
|
|
|
243
|
+ List<MsColumnValueVO> columnValueList = caseApplication.getColumnValueList();
|
|
|
244
|
+ if (CollectionUtil.isNotEmpty(columnValueList)) {
|
|
|
245
|
+ for (MsColumnValueVO msColumnValueVO : columnValueList) {
|
|
|
246
|
+ msColumnValueVO.setCaseId(caseApplication.getId());
|
|
|
247
|
+ }
|
|
|
248
|
+ columnValueMapper.batchSave(columnValueList);
|
|
|
249
|
+ }
|
|
|
250
|
+ CaseLogUtils.insertCaseLog(caseApplication.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "");
|
|
214
|
251
|
return 1;
|
|
215
|
252
|
}
|
|
216
|
253
|
|
|
217
|
254
|
return 0;
|
|
218
|
255
|
}
|
|
219
|
256
|
|
|
|
257
|
+ /**
|
|
|
258
|
+ * 计算仲裁费用
|
|
|
259
|
+ *
|
|
|
260
|
+ * @param caseApplication
|
|
|
261
|
+ */
|
|
|
262
|
+ private void setFeePayableMethod(MsCaseApplicationVO caseApplication) {
|
|
|
263
|
+ if (caseApplication.getCaseSubjectAmount() != null) {
|
|
|
264
|
+ BigDecimal feeRate = new BigDecimal("0.01");
|
|
|
265
|
+ BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2, RoundingMode.HALF_UP);
|
|
|
266
|
+ caseApplication.setFeePayable(feePayable);
|
|
|
267
|
+ }
|
|
|
268
|
+ }
|
|
|
269
|
+
|
|
|
270
|
+ /**
|
|
|
271
|
+ * 修改案件
|
|
|
272
|
+ *
|
|
|
273
|
+ * @param caseApplication
|
|
|
274
|
+ * @return
|
|
|
275
|
+ */
|
|
|
276
|
+ @Transactional
|
|
|
277
|
+ @Override
|
|
|
278
|
+ public AjaxResult update(MsCaseApplicationVO caseApplication) {
|
|
|
279
|
+ // 计算仲裁费用
|
|
|
280
|
+ setFeePayableMethod(caseApplication);
|
|
|
281
|
+ caseApplication.setUpdateBy(SecurityUtils.getUsername());
|
|
|
282
|
+ caseApplication.setUpdateTime(new Date());
|
|
|
283
|
+ // 为null则不更新
|
|
|
284
|
+ msCaseApplicationMapper.updateByPrimaryKeySelective(caseApplication);
|
|
|
285
|
+ MsCaseAffiliate affiliate = caseApplication.getAffiliate();
|
|
|
286
|
+ if (affiliate != null) {
|
|
|
287
|
+ affiliate.setCaseAppliId(caseApplication.getId());
|
|
|
288
|
+ // 设置申请人
|
|
|
289
|
+ if (StrUtil.isNotEmpty(affiliate.getApplicationOrganName())) {
|
|
|
290
|
+ // 组装申请机构
|
|
|
291
|
+ insertDept(affiliate);
|
|
|
292
|
+ // 新增申请机构代理人
|
|
|
293
|
+ insertAgentUser(affiliate);
|
|
|
294
|
+ }
|
|
|
295
|
+ msCaseAffiliateMapper.updateByPrimaryKeySelective(affiliate);
|
|
|
296
|
+ }
|
|
|
297
|
+ if (CollectionUtil.isNotEmpty(caseApplication.getCaseAttachList())) {
|
|
|
298
|
+ for (MsCaseAttach caseAttach : caseApplication.getCaseAttachList()) {
|
|
|
299
|
+ caseAttach.setCaseAppliId(caseApplication.getId());
|
|
|
300
|
+ msCaseAttachMapper.updateCaseAttach(caseAttach);
|
|
|
301
|
+ }
|
|
|
302
|
+ }
|
|
|
303
|
+ if (CollectionUtil.isNotEmpty(caseApplication.getColumnValueList())) {
|
|
|
304
|
+ columnValueMapper.batchUpdate(caseApplication.getColumnValueList());
|
|
|
305
|
+ }
|
|
|
306
|
+ return AjaxResult.success("修改成功");
|
|
|
307
|
+ }
|
|
|
308
|
+
|
|
|
309
|
+ /**
|
|
|
310
|
+ * 压缩包导入
|
|
|
311
|
+ *
|
|
|
312
|
+ * @param file 附件
|
|
|
313
|
+ * @param templateId 模板id
|
|
|
314
|
+ * @return
|
|
|
315
|
+ */
|
|
|
316
|
+ @Transactional
|
|
|
317
|
+ @Override
|
|
|
318
|
+ public AjaxResult uploadCaseZipFile(MultipartFile file, Long templateId) {
|
|
|
319
|
+ UUID uuid = UUID.randomUUID();
|
|
|
320
|
+ // todo 压缩包解压路径
|
|
|
321
|
+ String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + uuid + "/";
|
|
|
322
|
+// String targetPath = "D:/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
|
|
|
323
|
+ File zipFile = null;
|
|
|
324
|
+ InputStream ins = null;
|
|
|
325
|
+ try {
|
|
|
326
|
+ ins = file.getInputStream();
|
|
|
327
|
+ //上传的压缩包保存的路径
|
|
|
328
|
+ // todo
|
|
|
329
|
+ String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
|
|
|
330
|
+// String savePath = "D:/home/ruoyi/uploadPath/upload/zipFile/";
|
|
|
331
|
+ String saveName = uuid + "_" + file.getOriginalFilename();
|
|
|
332
|
+ zipFile = new File(savePath + saveName);
|
|
|
333
|
+ inputChangeToFile(ins, zipFile);
|
|
|
334
|
+ } catch (IOException e) {
|
|
|
335
|
+ e.printStackTrace();
|
|
|
336
|
+ }
|
|
|
337
|
+ if (zipFile == null) {
|
|
|
338
|
+ return AjaxResult.error("压缩包上传失败");
|
|
|
339
|
+ }
|
|
|
340
|
+ //解压缩上传的压缩包
|
|
|
341
|
+ boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
|
|
|
342
|
+ if (!unzipSuccess) {
|
|
|
343
|
+ // 解压失败
|
|
|
344
|
+ return AjaxResult.error("解压失败");
|
|
|
345
|
+ }
|
|
|
346
|
+ // 查询抓取规则
|
|
|
347
|
+ List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(templateId);
|
|
|
348
|
+ if (CollectionUtil.isEmpty(fatchRuleList)) {
|
|
|
349
|
+ return AjaxResult.error("未设置抓取规则");
|
|
|
350
|
+ }
|
|
|
351
|
+ Map<Integer, List<FatchRule>> defaultRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
|
|
|
352
|
+
|
|
|
353
|
+ // 判断解压后的文件夹是否存在
|
|
|
354
|
+ File directory = new File(targetPath);
|
|
|
355
|
+ if (!directory.exists()) {
|
|
|
356
|
+ return AjaxResult.error("文件不存在");
|
|
|
357
|
+ }
|
|
|
358
|
+ if (!directory.isDirectory() || directory.listFiles() == null) {
|
|
|
359
|
+ return AjaxResult.error("未找到文件夹");
|
|
|
360
|
+ }
|
|
|
361
|
+ File[] files = directory.listFiles();
|
|
|
362
|
+ if (files == null) {
|
|
|
363
|
+ return AjaxResult.error("压缩包格式不正确");
|
|
|
364
|
+ }
|
|
|
365
|
+ // 抓取规则,0-内置字段,1-自定义字段
|
|
|
366
|
+ Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
|
|
|
367
|
+ // 在系统表中查询案件内置字段
|
|
|
368
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
369
|
+ sysDictData.setDictType("case_built_type");
|
|
|
370
|
+ List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
|
|
|
371
|
+ if (CollectionUtil.isEmpty(dictDataList)) {
|
|
|
372
|
+ return AjaxResult.error("未找到案件内置字段");
|
|
|
373
|
+ }
|
|
|
374
|
+ //查询批次号
|
|
|
375
|
+ String batchNumber = getBatchNumber();
|
|
|
376
|
+ // 抓取内容
|
|
|
377
|
+ Map<String, String> fatchMap = new HashMap<>();
|
|
|
378
|
+ for (File outFile : files) {
|
|
|
379
|
+ if (!outFile.isDirectory() || outFile.listFiles() == null) {
|
|
|
380
|
+ continue;
|
|
|
381
|
+ }
|
|
|
382
|
+ // 一个infile对应一个案件
|
|
|
383
|
+ for (File inFile : outFile.listFiles()) {
|
|
|
384
|
+ // 所有的文件,fileMap<fileName,filePath>
|
|
|
385
|
+ Map<String, String> fileMap = findFile(inFile);
|
|
|
386
|
+ if (fileMap != null && !fileMap.isEmpty()) {
|
|
|
387
|
+ // 根据抓取规则设置字段值
|
|
|
388
|
+ for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
|
|
|
389
|
+ getFatchContent(fileMap, entry.getKey(), fatchMap, entry.getValue());
|
|
|
390
|
+ }
|
|
|
391
|
+ if (fatchMap.size() > 0) {
|
|
|
392
|
+ // 组装案件信息
|
|
|
393
|
+ MsCaseApplicationVO caseApplicationVO = new MsCaseApplicationVO();
|
|
|
394
|
+ MsCaseApplication caseApplication = new MsCaseApplication();
|
|
|
395
|
+ MsCaseAffiliate affiliate = new MsCaseAffiliate();
|
|
|
396
|
+ List<MsCaseAttach> attachList = new ArrayList<>();
|
|
|
397
|
+ List<MsColumnValueVO> columnValueList = new ArrayList<>();
|
|
|
398
|
+ caseApplication.setId(IdWorkerUtil.getId());
|
|
|
399
|
+ caseApplication.setTemplateId(templateId);
|
|
|
400
|
+ caseApplication.setBatchNumber(batchNumber);
|
|
|
401
|
+ // 组装案件内置字段
|
|
|
402
|
+ for (SysDictData dictData : dictDataList) {
|
|
|
403
|
+ // 主表字段
|
|
|
404
|
+ if (CASE_BASE_COLUMN.contains(dictData.getDictValue())) {
|
|
|
405
|
+ ObjectFieldUtils.setValue(caseApplication, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()));
|
|
|
406
|
+ } else {
|
|
|
407
|
+ // 相关人员字段
|
|
|
408
|
+ ObjectFieldUtils.setValue(affiliate, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()));
|
|
|
409
|
+ }
|
|
|
410
|
+ }
|
|
|
411
|
+ // 自定义字段,组装columnValue表
|
|
|
412
|
+ if (defaultRuleMap.size() > 0 && defaultRuleMap.containsKey(1)) {
|
|
|
413
|
+ List<FatchRule> columnRules = defaultRuleMap.get(1);
|
|
|
414
|
+ columnRules.forEach(columnRule -> {
|
|
|
415
|
+ MsColumnValueVO columnValue = new MsColumnValueVO();
|
|
|
416
|
+ columnValue.setColumn(columnRule.getColumn());
|
|
|
417
|
+ columnValue.setName(columnRule.getColumnName());
|
|
|
418
|
+ columnValue.setValue(fatchMap.get(columnRule.getColumnName()));
|
|
|
419
|
+ columnValue.setIsDefault(1);
|
|
|
420
|
+ columnValue.setCaseId(caseApplication.getId());
|
|
|
421
|
+ columnValueList.add(columnValue);
|
|
|
422
|
+ });
|
|
|
423
|
+ }
|
|
|
424
|
+ BeanUtil.copyProperties(caseApplication, caseApplicationVO);
|
|
|
425
|
+ // 组装附件
|
|
|
426
|
+ buildAttach(fileMap, caseApplicationVO, attachList);
|
|
|
427
|
+ caseApplicationVO.setAffiliate(affiliate);
|
|
|
428
|
+ caseApplicationVO.setCaseAttachList(attachList);
|
|
|
429
|
+ caseApplicationVO.setColumnValueList(columnValueList);
|
|
|
430
|
+ caseApplicationVO.setImportFlag(true);
|
|
|
431
|
+ insert(caseApplicationVO);
|
|
|
432
|
+
|
|
|
433
|
+ }
|
|
|
434
|
+ }
|
|
|
435
|
+ }
|
|
|
436
|
+
|
|
|
437
|
+ }
|
|
|
438
|
+ return AjaxResult.success();
|
|
|
439
|
+ }
|
|
|
440
|
+
|
|
|
441
|
+ /**
|
|
|
442
|
+ * 组装附件
|
|
|
443
|
+ *
|
|
|
444
|
+ * @param fileMap
|
|
|
445
|
+ * @param caseApplication
|
|
|
446
|
+ * @param attachList
|
|
|
447
|
+ */
|
|
|
448
|
+ private void buildAttach(Map<String, String> fileMap, MsCaseApplicationVO caseApplication, List<MsCaseAttach> attachList) {
|
|
|
449
|
+ for (Map.Entry<String, String> entry : fileMap.entrySet()) {
|
|
|
450
|
+ String fileUrl = entry.getValue();
|
|
|
451
|
+ if (StrUtil.isEmpty(fileUrl)) {
|
|
|
452
|
+ continue;
|
|
|
453
|
+ }
|
|
|
454
|
+ // 上传
|
|
|
455
|
+ // String filePath = RuoYiConfig.getUploadPath();
|
|
|
456
|
+ MsCaseAttach caseAttach = new MsCaseAttach();
|
|
|
457
|
+ caseAttach.setCaseAppliId(caseApplication.getId());
|
|
|
458
|
+ caseAttach.setAnnexPath(entry.getValue());
|
|
|
459
|
+ caseAttach.setAnnexName(entry.getKey());
|
|
|
460
|
+ // todo
|
|
|
461
|
+// if (StrUtil.isNotEmpty(fileUrl)) {
|
|
|
462
|
+// String fileName = fileUrl.replace(filePath, "/profile/upload");
|
|
|
463
|
+// caseAttach.setAnnexName(entry.getKey());
|
|
|
464
|
+// }
|
|
|
465
|
+ // 申请人提供的证据材料
|
|
|
466
|
+ caseAttach.setAnnexType(2);
|
|
|
467
|
+ attachList.add(caseAttach);
|
|
|
468
|
+ if (fileUrl.contains("仲裁申请书")) {
|
|
|
469
|
+ MsCaseAttach applyFile = new MsCaseAttach();
|
|
|
470
|
+ BeanUtil.copyProperties(caseAttach, applyFile);
|
|
|
471
|
+ applyFile.setAnnexType(1);
|
|
|
472
|
+ attachList.add(applyFile);
|
|
|
473
|
+ }
|
|
|
474
|
+
|
|
|
475
|
+ }
|
|
|
476
|
+ }
|
|
|
477
|
+
|
|
|
478
|
+ /**
|
|
|
479
|
+ * 获取抓取内容
|
|
|
480
|
+ *
|
|
|
481
|
+ * @param andConvertPDF 文件路径map
|
|
|
482
|
+ * @param mapKey 文件名
|
|
|
483
|
+ * @param map 抓取内容map
|
|
|
484
|
+ * @param fatchRules 抓取规则
|
|
|
485
|
+ */
|
|
|
486
|
+ private void getFatchContent(Map<String, String> andConvertPDF, String mapKey, Map<String, String> map, List<FatchRule> fatchRules) {
|
|
|
487
|
+ String fileURL = null;
|
|
|
488
|
+ for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
|
|
|
489
|
+ if (entry.getKey().contains(mapKey)) {
|
|
|
490
|
+ fileURL = entry.getValue();
|
|
|
491
|
+ }
|
|
|
492
|
+ }
|
|
|
493
|
+ if (StrUtil.isEmpty(fileURL)) {
|
|
|
494
|
+ return;
|
|
|
495
|
+ }
|
|
|
496
|
+ if (fileURL.endsWith("txt")) {
|
|
|
497
|
+ String readerFile = ReadFileUtils.readerTxtFile(fileURL);
|
|
|
498
|
+ OCRUtils.fatchRuleGetContent(readerFile, fatchRules, map);
|
|
|
499
|
+ } else if (fileURL.endsWith("doc") || fileURL.endsWith("docx")) {
|
|
|
500
|
+ // doc,docx,text识别内容
|
|
|
501
|
+ String readerFile = null;
|
|
|
502
|
+ try {
|
|
|
503
|
+ readerFile = ReadFileUtils.readWord(fileURL);
|
|
|
504
|
+ } catch (Exception e) {
|
|
|
505
|
+ e.printStackTrace();
|
|
|
506
|
+ }
|
|
|
507
|
+ OCRUtils.fatchRuleGetContent(readerFile, fatchRules, map);
|
|
|
508
|
+
|
|
|
509
|
+ } else if (fileURL.endsWith("pdf")) {
|
|
|
510
|
+ //获取文件的页数
|
|
|
511
|
+ int fileNumPage = getFileNumPage(fileURL);
|
|
|
512
|
+ //文件转成base64
|
|
|
513
|
+ String base64 = OCRUtils.pdfConvertBase64(fileURL);
|
|
|
514
|
+ if (base64 == null) {
|
|
|
515
|
+ throw new ServiceException("pdf转base64失败");
|
|
|
516
|
+ // return false;
|
|
|
517
|
+ }
|
|
|
518
|
+ StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
|
|
|
519
|
+ for (int i = 1; i <= fileNumPage; i++) {
|
|
|
520
|
+ //对接腾讯云接口.识别里面的数据
|
|
|
521
|
+ String text = OCRUtils.pdfIdentifyText(base64, i, fatchRules);
|
|
|
522
|
+ ocrText.append(text); // 拼接当前的字符串
|
|
|
523
|
+
|
|
|
524
|
+
|
|
|
525
|
+ }
|
|
|
526
|
+ // 根据抓取规则截取内容
|
|
|
527
|
+ OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules, map);
|
|
|
528
|
+ }
|
|
|
529
|
+
|
|
|
530
|
+
|
|
|
531
|
+ }
|
|
|
532
|
+
|
|
|
533
|
+ /**
|
|
|
534
|
+ * 获取pdf页数
|
|
|
535
|
+ *
|
|
|
536
|
+ * @param pdfUrl
|
|
|
537
|
+ * @return
|
|
|
538
|
+ */
|
|
|
539
|
+ private static int getFileNumPage(String pdfUrl) {
|
|
|
540
|
+ File pdfFile = new File(pdfUrl);
|
|
|
541
|
+ int pageCount = 0;
|
|
|
542
|
+ try (PDDocument document = PDDocument.load(pdfFile)) {
|
|
|
543
|
+ pageCount = document.getNumberOfPages();
|
|
|
544
|
+ } catch (IOException e) {
|
|
|
545
|
+ e.printStackTrace();
|
|
|
546
|
+ }
|
|
|
547
|
+ return pageCount;
|
|
|
548
|
+ }
|
|
|
549
|
+
|
|
|
550
|
+ /**
|
|
|
551
|
+ * 查找文件
|
|
|
552
|
+ *
|
|
|
553
|
+ * @param directory
|
|
|
554
|
+ * @param
|
|
|
555
|
+ * @return
|
|
|
556
|
+ */
|
|
|
557
|
+ private Map<String, String> findFile(File directory) {
|
|
|
558
|
+ Map<String, String> filePathMap = new HashMap<>();
|
|
|
559
|
+ if (directory.isFile()) {
|
|
|
560
|
+ String path = "";
|
|
|
561
|
+ // 如果传入的参数是一个文件
|
|
|
562
|
+ path = directory.getAbsolutePath();
|
|
|
563
|
+ filePathMap.put(directory.getName(), path);
|
|
|
564
|
+
|
|
|
565
|
+ } else if (directory.isDirectory()) {
|
|
|
566
|
+ searchFile(directory, filePathMap);
|
|
|
567
|
+ } else {
|
|
|
568
|
+ return null;
|
|
|
569
|
+ }
|
|
|
570
|
+ return filePathMap;
|
|
|
571
|
+ }
|
|
|
572
|
+
|
|
|
573
|
+ /**
|
|
|
574
|
+ * 递归查找文件夹
|
|
|
575
|
+ *
|
|
|
576
|
+ * @param directory
|
|
|
577
|
+ * @param filePathMap
|
|
|
578
|
+ */
|
|
|
579
|
+ public static void searchFile(File directory, Map<String, String> filePathMap) {
|
|
|
580
|
+ File[] files = directory.listFiles();
|
|
|
581
|
+
|
|
|
582
|
+ if (files != null) {
|
|
|
583
|
+ for (File file : files) {
|
|
|
584
|
+ if (file.getName().contains("zip") || file.getName().contains("rar")) {
|
|
|
585
|
+ continue;
|
|
|
586
|
+ }
|
|
|
587
|
+ if (file.isFile()) {
|
|
|
588
|
+
|
|
|
589
|
+ filePathMap.put(file.getName(), file.getAbsolutePath());
|
|
|
590
|
+ } else if (file.isDirectory()) {
|
|
|
591
|
+ // 如果是目录,递归查找
|
|
|
592
|
+ searchFile(file, filePathMap);
|
|
|
593
|
+ }
|
|
|
594
|
+ }
|
|
|
595
|
+ }
|
|
|
596
|
+ }
|
|
|
597
|
+
|
|
|
598
|
+ public void inputChangeToFile(InputStream instream, File file) {
|
|
|
599
|
+ try {
|
|
|
600
|
+ OutputStream outStr = new FileOutputStream(file);
|
|
|
601
|
+ int bytesRead = 0;
|
|
|
602
|
+ byte[] buffer = new byte[8192];
|
|
|
603
|
+ while ((bytesRead = instream.read(buffer, 0, 1024)) != -1) {
|
|
|
604
|
+ outStr.write(buffer, 0, bytesRead);
|
|
|
605
|
+ }
|
|
|
606
|
+ outStr.flush();
|
|
|
607
|
+ outStr.close();
|
|
|
608
|
+ instream.close();
|
|
|
609
|
+ } catch (Exception e) {
|
|
|
610
|
+ e.printStackTrace();
|
|
|
611
|
+ }
|
|
|
612
|
+ }
|
|
|
613
|
+
|
|
|
614
|
+ /**
|
|
|
615
|
+ * 新增申请机构代理人
|
|
|
616
|
+ *
|
|
|
617
|
+ * @param affiliate
|
|
|
618
|
+ */
|
|
|
619
|
+ @Transactional
|
|
|
620
|
+ public void insertAgentUser(MsCaseAffiliate affiliate) {
|
|
|
621
|
+ // 查询申请人角色id
|
|
|
622
|
+ Long roleId = roleMapper.selectRoleIdByName("申请人");
|
|
|
623
|
+ // 根据代理人手机号去用户表查询,有修改,么有新增
|
|
|
624
|
+ SysUser agentUser = userMapper.selectUserByPhone(affiliate.getContactTelphoneAgent());
|
|
|
625
|
+ // 代理人为空,新增代理人
|
|
|
626
|
+ if (agentUser == null) {
|
|
|
627
|
+ agentUser = new SysUser();
|
|
|
628
|
+ agentUser.setUserName(affiliate.getContactTelphoneAgent());
|
|
|
629
|
+ agentUser.setNickName(affiliate.getNameAgent());
|
|
|
630
|
+ agentUser.setPhonenumber(affiliate.getContactTelphoneAgent());
|
|
|
631
|
+ agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
|
|
|
632
|
+ agentUser.setDeptId(Long.valueOf(affiliate.getApplicationOrganId()));
|
|
|
633
|
+ userMapper.insertUser(agentUser);
|
|
|
634
|
+ userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
|
|
|
635
|
+ } else if (null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())) {
|
|
|
636
|
+ if (null != agentUser.getDept() && StrUtil.isNotEmpty(agentUser.getDept().getDeptName())) {
|
|
|
637
|
+ throw new ServiceException("该申请代理人已在【" + agentUser.getDept().getDeptName() + "】申请机构下存在,请检查填写信息是否正确");
|
|
|
638
|
+ } else {
|
|
|
639
|
+ throw new ServiceException("该申请代理人已存在,与申请机构不匹配,请检查填写信息是否正确");
|
|
|
640
|
+ }
|
|
|
641
|
+ } else if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())) {
|
|
|
642
|
+ // 同步用户表和案件关联人表的手机号和名称
|
|
|
643
|
+ affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber()) ? agentUser.getPhonenumber() : affiliate.getContactTelphoneAgent());
|
|
|
644
|
+ affiliate.setNameAgent(agentUser.getNickName());
|
|
|
645
|
+ affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail()) ? agentUser.getEmail() : affiliate.getAgentEmail());
|
|
|
646
|
+ List<Long> longList = new ArrayList<>();
|
|
|
647
|
+ // 新增角色为申请人
|
|
|
648
|
+ if (CollectionUtil.isNotEmpty(agentUser.getRoles())) {
|
|
|
649
|
+ longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
|
|
|
650
|
+ if (!longList.contains(roleId)) {
|
|
|
651
|
+ userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
|
|
|
652
|
+ }
|
|
|
653
|
+ } else {
|
|
|
654
|
+ userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
|
|
|
655
|
+ }
|
|
|
656
|
+
|
|
|
657
|
+ }
|
|
|
658
|
+ }
|
|
|
659
|
+
|
|
220
|
660
|
/**
|
|
221
|
661
|
* 新增部门
|
|
|
662
|
+ *
|
|
222
|
663
|
* @param affiliate
|
|
223
|
664
|
*/
|
|
224
|
665
|
@Transactional
|
|
225
|
|
- void insertDept(MsCaseAffiliate affiliate) {
|
|
|
666
|
+ void insertDept(MsCaseAffiliate affiliate) {
|
|
226
|
667
|
// 查询所有的组织机构,组装成map
|
|
227
|
668
|
List<SysDept> deptList = sysDeptMapper.selectDeptList(new SysDept());
|
|
228
|
669
|
if (CollectionUtil.isEmpty(deptList)) {
|
|
|
@@ -252,6 +693,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
252
|
693
|
|
|
253
|
694
|
/**
|
|
254
|
695
|
* 获取案件编码
|
|
|
696
|
+ *
|
|
255
|
697
|
* @return
|
|
256
|
698
|
*/
|
|
257
|
699
|
private String getCaseNum() {
|
|
|
@@ -265,7 +707,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
265
|
707
|
if (null == maxCaseNum) {
|
|
266
|
708
|
caseNum = caseNum + "00001";
|
|
267
|
709
|
} else {
|
|
268
|
|
- maxCaseNum=maxCaseNum+1;
|
|
|
710
|
+ maxCaseNum = maxCaseNum + 1;
|
|
269
|
711
|
caseNum = caseNum + String.format("%05d", maxCaseNum);
|
|
270
|
712
|
}
|
|
271
|
713
|
return caseNum;
|
|
|
@@ -273,14 +715,15 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
273
|
715
|
|
|
274
|
716
|
/**
|
|
275
|
717
|
* 获取批次号
|
|
|
718
|
+ *
|
|
276
|
719
|
* @return
|
|
277
|
720
|
*/
|
|
278
|
721
|
private String getBatchNumber() {
|
|
279
|
722
|
Integer batchNumber = msCaseApplicationMapper.selectMaxBatchNumber();
|
|
280
|
|
- if(batchNumber==null){
|
|
281
|
|
- return "000001";
|
|
282
|
|
- }else {
|
|
283
|
|
- return String.format("%06d", batchNumber+1);
|
|
|
723
|
+ if (batchNumber == null) {
|
|
|
724
|
+ return "000001";
|
|
|
725
|
+ } else {
|
|
|
726
|
+ return String.format("%06d", batchNumber + 1);
|
|
284
|
727
|
}
|
|
285
|
728
|
|
|
286
|
729
|
}
|