| | |
| | | InputStream zipFileInputStream = file.getInputStream();//test |
| | | |
| | | byte[] bytes = FileUtil.copyToByteArray(zipFileInputStream); |
| | | list = parseDncZipFromByteArray(bytes); |
| | | list = parseMdmZipFromByteArray(bytes); |
| | | |
| | | |
| | | } catch (IOException e) { |
| | |
| | | System.out.println("创建的临时文件: " + tempFile); |
| | | return tempFile.toFile(); |
| | | } |
| | | public static List<MdmProgramImportVO> parseDncZipFromByteArray(byte[] zipData) throws IOException { |
| | | public static List<MdmProgramImportVO> parseMdmZipFromByteArray(byte[] zipData) throws IOException { |
| | | List<MdmProgramImportVO> list = new ArrayList<>(); |
| | | //List<DncSendBackData> datas = ZipFileDirectoryScanner.getFilesInDirectoryRecursive(zipData, ""); |
| | | |
| | | Map<String,String> fileMd5Map = new HashMap<>(); |
| | | Map<String,MdmProgramImportVO> fileDataMap = new HashMap<>(); |
| | | try (SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel(zipData); |
| | |
| | | ZipArchiveEntry entry; |
| | | Enumeration<ZipArchiveEntry> entries = zipFile.getEntries(); |
| | | while (entries.hasMoreElements()) { |
| | | //while ((entry = zis.getNextZipEntry()) != null) { |
| | | entry = entries.nextElement(); |
| | | DncSendBackData prog = new DncSendBackData(); |
| | | |
| | | String entryName = entry.getName(); |
| | | |
| | | if (!entry.isDirectory()) { |
| | |
| | | d.setName(jsonObject.getString("name")); |
| | | d.setId(jsonObject.getLong("id")); |
| | | d.setCode(jsonObject.getString("code")); |
| | | //d.setFileBackTime(LocalDateTime.now());//到达时间 |
| | | d.setDescription(jsonObject.getString("description")); |
| | | d.setCategory(jsonObject.getString("category")); |
| | | d.setBindNcNodeId(jsonObject.getLong("bindNcNodeId")); |
| | | d.setIsLastEdition(jsonObject.getInteger("isLastEdition")); |
| | | d.setIsLocked(jsonObject.getInteger("isLocked")); |
| | | d.setIsTest(jsonObject.getInteger("isTest")); |
| | | d.setMachineCode(jsonObject.getString("machineCode")); |
| | | d.setNcNodeId(jsonObject.getLong("ncNodeId")); |
| | | d.setPartNo(jsonObject.getString("partNo")); |
| | | d.setProcessEdition(jsonObject.getString("processEdition")); |
| | | |
| | | fileDataMap.put(d.getName(),d); |
| | | |
| | | list.add(d); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | System.out.println("文件名: " + entry.getName()); |
| | | System.out.println("大小: " + entry.getSize()); |
| | | |
| | | // 读取文件内容到字节数组 |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | |
| | | } |
| | | |