| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.File; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 资料馆 |
| | |
| | | BaseQueryService baseQueryService; |
| | | |
| | | private final static Log log = LogFactory.getLog(DataLibService.class); |
| | | |
| | | /** |
| | | * 查询DB中溢出的单位ID |
| | | */ |
| | | public List<Integer> selectDbOverflowDep(UserEntity ue, List<String> entities, String wkt) { |
| | | List<Integer> rs = new ArrayList<>(); |
| | | for (String enity : entities) { |
| | | try { |
| | | GeomBaseMapper<?> baseMapper = ClassHelper.getGeoBaseMapper(enity); |
| | | if (null == baseMapper) { |
| | | continue; |
| | | } |
| | | |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.select("depid"); |
| | | wrapper.gt("depid", 0); |
| | | wrapper.apply(String.format("depid != ALL(fn_rec_array(%d, 'dep')", ue.getDepid())); |
| | | |
| | | Integer srid = baseQueryService.getSrid(baseMapper); |
| | | if (null != srid) { |
| | | wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", wkt, srid)); |
| | | } |
| | | |
| | | List<Integer> ids = baseMapper.selectList(wrapper); |
| | | |
| | | addDepIds(rs, ids); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | return rs; |
| | | } |
| | | |
| | | /** |
| | | * 添加单位ID |
| | | */ |
| | | private void addDepIds(List<Integer> rs, List<Integer> ids) { |
| | | if (null == ids || ids.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | for (Integer id : ids) { |
| | | if (!rs.contains(id)) { |
| | | rs.add(id); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建Zip包 |
| | |
| | | Map<String, List<?>> map = new HashMap<>(5); |
| | | for (String enity : entities) { |
| | | try { |
| | | GeomBaseMapper baseMapper = ClassHelper.getGeoBaseMapper(enity); |
| | | GeomBaseMapper<?> baseMapper = ClassHelper.getGeoBaseMapper(enity); |
| | | if (null == baseMapper) { |
| | | continue; |
| | | } |
| | |
| | | map.put(enity, list); |
| | | } |
| | | } catch (Exception ex) { |
| | | // |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | |
| | | 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)); |
| | | if (null != srid) { |
| | | wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", wkt, srid)); |
| | | } |
| | | |
| | | return wrapper; |
| | | } |