| | |
| | | |
| | | @Autowired |
| | | private IDocRelativeService docRelativeService; |
| | | @Autowired |
| | | private DataPackageService dataPackageService; |
| | | |
| | | public String exportData(TransferPackage.DataType type, String id,String fileName) { |
| | | // 1. 获取封装数据 |
| | | TransferPackage transferPackage = dataPackageService.packageData(type, id); |
| | | |
| | | // 2. 压缩层级结构 |
| | | compressHierarchy(transferPackage); |
| | | |
| | | // 3. JSON序列化 |
| | | String json = JsonUtils.toJson(transferPackage); |
| | | |
| | | // // 4. 压缩加密 |
| | | // byte[] compressed = CompressionUtils.gzipCompress(json.getBytes(StandardCharsets.UTF_8)); |
| | | // byte[] encrypted = securityService.encrypt(compressed); |
| | | //暂时不加密 |
| | | byte[] compressed = json.getBytes(StandardCharsets.UTF_8); |
| | | |
| | | // 5. 生成文件 |
| | | Path filePath = Paths.get(ferryPath,fileName); |
| | | try { |
| | | Files.createDirectories(filePath.getParent()); |
| | | Files.write(filePath, compressed); |
| | | return filePath.toString(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("文件写入失败", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public TransferPackage importData(String filePath) { |