管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-19 552da0d21c1203d5ac8ae6e3c82f4989b8845679
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
81
82
83
84
85
86
87
88
89
90
package com.lf.server.service.show;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.ClassHelper;
import com.lf.server.helper.PathHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.mapper.all.GeomBaseMapper;
import com.lf.server.service.all.BaseQueryService;
import com.lf.server.service.data.DownloadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 资料馆
 * @author WWW
 */
@Service
public class DataLibService {
    @Autowired
    PathHelper pathHelper;
 
    @Autowired
    BaseQueryService baseQueryService;
 
    @Autowired
    DownloadService downloadService;
 
    /**
     * 创建Zip包
     */
    public String createZipFile(UserEntity ue, List<String> entities, String wkt, String pwd) {
        Map<String, List<?>> map = queryData(entities, wkt);
        if (map.size() == 0) {
            return null;
        }
 
        return null;
    }
 
    /**
     * 查询数据
     */
    private Map<String, List<?>> queryData(List<String> entities, String wkt) {
        Map<String, List<?>> map = new HashMap<>(5);
        for (String enity : entities) {
            try {
                GeomBaseMapper baseMapper = ClassHelper.getGeoBaseMapper(enity);
                if (null == baseMapper) {
                    continue;
                }
 
                String tab = BaseQueryService.getTabName(baseMapper);
                if (StringHelper.isNull(tab)) {
                    continue;
                }
 
                QueryWrapper wrapper = createWrapper(baseMapper, wkt);
                List<?> list = baseMapper.selectList(wrapper);
                if (null == list || list.size() == 0) {
                    continue;
                }
 
                if (!map.containsKey(tab)) {
                    map.put(tab, list);
                }
            } catch (Exception ex) {
                //
            }
        }
 
        return map;
    }
 
    /**
     * 创建QueryWrapper
     */
    private QueryWrapper createWrapper(GeomBaseMapper baseMapper, String wkt) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.select("ST_AsText(geom) as geom");
        Integer srid = baseQueryService.getSrid(baseMapper);
        wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", wkt, srid));
 
        return wrapper;
    }
}