archiveManager/pom.xml
@@ -48,6 +48,36 @@ <groupId>com.ruoyi</groupId> <artifactId>ruoyi-system</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> <!-- 糊涂工具包使用生成二维码--> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.5.9</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>3.3.3</version> </dependency> <dependency> <groupId>net.sf.barcode4j</groupId> <artifactId>barcode4j</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13</version> <scope>compile</scope> </dependency> </dependencies> </project> archiveManager/src/main/java/com/ruoyi/domain/ArchivePlaceName.java
New file @@ -0,0 +1,87 @@ package com.ruoyi.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; import java.util.Date; /** * 【请填写功能名称】对象 archive_place_name * * @author ruoyi * @date 2025-08-08 */ public class ArchivePlaceName extends BaseEntity { private static final long serialVersionUID = 1L; /** 主键 */ /** $column.columnComment */ @TableId(type = IdType.AUTO) private Long id; /** 对应的区号 */ @Excel(name = "对应的区号") private String nnumber; @Override public Date getCreateTime() { return createTime; } @Override public void setCreateTime(Date createTime) { this.createTime = createTime; } private Date createTime; /** 对应的区名称 */ @Excel(name = "对应的区名称") private String name; public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setNnumber(String nnumber) { this.nnumber = nnumber; } public String getNnumber() { return nnumber; } public void setName(String name) { this.name = name; } public String getName() { return name; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("nnumber", getNnumber()) .append("name", getName()) .toString(); } } archiveManager/src/main/java/com/ruoyi/domain/ArchiveProjectName.java
New file @@ -0,0 +1,64 @@ package com.ruoyi.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; import java.util.Date; /** * 【请填写功能名称】对象 archive_project_name * * @author ruoyi * @date 2025-08-08 */ public class ArchiveProjectName extends BaseEntity { private static final long serialVersionUID = 1L; /** $column.columnComment */ @TableId(type = IdType.AUTO) private Long id; @Excel(name = "项目名称") private String name; private Date createTime; @Override public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getCreateTime() { return createTime; } public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setName(String name) { this.name = name; } public String getName() { return name; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("name", getName()) .toString(); } } archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
@@ -34,6 +34,17 @@ @Excel(name = "发问号") private String inquiryNumber; public String getEveryProjectName() { return everyProjectName; } public void setEveryProjectName(String everyProjectName) { this.everyProjectName = everyProjectName; } @Excel(name = "每个案卷属于的项目名称") private String everyProjectName; /** 案卷题名 */ @Excel(name = "案卷题名") private String caseTitle; @@ -103,6 +114,8 @@ private String remarks; /** 历史相关发文号 */ @Excel(name = "历史相关发文号") private String historicalReferenceNumber; @@ -114,6 +127,8 @@ private String archiveRecordsId; @TableField(exist = false) // private String archiveStatus private Long userId; @Override archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java
@@ -25,17 +25,28 @@ /** $column.columnComment */ @TableId(type = IdType.AUTO) private Long materialId; @Excel(name = "文件材料序号") private Long fileNumber; public Long getFileNumber() { return fileNumber; } public void setFileNumber(Long fileNumber) { this.fileNumber = fileNumber; } /** $column.columnComment */ @Excel(name = "文件编任者") @Excel(name = "编任者") private String creator; /** $column.columnComment */ @Excel(name = "文件提名") @Excel(name = "文件题名") private String title; /** $column.columnComment */ @Excel(name = "日期") @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd") private Date date; /** $column.columnComment */ @@ -104,7 +115,7 @@ /** $column.columnComment */ @Excel(name = "大小") private Long fileSize; private Double fileSize; /** $column.columnComment */ @Excel(name = "附件及历史发文号") @@ -115,15 +126,30 @@ private String remarks; /** $column.columnComment */ @Excel(name = "${comment}") private Date createdAt; /** $column.columnComment */ @Excel(name = "${comment}") private Date updatedAt; private String fileStyle; public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } private String url; private Long recordId; public String getFileStyle() { return fileStyle; } public void setFileStyle(String fileStyle) { this.fileStyle = fileStyle; } public Long getRecordId() { return recordId; @@ -333,12 +359,12 @@ return height; } public void setFileSize(Long fileSize) public void setFileSize(Double fileSize) { this.fileSize = fileSize; } public Long getFileSize() public Double getFileSize() { return fileSize; } archiveManager/src/main/java/com/ruoyi/domain/vo/AnalysisResult.java
New file @@ -0,0 +1,15 @@ package com.ruoyi.domain.vo; import lombok.Data; @Data public class AnalysisResult { private String everyProjectName; private Long cnt ; private Long unfinished; private Long finished; } archiveManager/src/main/java/com/ruoyi/domain/vo/ArchiveInfoVo.java
New file @@ -0,0 +1,54 @@ package com.ruoyi.domain.vo; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import lombok.Data; import java.util.Date; @Data public class ArchiveInfoVo { /** 档案号 */ @Excel(name = "档案号") private String recordId; /** 档案管(室)号 */ @Excel(name = "档案管(室)号") private String archiveRoomNumber; /** 缩微号 */ @Excel(name = "缩微号") private String microfilmNumber; /** 发问号 */ @Excel(name = "发文号") private String inquiryNumber; /** 案卷题名 */ @Excel(name = "案卷题名") private String caseTitle; /** 编制日期 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "编制日期", width = 30, dateFormat = "yyyy-MM-dd") private Date preparationDate; /** 编制单位 */ @Excel(name = "编制单位") private String preparationUnit; /** 保管期限 */ @Excel(name = "保管期限") private String retentionPeriod; /** 密级 */ @Excel(name = "密级") private String securityClassification; } archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java
New file @@ -0,0 +1,28 @@ package com.ruoyi.domain.vo; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import lombok.Data; import java.util.Date; @Data public class DocumentMaterialsVo { @Excel(name = "编任者") private String creator; @Excel(name = "文件题名") private String title; @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd") private Date date; @Excel(name = "页号") private Long pageNumber; @Excel(name = "备注") private String remarks; } archiveManager/src/main/java/com/ruoyi/mapper/ArchivePlaceNameMapper.java
New file @@ -0,0 +1,20 @@ package com.ruoyi.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.domain.ArchivePlaceName; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** * 【请填写功能名称】Mapper接口 * * @author ruoyi * @date 2025-08-08 */ @Mapper public interface ArchivePlaceNameMapper extends BaseMapper<ArchivePlaceName> { } archiveManager/src/main/java/com/ruoyi/mapper/ArchiveProjectNameMapper.java
New file @@ -0,0 +1,9 @@ package com.ruoyi.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.domain.ArchiveProjectName; import org.apache.ibatis.annotations.Mapper; @Mapper public interface ArchiveProjectNameMapper extends BaseMapper<ArchiveProjectName> { } archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
@@ -3,10 +3,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.vo.AnalysisResult; import com.ruoyi.domain.vo.ArchiveInfoVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; @Mapper public interface ArchiveRecordsMapper extends BaseMapper<ArchiveRecords> { @@ -14,9 +19,9 @@ @Select({ "<script>", "SELECT c.*,a.archive_records_id,b.user_id 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 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 a.user_id desc", "order by tst desc", "</if>", "</script>" }) @@ -25,4 +30,14 @@ @Select("select max(id) from archive_records") Long findMaxId(); @Select("UPDATE `archivesys`.`archive_records` SET `inquiry_number` = '', `case_title` = NULL, `public_attribute` = NULL, `preparation_unit` = NULL, `preparation_date` = NULL, `retention_period` = NULL, `security_classification` = NULL, `page_count` = NULL, `filing_number` = NULL, `construction_unit` = NULL, `construction_address` = NULL, `project_name` = '', `project_number` = NULL, `scanning_company` = NULL, `archive_room_number` = NULL, `microfilm_number` = NULL, `remarks` = NULL, `historical_reference_number` = NULL, `record_status` = NULL, `every_project_name` = NULL WHERE `id` = #{id}") Long updateAllInfoById(@Param("id") Long id); @Select("select record_id,archive_room_number,microfilm_number,inquiry_number,case_title,preparation_date,preparation_unit,retention_period,security_classification from archive_records where id=#{id}") ArchiveInfoVo findByRecordId(@Param("id") Long id); @Select("SELECT every_project_name, count(*) as cnt, (select count(*) from archive_records as ac where ac.every_project_name=ar.every_project_name and record_status='未录入') as unfinished,\n" + "(select count(*) from archive_records as ac where ac.every_project_name=ar.every_project_name and record_status='录入完成') as finished \n" + " from archive_records as ar GROUP BY every_project_name") List<AnalysisResult> statisticAyasis(); } archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
@@ -2,8 +2,34 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.DocumentMaterialsVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; @Mapper public interface DocumentMaterialsMapper extends BaseMapper<DocumentMaterials> { @Select("update document_materials SET url = #{url},file_number=#{fileNumber},page_order=#{pageOrder},width=#{width},height=#{height},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("fileSize") Double fileSize,@Param("url") String url,@Param("format") String format); //根据题名拿到最大的pageOrder @Select("select count(*) from document_materials where title=#{title} and page_number<#{pageNumber} and stage=#{stage}") Long getMaxPageOrder(@Param("title")String title,@Param("pageNumber") Long pageNumber,@Param("stage") String stage); //计算文件的序号 @Select("select count(distinct(title))-1 from document_materials where page_number<=#{pageNumber}") Long getFileNumber(@Param("pageNumber") Long pageNumber); //查询卷内目录 @Select("select creator,title, date, page_number,remarks from document_materials\n" + "WHERE page_number IN (\n" + " SELECT MIN(page_number)\n" + " FROM document_materials where record_id=#{recordId}\n" + " GROUP BY stage, title\n" + ") order by page_number ;") List<DocumentMaterialsVo> getArchiveMatInfo(@Param("recordId") String recordId); } archiveManager/src/main/java/com/ruoyi/service/IArchivePlaceNameService.java
New file @@ -0,0 +1,69 @@ package com.ruoyi.service; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ArchiveCategory; import com.ruoyi.domain.ArchivePlaceName; import java.util.List; /** * 【请填写功能名称】Service接口 * * @author ruoyi * @date 2025-08-08 */ public interface IArchivePlaceNameService { AjaxResult selectDataList(ArchivePlaceName archivePlaceName, Integer pageNum, Integer pageSize); /** * 查询【请填写功能名称】 * * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ public ArchivePlaceName selectArchivePlaceNameById(Long id); /** * 查询【请填写功能名称】列表 * * @param archivePlaceName 【请填写功能名称】 * @return 【请填写功能名称】集合 */ public List<ArchivePlaceName> selectArchivePlaceNameList(ArchivePlaceName archivePlaceName); /** * 新增【请填写功能名称】 * * @param archivePlaceName 【请填写功能名称】 * @return 结果 */ public int insertArchivePlaceName(ArchivePlaceName archivePlaceName); /** * 修改【请填写功能名称】 * * @param archivePlaceName 【请填写功能名称】 * @return 结果 */ public int updateArchivePlaceName(ArchivePlaceName archivePlaceName); /** * 批量删除【请填写功能名称】 * * @param ids 需要删除的【请填写功能名称】主键集合 * @return 结果 */ public int deleteArchivePlaceNameByIds(Long[] ids); /** * 删除【请填写功能名称】信息 * * @param id 【请填写功能名称】主键 * @return 结果 */ public int deleteArchivePlaceNameById(Long id); } archiveManager/src/main/java/com/ruoyi/service/IArchiveProjectNameService.java
New file @@ -0,0 +1,60 @@ package com.ruoyi.service; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ArchivePlaceName; import com.ruoyi.domain.ArchiveProjectName; import java.util.List; public interface IArchiveProjectNameService { AjaxResult selectDataList(ArchiveProjectName archiveProjectName, Integer pageNum, Integer pageSize); /** * 查询【请填写功能名称】 * * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ public ArchiveProjectName selectArchiveProjectNameById(Long id); /** * 查询【请填写功能名称】列表 * * @param archiveProjectName 【请填写功能名称】 * @return 【请填写功能名称】集合 */ public List<ArchiveProjectName> selectArchiveProjectNameList(ArchiveProjectName archiveProjectName); /** * 新增【请填写功能名称】 * * @param archiveProjectName 【请填写功能名称】 * @return 结果 */ public int insertArchiveProjectName(ArchiveProjectName archiveProjectName); /** * 修改【请填写功能名称】 * * @param archiveProjectName 【请填写功能名称】 * @return 结果 */ public int updateArchiveProjectName(ArchiveProjectName archiveProjectName); /** * 批量删除【请填写功能名称】 * * @param ids 需要删除的【请填写功能名称】主键集合 * @return 结果 */ public int deleteArchiveProjectNameByIds(Long[] ids); /** * 删除【请填写功能名称】信息 * * @param id 【请填写功能名称】主键 * @return 结果 */ public int deleteArchiveProjectNameById(Long id); } archiveManager/src/main/java/com/ruoyi/service/IArchiveRecordsService.java
@@ -2,6 +2,11 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.vo.AnalysisResult; import com.ruoyi.domain.vo.ArchiveInfoVo; import org.apache.ibatis.annotations.Param; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -64,4 +69,17 @@ * @return 结果 */ public int deleteArchiveRecordsById(Long id); ArchiveInfoVo selectByRecordId(Long id); @Transactional public AjaxResult importExcel(MultipartFile file) ; List<AnalysisResult> statisticAya(); } archiveManager/src/main/java/com/ruoyi/service/IArchiverecordstouserService.java
@@ -25,6 +25,9 @@ */ public Archiverecordstouser selectArchiverecordstouserById(Long id); public boolean selectArchiveRecordUsers(String recordId); /** * 查询【请填写功能名称】列表 * archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java
@@ -3,6 +3,8 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.DocumentMaterialsVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -56,4 +58,7 @@ * @return 结果 */ public int deleteDocumentMaterialsByMaterialId(String materialId); public Long getFiNum(Long pageNumber); public int updateByPageNumber(Long pageNumber,Long fileNumber, int wid, int hei, double sz,String url,String format); public List<DocumentMaterialsVo> findArchMInfo(String recordId); } archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveCategoryServiceImpl.java
@@ -46,20 +46,7 @@ LambdaQueryWrapper<ArchiveCategory> lqw = new LambdaQueryWrapper<>(); lqw.like(!StringUtils.isEmpty(archiveRecords.getNumb()), ArchiveCategory::getNumb, archiveRecords.getNumb()) .like(!StringUtils.isEmpty(archiveRecords.getNname()), ArchiveCategory::getNname, archiveRecords.getNname()); // lqw.like(!StringUtils.isEmpty(archiveRecords.getProjectName()), ArchiveRecords::getProjectName, archiveRecords.getProjectName()) // .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber()) // .like(!StringUtils.isEmpty(archiveRecords.getArchiveRoomNumber()), ArchiveRecords::getArchiveRoomNumber, archiveRecords.getArchiveRoomNumber()) // .like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId()); // // .like(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation()) // .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) // .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress()) // .like(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark()) // .eq(zfProperty.getFamilyId()!=null,ZfProperty::getFamilyId,zfProperty.getFamilyId()) // .in(ZfProperty::getFamilyId,familyIdList) // .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); // lqw.orderByDesc(ArchiveRecords::isOwnData); lqw.orderByDesc(ArchiveCategory::getCtime); System.out.println("ssssssssssssddd0000000000000000"); return lqw; archiveManager/src/main/java/com/ruoyi/service/impl/ArchivePlaceNameServiceImpl.java
New file @@ -0,0 +1,157 @@ package com.ruoyi.service.impl; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.utils.MapUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.domain.ArchiveCategory; import com.ruoyi.domain.ArchivePlaceName; import com.ruoyi.service.IArchivePlaceNameService; import org.springframework.stereotype.Service; import com.ruoyi.mapper.ArchivePlaceNameMapper; @Service public class ArchivePlaceNameServiceImpl extends ServiceImpl<ArchivePlaceNameMapper, ArchivePlaceName> implements IArchivePlaceNameService { private LambdaQueryWrapper<ArchivePlaceName> buildCondition(ArchivePlaceName archivePlaceName){ LambdaQueryWrapper<ArchivePlaceName> lqw = new LambdaQueryWrapper<>(); lqw.like(!StringUtils.isEmpty(archivePlaceName.getName()), ArchivePlaceName::getName, archivePlaceName.getName()) .like(!StringUtils.isEmpty(archivePlaceName.getNnumber()), ArchivePlaceName::getNnumber, archivePlaceName.getNnumber()); lqw.orderByDesc(ArchivePlaceName::getCreateTime); System.out.println("ssssssssssssddd0000000000000000"); return lqw; } @Override public AjaxResult selectDataList(ArchivePlaceName archivePlaceName, Integer pageNum, Integer pageSize) { LambdaQueryWrapper<ArchivePlaceName> lqw = buildCondition(archivePlaceName); Page<ArchivePlaceName> zfClanPage = new Page<>(pageNum, pageSize); Page<ArchivePlaceName> pageResult = page(zfClanPage, lqw); List<ArchivePlaceName> beanRecords = pageResult.getRecords();//得到查询出来的数据 // List<ArchiveRecords> beanRecords = list(lqw); // log.info("从数据库中查到的为:{}", beanRecords); // return markOwnData(familyId, fatherFaId, motherFaId, beanRecords); HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); return AjaxResult.success(data); } /** * 查询【请填写功能名称】 * * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ @Override public ArchivePlaceName selectArchivePlaceNameById(Long id) { LambdaQueryWrapper<ArchivePlaceName> lqw = new LambdaQueryWrapper<>(); lqw.eq(id!=null, ArchivePlaceName::getId, id); List<ArchivePlaceName> records = list(lqw); if(!records.isEmpty()) return records.get(0); else return null; } /** * 查询【请填写功能名称】列表 * * @param archivePlaceName 【请填写功能名称】 * @return 【请填写功能名称】 */ @Override public List<ArchivePlaceName> selectArchivePlaceNameList(ArchivePlaceName archivePlaceName) { LambdaQueryWrapper<ArchivePlaceName> lambdaQueryWrapper = buildCondition(archivePlaceName); List<ArchivePlaceName> beanRecords = list(lambdaQueryWrapper); System.out.println(beanRecords.size()); return beanRecords; } /** * 新增【请填写功能名称】 * * @param archivePlaceName 【请填写功能名称】 * @return 结果 */ @Override public int insertArchivePlaceName(ArchivePlaceName archivePlaceName) { LocalDateTime time = LocalDateTime.now(); Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); archivePlaceName.setCreateTime(date); boolean res = this.save(archivePlaceName); if(res) return 1; else return 0; } /** * 修改【请填写功能名称】 * * @param archivePlaceName 【请填写功能名称】 * @return 结果 */ @Override public int updateArchivePlaceName(ArchivePlaceName archivePlaceName) { boolean result = updateById(archivePlaceName); if(result) return 1; else return 0; } /** * 批量删除【请填写功能名称】 * * @param ids 需要删除的【请填写功能名称】主键 * @return 结果 */ @Override public int deleteArchivePlaceNameByIds(Long[] ids) { if (this.removeByIds(Arrays.asList(ids))) { return 1; } else return 0; } /** * 删除【请填写功能名称】信息 * * @param id 【请填写功能名称】主键 * @return 结果 */ @Override public int deleteArchivePlaceNameById(Long id) { return 0; } } archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveProjectNameServiceImpl.java
New file @@ -0,0 +1,116 @@ package com.ruoyi.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.utils.MapUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.domain.ArchiveCategory; import com.ruoyi.domain.ArchivePlaceName; import com.ruoyi.domain.ArchiveProjectName; import com.ruoyi.mapper.ArchiveProjectNameMapper; import com.ruoyi.service.IArchiveProjectNameService; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; @Service public class ArchiveProjectNameServiceImpl extends ServiceImpl<ArchiveProjectNameMapper, ArchiveProjectName> implements IArchiveProjectNameService { private LambdaQueryWrapper<ArchiveProjectName> buildCondition(ArchiveProjectName archiveProjectName){ LambdaQueryWrapper<ArchiveProjectName> lqw = new LambdaQueryWrapper<>(); lqw.like(!StringUtils.isEmpty(archiveProjectName.getName()), ArchiveProjectName::getName, archiveProjectName.getName()); lqw.orderByDesc(ArchiveProjectName::getCreateTime); System.out.println("ssssssssssssddd0000000000000000"); return lqw; } @Override public AjaxResult selectDataList(ArchiveProjectName archiveProjectName, Integer pageNum, Integer pageSize) { LambdaQueryWrapper<ArchiveProjectName> lqw = buildCondition(archiveProjectName); Page<ArchiveProjectName> zfClanPage = new Page<>(pageNum, pageSize); Page<ArchiveProjectName> pageResult = page(zfClanPage, lqw); List<ArchiveProjectName> beanRecords = pageResult.getRecords();//得到查询出来的数据 // List<ArchiveRecords> beanRecords = list(lqw); // log.info("从数据库中查到的为:{}", beanRecords); // return markOwnData(familyId, fatherFaId, motherFaId, beanRecords); HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); return AjaxResult.success(data); } @Override public ArchiveProjectName selectArchiveProjectNameById(Long id) { LambdaQueryWrapper<ArchiveProjectName> lqw = new LambdaQueryWrapper<>(); System.out.println(id); lqw.eq(id!=null, ArchiveProjectName::getId, id); List<ArchiveProjectName> records = list(lqw); if(!records.isEmpty()) return records.get(0); else return null; } @Override public List<ArchiveProjectName> selectArchiveProjectNameList(ArchiveProjectName archiveProjectName) { LambdaQueryWrapper<ArchiveProjectName> lambdaQueryWrapper = buildCondition(archiveProjectName); List<ArchiveProjectName> beanRecords = list(lambdaQueryWrapper); System.out.println(beanRecords.size()); return beanRecords; } @Override public int insertArchiveProjectName(ArchiveProjectName archiveProjectName) { LocalDateTime time = LocalDateTime.now(); Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); archiveProjectName.setCreateTime(date); boolean res = this.save(archiveProjectName); if(res) return 1; else return 0; } @Override public int updateArchiveProjectName(ArchiveProjectName archiveProjectName) { boolean result = updateById(archiveProjectName); if(result) return 1; else return 0; } @Override public int deleteArchiveProjectNameByIds(Long[] ids) { if (this.removeByIds(Arrays.asList(ids))) { return 1; } else return 0; } @Override public int deleteArchiveProjectNameById(Long id) { return 0; } } archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
@@ -11,13 +11,17 @@ import com.ruoyi.common.utils.MapUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.vo.AnalysisResult; import com.ruoyi.domain.vo.ArchiveInfoVo; import com.ruoyi.mapper.ArchiveRecordsMapper; import com.ruoyi.mapper.ArchiverecordstouserMapper; import com.ruoyi.service.IArchiveRecordsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; /** * 档案记录Service业务层处理 @@ -166,6 +170,10 @@ Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); archiveRecords.setCreateTime(date); archiveRecords.setRecordStatus("未录入"); // archiveRecords boolean res = this.save(archiveRecords); if(res) return 1; @@ -198,11 +206,13 @@ @Override public int deleteArchiveRecordsByIds(Long[] ids) { if (this.removeByIds(Arrays.asList(ids))) { return 1; Long res = 0L; for(Long id: ids) { this.baseMapper.updateAllInfoById(id); } else return 0; return 1; } /** @@ -216,4 +226,58 @@ { return 0; } @Override public ArchiveInfoVo selectByRecordId(Long id) { return this.baseMapper.findByRecordId(id); } @Override public AjaxResult importExcel(MultipartFile file) { ExcelUtil<ArchiveRecords> util = new ExcelUtil<>(ArchiveRecords.class); List<ArchiveRecords> dataList = null; try { dataList = util.importExcel(file.getInputStream()); } catch (Exception e) { throw new RuntimeException("没有按照规则导入数据"); } assert dataList != null; for (ArchiveRecords archiveRecords : dataList) { // physcialService.mySave(physcial); this.mySave(archiveRecords); } return AjaxResult.success(); } @Override public List<AnalysisResult> statisticAya() { return this.baseMapper.statisticAyasis(); } public AjaxResult mySave(ArchiveRecords archiveRecords) { //检查是否有重复数据插入 LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>(); lqw.eq(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId,archiveRecords.getRecordId()); List<ArchiveRecords> list = list(lqw); if (list.size() > 0) { // throw new RuntimeException("请勿新增重复数据"); //如果有重复数据,则根据recordId进行数据修改 this.baseMapper.update(archiveRecords, lqw); return AjaxResult.success(); } else { if (save(archiveRecords)) { return AjaxResult.success(); } else { return AjaxResult.error(); } } } } archiveManager/src/main/java/com/ruoyi/service/impl/ArchiverecordstouserServiceImpl.java
@@ -68,6 +68,7 @@ ur.setArchiveRecordsId(recordId); ur.setUserId(userId); list.add(ur); break; } boolean res = this.saveBatch(list); if(res) @@ -117,6 +118,14 @@ } @Override public boolean selectArchiveRecordUsers(String recordId) { LambdaQueryWrapper<Archiverecordstouser> lqw = new LambdaQueryWrapper<>(); lqw.eq(!StringUtils.isEmpty(recordId),Archiverecordstouser::getArchiveRecordsId, recordId); List<Archiverecordstouser> lis = list(lqw); return !lis.isEmpty(); } @Override public List<Archiverecordstouser> selectArchiverecordstouserList(Archiverecordstouser archiverecordstouser) { return null; } archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
New file @@ -0,0 +1,33 @@ package com.ruoyi.service.impl; import org.krysalis.barcode4j.impl.code128.Code128Bean; import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider; import org.springframework.stereotype.Service; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; @Service public class BarcodeService { public byte[] generateBarcodeImage(String barcodeText) { try { Code128Bean barcodeGenerator = new Code128Bean(); final int dpi = 160; barcodeGenerator.setModuleWidth(0.21); barcodeGenerator.doQuietZone(false); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); BitmapCanvasProvider canvas = new BitmapCanvasProvider( outputStream, "image/png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0); barcodeGenerator.generateBarcode(canvas, barcodeText); canvas.finish(); return outputStream.toByteArray(); } catch (IOException e) { throw new RuntimeException("Error generating barcode", e); } } } archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
@@ -11,17 +11,17 @@ import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.DocumentMaterialsVo; 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; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.*; @Service public class DocumentMaterialsServiceImpl extends ServiceImpl<DocumentMaterialsMapper, DocumentMaterials> implements IDocumentMaterialsService { private LambdaQueryWrapper<DocumentMaterials> buildCondition(DocumentMaterials documentMaterials){ @@ -50,7 +50,8 @@ // .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime()); // lqw.orderByDesc(ZfProperty::getCreateTime); // lqw.orderByDesc(ArchiveRecords::isOwnData) lqw.orderByDesc(DocumentMaterials::getCreatedAt); lqw.orderByAsc(DocumentMaterials::getPageNumber); System.out.println("ssssssssssssddd0000000000000000"); return lqw; @@ -65,7 +66,7 @@ List<DocumentMaterials> beanRecords = pageResult.getRecords();//得到查询出来的数据 System.out.println(beanRecords); // beanRecords.forEach(record -> { // if (record.getUserId() != null) { // SysUser user = userMapper.selectUserById(record.getUserId()); @@ -99,7 +100,6 @@ public List<DocumentMaterials> selectDocumentMaterialsList(DocumentMaterials documentMaterials) { LambdaQueryWrapper<DocumentMaterials> lambdaQueryWrapper = buildCondition(documentMaterials); List<DocumentMaterials> beanRecords = list(lambdaQueryWrapper); return beanRecords; } @@ -109,7 +109,20 @@ Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); documentMaterials.setCreatedAt(date); boolean res = this.save(documentMaterials); System.out.println(documentMaterials.getFileStyle()); System.out.println(documentMaterials.getPageNumber()); // if(documentMaterials.getPageNumber()==null) // { // documentMaterials.setPageNumber(-1L); // } boolean res = false; try { res = this.save(documentMaterials); } catch (Exception e) { System.out.println(e); throw new ErrorcodeExceptionextends(500, "同一个案卷内,不允许页码重复!"); } if(res) return 1; else @@ -139,4 +152,35 @@ public int deleteDocumentMaterialsByMaterialId(String materialId) { return 0; } @Override public Long getFiNum(Long pageNumber) { return this.baseMapper.getFileNumber(pageNumber); } @Override public int updateByPageNumber(Long pageNumber, Long fileNumber, int width, int height, double fileSize, String url, String format) { //根据pageNumber拿到title,然后计算pageOrder LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>(); lqw.eq(pageNumber!=null, DocumentMaterials::getPageNumber, pageNumber); List<DocumentMaterials> records = list(lqw); Long pageOrder = 1L; if(pageNumber.equals(1)) pageOrder = 1L; else { Long maxPOrder = this.baseMapper.getMaxPageOrder(records.get(0).getTitle(), pageNumber, records.get(0).getStage()); if (maxPOrder != null) pageOrder = maxPOrder + 1; } this.baseMapper.updateInfoByPageNumber(pageNumber, fileNumber,pageOrder, width, height, fileSize, url,format); return 0; } @Override public List<DocumentMaterialsVo> findArchMInfo(String recordId) { return this.baseMapper.getArchiveMatInfo(recordId); } } archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
New file @@ -0,0 +1,164 @@ package com.ruoyi.service.impl; import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import com.itextpdf.text.*; import com.itextpdf.text.Font; import com.itextpdf.text.Image; import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.PdfPCell; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; @Service public class pdfGenerateService { @Autowired private BarcodeService barcodeService; //生产二维码 public byte[] createQrCodeN(String content, int width, int height) throws IOException { QrConfig config = new QrConfig(width, height); config.setMargin(3); // 高纠错级别 config.setErrorCorrection(ErrorCorrectionLevel.H); // 设置前景色,既二维码颜色(自行选择颜色修改) config.setForeColor(new Color(11, 11, 11).getRGB()); // 设置背景色(灰色)需要背景色时候打开链接 config.setBackColor(new Color(242,242,242).getRGB()); BufferedImage bufferedImage = QrCodeUtil.generate(// content, //二维码内容 config ); System.out.println(bufferedImage); System.out.println("---02340230949394"); ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(bufferedImage, "jpg", os); // ImageIO.write(bufferedImage, "jpg", new File("outputImage.jpg")); return os.toByteArray(); } public void generatePdf(String pdfPath) throws IOException, DocumentException { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(pdfPath)); document.open(); String [] tits = {"档 号:","档案馆(室)号:","缩 微 号: ","发 文 号:", "案 卷 题 名:","编 制 日 期:","编 制 单 位:","保 管 期 限:","密 级:"}; String [] cons = {"D3.4.1-05-2024-0002","","","穗规划资源建证〔2024〕2033号","广州市自来水有限公司白云区江高镇江高镇政府西侧、江府路北侧白云区江高镇江高镇政府西侧、江府路北侧新装供水管工程","2024-04-23","广州市规划和自然资源局白云区分局","永久",""}; //把图片加入到pdf当中 Image img = Image.getInstance(createQrCodeN(cons[0], 80, 80)); // 设置图片在PDF中的位置(可选) // img.setAbsolutePosition(100, 100); // 将图片添加到PDF文档中 PdfPCell pdfPCell = new PdfPCell(img); pdfPCell.setBorder(Rectangle.NO_BORDER); // 移除单元格边框 pdfPCell.setMinimumHeight(80); 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 table = new PdfPTable(columnWidths); // PdfPTable table = new PdfPTable(2); table.setWidthPercentage(80); // 增大表格宽度百分比 table.setHorizontalAlignment(Element.ALIGN_LEFT); // 设置表格整体居中 table.setSpacingBefore(30f); // 设置表格前间距 table.setSpacingAfter(90f); // 设置表格后间距 // PdfPTable table1 = new PdfPTable(1); // table1.setWidthPercentage(90); // 增大表格宽度百分比 // table1.setHorizontalAlignment(Element.ALIGN_LEFT); // 设置表格整体居中 // table1.setSpacingBefore(10f); // 设置表格前间距 // table1.setSpacingAfter(10f); // 设置表格后间距 table.addCell(pdfPCell); // document.add(table1); // 设置中文字体 BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); Font chineseFont = new Font(bfChinese, 16, Font.BOLD); Font chineseFont1 = new Font(bfChinese, 10, Font.BOLD); // 添加档号 // 添加带下划线的档号 for(int i = 0; i < tits.length; i++) { // 使用PdfPTable实现精确对齐 // 第一行:档号 PdfPCell labelCell1 = new PdfPCell(new Phrase(tits[i], chineseFont)); labelCell1.setHorizontalAlignment(Element.ALIGN_RIGHT); // 设置右对齐 labelCell1.setBorder(Rectangle.NO_BORDER); // PdfPCell valueCell1 = new PdfPCell(new Phrase(cons[i], chineseFont)); // valueCell1.setBorder(Rectangle.NO_BORDER); labelCell1.setMinimumHeight(30); labelCell1.setPaddingTop(10f); // 上内边距10单位 labelCell1.setPaddingBottom(10f); // 下内边距10单位 labelCell1.setPaddingLeft(15f); // 左内边距15单位 labelCell1.setPaddingRight(15f); // 右内边距15单位 PdfPCell valueCell1 = new PdfPCell(new Phrase(cons[i], chineseFont)); valueCell1.setBorder(Rectangle.NO_BORDER); valueCell1.setUseBorderPadding(true); valueCell1.setBorderWidthBottom(0.5f); // 设置底部边框作为下划线 valueCell1.setMinimumHeight(30); valueCell1.setPaddingTop(10f); // 上内边距10单位 valueCell1.setPaddingBottom(10f); // 下内边距10单位 valueCell1.setPaddingLeft(15f); // 左内边距15单位 valueCell1.setPaddingRight(15f); // 右内边距15单位 table.addCell(labelCell1); table.addCell(valueCell1); if(i==3) { //增加那个条形码 byte [] bas = barcodeService.generateBarcodeImage(cons[0]); Image img1= Image.getInstance(bas); PdfPCell pdfPCell1 = new PdfPCell(img1); pdfPCell1.setBorder(Rectangle.NO_BORDER); // 移除单元格边框 pdfPCell1.setMinimumHeight(40); pdfPCell1.setUseAscender(true); // 设置可以居中 pdfPCell1.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); // 设置水平居中 pdfPCell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); // 设置垂直居中 pdfPCell1.setColspan(2); pdfPCell1.setPaddingBottom(20); pdfPCell1.setPaddingTop(20); table.addCell(pdfPCell1); } } document.add(table); // 空行 // 关闭文档 document.close(); } } archiveManager/src/main/java/com/ruoyi/util/ErrorcodeExceptionextends.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.util; import lombok.Data; @Data public class ErrorcodeExceptionextends extends RuntimeException { private Integer code; private String message; public ErrorcodeExceptionextends(Integer code,String msg) { this.message = msg; this.code = code; } public ErrorcodeExceptionextends(String msg) { super(msg); this.message = msg; } } pom.xml
@@ -40,7 +40,12 @@ <!-- 依赖声明 --> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <scope>true</scope> </dependency> <!-- 覆盖SpringFramework的依赖配置--> <dependency> <groupId>org.springframework</groupId> ruoyi-admin/pom.xml
@@ -18,17 +18,41 @@ <dependencies> <!-- spring-boot-devtools --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- 表示依赖不会传递 --> </dependency> <!-- <dependency>--> <!-- <groupId>org.springframework.boot</groupId>--> <!-- <artifactId>spring-boot-devtools</artifactId>--> <!-- <optional>true</optional> <!– 表示依赖不会传递 –>--> <!-- </dependency>--> <!-- swagger3--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> </dependency> <!--导出pdf--> <!--excel转pdf--> <!-- For Maven --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13</version> </dependency> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>2.1.7</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency> <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 --> <dependency> ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchivePlaceNameController.java
New file @@ -0,0 +1,114 @@ package com.ruoyi.web.controller.archive; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.domain.ArchivePlaceName; import com.ruoyi.service.IArchivePlaceNameService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; /** * 【请填写功能名称】Controller * * @author ruoyi * @date 2025-08-08 */ @RestController @RequestMapping("/system/placeName") public class ArchivePlaceNameController extends BaseController { @Autowired private IArchivePlaceNameService archivePlaceNameService; /** * 查询【请填写功能名称】列表 */ @PreAuthorize("@ss.hasPermi('system:placeName:list')") @GetMapping("/list") public AjaxResult list(ArchivePlaceName archivePlaceName) { Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); return archivePlaceNameService.selectDataList(archivePlaceName, pageNum, pageSize); } /** * 导出【请填写功能名称】列表 */ @PreAuthorize("@ss.hasPermi('system:name:export')") @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ArchivePlaceName archivePlaceName) { List<ArchivePlaceName> list = archivePlaceNameService.selectArchivePlaceNameList(archivePlaceName); ExcelUtil<ArchivePlaceName> util = new ExcelUtil<ArchivePlaceName>(ArchivePlaceName.class); util.exportExcel(response, list, "【请填写功能名称】数据"); } /** * 获取【请填写功能名称】详细信息 */ @PreAuthorize("@ss.hasPermi('system:name:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(archivePlaceNameService.selectArchivePlaceNameById(id)); } /** * 新增【请填写功能名称】 */ @PreAuthorize("@ss.hasPermi('system:name:add')") @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ArchivePlaceName archivePlaceName) { return toAjax(archivePlaceNameService.insertArchivePlaceName(archivePlaceName)); } /** * 修改【请填写功能名称】 */ @PreAuthorize("@ss.hasPermi('system:name:edit')") @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ArchivePlaceName archivePlaceName) { return toAjax(archivePlaceNameService.updateArchivePlaceName(archivePlaceName)); } /** * 删除【请填写功能名称】 */ @PreAuthorize("@ss.hasPermi('system:name:remove')") @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(archivePlaceNameService.deleteArchivePlaceNameByIds(ids)); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveProjectNameController.java
New file @@ -0,0 +1,116 @@ package com.ruoyi.web.controller.archive; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.domain.ArchivePlaceName; import com.ruoyi.domain.ArchiveProjectName; import com.ruoyi.service.IArchiveProjectNameService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; /** * 【请填写功能名称】Controller * * @author ruoyi * @date 2025-08-08 */ @RestController @RequestMapping("/system/projectName") public class ArchiveProjectNameController extends BaseController { @Autowired private IArchiveProjectNameService archiveProjectNameService; /** * 查询【请填写功能名称】列表 */ @PreAuthorize("@ss.hasPermi('system:projectName:list')") @GetMapping("/list") public AjaxResult list(ArchiveProjectName archiveProjectName) { Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); return archiveProjectNameService.selectDataList(archiveProjectName, pageNum, pageSize); } /** * 导出【请填写功能名称】列表 */ @PreAuthorize("@ss.hasPermi('system:projectName:export')") @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ArchiveProjectName archiveProjectName) { List<ArchiveProjectName> list = archiveProjectNameService.selectArchiveProjectNameList(archiveProjectName); ExcelUtil<ArchiveProjectName> util = new ExcelUtil<ArchiveProjectName>(ArchiveProjectName.class); util.exportExcel(response, list, "【请填写功能名称】数据"); } /** * 获取【请填写功能名称】详细信息 */ @PreAuthorize("@ss.hasPermi('system:projectName:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(archiveProjectNameService.selectArchiveProjectNameById(id)); } /** * 新增【请填写功能名称】 */ @PreAuthorize("@ss.hasPermi('system:projectName:add')") @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ArchiveProjectName archiveProjectName) { System.out.println("------"); return toAjax(archiveProjectNameService.insertArchiveProjectName(archiveProjectName)); } /** * 修改【请填写功能名称】 */ @PreAuthorize("@ss.hasPermi('system:projectName:edit')") @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ArchiveProjectName archiveProjectName) { return toAjax(archiveProjectNameService.updateArchiveProjectName(archiveProjectName)); } /** * 删除【请填写功能名称】 */ @PreAuthorize("@ss.hasPermi('system:projectName:remove')") @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(archiveProjectNameService.deleteArchiveProjectNameByIds(ids)); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -3,20 +3,17 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.framework.config.ServerConfig; import com.ruoyi.service.IArchiveRecordsService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -24,6 +21,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; import org.springframework.web.multipart.MultipartFile; import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; @@ -40,6 +38,21 @@ { @Autowired private IArchiveRecordsService archiveRecordsService; /** * 查询档案完成情况 */ @PreAuthorize("@ss.hasPermi('system:records:list')") @GetMapping("/analysisRes") public AjaxResult analysis() { System.out.println("009099"); return new AjaxResult(200, "查询成功", archiveRecordsService.statisticAya()); } /** * 查询档案记录列表 @@ -123,4 +136,12 @@ { return toAjax(archiveRecordsService.deleteArchiveRecordsByIds(ids)); } @PreAuthorize("@ss.hasPermi('system:records:edit')") @Log(title = "档案记录导入", businessType = BusinessType.IMPORT) @PostMapping("/importData") public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception { return archiveRecordsService.importExcel(file); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiverecordstouserController.java
@@ -3,8 +3,11 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.service.IArchiverecordstouserService; import org.springframework.security.access.prepost.PreAuthorize; @@ -24,6 +27,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; import org.springframework.web.multipart.MultipartFile; import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; @@ -54,6 +58,9 @@ return toAjax(0); } } //判断是否授权给别人了 if(archiverecordstouserService.selectArchiveRecordUsers(recordId)) return toAjax(0); archiverecordstouserService.insertRecordToUsers(recordId, userIds); return toAjax(200); } @@ -142,4 +149,11 @@ { return toAjax(archiverecordstouserService.queryArchiverecordstouserByRecordId(recordId, userId)); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
@@ -2,12 +2,18 @@ import java.awt.image.BufferedImage; import java.util.List; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.framework.config.ServerConfig; import com.ruoyi.service.IDocumentMaterialsService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +32,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; import org.springframework.web.multipart.MultipartFile; import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; @@ -40,6 +47,9 @@ @RequestMapping("/system/materials") public class DocumentMaterialsController extends BaseController { @Autowired private ServerConfig serverConfig; @Autowired private IDocumentMaterialsService documentMaterialsService; @@ -87,7 +97,9 @@ @PostMapping public AjaxResult add(@RequestBody DocumentMaterials documentMaterials) { return toAjax(documentMaterialsService.insertDocumentMaterials(documentMaterials)); int res = documentMaterialsService.insertDocumentMaterials(documentMaterials); System.out.println(res+"][[[[[[[[[[[[[[[[[["); return toAjax(res); } /** @@ -113,4 +125,53 @@ { return toAjax(documentMaterialsService.deleteDocumentMaterialsByMaterialIds(materialIds)); } @PostMapping("/upload") public AjaxResult uploadFile(MultipartFile file) throws Exception { // System.out.println("sdfd9999999999999999999999999999999"); try { //根据文件名称,然后修改对应数据的url String fname = file.getOriginalFilename(); // System.out.println(fname); // 上传文件路径 String filePath = RuoYiConfig.getUploadPath(); // System.out.println(filePath); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); String url = serverConfig.getUrl() + fileName; AjaxResult ajax = AjaxResult.success(); //分割文件名 String [] nams = fname.split("\\."); Long nam = Long.parseLong(nams[0]); //文件名称 String pname = nams[1]; ajax.put("url", url); //拿到图像属性 BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); int wid = bufferedImage.getWidth(); int hei = bufferedImage.getHeight(); double sz = Double.parseDouble(String.format("%.2f", file.getSize()*1.0/1024)); System.out.println(wid+":"+hei+":"+sz); //计算fileNumber Long fileNumber = documentMaterialsService.getFiNum(nam); //插入数据库对应的url当中 documentMaterialsService.updateByPageNumber(nam, fileNumber,wid, hei, sz, fileName, pname); // System.out.println(url); // System.out.println(fileName); ajax.put("fileName", fileName); // System.out.println(FileUtils.getName(fileName)); ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("originalFilename", file.getOriginalFilename()); return ajax; } catch (Exception e) { System.out.println(e); return AjaxResult.error(e.getMessage()); } } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
New file @@ -0,0 +1,511 @@ package com.ruoyi.web.controller.archive; import com.itextpdf.text.*; import com.itextpdf.text.Font; import com.itextpdf.text.pdf.BaseFont; 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.common.utils.file.FileUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.domain.vo.ArchiveInfoVo; import com.ruoyi.domain.vo.DocumentMaterialsVo; import com.ruoyi.framework.web.domain.server.Sys; import com.ruoyi.service.IArchiveRecordsService; import com.ruoyi.service.IDocumentMaterialsService; import com.ruoyi.service.impl.BarcodeService; import com.ruoyi.service.impl.pdfGenerateService; import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellUtil; import org.apache.poi.xssf.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.lang.reflect.Field; import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; import java.text.SimpleDateFormat; import java.util.*; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; import static org.apache.poi.hssf.usermodel.HSSFCell.*; @RestController @RequestMapping("/system/archiveAllExport") public class archiveAllExportController { @Autowired private pdfGenerateService pdfGenerateService; @Autowired private BarcodeService barcodeService; @Autowired private IDocumentMaterialsService documentMaterialsService; @Autowired private IArchiveRecordsService iArchiveRecordsService; /** * 打包下载 * @param response * @param */ @PostMapping("/export") public void packDownload(HttpServletResponse response, Long id) throws Exception { // 获取文件的保存位置,读取数据库, DocumentMaterials documentMaterials = new DocumentMaterials(); documentMaterials.setRecordId(id); List<DocumentMaterials> docs = documentMaterialsService.selectDocumentMaterialsList(documentMaterials); List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString()); ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); List<String> paths = new ArrayList<>(); // System.out.println(docs); if (docs.size() == 1) { // 直接下载 String filePath = paths.get(0); filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); File file = new File(filePath); if (!file.exists()) { throw new Exception("文件不存在"); } String suffix = filePath.substring(filePath.lastIndexOf(".")); // 输出文件流 writeFileToRes(response, "user" + "-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + suffix, file); } else { // 压缩之后在进行下载 //压缩包名称(会拼上当前时间) System.out.println(90); String datumName = "user"; //压缩文件 List<String> filePathList = paths; File file = compressedFileToZip(docs, dsvs, aIV); System.out.println(file.getName()); //输出文件流 writeFileToRes(response, file.getName(), file); //删除压缩包 if(file.exists()){ file.delete(); } } } // 输出文件流到response private void writeFileToRes(HttpServletResponse response, String fileName, File file) throws IOException { String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); String filePath = RuoYiConfig.getDownloadPath() + fileName; 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){ /** * 0 指前面补充零 * formatLength 字符总长度为 formatLength * inputNumber 格式化数字 * d 代表为正数。 */ String newString = String.format("%0"+formatLength+"d", formatNumber); 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); // 添加图片到PDF 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; } private PdfPCell ImageSet(int high) throws Exception { // byte[] fileByte = toByteArray("D:\\project\\archive\\download\\12.jpg"); // // // FileInputStream fis = new FileInputStream("D:\\project\\archive\\download\\56.png"); // byte[] imageBytes = new byte[fis.available()]; // fis.read(imageBytes); // fis.close(); // Jpeg jpeg = new Jpeg(imageBytes); // jpeg.scaleAbsolute(70, 50); byte[] imageBytes = barcodeService.generateBarcodeImage("D3.4.1-05-2024-0002"); // 加载PNG图片 Image img = Image.getInstance(imageBytes); // 设置图片在PDF中的位置(可选) img.setAbsolutePosition(100, 700); // 将图片添加到PDF文档中 PdfPCell pdfPCell = new PdfPCell(img); pdfPCell.setMinimumHeight(high); pdfPCell.setUseAscender(true); // 设置可以居中 pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // 设置水平居中 pdfPCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); // 设置垂直居中 return pdfPCell; } // 压缩文件 private File compressedFileToZip(List<DocumentMaterials> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV) throws Exception { //压缩包具体名称(拼接时间戳防止重名) String datumName = ""; String zipFileName = datumName + "-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip"; //生成压缩包存储地址(最后会删掉) String fileZip = RuoYiConfig.getProfile() + "/download/" + zipFileName; OutputStream os=null; ZipOutputStream zos = null ; System.out.println("==============_______________"); File file = new File(fileZip); try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } os=new FileOutputStream(file); //压缩文件 zos = new ZipOutputStream(os); //pdf目录封面 String pdfPathF = "07-卷面封面.pdf"; pdfGenerateService.generatePdf(pdfPathF); // 2. 压缩PDF到ZIP文件 // 添加PDF文件到ZIP ZipEntry zipEntry = new ZipEntry(pdfPathF); zos.putNextEntry(zipEntry); // 读取PDF文件内容并写入ZIP try (FileInputStream fis = new FileInputStream(pdfPathF)) { byte[] buffer = new byte[1024]; int len; while ((len = fis.read(buffer)) > 0) { zos.write(buffer, 0, len); } } //excel 卷内封面导出zip ZipEntry entryiv = new ZipEntry("卷内封面" + ".xls"); ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class); zos.putNextEntry(entryiv); ByteOutputStream boss = new ByteOutputStream(); List<ArchiveInfoVo> aivs = new ArrayList<>(); aivs.add(aIV); utilsv.byteOutputStreamExcel(boss, aivs,"Date List", ""); boss.writeTo(zos); //写入电子目录 xsxl ZipEntry entry = new ZipEntry("电子文件目录" + ".xls"); ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class); zos.putNextEntry(entry); ByteOutputStream bos = new ByteOutputStream(); util.byteOutputStreamExcel(bos, docs,"Date List", ""); bos.writeTo(zos); //拿到卷内目录的excel ZipEntry entr = new ZipEntry("卷内目录" + ".xls"); ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class); System.out.println(dsvs); zos.putNextEntry(entr); ByteOutputStream bos1 = new ByteOutputStream(); util1.byteOutputStreamExcel(bos1, dsvs,"Date List", ""); bos1.writeTo(zos); //把excel转为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); } } } // 添加表格到PDF文档 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) { String filePath = dc.getUrl(); filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); System.out.println(filePath); File tempFile = new File(filePath); //在压缩包中添加文件夹 if(res) { zos.putNextEntry(new ZipEntry("01-申请材料/")); zos.putNextEntry(new ZipEntry("02-办案过程材料/")); zos.putNextEntry(new ZipEntry("03-结论性文件/")); zos.putNextEntry(new ZipEntry("04-其他材料/")); zos.putNextEntry(new ZipEntry("05-档案变更材料/")); zos.putNextEntry(new ZipEntry("06-业务数据/")); res = false; } //得到文件名frontCompWithZore(4, dc.get)+ String fname = frontCompWithZore(4, dc.getFileNumber().intValue())+"-"+dc.getTitle()+"-"+frontCompWithZore(4,dc.getPageNumber().intValue())+"." +dc.getUrl().split("\\.")[1]; if(dc.getStage().equals("01-申请材料")) zos.putNextEntry(new ZipEntry("01-申请材料/"+fname)); else if(dc.getStage().equals("02-办案过程材料")) zos.putNextEntry(new ZipEntry("02-办案过程材料/"+fname)); else if(dc.getStage().equals("03-结论性文件")) zos.putNextEntry(new ZipEntry("03-结论性文件/"+fname)); else if(dc.getStage().equals("04-其他材料")) { zos.putNextEntry(new ZipEntry("04-其他材料/" + fname)); } else if(dc.getStage().equals("05-档案变更材料")) zos.putNextEntry(new ZipEntry("05-档案变更材料/"+fname)); else if(dc.getStage().equals("06-业务数据")) zos.putNextEntry(new ZipEntry("06-业务数据/"+fname)); else zos.putNextEntry(new ZipEntry(fname)); int len; FileInputStream in = new FileInputStream(tempFile); while ((len = in.read(buf)) != -1){ zos.write(buf, 0, len); } // zos.putNextEntry(new ZipEntry("04-其他材料")); zos.closeEntry(); in.close(); } } catch (Exception e) { e.printStackTrace(); System.out.println(e.toString()); throw new Exception("文件打包:"+e.getMessage()); }finally { //关闭流 if(zos != null){ try { zos.close(); } catch (IOException e) { e.printStackTrace(); } } //关闭流 if(os!= null){ try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } return file; } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -4,6 +4,8 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ruoyi.framework.web.domain.server.Sys; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +31,7 @@ @RequestMapping("/common") public class CommonController { private static final Logger log = LoggerFactory.getLogger(CommonController.class); @Autowired @@ -74,6 +77,7 @@ @PostMapping("/upload") public AjaxResult uploadFile(MultipartFile file) throws Exception { // System.out.println("sdfd9999999999999999999999999999999"); try { // 上传文件路径 @@ -100,18 +104,23 @@ @PostMapping("/uploads") public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception { System.out.println("2334994343"); try { // 上传文件路径 String filePath = RuoYiConfig.getUploadPath(); System.out.println(filePath); List<String> urls = new ArrayList<String>(); List<String> fileNames = new ArrayList<String>(); List<String> newFileNames = new ArrayList<String>(); List<String> originalFilenames = new ArrayList<String>(); for (MultipartFile file : files) { // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); System.out.println(fileName); String url = serverConfig.getUrl() + fileName; urls.add(url); fileNames.add(fileName); @@ -127,6 +136,7 @@ } catch (Exception e) { System.out.println(e); return AjaxResult.error(e.getMessage()); } } ruoyi-admin/src/main/resources/application-druid.yml
@@ -1,5 +1,9 @@ # 数据源配置 spring: devtools: restart: enabled: true #设置开启热部署 additional-paths: src/main/java #重启目录 datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver ruoyi-admin/src/main/resources/application.yml
@@ -7,7 +7,7 @@ # 版权年份 copyrightYear: 2025 # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) profile: D:/ruoyi/uploadPath profile: D:/project/archive # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数字计算 char 字符验证 ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
@@ -24,6 +24,8 @@ import java.util.UUID; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -205,6 +207,25 @@ { this.clazz = clazz; } public void byteOutputStreamExcel(ByteOutputStream byteOutputStream, List<T> list, String sheetName, String title) { this.init(list, sheetName, title,Type.EXPORT); try { writeSheet(); wb.write(byteOutputStream); } catch (Exception e) { log.error("导出Excel异常{}", e.getMessage()); } finally { IOUtils.closeQuietly(wb); } } /** * 仅在Excel中显示列属性