From af47b774448bfa3ece4741664ce4d24128c8f629 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 01 九月 2025 14:29:50 +0800
Subject: [PATCH] 新增了代码
---
archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java | 423 +++++++++++++++++
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelExp.java | 23
ruoyi-common/src/main/java/com/ruoyi/common/annotation/NumberFormatHandler.java | 15
archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java | 21
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialFileStyle.java | 14
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoLarge.java | 330 +++++++++++++
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java | 309 +++---------
archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java | 10
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java | 229 ++++++++
archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java | 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java | 17
archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java | 9
archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java | 21
13 files changed, 1,156 insertions(+), 267 deletions(-)
diff --git a/archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java b/archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java
index 2000fff..964ea0c 100644
--- a/archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java
+++ b/archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java
@@ -7,6 +7,7 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.NumberFormatHandler;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@@ -25,7 +26,7 @@
/** $column.columnComment */
@TableId(type = IdType.AUTO)
private Long materialId;
- @Excel(name = "鏂囦欢鏉愭枡搴忓彿")
+ @Excel(name = "鏂囦欢鏉愭枡搴忓彿", handler = NumberFormatHandler.class)
private Long fileNumber;
@@ -56,7 +57,7 @@
private Date date;
/** $column.columnComment */
- @Excel(name = "椤靛彿")
+ @Excel(name = "椤靛彿", handler = NumberFormatHandler.class)
private Long pageNumber;
/** $column.columnComment */
@@ -72,11 +73,11 @@
private String publicity;
/** $column.columnComment */
- @Excel(name = "鏄惁涓洪檮浠�")
+ @Excel(name = "鏄惁涓洪檮浠堕檮鍥�")
private String isAttachment;
/** $column.columnComment */
- @Excel(name = "鏄惁涓洪檮鍥�")
+// @Excel(name = "鏄惁涓洪檮鍥�")
private String isDiagram;
/** $column.columnComment */
diff --git a/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialFileStyle.java b/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialFileStyle.java
new file mode 100644
index 0000000..0f1065e
--- /dev/null
+++ b/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialFileStyle.java
@@ -0,0 +1,14 @@
+package com.ruoyi.domain.vo;
+
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class DocumentMaterialFileStyle {
+ /** 妗f鍙� */
+// @Excel(name = "妗f鍙�")
+ private int cnt;
+ /** 妗f绠�(瀹�)鍙� */
+// @Excel(name = "妗f绠�(瀹�)鍙�")
+ private String fileStyle;
+}
diff --git a/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoLarge.java b/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoLarge.java
new file mode 100644
index 0000000..728b605
--- /dev/null
+++ b/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoLarge.java
@@ -0,0 +1,330 @@
+package com.ruoyi.domain.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.annotation.NumberFormatHandler;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class DocumentMaterialsVoLarge {
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getRecordId() {
+ return recordId;
+ }
+
+ public void setRecordId(String recordId) {
+ this.recordId = recordId;
+ }
+
+ public Long getFileNumber() {
+ return fileNumber;
+ }
+
+ public void setFileNumber(Long fileNumber) {
+ this.fileNumber = fileNumber;
+ }
+
+ public String getCreator() {
+ return creator;
+ }
+
+ public void setCreator(String creator) {
+ this.creator = creator;
+ }
+
+ public String getDocumentNumber() {
+ return documentNumber;
+ }
+
+ public void setDocumentNumber(String documentNumber) {
+ this.documentNumber = documentNumber;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public String getAttachmentHistoryNumbers() {
+ return attachmentHistoryNumbers;
+ }
+
+ public void setAttachmentHistoryNumbers(String attachmentHistoryNumbers) {
+ this.attachmentHistoryNumbers = attachmentHistoryNumbers;
+ }
+
+ public Double getFileSize() {
+ return fileSize;
+ }
+
+ public void setFileSize(Double fileSize) {
+ this.fileSize = fileSize;
+ }
+
+ public Long getHeight() {
+ return height;
+ }
+
+ public void setHeight(Long height) {
+ this.height = height;
+ }
+
+ public Long getWidth() {
+ return width;
+ }
+
+ public void setWidth(Long width) {
+ this.width = width;
+ }
+
+ public Long getVerticalResolution() {
+ return verticalResolution;
+ }
+
+ public void setVerticalResolution(Long verticalResolution) {
+ this.verticalResolution = verticalResolution;
+ }
+
+ public Long getHorizontalResolution() {
+ return horizontalResolution;
+ }
+
+ public void setHorizontalResolution(Long horizontalResolution) {
+ this.horizontalResolution = horizontalResolution;
+ }
+
+ public String getSizeType() {
+ return sizeType;
+ }
+
+ public void setSizeType(String sizeType) {
+ this.sizeType = sizeType;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ public String getIsCanceled() {
+ return isCanceled;
+ }
+
+ public void setIsCanceled(String isCanceled) {
+ this.isCanceled = isCanceled;
+ }
+
+ public String getIsSensitive() {
+ return isSensitive;
+ }
+
+ public void setIsSensitive(String isSensitive) {
+ this.isSensitive = isSensitive;
+ }
+
+ public String getSecurityLevel() {
+ return securityLevel;
+ }
+
+ public void setSecurityLevel(String securityLevel) {
+ this.securityLevel = securityLevel;
+ }
+
+ public String getRetentionPeriod() {
+ return retentionPeriod;
+ }
+
+ public void setRetentionPeriod(String retentionPeriod) {
+ this.retentionPeriod = retentionPeriod;
+ }
+
+ public String getIsDiagram() {
+ return isDiagram;
+ }
+
+ public void setIsDiagram(String isDiagram) {
+ this.isDiagram = isDiagram;
+ }
+
+ public String getIsAttachment() {
+ return isAttachment;
+ }
+
+ public void setIsAttachment(String isAttachment) {
+ this.isAttachment = isAttachment;
+ }
+
+ public String getPublicity() {
+ return publicity;
+ }
+
+ public void setPublicity(String publicity) {
+ this.publicity = publicity;
+ }
+
+ public String getStage() {
+ return stage;
+ }
+
+ public void setStage(String stage) {
+ this.stage = stage;
+ }
+
+ public Long getPageOrder() {
+ return pageOrder;
+ }
+
+ public void setPageOrder(Long pageOrder) {
+ this.pageOrder = pageOrder;
+ }
+
+ public Long getPageNumber() {
+ return pageNumber;
+ }
+
+ public void setPageNumber(Long pageNumber) {
+ this.pageNumber = pageNumber;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Excel(name="搴忓彿")
+ private int num;
+ @Excel(name="妗e彿")
+ private String recordId;
+ @Excel(name = "鏂囦欢鏉愭枡搴忓彿", handler = NumberFormatHandler.class)
+ private Long fileNumber;
+
+
+ @Excel(name = "鏂囦欢缂栧彿")
+ private String documentNumber;
+
+
+ /** $column.columnComment */
+ @Excel(name = "缂栦换鑰�")
+ private String creator;
+
+ /** $column.columnComment */
+ @Excel(name = "鏂囦欢棰樺悕")
+ private String title;
+
+ /** $column.columnComment */
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ @Excel(name = "鏃ユ湡", width = 30, dateFormat = "yyyy-MM-dd")
+ private Date date;
+
+ /** $column.columnComment */
+ @Excel(name = "椤靛彿", handler = NumberFormatHandler.class)
+ private Long pageNumber;
+
+ /** $column.columnComment */
+ @Excel(name = "椤垫")
+ private Long pageOrder;
+
+ /** $column.columnComment */
+ @Excel(name = "鎵�澶勯樁娈�")
+ private String stage;
+
+ /** $column.columnComment */
+ @Excel(name = "鍏紑灞炴��")
+ private String publicity;
+
+ /** $column.columnComment */
+ @Excel(name = "鏄惁涓洪檮浠堕檮鍥�")
+ private String isAttachment;
+
+ /** $column.columnComment */
+// @Excel(name = "鏄惁涓洪檮鍥�")
+ private String isDiagram;
+
+ /** $column.columnComment */
+ @Excel(name = "淇濈鏈熼檺")
+ private String retentionPeriod;
+
+ /** $column.columnComment */
+ @Excel(name = "瀵嗙骇")
+ private String securityLevel;
+
+ /** $column.columnComment */
+ @Excel(name = "鏄惁娑夊瘑鍙婃晱鎰熶俊鎭�")
+ private String isSensitive;
+
+ /** $column.columnComment */
+ @Excel(name = "鏄惁娉ㄩ攢")
+ private String isCanceled;
+
+ /** $column.columnComment */
+ @Excel(name = "鏍煎紡")
+ private String format;
+
+ /** $column.columnComment */
+ @Excel(name = "骞呴潰")
+ private String sizeType;
+
+ /** $column.columnComment */
+ @Excel(name = "姘村钩鍒嗚鲸鐜�")
+ private Long horizontalResolution;
+
+ /** $column.columnComment */
+ @Excel(name = "鍨傜洿鍒嗚鲸鐜�")
+ private Long verticalResolution;
+
+ /** $column.columnComment */
+ @Excel(name = "瀹藉害")
+ private Long width;
+
+ /** $column.columnComment */
+ @Excel(name = "楂樺害")
+ private Long height;
+
+ /** $column.columnComment */
+ @Excel(name = "澶у皬")
+ private Double fileSize;
+
+ /** $column.columnComment */
+ @Excel(name = "闄勪欢鍙婂巻鍙插彂鏂囧彿")
+ private String attachmentHistoryNumbers;
+
+ /** $column.columnComment */
+ @Excel(name = "澶囨敞")
+ private String remarks;
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ private String url;
+
+}
diff --git a/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java b/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
index 13d8b96..3a9a890 100644
--- a/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
+++ b/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
@@ -19,7 +19,7 @@
@Select({
"<script>",
- "SELECT 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,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} ",
"<if test= \"userId !=1 \">",
"order by tst desc",
"</if>",
diff --git a/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java b/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
index 977d0f6..6898693 100644
--- a/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
+++ b/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
@@ -2,7 +2,9 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.DocumentMaterials;
+import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
+import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@@ -12,8 +14,8 @@
@Mapper
public interface DocumentMaterialsMapper extends BaseMapper<DocumentMaterials> {
- @Select("update document_materials SET url = #{url},file_number=#{fileNumber},page_order=#{pageOrder},width=#{width},height=#{height},horizontal_resolution=#{horizontalResolution},vertical_resolution=#{verticalResolution},file_size=#{fileSize}, format=#{format} where page_number = #{pageNumber}")
- Long updateInfoByPageNumber(@Param("pageNumber") Long pageNumber,@Param("fileNumber") Long fileNumber,@Param("pageOrder") Long pageOrder,@Param("width") int width, @Param("height") int height, @Param("horizontalResolution") int horizontalResolution, @Param("verticalResolution") int verticalResolution, @Param("fileSize") Double fileSize,@Param("url") String url,@Param("format") String format);
+ @Select("update document_materials SET url = #{url},size_type=#{sizeType}, file_number=#{fileNumber},page_order=#{pageOrder},width=#{width},height=#{height},horizontal_resolution=#{horizontalResolution},vertical_resolution=#{verticalResolution},file_size=#{fileSize}, format=#{format} where page_number = #{pageNumber}")
+ Long updateInfoByPageNumber(@Param("pageNumber") Long pageNumber,@Param("sizeType") String sizeType, @Param("fileNumber") Long fileNumber,@Param("pageOrder") Long pageOrder,@Param("width") int width, @Param("height") int height, @Param("horizontalResolution") int horizontalResolution, @Param("verticalResolution") int verticalResolution, @Param("fileSize") Double fileSize,@Param("url") String url,@Param("format") String format);
//鏍规嵁棰樺悕鎷垮埌鏈�澶х殑pageOrder
@@ -32,4 +34,19 @@
" FROM document_materials where record_id=#{recordId}\n" +
" GROUP BY stage, title) and ar.id =#{recordId} order by page_number ;")
List<DocumentMaterialsVo> getArchiveMatInfo(@Param("recordId") int recordId);
+
+
+ @Select( "select ROW_NUMBER() OVER (ORDER BY page_number) AS num,ar.record_id, file_number, \n" +
+ " document_number, creator, title, date, page_number, page_order, \n" +
+ " stage, publicity, is_attachment, dm.retention_period, security_level, is_sensitive,\n" +
+ " is_canceled, format, size_type, horizontal_resolution, vertical_resolution, width,\n" +
+ " height, file_size, attachment_history_numbers,url, dm.remarks\n" +
+ " from document_materials as dm, archive_records as ar WHERE dm.record_id=ar.id \n" +
+ "and dm.record_id=#{recordId}")
+ List<DocumentMaterialsVoLarge> getDocumentMaterialsvoLarge(@Param("recordId") int recordId);
+
+ @Select("select count(*) as cnt, file_style from document_materials " +
+ "where record_id=#{recordId} GROUP BY file_style")
+
+ List<DocumentMaterialFileStyle> getFileStyleInfo(@Param("recordId") int recordId);
}
diff --git a/archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java b/archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java
index beb7b81..d6088c3 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java
@@ -3,7 +3,9 @@
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.Archiverecordstouser;
import com.ruoyi.domain.DocumentMaterials;
+import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
+import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -26,6 +28,9 @@
* @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚�
*/
public List<DocumentMaterials> selectDocumentMaterialsList(DocumentMaterials documentMaterials);
+
+
+ public List<DocumentMaterialsVoLarge> selectDocumentMaterialsAllByRecordId(Long id);
/**
* 鏂板銆愯濉啓鍔熻兘鍚嶇О銆�
@@ -59,6 +64,9 @@
*/
public int deleteDocumentMaterialsByMaterialId(String materialId);
public Long getFiNum(Long pageNumber);
- public int updateByPageNumber(Long pageNumber,Long fileNumber, int wid, int hei, int wdpi, int hdpi, double sz,String url,String format);
+ public int updateByPageNumber(Long pageNumber,String sizeType, Long fileNumber, int wid, int hei, int wdpi, int hdpi, double sz,String url,String format);
public List<DocumentMaterialsVo> findArchMInfo(String recordId);
+
+
+ public List<DocumentMaterialFileStyle> findFileStyleInfo(@Param("recordId") int recordId);
}
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java b/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
index e2b02f4..a0fd31e 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
@@ -5,15 +5,13 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.domain.entity.SysUser;
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.DocumentMaterials;
+import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
+import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import com.ruoyi.mapper.DocumentMaterialsMapper;
-import com.ruoyi.service.IArchiveCategoryService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.util.ErrorcodeExceptionextends;
import org.springframework.stereotype.Service;
@@ -104,6 +102,12 @@
}
@Override
+ public List<DocumentMaterialsVoLarge> selectDocumentMaterialsAllByRecordId(Long id) {
+
+ return this.baseMapper.getDocumentMaterialsvoLarge(Math.toIntExact(id));
+ }
+
+ @Override
public int insertDocumentMaterials(DocumentMaterials documentMaterials) {
LocalDateTime time = LocalDateTime.now();
@@ -159,7 +163,7 @@
}
@Override
- public int updateByPageNumber(Long pageNumber, Long fileNumber, int width, int height, int horizontalResolution, int verticalResolution, double fileSize, String url, String format) {
+ public int updateByPageNumber(Long pageNumber, String sizeType, Long fileNumber, int width, int height, int horizontalResolution, int verticalResolution, double fileSize, String url, String format) {
//鏍规嵁pageNumber鎷垮埌title锛岀劧鍚庤绠梡ageOrder
LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
lqw.eq(pageNumber!=null, DocumentMaterials::getPageNumber, pageNumber);
@@ -174,7 +178,7 @@
pageOrder = maxPOrder + 1;
}
- this.baseMapper.updateInfoByPageNumber(pageNumber, fileNumber,pageOrder, width, height, horizontalResolution, verticalResolution, fileSize, url,format);
+ this.baseMapper.updateInfoByPageNumber(pageNumber, sizeType,fileNumber,pageOrder, width, height, horizontalResolution, verticalResolution, fileSize, url,format);
return 0;
}
@@ -183,4 +187,9 @@
public List<DocumentMaterialsVo> findArchMInfo(String recordId) {
return this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId));
}
+
+ @Override
+ public List<DocumentMaterialFileStyle> findFileStyleInfo(int recordId) {
+ return this.baseMapper.getFileStyleInfo(recordId);
+ }
}
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java b/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
index 723b026..c1081b0 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
@@ -11,18 +11,31 @@
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
+import com.ruoyi.domain.vo.DocumentMaterialsVo;
+import com.ruoyi.domain.vo.DocumentMaterialsVoSmall;
+import com.ruoyi.service.IDocumentMaterialsService;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import java.awt.*;
+import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.*;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.util.List;
@Service
public class pdfGenerateService {
@Autowired
private BarcodeService barcodeService;
+ @Autowired
+ private IDocumentMaterialsService documentMaterialsService;
//鐢熶骇浜岀淮鐮�
public byte[] createQrCodeN(String content, int width, int height) throws IOException {
QrConfig config = new QrConfig(width, height);
@@ -50,7 +63,417 @@
return os.toByteArray();
}
+ private void handleXSSFImages(XSSFSheet sheet, Document pdfDoc) throws Exception {
+ XSSFDrawing drawing = sheet.getDrawingPatriarch();
+ if (drawing == null) return;
+ for (XSSFShape shape : drawing.getShapes()) {
+ if (shape instanceof XSSFPicture) {
+ XSSFPicture pic = (XSSFPicture)shape;
+ XSSFClientAnchor anchor = pic.getPreferredSize();
+
+ // 鑾峰彇鍥剧墖鏁版嵁
+ byte[] bytes = pic.getPictureData().getData();
+ Image pdfImage = Image.getInstance(bytes);
+
+ // 璁剧疆鍥剧墖浣嶇疆鍜屽ぇ灏�
+ float imageWidth = pdfImage.getWidth();
+ float imageHeight = pdfImage.getHeight();
+ float scale = Math.min(
+ (PageSize.A4.getWidth() - 100) / imageWidth,
+ (PageSize.A4.getHeight() - 100) / imageHeight
+ );
+ pdfImage.scaleAbsolute(imageWidth * scale, imageHeight * scale);
+
+ // 娣诲姞鍥剧墖鍒癙DF
+ pdfDoc.add(pdfImage);
+ pdfDoc.add(Chunk.NEWLINE);
+ }
+ }
+ }
+
+
+
+
+ private static String getCellValue(Cell cell,FormulaEvaluator evaluator) {
+ // System.out.println(cell);
+ if (cell == null) return "";
+ CellValue cellValue = evaluator.evaluate(cell);
+ if(cellValue==null)
+ return "";
+ // System.out.println(cellValue.getCellType());
+ switch (cellValue.getCellType()) {
+ case STRING:
+ return cell.getStringCellValue();
+ case NUMERIC:
+ // 鑾峰彇鏁板�煎苟杞负鏁村瀷
+ double numericValue = cell.getNumericCellValue();
+ // 鍒ゆ柇鏄惁涓烘暣鏁�
+ if (numericValue == (int)numericValue) {
+ if((int)numericValue==0)
+ return "";
+ else
+ return String.valueOf((int)numericValue);
+ } else {
+ return String.valueOf(numericValue); // 鎴栬�呮牴鎹渶瑕佽繑鍥炲洓鑸嶄簲鍏ョ殑鏁村瀷
+ }
+
+ case BOOLEAN:
+ return String.valueOf(cell.getBooleanCellValue());
+ case FORMULA:
+
+ return cell.getCellFormula()+"";
+ case BLANK:
+ return "";
+ default:
+ return "";
+ }
+ }
+ private int getRealLastCellNum(Row row) {
+ int lastCellNum = 0;
+ for (int i = 0; i < row.getLastCellNum(); i++) {
+ Cell cell = row.getCell(i);
+ if (cell != null && cell.getCellType() != CellType.BLANK) {
+ lastCellNum = i + 1;
+ }
+ }
+ return lastCellNum;
+ }
+
+ //
+ void generateSimpleExample()
+ {
+
+// try {
+// // 1. 璇诲彇Excel鏂囦欢
+// String excelPath = RuoYiConfig.getProfile() + "/download/"+"鍗峰収鐩綍.xls";
+// String pdfPath = RuoYiConfig.getProfile() + "/download/"+"1.pdf";
+//
+// Workbook workbook = WorkbookFactory.create(new File(excelPath));
+// FileOutputStream fos = new FileOutputStream(pdfPath);
+// FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+//
+//
+// // 鑾峰彇绗竴涓伐浣滆〃
+// Sheet sheet = workbook.getSheetAt(1);
+//
+// // 鍒涘缓PDF鏂囨。瀵硅薄
+// Document document = new Document(PageSize.A2, 50, 50, 50, 50);
+//
+// // 鍒涘缓PDF杈撳嚭娴�
+// PdfWriter writer = PdfWriter.getInstance(document, fos);
+// // 4. 澶勭悊宸ヤ綔琛ㄤ腑鐨勫浘鐗�
+// if (workbook instanceof XSSFWorkbook) {
+// handleXSSFImages((XSSFSheet)sheet, document);
+// }
+// // 鎵撳紑PDF鏂囨。
+// document.open();
+//
+// // 鍒涘缓PDF琛ㄦ牸瀵硅薄
+// System.out.println(sheet.getRow(0).getLastCellNum()+"--00");
+// PdfPTable table = new PdfPTable(sheet.getRow(0).getLastCellNum());
+// table.setHeaderRows(1);
+//
+// // 璁剧疆琛ㄦ牸瀹藉害
+// table.setWidthPercentage(100);
+//
+// // 璁剧疆琛ㄦ牸鏍囬
+// Paragraph title = new Paragraph(sheet.getSheetName(), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 16, Font.BOLD));
+// title.setAlignment(Element.ALIGN_CENTER);
+// document.add(title);
+// // System.out.println(sheet.)
+// // 娣诲姞琛ㄦ牸鍐呭
+// for (Row row : sheet) {
+// {
+// if (row == null) continue;
+// System.out.println(getRealLastCellNum(row)+"---987");
+//// if(row.getRowNum()==0)
+//// continue;
+// if(row.getRowNum()==2)
+// {
+// PdfPCell pdfCell = ImageSet(100);
+// pdfCell.setColspan(7);
+// pdfCell.setRowspan(3);
+// pdfCell.setBorderWidth(1f);
+// pdfCell.setBorderColor(BaseColor.BLACK);
+// pdfCell.setPadding(5f);
+// pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
+// pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+// table.addCell(pdfCell);
+// System.out.println("{{{{{{{{{{{{{");
+// continue;
+// }
+// for (int i = 0; i < 7; i++)
+// {
+//
+// Cell cell = row.getCell(i);
+// if(row.getRowNum()==3)
+// {
+// PdfPCell pdfCell = new PdfPCell(new Paragraph("鍗峰唴鐩綍", new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
+// pdfCell.setColspan(7);
+// pdfCell.setBorderWidth(1f);
+// pdfCell.setBorderColor(BaseColor.BLACK);
+// pdfCell.setPadding(5f);
+// pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
+// pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+// table.addCell(pdfCell);
+// System.out.println("{{{{{{{{{{{{{");
+// break;
+// }
+// if(cell==null) {
+//
+// table.addCell("");
+// continue;
+// }
+// PdfPCell pdfCell = new PdfPCell(new Paragraph(getCellValue(cell, evaluator), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
+//
+// if(row.getRowNum()!=1) {
+// pdfCell.setBorderWidth(1f);
+// pdfCell.setBorderColor(BaseColor.BLACK);
+// pdfCell.setPadding(5f);
+// pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
+// pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+// }
+// if (cell.getRowIndex() == 5) {
+// pdfCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
+// }
+//
+// table.addCell(pdfCell);
+//
+// }
+// }
+// }
+//
+// // 娣诲姞琛ㄦ牸鍒癙DF鏂囨。
+// table.setSpacingBefore(20f);
+// table.setSpacingAfter(20f);
+// table.setKeepTogether(true);
+// document.add(table);
+//
+// // 鍏抽棴PDF鏂囨。
+// document.close();
+//
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+
+ }
+
+
+ //瀵煎嚭鍗峰唴鐩綍鐨刾df
+ public void generateFileDirectoryPdf(String pdfPath,List<DocumentMaterialsVo> dvss) throws DocumentException, IOException {
+ Document document = new Document();
+ PdfWriter.getInstance(document, new FileOutputStream(pdfPath));
+ document.open();
+
+ // 鍒涘缓琛ㄦ牸锛�5鍒楋級
+ PdfPTable table = new PdfPTable(7);
+
+ // 璁剧疆琛ㄦ牸瀹藉害锛堝崰椤甸潰瀹藉害鐨�100%锛�
+ table.setWidthPercentage(100);
+
+
+ //娣诲姞鏉″舰鐮�
+ String volumeNumber = dvss.get(0).getRecordId();
+ Image img = Image.getInstance(barcodeService.generateBarcodeImage(volumeNumber));
+ // 璁剧疆鍥剧墖鍦≒DF涓殑浣嶇疆锛堝彲閫夛級
+// img.setAbsolutePosition(100, 100);
+ // 灏嗗浘鐗囨坊鍔犲埌PDF鏂囨。涓�
+ PdfPCell pdfPCell = new PdfPCell(img);
+ pdfPCell.setBorder(Rectangle.NO_BORDER); // 绉婚櫎鍗曞厓鏍艰竟妗�
+
+ pdfPCell.setMinimumHeight(40);
+ pdfPCell.setUseAscender(true); // 璁剧疆鍙互灞呬腑
+ pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); // 璁剧疆姘村钩灞呬腑
+ pdfPCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); // 璁剧疆鍨傜洿灞呬腑
+ pdfPCell.setColspan(2);
+ pdfPCell.setPaddingBottom(30);
+// 鍒涘缓琛ㄦ牸骞惰缃垪瀹芥瘮渚�
+ float[] columnWidths = {35f, 65f}; // 绗竴鍒�30%锛岀浜屽垪70%
+ PdfPTable table1 = new PdfPTable(columnWidths);
+// PdfPTable table = new PdfPTable(2);
+ table1.setWidthPercentage(80); // 澧炲ぇ琛ㄦ牸瀹藉害鐧惧垎姣�
+ table1.setHorizontalAlignment(Element.ALIGN_LEFT); // 璁剧疆琛ㄦ牸鏁翠綋灞呬腑
+ table1.setSpacingBefore(30f); // 璁剧疆琛ㄦ牸鍓嶉棿璺�
+
+ table1.addCell(pdfPCell);
+
+ document.add(table1);
+
+
+ // 娣诲姞琛ㄥご
+ BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+ Font chineseFont = new Font(bfChinese, 12);
+ Font chineseFont1 = new Font(bfChinese, 16, Font.BOLD);
+ // 娣诲姞鏍囬
+ Paragraph title = new Paragraph("鍗� 鍐� 鐩� 褰�", chineseFont1);
+ title.setAlignment(Element.ALIGN_CENTER);
+ document.add(title);
+ Paragraph withNewLine = new Paragraph("\n");
+ document.add(withNewLine);
+ document.add(withNewLine);
+
+
+ //娣诲姞鍗峰彿
+ Paragraph recordInfo = new Paragraph("鍗峰彿锛�" + volumeNumber, chineseFont);
+ recordInfo.setAlignment(Element.ALIGN_RIGHT);
+ document.add(recordInfo);
+
+ document.add(withNewLine);
+ document.add(withNewLine);
+ String[] headers = {"搴忓彿", "鏂囦欢缂栧彿", "璐d换鑰�", "鏂囦欢棰樺悕", "鏃ユ湡", "椤靛彿", "澶囨敞"};
+ for (String header : headers) {
+ PdfPCell cell = new PdfPCell(new Paragraph(header,
+ chineseFont1));
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
+ cell.setBackgroundColor(new BaseColor(200, 200, 200));
+ table.addCell(cell);
+ }
+
+ // 娣诲姞琛ㄦ牸鏁版嵁
+// Object[][] data = {
+// // {1, "鍟嗗搧A", 2, 100.00, 200.00},
+// // {2, "鍟嗗搧B", 1, 250.50, 250.50},
+// // {3, "鍟嗗搧C", 3, 80.00, 240.00}
+// };
+// data.
+ // for (Object[] row : data) {
+ for (DocumentMaterialsVo cellData : dvss) {
+ //搴忓彿
+ PdfPCell cell = new PdfPCell(new Paragraph(cellData.getNum().toString(),
+ chineseFont));
+ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
+ cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ table.addCell(cell);
+
+
+ //搴忓彿
+ PdfPCell cell1 = new PdfPCell(new Paragraph(cellData.getDocumentNumber()==null?"":cellData.getDocumentNumber().toString(),
+ chineseFont));
+ cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
+ cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
+
+ table.addCell(cell1);
+
+
+ //搴忓彿
+ PdfPCell cell2 = new PdfPCell(new Paragraph(cellData.getCreator()==null?"":cellData.getCreator().toString(),
+ chineseFont));
+ cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
+ cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
+
+ table.addCell(cell2);
+
+
+ //搴忓彿
+ PdfPCell cell3 = new PdfPCell(new Paragraph(cellData.getTitle()==null?"":cellData.getTitle().toString(),
+ chineseFont));
+ cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
+
+ cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
+ table.addCell(cell3);
+
+ //搴忓彿
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ // String dateString = sdf.format(date);
+ PdfPCell cell4 = new PdfPCell(new Paragraph(cellData.getDate()==null?"":sdf.format(cellData.getDate()),
+ chineseFont));
+ cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
+
+ cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
+ table.addCell(cell4);
+
+
+ //搴忓彿
+ PdfPCell cell5 = new PdfPCell(new Paragraph(cellData.getPageNumber()==null?"": cellData.getPageNumber().toString(),
+ chineseFont));
+ cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
+ cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
+
+ table.addCell(cell5);
+
+ //搴忓彿
+ PdfPCell cell6 = new PdfPCell(new Paragraph(cellData.getRemarks()==null?"":cellData.getRemarks().toString(),
+ chineseFont));
+ cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
+
+ cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
+ table.addCell(cell6);
+ }
+ // }
+
+ document.add(table);
+ document.close();
+ }
+ //璁剧疆澶囪�冭〃
+ public void generateFileStyleInfo(String pdfPath, String volumeNumber, Long id) throws IOException, DocumentException {
+ Document document = new Document();
+ PdfWriter.getInstance(document, new FileOutputStream(pdfPath));
+ document.open();
+
+// 鍒涘缓PDF鏂囨。
+ List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
+ PdfWriter.getInstance(document, new FileOutputStream("09-澶囪�冭〃"+".pdf"));
+ document.open();
+ // 璁剧疆涓枃瀛椾綋
+
+ BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+ Font chineseFont = new Font(bfChinese, 16, Font.BOLD);
+ // 娣诲姞鏍囬
+ Paragraph title = new Paragraph("鍗峰唴澶囪�冭〃", chineseFont);
+ title.setAlignment(Element.ALIGN_CENTER);
+ document.add(title);
+
+ // 娣诲姞鍐呭
+ // String volumeNumber = "D3.4.1-05-2024-0002";
+ 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();
+ document.add(new Paragraph(" 鏈� 妗� 鍗� 鍏� 鏈� 鏂� 浠� 鏉� 鏂� " + allCnt + " 椤�"+"锛屽叾涓細鏂囧瓧鏉愭枡 " +
+ dmfs.get(1).getCnt() + " 椤�"+"锛屽浘鏍锋潗鏂� " + dmfs.get(2).getCnt() + " 椤�"+"锛岀収鐗� " + dmfs.get(0).getCnt() + " 寮�", chineseFont));
+
+
+ document.add(new Paragraph("璇存槑: ", chineseFont));
+ // 鏂规硶2锛氫娇鐢ㄥ甫鎹㈣绗︾殑Paragraph
+ for(int i = 0; i < 10; i++) {
+ Paragraph withNewLine = new Paragraph("\n");
+ document.add(withNewLine);
+ }
+
+
+ String tis1 = "绔嬪嵎浜猴細浠囩縺锛堝箍宸炵泩瀹舵。妗堢鐞嗘湁闄愬叕鍙革級";
+ Paragraph par1 = new Paragraph(tis1, chineseFont);
+ par1.setAlignment(Element.ALIGN_RIGHT);
+ document.add(par1);
+ //鎷垮埌褰撳墠鏃堕棿
+ // 鑾峰彇褰撳墠鏃ユ湡
+ LocalDate currentDate = LocalDate.now();
+
+ // 鎵撳嵃骞淬�佹湀銆佹棩
+// System.out.println("Year: " + currentDate.getYear());
+// System.out.println("Month: " + currentDate.getMonthValue()); // 鏈堜唤鏄粠1寮�濮嬬殑
+// System.out.println("Day of Month: " + currentDate.getDayOfMonth());
+ Paragraph withNewLine = new Paragraph("\n");
+ document.add(withNewLine);
+ String cdt = currentDate.getYear()+"骞�"+currentDate.getMonthValue()+"鏈�"+currentDate.getDayOfMonth()+"鏃�";
+
+
+ Paragraph par3 = new Paragraph(cdt, chineseFont);
+ par3.setAlignment(Element.ALIGN_RIGHT);
+ document.add(par3);
+ String tis2 = "瀹℃牳浜猴細鏇剧憺鑾癸紙骞垮窞鐩堝妗f绠$悊鏈夐檺鍏徃锛�";
+ document.add(withNewLine);
+
+ Paragraph par2 = new Paragraph(tis2, chineseFont);
+ par2.setAlignment(Element.ALIGN_RIGHT);
+ document.add(par2);
+ document.add(withNewLine);
+ document.add(par3);
+
+ document.close();
+
+ }
public void generatePdf(String pdfPath) throws IOException, DocumentException {
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 9e13d7e..a38294e 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
@@ -133,6 +133,19 @@
return toAjax(documentMaterialsService.deleteDocumentMaterialsByMaterialIds(materialIds));
}
+ public String getPageSize(double du)
+ {
+ if(du <= 8699840)
+ return "A4";
+ else if(du <= 17403188)
+ return "A3";
+ else if(du <= 34811347)
+ return "A2";
+ else if(du <= 69622674)
+ return "A1";
+ else
+ return "A0";
+ }
@PostMapping("/upload")
public AjaxResult uploadFile(MultipartFile file) throws Exception
@@ -173,8 +186,10 @@
System.out.println("DPI: " + info.getPhysicalWidthDpi());
//璁$畻fileNumber
Long fileNumber = documentMaterialsService.getFiNum(nam);
+ //璁$畻sizeType
+ String sizeType = getPageSize(wid*hei);
//鎻掑叆鏁版嵁搴撳搴旂殑url褰撲腑
- documentMaterialsService.updateByPageNumber(nam, fileNumber,wid, hei,wdpi, hdpi, sz, fileName, pname);
+ documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber,wid, hei,wdpi, hdpi, sz, fileName, pname);
// System.out.println(url);
// System.out.println(fileName);
ajax.put("fileName", fileName);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
index acddd4c..7936234 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
@@ -15,6 +15,7 @@
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.framework.web.domain.server.Sys;
import com.ruoyi.service.IArchiveRecordsService;
@@ -78,15 +79,19 @@
ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(55L);
List<ArchiveInfoVo> arsi = new ArrayList<>();
arsi.add(aIV);
+
+ String recordId = aIV.getRecordId();
+ byte[] imgr = barcodeService.generateBarcodeImage(recordId);
+ byte[] sedcode = pdfGenerateService.createQrCodeN(recordId, 30, 30);
ExcelExp e1 = new ExcelExp("妗堝嵎灏侀潰鏁版嵁",arsi, ArchiveInfoVo.class);
- ExcelExp e2 = new ExcelExp("鎻愬彇鏂规硶鈥�", arsi, ArchiveInfoVo.class);
+ ExcelExp e2 = new ExcelExp("妗堝嵎灏侀潰", arsi, recordId, imgr,sedcode, ArchiveInfoVo.class);
List<ExcelExp> mysheet = new ArrayList<ExcelExp>();
mysheet.add(e1);
mysheet.add(e2);
ByteOutputStream bos1 = new ByteOutputStream();
ExcelUtilManySheetSecond<List<ExcelExp>> util2 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet);
- util2.exportExcelManySheet(response, mysheet);
+ // util2.exportExcelManySheet(response, mysheet);
@@ -134,7 +139,11 @@
// 鑾峰彇鏂囦欢鐨勪繚瀛樹綅缃�,璇诲彇鏁版嵁搴�,
DocumentMaterials documentMaterials = new DocumentMaterials();
documentMaterials.setRecordId(id);
- List<DocumentMaterials> docs = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
+ List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id);
+ System.out.println(docs.size()+"----009");
+
+
+ //.selectDocumentMaterialsList(documentMaterials);
List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id);
@@ -157,8 +166,10 @@
String datumName = "user";
//鍘嬬缉鏂囦欢
List<String> filePathList = paths;
- File file = compressedFileToZip(docs, dsvs, aIV);
+ File file = compressedFileToZip(docs, dsvs, aIV, id);
System.out.println(file.getName());
+
+ String fileName =aIV.getRecordId()+".zip";
//杈撳嚭鏂囦欢娴�
writeFileToRes(response, file.getName(), file);
//鍒犻櫎鍘嬬缉鍖�
@@ -178,26 +189,7 @@
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
- // FileInputStream inputStream = new FileInputStream(file);
-// //1.璁剧疆鏂囦欢ContentType绫诲瀷锛岃繖鏍疯缃紝浼氳嚜鍔ㄥ垽鏂笅杞芥枃浠剁被鍨�.
-// response.setContentType("application/octet-stream");
-// //2.璁剧疆鏂囦欢澶达細鏈�鍚庝竴涓弬鏁版槸璁剧疆涓嬭浇鏂囦欢鍚�
-// response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
-// response.addHeader("Content-Length", "" + file.length());
-//
-// //3.閫氳繃response鑾峰彇ServletOutputStream瀵硅薄(out)
-// ServletOutputStream out = response.getOutputStream();
-//
-// int b = 0;
-// byte[] buffer = new byte[1024];
-// while (b != -1) {
-// b = inputStream.read(buffer);
-// //4.鍐欏埌杈撳嚭娴�(out)涓�
-// out.write(buffer, 0, b);
-// }
-// out.flush();
-// out.close();
-// inputStream.close();
+
}
public String frontCompWithZore(int formatLength,int formatNumber){
/**
@@ -210,82 +202,7 @@
return newString;
}
- private void handleXSSFImages(XSSFSheet sheet, Document pdfDoc) throws Exception {
- XSSFDrawing drawing = sheet.getDrawingPatriarch();
- if (drawing == null) return;
- for (XSSFShape shape : drawing.getShapes()) {
- if (shape instanceof XSSFPicture) {
- XSSFPicture pic = (XSSFPicture)shape;
- XSSFClientAnchor anchor = pic.getPreferredSize();
-
- // 鑾峰彇鍥剧墖鏁版嵁
- byte[] bytes = pic.getPictureData().getData();
- Image pdfImage = Image.getInstance(bytes);
-
- // 璁剧疆鍥剧墖浣嶇疆鍜屽ぇ灏�
- float imageWidth = pdfImage.getWidth();
- float imageHeight = pdfImage.getHeight();
- float scale = Math.min(
- (PageSize.A4.getWidth() - 100) / imageWidth,
- (PageSize.A4.getHeight() - 100) / imageHeight
- );
- pdfImage.scaleAbsolute(imageWidth * scale, imageHeight * scale);
-
- // 娣诲姞鍥剧墖鍒癙DF
- pdfDoc.add(pdfImage);
- pdfDoc.add(Chunk.NEWLINE);
- }
- }
- }
-
-
-
-
- private static String getCellValue(Cell cell,FormulaEvaluator evaluator) {
- // System.out.println(cell);
- if (cell == null) return "";
- CellValue cellValue = evaluator.evaluate(cell);
- if(cellValue==null)
- return "";
- // System.out.println(cellValue.getCellType());
- switch (cellValue.getCellType()) {
- case STRING:
- return cell.getStringCellValue();
- case NUMERIC:
- // 鑾峰彇鏁板�煎苟杞负鏁村瀷
- double numericValue = cell.getNumericCellValue();
- // 鍒ゆ柇鏄惁涓烘暣鏁�
- if (numericValue == (int)numericValue) {
- if((int)numericValue==0)
- return "";
- else
- return String.valueOf((int)numericValue);
- } else {
- return String.valueOf(numericValue); // 鎴栬�呮牴鎹渶瑕佽繑鍥炲洓鑸嶄簲鍏ョ殑鏁村瀷
- }
-
- case BOOLEAN:
- return String.valueOf(cell.getBooleanCellValue());
- case FORMULA:
-
- return cell.getCellFormula()+"";
- case BLANK:
- return "";
- default:
- return "";
- }
- }
- private int getRealLastCellNum(Row row) {
- int lastCellNum = 0;
- for (int i = 0; i < row.getLastCellNum(); i++) {
- Cell cell = row.getCell(i);
- if (cell != null && cell.getCellType() != CellType.BLANK) {
- lastCellNum = i + 1;
- }
- }
- return lastCellNum;
- }
@@ -316,10 +233,10 @@
// 鍘嬬缉鏂囦欢
- private File compressedFileToZip(List<DocumentMaterials> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV) throws Exception {
+ private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id) throws Exception {
//鍘嬬缉鍖呭叿浣撳悕绉帮紙鎷兼帴鏃堕棿鎴抽槻姝㈤噸鍚嶏級
String datumName = "";
- String zipFileName = datumName + "-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
+ String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip";
//鐢熸垚鍘嬬缉鍖呭瓨鍌ㄥ湴鍧�锛堟渶鍚庝細鍒犳帀锛�
String fileZip = RuoYiConfig.getProfile() + "/download/" + zipFileName;
OutputStream os=null;
@@ -350,20 +267,75 @@
zos.write(buffer, 0, len);
}
}
+ //08-鍗峰唴鍗峰唴鐩綍鐨刾df
+ String pdf08Path= "08-鍗峰唴鐩綍.pdf";
+ List<DocumentMaterialsVo> list3 = dsvs;
+ pdfGenerateService.generateFileDirectoryPdf(pdf08Path, list3);
+ ZipEntry zipEntry2 = new ZipEntry(pdf08Path);
+ zos.putNextEntry(zipEntry2);
+
+ // 璇诲彇PDF鏂囦欢鍐呭骞跺啓鍏IP
+ try (FileInputStream fis = new FileInputStream(pdf08Path)) {
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = fis.read(buffer)) > 0) {
+ zos.write(buffer, 0, len);
+ }
+ }
+ //09-澶囪�冭〃.pdf
+ String pdf09Path = "09-澶囪�冭〃.pdf";
+ pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id);
+ // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
+ // 娣诲姞PDF鏂囦欢鍒癦IP
+ ZipEntry zipEntry1 = new ZipEntry(pdf09Path);
+ zos.putNextEntry(zipEntry1);
+
+ // 璇诲彇PDF鏂囦欢鍐呭骞跺啓鍏IP
+ try (FileInputStream fis = new FileInputStream(pdf09Path)) {
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = fis.read(buffer)) > 0) {
+ zos.write(buffer, 0, len);
+ }
+ }
+
+
+
+
//excel 鍗峰唴灏侀潰瀵煎嚭zip
ZipEntry entryiv = new ZipEntry("鍗峰唴灏侀潰" + ".xls");
- ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class);
+ List<ArchiveInfoVo> arsi = new ArrayList<>();
+ arsi.add(aIV);
+
+ String recordId1 = aIV.getRecordId();
+ byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1);
+ byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 30, 30);
+ ExcelExp e3 = new ExcelExp("妗堝嵎灏侀潰鏁版嵁",arsi, ArchiveInfoVo.class);
+ ExcelExp e4 = new ExcelExp("妗堝嵎灏侀潰", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
+ List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>();
+ mysheet1.add(e3);
+ mysheet1.add(e4);
+ ByteOutputStream bos2 = new ByteOutputStream();
+ ExcelUtilManySheetSecond<List<ExcelExp>> util3 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet1);
+
+ util3.exportExcelManySheet(bos2, mysheet1);
+
+ // System.out.println(bos2);
zos.putNextEntry(entryiv);
- ByteOutputStream boss = new ByteOutputStream();
- List<ArchiveInfoVo> aivs = new ArrayList<>();
- aivs.add(aIV);
- utilsv.byteOutputStreamExcel(boss, aivs,"Date List", "");
- boss.writeTo(zos);
+
+// ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class);
+//
+//
+// ByteOutputStream boss = new ByteOutputStream();
+// List<ArchiveInfoVo> aivs = new ArrayList<>();
+// aivs.add(aIV);
+// utilsv.byteOutputStreamExcel(boss, aivs,"Date List", "");
+ bos2.writeTo(zos);
//鍐欏叆鐢靛瓙鐩綍 xsxl
ZipEntry entry = new ZipEntry("鐢靛瓙鏂囦欢鐩綍" + ".xls");
- ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class);
+ ExcelUtil<DocumentMaterialsVoLarge> util = new ExcelUtil<DocumentMaterialsVoLarge>(DocumentMaterialsVoLarge.class);
zos.putNextEntry(entry);
ByteOutputStream bos = new ByteOutputStream();
@@ -382,11 +354,6 @@
mysheet.add(e1);
mysheet.add(e2);
ExcelUtilManySheet<List<ExcelExp>> util2 = new ExcelUtilManySheet<List<ExcelExp>>(mysheet);
-
-
-
-
-
ZipEntry entr = new ZipEntry("鍗峰唴鐩綍" + ".xls");
ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class);
System.out.println(dsvs);
@@ -400,126 +367,12 @@
//鎶奺xcel杞负pdf
- try {
- // 1. 璇诲彇Excel鏂囦欢
- String excelPath = RuoYiConfig.getProfile() + "/download/"+"鍗峰収鐩綍.xls";
- String pdfPath = RuoYiConfig.getProfile() + "/download/"+"1.pdf";
-
- Workbook workbook = WorkbookFactory.create(new File(excelPath));
- FileOutputStream fos = new FileOutputStream(pdfPath);
- FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
- // 鑾峰彇绗竴涓伐浣滆〃
- Sheet sheet = workbook.getSheetAt(1);
-
- // 鍒涘缓PDF鏂囨。瀵硅薄
- Document document = new Document(PageSize.A2, 50, 50, 50, 50);
-
- // 鍒涘缓PDF杈撳嚭娴�
- PdfWriter writer = PdfWriter.getInstance(document, fos);
- // 4. 澶勭悊宸ヤ綔琛ㄤ腑鐨勫浘鐗�
- if (workbook instanceof XSSFWorkbook) {
- handleXSSFImages((XSSFSheet)sheet, document);
- }
- // 鎵撳紑PDF鏂囨。
- document.open();
-
- // 鍒涘缓PDF琛ㄦ牸瀵硅薄
- System.out.println(sheet.getRow(0).getLastCellNum()+"--00");
- PdfPTable table = new PdfPTable(sheet.getRow(0).getLastCellNum());
- table.setHeaderRows(1);
-
- // 璁剧疆琛ㄦ牸瀹藉害
- table.setWidthPercentage(100);
-
- // 璁剧疆琛ㄦ牸鏍囬
- Paragraph title = new Paragraph(sheet.getSheetName(), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 16, Font.BOLD));
- title.setAlignment(Element.ALIGN_CENTER);
- document.add(title);
- // System.out.println(sheet.)
- // 娣诲姞琛ㄦ牸鍐呭
- for (Row row : sheet) {
- {
- if (row == null) continue;
- System.out.println(getRealLastCellNum(row)+"---987");
-// if(row.getRowNum()==0)
-// continue;
- if(row.getRowNum()==2)
- {
- PdfPCell pdfCell = ImageSet(100);
- pdfCell.setColspan(7);
- pdfCell.setRowspan(3);
- pdfCell.setBorderWidth(1f);
- pdfCell.setBorderColor(BaseColor.BLACK);
- pdfCell.setPadding(5f);
- pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
- pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
- table.addCell(pdfCell);
- System.out.println("{{{{{{{{{{{{{");
- continue;
- }
- for (int i = 0; i < 7; i++)
- {
-
- Cell cell = row.getCell(i);
- if(row.getRowNum()==3)
- {
- PdfPCell pdfCell = new PdfPCell(new Paragraph("鍗峰唴鐩綍", new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
- pdfCell.setColspan(7);
- pdfCell.setBorderWidth(1f);
- pdfCell.setBorderColor(BaseColor.BLACK);
- pdfCell.setPadding(5f);
- pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
- pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
- table.addCell(pdfCell);
- System.out.println("{{{{{{{{{{{{{");
- break;
- }
- if(cell==null) {
-
- table.addCell("");
- continue;
- }
- PdfPCell pdfCell = new PdfPCell(new Paragraph(getCellValue(cell, evaluator), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
-
- if(row.getRowNum()!=1) {
- pdfCell.setBorderWidth(1f);
- pdfCell.setBorderColor(BaseColor.BLACK);
- pdfCell.setPadding(5f);
- pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
- pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
- }
- if (cell.getRowIndex() == 5) {
- pdfCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
- }
-
- table.addCell(pdfCell);
-
- }
- }
- }
-
- // 娣诲姞琛ㄦ牸鍒癙DF鏂囨。
- table.setSpacingBefore(20f);
- table.setSpacingAfter(20f);
- table.setKeepTogether(true);
- document.add(table);
-
- // 鍏抽棴PDF鏂囨。
- document.close();
-
-
-
-
-
- } catch (Exception e) {
- e.printStackTrace();
- }
boolean res = true;
byte[] buf = new byte[1024];
- for (DocumentMaterials dc : docs) {
+ for (DocumentMaterialsVoLarge dc : docs) {
String filePath = dc.getUrl();
filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/NumberFormatHandler.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/NumberFormatHandler.java
new file mode 100644
index 0000000..c9b474d
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/NumberFormatHandler.java
@@ -0,0 +1,15 @@
+package com.ruoyi.common.annotation;
+
+import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Workbook;
+
+public class NumberFormatHandler implements ExcelHandlerAdapter {
+ @Override
+ public Object format(Object value, String[] args, Cell cell, Workbook workbook) {
+ if (value instanceof Number) {
+ return String.format("%04d", ((Number)value).intValue());
+ }
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelExp.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelExp.java
index 099198f..cb467db 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelExp.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelExp.java
@@ -13,13 +13,22 @@
private String recordId; //妗f鍙�
private byte[] imgr; //鏉″舰鐮�
+
+ public byte[] getSedcode() {
+ return sedcode;
+ }
+
+ public void setSedcode(byte[] sedcode) {
+ this.sedcode = sedcode;
+ }
+
+ private byte[] sedcode; //浜岀淮鐮�
public ExcelExp(String fileName, List dataset, Class clazz) {
this.fileName = fileName;
this.dataset = dataset;
this.clazz = clazz;
}
-
- public ExcelExp(String fileName, List dataset, String recordId, byte[] imgr,Class clazz) {
+ public ExcelExp(String fileName, List dataset, String recordId, byte[] imgr, Class clazz) {
this.fileName = fileName;
this.dataset = dataset;
@@ -28,6 +37,16 @@
this.imgr = imgr;
}
+ public ExcelExp(String fileName, List dataset, String recordId, byte[] imgr,byte[] sedcode, Class clazz) {
+
+ this.fileName = fileName;
+ this.dataset = dataset;
+ this.clazz = clazz;
+ this.recordId = recordId;
+ this.imgr = imgr;
+ this.sedcode = sedcode;
+ }
+
public String getFileName() {
return fileName;
}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
index 6f40bb2..2dc3859 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
@@ -22,7 +22,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -267,9 +270,9 @@
* @return 缁撴灉
* @throws IOException
*/
- public void exportExcelManySheet(HttpServletResponse response, List<ExcelExp> list) throws IOException {
- response.setContentType("application/vnd.ms-excel");
- response.setCharacterEncoding("utf-8");
+ public void exportExcelManySheet(ByteOutputStream response, List<ExcelExp> list) throws IOException {
+// response.setContentType("application/vnd.ms-excel");
+// response.setCharacterEncoding("utf-8");
try {
createWorkbook();
for (int index = 0; index <list.size(); index++) {
@@ -278,22 +281,185 @@
// 鍙栧嚭涓�鍏辨湁澶氬皯涓猻heet.
// double sheetNo = Math.ceil(list.size() / sheetSize);
createSheetManySheet(index);
- // 浜х敓涓�琛�
- Row row = sheet.createRow(0);
- int column = 0;
- // 鍐欏叆鍚勪釜瀛楁鐨勫垪澶村悕绉�
- for (Object[] os : fields) {
- Excel excel = (Excel) os[1];
- this.createCell(excel, row, column++);
+ // 浜х敓涓�琛� if(index == 1) {
+ if(index==1)
+ {
+ Row row = sheet.createRow(0);
+ row.setHeightInPoints(20); // 璁剧疆琛岄珮涓�20纾�
+ int column = 0;
+ row = sheet.createRow(0);
+ sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 1));
+ row = sheet.createRow(2);
+ row.setHeightInPoints(120); // 璁剧疆琛岄珮涓�20纾�
+
+ //鎷垮埌鍥剧墖
+ // 鍒涘缓鍗曞厓鏍煎苟娣诲姞鍥剧墖
+ Cell cell = row.createCell(0);
+//sheet.setColumnWidth(0, 20 * 256); // 绗竴鍒楀搴�20瀛楃
+//sheet.setColumnWidth(1, 15 * 256); // 绗簩鍒楀搴�15瀛楃
+//sheet.setColumnWidth(2, 25 * 256); // 绗笁鍒楀搴�25瀛楃 // 璁剧疆绗竴鍒楀搴︿负20涓瓧绗�
+
+ ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) (cell.getColumnIndex()+1), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() +2),
+ cell.getRow().getRowNum() + 1);
+ // 璁$畻灞呬腑浣嶇疆
+// int col1 = 0; // 涓棿鍒�
+// int col2 = col1 + 2;
+// anchor.setCol1(col1);
+// anchor.setCol2(col2);
+// anchor.setDx1(100);
+// anchor.setDy1(0);
+// anchor.setDx2(255); // 瀹藉害
+// anchor.setDy2(255); // 楂樺害
+ anchor.setRow1(2);
+ anchor.setRow2(3);
+ byte[] data = list.get(index).getSedcode();
+// 璁剧疆鍥剧墖澶у皬鍜屼綅缃�
+ anchor.setDx1(2400000);
+ anchor.setDy1(100);
+
+ anchor.setDy2(-600000);
+ // 鑾峰彇鍥剧墖鍘熷灏哄
+ BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
+ double widthInEMU = image.getWidth() * 9525 * 0.2;
+ double heightInEMU = image.getHeight() * 9525;
+
+ // 璁剧疆鍥剧墖鍘熷灏哄
+ anchor.setDx2(-100000); // 鍘熷瀹藉害
+ // anchor.setDy2((int)heightInEMU); // 鍘熷楂樺害
+//anchor.setCol1(5); // 浠庣6鍒楀紑濮嬫樉绀�
+//anchor.setCol2(10); // 鍒扮11鍒楃粨鏉�
+
+ //Files.readAllBytes(Paths.get(RuoYiConfig.getProfile() + "/upload/2025/08/14/30_20250814212128A031.jpg"));
+//
+//
+// System.out.println(data.length);
+ getDrawingPatriarch(cell.getSheet()).createPicture(anchor,
+ cell.getSheet().getWorkbook().addPicture(data, getImageType(data)));
+
+
+
+ String [] tits = {"妗� 鍙�:","妗f棣�(瀹�)鍙�:","缂� 寰� 鍙�: ","鍙� 鏂� 鍙�:",
+ "妗� 鍗� 棰� 鍚�:","缂� 鍒� 鏃� 鏈�:","缂� 鍒� 鍗� 浣�:","淇� 绠� 鏈� 闄�:","瀵� 绾�:"};
+
+ List tmp = list.get(index).getDataset();
+ Object obj = tmp.get(0);
+ Field[] declaredFields = this.clazz.getDeclaredFields();
+ System.out.println(declaredFields.length);
+ int i = 0;
+ for (Field field : declaredFields) {
+ // 璁剧疆瀛楁鐨勮闂潈闄愶紝浠ヤ究浜庤闂鏈夊瓧娈�
+ field.setAccessible(true);
+
+ // 鑾峰彇瀛楁鐨勫悕绉板拰鍊�
+ String fieldName = field.getName();
+ // Object fieldValue = field.get(person);
+ Class<?> clazz = obj.getClass();
+ Field field1 =clazz.getDeclaredField(fieldName);
+ field1.setAccessible(true);
+ Object fieldValue = field1.get(obj);
+ if(fieldValue==null)
+ fieldValue="";
+ if(i <= 3)
+ row = sheet.createRow(i+4);
+ if(i > 3)
+ row = sheet.createRow(i+7);
+ // row.setHeight((short) 30);
+ row.setHeightInPoints(40); // 璁剧疆琛岄珮涓�20纾�
+ // row.createCell(0)
+ cell = row.createCell(0);
+ //璁剧疆cell鐨勫搴�
+ sheet.setColumnWidth(0, 20 * 256);
+ sheet.setColumnWidth(1, 60 * 256); // 绗簩鍒楀搴�15瀛楃
+
+ CellStyle style = wb.createCellStyle();
+ style.setAlignment(HorizontalAlignment.RIGHT);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+style.setVerticalAlignment(VerticalAlignment.CENTER); // 璁剧疆鍨傜洿灞呬腑
+ // style.setAlignment(VerticalAlignment.CENTER);
+ Font font = wb.createFont();
+ font.setBold(true);
+ style.setFont(font);
+style.setWrapText(true); // 璁剧疆鑷姩鎹㈣
+ cell.setCellStyle(style);
+ cell.setCellValue(tits[i]);
+ Cell cel = row.createCell(1);
+ CellStyle style1 = wb.createCellStyle();
+ style1.setBorderBottom(BorderStyle.THIN); // 娣诲姞涓嬪垝绾�
+ style1.setWrapText(true); // 璁剧疆鑷姩鎹㈣
+ style1.setVerticalAlignment(VerticalAlignment.CENTER);
+ cel.setCellStyle(style1);
+ cel.setCellValue(fieldValue.toString());
+ // sheet.setColumnWidth(0, 60 * 256);
+ i++;
+ if(i==3)
+ {
+ row = sheet.createRow(8);
+ // row.setHeight((short) 30);
+ row.setHeightInPoints(40); // 璁剧疆琛岄珮涓�20纾�
+ row = sheet.createRow(9);
+ //璁剧疆鏉″舰鐮�
+ Cell cell1 = row.createCell(0);
+//sheet.setColumnWidth(0, 20 * 256); // 绗竴鍒楀搴�20瀛楃
+//sheet.setColumnWidth(1, 15 * 256); // 绗簩鍒楀搴�15瀛楃
+//sheet.setColumnWidth(2, 25 * 256); // 绗笁鍒楀搴�25瀛楃 // 璁剧疆绗竴鍒楀搴︿负20涓瓧绗�
+
+ ClientAnchor anchor1 = new XSSFClientAnchor(0, 0, 0, 0, (short) (cell1.getColumnIndex()), cell1.getRow().getRowNum(), (short) (cell1.getColumnIndex() +2),
+ cell1.getRow().getRowNum() + 1);
+ // 璁$畻灞呬腑浣嶇疆
+//// 璁剧疆鍥剧墖澶у皬鍜屼綅缃�
+anchor1.setDx1(600000);
+anchor1.setDy1(0);
+anchor1.setDx2(-600000); // 瀹藉害
+anchor1.setDy2(255); // 楂樺害
+//anchor1.setCol1(0.5); // 浠庣6鍒楀紑濮嬫樉绀�
+//anchor1.setCol2(10); // 鍒扮11鍒楃粨鏉�
+ anchor1.setRow1(9);
+ anchor1.setRow2(10);
+ byte[] dat = list.get(index).getImgr();
+ //Files.readAllBytes(Paths.get(RuoYiConfig.getProfile() + "/upload/2025/08/14/30_20250814212128A031.jpg"));
+//
+//
+// System.out.println(data.length);
+ getDrawingPatriarch(cell1.getSheet()).createPicture(anchor1,
+ cell.getSheet().getWorkbook().addPicture(dat, getImageType(dat)));
+
+
+
+
+ row.setHeightInPoints(70); // 璁剧疆琛岄珮涓�20纾�
+ row = sheet.createRow(10);
+ row.setHeightInPoints(40); // 璁剧疆琛岄珮涓�20纾�
+ }
+ // 鎵撳嵃瀛楁鍚嶇О鍜屽��
+ System.out.println(fieldName + ": " + fieldValue);
+ }
+
+
+
+
}
- if (Excel.Type.EXPORT.equals(type)) {
- fillExcelData(index, row);
- addStatisticsRow();
+ else {
+
+ Row row = sheet.createRow(0);
+ int column = 0;
+ // 鍐欏叆鍚勪釜瀛楁鐨勫垪澶村悕绉�
+ for (Object[] os : fields) {
+ Excel excel = (Excel) os[1];
+ this.createCell(excel, row, column++);
+ }
+ if (Excel.Type.EXPORT.equals(type)) {
+ fillExcelData(index, row);
+ addStatisticsRow();
+ }
}
}
- wb.write(response.getOutputStream());
+ wb.write(response);
} catch (IOException e) {
log.error("瀵煎嚭Excel寮傚父{}", e.getMessage());
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
} finally {
if (wb != null) {
try {
@@ -302,13 +468,13 @@
e1.printStackTrace();
}
}
- if (response.getOutputStream() != null) {
- try {
- response.getOutputStream().close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
+// if (response.getOutputStream() != null) {
+// try {
+// response.getOutputStream().close();
+// } catch (IOException e1) {
+// e1.printStackTrace();
+// }
+// }
}
// exportExcel(response.getOutputStream());
}
@@ -388,6 +554,10 @@
row = sheet.createRow(i + 4 );
else
row = sheet.createRow(i + 1 );
+
+ row.setHeightInPoints(40); // 璁剧疆琛岄珮涓�20纾�
+ // row.createCell(0)
+
// 寰楀埌瀵煎嚭瀵硅薄.
T vo = (T) list.get(i);
int column = 0;
@@ -557,11 +727,26 @@
Cell cell = null;
try {
// 璁剧疆琛岄珮
- row.setHeight(maxHeight);
+ row.setHeight((short) 2000);
// 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
if (attr.isExport()) {
// 鍒涘缓cell
cell = row.createCell(column);
+ //璁剧疆cell鐨勫搴�
+ sheet.setColumnWidth(0, 20 * 256);
+ sheet.setColumnWidth(1, 60 * 256); // 绗簩鍒楀搴�15瀛楃
+
+ CellStyle style = wb.createCellStyle();
+// style.setAlignment(HorizontalAlignment.RIGHT);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER); // 璁剧疆鍨傜洿灞呬腑
+ // style.setAlignment(VerticalAlignment.CENTER);
+ Font font = wb.createFont();
+ font.setBold(true);
+ style.setFont(font);
+ style.setWrapText(true); // 璁剧疆鑷姩鎹㈣
+
+ cell.setCellStyle(style);
// attr.align();
// int align = attr.align().value;
// cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
--
Gitblit v1.9.1