|
|
@@ -35,6 +35,7 @@ import java.nio.file.StandardCopyOption;
|
|
35
|
35
|
import java.text.SimpleDateFormat;
|
|
36
|
36
|
import java.time.LocalDate;
|
|
37
|
37
|
import java.util.*;
|
|
|
38
|
+import java.util.regex.Pattern;
|
|
38
|
39
|
|
|
39
|
40
|
@RestController
|
|
40
|
41
|
@RequestMapping
|
|
|
@@ -52,6 +53,8 @@ public class TestPOIController {
|
|
52
|
53
|
private RedisCache redisCache;
|
|
53
|
54
|
@Autowired
|
|
54
|
55
|
private SendMailRecordMapper sendMailRecordMapper;
|
|
|
56
|
+ @Autowired
|
|
|
57
|
+ private ICaseApplicationService caseApplicationService;
|
|
55
|
58
|
|
|
56
|
59
|
@GetMapping("/test")
|
|
57
|
60
|
public AjaxResult createDocument(@RequestBody CaseApplication caseApplication) {
|
|
|
@@ -92,10 +95,10 @@ public class TestPOIController {
|
|
92
|
95
|
datas.put("resName", affiliate.getName());
|
|
93
|
96
|
datas.put("resAddress", affiliate.getResidenAffili());
|
|
94
|
97
|
String responSex = affiliate.getResponSex();
|
|
95
|
|
- if (responSex.equals("0")){
|
|
96
|
|
- datas.put("resSex","男");
|
|
97
|
|
- }else{
|
|
98
|
|
- datas.put("resSex","女");
|
|
|
98
|
+ if (responSex.equals("0")) {
|
|
|
99
|
+ datas.put("resSex", "男");
|
|
|
100
|
+ } else {
|
|
|
101
|
+ datas.put("resSex", "女");
|
|
99
|
102
|
}
|
|
100
|
103
|
Date responBirth = affiliate.getResponBirth();
|
|
101
|
104
|
if (responBirth != null) {
|
|
|
@@ -244,12 +247,37 @@ public class TestPOIController {
|
|
244
|
247
|
}
|
|
245
|
248
|
datas.put("claims", caseApplication1.getArbitratClaims());
|
|
246
|
249
|
datas.put("request", caseApplication1.getRequestRule());
|
|
247
|
|
- //申请人证据材料
|
|
248
|
|
- datas.put("appEvidenceMaterial", null);
|
|
249
|
|
- //被申请人证据材料
|
|
250
|
|
-
|
|
251
|
|
- PictureRenderData pictureRenderData = WordUtil.rebuildImageContent(100, 100, null, "D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg");
|
|
252
|
|
- datas.put("resEvidenceMaterial", "证据详情可查询附件");
|
|
|
250
|
+ CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication);
|
|
|
251
|
+ List<CaseAttach> caseAttachList1 = caseApplication2.getCaseAttachList();
|
|
|
252
|
+ if (caseAttachList1 != null && caseAttachList1.size() > 0) {
|
|
|
253
|
+ for (CaseAttach caseAttach : caseAttachList1) {
|
|
|
254
|
+ if (caseAttach.getAnnexType() == 6) { //被申请人证据材料
|
|
|
255
|
+ String annexName = caseAttach.getAnnexName();
|
|
|
256
|
+ boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
|
|
|
257
|
+ if (isImageFile) {
|
|
|
258
|
+ String prefix = "/profile";
|
|
|
259
|
+ int startIndex = annexName.indexOf(prefix);
|
|
|
260
|
+ startIndex += prefix.length();
|
|
|
261
|
+ String annexPath = "/uploadPath" + annexName.substring(startIndex);
|
|
|
262
|
+ System.out.println("路径是===========" + annexPath);
|
|
|
263
|
+ PictureRenderData pictureRenderData = WordUtil
|
|
|
264
|
+ .rebuildImageContent(100, 100, null, annexPath);
|
|
|
265
|
+ datas.put("resEvidenceMaterial", pictureRenderData);
|
|
|
266
|
+ }
|
|
|
267
|
+ } else if (caseAttach.getAnnexType() == 2) { //申请人证据材料
|
|
|
268
|
+ String annexName = caseAttach.getAnnexName();
|
|
|
269
|
+ boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
|
|
|
270
|
+ if (isImageFile) {
|
|
|
271
|
+ String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
|
|
|
272
|
+ System.out.println("路径是===========" + annexPath);
|
|
|
273
|
+ PictureRenderData pictureRenderData = WordUtil
|
|
|
274
|
+ .rebuildImageContent(100, 100, null, annexPath);
|
|
|
275
|
+ //申请人证据材料
|
|
|
276
|
+ datas.put("appEvidenceMaterial", pictureRenderData);
|
|
|
277
|
+ }
|
|
|
278
|
+ }
|
|
|
279
|
+ }
|
|
|
280
|
+ }
|
|
253
|
281
|
datas.put("applicaCrossOpin", caseApplication1.getApplicaCrossOpin());
|
|
254
|
282
|
if (arbitrateRecord1 != null) {
|
|
255
|
283
|
datas.put("factDetermi", arbitrateRecord1.getFactDetermi());
|
|
|
@@ -261,10 +289,10 @@ public class TestPOIController {
|
|
261
|
289
|
datas.put("year", year);
|
|
262
|
290
|
String month = String.format("%02d", now.getMonthValue());
|
|
263
|
291
|
String day = String.format("%02d", now.getDayOfMonth());
|
|
264
|
|
- //String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
|
|
265
|
|
- String modalFilePath = "D:/develop/新裁决书模板.docx";
|
|
266
|
|
- //String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
267
|
|
- String saveFolderPath = "D:/data/" + year + "/" + month + "/" + day;
|
|
|
292
|
+ String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
|
|
|
293
|
+ // String modalFilePath = "D:/develop/新裁决书模板.docx";
|
|
|
294
|
+ String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
|
295
|
+ // String saveFolderPath = "D:/data/" + year + "/" + month + "/" + day;
|
|
268
|
296
|
String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
|
269
|
297
|
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
270
|
298
|
String resultFilePath = saveFolderPath + "/" + fileName;
|
|
|
@@ -311,11 +339,13 @@ public class TestPOIController {
|
|
311
|
339
|
caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
|
|
312
|
340
|
caseApplicationMapper.submitCaseApplication(caseApplication1);
|
|
313
|
341
|
return AjaxResult.success("裁决书已生成");
|
|
314
|
|
- } catch (IOException e) {
|
|
315
|
|
- return AjaxResult.error(e + "请检查文件路径是否有误");
|
|
316
|
|
- }
|
|
|
342
|
+ } catch(IOException e)
|
|
|
343
|
+ {
|
|
|
344
|
+ return AjaxResult.error(e + "请检查文件路径是否有误");
|
|
317
|
345
|
}
|
|
318
|
346
|
|
|
|
347
|
+}
|
|
|
348
|
+
|
|
319
|
349
|
public String getNewEquipmentNo() {
|
|
320
|
350
|
Object awardNum = redisCache.getCacheObject("awardNum");
|
|
321
|
351
|
if (awardNum == null) {
|
|
|
@@ -343,30 +373,22 @@ public class TestPOIController {
|
|
343
|
373
|
}
|
|
344
|
374
|
|
|
345
|
375
|
public static void main(String[] args) throws Exception {
|
|
346
|
|
- // 创建一个新的Word文档
|
|
347
|
|
- XWPFDocument document = new XWPFDocument();
|
|
348
|
|
-
|
|
349
|
|
- // 创建一个段落
|
|
350
|
|
- XWPFParagraph paragraph = document.createParagraph();
|
|
351
|
|
-
|
|
352
|
|
- // 创建一个文本区域
|
|
353
|
|
- XWPFRun run = paragraph.createRun();
|
|
354
|
|
-
|
|
355
|
|
- // 加载图片文件
|
|
356
|
|
- File imageFile = new File("D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg");
|
|
357
|
|
- FileInputStream fis = new FileInputStream(imageFile);
|
|
358
|
|
-
|
|
359
|
|
- // 将图片插入到文档中
|
|
360
|
|
- run.addPicture(fis, Document.PICTURE_TYPE_JPEG, "image.jpg", Units.toEMU(100), Units.toEMU(100));
|
|
361
|
|
-
|
|
362
|
|
- // 关闭输入流
|
|
363
|
|
- fis.close();
|
|
|
376
|
+ Map<String, Object> datas = new HashMap<String, Object>() {
|
|
|
377
|
+ {
|
|
|
378
|
+ //本地图片
|
|
|
379
|
+ put("resEvidenceMaterial", new PictureRenderData(100, 120, "D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg"));
|
|
|
380
|
+ //网路图片
|
|
|
381
|
+ // put("urlPicture", new PictureRenderData(100, 100, ".png", BytePictureUtils.getUrlByteArray("https://avatars3.githubusercontent.com/u/1394854?v=3&s=40")));
|
|
|
382
|
+ }
|
|
|
383
|
+ };
|
|
364
|
384
|
|
|
365
|
|
- // 保存文档
|
|
366
|
|
- String filePath= "D:\\develop\\"+UUID.randomUUID()+"document.docx";
|
|
367
|
|
- FileOutputStream fos = new FileOutputStream(filePath);
|
|
368
|
|
- document.write(fos);
|
|
369
|
|
- fos.close();
|
|
370
|
|
- }
|
|
|
385
|
+ XWPFTemplate template = XWPFTemplate.compile("D:\\develop\\新裁决书模板.docx")
|
|
|
386
|
+ .render(datas);
|
|
371
|
387
|
|
|
|
388
|
+ FileOutputStream out = new FileOutputStream("D:\\develop\\out_picture.docx");
|
|
|
389
|
+ template.write(out);
|
|
|
390
|
+ out.flush();
|
|
|
391
|
+ out.close();
|
|
|
392
|
+ template.close();
|
|
372
|
393
|
}
|
|
|
394
|
+}
|