| | |
| | | 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.*; |
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | |
| | | // 创建PDF文档 |
| | | List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | if(dmfs.isEmpty()) |
| | | return; |
| | | |
| | | |
| | | System.out.println(dmfs); |
| | | PdfWriter.getInstance(document, new FileOutputStream("09-备考表"+".pdf")); |
| | | document.open(); |
| | | // 设置中文字体 |
| | |
| | | Paragraph recordInfo = new Paragraph("卷号:" + volumeNumber, chineseFont); |
| | | recordInfo.setAlignment(Element.ALIGN_RIGHT); |
| | | document.add(recordInfo); |
| | | int allCnt = dmfs.get(0).getCnt() + dmfs.get(1).getCnt() + dmfs.get(2).getCnt(); |
| | | int pcc = dmfs.size()<=1?0: dmfs.get(1).getCnt(); |
| | | int oth = dmfs.size()<=2?0: dmfs.get(2).getCnt(); |
| | | int allCnt = dmfs.get(0).getCnt() + pcc + oth; |
| | | document.add(new Paragraph(" 本 案 卷 共 有 文 件 材 料 " + allCnt + " 页"+",其中:文字材料 " + |
| | | dmfs.get(1).getCnt() + " 页"+",图样材料 " + dmfs.get(2).getCnt() + " 页"+",照片 " + dmfs.get(0).getCnt() + " 张", chineseFont)); |
| | | pcc + " 页"+",图样材料 " + oth + " 页"+",照片 " + dmfs.get(0).getCnt() + " 张", chineseFont)); |
| | | |
| | | |
| | | document.add(new Paragraph("说明: ", chineseFont)); |
| | |
| | | |
| | | } |
| | | |
| | | 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)); |
| | |
| | | |
| | | 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)); |