| | |
| | | /** 备注 */ |
| | | @Excel(name = "备注", headerColor = IndexedColors.BLACK, width = 8) |
| | | private String remarks; |
| | | @TableField(exist = false) |
| | | private String orderByColumn; |
| | | @TableField(exist = false) |
| | | private String isAsc; |
| | | |
| | | public String getIsAsc() { |
| | | return isAsc; |
| | | } |
| | | |
| | | public void setIsAsc(String isAsc) { |
| | | this.isAsc = isAsc; |
| | | } |
| | | |
| | | public String getOrderByColumn() { |
| | | return orderByColumn; |
| | | } |
| | | |
| | | public void setOrderByColumn(String orderByColumn) { |
| | | this.orderByColumn = orderByColumn; |
| | | } |
| | | |
| | | @TableField(exist = false) |
| | | private String categoryNumberStart; |
| | |
| | | /** $column.columnComment */ |
| | | // @Excel(name = "页号", handler = NumberFormatHandler.class, headerColor = IndexedColors.BLACK) |
| | | private Long pageNumber; |
| | | |
| | | public String getPageNumberFormatted() { |
| | | return pageNumberFormatted; |
| | | } |
| | | |
| | | public void setPageNumberFormatted(String pageNumberFormatted) { |
| | | this.pageNumberFormatted = pageNumberFormatted; |
| | | } |
| | | |
| | | @TableField(exist = false) |
| | | @Excel(name = "页号", height = 10,width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) |
| | | private String pageNumberFormatted; |
| | |
| | | public class DocumentMaterialsVoSmall { |
| | | |
| | | |
| | | @Excel(name="序号",width = 5, headerFontSize=12, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | @Excel(name="序号",width = 4.86, headerFontSize=12, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private Long num; |
| | | @Excel(name = "文件编号",width = 10, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private String documentNumber; |
| | | @Excel(name = "责任者",width = 10, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | @Excel(name = "责任者",width = 10.67, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private String creator; |
| | | @Excel(name = "文件题名",width = 30, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | @Excel(name = "文件题名",width = 36.29, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | |
| | | private String title; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | |
| | | @Excel(name = "日期", width = 10, headerFontSize=12,dateFormat = "yyyy-MM-dd", headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | @Excel(name = "日期", width = 11.57, headerFontSize=12,dateFormat = "yyyy-MM-dd", headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | |
| | | private Date date; |
| | | @Excel(name = "页号",width = 10, headerFontSize=12, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | @Excel(name = "页号",width = 10.14, headerFontSize=12, headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private String pageNumberFormatted; |
| | | private Long pageNumber; |
| | | @Excel(name = "备注",width = 8, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | @Excel(name = "备注",width = 10.14, headerFontSize=12,headerColor = IndexedColors.BLACK, headerFontBold = true) |
| | | private String remarks; |
| | | |
| | | public DocumentMaterialsVoSmall(Long num, String documentNumber, String creator, String title, Date date, String pageNumberFormatted, String remarks) { |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | |
| | | List<AnalysisResult> statisticAyasis(); |
| | | |
| | | |
| | | @Select("update archive_records set record_status=#{status} where id=#{id}") |
| | | public void updateStatusById(@Param("status") String status, @Param("id")Long id); |
| | | @Select("update archive_records set record_status=#{status}, create_time=#{date} where id=#{id}") |
| | | public void updateStatusById(@Param("status") String status, @Param("id")Long id ,@Param("date") Date date); |
| | | |
| | | @Select("select ROW_NUMBER() OVER (ORDER BY record_id) AS num, filing_number, concat_ws(\" \", inquiry_number,record_id) as inqrid, case_title, public_attribute, (select count(*) as cnt from document_materials where record_id=ar.id) as cnt, remarks from archive_records as ar \n" + |
| | | "${ew.customSqlSegment}") |
| | |
| | | package com.ruoyi.mapper;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
| | | import com.ruoyi.domain.DocumentMaterials;
|
| | | import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
|
| | | import com.ruoyi.domain.vo.DocumentMaterialsFileList;
|
| | | 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;
|
| | |
|
| | | import java.util.List;
|
| | | /**
|
| | | * 【文件材料综合信息】Mapper接口
|
| | | *
|
| | | * @author ruoyi
|
| | | * @date 2025-07-26
|
| | | */
|
| | | @Mapper
|
| | | public interface DocumentMaterialsMapper extends BaseMapper<DocumentMaterials> {
|
| | |
|
| | | @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} and record_id=#{recordId}")
|
| | | 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, @Param("recordId") Long recordId);
|
| | |
|
| | |
|
| | | //根据题名拿到最大的pageOrder
|
| | | @Select("select count(*) from document_materials where title=#{title} and page_number<#{pageNumber} and stage=#{stage} and record_id=#{recordId}")
|
| | | Long getMaxPageOrder(@Param("title")String title,@Param("pageNumber") Long pageNumber,@Param("stage") String stage, @Param("recordId") Long recordId);
|
| | |
|
| | | //计算文件的序号,title有可能重复
|
| | | @Select("select count(distinct(concat_ws(',', title, stage)))-1 from document_materials where page_number<=#{pageNumber} and record_id=#{recordId}")
|
| | | Long getFileNumber(@Param("pageNumber") Long pageNumber, @Param("recordId") Long recordId);
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | //查询卷内目录
|
| | | @Select(
|
| | | "select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number,dm.remarks, ar.record_id, publicity from document_materials as dm, archive_records as ar \n" +
|
| | | " WHERE ar.id = dm.record_id and page_number IN (\n" +
|
| | | " SELECT MIN(page_number)\n" +
|
| | | " 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} and file_style!='其它材料' ")
|
| | | List<DocumentMaterialsVoLarge> getDocumentMaterialsvoLarge(@Param("recordId") int recordId);
|
| | | @Select( "select ROW_NUMBER() OVER (ORDER BY page_number) AS num,file_style, ar.record_id, ar.inquiry_number, ar.case_title, " +
|
| | | " document_number, title, page_number, \n" +
|
| | | " publicity, dm.retention_period, dm.remarks\n" +
|
| | | " from document_materials as dm, archive_records as ar WHERE dm.record_id=ar.id \n" +
|
| | | "and dm.record_id=#{recordId} and file_style!='其它材料' ")
|
| | | List<DocumentMaterialsFileList> getDocumentMaterialsFileList(@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);
|
| | |
|
| | | @Select("select if(count(*) < max(page_number), false, true) as res from document_materials where record_id=#{recordId}")
|
| | | boolean isPageNumberLegal(@Param("recordId") int recordId);
|
| | |
|
| | |
|
| | | //拿到除其它材料之外的全部数据的个数
|
| | | @Select("select count(*) FROM document_materials where file_style!='其他材料' and record_id=#{recordId}")
|
| | | int getCount(@Param("recordId") int recordId);
|
| | | |
| | | //获取指定案卷的最大页号
|
| | | @Select("select max(page_number) FROM document_materials where record_id=#{recordId}")
|
| | | Long getMaxPageNumber(@Param("recordId") int recordId);
|
| | |
|
| | |
|
| | | //判断卷内目录是否全部上传了附件
|
| | | @Select("select if(num=total_count, true, false) as res from (\n" +
|
| | | "SELECT\n" +
|
| | | " ROW_NUMBER() OVER (ORDER BY page_number) AS num, SUM(CASE WHEN dm.url IS NOT NULL THEN 1 ELSE 0 END) OVER() AS total_count\n" +
|
| | | " from document_materials as dm, archive_records as ar \n" +
|
| | | " WHERE ar.id = dm.record_id and page_number IN (SELECT MIN(page_number) \n" +
|
| | | " FROM document_materials where record_id=#{recordId}\n" +
|
| | | " GROUP BY stage, title) and ar.id =#{recordId} order by page_number desc limit 1) as res ")
|
| | | Boolean judgeArchiveInfo( @Param("recordId") int recordId);
|
| | |
|
| | | }
|
| | |
|
| | | package com.ruoyi.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.domain.DocumentMaterials; |
| | | import com.ruoyi.domain.vo.DocumentMaterialFileStyle; |
| | | import com.ruoyi.domain.vo.DocumentMaterialsFileList; |
| | | 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; |
| | | |
| | | import java.util.List; |
| | | /** |
| | | * 【文件材料综合信息】Mapper接口 |
| | | * |
| | | * @author ruoyi |
| | | * @date 2025-07-26 |
| | | */ |
| | | @Mapper |
| | | public interface DocumentMaterialsMapper extends BaseMapper<DocumentMaterials> { |
| | | |
| | | @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} and record_id=#{recordId}") |
| | | 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, @Param("recordId") Long recordId); |
| | | |
| | | |
| | | //根据题名拿到最大的pageOrder |
| | | @Select("select count(*) from document_materials where title=#{title} and page_number<#{pageNumber} and stage=#{stage} and record_id=#{recordId}") |
| | | Long getMaxPageOrder(@Param("title")String title,@Param("pageNumber") Long pageNumber,@Param("stage") String stage, @Param("recordId") Long recordId); |
| | | |
| | | //计算文件的序号,title有可能重复 |
| | | @Select("select count(distinct(concat_ws(',', title, stage)))-1 from document_materials where page_number<=#{pageNumber} and record_id=#{recordId}") |
| | | Long getFileNumber(@Param("pageNumber") Long pageNumber, @Param("recordId") Long recordId); |
| | | |
| | | |
| | | |
| | | |
| | | //查询卷内目录 |
| | | @Select( |
| | | "select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number,dm.remarks, ar.record_id, publicity from document_materials as dm, archive_records as ar \n" + |
| | | " WHERE ar.id = dm.record_id and page_number IN (\n" + |
| | | " SELECT MIN(page_number)\n" + |
| | | " 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} and file_style!='其它材料' ") |
| | | List<DocumentMaterialsVoLarge> getDocumentMaterialsvoLarge(@Param("recordId") int recordId); |
| | | @Select( "select ROW_NUMBER() OVER (ORDER BY page_number) AS num,file_style, ar.record_id, ar.inquiry_number, ar.case_title, " + |
| | | " document_number, title, page_number, \n" + |
| | | " publicity, dm.retention_period, dm.remarks\n" + |
| | | " from document_materials as dm, archive_records as ar WHERE dm.record_id=ar.id \n" + |
| | | "and dm.record_id=#{recordId} and file_style!='其它材料' ") |
| | | List<DocumentMaterialsFileList> getDocumentMaterialsFileList(@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); |
| | | |
| | | @Select("select if(count(*) < max(page_number), false, true) as res from document_materials where record_id=#{recordId}") |
| | | boolean isPageNumberLegal(@Param("recordId") int recordId); |
| | | |
| | | |
| | | //拿到除其它材料之外的全部数据的个数 |
| | | @Select("select count(*) FROM document_materials where file_style!='其他材料' and record_id=#{recordId}") |
| | | int getCount(@Param("recordId") int recordId); |
| | | |
| | | //获取指定案卷的最大页号 |
| | | @Select("select max(page_number) FROM document_materials where record_id=#{recordId}") |
| | | Long getMaxPageNumber(@Param("recordId") int recordId); |
| | | |
| | | |
| | | //判断卷内目录是否全部上传了附件 |
| | | @Select("select if(num=total_count, true, false) as res from (\n" + |
| | | "SELECT\n" + |
| | | " ROW_NUMBER() OVER (ORDER BY page_number) AS num, SUM(CASE WHEN dm.url IS NOT NULL THEN 1 ELSE 0 END) OVER() AS total_count\n" + |
| | | " from document_materials as dm, archive_records as ar \n" + |
| | | " WHERE ar.id = dm.record_id and page_number IN (SELECT MIN(page_number) \n" + |
| | | " FROM document_materials where record_id=#{recordId}\n" + |
| | | " GROUP BY stage, title) and ar.id =#{recordId} order by page_number desc limit 1) as res ") |
| | | Boolean judgeArchiveInfo( @Param("recordId") int recordId); |
| | | |
| | | } |
| | | |
| | |
| | | // .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime()) |
| | | // .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime()); |
| | | // lqw.orderByDesc(ZfProperty::getCreateTime); |
| | | if(userId==1) |
| | | if(archiveRecords.getOrderByColumn()==null) { |
| | | if (userId == 1) |
| | | |
| | | lqw.orderByDesc(ArchiveRecords::getCreateTime); |
| | | lqw.orderByDesc(ArchiveRecords::getCreateTime); |
| | | }else |
| | | { |
| | | System.out.println(archiveRecords.getOrderByColumn()); |
| | | if("recordId".equals(archiveRecords.getOrderByColumn())) { |
| | | if (archiveRecords.getIsAsc().equals("asc")) |
| | | lqw.orderByAsc(ArchiveRecords::getRecordId); |
| | | else |
| | | lqw.orderByDesc(ArchiveRecords::getRecordId); |
| | | } |
| | | if("recordStatus".equals(archiveRecords.getOrderByColumn())) |
| | | { |
| | | if (archiveRecords.getIsAsc().equals("asc")) |
| | | lqw.orderByAsc(ArchiveRecords::getRecordStatus); |
| | | else |
| | | lqw.orderByDesc(ArchiveRecords::getRecordStatus); |
| | | } |
| | | } |
| | | // else |
| | | // lqw.eq(userId!=null, ArchiveRecords::getUserId, userId); |
| | | System.out.println("ssssssssssssddd0000000000000000"); |
| | |
| | | |
| | | @Override |
| | | public int updateArchiveById(String status, Long id) { |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | |
| | | Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); |
| | | // 获取当前用户ID |
| | | Long userId = SecurityUtils.getUserId(); |
| | | // 可以在这里使用userId进行授权操作 |
| | | archiverecordstouserService.deleteArchiverecordstouserByRecordId(id, userId); |
| | | this.baseMapper.updateStatusById(status, id); |
| | | this.baseMapper.updateStatusById(status, id, date); |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public int updateStatusByIds(Long[] ids) { |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | |
| | | Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); |
| | | for(Long id : ids) |
| | | this.baseMapper.updateStatusById("录入完成",id); |
| | | this.baseMapper.updateStatusById("录入完成",id, date); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | try { |
| | | Code128Bean barcodeGenerator = new Code128Bean(); |
| | | final int dpi = 160; |
| | | barcodeGenerator.setModuleWidth(0.21); |
| | | barcodeGenerator.setBarHeight(8.0); // 设置条形码高度为64 |
| | | barcodeGenerator.setModuleWidth(0.58); |
| | | barcodeGenerator.setBarHeight(14.2); // 设置条形码高度为64 |
| | | barcodeGenerator.doQuietZone(false); |
| | | |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | |
| | | public AjaxResult selectDataList(DocumentMaterials documentMaterials, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<DocumentMaterials> lqw = buildCondition(documentMaterials); |
| | | |
| | | |
| | | lqw.eq(true, DocumentMaterials::getVisible, 1); |
| | | Page<DocumentMaterials> zfClanPage = new Page<>(pageNum, pageSize); |
| | | Page<DocumentMaterials> pageResult = page(zfClanPage, lqw); |
| | | |
| | |
| | | public List<DocumentMaterials> selectDocumentMaterialsList(DocumentMaterials documentMaterials) { |
| | | LambdaQueryWrapper<DocumentMaterials> lambdaQueryWrapper = buildCondition(documentMaterials); |
| | | List<DocumentMaterials> beanRecords = list(lambdaQueryWrapper); |
| | | int size = beanRecords.size(); |
| | | // 获取该案卷的最大页号(总页数) |
| | | Long totalPages = this.baseMapper.getMaxPageNumber(documentMaterials.getRecordId().intValue()); |
| | | |
| | | // 遍历所有条目,设置pageNumberFormatted |
| | | for (int i = 0; i < size; i++) { |
| | | DocumentMaterials item = beanRecords.get(i); |
| | | Long pageNumber = item.getPageNumber(); |
| | | |
| | | if (i == size - 1) { |
| | | // 最后一行:格式化页号为"最后一页页号-总页数"的形式 |
| | | item.setPageNumberFormatted(pageNumber + "-" + totalPages); |
| | | } else { |
| | | // 其他行:直接使用pageNumber的值 |
| | | item.setPageNumberFormatted(pageNumber != null ? pageNumber.toString() : ""); |
| | | } |
| | | } |
| | | return beanRecords; |
| | | } |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IArchiveRecordsService iArchiveRecordsService; |
| | | private static BufferedImage trimWhiteBorder(BufferedImage img) { |
| | | int width = img.getWidth(); |
| | | int height = img.getHeight(); |
| | | |
| | | int minX = width, minY = height, maxX = 0, maxY = 0; |
| | | |
| | | // 查找非白色像素的边界 |
| | | for (int y = 0; y < height; y++) { |
| | | for (int x = 0; x < width; x++) { |
| | | int rgb = img.getRGB(x, y); |
| | | // 如果不是白色 |
| | | if ((rgb & 0x00FFFFFF) != 0x00FFFFFF) { |
| | | if (x < minX) minX = x; |
| | | if (x > maxX) maxX = x; |
| | | if (y < minY) minY = y; |
| | | if (y > maxY) maxY = y; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 如果全是白色,返回原图 |
| | | if (minX > maxX || minY > maxY) { |
| | | return img; |
| | | } |
| | | |
| | | // 裁剪 |
| | | int newWidth = maxX - minX + 1; |
| | | int newHeight = maxY - minY + 1; |
| | | |
| | | // 添加1像素安全边距(可选) |
| | | minX = Math.max(0, minX - 1); |
| | | minY = Math.max(0, minY - 1); |
| | | newWidth = Math.min(width - minX, newWidth + 2); |
| | | newHeight = Math.min(height - minY, newHeight + 2); |
| | | |
| | | return img.getSubimage(minX, minY, newWidth, newHeight); |
| | | } |
| | | //生产二维码 |
| | | public byte[] createQrCodeN(String content, int width, int height) throws IOException { |
| | | QrConfig config = new QrConfig(width, height); |
| | | |
| | | config.setMargin(0); |
| | | config.setMargin(2); |
| | | // 高纠错级别 |
| | | config.setErrorCorrection(ErrorCorrectionLevel.H); |
| | | // 设置前景色,既二维码颜色(自行选择颜色修改) |
| | | config.setForeColor(new Color(11, 11, 11).getRGB()); |
| | | // 设置背景色(灰色)需要背景色时候打开链接 |
| | | config.setBackColor(new Color(242,242,242).getRGB()); |
| | | config.setForeColor(java.awt.Color.BLACK); |
| | | config.setBackColor(java.awt.Color.WHITE); |
| | | |
| | | |
| | | BufferedImage bufferedImage = QrCodeUtil.generate(// |
| | | content, //二维码内容 |
| | | config |
| | | ); |
| | | |
| | | // 步骤2:手动裁剪白边 |
| | | bufferedImage = trimWhiteBorder(bufferedImage); |
| | | System.out.println(bufferedImage); |
| | | System.out.println("---02340230949394"); |
| | | ByteArrayOutputStream os = new ByteArrayOutputStream(); |
| | |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.List; |
| | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.aspose.words.License; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.drew.imaging.ImageMetadataReader; |
| | |
| | | vo.setCreator(doc.getCreator()); |
| | | vo.setTitle(doc.getTitle()); |
| | | vo.setDate(doc.getDate()); |
| | | vo.setPageNumber(doc.getPageNumber()); |
| | | vo.setPageNumberFormatted(doc.getPageNumber().toString()); |
| | | vo.setRemarks(doc.getRemarks()); |
| | | // vo.setRecordId(doc.getRecordId() != null ? doc.getRecordId().toString() : null); |
| | | // vo.setPublicity(doc.getPublicity()); |
| | |
| | | |
| | | //导出案卷封面 |
| | | @PostMapping("/exportPageInfo/{id}/{recordId}") |
| | | public void exportPageInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId) throws IOException { |
| | | public void exportPageInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId) throws IOException, ParseException { |
| | | |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); |
| | | |
| | |
| | | arsi.add(aIV); |
| | | |
| | | String recordId1 = recordId; |
| | | if(aIV!=null) |
| | | { |
| | | String date = ""; |
| | | if(arsi.get(0).getPreparationDate()!=null) { |
| | | System.out.println(arsi.get(0).getPreparationDate().toString() + "]]]]]]]]"); |
| | | |
| | | System.out.println(DateUtil.parseCST(arsi.get(0).getPreparationDate().toString())); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | DateTime dat = DateUtil.parseCST(arsi.get(0).getPreparationDate().toString()); |
| | | date = new SimpleDateFormat("yyyy-MM-dd").format(dat); |
| | | } |
| | | |
| | | |
| | | String tmp = "档号:" + |
| | | arsi.get(0).getRecordId() + |
| | | ";档案馆(室)号:" + arsi.get(0).getArchiveRoomNumber()+ |
| | | ";缩微号:" + arsi.get(0).getMicrofilmNumber()+ |
| | | ";发文号:" + arsi.get(0).getInquiryNumber()+ |
| | | ";案卷题名:" + arsi.get(0).getCaseTitle() + |
| | | ";编制日期:" + date + |
| | | ";编制单位:" + arsi.get(0).getPreparationUnit() + |
| | | ";保管期限:" + arsi.get(0).getRetentionPeriod() + |
| | | ";密级:" + arsi.get(0).getSecurityClassification(); |
| | | byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 200, 200); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(tmp, 210, 210); |
| | | ExcelExp e3 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.class); |
| | | ExcelExp e4 = new ExcelExp("案卷封面", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class); |
| | | List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>(); |
| | |
| | | |
| | | // System.out.println(bos2); |
| | | bos2.writeTo(response.getOutputStream()); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.archive; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.aspose.cells.PdfCompliance; |
| | | import com.aspose.words.License; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | |
| | | List<ArchiveInfoVo> arsi = new ArrayList<>(); |
| | | arsi.add(aIV); |
| | | |
| | | |
| | | |
| | | String date = ""; |
| | | if(arsi.get(0).getPreparationDate()!=null) { |
| | | System.out.println(arsi.get(0).getPreparationDate().toString() + "]]]]]]]]"); |
| | | |
| | | System.out.println(DateUtil.parseCST(arsi.get(0).getPreparationDate().toString())); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | DateTime dat = DateUtil.parseCST(arsi.get(0).getPreparationDate().toString()); |
| | | date = new SimpleDateFormat("yyyy-MM-dd").format(dat); |
| | | } |
| | | |
| | | |
| | | String tmpSec = "档号:" + |
| | | arsi.get(0).getRecordId() + |
| | | ";档案馆(室)号:" + arsi.get(0).getArchiveRoomNumber()+ |
| | | ";缩微号:" + arsi.get(0).getMicrofilmNumber()+ |
| | | ";发文号:" + arsi.get(0).getInquiryNumber()+ |
| | | ";案卷题名:" + arsi.get(0).getCaseTitle() + |
| | | ";编制日期:" + date + |
| | | ";编制单位:" + arsi.get(0).getPreparationUnit() + |
| | | ";保管期限:" + arsi.get(0).getRetentionPeriod() + |
| | | ";密级:" + arsi.get(0).getSecurityClassification(); |
| | | |
| | | String recordId = aIV.getRecordId(); |
| | | byte[] imgr = barcodeService.generateBarcodeImage(recordId); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(recordId, 100, 100); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(tmpSec, 100, 100); |
| | | ExcelExp e1 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.class); |
| | | ExcelExp e2 = new ExcelExp("案卷封面", arsi, recordId, imgr,sedcode, ArchiveInfoVo.class); |
| | | List<ExcelExp> mysheet = new ArrayList<ExcelExp>(); |
| | |
| | | List<ArchiveInfoVo> arsi = new ArrayList<>(); |
| | | arsi.add(aIV); |
| | | |
| | | String dates = ""; |
| | | if(arsi.get(0).getPreparationDate()!=null) { |
| | | System.out.println(arsi.get(0).getPreparationDate().toString() + "]]]]]]]]"); |
| | | |
| | | System.out.println(DateUtil.parseCST(arsi.get(0).getPreparationDate().toString())); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | DateTime dat = DateUtil.parseCST(arsi.get(0).getPreparationDate().toString()); |
| | | dates = new SimpleDateFormat("yyyy-MM-dd").format(dat); |
| | | } |
| | | |
| | | |
| | | String tmpSec = "档号:" + |
| | | arsi.get(0).getRecordId() + |
| | | ";档案馆(室)号:" + arsi.get(0).getArchiveRoomNumber()+ |
| | | ";缩微号:" + arsi.get(0).getMicrofilmNumber()+ |
| | | ";发文号:" + arsi.get(0).getInquiryNumber()+ |
| | | ";案卷题名:" + arsi.get(0).getCaseTitle() + |
| | | ";编制日期:" + dates + |
| | | ";编制单位:" + arsi.get(0).getPreparationUnit() + |
| | | ";保管期限:" + arsi.get(0).getRetentionPeriod() + |
| | | ";密级:" + arsi.get(0).getSecurityClassification(); |
| | | |
| | | |
| | | |
| | | String recordId1 = aIV.getRecordId(); |
| | | byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 200, 200); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(tmpSec, 200, 200); |
| | | ExcelExp e3 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.class); |
| | | ExcelExp e4 = new ExcelExp("案卷封面", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class); |
| | | List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>(); |
| | |
| | | List<ArchiveInfoVo> arsi = new ArrayList<>(); |
| | | arsi.add(aIV); |
| | | |
| | | |
| | | String date = ""; |
| | | if(arsi.get(0).getPreparationDate()!=null) { |
| | | System.out.println(arsi.get(0).getPreparationDate().toString() + "]]]]]]]]"); |
| | | |
| | | System.out.println(DateUtil.parseCST(arsi.get(0).getPreparationDate().toString())); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | DateTime dat = DateUtil.parseCST(arsi.get(0).getPreparationDate().toString()); |
| | | date = new SimpleDateFormat("yyyy-MM-dd").format(dat); |
| | | } |
| | | |
| | | |
| | | String tmpSec = "档号:" + |
| | | arsi.get(0).getRecordId() + |
| | | ";档案馆(室)号:" + arsi.get(0).getArchiveRoomNumber()+ |
| | | ";缩微号:" + arsi.get(0).getMicrofilmNumber()+ |
| | | ";发文号:" + arsi.get(0).getInquiryNumber()+ |
| | | ";案卷题名:" + arsi.get(0).getCaseTitle() + |
| | | ";编制日期:" + date + |
| | | ";编制单位:" + arsi.get(0).getPreparationUnit() + |
| | | ";保管期限:" + arsi.get(0).getRetentionPeriod() + |
| | | ";密级:" + arsi.get(0).getSecurityClassification(); |
| | | |
| | | |
| | | String recordId1 = aIV.getRecordId(); |
| | | byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 200, 200); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(tmpSec, 200, 200); |
| | | ExcelExp e3 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.class); |
| | | ExcelExp e4 = new ExcelExp("案卷封面", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class); |
| | | List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>(); |
| | |
| | | import com.ruoyi.common.utils.file.ImageUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | import org.apache.poi.hssf.usermodel.HSSFClientAnchor; |
| | | import org.apache.poi.hssf.usermodel.HSSFDataValidation; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.hssf.usermodel.HSSFClientAnchor; |
| | | import org.apache.poi.hssf.usermodel.HSSFDataValidation; |
| | |
| | | if(index == 1) { |
| | | // 合并第一行的前5个单元格 |
| | | sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6)); |
| | | // 获取页面设置 |
| | | // 必须先设置为true |
| | | // 页面布局设置 |
| | | sheet.setAutobreaks(true); |
| | | sheet.setFitToPage(true); |
| | | |
| | | // 创建行并设置高度 |
| | | // 获取打印设置 |
| | | PrintSetup printSetup = sheet.getPrintSetup(); |
| | | |
| | | // 设置为1页宽度 |
| | | printSetup.setFitWidth((short) 1); // 宽度调整为1页 |
| | | printSetup.setFitHeight((short) 0); // 高度不限制 |
| | | |
| | | // 其他打印设置 |
| | | printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE); // A4纸 |
| | | printSetup.setLandscape(false); // 纵向打印 |
| | | |
| | | // 设置页边距 |
| | | sheet.setMargin(Sheet.LeftMargin, 0.5); |
| | | sheet.setMargin(Sheet.RightMargin, 0.5); |
| | | // 设置打印区域,从第0行到第1000行,第0列到第20列(根据实际情况调整) |
| | | // sheet.setPrintArea(0, 0, 20, 0, 1000); |
| | | // 如果是index为1的sheet,设置顶端标题行 |
| | | |
| | | // 将第1行(索引为0)设置为每页重复的标题行 |
| | | sheet.setRepeatingRows(CellRangeAddress.valueOf("$1:$4")); |
| | | row = sheet.createRow(0); |
| | | row.setHeight((short)(30 *30)); |
| | | row.setHeight((short) (37*20)); |
| | | |
| | | // 创建单元格并添加图片 |
| | | Cell cell = row.createCell(0); |
| | |
| | | // if (Files.exists(Paths.get(imagePath))) { |
| | | // byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath)); |
| | | // 将byte数组转换成inputstream,以便插入到Excel中 |
| | | ClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 5), |
| | | ClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 100, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 5), |
| | | cell.getRow().getRowNum() + 1); |
| | | // 设置锚点类型为MOVE_AND_RESIZE,使图片可以随单元格调整大小 |
| | | anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE); |
| | | // 计算居中位置 |
| | | int col1 = 3; // 中间列 |
| | | int col2 = col1 + 2; |
| | |
| | | anchor.setCol2(col2); |
| | | anchor.setRow1(0); |
| | | anchor.setRow2(1); |
| | | // anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE); |
| | | // anchor.set |
| | | // anchor.setHorizontallyCenter(true); |
| | | |
| | |
| | | // log.error("添加图片失败: {}", e.getMessage()); |
| | | // } |
| | | row = sheet.createRow(1); |
| | | row.setHeight((short) (32.5*20)); |
| | | sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 6)); |
| | | Cell titleCell = row.createCell(0); |
| | | titleCell.setCellValue("卷 内 目 录"); |
| | | titleCell.setCellValue("卷 内 目 录"); |
| | | // 设置加粗、宋体、18号字体和居中样式 |
| | | CellStyle style = wb.createCellStyle(); |
| | | Font font = wb.createFont(); |
| | |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | titleCell.setCellStyle(style); |
| | | row = sheet.createRow(2); |
| | | row.setHeight((short) (20*20)); |
| | | // |
| | | row.createCell(4).setCellValue("档号:"); |
| | | Cell dnumCell = row.createCell(4); |
| | | dnumCell.setCellValue("档号:"); |
| | | // 设置加粗、宋体、18号字体和居中样式 |
| | | CellStyle style1 = wb.createCellStyle(); |
| | | Font font1 = wb.createFont(); |
| | | font1.setBold(true); |
| | | font1.setFontName("宋体"); |
| | | font1.setFontHeightInPoints((short) 12); |
| | | style1.setFont(font1); |
| | | style1.setAlignment(HorizontalAlignment.RIGHT); |
| | | dnumCell.setCellStyle(style1); |
| | | // row.createCell(4).setCellValue("档号:"); |
| | | //拿到档号 |
| | | String recordId = list.get(index).getRecordId(); |
| | | row.createCell(5).setCellValue(recordId); |
| | | // 创建带有下划线样式的单元格 |
| | | Cell recordIdCell = row.createCell(5); |
| | | recordIdCell.setCellValue(recordId); |
| | | // 创建下划线样式 |
| | | CellStyle underlineStyle = wb.createCellStyle(); |
| | | Font underlineFont = wb.createFont(); |
| | | underlineFont.setFontName("宋体"); |
| | | underlineFont.setFontHeightInPoints((short) 11); |
| | | underlineFont.setUnderline(Font.U_SINGLE); // 设置下划线 |
| | | underlineStyle.setFont(underlineFont); |
| | | recordIdCell.setCellStyle(underlineStyle); |
| | | row = sheet.createRow(3); |
| | | |
| | | row.setHeight((short) (17.5*20)); |
| | | row = sheet.createRow(4); |
| | | // // 添加总页数和当前页码信息 |
| | | // row.createCell(5).setCellValue("总页数: " + list.size() + ", 当前页: " + (index + 1)); |
| | | // row = sheet.createRow(4); |
| | |
| | | // int endNo = Math.min(startNo + sheetSize, list.size()); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if(index==1) |
| | | row = sheet.createRow(i + 4 ); |
| | | row = sheet.createRow(i + 5 ); |
| | | else |
| | | row = sheet.createRow(i + 1 ); |
| | | // 得到导出对象. |
| | |
| | | style.setWrapText(true); |
| | | Font dataFont = wb.createFont(); |
| | | dataFont.setFontName("Arial"); |
| | | dataFont.setFontHeightInPoints((short) 10); |
| | | dataFont.setFontHeightInPoints((short) 12); |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | | |
| | |
| | | style.setWrapText(true); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName(excel.headerFontName()); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setFontHeightInPoints((short) 12); |
| | | headerFont.setBold(excel.headerFontBold()); |
| | | headerFont.setColor(excel.headerColor().index); |
| | | style.setFont(headerFont); |
| | |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | Font totalFont = wb.createFont(); |
| | | totalFont.setFontName("Arial"); |
| | | totalFont.setFontHeightInPoints((short) 10); |
| | | totalFont.setFontHeightInPoints((short) 12); |
| | | style.setFont(totalFont); |
| | | // 总计行也设置自动换行 |
| | | style.setWrapText(true); |
| | |
| | | } else { |
| | | wb.setSheetName(index, sheetName + index); |
| | | } |
| | | // 设置页面属性 |
| | | sheet.setFitToPage(true); |
| | | PrintSetup printSetup = sheet.getPrintSetup(); |
| | | printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE); // 设置为A4纸张 |
| | | printSetup.setLandscape(false); // 纵向打印 |
| | | printSetup.setFitWidth((short) 1); // 宽度调整为1页 |
| | | printSetup.setFitHeight((short) 0); // 0表示高度不限制页数(自动) |
| | | // 设置页边距 |
| | | sheet.setMargin(Sheet.TopMargin, 1.0); // 增加顶部边距以容纳页眉 |
| | | sheet.setMargin(Sheet.BottomMargin, 0.5); |
| | | sheet.setMargin(Sheet.LeftMargin, 0.5); |
| | | sheet.setMargin(Sheet.RightMargin, 0.5); |
| | | sheet.setMargin(Sheet.HeaderMargin, 0.5); // 设置页眉边距 |
| | | sheet.setMargin(Sheet.FooterMargin, 0.5); // 设置页脚边距 |
| | | // 设置打印区域,从第0行到第1000行,第0列到第20列(根据实际情况调整) |
| | | //sheet.setPrintArea(0, 0, 20, 0, 1000); |
| | | // 设置页眉,显示总页数和当前页码 |
| | | if (wb instanceof HSSFWorkbook) { |
| | | HSSFWorkbook hssfWb = (HSSFWorkbook) wb; |
| | | HSSFSheet hssfSheet = hssfWb.getSheetAt(index); |
| | | HSSFHeader header = hssfSheet.getHeader(); |
| | | // 设置页眉字体 |
| | | // header.setFontName("宋体"); |
| | | // header.setFontSize((short) 10); |
| | | // 设置页眉内容 |
| | | hssfSheet.setMargin(Sheet.HeaderMargin, 0.5); |
| | | header.setRight("总页数: &P, 当前页: &N"); |
| | | // 设置页眉左对齐和右对齐内容(可选) |
| | | header.setLeft("文档标题"); |
| | | header.setRight("&D &T"); // 日期和时间 |
| | | } |
| | | // 如果是index为1的sheet,设置顶端标题行 |
| | | if (index == 1) { |
| | | // 将第1行(索引为0)设置为每页重复的标题行 |
| | | sheet.setRepeatingRows(CellRangeAddress.valueOf("$1:$4")); |
| | | } |
| | | } |
| | | /** |
| | | * 创建工作表 |
| | |
| | | this.sheet = wb.createSheet(); |
| | | this.styles = createStyles(wb); |
| | | wb.setSheetName(index, sheetName); |
| | | // 获取页面设置 |
| | | // 必须先设置为true |
| | | sheet.setFitToPage(true); |
| | | PrintSetup printSetup = sheet.getPrintSetup(); |
| | | printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE); // 设置为A4纸张 |
| | | printSetup.setLandscape(false); // 纵向打印 |
| | | printSetup.setFitWidth((short) 1); // 宽度调整为1页 |
| | | printSetup.setFitHeight((short) 0); // 0表示高度不限制页数(自动) |
| | | // 设置页边距 |
| | | sheet.setMargin(Sheet.TopMargin, 1.0); // 增加顶部边距以容纳页眉 |
| | | sheet.setMargin(Sheet.BottomMargin, 0.5); |
| | | sheet.setMargin(Sheet.LeftMargin, 0.5); |
| | | sheet.setMargin(Sheet.RightMargin, 0.5); |
| | | sheet.setMargin(Sheet.HeaderMargin, 0.5); // 设置页眉边距 |
| | | sheet.setMargin(Sheet.FooterMargin, 0.5); // 设置页脚边距 |
| | | // 设置打印区域,从第0行到第1000行,第0列到第20列(根据实际情况调整) |
| | | // sheet.setPrintArea(0, 0, 20, 0, 1000); |
| | | // 设置页眉,显示总页数和当前页码 |
| | | if (wb instanceof HSSFWorkbook) { |
| | | HSSFWorkbook hssfWb = (HSSFWorkbook) wb; |
| | | HSSFSheet hssfSheet = hssfWb.getSheetAt(index); |
| | | HSSFHeader header = hssfSheet.getHeader(); |
| | | // 设置页眉字体 |
| | | // header.setFontName("宋体"); |
| | | // header.setFontSize((short) 10); |
| | | // 设置页眉内容 |
| | | hssfSheet.setMargin(Sheet.HeaderMargin, 2.1); |
| | | header.setRight("共 &N 页 第 &P页"); |
| | | } |
| | | // 如果是index为1的sheet,设置顶端标题行 |
| | | if (index == 1) { |
| | | // 将第1行(索引为0)设置为每页重复的标题行 |
| | | sheet.setRepeatingRows(CellRangeAddress.valueOf("$1:$3")); |
| | | } |
| | | } |
| | | /** |
| | | * 获取单元格值 |
| | |
| | | } |
| | | return val; |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public void exportExcelManySheet(HttpServletResponse response, List<ExcelExp> list, boolean includeQrCode, byte[] bt, |
| | | List<String> sigArr, List<String> arrAn, String inquiryNumber, String caseTitle) throws IOException { |
| | | // response.setContentType("application/vnd.ms-excel"); |
| | | // response.setCharacterEncoding("utf-8"); |
| | | // response.setContentType("application/vnd.ms-excel"); |
| | | // response.setCharacterEncoding("utf-8"); |
| | | |
| | | try { |
| | | createWorkbook(); |
| | |
| | | |
| | | |
| | | // 创建行并设置高度 |
| | | row = sheet.createRow(firow); |
| | | row = sheet.createRow(firow); |
| | | row.setHeight((short)(40 * 40)); |
| | | //生成二维码 |
| | | if(includeQrCode) |
| | |
| | | firow = firow + 1; |
| | | row = sheet.createRow(firow); |
| | | } |
| | | // sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 7)); |
| | | // sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 7)); |
| | | if(firow==1) |
| | | { |
| | | sheet.addMergedRegion(new CellRangeAddress(firow, firow, 0, 8)); |
| | |
| | | titleCell.setCellStyle(style); |
| | | firow = firow + 1; |
| | | row = sheet.createRow(firow); |
| | | // |
| | | // |
| | | row.createCell(0).setCellValue("发文号:"); |
| | | sheet.addMergedRegion(new CellRangeAddress(firow, firow, 1, 3)); |
| | | row.createCell(1).setCellValue(inquiryNumber); |
| | |
| | | column = 0; |
| | | } else { |
| | | // 普通sheet处理 |
| | | // recordId = (DocumentMaterialsVo)list.get(0) |
| | | // recordId = (DocumentMaterialsVo)list.get(0) |
| | | row = sheet.createRow(0); |
| | | column = 0; |
| | | } |
| | |
| | | String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor()); |
| | | if (!headerStyles.containsKey(key)) |
| | | { |
| | | style = wb.createCellStyle(); |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | |
| | | } |
| | | return val; |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | import org.apache.poi.hssf.usermodel.HSSFClientAnchor; |
| | |
| | | if(index==1) |
| | | { |
| | | Row row = sheet.createRow(0); |
| | | row.setHeightInPoints(20); // 设置行高为20磅 |
| | | // row.setHeightInPoints(20); // 设置行高为20磅 |
| | | row.setHeight((short) (12.75*20)); |
| | | int column = 0; |
| | | row = sheet.createRow(0); |
| | | row = sheet.createRow(1); |
| | | row.setHeight((short) (12.75*20)); |
| | | sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 1)); |
| | | row = sheet.createRow(2); |
| | | row.setHeightInPoints(100); // 设置行高为20磅 |
| | | row.setHeight((short) (77.5*20)); |
| | | row = sheet.createRow(3); |
| | | row.setHeight((short) (35*20)); |
| | | // row.setHeightInPoints(100); // 设置行高为20磅 |
| | | |
| | | |
| | | // 页面布局设置 |
| | | sheet.setAutobreaks(true); |
| | | sheet.setFitToPage(true); |
| | | |
| | | // 获取打印设置 |
| | | PrintSetup printSetup = sheet.getPrintSetup(); |
| | | |
| | | // 设置为1页宽度 |
| | | printSetup.setFitWidth((short) 1); // 宽度调整为1页 |
| | | printSetup.setFitHeight((short) 0); // 高度不限制 |
| | | |
| | | // 其他打印设置 |
| | | printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE); // A4纸 |
| | | printSetup.setLandscape(false); // 纵向打印 |
| | | sheet.setMargin(Sheet.LeftMargin, 1.04); |
| | | sheet.setMargin(Sheet.RightMargin, 1.04); |
| | | sheet.setMargin(Sheet.TopMargin, 0.97); |
| | | sheet.setMargin(Sheet.BottomMargin, 0.97); |
| | | //拿到图片 |
| | | // 创建单元格并添加图片 |
| | | Cell cell = row.createCell(0); |
| | |
| | | // 创建单元格 |
| | | Cell qrCell = sheet.createRow(2).createCell(1); |
| | | // 设置行高足够高以显示二维码 |
| | | sheet.getRow(2).setHeightInPoints(100); |
| | | sheet.getRow(2).setHeight((short) (77.5*20)); |
| | | // sheet.getRow(3).setHeight((short) (35*20)); |
| | | // sheet.getRow(2).setHeightInPoints(100); |
| | | // 二维码需要较大的列宽来显示,设置之前先保存当前列宽 |
| | | int currentColumnWidth = sheet.getColumnWidth(1); |
| | | // 设置足够宽的列宽以显示二维码 |
| | |
| | | // 创建图片锚点,设置在第2行第2列 |
| | | // 二维码显示在右上角且不填满整个格子 |
| | | // 缩小图片范围:只占用部分单元格空间 |
| | | ClientAnchor anchor = new HSSFClientAnchor(700, 20, 1000, 220, (short) 1, 2, (short) 1, 2); |
| | | ClientAnchor anchor = new HSSFClientAnchor(680, 0, 1000, 250, (short) 1, 2, (short) 1, 2); |
| | | // 设置图片位置和大小 |
| | | anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_DONT_RESIZE); |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | | // 以"档案馆 (室) 号:"为基准,统一所有标题的长度和格式 |
| | | String [] tits = { |
| | | "档 号:", |
| | | "档案馆 (室) 号:", |
| | | "缩 微 号:", |
| | | "发 文 号:", |
| | | "档 号:", |
| | | "档案馆 (室) 号:", |
| | | "缩 微 号:", |
| | | "发 文 号:", |
| | | "案 卷 题 名:", |
| | | "编 制 日 期:", |
| | | "编 制 单 位:", |
| | |
| | | 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); |
| | | if(i != 4) |
| | | row.setHeight((short) (35*20)); |
| | | // row.setHeight((short) 30); |
| | | // 不设置固定行高,后续使用autoSizeRow自动调整 |
| | | cell = row.createCell(0); |
| | |
| | | // 第一列宽度设置为27 |
| | | // 第二列宽度设置为51 |
| | | // 使用与addCell方法相同的计算公式设置列宽 |
| | | sheet.setColumnWidth(0, (int) ((29 + 0.72) * 256)); // 第一列:宽度27 |
| | | sheet.setColumnWidth(1, (int) ((52 + 0.72) * 256)); // 第二列:宽度51 |
| | | sheet.setColumnWidth(0, (int) ((27.86 + 0.72) * 256)); // 第一列:宽度27 |
| | | sheet.setColumnWidth(1, (int) ((51.57 + 0.72) * 256)); // 第二列:宽度51 |
| | | |
| | | CellStyle style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.RIGHT); |
| | |
| | | font.setFontHeightInPoints((short) 18); |
| | | style.setFont(font); |
| | | style.setWrapText(true); // 设置自动换行 |
| | | |
| | | if(i==4) |
| | | { |
| | | style.setVerticalAlignment(VerticalAlignment.TOP); // 设置垂直下对齐 |
| | | |
| | | } |
| | | cell.setCellStyle(style); |
| | | cell.setCellValue(tits[i]); |
| | | |
| | | |
| | | Cell cel = row.createCell(1); |
| | | CellStyle style1 = wb.createCellStyle(); |
| | | style1.setBorderBottom(BorderStyle.THIN); // 添加下划线 |
| | | if(i!=4) |
| | | style1.setBorderBottom(BorderStyle.THIN); // 添加下划线 |
| | | style1.setWrapText(true); // 设置自动换行 |
| | | style1.setVerticalAlignment(VerticalAlignment.BOTTOM); // 设置垂直下对齐 |
| | | |
| | |
| | | { |
| | | // 确保案 卷 题 名:这一行能根据内容长度自动换行 |
| | | style1.setWrapText(true); // 明确设置自动换行 |
| | | style1.setVerticalAlignment(VerticalAlignment.TOP); // 设置垂直下对齐 |
| | | |
| | | cel.setCellStyle(style1); |
| | | row.setHeight((short) (110*20)); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | // 处理日期格式化,特别是"编 制 日 期:"这一行 |
| | | if (i == 5 && fieldValue instanceof Date) { |
| | | // 设置日期格式为yyyy-MM-dd |
| | |
| | | } |
| | | |
| | | // 对于i==4的情况,确保行高能根据内容自动调整 |
| | | if(i==4) |
| | | { |
| | | // 设置行高为自动调整(-1表示自动高度) |
| | | row.setHeight((short) -1); |
| | | // 不限制最大行高,允许根据内容自动调整 |
| | | } else { |
| | | // 使用setHeight方法设置行高为自动调整(-1表示自动高度) |
| | | row.setHeight((short) -1); |
| | | // 确保行高至少为40磅,但不限制最大行高 |
| | | if (row.getHeightInPoints() < 40) { |
| | | row.setHeightInPoints(40); |
| | | } |
| | | } |
| | | // if(i==4) |
| | | // { |
| | | // // 设置行高为自动调整(-1表示自动高度) |
| | | // // row.setHeight((short) -1); |
| | | // // 不限制最大行高,允许根据内容自动调整 |
| | | // } else if (i > 4) { // 只对i>1的行应用这些设置,保留i<=1的行高设置 |
| | | // // 使用setHeight方法设置行高为自动调整(-1表示自动高度) |
| | | // row.setHeight((short) -1); |
| | | // // 确保行高至少为40磅,但不限制最大行高 |
| | | // if (row.getHeightInPoints() < 40) { |
| | | // row.setHeightInPoints(40); |
| | | // } |
| | | // } |
| | | // sheet.setColumnWidth(0, 60 * 256); |
| | | i++; |
| | | if(i==3) |
| | | { |
| | | row = sheet.createRow(8); |
| | | row.setHeight((short) (35*20)); |
| | | // 设置行高为自动调整 |
| | | row.setHeight((short) -1); |
| | | // row.setHeight((short) -1); |
| | | // row.setHeight((short) 30); |
| | | row.setHeightInPoints(20); // 设置行高为20磅 |
| | | // row.setHeightInPoints(20); // 设置行高为20磅 |
| | | row = sheet.createRow(9); |
| | | row.setHeight((short) (50*20)); |
| | | |
| | | //设置条形码 |
| | | // 设置条形码 |
| | | byte[] dat = list.get(index).getImgr(); |
| | |
| | | // 创建单元格 |
| | | Cell barcodeCell = sheet.createRow(9).createCell(0); |
| | | // 设置行高足够高以显示条形码 |
| | | sheet.getRow(9).setHeightInPoints(40); |
| | | // sheet.getRow(9).setHeightInPoints(40); |
| | | sheet.getRow(9).setHeight((short) (50*20)); |
| | | // 设置列宽足够宽以显示条形码,先保存当前列宽 |
| | | int currentColumnWidth0 = sheet.getColumnWidth(0); |
| | | sheet.setColumnWidth(0, 40 * 256); |
| | |
| | | // 条形码居中且不超出第二个格子 |
| | | // 调整结束列索引和位置参数 |
| | | // 增加dx1值,使条形码整体向右移动 |
| | | ClientAnchor anchor1 = new HSSFClientAnchor(660, 50, 900, 200, (short) 0, 9, (short) 1, 10); |
| | | ClientAnchor anchor1 = new HSSFClientAnchor(660, 0, 900, 60, (short) 0, 9, (short) 1, 10); |
| | | // 设置图片位置和大小 |
| | | anchor1.setAnchorType(ClientAnchor.AnchorType.MOVE_DONT_RESIZE); |
| | | |
| | |
| | | |
| | | |
| | | |
| | | row.setHeightInPoints(70); // 设置行高为20磅 |
| | | //row.setHeightInPoints(70); // 设置行高为20磅 |
| | | row = sheet.createRow(10); |
| | | row.setHeightInPoints(40); // 设置行高为20磅 |
| | | row.setHeight((short) (35*20)); |
| | | } |
| | | // 打印字段名称和值 |
| | | System.out.println(fieldName + ": " + fieldValue); |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |