From 2f1ae9c10a1751438d09b3d848677deb883631aa Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期三, 14 一月 2026 11:28:16 +0800
Subject: [PATCH] 修改了对应代码
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java | 329 +++++++++++++++++++++++++++++++++++-------------------
1 files changed, 211 insertions(+), 118 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 710af70..096deb8 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
@@ -15,6 +15,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
@@ -176,6 +177,8 @@
list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
}
+
+
ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class);
util.exportExcel(response, list, "鐢靛瓙鏂囦欢鐩綍");
}
@@ -185,11 +188,11 @@
@PostMapping("/exportDir")
public void exportDir(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids)
{
+ ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(documentMaterials.getRecordId());
+ List<DocumentMaterialsVoMid> dsvs = documentMaterialsService.findArchMInfoAll(documentMaterials.getRecordId().toString(), archiveRecords.getPageCount());
- List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(documentMaterials.getRecordId().toString());
-
- 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<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);
@@ -224,8 +227,8 @@
// return vo;
// }).collect(Collectors.toList());
- ExcelUtil<DocumentMaterialsVoSmall> util = new ExcelUtil<DocumentMaterialsVoSmall>(DocumentMaterialsVoSmall.class);
- util.exportExcel(response, list2, "鍗峰唴鐩綍");
+ ExcelUtil<DocumentMaterialsVoMid> util = new ExcelUtil<DocumentMaterialsVoMid>(DocumentMaterialsVoMid.class);
+ util.exportExcel(response, dsvs, "鍗峰唴鐩綍");
}
// List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
@@ -280,13 +283,13 @@
public String getPageSize(double du)
{
- if(du <= 8699840)
+ if(du <= 8699840 * 1.5)
return "A4";
- else if(du <= 17403188)
+ else if(du <= 17403188 * 1.5)
return "A3";
- else if(du <= 34811347)
+ else if(du <= 34811347 * 1.5)
return "A2";
- else if(du <= 69622674)
+ else if(du <= 69622674 * 1.5)
return "A1";
else
return "A0";
@@ -479,9 +482,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);
@@ -534,6 +542,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()) {
@@ -588,7 +597,9 @@
@PostMapping("/exportJuan/{id}")
public void exportJuanInfo(HttpServletResponse response, @PathVariable Long id) throws IOException {
- List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
+
+ ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id);
+ List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString(), archiveRecords.getPageCount());
//鎷垮埌鍗峰唴鐩綍鐨別xcel
List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
@@ -667,125 +678,207 @@
}
+ @PreAuthorize("@ss.hasPermi('system:materials:list')")
+ @GetMapping("/getFileCounts/{recordId}")
+ public AjaxResult getFileCounts(@PathVariable("recordId") Integer recordId) throws IOException {
+ //涓婁紶鐨勬椂鍊欏垽鏂渶澶氬彧鑳戒笂浼犲灏戜釜
+ // 涓婁紶鏂囦欢璺緞
+ String filePath = RuoYiConfig.getUploadPath();
+ AjaxResult ajax = AjaxResult.success();
+ String path = filePath + File.separator + recordId;
+ File desc = new File(filePath + File.separator + recordId);
+ System.out.println("44444444444444456666666666666666");
+ if (!desc.exists())
+ {
+ ajax.put("length", 0);
+// 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;
+ }
+ Map<String, String> fileMap = new HashMap<>();
+ try (Stream<Path> paths = Files.walk(Paths.get(path))) {
+ fileMap = paths
+ .filter(Files::isRegularFile)
+ .collect(Collectors.toMap(
+ // Key: 鏂囦欢鍚嶅墠缂�锛堜笉甯︽墿灞曞悕锛�
+ Path -> {
+ String fileNam = Path.getFileName().toString();
+ int dotIndex = fileNam.lastIndexOf('.');
+ return dotIndex > 0 ? fileNam.substring(0, dotIndex) : fileNam;
+ },
+ // Value: 鏂囦欢鍏ㄨ矾寰�
+ Path::toString,
+ // 澶勭悊閲嶅閿殑鎯呭喌锛堝鏋滄湁鐩稿悓鍓嶇紑鐨勬枃浠讹級
+ (existing, replacement) -> existing
+ ));
+ System.out.println(fileMap);
+
+ ajax.put("length", fileMap.size());
+// 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;
+ }
+ }
@PostMapping("/uploads/{recordId}")
- public AjaxResult uploadFiles(List<MultipartFile> files, @PathVariable Long recordId) throws Exception {
+ public AjaxResult uploadFiles(MultipartFile file, @PathVariable Long recordId) throws Exception {
try {
+
+ //涓婁紶鐨勬椂鍊欏垽鏂渶澶氬彧鑳戒笂浼犲灏戜釜
// 涓婁紶鏂囦欢璺緞
String filePath = RuoYiConfig.getUploadPath();
+
+ String path = filePath + File.separator + recordId;
+ File desc = new File(filePath + File.separator + recordId);
+ System.out.println("44444444444444456666666666666666");
+ if (!desc.exists())
+ {
+ System.out.println("4444444444444445688888666666666666666");
+ System.out.println(desc.getParentFile().exists());
+ if (!desc.exists())
+ {
+ desc.mkdirs();
+ }
+ }
+
+ String fileName = FileUploadUtils.uploadImg(filePath + File.separator + recordId, file);
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("璇ラ〉鍙﹀瓨")) {
- // 鏇挎崲涓轰簡鍑嗗濂界殑鍥惧儚
- 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);
- }
- }
+ Map<String, String> fileMap = new HashMap<>();
+ try (Stream<Path> paths = Files.walk(Paths.get(path))) {
+ fileMap = paths
+ .filter(Files::isRegularFile)
+ .collect(Collectors.toMap(
+ // Key: 鏂囦欢鍚嶅墠缂�锛堜笉甯︽墿灞曞悕锛�
+ Path -> {
+ String fileNam = Path.getFileName().toString();
+ int dotIndex = fileNam.lastIndexOf('.');
+ return dotIndex > 0 ? fileNam.substring(0, dotIndex) : fileNam;
+ },
+ // Value: 鏂囦欢鍏ㄨ矾寰�
+ Path::toString,
+ // 澶勭悊閲嶅閿殑鎯呭喌锛堝鏋滄湁鐩稿悓鍓嶇紑鐨勬枃浠讹級
+ (existing, replacement) -> existing
+ ));
+ System.out.println(fileMap);
+ AjaxResult ajax = AjaxResult.success();
+ ajax.put("length", file.getSize());
+// 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;
}
+ //璇诲彇
+ //
+//
+// // 鎵归噺澶勭悊鏂囦欢涓婁紶
+// 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