Просмотр исходного кода

Merge branch 'hjb' of SH-Arbitrate/Arbitrate-Backend into dev

hejinbo 2 лет назад
Родитель
Сommit
2092e5d64d

+ 63
- 41
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/TestPOIController.java Просмотреть файл

@@ -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
+}

+ 1
- 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java Просмотреть файл

@@ -146,7 +146,7 @@ public class WordUtil {
146 146
     public static PictureRenderData rebuildImageContent(Integer with, Integer height, String imageUrl, String relatedPath) {
147 147
         PictureRenderData pictureRenderData = null;
148 148
         if (!StringUtils.isBlank(imageUrl)) {
149
-            // pictureRenderData = Pictures.of(imageUrl).size(with, height).create();
149
+            //pictureRenderData = Pictures.of(imageUrl).size(with, height).create();
150 150
             //Pictures.PictureBuilder pictureBuilder = Pictures.of("https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/1EtCRvm.png");
151 151
         } else if (!StringUtils.isBlank(relatedPath)) {
152 152
             pictureRenderData = Pictures.ofLocal(relatedPath).size(with, height).create();

+ 58
- 8
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Просмотреть файл

@@ -2,6 +2,7 @@ package com.ruoyi.wisdomarbitrate.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.alibaba.fastjson.JSONObject;
5
+import com.deepoove.poi.data.PictureRenderData;
5 6
 import com.ruoyi.common.constant.CaseApplicationConstants;
6 7
 import com.ruoyi.common.core.domain.AjaxResult;
7 8
 import com.ruoyi.common.core.redis.RedisCache;
@@ -36,6 +37,7 @@ import java.nio.file.StandardCopyOption;
36 37
 import java.text.SimpleDateFormat;
37 38
 import java.time.LocalDate;
38 39
 import java.util.*;
40
+import java.util.regex.Pattern;
39 41
 
40 42
 import static com.ruoyi.common.utils.SecurityUtils.getUsername;
41 43
 
@@ -254,10 +256,34 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
254 256
             }
255 257
             datas.put("claims", caseApplication1.getArbitratClaims());
256 258
             datas.put("request", caseApplication1.getRequestRule());
257
-            //申请人证据材料
258
-            datas.put("appEvidenceMaterial", null);
259
-            //被申请人证据材料
260
-            datas.put("resEvidenceMaterial","(详见附件列表)");
259
+            CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication);
260
+            List<CaseAttach> caseAttachList1 = caseApplication2.getCaseAttachList();
261
+            if (caseAttachList1 != null && caseAttachList1.size() > 0) {
262
+                for (CaseAttach caseAttach : caseAttachList1) {
263
+                    if (caseAttach.getAnnexType() == 6) {   //被申请人证据材料
264
+                        String annexName = caseAttach.getAnnexName();
265
+                        boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
266
+                        if (isImageFile) {
267
+                            String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
268
+                            System.out.println("路径是===========" + annexPath);
269
+                            PictureRenderData pictureRenderData = WordUtil
270
+                                    .rebuildImageContent(100, 100, null, annexPath);
271
+                            datas.put("resEvidenceMaterial", pictureRenderData);
272
+                        }
273
+                    } else if (caseAttach.getAnnexType() == 2) {   //申请人证据材料
274
+                        String annexName = caseAttach.getAnnexName();
275
+                        boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
276
+                        if (isImageFile) {
277
+                            String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
278
+                            System.out.println("路径是===========" + annexPath);
279
+                            PictureRenderData pictureRenderData = WordUtil
280
+                                    .rebuildImageContent(100, 100, null, annexPath);
281
+                            //申请人证据材料
282
+                            datas.put("appEvidenceMaterial", pictureRenderData);
283
+                        }
284
+                    }
285
+                }
286
+            }
261 287
             datas.put("applicaCrossOpin", caseApplication1.getApplicaCrossOpin());
262 288
             if (arbitrateRecord1 != null) {
263 289
                 datas.put("factDetermi", arbitrateRecord1.getFactDetermi());
@@ -804,10 +830,34 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
804 830
             }
805 831
             datas.put("claims", caseApplication1.getArbitratClaims());
806 832
             datas.put("request", caseApplication1.getRequestRule());
807
-            //申请人证据材料
808
-            datas.put("appEvidenceMaterial", null);
809
-            //被申请人证据材料
810
-            datas.put("resEvidenceMaterial","(详见附件列表)");
833
+            CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication);
834
+            List<CaseAttach> caseAttachList1 = caseApplication2.getCaseAttachList();
835
+            if (caseAttachList1 != null && caseAttachList1.size() > 0) {
836
+                for (CaseAttach caseAttach : caseAttachList1) {
837
+                    if (caseAttach.getAnnexType() == 6) {   //被申请人证据材料
838
+                        String annexName = caseAttach.getAnnexName();
839
+                        boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
840
+                        if (isImageFile) {
841
+                            String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
842
+                            System.out.println("路径是===========" + annexPath);
843
+                            PictureRenderData pictureRenderData = WordUtil
844
+                                    .rebuildImageContent(100, 100, null, annexPath);
845
+                            datas.put("resEvidenceMaterial", pictureRenderData);
846
+                        }
847
+                    } else if (caseAttach.getAnnexType() == 2) {   //申请人证据材料
848
+                        String annexName = caseAttach.getAnnexName();
849
+                        boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
850
+                        if (isImageFile) {
851
+                            String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
852
+                            System.out.println("路径是===========" + annexPath);
853
+                            PictureRenderData pictureRenderData = WordUtil
854
+                                    .rebuildImageContent(100, 100, null, annexPath);
855
+                            //申请人证据材料
856
+                            datas.put("appEvidenceMaterial", pictureRenderData);
857
+                        }
858
+                    }
859
+                }
860
+            }
811 861
             datas.put("applicaCrossOpin", caseApplication1.getApplicaCrossOpin());
812 862
             if (arbitrateRecord1 != null) {
813 863
                 datas.put("factDetermi", arbitrateRecord1.getFactDetermi());