| | |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.show.PipelineEntity; |
| | | import com.lf.server.entity.sys.AttachEntity; |
| | | import com.lf.server.entity.sys.MetaDownEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.*; |
| | | import com.lf.server.mapper.data.DownloadMapper; |
| | | import com.lf.server.service.show.DataLibService; |
| | | import com.lf.server.service.sys.MetaDownService; |
| | | import net.lingala.zip4j.ZipFile; |
| | | import net.lingala.zip4j.model.FileHeader; |
| | |
| | | |
| | | @Autowired |
| | | DownloadMapper downloadMapper; |
| | | |
| | | @Autowired |
| | | DataLibService dataLibService; |
| | | |
| | | @Autowired |
| | | MetaDownService metaDownService; |
| | |
| | | * @param pwd 密码 |
| | | * @return 下载文件GUID |
| | | */ |
| | | public String zipFiles(UserEntity ue, List<MetaEntity> list, String pwd) { |
| | | public String zipFiles(UserEntity ue, List<MetaEntity> list, String pwd) throws Exception { |
| | | Map<String, List<String>> tabs = getTabs(list); |
| | | rmRepeatMetas(list); |
| | | |
| | | String downloadPath = pathHelper.getDownloadFullPath(); |
| | | String zipName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip"; |
| | | String zipFile = downloadPath + File.separator + zipName; |
| | | Map<String, List<?>> dataMap = new HashMap<>(2); |
| | | Map<String, List<AttachEntity>> annexMap = new HashMap<>(2); |
| | | queryData(tabs, dataMap, annexMap); |
| | | |
| | | //String downloadPath = pathHelper.getDownloadFullPath(); |
| | | //String zipName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip"; |
| | | //String zipFile = downloadPath + File.separator + zipName; |
| | | |
| | | String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | String tempPath = pathHelper.getTempPath(tempName); |
| | | String gdbPath = tempPath + File.separator + "tabs.gdb"; |
| | | |
| | | File gdbFile = new File(gdbPath); |
| | | if (gdbFile.exists() && gdbFile.isDirectory()) { |
| | | FileHelper.deleteDir(gdbPath); |
| | | } |
| | | if (dataMap.size() > 0) { |
| | | GdbHelper.createGdb(gdbPath, dataMap); |
| | | } |
| | | |
| | | String zipFile = pathHelper.getDownloadFullPath() + File.separator + tempName + ".gdb.zip"; |
| | | ZipFile zip = Zip4jHelper.createZipFile(zipFile, pwd); |
| | | ZipParameters params = Zip4jHelper.getZipParams(true); |
| | | addMetaFiles(zip, params, list); |
| | | //addMetaFiles(zip, params, list); |
| | | zip.addFolder(new File(gdbPath), params); |
| | | dataLibService.addAnnex(zip, params, annexMap); |
| | | |
| | | String dbPwd = Md5Helper.reverse(Md5Helper.generate(pwd)); |
| | | DownloadEntity de = getDownloadEntity(ue, zipFile, dbPwd); |
| | | |
| | | int rows = downloadMapper.insert(de); |
| | | if (de.getId() > 0) { |
| | | insertMetaDown(ue, list, de); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询数据 |
| | | */ |
| | | private void queryData(Map<String, List<String>> tabs, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) { |
| | | // |
| | | } |
| | | |
| | | /** |
| | | * 添加元数据文件至Zip包 |
| | | */ |
| | | private void addMetaFiles(ZipFile zip, ZipParameters params, List<MetaEntity> list) { |