管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-28 ea3027b84222db35c61f652753fca583c4cc3ab3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.lf.server.service.all;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lf.server.helper.AesHelper;
import com.lf.server.helper.ClassHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.mapper.all.GeomBaseMapper;
import org.springframework.stereotype.Service;
 
/**
 * 父查询服务类
 * @author WWW
 */
@Service
public class BaseQueryService {
    /**
     * 获取父Mapper
     *
     * @param name Mapper名
     * @return BaseMapper
     */
    public BaseMapper getBaseMapper(String name) {
        if (StringHelper.isEmpty(name)) {
            return null;
        }
 
        Object obj = ClassHelper.getBean(name.trim() + "Mapper");
        if (!(obj instanceof BaseMapper)) {
            return null;
        }
 
        return (BaseMapper) obj;
    }
 
    /**
     * 获取空间父Mapper
     *
     * @param name Mapper名
     * @return GeomBaseMapper
     */
    public GeomBaseMapper getGeoBaseMapper(String name) {
        if (StringHelper.isEmpty(name)) {
            return null;
        }
 
        Object obj = ClassHelper.getBean(name.trim() + "Mapper");
        if (!(obj instanceof GeomBaseMapper)) {
            return null;
        }
 
        return (GeomBaseMapper) obj;
    }
 
    /**
     * @param wrapper
     * @param filter
     */
    public void addFilterWrapper(QueryWrapper<Object> wrapper, String filter) {
        if (StringHelper.isEmpty(filter)) {
            return;
        }
    }
 
    /**
     * 添加空间查询条件
     *
     * @param baseMapper 父Mapper
     * @param wrapper    QueryWrapper
     * @param wkt        WKT(著名文本)
     * @param srid       空间引用标识符
     * @throws Exception 异常
     */
    public void addGeomWrapper(BaseMapper baseMapper, QueryWrapper<Object> wrapper, String wkt, Integer srid) throws Exception {
        if (baseMapper instanceof GeomBaseMapper && !StringHelper.isEmpty(wkt) && srid != null) {
            wkt = AesHelper.decrypt(wkt);
            wrapper.apply(String.format("ST_Intersects(geom, ST_PolygonFromText('%s', %d))", wkt, srid));
        }
    }
}