|
|
@@ -4,13 +4,18 @@ package com.ruoyi.wisdomarbitrate.service.impl;
|
|
4
|
4
|
import cn.hutool.core.collection.CollectionUtil;
|
|
5
|
5
|
import cn.hutool.core.util.IdcardUtil;
|
|
6
|
6
|
import cn.hutool.core.util.StrUtil;
|
|
|
7
|
+import cn.hutool.core.util.ZipUtil;
|
|
7
|
8
|
import com.alibaba.fastjson.JSON;
|
|
8
|
9
|
import com.alibaba.fastjson.JSONArray;
|
|
9
|
10
|
import com.alibaba.fastjson.JSONObject;
|
|
|
11
|
+import com.documents4j.api.DocumentType;
|
|
|
12
|
+import com.documents4j.api.IConverter;
|
|
|
13
|
+import com.documents4j.job.LocalConverter;
|
|
10
|
14
|
import com.google.gson.Gson;
|
|
11
|
15
|
import com.google.gson.JsonArray;
|
|
12
|
16
|
import com.google.gson.JsonObject;
|
|
13
|
17
|
import com.ruoyi.common.annotation.DataScope;
|
|
|
18
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
14
|
19
|
import com.ruoyi.common.constant.CaseApplicationConstants;
|
|
15
|
20
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
16
|
21
|
import com.ruoyi.common.core.domain.entity.*;
|
|
|
@@ -19,6 +24,7 @@ import com.ruoyi.common.enums.UpdateSubmitStatus;
|
|
19
|
24
|
import com.ruoyi.common.exception.EsignDemoException;
|
|
20
|
25
|
import com.ruoyi.common.exception.ServiceException;
|
|
21
|
26
|
import com.ruoyi.common.utils.*;
|
|
|
27
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
22
|
28
|
import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
|
|
23
|
29
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
24
|
30
|
import com.ruoyi.common.utils.thread.ThreadPoolUtil;
|
|
|
@@ -44,11 +50,14 @@ import org.apache.http.entity.StringEntity;
|
|
44
|
50
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
45
|
51
|
import org.apache.http.impl.client.HttpClients;
|
|
46
|
52
|
import org.apache.http.util.EntityUtils;
|
|
|
53
|
+import org.apache.poi.xwpf.usermodel.Document;
|
|
|
54
|
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
47
|
55
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
48
|
56
|
import org.springframework.beans.factory.annotation.Value;
|
|
49
|
57
|
import org.springframework.stereotype.Service;
|
|
50
|
58
|
import org.springframework.transaction.annotation.Transactional;
|
|
51
|
59
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
60
|
+
|
|
52
|
61
|
import java.io.*;
|
|
53
|
62
|
import java.math.BigDecimal;
|
|
54
|
63
|
import java.math.RoundingMode;
|
|
|
@@ -61,6 +70,8 @@ import java.time.ZoneId;
|
|
61
|
70
|
import java.util.*;
|
|
62
|
71
|
import java.util.regex.Pattern;
|
|
63
|
72
|
import java.util.stream.Collectors;
|
|
|
73
|
+import java.util.zip.ZipEntry;
|
|
|
74
|
+import java.util.zip.ZipInputStream;
|
|
64
|
75
|
|
|
65
|
76
|
import static com.ruoyi.common.core.domain.AjaxResult.success;
|
|
66
|
77
|
import static com.ruoyi.common.utils.PageUtils.startPage;
|
|
|
@@ -159,7 +170,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
159
|
170
|
}
|
|
160
|
171
|
|
|
161
|
172
|
for (SysRole role : roles) {
|
|
162
|
|
- if(StrUtil.isEmpty(role.getRoleName())){
|
|
|
173
|
+ if (StrUtil.isEmpty(role.getRoleName())) {
|
|
163
|
174
|
continue;
|
|
164
|
175
|
}
|
|
165
|
176
|
// 超级管理员和仲裁委(部门长)案件,可查看所有案件 √
|
|
|
@@ -190,7 +201,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
190
|
201
|
caseApplication.setDeptIds(deptIds);
|
|
191
|
202
|
}
|
|
192
|
203
|
if ("申请人".equals(role.getRoleName())) {
|
|
193
|
|
- // caseApplication.setIsOtherRole(1);
|
|
|
204
|
+ // caseApplication.setIsOtherRole(1);
|
|
194
|
205
|
// 查询有关的用户部门
|
|
195
|
206
|
caseApplication.setApplicationOrganId(String.valueOf(sysUser.getDeptId()));
|
|
196
|
207
|
}
|
|
|
@@ -202,7 +213,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
202
|
213
|
if ("代理人".equals(role.getRoleName())) {
|
|
203
|
214
|
caseApplication.setIsOtherRole(1);
|
|
204
|
215
|
// 查询角色有关的用户部门
|
|
205
|
|
- // List<Long> agentDeptIds = sysDeptMapper.selectUserDeptListByRoleId(role.getRoleId());
|
|
|
216
|
+ // List<Long> agentDeptIds = sysDeptMapper.selectUserDeptListByRoleId(role.getRoleId());
|
|
206
|
217
|
List<Long> agentDeptIds = new ArrayList<>();
|
|
207
|
218
|
agentDeptIds.add(sysUser.getDeptId());
|
|
208
|
219
|
caseApplication.setAgentDeptIds(agentDeptIds);
|
|
|
@@ -235,7 +246,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
235
|
246
|
CaseApplication caseApplication = new CaseApplication();
|
|
236
|
247
|
List<Integer> caseStatusList = new ArrayList<>();
|
|
237
|
248
|
for (SysRole role : roles) {
|
|
238
|
|
- if(StrUtil.isEmpty(role.getRoleName())){
|
|
|
249
|
+ if (StrUtil.isEmpty(role.getRoleName())) {
|
|
239
|
250
|
continue;
|
|
240
|
251
|
}
|
|
241
|
252
|
// 超级管理员和仲裁委(部门长)案件,可查看所有案件 √
|
|
|
@@ -266,7 +277,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
266
|
277
|
caseApplication.setDeptIds(deptIds);
|
|
267
|
278
|
}
|
|
268
|
279
|
if ("申请人".equals(role.getRoleName())) {
|
|
269
|
|
- // caseApplication.setIsOtherRole(1);
|
|
|
280
|
+ // caseApplication.setIsOtherRole(1);
|
|
270
|
281
|
// 查询角色有关的用户部门
|
|
271
|
282
|
caseApplication.setApplicationOrganId(String.valueOf(sysUser.getDeptId()));
|
|
272
|
283
|
}
|
|
|
@@ -288,7 +299,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
288
|
299
|
|
|
289
|
300
|
// 根据条件查询申请人,被申请人,仲裁员,法律顾问案件
|
|
290
|
301
|
ToDoCount toDoCount = caseApplicationMapper.selectTodoCountByRole(caseApplication);
|
|
291
|
|
- if(toDoCount==null){
|
|
|
302
|
+ if (toDoCount == null) {
|
|
292
|
303
|
return new ToDoCount();
|
|
293
|
304
|
}
|
|
294
|
305
|
return toDoCount;
|
|
|
@@ -362,7 +373,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
362
|
373
|
return AjaxResult.error("请选择要上传的文件");
|
|
363
|
374
|
}
|
|
364
|
375
|
String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
|
|
365
|
|
-// String targetPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile";
|
|
|
376
|
+ // String targetPath = "D:\\home\\unzip\\";
|
|
366
|
377
|
File zipFile = null;
|
|
367
|
378
|
InputStream ins = null;
|
|
368
|
379
|
try {
|
|
|
@@ -542,7 +553,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
542
|
553
|
}
|
|
543
|
554
|
}
|
|
544
|
555
|
}
|
|
545
|
|
-
|
|
546
|
556
|
return success();
|
|
547
|
557
|
|
|
548
|
558
|
}
|
|
|
@@ -880,6 +890,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
880
|
890
|
|
|
881
|
891
|
/**
|
|
882
|
892
|
* 新增案件
|
|
|
893
|
+ *
|
|
883
|
894
|
* @param caseApplication
|
|
884
|
895
|
* @return
|
|
885
|
896
|
*/
|
|
|
@@ -900,7 +911,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
900
|
911
|
caseApplication.setVersion(1);
|
|
901
|
912
|
// 新增立案信息
|
|
902
|
913
|
int rows = caseApplicationMapper.insertCaseApplication(caseApplication);
|
|
903
|
|
- if(rows==0){
|
|
|
914
|
+ if (rows == 0) {
|
|
904
|
915
|
return rows;
|
|
905
|
916
|
}
|
|
906
|
917
|
List<CaseAffiliate> caseAffiliates = caseApplication.getCaseAffiliates();
|
|
|
@@ -1024,12 +1035,12 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1024
|
1035
|
caseApplication.setFeePayable(feePayable);
|
|
1025
|
1036
|
caseApplication.setUpdateBy(getUsername());
|
|
1026
|
1037
|
// 立案申请状态直接修改主表信息
|
|
1027
|
|
- if(caseApplication.getCaseStatus()!=null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
|
|
|
1038
|
+ if (caseApplication.getCaseStatus() != null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
|
|
1028
|
1039
|
|
|
1029
|
1040
|
caseApplicationMapper.updataCaseApplication(caseApplication);
|
|
1030
|
1041
|
// 修改记录表状态为同意提交修改的内容
|
|
1031
|
1042
|
caseApplication.setUpdateSubmitStatus(0);
|
|
1032
|
|
- }else {
|
|
|
1043
|
+ } else {
|
|
1033
|
1044
|
// 修改记录表状态为已提交修改的内容
|
|
1034
|
1045
|
caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.COMMITTED.getCode());
|
|
1035
|
1046
|
}
|
|
|
@@ -1078,7 +1089,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1078
|
1089
|
|
|
1079
|
1090
|
}
|
|
1080
|
1091
|
// 立案申请状态直接修改主表信息
|
|
1081
|
|
- if(caseApplication.getCaseStatus()!=null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
|
|
|
1092
|
+ if (caseApplication.getCaseStatus() != null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
|
|
1082
|
1093
|
|
|
1083
|
1094
|
caseAffiliateMapper.updataCaseAffiliate(caseAffiliate);
|
|
1084
|
1095
|
}
|
|
|
@@ -1111,11 +1122,11 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1111
|
1122
|
if (maxVersion == null) {
|
|
1112
|
1123
|
maxVersion = 1;
|
|
1113
|
1124
|
}
|
|
1114
|
|
- caseApplication.setVersion(maxVersion+1);
|
|
|
1125
|
+ caseApplication.setVersion(maxVersion + 1);
|
|
1115
|
1126
|
// 将修改提交状态改为未提交
|
|
1116
|
|
- // caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.UNCOMMITTED.getCode());
|
|
|
1127
|
+ // caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.UNCOMMITTED.getCode());
|
|
1117
|
1128
|
// 修改案件表的版本号
|
|
1118
|
|
- // caseApplicationMapper.updateVersionById(caseApplication.getId(),caseApplication.getVersion());
|
|
|
1129
|
+ // caseApplicationMapper.updateVersionById(caseApplication.getId(),caseApplication.getVersion());
|
|
1119
|
1130
|
|
|
1120
|
1131
|
// 异步新增案件日志
|
|
1121
|
1132
|
ThreadPoolUtil.execute(() -> {
|
|
|
@@ -1353,7 +1364,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1353
|
1364
|
StringBuilder failureMsg = new StringBuilder();
|
|
1354
|
1365
|
StringBuilder successMsg = new StringBuilder();
|
|
1355
|
1366
|
int successNum = 0;
|
|
1356
|
|
- List<CaseAffiliate> caseAffiliateLogList=new ArrayList<>();
|
|
|
1367
|
+ List<CaseAffiliate> caseAffiliateLogList = new ArrayList<>();
|
|
1357
|
1368
|
if (caseApplicationList != null && caseApplicationList.size() > 0) {
|
|
1358
|
1369
|
// 1,查询所有的组织机构,组装成map
|
|
1359
|
1370
|
List<SysDept> deptList = sysDeptMapper.selectDeptList(new SysDept());
|
|
|
@@ -1420,7 +1431,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1420
|
1431
|
caseApplicationItera.setCreateBy(getUsername());
|
|
1421
|
1432
|
caseApplicationItera.setImportFlag(1);
|
|
1422
|
1433
|
int rows = caseApplicationMapper.insertCaseApplication(caseApplicationItera);
|
|
1423
|
|
- if(rows==0){
|
|
|
1434
|
+ if (rows == 0) {
|
|
1424
|
1435
|
continue;
|
|
1425
|
1436
|
}
|
|
1426
|
1437
|
// 新增日志
|
|
|
@@ -1440,7 +1451,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1440
|
1451
|
caseApplicationItera.setVersion(1);
|
|
1441
|
1452
|
|
|
1442
|
1453
|
int insertRow = caseApplicationLogMapper.insert(caseApplicationItera);
|
|
1443
|
|
- if(insertRow>0){
|
|
|
1454
|
+ if (insertRow > 0) {
|
|
1444
|
1455
|
caseAffiliates.forEach(caseAffiliate -> caseAffiliate.setCaseAppliLogId(caseApplicationItera.getId()));
|
|
1445
|
1456
|
caseAffiliateLogList.addAll(caseAffiliates);
|
|
1446
|
1457
|
}
|
|
|
@@ -1454,7 +1465,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1454
|
1465
|
}
|
|
1455
|
1466
|
// 异步新增案件日志
|
|
1456
|
1467
|
ThreadPoolUtil.execute(() -> {
|
|
1457
|
|
- if ( CollectionUtil.isNotEmpty(caseAffiliateLogList)) {
|
|
|
1468
|
+ if (CollectionUtil.isNotEmpty(caseAffiliateLogList)) {
|
|
1458
|
1469
|
// 插入案件日志人员相关表
|
|
1459
|
1470
|
caseAffiliateLogMapper.batchCaseAffiliate(caseAffiliateLogList);
|
|
1460
|
1471
|
}
|
|
|
@@ -1503,7 +1514,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1503
|
1514
|
}
|
|
1504
|
1515
|
if (StrUtil.isEmpty(caseApplication.getDebtorIdentityNumAgent())) {
|
|
1505
|
1516
|
failureMsg.append("【被申请人主体信息-代理人身份证号】字段不能为空;");
|
|
1506
|
|
- } else if (! IdcardUtil.isValidCard((caseApplication.getDebtorIdentityNumAgent()))) {
|
|
|
1517
|
+ } else if (!IdcardUtil.isValidCard((caseApplication.getDebtorIdentityNumAgent()))) {
|
|
1507
|
1518
|
failureMsg.append("【被申请人主体信息-代理人身份证号】不合法;");
|
|
1508
|
1519
|
}
|
|
1509
|
1520
|
String debtorContactTelphoneAgent = caseApplication.getDebtorContactTelphoneAgent();
|
|
|
@@ -1533,7 +1544,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1533
|
1544
|
}
|
|
1534
|
1545
|
if (StrUtil.isEmpty(caseApplication.getDebtorIdentityNum())) {
|
|
1535
|
1546
|
failureMsg.append("【被申请人主体信息-身份证号】字段不能为空;");
|
|
1536
|
|
- } else if (! IdcardUtil.isValidCard(caseApplication.getDebtorIdentityNum())) {
|
|
|
1547
|
+ } else if (!IdcardUtil.isValidCard(caseApplication.getDebtorIdentityNum())) {
|
|
1537
|
1548
|
failureMsg.append("【被申请人主体信息-身份证号】不合法;");
|
|
1538
|
1549
|
}
|
|
1539
|
1550
|
String debtorContactTelphone = caseApplication.getDebtorContactTelphone();
|
|
|
@@ -1570,7 +1581,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1570
|
1581
|
}
|
|
1571
|
1582
|
if (StrUtil.isEmpty(caseApplication.getDebtorEmail())) {
|
|
1572
|
1583
|
failureMsg.append("【被申请人主体信息-邮箱】字段不能为空;");
|
|
1573
|
|
- } else if(!EMAIL_PATTERN.matcher(caseApplication.getDebtorEmail()).matches()){
|
|
|
1584
|
+ } else if (!EMAIL_PATTERN.matcher(caseApplication.getDebtorEmail()).matches()) {
|
|
1574
|
1585
|
|
|
1575
|
1586
|
failureMsg.append("【被申请人主体信息-邮箱】字段不合法;");
|
|
1576
|
1587
|
}
|
|
|
@@ -1676,7 +1687,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1676
|
1687
|
}
|
|
1677
|
1688
|
if (StrUtil.isEmpty(caseApplication.getEmail())) {
|
|
1678
|
1689
|
failureMsg.append("【申请人主体信息-邮箱】字段不能为空;");
|
|
1679
|
|
- } else if(!EMAIL_PATTERN.matcher(caseApplication.getEmail()).matches()){
|
|
|
1690
|
+ } else if (!EMAIL_PATTERN.matcher(caseApplication.getEmail()).matches()) {
|
|
1680
|
1691
|
|
|
1681
|
1692
|
failureMsg.append("【申请人主体信息-邮箱】字段不合法;");
|
|
1682
|
1693
|
}
|
|
|
@@ -1974,7 +1985,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1974
|
1985
|
EsignHttpResponse response3 = SignAward.createByFile(sealSignRecord, sealIdList);
|
|
1975
|
1986
|
|
|
1976
|
1987
|
JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody());
|
|
1977
|
|
- if (jsonObject3 != null){
|
|
|
1988
|
+ if (jsonObject3 != null) {
|
|
1978
|
1989
|
if (jsonObject3.getIntValue("code") == 0) {
|
|
1979
|
1990
|
//获取签署流程ID
|
|
1980
|
1991
|
JSONObject data1 = jsonObject3.getJSONObject("data");
|
|
|
@@ -1987,7 +1998,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
1987
|
1998
|
} else {
|
|
1988
|
1999
|
throw new ServiceException("发起签署流程失败,请检查参数是否有误");
|
|
1989
|
2000
|
}
|
|
1990
|
|
- }else {
|
|
|
2001
|
+ } else {
|
|
1991
|
2002
|
return AjaxResult.error();
|
|
1992
|
2003
|
}
|
|
1993
|
2004
|
|
|
|
@@ -2738,14 +2749,14 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2738
|
2749
|
*/
|
|
2739
|
2750
|
@Transactional
|
|
2740
|
2751
|
@Override
|
|
2741
|
|
- public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) {
|
|
|
2752
|
+ public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) {
|
|
2742
|
2753
|
|
|
2743
|
2754
|
// 新增预约会议表
|
|
2744
|
|
- ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(),SecurityUtils.getUserId(), reservedConferenceVO.getRoomId(),
|
|
2745
|
|
- reservedConferenceVO.getScheduleStartTime(), reservedConferenceVO.getScheduleEndTime());
|
|
|
2755
|
+ ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(), SecurityUtils.getUserId(), reservedConferenceVO.getRoomId(),
|
|
|
2756
|
+ reservedConferenceVO.getScheduleStartTime(), reservedConferenceVO.getScheduleEndTime());
|
|
2746
|
2757
|
|
|
2747
|
|
- reservedConferenceMapper.insert(conference);
|
|
2748
|
|
- return success("预约会议成功");
|
|
|
2758
|
+ reservedConferenceMapper.insert(conference);
|
|
|
2759
|
+ return success("预约会议成功");
|
|
2749
|
2760
|
}
|
|
2750
|
2761
|
|
|
2751
|
2762
|
|
|
|
@@ -2774,10 +2785,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2774
|
2785
|
// 查询最大房间号
|
|
2775
|
2786
|
Long maxRoomId = caseApplicationMapper.selectMaxRoomId();
|
|
2776
|
2787
|
|
|
2777
|
|
- if (null == maxRoomId || maxRoomId >4294967294L) {
|
|
|
2788
|
+ if (null == maxRoomId || maxRoomId > 4294967294L) {
|
|
2778
|
2789
|
return 1L;
|
|
2779
|
2790
|
} else {
|
|
2780
|
|
- return maxRoomId+1;
|
|
|
2791
|
+ return maxRoomId + 1;
|
|
2781
|
2792
|
}
|
|
2782
|
2793
|
|
|
2783
|
2794
|
}
|
|
|
@@ -2833,9 +2844,144 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|
2833
|
2844
|
@Override
|
|
2834
|
2845
|
public AjaxResult deleteRoom(String roomId) {
|
|
2835
|
2846
|
|
|
2836
|
|
- return success( reservedConferenceMapper.deleteByRoomId(roomId));
|
|
|
2847
|
+ return success(reservedConferenceMapper.deleteByRoomId(roomId));
|
|
|
2848
|
+ }
|
|
|
2849
|
+
|
|
|
2850
|
+ @Override
|
|
|
2851
|
+ public AjaxResult uploadCaseZipFile(MultipartFile file) {
|
|
|
2852
|
+ if (file.isEmpty()) {
|
|
|
2853
|
+ return AjaxResult.error("请选择要上传的文件");
|
|
|
2854
|
+ }
|
|
|
2855
|
+ //String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
|
|
|
2856
|
+ UUID uuid = UUID.randomUUID();
|
|
|
2857
|
+ String targetPath = "D:\\home\\unzip\\"+uuid+"\\";
|
|
|
2858
|
+ File zipFile = null;
|
|
|
2859
|
+ InputStream ins = null;
|
|
|
2860
|
+ try {
|
|
|
2861
|
+ ins = file.getInputStream();
|
|
|
2862
|
+ String savePath = "D:\\develop\\java\\";
|
|
|
2863
|
+ String saveName = uuid+file.getOriginalFilename();
|
|
|
2864
|
+ zipFile = new File(savePath+saveName);
|
|
|
2865
|
+ inputChangeToFile(ins, zipFile);
|
|
|
2866
|
+ } catch (IOException e) {
|
|
|
2867
|
+ e.printStackTrace();
|
|
|
2868
|
+ }
|
|
|
2869
|
+ //解压缩上传的压缩包
|
|
|
2870
|
+ boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
|
|
|
2871
|
+ if (unzipSuccess ) {
|
|
|
2872
|
+ //去掉后缀名,拿到解压后的文件夹路径
|
|
|
2873
|
+ String fileName = file.getOriginalFilename();
|
|
|
2874
|
+ String nameWithoutExtension = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
2875
|
+ File directory = new File(targetPath);
|
|
|
2876
|
+ List<String> andConvertPDF = findAndConvertPDF(directory);
|
|
|
2877
|
+ if (andConvertPDF != null && andConvertPDF.size() > 0){
|
|
|
2878
|
+ // 返回找到的PDF文件路径
|
|
|
2879
|
+ return AjaxResult.success(andConvertPDF);
|
|
|
2880
|
+ }else {
|
|
|
2881
|
+ // 没有找到符合条件的文件
|
|
|
2882
|
+ return AjaxResult.error("未找到符合条件的文件");
|
|
|
2883
|
+ }
|
|
|
2884
|
+ }else {
|
|
|
2885
|
+ // 解压失败
|
|
|
2886
|
+ return AjaxResult.error("解压失败");
|
|
|
2887
|
+ }
|
|
|
2888
|
+
|
|
|
2889
|
+ }
|
|
|
2890
|
+ public static List<String> findAndConvertPDF(File directory) {
|
|
|
2891
|
+ List<String> pdfPaths = new ArrayList<>();
|
|
|
2892
|
+ if (directory.isFile()) {
|
|
|
2893
|
+ String path = "";
|
|
|
2894
|
+ // 如果传入的参数是一个文件
|
|
|
2895
|
+ if (directory.getName().contains("仲裁申请书")) {
|
|
|
2896
|
+ if (isPDF(directory)) {
|
|
|
2897
|
+ // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
|
|
|
2898
|
+ path = directory.getAbsolutePath();
|
|
|
2899
|
+ } else {
|
|
|
2900
|
+ // 如果不是PDF格式,进行转换成PDF并返回路径
|
|
|
2901
|
+ String pdfPath = convertToPDF(directory);
|
|
|
2902
|
+ if (pdfPath != null) {
|
|
|
2903
|
+ path = pdfPath;
|
|
|
2904
|
+ }
|
|
|
2905
|
+ }
|
|
|
2906
|
+ if (path!= null) {
|
|
|
2907
|
+ pdfPaths.add(path);
|
|
|
2908
|
+ }
|
|
|
2909
|
+ }
|
|
|
2910
|
+ } else if (directory.isDirectory()) {
|
|
|
2911
|
+ searchAndConvertPDF(directory, pdfPaths);
|
|
|
2912
|
+ }else {
|
|
|
2913
|
+ return null;
|
|
|
2914
|
+ }
|
|
|
2915
|
+ return pdfPaths;
|
|
|
2916
|
+ }
|
|
|
2917
|
+
|
|
|
2918
|
+ public static boolean isPDF(File file) {
|
|
|
2919
|
+ String extension = getFileExtension(file);
|
|
|
2920
|
+ return extension.equalsIgnoreCase("pdf");
|
|
2837
|
2921
|
}
|
|
2838
|
2922
|
|
|
|
2923
|
+ public static String getFileExtension(File file) {
|
|
|
2924
|
+ String name = file.getName();
|
|
|
2925
|
+ int lastIndexOfDot = name.lastIndexOf(".");
|
|
|
2926
|
+ if (lastIndexOfDot != -1 && lastIndexOfDot < name.length() - 1) {
|
|
|
2927
|
+ return name.substring(lastIndexOfDot + 1);
|
|
|
2928
|
+ } else {
|
|
|
2929
|
+ return "";
|
|
|
2930
|
+ }
|
|
|
2931
|
+ }
|
|
|
2932
|
+ public static void searchAndConvertPDF(File directory, List<String> pdfPaths) {
|
|
|
2933
|
+ File[] files = directory.listFiles();
|
|
|
2934
|
+ if (files != null) {
|
|
|
2935
|
+ for (File file : files) {
|
|
|
2936
|
+ if (file.isFile()) {
|
|
|
2937
|
+ // 如果是文件且文件名包含"仲裁申请书"
|
|
|
2938
|
+ if (file.getName().contains("仲裁申请书")) {
|
|
|
2939
|
+ if (isPDF(file)) {
|
|
|
2940
|
+ // 如果是PDF格式,直接添加到列表中
|
|
|
2941
|
+ pdfPaths.add(file.getAbsolutePath());
|
|
|
2942
|
+ } else {
|
|
|
2943
|
+ // 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
|
|
|
2944
|
+ String pdfPath = convertToPDF(file);
|
|
|
2945
|
+ if (pdfPath != null) {
|
|
|
2946
|
+ pdfPaths.add(pdfPath);
|
|
|
2947
|
+ }
|
|
|
2948
|
+ }
|
|
|
2949
|
+ }
|
|
|
2950
|
+ } else if (file.isDirectory()) {
|
|
|
2951
|
+ // 如果是目录,递归查找
|
|
|
2952
|
+ searchAndConvertPDF(file, pdfPaths);
|
|
|
2953
|
+ }
|
|
|
2954
|
+ }
|
|
|
2955
|
+ }
|
|
|
2956
|
+ }
|
|
|
2957
|
+ private static String convertToPDF(File file) {
|
|
|
2958
|
+ String wordFilePath = file.getAbsolutePath();
|
|
|
2959
|
+ String pdfSaveDirectory ="D:\\home\\unzip\\wordToPDF\\";
|
|
|
2960
|
+ File directory = new File(pdfSaveDirectory);
|
|
|
2961
|
+ if (!directory.exists()) {
|
|
|
2962
|
+ directory.mkdirs();
|
|
|
2963
|
+ }
|
|
|
2964
|
+ String name = file.getName();
|
|
|
2965
|
+ String nameWithoutExtension = name.substring(0, name.lastIndexOf("."));
|
|
|
2966
|
+ String pdfFilePath =pdfSaveDirectory+nameWithoutExtension+".pdf";
|
|
|
2967
|
+ File inputWord = new File(wordFilePath);
|
|
|
2968
|
+ File outputFile = new File(pdfFilePath);
|
|
|
2969
|
+ try {
|
|
|
2970
|
+ InputStream docxInputStream = new FileInputStream(inputWord);
|
|
|
2971
|
+ OutputStream outputStream = new FileOutputStream(outputFile);
|
|
|
2972
|
+ IConverter converter = LocalConverter.builder().build();
|
|
|
2973
|
+ converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
|
|
|
2974
|
+ docxInputStream.close();
|
|
|
2975
|
+ outputStream.close();
|
|
|
2976
|
+ System.out.println("success");
|
|
|
2977
|
+ File file1= new File(pdfFilePath);
|
|
|
2978
|
+ System.out.println("这是转化后的PDF文件路径"+file1);
|
|
|
2979
|
+
|
|
|
2980
|
+ } catch (Exception e) {
|
|
|
2981
|
+ e.printStackTrace();
|
|
|
2982
|
+ }
|
|
|
2983
|
+ return pdfFilePath;
|
|
|
2984
|
+ }
|
|
2839
|
2985
|
}
|
|
2840
|
2986
|
|
|
2841
|
2987
|
|