|
|
@@ -1,7 +1,9 @@
|
|
1
|
1
|
package com.ruoyi.wisdomarbitrate.service.impl;
|
|
2
|
2
|
|
|
3
|
3
|
import com.deepoove.poi.config.Configure;
|
|
|
4
|
+import com.ruoyi.common.constant.CaseApplicationConstants;
|
|
4
|
5
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
6
|
+import com.ruoyi.common.utils.EmailOutUtil;
|
|
5
|
7
|
import com.ruoyi.common.utils.WordUtil;
|
|
6
|
8
|
import com.ruoyi.wisdomarbitrate.domain.*;
|
|
7
|
9
|
import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper;
|
|
|
@@ -11,9 +13,14 @@ import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
|
|
11
|
13
|
import com.ruoyi.wisdomarbitrate.service.IAdjudicationService;
|
|
12
|
14
|
import org.apache.poi.xwpf.usermodel.*;
|
|
13
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
16
|
+import org.springframework.mail.MailSendException;
|
|
|
17
|
+import org.springframework.mail.javamail.JavaMailSender;
|
|
14
|
18
|
import org.springframework.stereotype.Service;
|
|
15
|
19
|
|
|
16
|
20
|
import java.io.*;
|
|
|
21
|
+import java.net.HttpURLConnection;
|
|
|
22
|
+import java.net.URL;
|
|
|
23
|
+import java.net.URLEncoder;
|
|
17
|
24
|
import java.nio.file.Files;
|
|
18
|
25
|
import java.nio.file.Path;
|
|
19
|
26
|
import java.nio.file.StandardCopyOption;
|
|
|
@@ -24,6 +31,8 @@ import java.util.*;
|
|
24
|
31
|
|
|
25
|
32
|
@Service
|
|
26
|
33
|
public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
|
34
|
+ private final String apiUrl = "http://api.cainiaoapi.com/api/exp/v1/index";
|
|
|
35
|
+
|
|
27
|
36
|
@Autowired
|
|
28
|
37
|
private CaseApplicationMapper caseApplicationMapper;
|
|
29
|
38
|
@Autowired
|
|
|
@@ -32,14 +41,15 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
32
|
41
|
private ArbitrateRecordMapper arbitrateRecordMapper;
|
|
33
|
42
|
@Autowired
|
|
34
|
43
|
private CaseAttachMapper caseAttachMapper;
|
|
|
44
|
+ @Autowired
|
|
|
45
|
+ private EmailOutUtil emailOutUtil;
|
|
35
|
46
|
|
|
36
|
47
|
@Override
|
|
37
|
48
|
public AjaxResult createDocument(CaseApplication caseApplication) {
|
|
38
|
49
|
try {
|
|
39
|
50
|
Map<String, Object> datas = new HashMap<>();
|
|
40
|
|
- Adjudication adjudication = new Adjudication();
|
|
41
|
51
|
Long id = caseApplication.getId();
|
|
42
|
|
- if (id == null){
|
|
|
52
|
+ if (id == null) {
|
|
43
|
53
|
return null;
|
|
44
|
54
|
}
|
|
45
|
55
|
//获取案件详细信息
|
|
|
@@ -53,59 +63,60 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
53
|
63
|
CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
54
|
64
|
caseAffiliate.setCaseAppliId(id);
|
|
55
|
65
|
List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
|
|
56
|
|
- if (caseAffiliates != null && caseAffiliates.size() > 0){
|
|
57
|
|
- for (CaseAffiliate affiliate : caseAffiliates){
|
|
|
66
|
+ if (caseAffiliates != null && caseAffiliates.size() > 0) {
|
|
|
67
|
+ for (CaseAffiliate affiliate : caseAffiliates) {
|
|
58
|
68
|
//获取身份类型
|
|
59
|
69
|
int identityType = affiliate.getIdentityType();
|
|
60
|
70
|
if (identityType == 1) { //申请人
|
|
61
|
71
|
datas.put("appName", affiliate.getName());
|
|
62
|
|
- datas.put("appSex", null);
|
|
63
|
72
|
datas.put("appIDNo", affiliate.getIdentityNum());
|
|
64
|
73
|
datas.put("appAddress", affiliate.getContactAddress());
|
|
65
|
74
|
datas.put("appAgentName", affiliate.getNameAgent());
|
|
66
|
|
- datas.put("appAgentIDNo",affiliate.getIdentityNumAgent());
|
|
67
|
|
- }else if (identityType == 2){ //被申请人
|
|
|
75
|
+ datas.put("appAgentIDNo", affiliate.getIdentityNumAgent());
|
|
|
76
|
+ } else if (identityType == 2) { //被申请人
|
|
68
|
77
|
datas.put("resName", affiliate.getName());
|
|
69
|
|
- datas.put("resSex", null);
|
|
70
|
78
|
datas.put("resIDNo", affiliate.getIdentityNum());
|
|
71
|
79
|
datas.put("resAddress", affiliate.getContactAddress());
|
|
72
|
80
|
datas.put("resAgentName", affiliate.getNameAgent());
|
|
73
|
|
- datas.put("resAgentIDNo",affiliate.getIdentityNumAgent());
|
|
|
81
|
+ datas.put("resAgentIDNo", affiliate.getIdentityNumAgent());
|
|
74
|
82
|
}
|
|
75
|
83
|
}
|
|
76
|
84
|
}
|
|
77
|
85
|
String arbitratorName = caseApplication1.getArbitratorName();
|
|
78
|
|
- datas.put("caseName",caseApplication1.getCaseName());
|
|
79
|
|
- datas.put("arbitratorName",arbitratorName);
|
|
80
|
|
- LocalDate localDate = caseApplication1.getHearDate()
|
|
81
|
|
- .toInstant()
|
|
82
|
|
- .atZone(ZoneId.systemDefault())
|
|
83
|
|
- .toLocalDate();
|
|
84
|
|
- datas.put("hearYear", localDate.getYear());
|
|
85
|
|
- datas.put("hearMonths", localDate.getMonthValue());
|
|
86
|
|
- datas.put("hearDay", localDate.getDayOfMonth());
|
|
87
|
|
- datas.put("appArbitrationClaims", null);
|
|
88
|
|
- datas.put("appEvidenceName", null);
|
|
89
|
|
- datas.put("appProveFacts", null);
|
|
90
|
|
- datas.put("resDefenseContentToApp", null);
|
|
91
|
|
- datas.put("resArbitrationClaims", null);
|
|
92
|
|
- datas.put("resEvidenceName", null);
|
|
93
|
|
- datas.put("resProveFacts", null);
|
|
94
|
|
- datas.put("appDefenseContentToRes", null);
|
|
95
|
|
- datas.put("evidenDetermi", arbitrateRecord1.getEvidenDetermi());
|
|
96
|
|
- datas.put("factDetermi", arbitrateRecord1.getFactDetermi());
|
|
97
|
|
- datas.put("caseSketch", arbitrateRecord1.getCaseSketch());
|
|
98
|
|
- datas.put("arbitrateThink", arbitrateRecord1.getArbitrateThink());
|
|
99
|
|
- datas.put("legalProvisions", null);
|
|
100
|
|
- datas.put("rulingFollows", arbitrateRecord1.getRulingFollows());
|
|
101
|
|
- datas.put("umpire", null);
|
|
102
|
|
- if (arbitratorName.contains(",")){
|
|
|
86
|
+ datas.put("caseName", caseApplication1.getCaseName());
|
|
|
87
|
+ datas.put("arbitratorName", arbitratorName);
|
|
|
88
|
+ Date hearDate = caseApplication1.getHearDate();
|
|
|
89
|
+ if (hearDate != null) {
|
|
|
90
|
+ LocalDate localDate = hearDate.toInstant()
|
|
|
91
|
+ .atZone(ZoneId.systemDefault())
|
|
|
92
|
+ .toLocalDate();
|
|
|
93
|
+ datas.put("hearYear", localDate.getYear());
|
|
|
94
|
+ datas.put("hearMonths", localDate.getMonthValue());
|
|
|
95
|
+ datas.put("hearDay", localDate.getDayOfMonth());
|
|
|
96
|
+ } else {
|
|
|
97
|
+ datas.put("hearYear", null);
|
|
|
98
|
+ datas.put("hearMonths", null);
|
|
|
99
|
+ datas.put("hearDay", null);
|
|
|
100
|
+ }
|
|
|
101
|
+ datas.put("appArbitrationClaims", caseApplication1.getArbitratClaims());
|
|
|
102
|
+ if (arbitrateRecord1 != null) {
|
|
|
103
|
+ datas.put("evidenDetermi", arbitrateRecord1.getEvidenDetermi());
|
|
|
104
|
+ datas.put("factDetermi", arbitrateRecord1.getFactDetermi());
|
|
|
105
|
+ datas.put("caseSketch", arbitrateRecord1.getCaseSketch());
|
|
|
106
|
+ datas.put("arbitrateThink", arbitrateRecord1.getArbitrateThink());
|
|
|
107
|
+ datas.put("rulingFollows", arbitrateRecord1.getRulingFollows());
|
|
|
108
|
+ }
|
|
|
109
|
+ datas.put("legalProvisions", "仲裁法");
|
|
|
110
|
+ if (arbitratorName == null) {
|
|
|
111
|
+ datas.put("arbitratorName1", null);
|
|
|
112
|
+ datas.put("arbitratorName2", null);
|
|
|
113
|
+ } else if (arbitratorName.contains(",")) {
|
|
103
|
114
|
String[] nameArray = arbitratorName.split(",");
|
|
104
|
115
|
String firstName = nameArray[0];
|
|
105
|
116
|
String secondName = nameArray[1];
|
|
106
|
117
|
datas.put("arbitratorName1", firstName);
|
|
107
|
118
|
datas.put("arbitratorName2", secondName);
|
|
108
|
|
- }else {
|
|
|
119
|
+ } else {
|
|
109
|
120
|
String secondName = "";
|
|
110
|
121
|
datas.put("arbitratorName1", arbitratorName);
|
|
111
|
122
|
datas.put("arbitratorName2", secondName);
|
|
|
@@ -114,19 +125,24 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
114
|
125
|
datas.put("year", now.getYear());
|
|
115
|
126
|
datas.put("months", now.getMonthValue());
|
|
116
|
127
|
datas.put("day", now.getDayOfMonth());
|
|
117
|
|
- datas.put("clerk", null);
|
|
118
|
|
- String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx";
|
|
119
|
|
-
|
|
120
|
|
- String currentDateStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
121
|
|
- String saveFolderPath = "/data/arbitrate-document/formal/" + currentDateStr;
|
|
|
128
|
+ //String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx";
|
|
|
129
|
+ String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx";
|
|
|
130
|
+ //String saveFolderPath = "/data/arbitrate-document/formal/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
|
|
|
131
|
+ String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
|
|
|
132
|
+ String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
|
|
133
|
+ String resultFilePath = saveFolderPath + "/" + fileName;
|
|
122
|
134
|
// 创建日期目录
|
|
123
|
135
|
File saveFolder = new File(saveFolderPath);
|
|
124
|
136
|
if (!saveFolder.exists()) {
|
|
125
|
137
|
saveFolder.mkdirs();
|
|
126
|
138
|
}
|
|
127
|
|
- String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
|
128
|
|
- String resultFilePath = saveFolderPath+ fileName;
|
|
|
139
|
+ Path sourcePath = new File(modalFilePath).toPath();
|
|
|
140
|
+ Path destinationPath = new File(resultFilePath).toPath();
|
|
|
141
|
+ Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
|
|
129
|
142
|
String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
|
|
|
143
|
+ //修改案件状态
|
|
|
144
|
+ caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
|
|
|
145
|
+ caseApplicationMapper.submitCaseApplication(caseApplication1);
|
|
130
|
146
|
//将裁决书保存到附件表里
|
|
131
|
147
|
CaseAttach caseAttach = CaseAttach.builder()
|
|
132
|
148
|
.caseAppliId(id)
|
|
|
@@ -135,13 +151,93 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
135
|
151
|
.annexType(3)
|
|
136
|
152
|
.build();
|
|
137
|
153
|
int i = caseAttachMapper.save(caseAttach);
|
|
138
|
|
- if (i>0){
|
|
139
|
|
- Integer annexId = caseAttach.getAnnexId();
|
|
140
|
|
- //将附件id保存到仲裁记录表里面
|
|
141
|
|
- arbitrateRecord1.setAnnexId(annexId);
|
|
142
|
|
- arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
|
|
|
154
|
+ if (i > 0) {
|
|
|
155
|
+ if (arbitrateRecord1 != null) {
|
|
|
156
|
+ Integer annexId = caseAttach.getAnnexId();
|
|
|
157
|
+ //将附件id保存到仲裁记录表里面
|
|
|
158
|
+ arbitrateRecord1.setAnnexId(annexId);
|
|
|
159
|
+ arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
|
|
|
160
|
+ }
|
|
|
161
|
+ }
|
|
|
162
|
+ return AjaxResult.success("裁决书已生成");
|
|
|
163
|
+ } catch (IOException e) {
|
|
|
164
|
+ e.printStackTrace();
|
|
|
165
|
+ }
|
|
|
166
|
+ return null;
|
|
|
167
|
+ }
|
|
|
168
|
+
|
|
|
169
|
+ @Override
|
|
|
170
|
+ public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail) {
|
|
|
171
|
+ CaseApplication caseApplication = new CaseApplication();
|
|
|
172
|
+ caseApplication.setId(id);
|
|
|
173
|
+ CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
|
174
|
+ if (caseApplication1 == null) {
|
|
|
175
|
+ return AjaxResult.error("未查询到相关案件");
|
|
|
176
|
+ }
|
|
|
177
|
+
|
|
|
178
|
+ //根据案件id查询裁决书
|
|
|
179
|
+ try {
|
|
|
180
|
+ List<File> fileList = new ArrayList<>();
|
|
|
181
|
+ List<CaseAttach> caseAttachList = caseAttachMapper.queryAnnexPathByCaseId(id);
|
|
|
182
|
+ if (caseAttachList != null && caseAttachList.size() > 0) {
|
|
|
183
|
+ for (CaseAttach caseAttach : caseAttachList) {
|
|
|
184
|
+ if (caseAttach.getAnnexType() == 3) {
|
|
|
185
|
+ String annexPath = caseAttach.getAnnexPath();
|
|
|
186
|
+ fileList.add(new File(annexPath));
|
|
|
187
|
+ }
|
|
|
188
|
+ }
|
|
|
189
|
+ }
|
|
|
190
|
+ //电子邮件送达
|
|
|
191
|
+ JavaMailSender javaMailSender = emailOutUtil.rebuildMailSender();
|
|
|
192
|
+ if (appEmail != null) {
|
|
|
193
|
+ emailOutUtil.sendMessageCarryFiles(appEmail, "案件裁决书", "您的裁决书已送达,详情请查阅附件", fileList
|
|
|
194
|
+ , "hjbjava@163.com", javaMailSender);
|
|
|
195
|
+ }
|
|
|
196
|
+ if (resEmail != null) {
|
|
|
197
|
+ emailOutUtil.sendMessageCarryFiles(resEmail, "案件裁决书", "您的裁决书已送达,详情请查阅附件", fileList
|
|
|
198
|
+ , "hjbjava@163.com", javaMailSender);
|
|
|
199
|
+ }
|
|
|
200
|
+ //修改案件状态
|
|
|
201
|
+ caseApplication1.setCaseStatus(CaseApplicationConstants.CASE_FILING);
|
|
|
202
|
+ caseApplicationMapper.submitCaseApplication(caseApplication1);
|
|
|
203
|
+ return AjaxResult.success("仲裁文书送达成功");
|
|
|
204
|
+ } catch (MailSendException e) {
|
|
|
205
|
+ return AjaxResult.error("发送失败,请检查文件路径");
|
|
|
206
|
+ }
|
|
|
207
|
+ }
|
|
|
208
|
+
|
|
|
209
|
+ @Override
|
|
|
210
|
+ public AjaxResult getLogisticsInfo(String trackingNum, Integer phoneLastFour) {
|
|
|
211
|
+ try {
|
|
|
212
|
+ //快递单号查询
|
|
|
213
|
+ String key = "70ba5c7b327f71fccd5924f70e3e7b7f";
|
|
|
214
|
+ String com = "auto";
|
|
|
215
|
+ // 构造查询字符串参数
|
|
|
216
|
+ String queryParameters = String.format("key=%s&com=%s&no=%s&phone=%d",
|
|
|
217
|
+ URLEncoder.encode(key, "UTF-8"),
|
|
|
218
|
+ URLEncoder.encode(com, "UTF-8"),
|
|
|
219
|
+ URLEncoder.encode(trackingNum, "UTF-8"),
|
|
|
220
|
+ phoneLastFour);
|
|
|
221
|
+ // 拼接到API URL中
|
|
|
222
|
+ String fullUrl = apiUrl + "?" + queryParameters;
|
|
|
223
|
+ URL url = new URL(fullUrl);
|
|
|
224
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
225
|
+ connection.setRequestMethod("GET");
|
|
|
226
|
+ int responseCode = connection.getResponseCode();
|
|
|
227
|
+ if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
228
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
|
229
|
+ String line;
|
|
|
230
|
+ StringBuilder response = new StringBuilder();
|
|
|
231
|
+ while ((line = reader.readLine()) != null) {
|
|
|
232
|
+ response.append(line);
|
|
|
233
|
+ }
|
|
|
234
|
+ reader.close();
|
|
|
235
|
+ // 处理返回的响应数据
|
|
|
236
|
+ return AjaxResult.success(response);
|
|
|
237
|
+ } else {
|
|
|
238
|
+ // 请求失败
|
|
|
239
|
+ return AjaxResult.error("请求失败,错误码:" + responseCode);
|
|
143
|
240
|
}
|
|
144
|
|
- return AjaxResult.success("裁决书保存路径为" + docFilePath);
|
|
145
|
241
|
} catch (IOException e) {
|
|
146
|
242
|
e.printStackTrace();
|
|
147
|
243
|
}
|