|
|
@@ -7,9 +7,13 @@ import com.ruoyi.common.config.RuoYiConfig;
|
|
7
|
7
|
import com.ruoyi.common.constant.FileTransformation;
|
|
8
|
8
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
9
|
9
|
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
|
|
10
|
+import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
11
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
10
|
12
|
import com.ruoyi.common.exception.EsignDemoException;
|
|
11
|
13
|
import com.ruoyi.common.utils.SealUtil;
|
|
12
|
14
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
15
|
+import com.ruoyi.system.mapper.SysDeptMapper;
|
|
|
16
|
+import com.ruoyi.system.mapper.SysUserMapper;
|
|
13
|
17
|
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
|
|
14
|
18
|
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
|
|
15
|
19
|
import com.ruoyi.wisdomarbitrate.domain.SealManage;
|
|
|
@@ -27,10 +31,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
27
|
31
|
import java.io.File;
|
|
28
|
32
|
import java.io.IOException;
|
|
29
|
33
|
import java.time.LocalDate;
|
|
30
|
|
-import java.util.ArrayList;
|
|
31
|
|
-import java.util.Date;
|
|
32
|
|
-import java.util.List;
|
|
33
|
|
-import java.util.UUID;
|
|
|
34
|
+import java.util.*;
|
|
34
|
35
|
|
|
35
|
36
|
@Service
|
|
36
|
37
|
public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
|
@@ -41,6 +42,10 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
41
|
42
|
private CaseAttachMapper caseAttachMapper;
|
|
42
|
43
|
@Autowired
|
|
43
|
44
|
private SealManageMapper sealManageMapper;
|
|
|
45
|
+ @Autowired
|
|
|
46
|
+ private SysDeptMapper sysDeptMapper;
|
|
|
47
|
+ @Autowired
|
|
|
48
|
+ private SysUserMapper sysUserMapper;
|
|
44
|
49
|
|
|
45
|
50
|
|
|
46
|
51
|
@Override
|
|
|
@@ -106,7 +111,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
106
|
111
|
}
|
|
107
|
112
|
|
|
108
|
113
|
@Override
|
|
109
|
|
- public AjaxResult sealUpload(Long id, MultipartFile file) {
|
|
|
114
|
+ public AjaxResult sealUpload(Long id, String sealName, MultipartFile file) {
|
|
110
|
115
|
try {
|
|
111
|
116
|
if (file.isEmpty()) {
|
|
112
|
117
|
return AjaxResult.error("请选择要上传的文件");
|
|
|
@@ -133,8 +138,8 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
133
|
138
|
startIndex += prefix.length();
|
|
134
|
139
|
String annexPath = "home/ruoyi/uploadPath" + fileName.substring(startIndex);
|
|
135
|
140
|
//创建机构图片印章
|
|
136
|
|
- // String annexPath = "D:\\develop\\2.jpg";
|
|
137
|
|
- String sealName = "自定义" + UUID.randomUUID() + ""; //自定义印章印章名称不能重复,所以用UUID确保唯一性
|
|
|
141
|
+ //String annexPath = "D:\\develop\\2.jpg";
|
|
|
142
|
+
|
|
138
|
143
|
EsignHttpResponse response = SignAward.createOrgByImage(identify, sealName, annexPath);
|
|
139
|
144
|
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
|
|
140
|
145
|
int code = jsonObject.getIntValue("code");
|
|
|
@@ -152,7 +157,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
152
|
157
|
return AjaxResult.success("上传成功");
|
|
153
|
158
|
}
|
|
154
|
159
|
}
|
|
155
|
|
- return AjaxResult.error("公章上传失败,请检查参数");
|
|
|
160
|
+ return AjaxResult.error(jsonObject.getString("message"));
|
|
156
|
161
|
}
|
|
157
|
162
|
return AjaxResult.error("企业用户未授予资源管理权限");
|
|
158
|
163
|
}
|
|
|
@@ -257,14 +262,15 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
257
|
262
|
List<SealListVO> sealListVOS = new ArrayList<>();
|
|
258
|
263
|
if (selectSealList != null && selectSealList.size() > 0) {
|
|
259
|
264
|
for (SealManage sealManage1 : selectSealList) {
|
|
260
|
|
- Integer sealStatus = sealManage1.getSealStatus();
|
|
261
|
|
- if (sealStatus == 1) { //审核状态为启用
|
|
262
|
|
- SealListVO sealListVO = new SealListVO();
|
|
263
|
|
- sealListVO.setSealId(sealManage1.getSealId());
|
|
264
|
|
- sealListVO.setSealName(sealManage1.getSealName());
|
|
265
|
|
- sealListVO.setSealStatus(sealManage1.getSealStatus());
|
|
|
265
|
+ SealListVO sealListVO = new SealListVO();
|
|
|
266
|
+ sealListVO.setId(sealManage1.getId());
|
|
|
267
|
+ sealListVO.setSealId(sealManage1.getSealId());
|
|
|
268
|
+ sealListVO.setSealName(sealManage1.getSealName());
|
|
|
269
|
+ sealListVO.setSealStatus(sealManage1.getSealStatus());
|
|
|
270
|
+ Integer annexId = sealManage1.getAnnexId();
|
|
|
271
|
+ if (annexId != null) {
|
|
266
|
272
|
//根据附件id查询路径
|
|
267
|
|
- CaseAttach caseAttach = caseAttachMapper.queryAnnexById(sealManage1.getAnnexId());
|
|
|
273
|
+ CaseAttach caseAttach = caseAttachMapper.queryAnnexById(annexId);
|
|
268
|
274
|
String annexName = caseAttach.getAnnexName();
|
|
269
|
275
|
String prefix = "/profile";
|
|
270
|
276
|
int startIndex = annexName.indexOf(prefix);
|
|
|
@@ -272,9 +278,12 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
272
|
278
|
String annexPath = "/uploadPath" + annexName.substring(startIndex);
|
|
273
|
279
|
sealListVO.setAnnexPath(annexPath);
|
|
274
|
280
|
sealListVO.setAnnexType(caseAttach.getAnnexType());
|
|
275
|
|
- sealListVO.setIsUse(sealManage1.getIsUse());
|
|
276
|
|
- sealListVOS.add(sealListVO);
|
|
|
281
|
+ } else {
|
|
|
282
|
+ sealListVO.setAnnexPath(null);
|
|
|
283
|
+ sealListVO.setAnnexType(null);
|
|
277
|
284
|
}
|
|
|
285
|
+ sealListVO.setIsUse(sealManage1.getIsUse());
|
|
|
286
|
+ sealListVOS.add(sealListVO);
|
|
278
|
287
|
}
|
|
279
|
288
|
}
|
|
280
|
289
|
return sealListVOS;
|
|
|
@@ -309,8 +318,74 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
|
309
|
318
|
deptIdentify.setIsUse(0); //设置机构默认为未启用
|
|
310
|
319
|
int i = deptIdentifyMapper.insertDeptIdentify(deptIdentify);
|
|
311
|
320
|
if (i > 0) {
|
|
|
321
|
+ //将机构名称保存到部门表里
|
|
|
322
|
+ SysDept sysDept = new SysDept();
|
|
|
323
|
+ sysDept.setDeptName(identifyName);
|
|
|
324
|
+ sysDept.setParentId(0L);
|
|
|
325
|
+ sysDept.setDeptType(1);
|
|
|
326
|
+ int i1 = sysDeptMapper.insertDept(sysDept);
|
|
|
327
|
+ if (i1 > 0) {
|
|
|
328
|
+ //将经办人信息存入到用户表里
|
|
|
329
|
+ Long deptId = sysDept.getDeptId();
|
|
|
330
|
+ SysUser sysUser = new SysUser();
|
|
|
331
|
+ sysUser.setDeptId(deptId);
|
|
|
332
|
+ sysUser.setUserName(generateUniqueUsername());//设置默认的用户名
|
|
|
333
|
+ sysUser.setNickName(operName);
|
|
|
334
|
+ sysUser.setPhonenumber(operPhone);
|
|
|
335
|
+ sysUserMapper.insertUser(sysUser);
|
|
|
336
|
+ }
|
|
|
337
|
+
|
|
312
|
338
|
return AjaxResult.success("新增成功");
|
|
313
|
339
|
}
|
|
314
|
340
|
return AjaxResult.error();
|
|
315
|
341
|
}
|
|
|
342
|
+
|
|
|
343
|
+ @Override
|
|
|
344
|
+ public AjaxResult deleteDeptIdentify(Long id) {
|
|
|
345
|
+ DeptIdentify deptIdentify = new DeptIdentify();
|
|
|
346
|
+ deptIdentify.setId(id);
|
|
|
347
|
+ deptIdentify.setDelFlag(2);
|
|
|
348
|
+ int i = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
|
|
|
349
|
+ if (i > 0) {
|
|
|
350
|
+ return AjaxResult.success("删除成功");
|
|
|
351
|
+ }
|
|
|
352
|
+ return AjaxResult.error();
|
|
|
353
|
+ }
|
|
|
354
|
+
|
|
|
355
|
+ @Override
|
|
|
356
|
+ public AjaxResult updateDeptIdentify(DeptIdentify deptIdentify) {
|
|
|
357
|
+ Long id = deptIdentify.getId();
|
|
|
358
|
+ if (id == null) {
|
|
|
359
|
+ return AjaxResult.error();
|
|
|
360
|
+ }
|
|
|
361
|
+ DeptIdentify deptIdentifyNew = new DeptIdentify();
|
|
|
362
|
+ deptIdentifyNew.setId(id);
|
|
|
363
|
+ List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentifyNew);
|
|
|
364
|
+ if (deptIdentifies != null && deptIdentifies.size() > 0) {
|
|
|
365
|
+ DeptIdentify deptIdentify1 = deptIdentifies.get(0);
|
|
|
366
|
+ if (deptIdentify1.getIdentifyStatus() == 1) {
|
|
|
367
|
+ return AjaxResult.error("已认证的机构不允许修改");
|
|
|
368
|
+ }
|
|
|
369
|
+ int i = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
|
|
|
370
|
+ if (i > 0) {
|
|
|
371
|
+ return AjaxResult.success("修改成功");
|
|
|
372
|
+ }
|
|
|
373
|
+ }
|
|
|
374
|
+ return null;
|
|
|
375
|
+ }
|
|
|
376
|
+
|
|
|
377
|
+ private String generateUniqueUsername() {
|
|
|
378
|
+ final Random random = new Random();
|
|
|
379
|
+ final Set<String> generatedUsernames = new HashSet<>();
|
|
|
380
|
+ while (true) {
|
|
|
381
|
+ int min = 000000; // 最小的六位数
|
|
|
382
|
+ int max = 999999; // 最大的六位数
|
|
|
383
|
+ int randomNum = random.nextInt(max - min + 1) + min;
|
|
|
384
|
+ if (!generatedUsernames.contains(randomNum)) {
|
|
|
385
|
+ generatedUsernames.add(String.valueOf(randomNum));
|
|
|
386
|
+ return String.valueOf(randomNum);
|
|
|
387
|
+ }
|
|
|
388
|
+ }
|
|
|
389
|
+ }
|
|
|
390
|
+
|
|
316
|
391
|
}
|