Browse Source

连接池

liwh 1 year ago
parent
commit
a895c1f452

+ 33 - 11
tile-service/src/main/java/cn/com/taiji/tile/service/impl/TileServiceImpl.java

@@ -35,18 +35,41 @@ public class TileServiceImpl implements ITileService {
 
         long currentTimeMillis = System.currentTimeMillis();
 
-        StringBuffer sbBbox = new StringBuffer();
-        sbBbox.append("(bbox (");
-        sbBbox.append(geoDs.getBboxColumn() + ",");
-        sbBbox.append(requestParam.getBbox() + "))");
+        StringBuffer filterCqlStr = new StringBuffer();
 
+        String filterCql = requestParam.getCqlFilter();
 
-//        String filterCql = requestParam.getCqlFilter()+" and "+sbBbox.toString();
-//        String filterCql = sbBbox.toString();
+        if(filterCql !=null && !"".equals(filterCql)){
 
-        String filterCql = requestParam.getCqlFilter();
+            StringBuffer sbBbox = new StringBuffer();
+            sbBbox.append("(bbox (");
+            sbBbox.append(geoDs.getBboxColumn() + ",");
+            sbBbox.append(requestParam.getBbox() + "))");
+
+            filterCqlStr.append(filterCql);
+        }
+
+        String bbox = requestParam.getBbox();
+
+        if(bbox !=null && !"".equals(bbox)){
+
+            StringBuffer sbBbox = new StringBuffer();
+            sbBbox.append("(bbox (");
+            sbBbox.append(geoDs.getBboxColumn()+",");
+            sbBbox.append(requestParam.getBbox()+"))");
+
+            if(filterCqlStr.length() >0){
+
+                filterCqlStr.append(" and "+sbBbox.toString());
+            }else{
+
+                filterCqlStr.append(sbBbox.toString());
+
+            }
+
+        }
 
-        System.out.println("查询条件:" + filterCql);
+        System.out.println("查询条件:" + filterCqlStr.toString());
 
         Map<String, Object> cqlDsParams = new HashMap<String, Object>();
         cqlDsParams.put(JDBCDataStoreFactory.DATABASE.key, geoDs.getDataBase());
@@ -60,9 +83,8 @@ public class TileServiceImpl implements ITileService {
 
         //组装排序参数
         Map<String, Object> sortParams = new HashMap<String, Object>();
-        sortParams.put("sort", "asc");
 
-        PageResult pageResult = ecqlService.cqlQuery4Mysql(cqlDsParams, filterCql, sortParams, null);
+        PageResult pageResult = ecqlService.cqlQuery4Mysql(cqlDsParams, filterCqlStr.toString(), sortParams, null);
 
         if (pageResult.getRecordCount() > 0) {
 
@@ -91,7 +113,7 @@ public class TileServiceImpl implements ITileService {
 
         } else {
 
-            log.info("根据cql规则:" + sbBbox.toString() + "和图层代码:" + requestParam.getLayers() + " 没有找到图层对应的数据源的空间地理数据");
+            log.info("根据cql规则:" + filterCqlStr.toString() + "和图层代码:" + requestParam.getLayers() + " 没有找到图层对应的数据源的空间地理数据");
         }
 
         return new byte[0];