archiveManager/pom.xml
@@ -78,6 +78,16 @@ <scope>compile</scope> </dependency> <!-- Apache HttpClient依赖 --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.14</version> </dependency> </dependencies> </project> archiveManager/src/main/java/com/ruoyi/domain/ArchiveProjectName.java
@@ -26,6 +26,13 @@ private String name; private Date createTime; @Excel(name = "公司名称") private String companyName; @Excel(name = "项目负责人") private String createPerson; @Override public void setCreateTime(Date createTime) { this.createTime = createTime; archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
@@ -125,11 +125,22 @@ @TableField(exist = false) private String archiveRecordsId; public Long[] getIds() { return ids; } public void setIds(Long[] ids) { this.ids = ids; } @TableField(exist = false) // private String archiveStatus private Long userId; @TableField(exist = false) private Long [] ids; @Override public Date getCreateTime() { archiveManager/src/main/java/com/ruoyi/domain/vo/ArchiveRecordSmall.java
New file @@ -0,0 +1,39 @@ package com.ruoyi.domain.vo; import com.ruoyi.common.annotation.Excel; import lombok.Data; @Data public class ArchiveRecordSmall { /** 档案号 */ @Excel(name = "序号") private Long num; @Excel(name = "立案号") private String filingNumber; /** 档案管(室)号 */ @Excel(name = "档案发文号_档号") private String inqrid; /** 案卷题名 */ @Excel(name = "案卷题名") private String caseTitle; @Excel(name = "公开属性") private String publicAttribute; /** 缩微号 */ @Excel(name = "电子文件个数") private Long cnt; @Excel(name = "备注") private String remarks; } archiveManager/src/main/java/com/ruoyi/domain/vo/RecordToUserCount.java
New file @@ -0,0 +1,14 @@ package com.ruoyi.domain.vo; import lombok.Data; @Data public class RecordToUserCount { private Long userId; private String userName; private Long cnt; private Long swlr; private Long ylr; } archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
@@ -7,6 +7,7 @@ import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.vo.AnalysisResult; import com.ruoyi.domain.vo.ArchiveInfoVo; import com.ruoyi.domain.vo.ArchiveRecordSmall; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -19,7 +20,7 @@ @Select({ "<script>", "SELECT distinct c.*,a.archive_records_id,b.user_id, if(a.user_id=#{userId}, TRUE, FALSE) as tst FROM archiverecordstouser a inner join sys_user b ON a.user_id = b.user_id right join archive_records c on c.record_id=a.archive_records_id ${ew.customSqlSegment} ", "SELECT distinct c.*,a.archive_records_id, if(a.user_id=#{userId}, TRUE, FALSE) as tst FROM archiverecordstouser a inner join sys_user b ON a.user_id = b.user_id right join archive_records c on c.record_id=a.archive_records_id ${ew.customSqlSegment} ", "<if test= \"userId !=1 \">", "order by tst desc", "</if>", @@ -40,4 +41,12 @@ "(select count(*) from archive_records as ac where ac.every_project_name=ar.every_project_name and record_status='录入完成') as finished \n" + " from archive_records as ar GROUP BY every_project_name") List<AnalysisResult> statisticAyasis(); @Select("update archive_records set record_status='录入完成' where id=#{id}") public void updateStatusById(@Param("id")Long id); @Select("select ROW_NUMBER() OVER (ORDER BY record_id) AS num, filing_number, concat_ws(\" \", inquiry_number,record_id) as inqrid, case_title, public_attribute, (select count(*) as cnt from document_materials where record_id=ar.id) as cnt, remarks from archive_records as ar \n" + "${ew.customSqlSegment}") public List<ArchiveRecordSmall> selectByIds(@Param("ew") LambdaQueryWrapper<ArchiveRecords> queryWrapper); } archiveManager/src/main/java/com/ruoyi/mapper/ArchiverecordstouserMapper.java
@@ -2,11 +2,14 @@ import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.vo.RecordToUserCount; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; /** @@ -16,7 +19,12 @@ * @date 2025-07-20 */ @Mapper public interface ArchiverecordstouserMapper extends BaseMapper<Archiverecordstouser> { public interface ArchiverecordstouserMapper extends BaseMapper<Archiverecordstouser> { @Select("select ad.user_id, user_name, count(*) as cnt, (select count(*) from archive_records as ar,archiverecordstouser as ats, sys_user as su where ar.record_id= ats.archive_records_id and ats.user_id=su.user_id and su.user_id=sy.user_id and\n" + "record_status='未录入') as swlr,(select count(*) from archive_records as ar,archiverecordstouser as ats, sys_user as su where ar.record_id= ats.archive_records_id and ats.user_id=su.user_id and su.user_id=sy.user_id and\n" + "record_status='录入完成') as ylr from archiverecordstouser as ad, sys_user as sy,archive_records as ard where ad.user_id=sy.user_id and ard.record_id=ad.archive_records_id ${ew.customSqlSegment} group by user_id, user_name") Page<RecordToUserCount> selectRecordToUserPage(Page<RecordToUserCount> page, @Param("ew") LambdaQueryWrapper<RecordToUserCount> queryWrapper); } archiveManager/src/main/java/com/ruoyi/service/IArchiveDoublePdfGenerateService.java
New file @@ -0,0 +1,5 @@ package com.ruoyi.service; public interface IArchiveDoublePdfGenerateService { public void testConnection(); } archiveManager/src/main/java/com/ruoyi/service/IArchiveRecordsService.java
@@ -4,6 +4,7 @@ import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.vo.AnalysisResult; import com.ruoyi.domain.vo.ArchiveInfoVo; import com.ruoyi.domain.vo.ArchiveRecordSmall; import org.apache.ibatis.annotations.Param; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -82,4 +83,9 @@ List<AnalysisResult> statisticAya(); public int updateArchiveById(Long id); public List<ArchiveRecordSmall> findByIds(ArchiveRecords archiveRecords); } archiveManager/src/main/java/com/ruoyi/service/IArchiverecordstouserService.java
@@ -3,6 +3,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.vo.RecordToUserCount; import java.util.List; @@ -74,4 +75,7 @@ public int queryArchiverecordstouserByRecordId(String recordId, Long userId); public AjaxResult countStatistic(String username, int pageNum, int pageSize); } archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
@@ -16,6 +16,7 @@ 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; @@ -44,10 +45,18 @@ private LambdaQueryWrapper<ArchiveRecords> buildCondition(ArchiveRecords archiveRecords, Long userId){ LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>(); System.out.println(archiveRecords.getIds()); lqw.like(!StringUtils.isEmpty(archiveRecords.getProjectName()), ArchiveRecords::getProjectName, archiveRecords.getProjectName()) .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber()) .like(!StringUtils.isEmpty(archiveRecords.getArchiveRoomNumber()), ArchiveRecords::getArchiveRoomNumber, archiveRecords.getArchiveRoomNumber()) .like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId()); .like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId()) .eq(!StringUtils.isEmpty(archiveRecords.getRecordStatus()), ArchiveRecords::getRecordStatus, archiveRecords.getRecordStatus()) ; if(archiveRecords.getIds()!=null) lqw.in(ArchiveRecords::getId,new ArrayList<>(Arrays.asList(archiveRecords.getIds()))); // .like(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation()) // .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) // .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress()) @@ -257,6 +266,21 @@ return this.baseMapper.statisticAyasis(); } @Override public int updateArchiveById(Long id) { this.baseMapper.updateStatusById(id); return 0; } @Override public List<ArchiveRecordSmall> findByIds(ArchiveRecords archiveRecords) { LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>(); if(archiveRecords.getIds()!=null) lqw.in(ArchiveRecords::getId,new ArrayList<>(Arrays.asList(archiveRecords.getIds()))); return this.baseMapper.selectByIds(lqw); } public AjaxResult mySave(ArchiveRecords archiveRecords) { archiveManager/src/main/java/com/ruoyi/service/impl/ArchiverecordstouserServiceImpl.java
@@ -1,6 +1,7 @@ package com.ruoyi.service.impl; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -13,7 +14,9 @@ import com.ruoyi.common.utils.MapUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.vo.RecordToUserCount; import com.ruoyi.mapper.ArchiverecordstouserMapper; import com.ruoyi.service.IArchiverecordstouserService; import com.ruoyi.system.mapper.SysUserMapper; @@ -210,4 +213,30 @@ else return 0; } @Override public AjaxResult countStatistic(String username, int pageNum, int pageSize) { LambdaQueryWrapper<RecordToUserCount> lqw = new LambdaQueryWrapper<>(); if(username!=null) lqw.like(!StringUtils.isEmpty(username), RecordToUserCount::getUserName, username); Page<RecordToUserCount> page = new Page<>(pageNum, pageSize); // 使用自定义的分页查询方法,先连接再分页 Page<RecordToUserCount> pageResult = this.baseMapper.selectRecordToUserPage(page, lqw); List<RecordToUserCount> beanRecords = pageResult.getRecords();//得到查询出来的数据 HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); return AjaxResult.success(data); } } archiveManager/src/main/java/com/ruoyi/service/impl/IArchiveDoublePdfGenerateServiceImpl.java
New file @@ -0,0 +1,125 @@ package com.ruoyi.service.impl; import com.ruoyi.service.IArchiveDoublePdfGenerateService; import org.apache.http.HttpEntity; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.ParseException; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.springframework.stereotype.Service; import java.io.IOException; import java.net.URI; import java.nio.file.Files; import java.nio.file.Paths; import java.util.UUID; @Service public class IArchiveDoublePdfGenerateServiceImpl implements IArchiveDoublePdfGenerateService { private final String OCRServer = "http://127.0.0.1:1224/"; private String MUL_LAYER_PDF_URL = OCRServer + "api/doc/upload"; private String MUL_LAYER_PDF_STATE_URL = OCRServer + "api/doc/result"; private String MUL_LAYER_PDF_DOWNLOAD_URL = OCRServer + "api/doc/download"; public void testConnection() { // 获得Http客户端(可以理解为:你得先有一个浏览器;注意:实际上HttpClient与浏览器是不一样的) CloseableHttpClient httpClient = HttpClientBuilder.create().build(); // 创建Get请求 HttpGet httpGet = new HttpGet(OCRServer); // 响应模型 CloseableHttpResponse response = null; try { // 由客户端执行(发送)Get请求 response = httpClient.execute(httpGet); // 从响应模型中获取响应实体 HttpEntity responseEntity = response.getEntity(); System.out.println("响应状态为:" + response.getStatusLine()); if (responseEntity != null) { System.out.println("响应内容长度为:" + responseEntity.getContentLength()); System.out.println("响应内容为:" + EntityUtils.toString(responseEntity)); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { // 释放资源 if (httpClient != null) { httpClient.close(); } if (response != null) { response.close(); } } catch (IOException e) { e.printStackTrace(); } } } public void doublePdfGenerate() throws IOException { // 构建请求URL和文件路径 String url = "http://127.0.0.1:1224/api/doc/upload"; String path = "测试文件.pdf"; String options_json = "{\"doc.extractionMode\": \"fullPage\"}"; // 创建HttpClient实例 // HttpClient client = HttpClient.newHttpClient(); //// 生成boundary用于分隔表单数据 // String boundary = UUID.randomUUID().toString(); // //// 构建multipart/form-data请求体 // StringBuilder sb = new StringBuilder(); //// 添加JSON参数部分 // sb.append("--").append(boundary).append("\r\n"); // sb.append("Content-Disposition: form-data; name=\"json\"\r\n"); // sb.append("Content-Type: application/json\r\n"); // sb.append("\r\n"); // sb.append(options_json).append("\r\n"); // //// 添加文件部分 // sb.append("--").append(boundary).append("\r\n"); // sb.append("Content-Disposition: form-data; name=\"file\"; filename=\"") // .append(Paths.get(path).getFileName()).append("\"\r\n"); // sb.append("Content-Type: application/pdf\r\n"); // 明确指定PDF类型 // sb.append("\r\n"); // //// 读取文件内容并构建完整请求体 // byte[] fileBytes = Files.readAllBytes(Paths.get(path)); // byte[] requestBody = new byte[sb.toString().getBytes().length + fileBytes.length // + ("\r\n--" + boundary + "--\r\n").getBytes().length]; // System.arraycopy(sb.toString().getBytes(), 0, requestBody, 0, sb.toString().getBytes().length); // System.arraycopy(fileBytes, 0, requestBody, sb.toString().getBytes().length, fileBytes.length); // System.arraycopy(("\r\n--" + boundary + "--\r\n").getBytes(), 0, requestBody, // sb.toString().getBytes().length + fileBytes.length, // ("\r\n--" + boundary + "--\r\n").getBytes().length); // //// 创建并发送请求 // HttpRequest request = HttpRequest.newBuilder() // .uri(URI.create(url)) // .header("Content-Type", "multipart/form-data; boundary=" + boundary) // .POST(HttpRequest.BodyPublishers.ofByteArray(requestBody)) // .build(); // //// 处理响应 // HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); // System.out.println("响应状态码: " + response.statusCode()); // System.out.println("响应内容: " + response.body()); } } archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
@@ -12,9 +12,11 @@ import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.vo.DocumentMaterialFileStyle; import com.ruoyi.domain.vo.DocumentMaterialsVo; import com.ruoyi.domain.vo.DocumentMaterialsVoSmall; import com.ruoyi.service.IArchiveRecordsService; import com.ruoyi.service.IDocumentMaterialsService; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.*; @@ -28,6 +30,9 @@ import java.io.*; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; @Service @@ -36,6 +41,9 @@ private BarcodeService barcodeService; @Autowired private IDocumentMaterialsService documentMaterialsService; @Autowired private IArchiveRecordsService iArchiveRecordsService; //生产二维码 public byte[] createQrCodeN(String content, int width, int height) throws IOException { QrConfig config = new QrConfig(width, height); @@ -475,7 +483,7 @@ } public void generatePdf(String pdfPath) throws IOException, DocumentException { public void generatePdf(String pdfPath, Long id) throws IOException, DocumentException { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(pdfPath)); @@ -483,7 +491,23 @@ String [] tits = {"档 号:","档案馆(室)号:","缩 微 号: ","发 文 号:", "案 卷 题 名:","编 制 日 期:","编 制 单 位:","保 管 期 限:","密 级:"}; String [] cons = {"D3.4.1-05-2024-0002","","","穗规划资源建证〔2024〕2033号","广州市自来水有限公司白云区江高镇江高镇政府西侧、江府路北侧白云区江高镇江高镇政府西侧、江府路北侧新装供水管工程","2024-04-23","广州市规划和自然资源局白云区分局","永久",""}; ArchiveRecords ard = iArchiveRecordsService.selectArchiveRecordsById(id); String formattedDate = ""; if(ard.getPreparationDate()!=null) { LocalDate date = ard.getPreparationDate().toInstant() .atZone(ZoneId.systemDefault()) .toLocalDate(); ; System.out.println("当前日期: " + date); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); formattedDate = date.format(formatter); } String [] cons = {ard.getRecordId(),ard.getArchiveRoomNumber(),ard.getMicrofilmNumber(),ard.getInquiryNumber(),ard.getCaseTitle(),formattedDate,ard.getPreparationUnit(), ard.getRetentionPeriod(),ard.getSecurityClassification()}; //把图片加入到pdf当中 Image img = Image.getInstance(createQrCodeN(cons[0], 80, 80)); ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -144,4 +144,12 @@ return archiveRecordsService.importExcel(file); } @PreAuthorize("@ss.hasPermi('system:records:edit')") @Log(title = "修改状态", businessType = BusinessType.IMPORT) @GetMapping(value = "/updateStatusById/{id}") public AjaxResult updateStatusById(@PathVariable("id") String id) { return new AjaxResult(200, archiveRecordsService.updateArchiveById(Long.parseLong(id))+""); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiverecordstouserController.java
@@ -77,6 +77,18 @@ } @PreAuthorize("@ss.hasPermi('system:archiverecordstouser:list')") @GetMapping("/listArToUser") public AjaxResult listAllUserRecord(String userName ) { Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); System.out.println(userName); return archiverecordstouserService.countStatistic(userName,pageNum, pageSize); } /** * 导出【请填写功能名称】列表 */ ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DoublePdfGenerateController.java
New file @@ -0,0 +1,30 @@ package com.ruoyi.web.controller.archive; import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.domain.ArchiveCategory; import com.ruoyi.service.IArchiveDoublePdfGenerateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; @Anonymous @RestController @RequestMapping("/doublePdf") public class DoublePdfGenerateController { @Autowired private IArchiveDoublePdfGenerateService iArchiveDoublePdfGenerateService; @GetMapping("/testConn") public AjaxResult testCon() { iArchiveDoublePdfGenerateService.testConnection(); return AjaxResult.success("2134"); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
@@ -12,11 +12,9 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtilManySheet; import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.ArchiveInfoVo; import com.ruoyi.domain.vo.DocumentMaterialsVo; import com.ruoyi.domain.vo.DocumentMaterialsVoLarge; import com.ruoyi.domain.vo.DocumentMaterialsVoSmall; import com.ruoyi.domain.vo.*; import com.ruoyi.framework.web.domain.server.Sys; import com.ruoyi.service.IArchiveRecordsService; import com.ruoyi.service.IDocumentMaterialsService; @@ -30,6 +28,7 @@ import org.apache.poi.xssf.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -43,6 +42,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.List; import java.util.stream.Collectors; @@ -121,7 +122,173 @@ @PostMapping("/exportChooseArchive/{ids}") public void exportChooseArchive(HttpServletResponse response, @PathVariable Long[] ids)throws Exception { System.out.println("092939932"); String zipFileName ="test" +".zip"; //生成压缩包存储地址(最后会删掉) String fileZip = RuoYiConfig.getProfile() + "/download/" + zipFileName; OutputStream os=null; ZipOutputStream zos = null ; System.out.println("==============_______________"); System.out.println(ids.length); File file = new File(fileZip); try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } os = new FileOutputStream(file); //压缩文件 zos = new ZipOutputStream(os); //拿到当前的时间 LocalDate date = LocalDate.now(); System.out.println("当前日期: " + date); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); String formattedDate = date.format(formatter); System.out.println(formattedDate); String fna = "GH"+20250908+"/"; zos.putNextEntry(new ZipEntry(fna)); //添加ids的全部数据到excel ArchiveRecords archiveRecords = new ArchiveRecords(); archiveRecords.setIds(ids); List<ArchiveRecords> lis = iArchiveRecordsService.selectArchiveRecordsList(archiveRecords); //案卷目录导出 ZipEntry entry = new ZipEntry("案卷目录" + ".xls"); ExcelUtil<ArchiveRecords> util = new ExcelUtil<ArchiveRecords>(ArchiveRecords.class); zos.putNextEntry(entry); ByteOutputStream bos = new ByteOutputStream(); util.byteOutputStreamExcel(bos, lis,"案卷目录", ""); bos.writeTo(zos); //移交清单 List<ArchiveRecordSmall> lrs = iArchiveRecordsService.findByIds(archiveRecords); System.out.println(lrs); ZipEntry entry1 = new ZipEntry("移交清单" + ".xls"); ExcelUtil<ArchiveRecordSmall> util1 = new ExcelUtil<ArchiveRecordSmall>(ArchiveRecordSmall.class); zos.putNextEntry(entry1); ByteOutputStream bos1 = new ByteOutputStream(); util1.byteOutputStreamExcel(bos1, lrs,"移交清单", ""); bos1.writeTo(zos); for(int i = 0; i < ids.length; i++) { // 获取文件的保存位置,读取数据库, DocumentMaterials documentMaterials = new DocumentMaterials(); documentMaterials.setRecordId(ids[i]); List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]); System.out.println(docs.size()+"----009"); //.selectDocumentMaterialsList(documentMaterials); List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(ids[i].toString()); ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]); String adir = aIV.getInquiryNumber() + " " + aIV.getRecordId(); System.out.println(fna+adir); zos.putNextEntry(new ZipEntry(fna + adir + "/")); //在里面添加文件 boolean res = true; if(res) { zos.putNextEntry(new ZipEntry(fna + adir + "/01-申请材料/")); zos.putNextEntry(new ZipEntry(fna + adir + "/02-办案过程材料/")); zos.putNextEntry(new ZipEntry(fna + adir + "/03-结论性文件/")); zos.putNextEntry(new ZipEntry(fna + adir + "/04-其他材料/")); zos.putNextEntry(new ZipEntry(fna + adir + "/05-档案变更材料/")); zos.putNextEntry(new ZipEntry(fna + adir + "/06-业务数据/")); res = false; } //添加07 的pdf //pdf目录封面 String pdfPathF = "07-卷面封面.pdf"; pdfGenerateService.generatePdf(pdfPathF, ids[i]); // 2. 压缩PDF到ZIP文件 // 添加PDF文件到ZIP ZipEntry zipEntry2 = new ZipEntry(fna + adir +"/"+pdfPathF); zos.putNextEntry(zipEntry2); // 读取PDF文件内容并写入ZIP try (FileInputStream fis = new FileInputStream(pdfPathF)) { byte[] buffer = new byte[1024]; int len; while ((len = fis.read(buffer)) > 0) { zos.write(buffer, 0, len); } } byte[] buf = new byte[1024]; for (DocumentMaterialsVoLarge dc : docs) { String filePath = dc.getUrl(); if(filePath==null) continue; filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); System.out.println(filePath); File tempFile = new File(filePath); //在压缩包中添加文件夹 //得到文件名frontCompWithZore(4, dc.get)+ String fname = frontCompWithZore(4, dc.getFileNumber().intValue())+"-"+dc.getTitle()+"-"+frontCompWithZore(4,dc.getPageNumber().intValue())+"." +dc.getUrl().split("\\.")[1]; if(dc.getStage().equals("01-申请材料")) zos.putNextEntry(new ZipEntry(fna + adir + "/01-申请材料/"+fname)); else if(dc.getStage().equals("02-办案过程材料")) zos.putNextEntry(new ZipEntry(fna + adir + "/02-办案过程材料/"+fname)); else if(dc.getStage().equals("03-结论性文件")) zos.putNextEntry(new ZipEntry(fna + adir + "/03-结论性文件/"+fname)); else if(dc.getStage().equals("04-其他材料")) { zos.putNextEntry(new ZipEntry(fna + adir + "/04-其他材料/" + fname)); } else if(dc.getStage().equals("05-档案变更材料")) zos.putNextEntry(new ZipEntry(fna + adir + "/05-档案变更材料/"+fname)); else if(dc.getStage().equals("06-业务数据")) zos.putNextEntry(new ZipEntry(fna + adir + "/06-业务数据/"+fname)); else zos.putNextEntry(new ZipEntry(fna + adir + "/"+fname)); int len; FileInputStream in = new FileInputStream(tempFile); while ((len = in.read(buf)) != -1){ zos.write(buf, 0, len); } // zos.putNextEntry(new ZipEntry("04-其他材料")); zos.closeEntry(); in.close(); } } System.out.println(file.getName()); writeFileToRes(response, file.getName(), file); } catch (Exception e) { throw new RuntimeException(e); }finally { //关闭流 if(zos != null){ try { zos.close(); } catch (IOException e) { e.printStackTrace(); } } //关闭流 if(os!= null){ try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } } @@ -133,9 +300,9 @@ * @param response * @param */ @PostMapping("/export") @PostMapping("/export/{id}") public void packDownload(HttpServletResponse response, Long id) throws Exception { public void packDownload(HttpServletResponse response, @PathVariable Long id) throws Exception { // 获取文件的保存位置,读取数据库, DocumentMaterials documentMaterials = new DocumentMaterials(); documentMaterials.setRecordId(id); @@ -170,6 +337,7 @@ System.out.println(file.getName()); String fileName =aIV.getRecordId()+".zip"; //输出文件流 writeFileToRes(response, file.getName(), file); //删除压缩包 @@ -253,7 +421,7 @@ //pdf目录封面 String pdfPathF = "07-卷面封面.pdf"; pdfGenerateService.generatePdf(pdfPathF); pdfGenerateService.generatePdf(pdfPathF, 55L); // 2. 压缩PDF到ZIP文件 // 添加PDF文件到ZIP ZipEntry zipEntry = new ZipEntry(pdfPathF); @@ -374,6 +542,8 @@ byte[] buf = new byte[1024]; for (DocumentMaterialsVoLarge dc : docs) { String filePath = dc.getUrl(); if(filePath==null) continue; filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); System.out.println(filePath);