| | |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.aspose.words.License; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.drew.imaging.ImageMetadataReader; |
| | | import com.drew.metadata.Metadata; |
| | | import com.drew.metadata.exif.ExifIFD0Directory; |
| | |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelExp; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheet; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond; |
| | | import com.ruoyi.domain.ArchiveCategory; |
| | | import com.ruoyi.domain.ArchiveRecords; |
| | | import com.ruoyi.domain.DocumentMaterials; |
| | | import com.ruoyi.domain.vo.DocumentMaterialFileSmallVo; |
| | | import com.ruoyi.domain.vo.*; |
| | | import com.ruoyi.framework.config.ServerConfig; |
| | | 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 com.sun.xml.internal.ws.api.addressing.WSEndpointReference; |
| | | import org.apache.commons.imaging.ImageInfo; |
| | | import org.apache.commons.imaging.Imaging; |
| | | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
| | | import org.springframework.core.io.support.ResourcePatternResolver; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | public class DocumentMaterialsController extends BaseController |
| | | { |
| | | @Autowired |
| | | private BarcodeService barcodeService; |
| | | @Autowired |
| | | private ServerConfig serverConfig; |
| | | |
| | | @Autowired |
| | | private pdfGenerateService pdfGenerateService; |
| | | @Autowired |
| | | private IDocumentMaterialsService documentMaterialsService; |
| | | |
| | | |
| | | @Autowired |
| | | private IArchiveRecordsService iArchiveRecordsService; |
| | | /** |
| | | * 判断PageNumber是否连续 |
| | | */ |
| | |
| | | { |
| | | |
| | | int cnt = documentMaterialsService.getFileCount(recordId); |
| | | return AjaxResult.success(cnt); |
| | | } |
| | | |
| | | /** |
| | | * 判断卷内目录是否上传了附件 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:materials:list')") |
| | | @GetMapping("/judge/{recordId}") |
| | | public AjaxResult judge(@PathVariable("recordId") Integer recordId) |
| | | { |
| | | |
| | | Boolean cnt = documentMaterialsService.judgeInfo(recordId); |
| | | return AjaxResult.success(cnt); |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class); |
| | | util.exportExcel(response, list, "【文件材料综合信息】数据"); |
| | | util.exportExcel(response, list, "电子文件目录"); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:materials:export')") |
| | | @Log(title = "【导出卷内目录】", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportDir") |
| | | public void exportDir(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids) |
| | | { |
| | | List<DocumentMaterials> list; |
| | | System.out.println(ids); |
| | | // 如果提供了ids参数,则根据ids导出指定记录 |
| | | if (ids != null && ids.length > 0) { |
| | | list = documentMaterialsService.selectDocumentMaterialsByIds(ids); |
| | | } else { |
| | | list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials); |
| | | |
| | | } |
| | | // 根据visible字段筛选,只保留visible为1的记录 |
| | | List<DocumentMaterials> filteredList = list.stream() |
| | | .filter(doc -> doc.getVisible() != null && doc.getVisible() == 1 && !Objects.equals(doc.getFileStyle(), "其他材料")) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 使用AtomicLong实现序号的递增 |
| | | AtomicLong nm = new AtomicLong(1L); |
| | | // 将筛选后的DocumentMaterials转换为DocumentMaterialsVo |
| | | List<DocumentMaterialsVoSmall> list1 = filteredList.stream().map(doc -> { |
| | | DocumentMaterialsVoSmall vo = new DocumentMaterialsVoSmall(); |
| | | // 手动映射字段,使用getAndIncrement()方法获取当前值并递增 |
| | | vo.setNum(nm.getAndIncrement()); |
| | | |
| | | vo.setDocumentNumber(doc.getDocumentNumber()); |
| | | vo.setCreator(doc.getCreator()); |
| | | vo.setTitle(doc.getTitle()); |
| | | vo.setDate(doc.getDate()); |
| | | vo.setPageNumber(doc.getPageNumber()); |
| | | vo.setRemarks(doc.getRemarks()); |
| | | // vo.setRecordId(doc.getRecordId() != null ? doc.getRecordId().toString() : null); |
| | | // vo.setPublicity(doc.getPublicity()); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | ExcelUtil<DocumentMaterialsVoSmall> util = new ExcelUtil<DocumentMaterialsVoSmall>(DocumentMaterialsVoSmall.class); |
| | | util.exportExcel(response, list1, "卷内目录"); |
| | | } |
| | | |
| | | // List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString()); |
| | | |
| | | /** |
| | | * 获取【文件材料综合信息】详细信息 |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody DocumentMaterials documentMaterials) |
| | | { |
| | | documentMaterials.setVisible(1); |
| | | int res = documentMaterialsService.insertDocumentMaterials(documentMaterials); |
| | | System.out.println(res+"][[[[[[[[[[[[[[[[[["); |
| | | return toAjax(res); |
| | |
| | | ExcelUtil<DocumentMaterialFileSmallVo> util = new ExcelUtil<>(DocumentMaterialFileSmallVo.class); |
| | | util.exportExcel(response,list,"档案详细信息导入模板"); |
| | | } |
| | | public boolean getLicense() { |
| | | boolean result = false; |
| | | try { |
| | | InputStream is = null; |
| | | |
| | | //导出material |
| | | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
| | | org.springframework.core.io.Resource[] resources = resolver.getResources("classpath:words.xml"); |
| | | is = resources[0].getInputStream(); |
| | | // ��Ŀ��lincense.xml��·�� |
| | | License aposeLic = new License(); |
| | | aposeLic.setLicense(is); |
| | | result = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | //导出备考表 |
| | | @PostMapping("/exportBack/{id}/{recordId}") |
| | | public void exportBackInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId) |
| | | { |
| | | //09-备考表.pdf |
| | | String pdf09Path = "09-备考表.pdf"; |
| | | // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id); |
| | | //拿到相关数据 |
| | | List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | |
| | | LocalDate currentDate = LocalDate.now(); |
| | | |
| | | |
| | | String cdt = currentDate.getYear()+"年"+currentDate.getMonthValue()+"月"+currentDate.getDayOfMonth()+"日"; |
| | | |
| | | HashMap<String, Object> hs = new HashMap<String, Object>(); |
| | | int allPages = 0; |
| | | int texPages = 0; |
| | | int picPages = 0; |
| | | int patPages = 0; |
| | | if(!dmfs.isEmpty()) |
| | | { |
| | | for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs) |
| | | { |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料")) |
| | | texPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料")) |
| | | patPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料")) |
| | | picPages = documentMaterialFileStyle.getCnt(); |
| | | } |
| | | } |
| | | allPages = texPages + picPages + patPages; |
| | | hs.put("pages", allPages); |
| | | hs.put("patPages", patPages); |
| | | hs.put("picPages", picPages); |
| | | hs.put("texPages", texPages); |
| | | hs.put("volumeNumber", recordId); |
| | | hs.put("time", cdt); |
| | | |
| | | if (!getLicense()) { |
| | | System.out.println("没有相关证书!"); |
| | | } |
| | | |
| | | |
| | | try { |
| | | |
| | | // 获取 Word 模板所在路径 |
| | | String filepath = "09-备考表.docx"; |
| | | // 通过 XWPFTemplate 编译文件并渲染数据到模板中 |
| | | XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs |
| | | ); |
| | | |
| | | String renderedDocPath = "rendered_output.docx"; |
| | | File renderedFile = new File(renderedDocPath); |
| | | try { |
| | | // 将完成数据渲染的文档写出 |
| | | template.writeAndClose(new FileOutputStream(renderedFile)); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | com.aspose.words.Document doc = new com.aspose.words.Document("rendered_output.docx"); |
| | | // 创建临时字节输出流 |
| | | ByteArrayOutputStream baobk = new ByteArrayOutputStream(); |
| | | // 将Word文档转换为PDF字节数组 |
| | | doc.save(response.getOutputStream(), com.aspose.words.SaveFormat.PDF);//ȫ��֧��DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF �ת�� |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | //导出卷内目录 |
| | | @PostMapping("/exportJuan/{id}") |
| | | |
| | | public void exportJuanInfo(HttpServletResponse response, @PathVariable Long id) throws IOException { |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString()); |
| | | |
| | | //拿到卷内目录的excel |
| | | List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(), |
| | | res1.getTitle(), res1.getDate(), res1.getPageNumber(), res1.getRemarks())).collect(Collectors.toList()); |
| | | if(!dsvs.isEmpty()) { |
| | | String recordId = dsvs.get(0).getRecordId(); |
| | | byte[] imgr = barcodeService.generateBarcodeImage(recordId); |
| | | ExcelExp e1 = new ExcelExp("卷内目录数据", dsvs, DocumentMaterialsVo.class); |
| | | ExcelExp e2 = new ExcelExp("卷内数据", list2, recordId, imgr, DocumentMaterialsVoSmall.class); |
| | | List<ExcelExp> mysheet = new ArrayList<ExcelExp>(); |
| | | mysheet.add(e1); |
| | | mysheet.add(e2); |
| | | ExcelUtilManySheet<List<ExcelExp>> util2 = new ExcelUtilManySheet<List<ExcelExp>>(mysheet); |
| | | // ZipEntry entr = new ZipEntry(fna + adir + "/" + "卷内目录" + ".xls"); |
| | | // ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class); |
| | | // System.out.println(dsvs); |
| | | // zos.putNextEntry(entr); |
| | | ByteOutputStream bos8 = new ByteOutputStream(); |
| | | |
| | | util2.exportExcelManySheet(bos8, mysheet); |
| | | |
| | | bos8.writeTo( response.getOutputStream()); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | //导出案卷封面 |
| | | @PostMapping("/exportPageInfo/{id}/{recordId}") |
| | | public void exportPageInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId) throws IOException { |
| | | |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); |
| | | |
| | | List<ArchiveInfoVo> arsi = new ArrayList<>(); |
| | | arsi.add(aIV); |
| | | |
| | | String recordId1 = recordId; |
| | | byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 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>(); |
| | | mysheet1.add(e3); |
| | | mysheet1.add(e4); |
| | | ByteOutputStream bos2 = new ByteOutputStream(); |
| | | ExcelUtilManySheetSecond<List<ExcelExp>> util3 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet1); |
| | | |
| | | util3.exportExcelManySheet(bos2, mysheet1); |
| | | |
| | | // System.out.println(bos2); |
| | | bos2.writeTo(response.getOutputStream()); |
| | | |
| | | } |
| | | |
| | | |
| | | } |