Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
aroad_aqsc
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
许言琪
aroad_aqsc
Commits
880c9bd5
提交
880c9bd5
authored
5月 13, 2019
作者:
朱运伟
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/dev' into dev
上级
4130b330
4ac431e6
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
576 行增加
和
43 行删除
+576
-43
EsUtil_fanshe.java
...lephant/framework/galaxy/aroad/bigdata/EsUtil_fanshe.java
+551
-30
ReadElasticsearch.java
...ant/framework/galaxy/aroad/bigdata/ReadElasticsearch.java
+25
-13
没有找到文件。
src/main/java/com/elephant/framework/galaxy/aroad/bigdata/EsUtil_fanshe.java
浏览文件 @
880c9bd5
...
...
@@ -71,6 +71,164 @@ public class EsUtil_fanshe {
}
}
/**
* @Description: 桥梁所有数据查询
* @Param:
* @return:
* @Author: dongjili
* @Date: 2019/5/13 0013
*/
public
static
List
<
Basebridgealldata
>
queryBridgeAll
(
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
// 搜索数据
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
index
).
setTypes
(
type
).
setFrom
(
start
).
setSize
(
row
);
//isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度)
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
matchAllQuery
());
String
[]
bridgeNames
=
{
"id"
,
"quhuadaima"
,
"quhuamingcheng"
,
"qiaoliangmingcheng"
,
"qiaoliangdaima"
,
"zhongxinzhuanghao"
,
"luxianbianma"
,
"luxianmingcheng"
,
"jishudengji"
,
"quanchang"
,
"kuajingzongchang"
,
"dankongzuidakuajing"
,
"qiaoliangquankuan"
,
"qiaomianjingkuan"
,
"kuajingfenleidaima"
,
"kuajingfenleileixing"
,
"nianxianfenleidaima"
,
"nianxianfenleileixing"
,
"yuanshangbujiegou1daima"
,
"yuanshangbujiegou1xingshi"
,
"yuanshangbujiegou2daima"
,
"yuanshangbujiegou2xingshi"
,
"shangbujiegoudaima"
,
"shangbujiegouxingshi"
,
"shangbujiegoucailiaodaima"
,
"shangbujiegoucailiaomingcheng"
,
"qiaodunleixingdaima"
,
"qiaodunleixingmingcheng"
,
"shejihezaidaima"
,
"shejihezaidengji"
,
"kangzhendengjidaima"
,
"kangzhendengji"
,
"kuayuediwudaima"
,
"kuayuediwuleixing"
,
"kuayuemingcheng"
,
"tonghangdengji"
,
"fangzhuangleixing"
,
"lijiaoleibie"
,
"jianshedanwei"
,
"shejidanwei"
,
"shigongdanwei"
,
"jianlidanwei"
,
"xiujianniandu"
,
"tongcheriqi"
,
"guanyangdaima"
,
"guanyangmingcheng"
,
"jianguandanweimingcheng"
,
"shoufeixingzhidaima"
,
"shoufeixingzhi"
,
"pingdingdengjidaima"
,
"pingdingdengji"
,
"pingdingdanwei"
,
"pingdingriqi"
,
"gaizaoniandu"
,
"wangongriqi"
,
"gaizaobuwei"
,
"gaizaoshigongdanwei"
,
"gongchengxingzhi"
,
"bubuxiangmu"
,
"binghaidaima"
,
"binghaibuwei"
,
"binghaimiaoshu"
,
"guanzhicuoshidaima"
,
"guanzhicuoshi"
,
"beizhu"
,
"zhuqiaokongshu"
,
"zhuqiaozhukua"
,
"zhuqiaobiankua"
,
"qianyinqiaochang"
,
"houyinqiaochang"
,
"qiaoxiajingkong"
,
"xiabujiegoudaima"
,
"xiabujiegoumingcheng"
,
"qiaotaidaima"
,
"qiaotaimingcheng"
,
"zhizuodaima"
,
"zhizuomingcheng"
,
"qiaomianpuzhuangdaima"
,
"qiaomianpuzhuangmingcheng"
,
"shensuofengdaima"
,
"shensuofengmingcheng"
,
"wanpoxiedaima"
,
"wanpoxiemingcheng"
,
"yuyingliqiao"
,
"zaixiuzaijian"
,
"zhadaomianji"
,
"shejihongshuipinlv"
,
"zongzaojia"
,
"maishezhuanghao"
,
"shifouzhadaoqiao"
,
"shifoushangkuaqiao"
,
"guanlidanweimingcheng"
,
"guanlidanweidaima"
,
"biangengyuanyindaima"
,
"biangengyuanyin"
,
"biangengshijian"
,
"xiangmuxingzhi"
,
"xiangmumingcheng"
,
"jihuaxiangmubianma"
,
"xiangmuleibie"
,
"xiangmudaima"
,
"xiangmuluxianbianma"
,
"xiangmuluxianmingcheng"
,
"xiangmuqiaoliangzhuanghao"
,
"xiangmubiangengyuanyin"
,
"xiangmubiangengshijian"
,
"touzilaiyuan"
,
"qiaoliangsuozaiweizhi"
,
"shifoukuanluzhaiqiao"
,
"shifouzaizhangdaqiaolaingmuluzhong"
,
"tianbaodanweimingcheng"
,
"shape"
,
"qiaokuazuhe"
};
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
ArrayList
<
Basebridgealldata
>
basebridgealldataList
=
new
ArrayList
<>();
for
(
SearchHit
hit
:
hits
)
{
//System.out.println(hit.getSourceAsString());
Map
<
String
,
Object
>
sourceAsMap
=
hit
.
getSourceAsMap
();
//LuKeBridge luKeBridge = new LuKeBridge();
//获取该类在堆区的Class对象
Class
<?>
clazz
=
Class
.
forName
(
"com.elephant.framework.galaxy.aroad.bigdata.Basebridgealldata"
);
//获取私有的构造方法
Constructor
<?>
constructor
=
clazz
.
getDeclaredConstructor
();
//暴力破解
constructor
.
setAccessible
(
true
);
//实例化对象
Basebridgealldata
basebridgealldata
=
(
Basebridgealldata
)
constructor
.
newInstance
();
//获得私有的属性对象
Field
[]
beanFiled
=
clazz
.
getDeclaredFields
();
basebridgealldata
.
setId
(
hit
.
getId
());
for
(
int
a
=
1
;
a
<
bridgeNames
.
length
;
a
++)
{
//暴力破解
beanFiled
[
a
].
setAccessible
(
true
);
//把查询到的每一个字段的值赋给luKeBridge的每一个属性
beanFiled
[
a
].
set
(
basebridgealldata
,
sourceAsMap
.
get
(
bridgeNames
[
a
])
==
null
?
""
:
sourceAsMap
.
get
(
bridgeNames
[
a
]).
toString
());
}
basebridgealldataList
.
add
(
basebridgealldata
);
}
return
basebridgealldataList
;
}
/**
* @Description: 桥梁全字段查询
* @Param:
...
...
@@ -78,7 +236,7 @@ public class EsUtil_fanshe {
* @Author: dongjili
* @Date:
*/
public
static
Map
<
String
,
Object
>
queryBridge
(
String
keyword
,
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
public
static
Map
<
String
,
Object
>
queryBridge
(
String
keyword
,
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
// 搜索数据
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
index
).
setTypes
(
type
).
setFrom
(
start
).
setSize
(
row
);
//isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度)
...
...
@@ -232,11 +390,12 @@ public class EsUtil_fanshe {
}
basebridgealldataList
.
add
(
basebridgealldata
);
}
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
basebridgealldataList
);
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
basebridgealldataList
);
}};
}
/**
* @Description: termquery()桥梁代码词条查询
* @Param:
...
...
@@ -251,7 +410,7 @@ public class EsUtil_fanshe {
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isNotBlank
(
keyword
))
{
//multiMatchQuery多个字段匹配某一个值
//multiMatchQuery(text,fields)其中的fields是字段的名字,可以写好几个,每一个中间用逗号分隔
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
"qiaoliangdaima"
,
keyword
));
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
"qiaoliangdaima"
,
keyword
));
}
String
[]
bridgeNames
=
{
"id"
,
...
...
@@ -397,6 +556,7 @@ public class EsUtil_fanshe {
}
return
basebridgealldataList
;
}
/**
* @Description: 桥梁字段查询查询出一条结果就返回
* @Param:
...
...
@@ -420,14 +580,150 @@ public class EsUtil_fanshe {
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
if
(
hits
.
getHits
().
length
>
0
)
{
if
(
hits
.
getHits
().
length
>
0
)
{
return
true
;
}
else
{
}
else
{
return
false
;
}
}
/**
* @Description: 路段查询所有数据
* @Param:
* @return:
* @Author: dongjili
* @Date: 2019/5/13 0013
*/
public
static
List
<
Basehighwayalldata
>
queryHighWayAll
(
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
//搜索数据
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
index
).
setTypes
(
type
).
setFrom
(
start
).
setSize
(
row
);
//isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度)
//multiMatchQuery多个字段匹配某一个值
//multiMatchQuery(text,fields)其中的fields是字段的名字,可以写好几个,每一个中间用逗号分隔
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
matchAllQuery
());
String
[]
highwayNames
=
{
"id"
,
"luxianbianhao"
,
"quhuadaima"
,
"luxianmingcheng"
,
"qidianmingcheng"
,
"zhidianmingcheng"
,
"Qidianzhuanghao"
,
"zhidianzhuanghao"
,
"licheng"
,
"lichengjisuan"
,
"sanDlicheng"
,
"dengjidaima"
,
"dengjimingcheng"
,
"chedaodaima"
,
"chedaofenlei"
,
"mianchengdaima"
,
"mianchengfenlei"
,
"lujikuandu"
,
"lumiankuandu"
,
"shejishisu"
,
"xiujianniandu"
,
"gaijianniandu"
,
"chengguanlu"
,
"duantoulu"
,
"chongfubianma"
,
"chongfuxuhao"
,
"qidianzhuanghao"
,
"zhongdianzhuanghao"
,
"yanghulicheng"
,
"qingyulicheng"
,
"kelvhaolicheng"
,
"yilvhualicheng"
,
"dimaodaima"
,
"dimaohanzi"
,
"handongshuliang"
,
"maisheqidianzhuanghao"
,
"maishezhidianzhuanghao"
,
"quhuamingchengshi"
,
"quhuamingchengxian"
,
"quhuamingchengxiang"
,
"luduanxuhao"
,
"guanyangdanweileibie"
,
"beizhu"
,
"kaigongriqi"
,
"jungongriqi"
,
"qidianfenjiedianleixing"
,
"zhidianfenjiedianleixing"
,
"shengjichurukou"
,
"GBMlicheng"
,
"yangbanlicheng"
,
"tongcheriqi"
,
"luxiandifangmingcheng"
,
"jianshexingzhidaima"
,
"jianshexingzhihanzi"
,
"duanlianleixing"
,
"luduanleixingdaima"
,
"luduanleixing"
,
"guanyangdanweimingcheng"
,
"MQI"
,
"pingdingdengji"
,
"shoufeixingzhi"
,
"biangengyuanyindaima"
,
"biangengyuanyin"
,
"biangengshijian"
,
"xiangmuxingzhi"
,
"xiangmumingcheng"
,
"xiangmudaima"
,
"xiangmuqidianmingcheng"
,
"xiangmuzhidianmingcheng"
,
"xiangmuleibie"
,
"jihuaxiangmubianma"
,
"xiangmuluxianbianma"
,
"xiangmuluxianmingcheng"
,
"xiangmubiangengyuanyin"
,
"xiangmubiangengshijian"
,
"touzilaiyuan"
,
"miancenghoudu"
,
"zuijinyicidaxiuniandu"
,
"zuijinyicizhongxiuniandu"
,
"guodaotiaozhengqianluxianbianma"
,
"guodaozhuanghaochuandiyuliulicheng"
,
"nianpingjunrijiaotongliang"
,
"shifouanganxiangongluguanlijieyang"
,
"luxiantiaozhengleixing"
,
"shangnianluxianbianma"
,
"shangnianluxianmingcheng"
,
"shangnianluxianqidianzhuanghao"
,
"shangnianluxianzhidianzhuanghao"
,
"tianbaodanweimingcheng"
,
"shape"
};
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
ArrayList
<
Basehighwayalldata
>
basehighwayalldataList
=
new
ArrayList
<>();
for
(
SearchHit
hit
:
hits
)
{
Map
<
String
,
Object
>
sourceAsMap
=
hit
.
getSourceAsMap
();
//LuKeHighWay luKeHighWay = new LuKeHighWay();
//获取该类在堆区的Class对象
Class
<?>
clazz
=
Class
.
forName
(
"com.elephant.framework.galaxy.aroad.bigdata.Basehighwayalldata"
);
//获取私有的构造方法
Constructor
<?>
constructor
=
clazz
.
getDeclaredConstructor
();
//暴力破解
constructor
.
setAccessible
(
true
);
//实例化对象
Basehighwayalldata
basehighwayalldata
=
(
Basehighwayalldata
)
constructor
.
newInstance
();
//获取私有的属性字段
Field
[]
beanFiled
=
clazz
.
getDeclaredFields
();
basehighwayalldata
.
setId
(
hit
.
getId
());
for
(
int
a
=
1
;
a
<
highwayNames
.
length
;
a
++)
{
//暴力破解
beanFiled
[
a
].
setAccessible
(
true
);
//给路段属性复制
beanFiled
[
a
].
set
(
basehighwayalldata
,
sourceAsMap
.
get
(
highwayNames
[
a
])
==
null
?
""
:
sourceAsMap
.
get
(
highwayNames
[
a
]).
toString
());
}
basehighwayalldataList
.
add
(
basehighwayalldata
);
}
return
basehighwayalldataList
;
}
/**
* @Description: 路段全字段查询
* @Param:
...
...
@@ -435,7 +731,7 @@ public class EsUtil_fanshe {
* @Author: dongjili
* @Date:
*/
public
static
HashMap
<
String
,
Object
>
queryHighWay
(
String
keyword
,
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
public
static
HashMap
<
String
,
Object
>
queryHighWay
(
String
keyword
,
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
//搜索数据
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
index
).
setTypes
(
type
).
setFrom
(
start
).
setSize
(
row
);
//isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度)
...
...
@@ -566,11 +862,12 @@ public class EsUtil_fanshe {
}
basehighwayalldataList
.
add
(
basehighwayalldata
);
}
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
basehighwayalldataList
);
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
basehighwayalldataList
);
}};
}
/**
* @Description: termquery()路线编号词条查询
* @Param:
...
...
@@ -585,7 +882,7 @@ public class EsUtil_fanshe {
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isNotBlank
(
keyword
))
{
//multiMatchQuery多个字段匹配某一个值
//multiMatchQuery(text,fields)其中的fields是字段的名字,可以写好几个,每一个中间用逗号分隔
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
"luxianbianhao"
,
keyword
));
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
"luxianbianhao"
,
keyword
));
/*searchRequestBuilder.setQuery(QueryBuilders.matchQuery("luxianbianhao",keyword));*/
}
String
[]
highwayNames
=
{
"id"
,
...
...
@@ -733,14 +1030,105 @@ public class EsUtil_fanshe {
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
if
(
hits
.
getHits
().
length
>
0
)
{
if
(
hits
.
getHits
().
length
>
0
)
{
return
true
;
}
else
{
}
else
{
return
false
;
}
}
/**
* @Description: 隧道查询所有数据
* @Param:
* @return:
* @Author: dongjili
* @Date: 2019/5/13 0013
*/
public
static
List
<
Basetunnelalldata
>
queryTunnelAll
(
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
//搜索数据
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
index
).
setTypes
(
type
).
setFrom
(
start
).
setSize
(
row
);
//isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度)
//multiMatchQuery多个字段匹配某一个值
//multiMatchQuery(text,fields)其中的fields是字段的名字,可以写好几个,每一个中间用逗号分隔
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
matchAllQuery
());
String
[]
basicTunnelNames
=
{
"id"
,
"suidaomingcheng"
,
"suidaodaima"
,
"zhongxinzhuanghao"
,
"luxianbianma"
,
"luxianmingcheng"
,
"jishudengji"
,
"changdu"
,
"jingkuan"
,
"jinggao"
,
"changdufenleidaima"
,
"fenleimingcheng"
,
"shuixiasuidao"
,
"xiujianniandu"
,
"jianshedanwei"
,
"shejidanwei"
,
"shigongdanwei"
,
"jianlidanwei"
,
"tongcheshijian"
,
"shuidaoyanghudengji"
,
"guanyangdanweixingzhi"
,
"guanyangdanweimingcheng"
,
"jianguandanwei"
,
"pingdingdengji"
,
"pingdingriqi"
,
"pingdingdanwei"
,
"pingdingdengjitujian"
,
"pingdingriqitujian"
,
"pingdingdanweitujian"
,
"pingdingdengjijidian"
,
"pingdingriqijidian"
,
"pingdingdanweijidian"
,
"pingdingdengjiqita"
,
"pingdingriqiqita"
,
"pingdingdanweiqita"
,
"gaijianniandu"
,
"wangongriqi"
,
"gaizaibuwei"
,
"gongchengxingzhi"
,
"binghaibuwei"
,
"binghaimiaoshu"
,
"xianjizhengqudaima"
,
"shifouzaizhangdasuidaomuluzhong"
,
"beizhu"
,
"shape"
};
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
List
<
Basetunnelalldata
>
basetunnelalldataList
=
new
ArrayList
<>();
for
(
SearchHit
hit
:
hits
)
{
Map
<
String
,
Object
>
sourceAsMap
=
hit
.
getSourceAsMap
();
//LuKeHighWay luKeHighWay = new LuKeHighWay();
//获取该类在堆区的Class对象
Class
<?>
clazz
=
Class
.
forName
(
"com.elephant.framework.galaxy.aroad.bigdata.Basetunnelalldata"
);
//获取私有的构造方法
Constructor
<?>
constructor
=
clazz
.
getDeclaredConstructor
();
//暴力破解
constructor
.
setAccessible
(
true
);
//实例化对象
Basetunnelalldata
basetunnelalldata
=
(
Basetunnelalldata
)
constructor
.
newInstance
();
//获取私有的属性字段
Field
[]
beanFiled
=
clazz
.
getDeclaredFields
();
basetunnelalldata
.
setId
(
hit
.
getId
());
for
(
int
a
=
1
;
a
<
basicTunnelNames
.
length
;
a
++)
{
//暴力破解
beanFiled
[
a
].
setAccessible
(
true
);
//给路段属性复制
beanFiled
[
a
].
set
(
basetunnelalldata
,
sourceAsMap
.
get
(
basicTunnelNames
[
a
])
==
null
?
""
:
sourceAsMap
.
get
(
basicTunnelNames
[
a
]).
toString
());
}
basetunnelalldataList
.
add
(
basetunnelalldata
);
}
return
basetunnelalldataList
;
}
/**
* @Description: 隧道全字段查询
* @Param:
...
...
@@ -832,11 +1220,12 @@ public class EsUtil_fanshe {
}
basetunnelalldataList
.
add
(
basetunnelalldata
);
}
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
basetunnelalldataList
);
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
basetunnelalldataList
);
}};
}
/**
* @Description: termquery()隧道代码词条匹配查询
* @Param:
...
...
@@ -851,7 +1240,7 @@ public class EsUtil_fanshe {
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isNotBlank
(
keyword
))
{
//multiMatchQuery多个字段匹配某一个值
//multiMatchQuery(text,fields)其中的fields是字段的名字,可以写好几个,每一个中间用逗号分隔
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
"suidaodaima"
,
keyword
));
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
"suidaodaima"
,
keyword
));
}
String
[]
basicTunnelNames
=
{
"id"
,
...
...
@@ -928,6 +1317,7 @@ public class EsUtil_fanshe {
}
return
basetunnelalldataList
;
}
/**
* @Description: 隧道全字段查询,查询出一条就返回
* @Param:
...
...
@@ -950,14 +1340,77 @@ public class EsUtil_fanshe {
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
if
(
hits
.
getHits
().
length
>
0
)
{
if
(
hits
.
getHits
().
length
>
0
)
{
return
true
;
}
else
{
}
else
{
return
false
;
}
}
/**
* @Description: 收费站查询所有数据
* @Param:
* @return:
* @Author: dongjili
* @Date: 2019/5/13 0013
*/
public
static
List
<
BaseRoadToll_String
>
queryBaseRoadTollStringAll
(
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
//搜索数据
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
index
).
setTypes
(
type
).
setFrom
(
start
).
setSize
(
row
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
matchAllQuery
());
String
[]
baseRoadTollNames
=
{
"id"
,
"roadCode"
,
"roadName"
,
"number"
,
"code"
,
"name"
,
"shortName"
,
"tecLevel"
,
"locationType"
,
"tollDirection"
,
"entNum"
,
"entEtcNum"
,
"entMtcNum"
,
"entMixNum"
,
"expNum"
,
"expEtcNum"
,
"expMtcNum"
,
"expMixNum"
,
"managementUnit"
,
"longitude"
,
"latitude"
};
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
ArrayList
<
BaseRoadToll_String
>
baseRoadTollStrings
=
new
ArrayList
<>();
for
(
SearchHit
hit
:
hits
)
{
Map
<
String
,
Object
>
sourceAsMap
=
hit
.
getSourceAsMap
();
//LuKeHighWay luKeHighWay = new LuKeHighWay();
//获取该类在堆区的Class对象
Class
<?>
clazz
=
Class
.
forName
(
"com.elephant.framework.galaxy.aroad.bigdata.BaseRoadToll_String"
);
//获取私有的构造方法
Constructor
<?>
constructor
=
clazz
.
getDeclaredConstructor
();
//暴力破解
constructor
.
setAccessible
(
true
);
//实例化对象
BaseRoadToll_String
baseRoadTollString
=
(
BaseRoadToll_String
)
constructor
.
newInstance
();
//获取私有的属性字段
Field
[]
beanFiled
=
clazz
.
getDeclaredFields
();
baseRoadTollString
.
setId
(
hit
.
getId
());
for
(
int
a
=
1
;
a
<
baseRoadTollNames
.
length
;
a
++)
{
//暴力破解
beanFiled
[
a
].
setAccessible
(
true
);
//给路段属性复制
beanFiled
[
a
].
set
(
baseRoadTollString
,
sourceAsMap
.
get
(
baseRoadTollNames
[
a
])
==
null
?
""
:
sourceAsMap
.
get
(
baseRoadTollNames
[
a
]).
toString
());
}
baseRoadTollStrings
.
add
(
baseRoadTollString
);
}
return
baseRoadTollStrings
;
}
/**
* @Description: 收费站全字段查询
* @Param:
...
...
@@ -1026,9 +1479,9 @@ public class EsUtil_fanshe {
baseRoadTollStrings
.
add
(
baseRoadTollString
);
}
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
baseRoadTollStrings
);
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
baseRoadTollStrings
);
}};
}
...
...
@@ -1053,14 +1506,82 @@ public class EsUtil_fanshe {
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
if
(
hits
.
getHits
().
length
>
0
)
{
if
(
hits
.
getHits
().
length
>
0
)
{
return
true
;
}
else
{
}
else
{
return
false
;
}
}
/**
* @Description: 查询服务区所有数据
* @Param:
* @return:
* @Author: dongjili
* @Date: 2019/5/13 0013
*/
public
static
List
<
BaseHighWayService
>
queryBaseHighWayServiceAll
(
String
index
,
String
type
,
int
start
,
int
row
)
throws
Exception
{
//搜索数据
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
index
).
setTypes
(
type
).
setFrom
(
start
).
setSize
(
row
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
matchAllQuery
());
String
[]
baseRoadTollNames
=
{
"id"
,
"lxbh"
,
"lxmc"
,
"zh1"
,
"fwsslx"
,
"fwssmc"
,
"csyysj"
,
"bjxs"
,
"jyms"
,
"zdmj"
,
"tccmj"
,
"tcwsl"
,
"fwssgnSFycs"
,
"fwssgnSfyjyss"
,
"fwssgnSfyjqss"
,
"fwssgnSfyclcdss"
,
"fwssgnSfycyss"
,
"fwssgnSfycs"
,
"fwssgnSfyzsss"
,
"fwssgnSfyqcwx"
,
"bz"
,
"lxbm"
,
"zh"
,
"jd"
,
"wd"
};
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
ArrayList
<
BaseHighWayService
>
baseHighWayServices
=
new
ArrayList
<>();
for
(
SearchHit
hit
:
hits
)
{
Map
<
String
,
Object
>
sourceAsMap
=
hit
.
getSourceAsMap
();
//LuKeHighWay luKeHighWay = new LuKeHighWay();
//获取该类在堆区的Class对象
Class
<?>
clazz
=
Class
.
forName
(
"com.elephant.framework.galaxy.aroad.bigdata.BaseHighWayService"
);
//获取私有的构造方法
Constructor
<?>
constructor
=
clazz
.
getDeclaredConstructor
();
//暴力破解
constructor
.
setAccessible
(
true
);
//实例化对象
BaseHighWayService
baseHighWayService
=
(
BaseHighWayService
)
constructor
.
newInstance
();
//获取私有的属性字段
Field
[]
beanFiled
=
clazz
.
getDeclaredFields
();
baseHighWayService
.
setId
(
hit
.
getId
());
for
(
int
a
=
1
;
a
<
baseRoadTollNames
.
length
;
a
++)
{
//暴力破解
beanFiled
[
a
].
setAccessible
(
true
);
//给路段属性复制
beanFiled
[
a
].
set
(
baseHighWayService
,
sourceAsMap
.
get
(
baseRoadTollNames
[
a
])
==
null
?
""
:
sourceAsMap
.
get
(
baseRoadTollNames
[
a
]).
toString
());
}
baseHighWayServices
.
add
(
baseHighWayService
);
}
return
baseHighWayServices
;
}
/**
* @Description: 服务区全字段查询
* @Param:
...
...
@@ -1133,9 +1654,9 @@ public class EsUtil_fanshe {
baseHighWayServices
.
add
(
baseHighWayService
);
}
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
baseHighWayServices
);
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"total"
,
hits
.
getTotalHits
());
put
(
"list"
,
baseHighWayServices
);
}};
}
...
...
@@ -1160,9 +1681,9 @@ public class EsUtil_fanshe {
SearchResponse
response
=
searchRequestBuilder
.
get
();
//获取命中次数,查询结果有多少对象
SearchHits
hits
=
response
.
getHits
();
if
(
hits
.
getHits
().
length
>
0
)
{
if
(
hits
.
getHits
().
length
>
0
)
{
return
true
;
}
else
{
}
else
{
return
false
;
}
}
...
...
src/main/java/com/elephant/framework/galaxy/aroad/bigdata/ReadElasticsearch.java
浏览文件 @
880c9bd5
package
com
.
elephant
.
framework
.
galaxy
.
aroad
.
bigdata
;
import
java.util.List
;
/**
* @program: pingxiang_basedata
* @description: ${description}
...
...
@@ -17,31 +15,45 @@ public class ReadElasticsearch {
//分词查询桥梁数据返回list集合
//List<Basebridgealldata> basebridgealldataList = EsUtil_fanshe.queryBridge("广州桥", "basebridgealldata", "2018", 0, 2000000000);
//词条查询桥梁代码数据返回list集合
// List<Basebridgealldata> basebridgealldataList = EsUtil_fanshe.queryBridgeQLDM("G3W371726L0012", "basebridgealldata", "2018", 0, 2000000000);
// for (Basebridgealldata basebridgealldata : basebridgealldataList) {
// System.out.println(basebridgealldata);
// }
//List<Basebridgealldata> basebridgealldataList = EsUtil_fanshe.queryBridgeQLDM("G3W371726L0012", "basebridgealldata", "2018", 0, 2000000000);
//查询桥梁所有数据
//List<Basebridgealldata> basebridgealldataList = EsUtil_fanshe.queryBridgeAll("basebridgealldata", "2018", 0, 2000000000);
/* for (Basebridgealldata basebridgealldata : basebridgealldataList) {
System.out.println(basebridgealldata);
}
*/
//List<Basebridgealldata> basebridgealldataList = EsUtil_fanshe.queryBridge("广州桥", "basebridgealldata", "2018", 0, 2000000000);
//分词查询路段数据返回list集合
//
Array
List<Basehighwayalldata> basehighwayalldataList = EsUtil_fanshe.queryHighWay("广州桥", "basehighwayalldata", "2018", 0, 2000000000);
//List<Basehighwayalldata> basehighwayalldataList = EsUtil_fanshe.queryHighWay("广州桥", "basehighwayalldata", "2018", 0, 2000000000);
//词条查询路线编号数据返回list集合
List
<
Basehighwayalldata
>
basehighwayalldataList
=
EsUtil_fanshe
.
queryHighWayLXBH
(
"S226"
,
"basehighwayalldata"
,
"2018"
,
0
,
2000000000
);
for
(
Basehighwayalldata
basehighwayalldata
:
basehighwayalldataList
)
{
//List<Basehighwayalldata> basehighwayalldataList = EsUtil_fanshe.queryHighWayLXBH("S226", "basehighwayalldata", "2018", 0, 2000000000);
//路段查询所有数据返回
//List<Basehighwayalldata> basehighwayalldataList = EsUtil_fanshe.queryHighWayAll("basehighwayalldata", "2018", 0, 2000000000);
/*for (Basehighwayalldata basehighwayalldata : basehighwayalldataList) {
System.out.println(basehighwayalldata);
}
}*/
//分词查询隧道数据返回list集合
//List<Basetunnelalldata> basetunnelalldataList = EsUtil_fanshe.queryTunnel("港沟", "basetunnelalldata", "2018", 0, 2000000000);
//termquery()隧道代码词条查询返回list集合
//List<Basetunnelalldata> basetunnelalldataList = EsUtil_fanshe.queryTunnelSDDM("S89370112U0010", "basetunnelalldata", "2018", 0, 2000000000);
/* for (Basetunnelalldata basetunnelalldata : basetunnelalldataList) {
//查询隧道所有数据返回
//List<Basetunnelalldata> basetunnelalldataList = EsUtil_fanshe.queryTunnelAll("basetunnelalldata", "2018", 0, 2000000000);
/*for (Basetunnelalldata basetunnelalldata : basetunnelalldataList) {
System.out.println(basetunnelalldata);
}*/
//分词查询收费站数据返回list集合
//ArrayList<BaseRoadToll_String> baseRoadTollStrings = EsUtil_fanshe.queryBaseRoadTollString("广州桥", "baseroadtolldata", "2018", 0, 2000000000);
//List<BaseRoadToll_String> baseRoadTollStrings = EsUtil_fanshe.queryBaseRoadTollString("广州桥", "baseroadtolldata", "2018", 0, 2000000000);
//查询收费站所有数据返回
//List<BaseRoadToll_String> baseRoadTollStrings = EsUtil_fanshe.queryBaseRoadTollStringAll("baseroadtolldata", "2018", 0, 2000000000);
/* for (BaseRoadToll_String baseRoadTollString : baseRoadTollStrings) {
System.out.println(baseRoadTollString.toString());
}*/
//分词查询服务区数据返回list集合
//ArrayList<BaseHighWayService> baseHighWayServices = EsUtil_fanshe.queryBaseHighWayService("京岚线", "basehighwayservice", "2018", 0, 2000000000);
//List<BaseHighWayService> baseHighWayServices = EsUtil_fanshe.queryBaseHighWayService("京岚线", "basehighwayservice", "2018", 0, 2000000000);
//查询服务区所有数据返回
//List<BaseHighWayService> baseHighWayServices = EsUtil_fanshe.queryBaseHighWayServiceAll("basehighwayservice", "2018", 0, 2000000000);
/*for (BaseHighWayService baseHighWayService : baseHighWayServices) {
System.out.println(baseHighWayService);
}*/
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论