| | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询映射") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20230110010101"), |
| | | @ApiImplicitParam(name = "dirid", value = "目录ID", dataType = "Integer", paramType = "query", example = "163"), |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20230722"), |
| | | @ApiImplicitParam(name = "dirid", value = "目录ID", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "verid", value = "版本ID", dataType = "Integer", paramType = "query", example = "0"), |
| | | @ApiImplicitParam(name = "epsgCode", value = "坐标编码", dataType = "String", paramType = "query", example = "EPSG:4490") |
| | | }) |
| | |
| | | |
| | | public final static int ONE_HUNDRED_THOUSAND = 100000; |
| | | |
| | | public static final double D75 = 75.0; |
| | | public static final double D90 = 90.0; |
| | | |
| | | public static final double D100 = 100.0; |
| | | |
| | |
| | | public void deleteOldPath(String tempPath) { |
| | | try { |
| | | double ran = Math.random() * 99; |
| | | if (ran < StaticData.D75) { |
| | | if (ran < StaticData.D90) { |
| | | return; |
| | | } |
| | | |
| | |
| | | dir.mkdirs(); |
| | | } |
| | | |
| | | int count; |
| | | zipFile = new ZipFile(filePath, Charset.forName("GBK")); |
| | | Enumeration e = zipFile.entries(); |
| | | while (e.hasMoreElements()) { |
| | | ZipEntry entry = (ZipEntry) e.nextElement(); |
| | | if (entry.isDirectory()) { |
| | | File f = new File(zipDir + File.separator + entry.getName()); |
| | | if (!f.exists()) { |
| | | f.mkdirs(); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry)); |
| | | FileOutputStream fos = new FileOutputStream(zipDir + File.separator + entry.getName()); |
| | | BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE); |
| | | while ((count = is.read(BUFFER, 0, BUFFER_SIZE)) != -1) { |
| | | dest.write(BUFFER, 0, count); |
| | | } |
| | | |
| | | dest.flush(); |
| | | dest.close(); |
| | | fos.close(); |
| | | is.close(); |
| | | } |
| | | createDirs(zipFile, zipDir); |
| | | writeFiles(zipFile, zipDir); |
| | | |
| | | return true; |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建目录 |
| | | */ |
| | | private static void createDirs(ZipFile zipFile, String zipDir) { |
| | | Enumeration<?> e = zipFile.entries(); |
| | | while (e.hasMoreElements()) { |
| | | ZipEntry entry = (ZipEntry) e.nextElement(); |
| | | if (entry.isDirectory()) { |
| | | File f = new File(zipDir + File.separator + entry.getName()); |
| | | if (!f.exists()) { |
| | | f.mkdirs(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 写文件 |
| | | */ |
| | | private static void writeFiles(ZipFile zipFile, String zipDir) throws IOException { |
| | | Enumeration<?> e = zipFile.entries(); |
| | | while (e.hasMoreElements()) { |
| | | ZipEntry entry = (ZipEntry) e.nextElement(); |
| | | if (!entry.isDirectory()) { |
| | | writeFile(zipFile, entry, zipDir); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 写文件 |
| | | */ |
| | | private static void writeFile(ZipFile zipFile, ZipEntry entry, String zipDir) throws IOException { |
| | | int count; |
| | | |
| | | BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry)); |
| | | FileOutputStream fos = new FileOutputStream(zipDir + File.separator + entry.getName()); |
| | | BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE); |
| | | while ((count = is.read(BUFFER, 0, BUFFER_SIZE)) != -1) { |
| | | dest.write(BUFFER, 0, count); |
| | | } |
| | | |
| | | dest.flush(); |
| | | dest.close(); |
| | | fos.close(); |
| | | is.close(); |
| | | } |
| | | |
| | | /** |
| | | * Zip压缩 |
| | | * |
| | | * @param zipFile zip源文件 |