| | |
| | | package com.lf.server.service.data; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.ctrl.DownloadReqEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | |
| | | import com.lf.server.entity.sys.MetaDownEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.*; |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | | import com.lf.server.mapper.data.DownloadMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.sys.MetaDownService; |
| | | import net.lingala.zip4j.ZipFile; |
| | | import net.lingala.zip4j.model.FileHeader; |
| | |
| | | * 查询数据 |
| | | */ |
| | | private void queryData(Map<String, List<String>> tabs, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) { |
| | | // |
| | | for (String tab : tabs.keySet()) { |
| | | try { |
| | | String entity = tab.split(StaticData.POINT)[1].replace("_", ""); |
| | | BasicMapper baseMapper = ClassHelper.getBasicMapper(entity); |
| | | if (null == baseMapper) { |
| | | continue; |
| | | } |
| | | |
| | | QueryWrapper wrapper = createQueryWrapper(baseMapper, tabs.get(tab)); |
| | | addData(entity, baseMapper, wrapper, dataMap, annexMap); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加数据 |
| | | */ |
| | | public void addData(String entity, BasicMapper baseMapper, QueryWrapper wrapper, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) { |
| | | List list = baseMapper.selectList(wrapper); |
| | | if (null == list || list.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | if (!dataMap.containsKey(entity)) { |
| | | dataMap.put(entity, list); |
| | | } else { |
| | | dataMap.get(entity).addAll(list); |
| | | } |
| | | if (wrapper.isEmptyOfWhere()) { |
| | | wrapper.apply("1 = 1"); |
| | | } |
| | | if (StaticData.BBOREHOLE.equals(entity)) { |
| | | wrapper.last("limit 100"); |
| | | } |
| | | |
| | | String tab = BaseQueryService.getTabName(baseMapper); |
| | | List<AttachEntity> annex = baseMapper.selectAnnex(tab, wrapper); |
| | | if (null == annex || annex.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | if (!annexMap.containsKey(entity)) { |
| | | annexMap.put(tab.replace(StaticData.POINT, "_"), annex); |
| | | } else { |
| | | annexMap.get(tab.replace(StaticData.POINT, "_")).addAll(annex); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建查询包装器 |
| | | */ |
| | | private <T> QueryWrapper<T> createQueryWrapper(BasicMapper baseMapper, List<String> ids) { |
| | | QueryWrapper<T> wrapper = new QueryWrapper<T>(); |
| | | |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void addSingleFile(String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params) throws Exception { |
| | | File file = new File(uploadPath + File.separator + mf.getPath()); |
| | | if (!file.exists() || file.isDirectory()) { |
| | | return; |
| | | } |
| | | zip.addFile(file, params); |
| | | |
| | | String fileName = FileHelper.getFileName(file.getPath()); |