| | |
| | | } |
| | | |
| | | // @Excel(name = "项目名称", headerColor = IndexedColors.BLACK) |
| | | |
| | | @Excel(name = "项目名称", type = Excel.Type.IMPORT) |
| | | private String everyProjectName; |
| | | /** 案卷题名 */ |
| | | @Excel(name = "案卷题名", headerColor = IndexedColors.RED, width = 10) |
| | |
| | | if (StringUtils.isEmpty(categoryNumberStart) || StringUtils.isEmpty(categoryNumberEnd)) { |
| | | lqw.like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId()); |
| | | } |
| | | else { |
| | | // else { |
| | | lqw. |
| | | like(!StringUtils.isEmpty(archiveRecords.getInquiryNumber()), ArchiveRecords::getInquiryNumber, archiveRecords.getInquiryNumber()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getCaseTitle()), ArchiveRecords::getCaseTitle, archiveRecords.getCaseTitle()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute()) |
| | | |
| | | .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getPreparationUnit()), ArchiveRecords::getPreparationUnit, archiveRecords.getPreparationUnit()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getRetentionPeriod()), ArchiveRecords::getRetentionPeriod, archiveRecords.getRetentionPeriod()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getSecurityClassification()), ArchiveRecords::getSecurityClassification, archiveRecords.getSecurityClassification()) |
| | |
| | | .like(!StringUtils.isEmpty(archiveRecords.getEveryProjectName()), ArchiveRecords::getEveryProjectName, archiveRecords.getEveryProjectName()) |
| | | .like(!StringUtils.isEmpty(archiveRecords.getRemarks()), ArchiveRecords::getRemarks, archiveRecords.getRemarks()); |
| | | |
| | | } |
| | | // } |
| | | |
| | | if(archiveRecords.getIds()!=null) |
| | | lqw.in(ArchiveRecords::getId,new ArrayList<>(Arrays.asList(archiveRecords.getIds()))); |
| | |
| | | for (ArchiveRecords archiveRecords : dataList) { |
| | | // physcialService.mySave(physcial); |
| | | archiveRecords.setRecordStatus("未录入"); |
| | | System.out.println(archiveRecords.getProjectName()); |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | |
| | | String title = ""; |
| | | if(archiveRecords.getConstructionUnit()!=null) |
| | | title = title +archiveRecords.getConstructionUnit(); |
| | | if(archiveRecords.getConstructionAddress()!=null) |
| | | title = title + archiveRecords.getConstructionAddress(); |
| | | if(archiveRecords.getProjectName()!=null) |
| | | title = title + archiveRecords.getProjectName(); |
| | | archiveRecords.setCaseTitle(title); |
| | | Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); |
| | | archiveRecords.setCreateTime(date); |
| | | this.mySave(archiveRecords); |
| | |
| | | // 获取当前用户ID |
| | | Long userId = SecurityUtils.getUserId(); |
| | | // 可以在这里使用userId进行授权操作 |
| | | if(operator.equals("退回管理员")) |
| | | if(operator.equals("退回管理员")||status.equals("录入完成")) |
| | | archiverecordstouserService.deleteArchiverecordstouserByRecordId(id, userId); |
| | | this.baseMapper.updateStatusById(status, id, date); |
| | | return 0; |
| | |
| | | public byte[] generateBarcodeImage(String barcodeText) { |
| | | try { |
| | | // 使用 BitMatrix 生成纯条码,不包含任何文字 |
| | | BarcodeFormat format = BarcodeFormat.CODE_39; // 根据您的条码类型 |
| | | BarcodeFormat format = BarcodeFormat.CODE_128; // 根据您的条码类型 |
| | | |
| | | // 创建编码器 |
| | | Code39Writer writer = new Code39Writer(); |
| | | Code128Writer writer = new Code128Writer(); |
| | | |
| | | // 编码参数 |
| | | Map<EncodeHintType, Object> hints = new HashMap<>(); |
| | |
| | | } |
| | | |
| | | // 添加自定义文字 |
| | | g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, |
| | | RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
| | | g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); |
| | | g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); |
| | | |
| | | Font font = new Font("Tahoma", Font.BOLD, 18); |
| | | Font font = new Font("Tahoma", Font.PLAIN, 20); |
| | | g2d.setFont(font); |
| | | |
| | | FontMetrics fm = g2d.getFontMetrics(); |
| | |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelExp; |
| | |
| | | System.out.println(compName+"--+"+sh_person); |
| | | // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id); |
| | | //拿到相关数据 |
| | | List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | // List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | |
| | | |
| | | List<DocumentMaterials> docAllInfo = documentMaterialsService.SelectAllRecordsByPageNumbersToList(id, archiveRecords.getPageCount()); |
| | | if (docAllInfo==null||docAllInfo.isEmpty()) |
| | | { |
| | | throw new RuntimeException("请补充完整信息,然后导出ISO包!"); |
| | | } |
| | | //把DocumentMaterils转到docs |
| | | // List<DocumentMaterialsVoLarge> docs = new ArrayList<>(); |
| | | int texPages = 0; |
| | | int patPages = 0; |
| | | int picPages = 0; |
| | | for (DocumentMaterials mater : docAllInfo) { |
| | | |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("文字材料")) |
| | | texPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("图样材料")) |
| | | patPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("照片材料")) |
| | | picPages++; |
| | | } |
| | | |
| | | |
| | | LocalDate currentDate = LocalDate.now(); |
| | | |
| | |
| | | |
| | | HashMap<String, Object> hs = new HashMap<String, Object>(); |
| | | int allPages = 0; |
| | | int texPages = 0; |
| | | int picPages = 0; |
| | | int patPages = 0; |
| | | if(!dmfs.isEmpty()) |
| | | { |
| | | for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs) |
| | | { |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料")) |
| | | texPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料")) |
| | | patPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料")) |
| | | picPages = documentMaterialFileStyle.getCnt(); |
| | | } |
| | | } |
| | | |
| | | |
| | | allPages = texPages + picPages + patPages; |
| | | hs.put("pages", allPages); |
| | | hs.put("patPages", patPages); |
| | |
| | | @PostMapping("/exportJuan/{id}") |
| | | |
| | | public void exportJuanInfo(HttpServletResponse response, @PathVariable Long id) throws IOException { |
| | | System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa"); |
| | | |
| | | ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id); |
| | | System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa"); |
| | | |
| | | if(archiveRecords.getPageCount()==null) |
| | | return; |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString(), archiveRecords.getPageCount()); |
| | | System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa"); |
| | | |
| | | //拿到卷内目录的excel |
| | | 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()); |
| | | System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa"); |
| | | |
| | | if(!dsvs.isEmpty()) { |
| | | System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa"); |
| | | |
| | | String recordId = dsvs.get(0).getRecordId(); |
| | | byte[] imgr = barcodeService.generateBarcodeImage(recordId); |
| | | ExcelExp e1 = new ExcelExp("卷内目录数据", dsvs, DocumentMaterialsVo.class); |
| | |
| | | // System.out.println(dsvs); |
| | | // zos.putNextEntry(entr); |
| | | ByteOutputStream bos8 = new ByteOutputStream(); |
| | | |
| | | System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa"); |
| | | util2.exportExcelManySheet(bos8, mysheet); |
| | | |
| | | bos8.writeTo( response.getOutputStream()); |
| | |
| | | //把DocumentMaterils转到docs |
| | | List<DocumentMaterialsVoLarge> docs = new ArrayList<>(); |
| | | int nstar = 1; |
| | | |
| | | //统计3中材料的个数 |
| | | int texPages = 0; |
| | | int picPages = 0; |
| | | int patPages = 0; |
| | | for (DocumentMaterials mater : docAllInfo) { |
| | | // physcialService.mySave(physcial); |
| | | DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge(); |
| | |
| | | docum.setRecordId(archiveRecords1.getRecordId()); |
| | | docum.setNum(nstar++); |
| | | docs.add(docum); |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("文字材料")) |
| | | texPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("图样材料")) |
| | | patPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("照片材料")) |
| | | picPages++; |
| | | } |
| | | |
| | | |
| | |
| | | dc.setHorizontalResolution((long) wdpi); |
| | | dc.setVerticalResolution((long) hdpi); |
| | | dc.setSizeType(sizeType); |
| | | fileMap.put(dc.getPageNumber()+"", fp); |
| | | fileMap.put(dc.getPageNumber()+"", fileName1); |
| | | // dc.set |
| | | // 更新数据库 |
| | | // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId); |
| | |
| | | System.out.println(dc.getPageNumber()); |
| | | String fip = fileMap.get(dc.getPageNumber().toString()); |
| | | // 创建 File 对象 |
| | | if (fip == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | fip = fileMap.get(paddedKey); |
| | | } |
| | | File fils = new File(fip); |
| | | |
| | | // 使用 ImageIO 读取图片 |
| | |
| | | |
| | | HashMap<String, Object> hs = new HashMap<String, Object>(); |
| | | int allPages = 0; |
| | | int texPages = 0; |
| | | int picPages = 0; |
| | | int patPages = 0; |
| | | if(!dmfs.isEmpty()) |
| | | { |
| | | for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs) |
| | | { |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料")) |
| | | texPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料")) |
| | | patPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料")) |
| | | picPages = documentMaterialFileStyle.getCnt(); |
| | | } |
| | | } |
| | | // int texPages = 0; |
| | | // int picPages = 0; |
| | | // int patPages = 0; |
| | | // if(!dmfs.isEmpty()) |
| | | // { |
| | | // for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs) |
| | | // { |
| | | // if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料")) |
| | | // texPages = documentMaterialFileStyle.getCnt(); |
| | | // if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料")) |
| | | // patPages = documentMaterialFileStyle.getCnt(); |
| | | // if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料")) |
| | | // picPages = documentMaterialFileStyle.getCnt(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | String compName = "广州盈家档案管理有限公司"; |
| | |
| | | // 创建PDF保存选项 |
| | | com.aspose.cells.PdfSaveOptions pdfSaveOptions = new com.aspose.cells.PdfSaveOptions(); |
| | | pdfSaveOptions.setCompliance(com.aspose.cells.PdfCompliance.PDF_A_1_B); |
| | | // 确保字体嵌入到PDF中 |
| | | |
| | | |
| | | // 创建临时字节输出流 |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | |
| | |
| | | byte[] buf = new byte[1024]; |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | String filePath = fileMap.get(dc.getPageNumber().toString()); |
| | | if(filePath==null) |
| | | continue; |
| | | |
| | | // filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | System.out.println(filePath); |
| | | if (filePath == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | filePath = fileMap.get(paddedKey); |
| | | } |
| | | if(filePath==null) |
| | | continue; |
| | | |
| | | if(filePath.contains("profile")) |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | File tempFile = new File(filePath); |
| | | |
| | | //在压缩包中添加文件夹 |
| | |
| | | //把DocumentMaterils转到docs |
| | | List<DocumentMaterialsVoLarge> docs = new ArrayList<>(); |
| | | int nstar = 1; |
| | | int texPages = 0; |
| | | int patPages = 0; |
| | | int picPages = 0; |
| | | for (DocumentMaterials mater : docAllInfo) { |
| | | // physcialService.mySave(physcial); |
| | | DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge(); |
| | |
| | | docum.setRecordId(aIV.getRecordId()); |
| | | docum.setNum(nstar++); |
| | | docs.add(docum); |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("文字材料")) |
| | | texPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("图样材料")) |
| | | patPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("照片材料")) |
| | | picPages++; |
| | | } |
| | | System.out.println(docs.size()+"----009"); |
| | | |
| | |
| | | dc.setHorizontalResolution((long) wdpi); |
| | | dc.setVerticalResolution((long) hdpi); |
| | | dc.setSizeType(sizeType); |
| | | fileMap.put(dc.getPageNumber()+"", fp); |
| | | System.out.println(fileName1); |
| | | System.out.println("gggggggggggggggg999999999999"); |
| | | fileMap.put(dc.getPageNumber()+"", fileName1); |
| | | // dc.set |
| | | // 更新数据库 |
| | | // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId); |
| | |
| | | //拿到图像属性 |
| | | System.out.println(dc.getPageNumber()); |
| | | String fip = fileMap.get(dc.getPageNumber().toString()); |
| | | // 如果直接匹配失败,尝试补零匹配 |
| | | if (fip == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | fip = fileMap.get(paddedKey); |
| | | } |
| | | // 创建 File 对象 |
| | | if(fip==null||fip.equals("")) |
| | | { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | File file = new File(fip); |
| | | |
| | | // 使用 ImageIO 读取图片 |
| | |
| | | //压缩文件 |
| | | List<String> filePathList = paths; |
| | | //把docmentMaterial转为 |
| | | File file = compressedFileToZip(docs, dsvs, aIV, id, fileMap); |
| | | File file = compressedFileToZip(docs, dsvs, aIV, id, fileMap, texPages, patPages, picPages); |
| | | System.out.println(file.getName()); |
| | | |
| | | String fileName =aIV.getRecordId()+".zip"; |
| | |
| | | |
| | | |
| | | // 压缩文件 |
| | | private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id, Map<String, String> fileMap) throws Exception { |
| | | private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id, Map<String, String> fileMap, |
| | | int texPages, |
| | | int patPages, |
| | | int picPages) throws Exception { |
| | | //压缩包具体名称(拼接时间戳防止重名) |
| | | String datumName = ""; |
| | | String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip"; |
| | |
| | | String pdf09Path = "09-备考表.pdf"; |
| | | // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id); |
| | | //拿到相关数据 |
| | | List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | // List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | |
| | | LocalDate currentDate = LocalDate.now(); |
| | | |
| | |
| | | |
| | | HashMap<String, Object> hs = new HashMap<String, Object>(); |
| | | int allPages = 0; |
| | | int texPages = 0; |
| | | int picPages = 0; |
| | | int patPages = 0; |
| | | if(!dmfs.isEmpty()) |
| | | { |
| | | for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs) |
| | | { |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料")) |
| | | texPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料")) |
| | | patPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料")) |
| | | picPages = documentMaterialFileStyle.getCnt(); |
| | | } |
| | | } |
| | | // int texPages = 0; |
| | | // int picPages = 0; |
| | | // int patPages = 0; |
| | | // if(!docs.isEmpty()) |
| | | // { |
| | | // for(DocumentMaterialsVoLarge documentMaterialFileStyle:docs) |
| | | // { |
| | | // if(documentMaterialFileStyle!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料")) |
| | | // texPages = documentMaterialFileStyle.getCnt(); |
| | | // if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料")) |
| | | // patPages = documentMaterialFileStyle.getCnt(); |
| | | // if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料")) |
| | | // picPages = documentMaterialFileStyle.getCnt(); |
| | | // } |
| | | // } |
| | | |
| | | String compName = "广州盈家档案管理有限公司"; |
| | | String li_person = "仇翀"; |
| | |
| | | byte[] buf = new byte[1024]; |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | String filePath = fileMap.get(dc.getPageNumber().toString()); |
| | | if(filePath==null) |
| | | continue; |
| | | |
| | | |
| | | // else { |
| | | // // 文件名称 |
| | |
| | | // |
| | | |
| | | |
| | | if (filePath == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | filePath = fileMap.get(paddedKey); |
| | | System.out.println(paddedKey); |
| | | |
| | | } |
| | | System.out.println(filePath); |
| | | |
| | | if(filePath==null) |
| | | continue; |
| | | |
| | | if(filePath.contains("profile")) |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | File tempFile = new File(filePath); |
| | | System.out.println(filePath); |
| | |
| | | uri-encoding: UTF-8 |
| | | # 连接数满后的排队数,默认为100 |
| | | accept-count: 1000 |
| | | connection-timeout: 150000 # 20秒 |
| | | keep-alive-timeout: 150000 # 长连接超时 |
| | | max-keep-alive-requests: 100 |
| | | threads: |
| | | # tomcat最大线程数,默认为200 |
| | | max: 800 |
| | |
| | | try |
| | | { |
| | | // 设置行高为自动调整 |
| | | row.setHeight((short) -1); |
| | | // row.setHeight((short) -1); |
| | | // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. |
| | | if (attr.isExport()) |
| | | { |
| | |
| | | sheet.addMergedRegion(new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column)); |
| | | } |
| | | } |
| | | cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText()))); |
| | | |
| | | // cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText()))); |
| | | // 获取并修改样式 |
| | | CellStyle style = styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())); |
| | | Workbook workbook = row.getSheet().getWorkbook(); |
| | | CellStyle newStyle = workbook.createCellStyle(); |
| | | newStyle.cloneStyleFrom(style); |
| | | newStyle.setWrapText(true); // 关键:启用自动换行 |
| | | cell.setCellStyle(newStyle); |
| | | // 用于读取对象中的属性 |
| | | Object value = getTargetValue(vo, field, attr); |
| | | String dateFormat = attr.dateFormat(); |
| | |
| | | // 设置列类型 |
| | | setCellVo(value, attr, cell); |
| | | } |
| | | adjustRowHeightAfterSetValue(row, cell, value); |
| | | |
| | | addStatisticsData(column, Convert.toStr(value), attr); |
| | | } |
| | | } |
| | |
| | | } |
| | | return cell; |
| | | } |
| | | /** |
| | | * 设置值后调整行高 |
| | | */ |
| | | private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) { |
| | | if (value == null) return; |
| | | |
| | | String text = value.toString(); |
| | | Sheet sheet = row.getSheet(); |
| | | |
| | | // 1. 计算自动高度(基于内容) |
| | | short autoHeight = calculateSimpleAutoHeight(text, cell); |
| | | |
| | | // 2. 获取当前行高 |
| | | short currentHeight = row.getHeight(); |
| | | if (currentHeight == -1) { |
| | | currentHeight = sheet.getDefaultRowHeight(); |
| | | } |
| | | |
| | | // 3. 使用较大的高度(自动计算的高度或当前高度) |
| | | short baseHeight = (short) Math.max(currentHeight, autoHeight); |
| | | System.out.println(baseHeight+"aaaaaaaaatttttttt"); |
| | | // 4. 在基础上增加额外高度(100单位 = 5点) |
| | | short extraHeight = 80; |
| | | short newHeight = (short) (baseHeight + extraHeight); |
| | | |
| | | // 5. 限制最大高度 |
| | | short maxHeight = (short) 4000; // 100点 |
| | | row.setHeight((short) Math.min(maxHeight,newHeight)); |
| | | } |
| | | |
| | | /** |
| | | * 简化的自动高度计算 |
| | | */ |
| | | private short calculateSimpleAutoHeight(String text, Cell cell) { |
| | | if (text == null || text.isEmpty()) return 0; |
| | | |
| | | Sheet sheet = cell.getSheet(); |
| | | int colIndex = cell.getColumnIndex(); |
| | | |
| | | // 获取列宽(字符数) |
| | | int colWidthChars = sheet.getColumnWidth(colIndex) / 256; |
| | | if (colWidthChars <= 0) colWidthChars = 10; |
| | | |
| | | // 计算文本行数 |
| | | int lines = 1; |
| | | if (text.contains("\n")) { |
| | | // 有显式换行 |
| | | String[] parts = text.split("\n"); |
| | | for (String part : parts) { |
| | | lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars)); |
| | | } |
| | | } else { |
| | | // 自动换行 |
| | | lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars); |
| | | } |
| | | |
| | | // 每行高度:假设18点(360 POI单位) |
| | | return (short) (lines * 360); |
| | | } |
| | | /** |
| | | * 设置 POI XSSFSheet 单元格提示或选择框 |
| | | * |
| | |
| | | // 如果是index为1的sheet,设置顶端标题行 |
| | | |
| | | // 将第1行(索引为0)设置为每页重复的标题行 |
| | | sheet.setRepeatingRows(CellRangeAddress.valueOf("$1:$4")); |
| | | sheet.setRepeatingRows(CellRangeAddress.valueOf("$1:$5")); |
| | | row = sheet.createRow(0); |
| | | row.setHeight((short) (37*20)); |
| | | |
| | |
| | | row = sheet.createRow(i + 5 ); |
| | | else |
| | | row = sheet.createRow(i + 1 ); |
| | | // 第一步:让POI自动计算适配内容的行高 |
| | | // sheet.autoSizeRow(0); |
| | | // 第二步:获取自动计算后的行高 |
| | | |
| | | |
| | | // 得到导出对象. |
| | | T vo = (T) list.get(i); |
| | |
| | | // 设置实体类私有属性可访问 |
| | | field.setAccessible(true); |
| | | this.addCell(excel, row, vo, field, column++); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | Cell cell = null; |
| | | try { |
| | | // 设置行高为自动调整 |
| | | row.setHeight((short) -1); |
| | | // row.setHeight((short) -1); |
| | | // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. |
| | | if (attr.isExport()) { |
| | | // 创建cell |
| | |
| | | } else if (align == HorizontalAlignment.RIGHT) { |
| | | styleKey = "data3"; |
| | | } |
| | | cell.setCellStyle(styles.get(styleKey)); |
| | | // 获取并修改样式 |
| | | CellStyle style = styles.get(styleKey); |
| | | Workbook workbook = row.getSheet().getWorkbook(); |
| | | CellStyle newStyle = workbook.createCellStyle(); |
| | | newStyle.cloneStyleFrom(style); |
| | | newStyle.setWrapText(true); // 关键:启用自动换行 |
| | | cell.setCellStyle(newStyle); |
| | | |
| | | // 用于读取对象中的属性 |
| | | Object value = getTargetValue(vo, field, attr); |
| | |
| | | // 设置列类型 |
| | | setCellVo(value, attr, cell); |
| | | } |
| | | |
| | | adjustRowHeightAfterSetValue(row, cell, value); |
| | | |
| | | addStatisticsData(column, Convert.toStr(value), attr); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | return cell; |
| | | } |
| | | /** |
| | | * 设置值后调整行高 |
| | | */ |
| | | private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) { |
| | | if (value == null) return; |
| | | |
| | | String text = value.toString(); |
| | | Sheet sheet = row.getSheet(); |
| | | |
| | | // 1. 计算自动高度(基于内容) |
| | | short autoHeight = calculateSimpleAutoHeight(text, cell); |
| | | |
| | | // 2. 获取当前行高 |
| | | short currentHeight = row.getHeight(); |
| | | if (currentHeight == -1) { |
| | | currentHeight = sheet.getDefaultRowHeight(); |
| | | } |
| | | |
| | | // 3. 使用较大的高度(自动计算的高度或当前高度) |
| | | short baseHeight = (short) Math.max(currentHeight, autoHeight); |
| | | System.out.println(baseHeight+"aaaaaaaaatttttttt"); |
| | | // 4. 在基础上增加额外高度(100单位 = 5点) |
| | | short extraHeight = 80; |
| | | short newHeight = (short) (baseHeight + extraHeight); |
| | | |
| | | // 5. 限制最大高度 |
| | | short maxHeight = (short) 4000; // 100点 |
| | | row.setHeight((short) Math.min(maxHeight,newHeight)); |
| | | } |
| | | |
| | | /** |
| | | * 简化的自动高度计算 |
| | | */ |
| | | private short calculateSimpleAutoHeight(String text, Cell cell) { |
| | | if (text == null || text.isEmpty()) return 0; |
| | | |
| | | Sheet sheet = cell.getSheet(); |
| | | int colIndex = cell.getColumnIndex(); |
| | | |
| | | // 获取列宽(字符数) |
| | | int colWidthChars = sheet.getColumnWidth(colIndex) / 256; |
| | | if (colWidthChars <= 0) colWidthChars = 10; |
| | | |
| | | // 计算文本行数 |
| | | int lines = 1; |
| | | if (text.contains("\n")) { |
| | | // 有显式换行 |
| | | String[] parts = text.split("\n"); |
| | | for (String part : parts) { |
| | | lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars)); |
| | | } |
| | | } else { |
| | | // 自动换行 |
| | | lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars); |
| | | } |
| | | |
| | | // 每行高度:假设18点(360 POI单位) |
| | | return (short) (lines * 360); |
| | | } |
| | | /** |
| | | * 设置 POI HSSFSheet 单元格提示 |
| | | * |
| | |
| | | // header.setFontName("宋体");4 |
| | | // header.setFontSize((short) 10); |
| | | // 设置页眉内容 |
| | | hssfSheet.setMargin(Sheet.HeaderMargin, 1.34); |
| | | hssfSheet.setMargin(Sheet.HeaderMargin, 1.43); |
| | | header.setRight("&\"宋体,Bold\"共 &N 页 第 &P 页"); |
| | | } |
| | | // 如果是index为1的sheet,设置顶端标题行 |
| | |
| | | Cell cell = null; |
| | | try { |
| | | // 设置行高为自动调整 |
| | | row.setHeight((short) -1); |
| | | // row.setHeight((short) -1); |
| | | // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. |
| | | if (attr.isExport()) { |
| | | // 创建cell |
| | |
| | | } else if (align == HorizontalAlignment.RIGHT) { |
| | | styleKey = "data3"; |
| | | } |
| | | cell.setCellStyle(styles.get(styleKey)); |
| | | // 获取并修改样式 |
| | | CellStyle style = styles.get(styleKey); |
| | | Workbook workbook = row.getSheet().getWorkbook(); |
| | | CellStyle newStyle = workbook.createCellStyle(); |
| | | newStyle.cloneStyleFrom(style); |
| | | newStyle.setWrapText(true); // 关键:启用自动换行 |
| | | cell.setCellStyle(newStyle); |
| | | |
| | | // 用于读取对象中的属性 |
| | | Object value = getTargetValue(vo, field, attr); |
| | |
| | | // 设置列类型 |
| | | setCellVo(value, attr, cell); |
| | | } |
| | | adjustRowHeightAfterSetValue(row, cell, value); |
| | | addStatisticsData(column, Convert.toStr(value), attr); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | return cell; |
| | | } |
| | | /** |
| | | * 设置值后调整行高 |
| | | */ |
| | | private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) { |
| | | if (value == null) return; |
| | | |
| | | String text = value.toString(); |
| | | Sheet sheet = row.getSheet(); |
| | | |
| | | // 1. 计算自动高度(基于内容) |
| | | short autoHeight = calculateSimpleAutoHeight(text, cell); |
| | | |
| | | // 2. 获取当前行高 |
| | | short currentHeight = row.getHeight(); |
| | | if (currentHeight == -1) { |
| | | currentHeight = sheet.getDefaultRowHeight(); |
| | | } |
| | | |
| | | // 3. 使用较大的高度(自动计算的高度或当前高度) |
| | | short baseHeight = (short) Math.max(currentHeight, autoHeight); |
| | | System.out.println(baseHeight+"aaaaaaaaatttttttt"); |
| | | // 4. 在基础上增加额外高度(100单位 = 5点) |
| | | short extraHeight = 80; |
| | | short newHeight = (short) (baseHeight + extraHeight); |
| | | |
| | | // 5. 限制最大高度 |
| | | short maxHeight = (short) 4000; // 100点 |
| | | row.setHeight((short) Math.min(maxHeight,newHeight)); |
| | | } |
| | | |
| | | /** |
| | | * 简化的自动高度计算 |
| | | */ |
| | | private short calculateSimpleAutoHeight(String text, Cell cell) { |
| | | if (text == null || text.isEmpty()) return 0; |
| | | |
| | | Sheet sheet = cell.getSheet(); |
| | | int colIndex = cell.getColumnIndex(); |
| | | |
| | | // 获取列宽(字符数) |
| | | int colWidthChars = sheet.getColumnWidth(colIndex) / 256; |
| | | if (colWidthChars <= 0) colWidthChars = 10; |
| | | |
| | | // 计算文本行数 |
| | | int lines = 1; |
| | | if (text.contains("\n")) { |
| | | // 有显式换行 |
| | | String[] parts = text.split("\n"); |
| | | for (String part : parts) { |
| | | lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars)); |
| | | } |
| | | } else { |
| | | // 自动换行 |
| | | lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars); |
| | | } |
| | | |
| | | // 每行高度:假设18点(360 POI单位) |
| | | return (short) (lines * 360); |
| | | } |
| | | /** |
| | | * 设置单元格提示 |
| | | * |
| | |
| | | System.out.println(declaredFields.length); |
| | | int i = 0; |
| | | for (Field field : declaredFields) { |
| | | if(i==8) |
| | | if(i==9) |
| | | break; |
| | | // 设置字段的访问权限,以便于访问私有字段 |
| | | field.setAccessible(true); |
| | |
| | | Cell cell = null; |
| | | try { |
| | | // 设置行高为自动调整 |
| | | row.setHeight((short) -1); |
| | | // row.setHeight((short) -1); |
| | | // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. |
| | | if (attr.isExport()) { |
| | | // 创建cell |
| | |
| | | // 设置列类型 |
| | | setCellVo(value, attr, cell); |
| | | } |
| | | |
| | | adjustRowHeightAfterSetValue(row, cell, value); |
| | | |
| | | addStatisticsData(column, Convert.toStr(value), attr); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | return cell; |
| | | } |
| | | /** |
| | | * 设置值后调整行高 |
| | | */ |
| | | private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) { |
| | | if (value == null) return; |
| | | |
| | | String text = value.toString(); |
| | | Sheet sheet = row.getSheet(); |
| | | |
| | | // 1. 计算自动高度(基于内容) |
| | | short autoHeight = calculateSimpleAutoHeight(text, cell); |
| | | |
| | | // 2. 获取当前行高 |
| | | short currentHeight = row.getHeight(); |
| | | if (currentHeight == -1) { |
| | | currentHeight = sheet.getDefaultRowHeight(); |
| | | } |
| | | |
| | | // 3. 使用较大的高度(自动计算的高度或当前高度) |
| | | short baseHeight = (short) Math.max(currentHeight, autoHeight); |
| | | System.out.println(baseHeight+"aaaaaaaaatttttttt"); |
| | | // 4. 在基础上增加额外高度(100单位 = 5点) |
| | | short extraHeight = 80; |
| | | short newHeight = (short) (baseHeight + extraHeight); |
| | | |
| | | // 5. 限制最大高度 |
| | | short maxHeight = (short) 4000; // 100点 |
| | | row.setHeight((short) Math.min(maxHeight,newHeight)); |
| | | } |
| | | |
| | | /** |
| | | * 简化的自动高度计算 |
| | | */ |
| | | private short calculateSimpleAutoHeight(String text, Cell cell) { |
| | | if (text == null || text.isEmpty()) return 0; |
| | | |
| | | Sheet sheet = cell.getSheet(); |
| | | int colIndex = cell.getColumnIndex(); |
| | | |
| | | // 获取列宽(字符数) |
| | | int colWidthChars = sheet.getColumnWidth(colIndex) / 256; |
| | | if (colWidthChars <= 0) colWidthChars = 10; |
| | | |
| | | // 计算文本行数 |
| | | int lines = 1; |
| | | if (text.contains("\n")) { |
| | | // 有显式换行 |
| | | String[] parts = text.split("\n"); |
| | | for (String part : parts) { |
| | | lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars)); |
| | | } |
| | | } else { |
| | | // 自动换行 |
| | | lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars); |
| | | } |
| | | |
| | | // 每行高度:假设18点(360 POI单位) |
| | | return (short) (lines * 360); |
| | | } |
| | | /** |
| | | * 设置 POI HSSFSheet 单元格提示 |
| | | * |
| | |
| | | Cell cell = null; |
| | | try { |
| | | // 设置行高为自动调整 |
| | | row.setHeight((short) -1); |
| | | // row.setHeight((short) -1); |
| | | // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. |
| | | if (attr.isExport()) { |
| | | // 创建cell |
| | |
| | | } else if (align == HorizontalAlignment.RIGHT) { |
| | | styleKey = "data3"; |
| | | } |
| | | cell.setCellStyle(styles.get(styleKey)); |
| | | // 获取并修改样式 |
| | | CellStyle style = styles.get(styleKey); |
| | | Workbook workbook = row.getSheet().getWorkbook(); |
| | | CellStyle newStyle = workbook.createCellStyle(); |
| | | newStyle.cloneStyleFrom(style); |
| | | newStyle.setWrapText(true); // 关键:启用自动换行 |
| | | cell.setCellStyle(newStyle); |
| | | |
| | | // 用于读取对象中的属性 |
| | | Object value = getTargetValue(vo, field, attr); |
| | |
| | | // 设置列类型 |
| | | setCellVo(value, attr, cell); |
| | | } |
| | | adjustRowHeightAfterSetValue(row, cell, value); |
| | | |
| | | addStatisticsData(column, Convert.toStr(value), attr); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | return cell; |
| | | } |
| | | /** |
| | | * 设置值后调整行高 |
| | | */ |
| | | private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) { |
| | | if (value == null) return; |
| | | |
| | | String text = value.toString(); |
| | | Sheet sheet = row.getSheet(); |
| | | |
| | | // 1. 计算自动高度(基于内容) |
| | | short autoHeight = calculateSimpleAutoHeight(text, cell); |
| | | |
| | | // 2. 获取当前行高 |
| | | short currentHeight = row.getHeight(); |
| | | if (currentHeight == -1) { |
| | | currentHeight = sheet.getDefaultRowHeight(); |
| | | } |
| | | |
| | | // 3. 使用较大的高度(自动计算的高度或当前高度) |
| | | short baseHeight = (short) Math.max(currentHeight, autoHeight); |
| | | System.out.println(baseHeight+"aaaaaaaaatttttttt"); |
| | | // 4. 在基础上增加额外高度(100单位 = 5点) |
| | | short extraHeight = 80; |
| | | short newHeight = (short) (baseHeight + extraHeight); |
| | | |
| | | // 5. 限制最大高度 |
| | | short maxHeight = (short) 4000; // 100点 |
| | | row.setHeight((short) Math.min(maxHeight,newHeight)); |
| | | } |
| | | |
| | | /** |
| | | * 简化的自动高度计算 |
| | | */ |
| | | private short calculateSimpleAutoHeight(String text, Cell cell) { |
| | | if (text == null || text.isEmpty()) return 0; |
| | | |
| | | Sheet sheet = cell.getSheet(); |
| | | int colIndex = cell.getColumnIndex(); |
| | | |
| | | // 获取列宽(字符数) |
| | | int colWidthChars = sheet.getColumnWidth(colIndex) / 256; |
| | | if (colWidthChars <= 0) colWidthChars = 10; |
| | | |
| | | // 计算文本行数 |
| | | int lines = 1; |
| | | if (text.contains("\n")) { |
| | | // 有显式换行 |
| | | String[] parts = text.split("\n"); |
| | | for (String part : parts) { |
| | | lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars)); |
| | | } |
| | | } else { |
| | | // 自动换行 |
| | | lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars); |
| | | } |
| | | |
| | | // 每行高度:假设18点(360 POI单位) |
| | | return (short) (lines * 360); |
| | | } |
| | | /** |
| | | * 设置 POI HSSFSheet 单元格提示 |
| | | * |