archiveManager/pom.xml
@@ -116,6 +116,8 @@ <artifactId>spring-test</artifactId> </dependency> </dependencies> </project> archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java
@@ -27,11 +27,11 @@ /** $column.columnComment */ @TableId(type = IdType.AUTO) private Long materialId; @Excel(name = "文件材料序号", handler = NumberFormatHandler.class) @Excel(name = "文件材料序号", handler = NumberFormatHandler.class, headerColor = IndexedColors.BLACK) private Long fileNumber; @Excel(name = "文件编号") @Excel(name = "文件编号", headerColor = IndexedColors.BLACK) private String documentNumber; @@ -58,9 +58,10 @@ private Date date; /** $column.columnComment */ @Excel(name = "页号", handler = NumberFormatHandler.class, headerColor = IndexedColors.BLACK) // @Excel(name = "页号", handler = NumberFormatHandler.class, headerColor = IndexedColors.BLACK) private Long pageNumber; @Excel(name = "页号", height = 10,width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) private String pageNumberFormatted; /** $column.columnComment */ @Excel(name = "页次", headerColor = IndexedColors.BLACK) private Long pageOrder; archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java
@@ -26,9 +26,12 @@ @Excel(name = "日期", width = 10, dateFormat = "yyyy-MM-dd", height = 10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) private Date date; @Excel(name = "页号", height = 10,width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) // 页号(原始数值,用于计算) private Long pageNumber; // 格式化后的页号,用于显示范围,如"38-38"或"23-38" @Excel(name = "页号", height = 10,width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) private String pageNumberFormatted; @Excel(name = "备注", height = 20,width=10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) private String remarks; @@ -42,3 +45,6 @@ // @Excel(name = "图片", cellType = Excel.ColumnType.IMAGE) // private String url; } archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoSmall.java
@@ -27,18 +27,18 @@ private Date date; @Excel(name = "页号",width = 10, headerFontSize=12, headerColor = IndexedColors.BLACK, headerFontBold = true) private String pageNumberFormatted; private Long pageNumber; @Excel(name = "备注",width = 8, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) private String remarks; public DocumentMaterialsVoSmall(Long num, String documentNumber, String creator, String title, Date date, Long pageNumber, String remarks) { public DocumentMaterialsVoSmall(Long num, String documentNumber, String creator, String title, Date date, String pageNumberFormatted, String remarks) { this.num = num; this.documentNumber = documentNumber; this.creator = creator; this.title = title; this.date = date; this.pageNumber = pageNumber; this.pageNumberFormatted = pageNumberFormatted; this.remarks = remarks; } archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
@@ -72,6 +72,10 @@ @Select("select count(*) FROM document_materials where file_style!='其他材料' and record_id=#{recordId}") int getCount(@Param("recordId") int recordId); //获取指定案卷的最大页号 @Select("select max(page_number) FROM document_materials where record_id=#{recordId}") Long getMaxPageNumber(@Param("recordId") int recordId); //判断卷内目录是否全部上传了附件 @Select("select if(num=total_count, true, false) as res from (\n" + @@ -84,3 +88,4 @@ Boolean judgeArchiveInfo( @Param("recordId") int recordId); } archiveManager/src/main/java/com/ruoyi/service/IArchiveRecordsService.java
@@ -97,6 +97,8 @@ public int updateStatusByIds(Long [] ids); public List<ArchiveRecordSmall> findByIds(ArchiveRecords archiveRecords); AjaxResult mySave(ArchiveRecords archiveRecords); boolean whether(@Param("recordId") Long recordId); archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
@@ -15,13 +15,13 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.vo.AnalysisResult; import com.ruoyi.domain.vo.ArchiveInfoVo; import com.ruoyi.domain.vo.ArchiveRecordSmall; import com.ruoyi.mapper.ArchiveRecordsMapper; import com.ruoyi.mapper.ArchiverecordstouserMapper; import com.ruoyi.service.IArchiveRecordsService; import com.ruoyi.service.IArchiverecordstouserService; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -41,6 +41,9 @@ // @Autowired // private ArchiveRecordsMapper archiveRecordsMapper; @Autowired private IArchiverecordstouserService archiverecordstouserService; @Autowired private ArchiverecordstouserMapper archiverecordstouserMapper; @@ -373,6 +376,11 @@ @Override public int updateArchiveById(String status, Long id) { // 获取当前用户ID Long userId = SecurityUtils.getUserId(); // 可以在这里使用userId进行授权操作 archiverecordstouserService.deleteArchiverecordstouserByRecordId(id, userId); this.baseMapper.updateStatusById(status, id); return 0; } @@ -394,9 +402,8 @@ } @Override public AjaxResult mySave(ArchiveRecords archiveRecords) { //检查是否有重复数据插入 LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>(); lqw.eq(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId,archiveRecords.getRecordId()); @@ -430,3 +437,4 @@ return this.baseMapper.whether(recordId); } } archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
@@ -129,8 +129,9 @@ @Override public int insertDocumentMaterials(DocumentMaterials documentMaterials) { LocalDateTime time = LocalDateTime.now(); LocalDateTime time = LocalDateTime.now(); Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); documentMaterials.setCreatedAt(date); System.out.println(documentMaterials.getFileStyle()); @@ -142,7 +143,6 @@ boolean res = false; try { res = this.save(documentMaterials); } catch (Exception e) { System.out.println(e); throw new ErrorcodeExceptionextends(500, "同一个案卷内,不允许页码重复!"); @@ -265,7 +265,32 @@ @Override public List<DocumentMaterialsVo> findArchMInfo(String recordId) { return this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId)); // 获取原始数据列表 List<DocumentMaterialsVo> dataList = this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId)); // 获取该案卷的最大页号(总页数) Long totalPages = this.baseMapper.getMaxPageNumber(Integer.parseInt(recordId)); // 如果数据列表不为空 if (dataList != null && !dataList.isEmpty() && totalPages != null) { int size = dataList.size(); // 遍历所有条目,设置pageNumberFormatted for (int i = 0; i < size; i++) { DocumentMaterialsVo item = dataList.get(i); Long pageNumber = item.getPageNumber(); if (i == size - 1) { // 最后一行:格式化页号为"最后一页页号-总页数"的形式 item.setPageNumberFormatted(pageNumber + "-" + totalPages); } else { // 其他行:直接使用pageNumber的值 item.setPageNumberFormatted(pageNumber != null ? pageNumber.toString() : ""); } } } return dataList; } @Override @@ -291,6 +316,32 @@ BeanUtils.copyProperties(archiveCategory, documentMaterials); documentMaterials.setRecordId(Long.parseLong(recordId)); documentMaterials.setVisible(1); // 验证必填字段 if (StringUtils.isEmpty(documentMaterials.getTitle())) { throw new ErrorcodeExceptionextends(400, "文件题名不能为空"); } if (StringUtils.isEmpty(documentMaterials.getFileStyle())) { throw new ErrorcodeExceptionextends(400, "材料类型不能为空"); } // 材料类型不是"其它材料"时,页号必须输入 if (!"其他材料".equals(documentMaterials.getFileStyle()) && documentMaterials.getPageNumber() == null) { throw new ErrorcodeExceptionextends(400, "当前材料类型非其它材料,页号必须输入"); } if (StringUtils.isEmpty(documentMaterials.getIsAttachment())) { throw new ErrorcodeExceptionextends(400, "是否为附件不能为空"); } if (StringUtils.isEmpty(documentMaterials.getStage())) { throw new ErrorcodeExceptionextends(400, "所处阶段不能为空"); } if (StringUtils.isEmpty(documentMaterials.getRetentionPeriod())) { throw new ErrorcodeExceptionextends(400, "保管期限不能为空"); } if (StringUtils.isEmpty(documentMaterials.getIsSensitive())) { throw new ErrorcodeExceptionextends(400, "是否敏感不能为空"); } if (StringUtils.isEmpty(documentMaterials.getIsCanceled())) { throw new ErrorcodeExceptionextends(400, "是否注销不能为空"); } this.insertDocumentMaterials(documentMaterials); } @@ -431,3 +482,5 @@ } ruoyi-admin/pom.xml
@@ -139,11 +139,15 @@ <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.5.15</version> <configuration> <includeSystemScope>true</includeSystemScope> <mainClass>com.ruoyi.RuoYiApplication</mainClass> <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 --> </configuration> <executions> @@ -169,9 +173,16 @@ <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> <!-- <compilerArgs>--> <!-- <arg>-XDignore.symbol.file</arg>--> <!-- </compilerArgs>--> <!-- <fork>true</fork>--> </configuration> </plugin> </plugins> <finalName>${project.artifactId}</finalName> </build> ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -14,7 +14,6 @@ import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.common.utils.poi.ExcelExp; import com.ruoyi.common.utils.poi.ExcelUtilManySheetFour; import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.*; ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
@@ -25,17 +25,20 @@ import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.common.utils.poi.ExcelExp; import com.ruoyi.common.utils.poi.ExcelUtilManySheet; import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond; import com.ruoyi.domain.ArchiveCategory; import com.ruoyi.domain.ArchiveProjectName; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.*; import com.ruoyi.framework.config.ServerConfig; import com.ruoyi.framework.web.domain.server.Sys; import com.ruoyi.service.IArchiveProjectNameService; import com.ruoyi.service.IArchiveRecordsService; import com.ruoyi.service.IDocumentMaterialsService; import com.ruoyi.service.impl.BarcodeService; @@ -72,6 +75,8 @@ @RequestMapping("/system/materials") public class DocumentMaterialsController extends BaseController { @Autowired private IArchiveProjectNameService iArchiveProjectNameService; @Autowired private BarcodeService barcodeService; @Autowired @@ -452,6 +457,23 @@ { //09-备考表.pdf String pdf09Path = "09-备考表.pdf"; //根据项目名称拿到公司名称和项目负责人 String compName = "广州盈家档案管理有限公司"; String li_person = "仇翀"; String sh_person = "曾瑞莹"; ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id); ArchiveProjectName tmp = new ArchiveProjectName(); tmp.setName(archiveRecords.getProjectName()); List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp); if(!projectName.isEmpty()) { if(StringUtils.isEmpty(projectName.get(0).getCompanyName())) compName = projectName.get(0).getCompanyName(); if(StringUtils.isEmpty(projectName.get(0).getCreatePerson())) li_person = projectName.get(0).getCreatePerson(); } // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id); //拿到相关数据 List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); @@ -484,6 +506,7 @@ hs.put("picPages", picPages); hs.put("texPages", texPages); hs.put("volumeNumber", recordId); hs.put("company", compName); hs.put("time", cdt); if (!getLicense()) { @@ -494,9 +517,21 @@ try { // 获取 Word 模板所在路径 String filepath = "09-备考表.docx"; // String filepath = "09-备考表.docx"; // // 通过 XWPFTemplate 编译文件并渲染数据到模板中 // XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs // ); // 获取 Word 模板所在路径 ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); org.springframework.core.io.Resource resource = resolver.getResource("classpath:09.docx"); // String filepath = resource.getFile().getAbsolutePath(); // // 通过 XWPFTemplate 编译文件并渲染数据到模板中 // XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs // ); InputStream inputStream = resource.getInputStream(); // 通过 XWPFTemplate 编译文件并渲染数据到模板中 XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs XWPFTemplate template = XWPFTemplate.compile(inputStream).render(hs ); String renderedDocPath = "rendered_output.docx"; @@ -530,7 +565,7 @@ //拿到卷内目录的excel List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(), res1.getTitle(), res1.getDate(), res1.getPageNumber(), res1.getRemarks())).collect(Collectors.toList()); res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList()); if(!dsvs.isEmpty()) { String recordId = dsvs.get(0).getRecordId(); byte[] imgr = barcodeService.generateBarcodeImage(recordId); ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
@@ -6,11 +6,14 @@ import com.itextpdf.text.*; import com.itextpdf.text.pdf.PdfPCell; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.common.utils.poi.*; import com.ruoyi.domain.ArchiveProjectName; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.*; import com.ruoyi.service.IArchiveProjectNameService; import com.ruoyi.service.IArchiveRecordsService; import com.ruoyi.service.IDocumentMaterialsService; import com.ruoyi.service.impl.BarcodeService; @@ -53,7 +56,8 @@ private BarcodeService barcodeService; @Autowired private IDocumentMaterialsService documentMaterialsService; @Autowired private IArchiveProjectNameService iArchiveProjectNameService; @Autowired private IArchiveRecordsService iArchiveRecordsService; @@ -569,12 +573,30 @@ picPages = documentMaterialFileStyle.getCnt(); } } String compName = "广州盈家档案管理有限公司"; String li_person = "仇翀"; String sh_person = "曾瑞莹"; ArchiveRecords archiveRecords1 = iArchiveRecordsService.selectArchiveRecordsById(ids[i]); ArchiveProjectName tmp = new ArchiveProjectName(); tmp.setName(archiveRecords1.getProjectName()); List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp); if(!projectName.isEmpty()) { if(StringUtils.isEmpty(projectName.get(0).getCompanyName())) compName = projectName.get(0).getCompanyName(); if(StringUtils.isEmpty(projectName.get(0).getCreatePerson())) li_person = projectName.get(0).getCreatePerson(); } allPages = texPages + picPages + patPages; hs.put("pages", allPages); hs.put("patPages", patPages); hs.put("picPages", picPages); hs.put("texPages", texPages); hs.put("volumeNumber", aIV.getRecordId()); hs.put("company", compName); hs.put("time", cdt); if (!getLicense()) { @@ -584,10 +606,16 @@ try { // 获取 Word 模板所在路径 String filepath = "09-备考表.docx"; ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); org.springframework.core.io.Resource resource = resolver.getResource("classpath:09.docx"); // String filepath = resource.getFile().getAbsolutePath(); // // 通过 XWPFTemplate 编译文件并渲染数据到模板中 // XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs // ); InputStream inputStream = resource.getInputStream(); // 通过 XWPFTemplate 编译文件并渲染数据到模板中 XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs XWPFTemplate template = XWPFTemplate.compile(inputStream).render(hs ); String renderedDocPath = "rendered_output.docx"; @@ -726,7 +754,7 @@ //拿到卷内目录的excel List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(), res1.getTitle(), res1.getDate(), res1.getPageNumber(), res1.getRemarks())).collect(Collectors.toList()); res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList()); if(!dsvs.isEmpty()) { String recordId = dsvs.get(0).getRecordId(); byte[] imgr = barcodeService.generateBarcodeImage(recordId); @@ -1097,12 +1125,30 @@ picPages = documentMaterialFileStyle.getCnt(); } } String compName = "广州盈家档案管理有限公司"; String li_person = "仇翀"; String sh_person = "曾瑞莹"; ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id); ArchiveProjectName tmp = new ArchiveProjectName(); tmp.setName(archiveRecords.getProjectName()); List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp); if(!projectName.isEmpty()) { if(StringUtils.isEmpty(projectName.get(0).getCompanyName())) compName = projectName.get(0).getCompanyName(); if(StringUtils.isEmpty(projectName.get(0).getCreatePerson())) li_person = projectName.get(0).getCreatePerson(); } allPages = texPages + picPages + patPages; hs.put("pages", allPages); hs.put("patPages", patPages); hs.put("picPages", picPages); hs.put("texPages", texPages); hs.put("volumeNumber", aIV.getRecordId()); hs.put("company", compName); hs.put("time", cdt); if (!getLicense()) { @@ -1113,10 +1159,22 @@ try { // 获取 Word 模板所在路径 String filepath = "09-备考表.docx"; ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); org.springframework.core.io.Resource resource = resolver.getResource("classpath:09.docx"); // String filepath = resource.getFile().getAbsolutePath(); // // 通过 XWPFTemplate 编译文件并渲染数据到模板中 // XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs // ); InputStream inputStream = resource.getInputStream(); // 通过 XWPFTemplate 编译文件并渲染数据到模板中 XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs XWPFTemplate template = XWPFTemplate.compile(inputStream).render(hs ); String renderedDocPath = "rendered_output.docx"; File renderedFile = new File(renderedDocPath); @@ -1148,7 +1206,7 @@ com.aspose.words.Document doc = new com.aspose.words.Document("09-备考表.docx"); // com.aspose.words.Document doc = new com.aspose.words.Document("09.docx"); @@ -1271,7 +1329,7 @@ //拿到卷内目录的excel List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res -> new DocumentMaterialsVoSmall(res.getNum(), res.getDocumentNumber(),res.getCreator(), res.getTitle(), res.getDate(), res.getPageNumber(), res.getRemarks())).collect(Collectors.toList()); res.getTitle(), res.getDate(), res.getPageNumberFormatted(), res.getRemarks())).collect(Collectors.toList()); String recordId = dsvs.get(0).getRecordId(); byte[] imgr = barcodeService.generateBarcodeImage(recordId); ruoyi-common/pom.xml
@@ -147,10 +147,40 @@ <version>5.5.13</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.sun.xml.messaging.saaj</groupId> <artifactId>saaj-impl</artifactId> <version>3.0.2</version> </dependency> <!-- 也可以同时添加这个 --> <dependency> <groupId>javax.xml.soap</groupId> <artifactId>javax.xml.soap-api</artifactId> <version>1.4.0</version> </dependency> </dependencies> <!-- <build>--> <!-- <plugins>--> <!-- <plugin>--> <!-- <groupId>org.apache.maven.plugins</groupId>--> <!-- <artifactId>maven-compiler-plugin</artifactId>--> <!-- <version>3.1</version>--> <!-- <configuration>--> <!-- <source>1.8</source>--> <!-- <target>1.8</target>--> <!-- <encoding>UTF-8</encoding>--> <!-- <compilerArgs>--> <!-- <arg>-XDignore.symbol.file</arg>--> <!-- </compilerArgs>--> <!-- <fork>true</fork>--> <!-- </configuration>--> <!-- </plugin>--> <!-- </plugins>--> <!-- </build>--> <!-- <build>--> <!-- <plugins>--> <!-- <plugin>--> <!-- <groupId>org.apache.maven.plugins</groupId>--> ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java
@@ -541,7 +541,7 @@ style.setWrapText(true); Font headerFont = wb.createFont(); headerFont.setFontName(excel.headerFontName()); headerFont.setFontHeightInPoints((short) 12); headerFont.setFontHeightInPoints((short) 10); headerFont.setBold(excel.headerFontBold()); headerFont.setColor(excel.headerColor().index); style.setFont(headerFont);