From 4281f6c90e4a17845a5721ab51b3bc5c5409ab45 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期三, 07 一月 2026 23:27:04 +0800
Subject: [PATCH] 修改了对应代码

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java |  209 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 178 insertions(+), 31 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
index 6adca94..43f5975 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
@@ -68,6 +68,7 @@
 
 import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
 import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
+import static com.ruoyi.framework.datasource.DynamicDataSourceContextHolder.log;
 
 /**
  * 銆愭枃浠舵潗鏂欑患鍚堜俊鎭�慍ontroller
@@ -92,6 +93,11 @@
 
     @Autowired
     private IArchiveRecordsService iArchiveRecordsService;
+    
+    /**
+     * 鏂囦欢鍒嗛殧绗�
+     */
+    private static final String FILE_DELIMETER = ",";
     /**
      * 鍒ゆ柇PageNumber鏄惁杩炵画
      */
@@ -170,6 +176,8 @@
             list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
 
         }
+
+
         ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class);
         util.exportExcel(response, list, "鐢靛瓙鏂囦欢鐩綍");
     }
@@ -179,41 +187,47 @@
     @PostMapping("/exportDir")
     public void exportDir(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids)
     {
-        List<DocumentMaterials> list;
-        System.out.println(ids);
-        // 濡傛灉鎻愪緵浜唅ds鍙傛暟锛屽垯鏍规嵁ids瀵煎嚭鎸囧畾璁板綍
-        if (ids != null && ids.length > 0) {
-            list = documentMaterialsService.selectDocumentMaterialsByIds(ids);
-        } else {
-            list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
 
-        }
-        // 鏍规嵁visible瀛楁绛涢�夛紝鍙繚鐣檝isible涓�1鐨勮褰�
-        List<DocumentMaterials> filteredList = list.stream()
-                .filter(doc -> doc.getVisible() != null && doc.getVisible() == 1 && !Objects.equals(doc.getFileStyle(), "鍏朵粬鏉愭枡"))
-                .collect(Collectors.toList());
-        
-        // 浣跨敤AtomicLong瀹炵幇搴忓彿鐨勯�掑
-        AtomicLong nm = new AtomicLong(1L);
-        // 灏嗙瓫閫夊悗鐨凞ocumentMaterials杞崲涓篋ocumentMaterialsVo
-        List<DocumentMaterialsVoSmall> list1 = filteredList.stream().map(doc -> {
-            DocumentMaterialsVoSmall vo = new DocumentMaterialsVoSmall();
-            // 鎵嬪姩鏄犲皠瀛楁锛屼娇鐢╣etAndIncrement()鏂规硶鑾峰彇褰撳墠鍊煎苟閫掑
-            vo.setNum(nm.getAndIncrement());
+        List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(documentMaterials.getRecordId().toString());
 
-            vo.setDocumentNumber(doc.getDocumentNumber());
-            vo.setCreator(doc.getCreator());
-            vo.setTitle(doc.getTitle());
-            vo.setDate(doc.getDate());
-            vo.setPageNumberFormatted(doc.getPageNumber().toString());
-            vo.setRemarks(doc.getRemarks());
-//            vo.setRecordId(doc.getRecordId() != null ? doc.getRecordId().toString() : null);
-//            vo.setPublicity(doc.getPublicity());
-            return vo;
-        }).collect(Collectors.toList());
+        List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
+                res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList());
+
+//        List<DocumentMaterials> list;
+//        System.out.println(ids);
+//        // 濡傛灉鎻愪緵浜唅ds鍙傛暟锛屽垯鏍规嵁ids瀵煎嚭鎸囧畾璁板綍
+//        if (ids != null && ids.length > 0) {
+//            list = documentMaterialsService.selectDocumentMaterialsByIds(ids);
+//        } else {
+//            list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
+//
+//        }
+//        // 鏍规嵁visible瀛楁绛涢�夛紝鍙繚鐣檝isible涓�1鐨勮褰�
+//        List<DocumentMaterials> filteredList = list.stream()
+//                .filter(doc -> doc.getVisible() != null && doc.getVisible() == 1 && !Objects.equals(doc.getFileStyle(), "鍏朵粬鏉愭枡"))
+//                .collect(Collectors.toList());
+//
+//        // 浣跨敤AtomicLong瀹炵幇搴忓彿鐨勯�掑
+//        AtomicLong nm = new AtomicLong(1L);
+//        // 灏嗙瓫閫夊悗鐨凞ocumentMaterials杞崲涓篋ocumentMaterialsVo
+//        List<DocumentMaterialsVoSmall> list1 = filteredList.stream().map(doc -> {
+//            DocumentMaterialsVoSmall vo = new DocumentMaterialsVoSmall();
+//            // 鎵嬪姩鏄犲皠瀛楁锛屼娇鐢╣etAndIncrement()鏂规硶鑾峰彇褰撳墠鍊煎苟閫掑
+//            vo.setNum(nm.getAndIncrement());
+//
+//            vo.setDocumentNumber(doc.getDocumentNumber());
+//            vo.setCreator(doc.getCreator());
+//            vo.setTitle(doc.getTitle());
+//            vo.setDate(doc.getDate());
+//            vo.setPageNumberFormatted(doc.getPageNumber().toString());
+//            vo.setRemarks(doc.getRemarks());
+////            vo.setRecordId(doc.getRecordId() != null ? doc.getRecordId().toString() : null);
+////            vo.setPublicity(doc.getPublicity());
+//            return vo;
+//        }).collect(Collectors.toList());
         
         ExcelUtil<DocumentMaterialsVoSmall> util = new ExcelUtil<DocumentMaterialsVoSmall>(DocumentMaterialsVoSmall.class);
