| | |
| | | package com.lf.server.service.show; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.lf.server.entity.all.BaseEntity; |
| | | import com.lf.server.entity.ctrl.DownloadReqEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.sys.AttachEntity; |
| | |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import com.lf.server.mapper.data.DownloadMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.data.DownloadService; |
| | | import com.lf.server.service.data.MetaService; |
| | | import net.lingala.zip4j.ZipFile; |
| | | import net.lingala.zip4j.model.ZipParameters; |
| | | import org.apache.commons.logging.Log; |
| | |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | DownloadMapper downloadMapper; |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | DownloadService downloadService; |
| | | DownloadMapper downloadMapper; |
| | | |
| | | @Autowired |
| | | BaseQueryService baseQueryService; |
| | |
| | | String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | String tempPath = pathHelper.getTempPath(tempName); |
| | | String gdbPath = tempPath + File.separator + "tabs.gdb"; |
| | | String annexPath = tempPath + File.separator + "annex"; |
| | | |
| | | File gdbFile = new File(gdbPath); |
| | | if (gdbFile.exists() && gdbFile.isDirectory()) { |
| | |
| | | } |
| | | GdbHelper.createGdb(gdbPath, dataMap); |
| | | |
| | | File annexFile = new File(annexPath); |
| | | if (!annexFile.exists() || !annexFile.isDirectory()) { |
| | | annexFile.mkdirs(); |
| | | } |
| | | createAnnex(annexPath, annexMap); |
| | | |
| | | String zipFile = pathHelper.getDownloadFullPath() + File.separator + tempName + ".gdb.zip"; |
| | | ZipFile zip = Zip4jHelper.createZipFile(zipFile, dr.getPwd()); |
| | | ZipParameters params = Zip4jHelper.getZipParams(true); |
| | | zip.addFolder(new File(gdbPath), params); |
| | | zip.addFolder(new File(annexPath), params); |
| | | // zip.addFolder(new File(annexPath), params) |
| | | metaService.addAnnex(zip, params, annexMap); |
| | | |
| | | String dbPwd = Md5Helper.reverse(Md5Helper.generate(dr.getPwd())); |
| | | DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, dbPwd); |
| | | int rows = downloadMapper.insert(downloadEntity); |
| | | DownloadEntity de = getDownloadEntity(ue, zipFile, dbPwd); |
| | | int rows = downloadMapper.insert(de); |
| | | |
| | | return rows > 0 ? downloadEntity.getGuid() : null; |
| | | return rows > 0 ? de.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | QueryWrapper wrapper = createQueryWrapper(baseMapper, dr); |
| | | List list = baseMapper.selectList(wrapper); |
| | | if (null == list || list.size() == 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (!dataMap.containsKey(entity)) { |
| | | dataMap.put(entity, list); |
| | | } else { |
| | | dataMap.get(entity).addAll(list); |
| | | } |
| | | if ("bborehole".equals(entity)) { |
| | | continue; |
| | | } |
| | | if (wrapper.isEmptyOfWhere()) { |
| | | wrapper.apply("1 = 1"); |
| | | } |
| | | |
| | | String tab = BaseQueryService.getTabName(baseMapper); |
| | | List<AttachEntity> annex = baseMapper.selectAnnex(tab, wrapper); |
| | | if (null == annex || annex.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!annexMap.containsKey(entity)) { |
| | | annexMap.put(entity, annex); |
| | | } else { |
| | | annexMap.get(entity).addAll(annex); |
| | | } |
| | | metaService.addData(entity, baseMapper, wrapper, dataMap, annexMap); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建附件 |
| | | * 创建附件 * |
| | | */ |
| | | private void createAnnex(String annexPath, Map<String, List<AttachEntity>> annexMap) { |
| | | if (annexMap.size() == 0) { |