| | |
| | | import com.se.simu.domain.SeField; |
| | | import com.se.simu.domain.SeLayer; |
| | | import com.se.simu.helper.RsaHelper; |
| | | import com.se.simu.helper.StringHelper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Value("${sedb.dbName}") |
| | | String dbName; |
| | | |
| | | @Value("${sedb.pageSize}") |
| | | Integer pageSize; |
| | | |
| | | @Value("#{'${sedb.layerNames}'}") |
| | | List<String> layerNames; |
| | | |
| | |
| | | List<String> sysFields; |
| | | |
| | | String password; |
| | | |
| | | |
| | | @Resource |
| | | RestTemplate restTemplate; |
| | |
| | | db.setBbox(bbox); |
| | | |
| | | List<SeLayer> layers = getLayers(token, db.getDbid()); |
| | | queryData(token, db, layers); |
| | | |
| | | return db.getDbid(); |
| | | } |
| | |
| | | return layers; |
| | | } |
| | | |
| | | public JSONArray query(String token, String dbid, String layerId, String bbox) { |
| | | int start = 1, count = 1000, total = 0; |
| | | public void queryData(String token, SeDb db, List<SeLayer> layers) throws Exception { |
| | | for (SeLayer layer : layers) { |
| | | int count = getCount(token, db, layer); |
| | | if (0 == count) throw new Exception(layer.getName() + ",图层数据为空"); |
| | | |
| | | int pageCount = (count - 1) / pageSize + 1; |
| | | for (int i = 0; i < pageCount; i++) { |
| | | JSONArray data = query(token, db, layer, i + 1, pageSize); |
| | | if (null != data && data.size() > 0) { |
| | | layer.addData(data); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public int getCount(String token, SeDb db, SeLayer layer) { |
| | | Map<String, Object> map = new HashMap<>(4); |
| | | map.put("token", token); |
| | | map.put("dbid", db.getDbid()); |
| | | map.put("bbox", db.getBbox()); |
| | | map.put("layerid", layer.getId()); |
| | | |
| | | JSONObject obj = restTemplate.postForObject(host + "geo-service/entitydbdata/layer/query", map, JSONObject.class); |
| | | if (null == obj || 200 != obj.getInt("code")) return 0; |
| | | |
| | | return obj.getInt("data"); |
| | | } |
| | | |
| | | public JSONArray query(String token, SeDb db, SeLayer layer, int start, int count) { |
| | | Map<String, Object> map = new HashMap<>(8); |
| | | map.put("token", token); |
| | | map.put("start", start); |
| | | map.put("count", count); |
| | | map.put("dbid", dbid); |
| | | map.put("layerid", layerId); |
| | | map.put("containCount", true); |
| | | map.put("bbox", bbox); |
| | | map.put("querytype", "entity"); |
| | | map.put("dbid", db.getDbid()); |
| | | map.put("bbox", db.getBbox()); |
| | | map.put("containCount", false); |
| | | map.put("layerid", layer.getId()); |
| | | map.put("querytype", layer.getQueryType()); |
| | | |
| | | JSONObject obj = restTemplate.postForObject(host + "geo-service/entitydbdata/layer/query", map, JSONObject.class); |
| | | if (null == obj || 200 != obj.getInt("code")) return null; |
| | | |
| | | JSONObject data = obj.getJSONObject("data"); |
| | | total = data.getInt("data"); |
| | | if (0 == total) return null; |
| | | |
| | | JSONArray arr = new JSONArray(); |
| | | JSONArray items = data.getJSONArray("items"); |
| | | arr.addAll(items); |
| | | |
| | | return arr; |
| | | return data.getJSONArray("items"); |
| | | } |
| | | } |