|  | @@ -653,7 +653,115 @@ public class LocalSysFileServiceImpl implements ISysFileService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public void cutFileCompress(CoreRegisterBookPdfExportDto exportDto) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    public void cutFileCompress(CoreRegisterBookPdfExportDto pdfDto) {
 | 
	
		
			
				|  |  | +        // String orgName = objectMapper.selectOrgNameById(pdfDto.getOrgId());
 | 
	
		
			
				|  |  | +       /* Date date = new Date();
 | 
	
		
			
				|  |  | +        Sy org = objectMapper.selectOrg(pdfDto.getOrgId());
 | 
	
		
			
				|  |  | +        String fileName = pdfDto.getIsRegisterBookPage() ? org.getName() + "_登记簿_" : org.getName() + "_数据报表_";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //判断需要分几片导出
 | 
	
		
			
				|  |  | +        List<List<CoreRegisterBookPdfPageVo>> lists = checkSubList(pdfDto);
 | 
	
		
			
				|  |  | +        int num = 1;
 | 
	
		
			
				|  |  | +        for (List<CoreRegisterBookPdfPageVo> list : lists) {
 | 
	
		
			
				|  |  | +            CountDownLatch count = new CountDownLatch(list.size());
 | 
	
		
			
				|  |  | +            String zipName = null;
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                String str = lists.size() == 1 ? "" : "_part_" + num;
 | 
	
		
			
				|  |  | +                String fileNameStr = fileName + DateHelper.getDateString(new Date()) + str;
 | 
	
		
			
				|  |  | +                zipName = URLEncoder.encode(fileNameStr + ".zip", "UTF-8");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                List<PdfToZipTempVo> pdfToZipTempVoList = list.parallelStream().map(pdf -> {
 | 
	
		
			
				|  |  | +                            return resolve(pdf, null, count);
 | 
	
		
			
				|  |  | +                        }).filter(Objects::nonNull)
 | 
	
		
			
				|  |  | +                        .collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                pdfToZipTempVoList.removeIf(pdfToZipTempVo -> !FileUtil.exist(pdfToZipTempVo.getFile()));
 | 
	
		
			
				|  |  | +                log.info("登记簿全部下载完成,开始压缩文件,数量:{}", pdfToZipTempVoList.size());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                String localFileName = URLEncoder.encode(RedisConstantKey.REGISTER_PDF_FILE_KEY + DateHelper.getDateString(date) + str + ZipUtil.ZIP_EXT, "UTF-8");
 | 
	
		
			
				|  |  | +                FileOutputStream fos = new FileOutputStream(localFileName);
 | 
	
		
			
				|  |  | +                ZipOutputStream zos = new ZipOutputStream(fos);
 | 
	
		
			
				|  |  | +                long fileSize = 0L;
 | 
	
		
			
				|  |  | +                for (PdfToZipTempVo tempVo : pdfToZipTempVoList) {
 | 
	
		
			
				|  |  | +                    fileSize += tempVo.getFile().length();
 | 
	
		
			
				|  |  | +                    logger.info("当前开始处理第{}个文件 ", pdfToZipTempVoList.indexOf(tempVo) + 1);
 | 
	
		
			
				|  |  | +                    deal(zos, null, tempVo);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                zos.flush();
 | 
	
		
			
				|  |  | +                fos.flush();
 | 
	
		
			
				|  |  | +                zos.close();
 | 
	
		
			
				|  |  | +                fos.close();
 | 
	
		
			
				|  |  | +                num++;
 | 
	
		
			
				|  |  | +                PdfLocalFileTempVo pdfLocalFileTempVo = new PdfLocalFileTempVo();
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setOrgId(pdfDto.getOrgId());
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setOrgName(org.getName());
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setOrgPath(org.getPath());
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setLocalFileName(localFileName);
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setZipName(URLDecoder.decode(zipName, "UTF-8"));
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setFileSize(changeUnit(fileSize));
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setDownLoadTime(DateUtil.format(date, "yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setIsRegisterBookPage(pdfDto.getIsRegisterBookPage());
 | 
	
		
			
				|  |  | +                pdfLocalFileTempVo.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +                redisTemplate.opsForValue().set(URLDecoder.decode(localFileName, "UTF-8"), JSON.toJSONString(pdfLocalFileTempVo));
 | 
	
		
			
				|  |  | +                DateTime dateTime = DateUtil.offsetHour(new Date(), 1);
 | 
	
		
			
				|  |  | +                delayTaskService.add("ExportLocalFileBusiness", dateTime, URLDecoder.decode(localFileName, "UTF-8"), 5, 2);
 | 
	
		
			
				|  |  | +            } catch (Throwable e) {
 | 
	
		
			
				|  |  | +                throw new RuntimeException(e);
 | 
	
		
			
				|  |  | +            } finally {
 | 
	
		
			
				|  |  | +                File file = new File(TEMP_DIR_NAME);
 | 
	
		
			
				|  |  | +                if (file.exists()) {
 | 
	
		
			
				|  |  | +                    FileUtil.del(file);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +*/
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +   /* private List<List<CoreRegisterBookPdfPageVo>> checkSubList(CoreRegisterBookPdfExportDto pdfDto) {
 | 
	
		
			
				|  |  | +        List<List<CoreRegisterBookPdfPageVo>> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Long orgId = pdfDto.getOrgId();
 | 
	
		
			
				|  |  | +        List<CoreRegisterBookPdfPageVo> registerBookPdfList = pdfDto.getDataList();
 | 
	
		
			
				|  |  | +        if (registerBookPdfList == null || registerBookPdfList.size() == 0) {
 | 
	
		
			
				|  |  | +            throw new RuntimeException("暂无可下载数据!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //小于3000条直接导出
 | 
	
		
			
				|  |  | +        if (registerBookPdfList.size() < 3000) {
 | 
	
		
			
				|  |  | +            list.add(registerBookPdfList);
 | 
	
		
			
				|  |  | +            return list;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<SysOrgVO> orgList = objectMapper.selectChildOrgList(orgId);
 | 
	
		
			
				|  |  | +        //大于3000条需要分片
 | 
	
		
			
				|  |  | +        return splitList(registerBookPdfList, orgList, 3000);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public static List<List<CoreRegisterBookPdfPageVo>> splitList(List<CoreRegisterBookPdfPageVo> list, List<SysOrgVO> orgList, int size) {
 | 
	
		
			
				|  |  | +        // 根据机构分组
 | 
	
		
			
				|  |  | +        List<List<CoreRegisterBookPdfPageVo>> collect = orgList.stream().map(org -> {
 | 
	
		
			
				|  |  | +            List<CoreRegisterBookPdfPageVo> arrayList = new ArrayList<>();
 | 
	
		
			
				|  |  | +            for (CoreRegisterBookPdfPageVo pdf : list) {
 | 
	
		
			
				|  |  | +                if (pdf.getOrgPath().startsWith(org.getPath())) {
 | 
	
		
			
				|  |  | +                    arrayList.add(pdf);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return arrayList;
 | 
	
		
			
				|  |  | +        }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 合并不满3000的数组
 | 
	
		
			
				|  |  | +        List<List<CoreRegisterBookPdfPageVo>> merged = new LinkedList<>();
 | 
	
		
			
				|  |  | +        List<CoreRegisterBookPdfPageVo> current = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (List<CoreRegisterBookPdfPageVo> group : collect) {
 | 
	
		
			
				|  |  | +            if (group.size() >= 3000) {
 | 
	
		
			
				|  |  | +                merged.add(group);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                current.addAll(group);
 | 
	
		
			
				|  |  | +                if (current.size() >= 3000) {
 | 
	
		
			
				|  |  | +                    merged.add(current);
 | 
	
		
			
				|  |  | +                    current = new ArrayList<>();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (!current.isEmpty()) {
 | 
	
		
			
				|  |  | +            merged.add(current);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return merged;
 | 
	
		
			
				|  |  | +        //return merged.stream().limit(size).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +    }*/
 | 
	
		
			
				|  |  |  }
 |