| | |
| | | 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; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | DownloadMapper downloadMapper; |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | DownloadService downloadService; |
| | | DownloadMapper downloadMapper; |
| | | |
| | | @Autowired |
| | | BaseQueryService baseQueryService; |
| | |
| | | |
| | | QueryWrapper wrapper = getWrapper4DbOverflow(ue, dr); |
| | | Integer srid = baseQueryService.getSrid(baseMapper); |
| | | if (null != srid) { |
| | | wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", dr.getWkt(), srid)); |
| | | } |
| | | wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", dr.getWkt(), srid)); |
| | | |
| | | List<String> ids = baseMapper.selectObjs(wrapper); |
| | | addDepCodes(rs, ids); |
| | |
| | | ZipParameters params = Zip4jHelper.getZipParams(true); |
| | | zip.addFolder(new File(gdbPath), params); |
| | | // zip.addFolder(new File(annexPath), params) |
| | | addAnnex(zip, params, annexMap); |
| | | 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 (wrapper.isEmptyOfWhere()) { |
| | | wrapper.apply("1 = 1"); |
| | | } |
| | | if ("bborehole".equals(entity)) { |
| | | wrapper.last("limit 100"); |
| | | } |
| | | |
| | | String tab = BaseQueryService.getTabName(baseMapper); |
| | | List<AttachEntity> annex = baseMapper.selectAnnex(tab, wrapper); |
| | | if (null == annex || annex.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!annexMap.containsKey(entity)) { |
| | | annexMap.put(tab.replace(".", "_"), annex); |
| | | } else { |
| | | annexMap.get(tab.replace(".", "_")).addAll(annex); |
| | | } |
| | | metaService.addData(entity, baseMapper, wrapper, dataMap, annexMap); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | |
| | | // wrapper.apply(String.format("depid like '%s'", StringHelper.getRightLike(dr.getDepcode()))) |
| | | wrapper.likeRight("depid", dr.getDepcode()); |
| | | } |
| | | if (baseMapper instanceof GeomBaseMapper && !StringHelper.isEmpty(dr.getWkt())) { |
| | | if (baseMapper instanceof GeomBaseMapper) { |
| | | wrapper.select("ST_AsText(geom) as geom, *"); |
| | | Integer srid = baseQueryService.getSrid((GeomBaseMapper) baseMapper); |
| | | if (null != srid) { |
| | | if (!StringHelper.isEmpty(dr.getWkt())) { |
| | | Integer srid = baseQueryService.getSrid((GeomBaseMapper) baseMapper); |
| | | wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", dr.getWkt(), srid)); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | FileHelper.copyFile(srcFile, destFile); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加附件 |
| | | */ |
| | | private void addAnnex(ZipFile zip, ZipParameters params, Map<String, List<AttachEntity>> annexMap) { |
| | | List<String> files = new ArrayList<>(); |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | | for (String key : annexMap.keySet()) { |
| | | for (AttachEntity ae : annexMap.get(key)) { |
| | | try { |
| | | File srcFile = new File(uploadPath + File.separator + ae.getPath()); |
| | | if (!srcFile.exists() || srcFile.isDirectory()) { |
| | | continue; |
| | | } |
| | | if (files.contains(srcFile.getPath())) { |
| | | continue; |
| | | } |
| | | |
| | | files.add(srcFile.getPath()); |
| | | params.setFileNameInZip("annex" + File.separator + key + File.separator + ae.getName()); |
| | | zip.addStream(new FileInputStream(srcFile), params); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |