月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-17 796b44ea813a1133beae4f3a67f1c0263510c0c7
src/main/java/com/moon/server/service/data/MetaService.java
@@ -27,11 +27,8 @@
import java.io.FileInputStream;
import java.util.*;
/**
 * 元数据
 * @author WWW
 */
@Service
@SuppressWarnings("ALL")
public class MetaService implements MetaMapper {
    @Autowired
    PathHelper pathHelper;
@@ -48,21 +45,21 @@
    private final static Log log = LogFactory.getLog(MetaService.class);
    @Override
    public Integer selectCount(String depcode, String dircode, Integer verid, String name) {
    public Integer selectCount(String depcode, String dircode, Integer verid, String name, Integer sensorType, Integer mataType, Date startDate, Date endDate, String wkt) {
        depcode = StringHelper.getRightLike(depcode);
        dircode = StringHelper.getRightLike(dircode);
        name = StringHelper.getLikeUpperStr(name);
        return metaMapper.selectCount(depcode, dircode, verid, name);
        return metaMapper.selectCount(depcode, dircode, verid, name, sensorType, mataType, startDate, endDate, wkt);
    }
    @Override
    public List<MetaEntity> selectByPage(String depcode, String dircode, Integer verid, String name, Integer limit, Integer offset) {
    public List<MetaEntity> selectByPage(String depcode, String dircode, Integer verid, String name, Integer sensorType, Integer mataType, Date startDate, Date endDate, String wkt, Integer limit, Integer offset) {
        depcode = StringHelper.getRightLike(depcode);
        dircode = StringHelper.getRightLike(dircode);
        name = StringHelper.getLikeUpperStr(name);
        return metaMapper.selectByPage(depcode, dircode, verid, name, limit, offset);
        return metaMapper.selectByPage(depcode, dircode, verid, name, sensorType, mataType, startDate, endDate, wkt, limit, offset);
    }
    @Override
@@ -120,6 +117,11 @@
    }
    @Override
    public List<MetaEntity> selectByIds(String ids) {
        return metaMapper.selectByIds(ids);
    }
    @Override
    public MetaEntity selectByGuid(String guid, String dircode, String tab) {
        return metaMapper.selectByGuid(guid, dircode, tab);
    }
@@ -129,8 +131,12 @@
        return metaMapper.selectByIdsForTab(ids);
    }
    @Override
    public List<MetaEntity> selectMetaFiles(List<Integer> ids) {
        return metaMapper.selectMetaFiles(StringHelper.join(ids, StaticData.COMMA));
    }
    @Override
    public List<MetaEntity> selectMetaFiles(String ids) {
        return metaMapper.selectMetaFiles(ids);
    }
@@ -178,9 +184,6 @@
        return metaMapper.updates(list);
    }
    /**
     * 删除元数据
     */
    public Integer deletes(List<Integer> list) {
        String ids = StringHelper.join(list, ",");
@@ -193,9 +196,6 @@
        return deletes(sql, ids);
    }
    /**
     * 获取删除表记录SQL
     */
    public String getDelTabsSql(List<MetaEntity> metas) {
        List<String> list = getTabDeletes(metas, metas.get(0).getTab());
        addCascadDeletes(list);
@@ -205,9 +205,6 @@
        return StringHelper.join(list, ";");
    }
    /**
     * 获取删除表记录SQL
     */
    private List<String> getTabDeletes(List<MetaEntity> metas, String tab) {
        List<String> list = new ArrayList<>();
@@ -230,9 +227,6 @@
        return list;
    }
    /**
     * 添加级联删除
     */
    private void addCascadDeletes(List<String> list) {
        int i = 0, c = list.size();
        while (i < c) {
@@ -252,9 +246,6 @@
        }
    }
    /**
     * 添加附件删除
     */
    private void addAttachDeletes(List<String> list) {
        int i = 0, c = list.size();
        while (i < c) {
@@ -268,9 +259,6 @@
        }
    }
    /**
     * 查看文件
     */
    public void downloadForView(String guid, boolean inline, HttpServletResponse res) {
        try {
            if (StringHelper.isEmpty(guid)) {
@@ -297,23 +285,12 @@
        }
    }
    /**
     * 查询元数据中溢出的单位ID
     */
    public List<String> selectMetaOverflowDep(UserEntity ue, DownloadReqEntity dr) {
        String ids = StringHelper.join(dr.getIds(), ",");
        return selectMetaOverflowDep(ids, ue.getDepcode());
    }
    /**
     * 请求元数据下载
     *
     * @param ue 用户实体
     * @param dr 请求下载实体
     * @return 下载文件GUID
     * @throws Exception 异常
     */
    public String downloadMeteReq(UserEntity ue, DownloadReqEntity dr) throws Exception {
        List<MetaEntity> list = selectMetaFiles(dr.getIds());
        if (null == list || list.isEmpty()) {
@@ -358,9 +335,6 @@
        return rows > 0 ? de.getGuid() : null;
    }
    /**
     * 获取数据表
     */
    private Map<String, List<String>> getTabs(List<MetaEntity> list) {
        Map<String, List<String>> tabs = new HashMap<>(2);
        for (MetaEntity meta : list) {
@@ -381,9 +355,6 @@
        return tabs;
    }
    /**
     * 移除重复的元数据文件
     */
    private void rmRepeatMetas(List<MetaEntity> list) {
        List<String> guidList = new ArrayList<>();
@@ -400,9 +371,6 @@
        }
    }
    /**
     * 查询数据
     */
    private void queryData(Map<String, List<String>> tabs, Map<String, List<?>> dataMap, Map<String, List<AttachEntity>> annexMap) {
        for (String tab : tabs.keySet()) {
            try {
@@ -420,9 +388,6 @@
        }
    }
    /**
     * 添加数据
     */
    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) {
@@ -454,9 +419,6 @@
        }
    }
    /**
     * 创建查询包装器
     */
    private <T> QueryWrapper<T> createQueryWrapper(BasicMapper baseMapper, List<String> ids) {
        for (int i = 0, c = ids.size(); i < c; i++) {
            ids.set(i, "'" + ids.get(i) + "'");
@@ -472,9 +434,6 @@
        return wrapper;
    }
    /**
     * 添加附件
     */
    public void addAnnex(ZipFile zip, ZipParameters params, Map<String, List<AttachEntity>> annexMap) {
        List<String> files = new ArrayList<>();
        String uploadPath = pathHelper.getConfig().getUploadPath();
@@ -499,9 +458,6 @@
        }
    }
    /**
     * 添加元数据文件至Zip包
     */
    private void addMetaFiles(ZipFile zip, ZipParameters params, List<MetaEntity> list) {
        List<String> names = new ArrayList<>();
        String uploadPath = pathHelper.getConfig().getUploadPath();
@@ -550,9 +506,6 @@
        }
    }
    /**
     * 添加目录文件
     */
    private void addFolderFile(String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params) throws Exception {
        File file = new File(uploadPath + File.separator + mf.getPath());
        if (!file.exists() || !file.isDirectory()) {
@@ -567,9 +520,6 @@
        }
    }
    /**
     * 添加多文件
     */
    private void addMultiFile(String uploadPath, MetaEntity mf, ZipFile zip, ZipParameters params, List<String> extList) throws Exception {
        addSingleFile(uploadPath, mf, zip, params);
@@ -588,9 +538,6 @@
        }
    }
    /**
     * 添加单文件
     */
    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()) {
@@ -605,9 +552,6 @@
        }
    }
    /**
     * 获取下载实体类
     */
    private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) {
        DownloadEntity de = new DownloadEntity();
        de.setName(FileHelper.getFileName(file));
@@ -626,9 +570,6 @@
        return de;
    }
    /**
     * 插入元数据-下载表
     */
    private void insertMetaDown(UserEntity ue, List<MetaEntity> metas, DownloadEntity de) {
        List<MetaDownEntity> list = new ArrayList<>();
        for (MetaEntity me : metas) {
@@ -642,4 +583,14 @@
        metaDownService.inserts(list);
    }
    public String getGeometryFilter(String wkt) throws Exception {
        if (StringHelper.isEmpty(wkt)) {
            return null;
        }
        wkt = AesHelper.decrypt(wkt);
        return String.format("ST_Intersects(ST_GeomFromText('%s', %d), geom)", wkt, StaticData.I104903);
    }
}