|
@@ -0,0 +1,118 @@
|
|
|
|
+package cn.com.taiji.web.service.impl;
|
|
|
|
+
|
|
|
|
+import cn.com.taiji.common.domain.PageResult;
|
|
|
|
+import cn.com.taiji.common.domain.Result;
|
|
|
|
+import cn.com.taiji.cql.service.IECqlService;
|
|
|
|
+import cn.com.taiji.web.config.EnterpriseConfig;
|
|
|
|
+import cn.com.taiji.web.service.IEnterpriseService;
|
|
|
|
+import cn.com.taiji.web.vo.DeviceVo;
|
|
|
|
+import cn.com.taiji.web.vo.EnterpriseVo;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.geotools.jdbc.JDBCDataStoreFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+public class EnterpriseServiceImpl implements IEnterpriseService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private EnterpriseConfig enterpriseConfig;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IECqlService ecqlService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public PageResult enterpriseQuery(EnterpriseVo enterpriseVo) {
|
|
|
|
+
|
|
|
|
+ //数据源
|
|
|
|
+ Map<String, Object> entDsParams = new HashMap<String, Object>();
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.DATABASE.key, enterpriseConfig.getDsBaseName());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.DBTYPE.key, enterpriseConfig.getDbType());
|
|
|
|
+
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.HOST.key, enterpriseConfig.getDsIp());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.PORT.key, enterpriseConfig.getDsPort());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.USER.key, enterpriseConfig.getDsUserName());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.PASSWD.key, enterpriseConfig.getDsPassword());
|
|
|
|
+ entDsParams.put("tableName", enterpriseConfig.getDsTableName());
|
|
|
|
+
|
|
|
|
+ //组装排序参数
|
|
|
|
+ Map<String, Object> sortParams = new HashMap<String, Object>();
|
|
|
|
+ sortParams.put("sort","asc");
|
|
|
|
+
|
|
|
|
+ //组装分页参数
|
|
|
|
+ Map<String, Object> pageParams = new HashMap<String, Object>();
|
|
|
|
+ pageParams.put("pageSize",enterpriseVo.getPageSize());
|
|
|
|
+ pageParams.put("pageNumber",enterpriseVo.getPageSize());
|
|
|
|
+
|
|
|
|
+ //组转cql查询条件
|
|
|
|
+ StringBuffer filterCql = new StringBuffer();
|
|
|
|
+ if(enterpriseVo.getEntName() !=null && !"".equals(enterpriseVo.getEntName())){
|
|
|
|
+
|
|
|
|
+ filterCql.append("(entName like '%"+enterpriseVo.getEntName()+"%')");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(enterpriseVo.getEntType() !=null && !"".equals(enterpriseVo.getEntType())){
|
|
|
|
+
|
|
|
|
+ if(filterCql.length() >0){
|
|
|
|
+
|
|
|
|
+ filterCql.append(" and (entType = '"+enterpriseVo.getEntType()+"')");
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ filterCql.append(" (entType = '"+enterpriseVo.getEntType()+"')");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println("查询条件:"+filterCql.toString());
|
|
|
|
+
|
|
|
|
+ return ecqlService.cqlQuery4Mysql(entDsParams,filterCql.toString(),sortParams,pageParams);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result deviceQuery(DeviceVo deviceVo) {
|
|
|
|
+
|
|
|
|
+ //数据源
|
|
|
|
+ Map<String, Object> entDsParams = new HashMap<String, Object>();
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.DATABASE.key, enterpriseConfig.getDsBaseName());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.DBTYPE.key, enterpriseConfig.getDbType());
|
|
|
|
+
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.HOST.key, enterpriseConfig.getDsIp());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.PORT.key, enterpriseConfig.getDsPort());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.USER.key, enterpriseConfig.getDsUserName());
|
|
|
|
+ entDsParams.put(JDBCDataStoreFactory.PASSWD.key, enterpriseConfig.getDsPassword());
|
|
|
|
+ entDsParams.put("tableName", enterpriseConfig.getDsTableName());
|
|
|
|
+
|
|
|
|
+ //组转cql查询条件
|
|
|
|
+ StringBuffer filterCql = new StringBuffer();
|
|
|
|
+
|
|
|
|
+ String wkt = "POINT ("+deviceVo.getLon()+" "+deviceVo.getLat()+")";
|
|
|
|
+
|
|
|
|
+ filterCql.append("(DWITHIN(location," + wkt + ", "+deviceVo.getRadius()+", kilometers))");
|
|
|
|
+
|
|
|
|
+ if(deviceVo.getEntCode() !=null && !"".equals(deviceVo.getEntCode())){
|
|
|
|
+
|
|
|
|
+ if(filterCql.length() >0){
|
|
|
|
+
|
|
|
|
+ filterCql.append(" and (entCode = '"+deviceVo.getEntCode()+"')");
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ filterCql.append(" (entCode = '"+deviceVo.getEntCode()+"')");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println("查询条件:"+filterCql.toString());
|
|
|
|
+
|
|
|
|
+ PageResult pageResult = ecqlService.cqlQuery4Mysql(entDsParams,filterCql.toString(),null,null);
|
|
|
|
+
|
|
|
|
+ return Result.of(pageResult.getDatas().toString(),pageResult.getResp_code(),pageResult.getResp_msg());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|