-        util.exportExcel(response, list1, "鍗峰唴鐩綍");
+        util.exportExcel(response, list2, "鍗峰唴鐩綍");
     }
 
    // List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
@@ -467,9 +481,14 @@
         String compName = "骞垮窞鐩堝妗f绠$悊鏈夐檺鍏徃";
         String li_person = "浠囩縺";
         String sh_person = "鏇剧憺鑾�";
+
         ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id);
         if(!StringUtils.isEmpty(archiveRecords.getLiPerson()))
             li_person = archiveRecords.getLiPerson();
+        String note_remark = "";
+        if(!StringUtils.isEmpty(archiveRecords.getNoteRemark()))
+            note_remark = "锛�"+archiveRecords.getNoteRemark();
+        System.out.println(note_remark+"{{{{");
         ArchiveProjectName tmp = new ArchiveProjectName();
         tmp.setName(archiveRecords.getProjectName());
         List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp);
@@ -522,6 +541,7 @@
         hs.put("company", compName);
         hs.put("liPerson", li_person);
         hs.put("shPerson", sh_person);
+        hs.put("noteRemark", note_remark);
         hs.put("time", cdt);
 
         if (!getLicense()) {
@@ -656,4 +676,131 @@
     }
 
 
+
+    @PostMapping("/uploads/{recordId}")
+    public AjaxResult uploadFiles(List<MultipartFile> files, @PathVariable Long recordId) throws Exception {
+        try {
+            // 涓婁紶鏂囦欢璺緞
+            String filePath = RuoYiConfig.getUploadPath();
+            List<String> urls = new ArrayList<>();
+            List<String> fileNames = new ArrayList<>();
+            List<String> newFileNames = new ArrayList<>();
+            List<String> originalFilenames = new ArrayList<>();
+
+            // 鎵归噺澶勭悊鏂囦欢涓婁紶
+            for (MultipartFile file : files) {
+                // 鏍规嵁鏂囦欢鍚嶇О锛岀劧鍚庝慨鏀瑰搴旀暟鎹殑url
+                String fname = file.getOriginalFilename();
+                if (StringUtils.isBlank(fname)) {
+                    continue;
+                }
+
+                // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+                String fileName = FileUploadUtils.upload(filePath, file);
+                String url = serverConfig.getUrl() + fileName;
+
+                // 鍒嗗壊鏂囦欢鍚�
+                String[] nams = fname.split("\\.");
+                if (nams.length < 2) {
+                    continue;
+                }
+
+                Long nam = Long.parseLong(nams[0]);
+
+                // 鏍规嵁椤靛彿鎷垮埌妗堝嵎鐨勮缁嗕俊鎭�
+                DocumentMaterials doc = documentMaterialsService.selectByPageNumber(nam, Math.toIntExact(recordId));
+                if (doc != null) {
+                    if (doc.getSecurityLevel() != null && (doc.getSecurityLevel().equals("璇ラ〉鍙﹀瓨")||
+                            doc.getSecurityLevel().equals("绉樺瘑")||doc.getSecurityLevel().equals("鍐呴儴鐢ㄩ��")||
+                            doc.getSecurityLevel().equals("鍐呴儴鐢ㄥ浘"))) {
+                        // 鏇挎崲涓轰簡鍑嗗濂界殑鍥惧儚
+                        String fp = filePath + "\\glc.jpg";
+                        Path path = Paths.get(fp);
+                        // 鎷垮埌鍥惧儚灞炴��
+                        BufferedImage bufferedImage = ImageIO.read(Files.newInputStream(path));
+                        int wid = bufferedImage.getWidth();
+                        int hei = bufferedImage.getHeight();
+                        double sz = Double.parseDouble(String.format("%.2f", Files.size(path) * 1.0 / 1024));
+
+                        // 鎷垮埌鍥惧儚鐨刣pi淇℃伅
+                        ImageInfo info = Imaging.getImageInfo(Files.readAllBytes(path));
+                        int wdpi = info.getPhysicalWidthDpi();
+                        int hdpi = info.getPhysicalHeightDpi();
+
+                        // 璁$畻fileNumber
+                        Long fileNumber = documentMaterialsService.getFiNum(nam, recordId);
+                        // 璁$畻sizeType
+                        String sizeType = getPageSize(wid * hei);
+
+                        Graphics2D g2d = bufferedImage.createGraphics();
+                        g2d.setFont(new Font("Arial", Font.BOLD, 80));
+                        g2d.setColor(Color.black);
+                        String pageNumber = doc.getPageNumber() + "";
+                        int fontHeight = g2d.getFontMetrics().getHeight();
+                        int x = bufferedImage.getWidth() - g2d.getFontMetrics().stringWidth(pageNumber) - 80;
+                        int y = bufferedImage.getHeight() - fontHeight / 2 - 100;
+                        g2d.drawString(pageNumber, x, y);
+                        g2d.dispose();
+
+                        // 灏咮ufferedImage杞崲涓篗ultipartFile
+                        MultipartFile multipartFile = null;
+                        ByteArrayOutputStream os = new ByteArrayOutputStream();
+                        ImageIO.write(bufferedImage, "jpg", os);
+                        InputStream input = new ByteArrayInputStream(os.toByteArray());
+                        multipartFile = new MockMultipartFile(pageNumber, pageNumber + ".jpg", "text/plain", input);
+
+                        // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+                        String fileName1 = FileUploadUtils.upload(filePath, multipartFile);
+
+                        // 鏇存柊鏁版嵁搴�
+                        documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId);
+
+                        urls.add(serverConfig.getUrl() + fileName1);
+                        fileNames.add(fileName1);
+                        newFileNames.add(FileUtils.getName(fileName1));
+                        originalFilenames.add(pageNumber + ".jpg");
+                    } else {
+                        // 鏂囦欢鍚嶇О
+                        String pname = nams[1];
+
+                        // 鎷垮埌鍥惧儚灞炴��
+                        BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
+                        int wid = bufferedImage.getWidth();
+                        int hei = bufferedImage.getHeight();
+                        double sz = Double.parseDouble(String.format("%.2f", file.getSize() * 1.0 / 1024));
+
+                        // 鎷垮埌鍥惧儚鐨刣pi淇℃伅
+                        ImageInfo info = Imaging.getImageInfo(file.getBytes());
+                        int wdpi = info.getPhysicalWidthDpi();
+                        int hdpi = info.getPhysicalHeightDpi();
+
+                        // 璁$畻fileNumber
+                        Long fileNumber = documentMaterialsService.getFiNum(nam, recordId);
+                        // 璁$畻sizeType
+                        String sizeType = getPageSize(wid * hei);
+
+                        // 鏇存柊鏁版嵁搴�
+                        documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName, pname, recordId);
+
+                        urls.add(url);
+                        fileNames.add(fileName);
+                        newFileNames.add(FileUtils.getName(fileName));
+                        originalFilenames.add(fname);
+                    }
+                }
+            }
+
+            AjaxResult ajax = AjaxResult.success();
+            ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
+            ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
+            ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
+            ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
+            return ajax;
+        } catch (Exception e) {
+            log.error("鎵归噺涓婁紶鏂囦欢澶辫触", e);
+            return AjaxResult.error(e.getMessage());
+        }
+    }
+
+
 }

--
Gitblit v1.9.1