|
|
@@ -1,16 +1,21 @@
|
|
1
|
1
|
package com.ruoyi.wisdomarbitrate.service.impl;
|
|
2
|
2
|
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
|
4
|
+import com.alibaba.fastjson.JSONObject;
|
|
3
|
5
|
import com.deepoove.poi.config.Configure;
|
|
4
|
6
|
import com.ruoyi.common.constant.CaseApplicationConstants;
|
|
5
|
7
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
6
|
8
|
import com.ruoyi.common.utils.EmailOutUtil;
|
|
7
|
9
|
import com.ruoyi.common.utils.WordUtil;
|
|
8
|
10
|
import com.ruoyi.wisdomarbitrate.domain.*;
|
|
|
11
|
+import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO;
|
|
9
|
12
|
import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper;
|
|
10
|
13
|
import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper;
|
|
11
|
14
|
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
|
|
12
|
15
|
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
|
|
13
|
16
|
import com.ruoyi.wisdomarbitrate.service.IAdjudicationService;
|
|
|
17
|
+import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
|
|
|
18
|
+import lombok.extern.slf4j.Slf4j;
|
|
14
|
19
|
import org.apache.poi.xwpf.usermodel.*;
|
|
15
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
16
|
21
|
import org.springframework.mail.MailSendException;
|
|
|
@@ -31,6 +36,7 @@ import java.time.format.DateTimeFormatter;
|
|
31
|
36
|
import java.util.*;
|
|
32
|
37
|
|
|
33
|
38
|
@Service
|
|
|
39
|
+@Slf4j
|
|
34
|
40
|
public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
35
|
41
|
private final String apiUrl = "http://api.cainiaoapi.com/api/exp/v1/index";
|
|
36
|
42
|
|
|
|
@@ -44,6 +50,8 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
44
|
50
|
private CaseAttachMapper caseAttachMapper;
|
|
45
|
51
|
@Autowired
|
|
46
|
52
|
private EmailOutUtil emailOutUtil;
|
|
|
53
|
+ @Autowired
|
|
|
54
|
+ private ICaseApplicationService caseApplicationService;
|
|
47
|
55
|
|
|
48
|
56
|
@Override
|
|
49
|
57
|
public AjaxResult createDocument(CaseApplication caseApplication) {
|
|
|
@@ -123,14 +131,18 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
123
|
131
|
datas.put("arbitratorName2", secondName);
|
|
124
|
132
|
}
|
|
125
|
133
|
LocalDate now = LocalDate.now();
|
|
126
|
|
- datas.put("year", now.getYear());
|
|
127
|
|
- datas.put("months", now.getMonthValue());
|
|
128
|
|
- datas.put("day", now.getDayOfMonth());
|
|
|
134
|
+ String year = Integer.toString(now.getYear());
|
|
|
135
|
+ String month = String.format("%02d", now.getMonthValue());
|
|
|
136
|
+ String day = String.format("%02d", now.getDayOfMonth());
|
|
|
137
|
+ datas.put("year", year);
|
|
|
138
|
+ datas.put("months", month);
|
|
|
139
|
+ datas.put("day", day);
|
|
129
|
140
|
String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx";
|
|
130
|
141
|
//String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx";
|
|
131
|
|
- String saveFolderPath = "/data/arbitrate-document/formal/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
|
|
|
142
|
+ String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
132
|
143
|
//String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
|
|
133
|
144
|
String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
|
|
145
|
+ String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
134
|
146
|
String resultFilePath = saveFolderPath + "/" + fileName;
|
|
135
|
147
|
// 创建日期目录
|
|
136
|
148
|
File saveFolder = new File(saveFolderPath);
|
|
|
@@ -141,14 +153,15 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
141
|
153
|
Path destinationPath = new File(resultFilePath).toPath();
|
|
142
|
154
|
Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
|
|
143
|
155
|
String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
|
|
|
156
|
+ String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
|
|
144
|
157
|
//修改案件状态
|
|
145
|
158
|
caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
|
|
146
|
159
|
caseApplicationMapper.submitCaseApplication(caseApplication1);
|
|
147
|
160
|
//将裁决书保存到附件表里
|
|
148
|
161
|
CaseAttach caseAttach = CaseAttach.builder()
|
|
149
|
162
|
.caseAppliId(id)
|
|
150
|
|
- .annexName(fileName)
|
|
151
|
|
- .annexPath(docFilePath)
|
|
|
163
|
+ .annexName(saveName)
|
|
|
164
|
+ .annexPath(savePath)
|
|
152
|
165
|
.annexType(3)
|
|
153
|
166
|
.build();
|
|
154
|
167
|
int i = caseAttachMapper.save(caseAttach);
|
|
|
@@ -169,7 +182,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
169
|
182
|
|
|
170
|
183
|
@Override
|
|
171
|
184
|
@Transactional
|
|
172
|
|
- public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail ,String apptrackingNum,String restrackingNum) {
|
|
|
185
|
+ public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) {
|
|
173
|
186
|
CaseApplication caseApplication = new CaseApplication();
|
|
174
|
187
|
caseApplication.setId(id);
|
|
175
|
188
|
CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
|
@@ -180,16 +193,21 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
180
|
193
|
//根据案件id查询裁决书
|
|
181
|
194
|
try {
|
|
182
|
195
|
List<File> fileList = new ArrayList<>();
|
|
183
|
|
- List<CaseAttach> caseAttachList = caseAttachMapper.queryAnnexPathByCaseId(id);
|
|
|
196
|
+ CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication);
|
|
|
197
|
+ List<CaseAttach> caseAttachList = caseApplication2.getCaseAttachList();
|
|
184
|
198
|
if (caseAttachList != null && caseAttachList.size() > 0) {
|
|
185
|
199
|
for (CaseAttach caseAttach : caseAttachList) {
|
|
186
|
200
|
if (caseAttach.getAnnexType() == 3) {
|
|
187
|
201
|
String annexPath = caseAttach.getAnnexPath();
|
|
188
|
|
- fileList.add(new File(annexPath));
|
|
|
202
|
+ //File file = new File("/home/ruoyi/" + annexPath);
|
|
|
203
|
+ String path = "/home/ruoyi/" + annexPath;
|
|
|
204
|
+ File file = new File(path);
|
|
|
205
|
+ System.out.println("文件是:" + file);
|
|
|
206
|
+ fileList.add(file);
|
|
189
|
207
|
}
|
|
190
|
208
|
}
|
|
191
|
209
|
}
|
|
192
|
|
- if (fileList.size()<1){
|
|
|
210
|
+ if (fileList.size() < 1) {
|
|
193
|
211
|
return AjaxResult.error("未查询到裁决书");
|
|
194
|
212
|
}
|
|
195
|
213
|
File file = fileList.get(0);
|
|
|
@@ -210,13 +228,13 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
210
|
228
|
CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
211
|
229
|
caseAffiliate.setCaseAppliId(id);
|
|
212
|
230
|
List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
|
|
213
|
|
- if (caseAffiliates!=null&&caseAffiliates.size()>0){
|
|
|
231
|
+ if (caseAffiliates != null && caseAffiliates.size() > 0) {
|
|
214
|
232
|
for (CaseAffiliate affiliate : caseAffiliates) {
|
|
215
|
|
- if (affiliate.getIdentityType() == 1){ //申请人
|
|
|
233
|
+ if (affiliate.getIdentityType() == 1) { //申请人
|
|
216
|
234
|
affiliate.setSendEmail(appEmail);
|
|
217
|
235
|
affiliate.setTrackNum(apptrackingNum);
|
|
218
|
236
|
caseAffiliateMapper.updataCaseAffiliate(affiliate);
|
|
219
|
|
- }else {
|
|
|
237
|
+ } else {
|
|
220
|
238
|
affiliate.setSendEmail(resEmail);
|
|
221
|
239
|
affiliate.setTrackNum(restrackingNum);
|
|
222
|
240
|
caseAffiliateMapper.updataCaseAffiliate(affiliate);
|
|
|
@@ -230,40 +248,124 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
230
|
248
|
}
|
|
231
|
249
|
|
|
232
|
250
|
@Override
|
|
233
|
|
- public AjaxResult getLogisticsInfo(String trackingNum, Integer phoneLastFour) {
|
|
|
251
|
+ public AjaxResult getLogisticsInfo(CaseApplication caseApplication) {
|
|
234
|
252
|
try {
|
|
235
|
253
|
//快递单号查询
|
|
236
|
|
- String key = "70ba5c7b327f71fccd5924f70e3e7b7f";
|
|
|
254
|
+ String key = "729437f92468910aee6c12dbfeaee3c1";
|
|
237
|
255
|
String com = "auto";
|
|
238
|
|
- // 构造查询字符串参数
|
|
239
|
|
- String queryParameters = String.format("key=%s&com=%s&no=%s&phone=%d",
|
|
240
|
|
- URLEncoder.encode(key, "UTF-8"),
|
|
241
|
|
- URLEncoder.encode(com, "UTF-8"),
|
|
242
|
|
- URLEncoder.encode(trackingNum, "UTF-8"),
|
|
243
|
|
- phoneLastFour);
|
|
244
|
|
- // 拼接到API URL中
|
|
245
|
|
- String fullUrl = apiUrl + "?" + queryParameters;
|
|
246
|
|
- URL url = new URL(fullUrl);
|
|
247
|
|
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
248
|
|
- connection.setRequestMethod("GET");
|
|
249
|
|
- int responseCode = connection.getResponseCode();
|
|
250
|
|
- if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
251
|
|
- BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
252
|
|
- String line;
|
|
253
|
|
- StringBuilder response = new StringBuilder();
|
|
254
|
|
- while ((line = reader.readLine()) != null) {
|
|
255
|
|
- response.append(line);
|
|
|
256
|
+ //根据案件id查询单号信息
|
|
|
257
|
+ CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
|
258
|
+ caseAffiliate.setCaseAppliId(caseApplication.getId());
|
|
|
259
|
+ List<LogisticsInfoVO> logisticsInfoVOList = new ArrayList<>();
|
|
|
260
|
+ List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
|
|
|
261
|
+ if (caseAffiliates != null && caseAffiliates.size() > 0) {
|
|
|
262
|
+ for (CaseAffiliate affiliate : caseAffiliates) {
|
|
|
263
|
+ LogisticsInfoVO logisticsInfoVO = new LogisticsInfoVO();
|
|
|
264
|
+ String trackNum = affiliate.getTrackNum();
|
|
|
265
|
+ if (trackNum != null) {
|
|
|
266
|
+ // 构造查询字符串参数
|
|
|
267
|
+ String queryParameters = String.format("key=%s&com=%s&no=%s&phone=%d",
|
|
|
268
|
+ URLEncoder.encode(key, "UTF-8"),
|
|
|
269
|
+ URLEncoder.encode(com, "UTF-8"),
|
|
|
270
|
+ URLEncoder.encode(trackNum, "UTF-8"), null);
|
|
|
271
|
+ // 拼接到API URL中
|
|
|
272
|
+ String fullUrl = apiUrl + "?" + queryParameters;
|
|
|
273
|
+ URL url = new URL(fullUrl);
|
|
|
274
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
275
|
+ connection.setRequestMethod("GET");
|
|
|
276
|
+ int responseCode = connection.getResponseCode();
|
|
|
277
|
+ if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
278
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
|
279
|
+ String line;
|
|
|
280
|
+ StringBuilder response = new StringBuilder();
|
|
|
281
|
+ while ((line = reader.readLine()) != null) {
|
|
|
282
|
+ response.append(line);
|
|
|
283
|
+ }
|
|
|
284
|
+ reader.close();
|
|
|
285
|
+ // 处理返回的响应数据\
|
|
|
286
|
+ JSONObject jsonObject = JSON.parseObject(response.toString());
|
|
|
287
|
+ // 提取 "data" 字段并转换为字符串
|
|
|
288
|
+ String data = jsonObject.getString("data");
|
|
|
289
|
+ if (data != null) {
|
|
|
290
|
+ logisticsInfoVO.setIdentityType(affiliate.getIdentityType());
|
|
|
291
|
+ logisticsInfoVO.setLogisticsInfo(data);
|
|
|
292
|
+ logisticsInfoVOList.add(logisticsInfoVO);
|
|
|
293
|
+ }
|
|
|
294
|
+ } else {
|
|
|
295
|
+ // 请求失败
|
|
|
296
|
+ return AjaxResult.error("请求失败,错误码:" + responseCode);
|
|
|
297
|
+ }
|
|
|
298
|
+ }
|
|
256
|
299
|
}
|
|
257
|
|
- reader.close();
|
|
258
|
|
- // 处理返回的响应数据
|
|
259
|
|
- return AjaxResult.success(response);
|
|
260
|
|
- } else {
|
|
261
|
|
- // 请求失败
|
|
262
|
|
- return AjaxResult.error("请求失败,错误码:" + responseCode);
|
|
|
300
|
+ return AjaxResult.success(logisticsInfoVOList);
|
|
263
|
301
|
}
|
|
264
|
302
|
} catch (IOException e) {
|
|
265
|
303
|
e.printStackTrace();
|
|
266
|
304
|
}
|
|
267
|
305
|
return null;
|
|
268
|
306
|
}
|
|
|
307
|
+
|
|
|
308
|
+ @Override
|
|
|
309
|
+ public AjaxResult signature(CaseApplication caseApplication) {
|
|
|
310
|
+ //更改案件状态(暂时)
|
|
|
311
|
+ caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL);
|
|
|
312
|
+ caseApplicationMapper.submitCaseApplication(caseApplication);
|
|
|
313
|
+ return AjaxResult.success("签名成功,案件状态已改为待仲裁文书用印");
|
|
|
314
|
+ }
|
|
|
315
|
+
|
|
|
316
|
+ @Override
|
|
|
317
|
+ public AjaxResult caseFile(CaseApplication caseApplication) {
|
|
|
318
|
+ //更改案件状态(暂时)
|
|
|
319
|
+ caseApplication.setCaseStatus(CaseApplicationConstants.CASE_ARCHIVED);
|
|
|
320
|
+ caseApplicationMapper.submitCaseApplication(caseApplication);
|
|
|
321
|
+ return AjaxResult.success("归档成功,案件状态已改为已归档");
|
|
|
322
|
+ }
|
|
|
323
|
+
|
|
|
324
|
+ @Override
|
|
|
325
|
+ public AjaxResult service(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) {
|
|
|
326
|
+ CaseApplication caseApplication = new CaseApplication();
|
|
|
327
|
+ caseApplication.setId(id);
|
|
|
328
|
+ CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
|
329
|
+ if (caseApplication1 == null) {
|
|
|
330
|
+ return AjaxResult.error("未查询到相关案件");
|
|
|
331
|
+ }
|
|
|
332
|
+ //修改案件状态
|
|
|
333
|
+ caseApplication1.setCaseStatus(CaseApplicationConstants.CASE_FILING);
|
|
|
334
|
+ caseApplicationMapper.submitCaseApplication(caseApplication1);
|
|
|
335
|
+ //保存邮箱信息和快递单号到关联人表
|
|
|
336
|
+ CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
|
337
|
+ caseAffiliate.setCaseAppliId(id);
|
|
|
338
|
+ List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
|
|
|
339
|
+ if (caseAffiliates != null && caseAffiliates.size() > 0) {
|
|
|
340
|
+ for (CaseAffiliate affiliate : caseAffiliates) {
|
|
|
341
|
+ if (affiliate.getIdentityType() == 1) { //申请人
|
|
|
342
|
+ affiliate.setSendEmail(appEmail);
|
|
|
343
|
+ affiliate.setTrackNum(apptrackingNum);
|
|
|
344
|
+ caseAffiliateMapper.updataCaseAffiliate(affiliate);
|
|
|
345
|
+ } else {
|
|
|
346
|
+ affiliate.setSendEmail(resEmail);
|
|
|
347
|
+ affiliate.setTrackNum(restrackingNum);
|
|
|
348
|
+ caseAffiliateMapper.updataCaseAffiliate(affiliate);
|
|
|
349
|
+ }
|
|
|
350
|
+ }
|
|
|
351
|
+ }
|
|
|
352
|
+ return AjaxResult.success("仲裁文书送达成功");
|
|
|
353
|
+ }
|
|
|
354
|
+
|
|
|
355
|
+ public static void main(String[] args) {
|
|
|
356
|
+ try {
|
|
|
357
|
+ List<File> fileList = new ArrayList<>();
|
|
|
358
|
+ fileList.add(new File("D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\b442880179844a848f1f8b08c29e3d0c.docx"));
|
|
|
359
|
+ File file = fileList.get(0);
|
|
|
360
|
+ //电子邮件送达
|
|
|
361
|
+ EmailOutUtil emailOutUtil = new EmailOutUtil();
|
|
|
362
|
+ JavaMailSender javaMailSender = emailOutUtil.rebuildMailSender();
|
|
|
363
|
+ if (javaMailSender != null) {
|
|
|
364
|
+ emailOutUtil.sendMessageCarryFile("1154956315@qq.com", "案件裁决书", "您的裁决书已送达,详情请查阅附件", file
|
|
|
365
|
+ , "hjbjava@163.com", javaMailSender);
|
|
|
366
|
+ }
|
|
|
367
|
+ } catch (MailSendException e) {
|
|
|
368
|
+ e.printStackTrace();
|
|
|
369
|
+ }
|
|
|
370
|
+ }
|
|
269
|
371
|
}
|