Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
087b24ba
Commit
087b24ba
authored
Sep 21, 2022
by
tangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加120相似警情接口
parent
43d043ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
2 deletions
+148
-2
AlertCalledController.java
...boot/module/jcs/biz/controller/AlertCalledController.java
+26
-0
ESAlertCalledService.java
...oot/module/jcs/biz/service/impl/ESAlertCalledService.java
+122
-2
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/controller/AlertCalledController.java
View file @
087b24ba
...
@@ -322,6 +322,32 @@ public class AlertCalledController extends BaseController {
...
@@ -322,6 +322,32 @@ public class AlertCalledController extends BaseController {
return
ResponseHelper
.
buildResponse
(
esAlertCalledDtoPage
);
return
ResponseHelper
.
buildResponse
(
esAlertCalledDtoPage
);
}
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
value
=
"相似警情分页查询"
)
@PostMapping
(
value
=
"/page/similarby120"
)
public
ResponseModel
<
Page
<
ESAlertCalledDto
>>
pageBySimilar120
(
@RequestBody
ESAlertCalledRequestDto
alertCalledVo
,
@RequestParam
(
value
=
"current"
)
int
current
,
@RequestParam
(
value
=
"size"
)
int
size
)
throws
Exception
{
/*bug 3090 警情填报,相似警情中响应级别错误显示为code 2021-10-13 chenzhao */
Page
<
ESAlertCalledDto
>
esAlertCalledDtoPage
=
eSAlertCalledService
.
queryByKeys
(
alertCalledVo
,
current
,
size
,
"120"
);
List
<
ESAlertCalledDto
>
records
=
esAlertCalledDtoPage
.
getRecords
();
for
(
ESAlertCalledDto
record
:
records
)
{
if
(
record
.
getResponseLevelCode
()
!=
null
)
{
DataDictionary
byCode
=
dataDictionaryService
.
getByCode
(
record
.
getResponseLevelCode
(),
"XYJBR"
);
record
.
setResponseLevel
(
byCode
.
getName
());
}
}
/*bug 3090 警情填报,相似警情中响应级别错误显示为code 2021-10-13 chenzhao */
return
ResponseHelper
.
buildResponse
(
esAlertCalledDtoPage
);
}
/**
/**
* <pre>
* <pre>
* 初始化ES
* 初始化ES
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/ESAlertCalledService.java
View file @
087b24ba
...
@@ -306,14 +306,22 @@ public class ESAlertCalledService {
...
@@ -306,14 +306,22 @@ public class ESAlertCalledService {
boolMust
.
minimumShouldMatch
(
1
);
//至少满足一个
boolMust
.
minimumShouldMatch
(
1
);
//至少满足一个
boolMustAll
.
must
(
boolMust
);
boolMustAll
.
must
(
boolMust
);
// 创建查询构造器
BoolQueryBuilder
qb120
=
QueryBuilders
.
boolQuery
()
.
mustNot
(
QueryBuilders
.
termQuery
(
"alertTypeCode.keyword"
,
"1214"
));
// 创建查询构造器
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
// 分页
// 分页
.
withPageable
(
PageRequest
.
of
(
current
,
size
))
.
withPageable
(
PageRequest
.
of
(
current
,
size
))
// 排序
// 排序
// .withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
// .withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
//过滤条件
//过滤条件
.
withQuery
(
boolMustAll
);
.
withQuery
(
boolMustAll
)
.
withQuery
(
qb120
)
;
List
<
ESAlertCalledDto
>
list
=
new
LinkedList
<>();
List
<
ESAlertCalledDto
>
list
=
new
LinkedList
<>();
long
totle
=
0
;
long
totle
=
0
;
...
@@ -338,5 +346,117 @@ public class ESAlertCalledService {
...
@@ -338,5 +346,117 @@ public class ESAlertCalledService {
return
result
;
return
result
;
}
}
@SuppressWarnings
({
"rawtypes"
})
public
Page
<
ESAlertCalledDto
>
queryByKeys
(
ESAlertCalledRequestDto
alertCalledVo
,
int
current
,
int
size
,
String
type
)
{
Page
<
ESAlertCalledDto
>
result
=
new
Page
<
ESAlertCalledDto
>(
current
,
size
);
String
[]
alertStatus
=
alertCalledVo
.
getAlertStatus
();
if
(
ValidationUtil
.
isEmpty
(
alertStatus
))
{
return
result
;
}
AlertCalled
alertCalled
=
alertCalledVo
.
getAlertCalled
();
if
(
ValidationUtil
.
isEmpty
(
alertCalled
))
{
return
result
;
}
/**
* 通用匹配规则,条件构建
*/
BoolQueryBuilder
boolMustAll
=
QueryBuilders
.
boolQuery
();
//警情状态
BoolQueryBuilder
qb0
=
QueryBuilders
.
boolQuery
();
for
(
String
status
:
alertStatus
)
{
AlertStatusEnum
alertStatusEnum
=
AlertStatusEnum
.
getEnum
(
status
);
if
(!
ValidationUtil
.
isEmpty
(
alertStatusEnum
))
{
qb0
.
should
(
QueryBuilders
.
termQuery
(
"alertStatusStr.keyword"
,
alertStatusEnum
.
getCode
()));
}
}
boolMustAll
.
must
(
qb0
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
//接警时间,距离当前时间不超过半小时的
long
currentTime
=
System
.
currentTimeMillis
()
;
currentTime
=
currentTime
-
30
*
60
*
1000
;
BoolQueryBuilder
qb1
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
rangeQuery
(
"callTimeLong"
).
gte
(
currentTime
));
boolMust
.
should
(
qb1
);
//报警人及报警电话一致
if
(!
ValidationUtil
.
isEmpty
(
alertCalled
.
getContactUser
())
&&
!
ValidationUtil
.
isEmpty
(
alertCalled
.
getContactPhone
()))
{
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
"contactUser.keyword"
,
alertCalled
.
getContactUser
()))
.
must
(
QueryBuilders
.
termQuery
(
"contactPhone.keyword"
,
alertCalled
.
getContactPhone
()));
boolMust
.
should
(
qb2
);
}
//事发地点一致,或相距不超过200米的
if
(!
ValidationUtil
.
isEmpty
(
alertCalled
.
getAddress
()))
{
BoolQueryBuilder
qb3
=
QueryBuilders
.
boolQuery
()
.
should
(
QueryBuilders
.
matchQuery
(
"address"
,
alertCalled
.
getAddress
()));
boolMust
.
should
(
qb3
);
}
//警情类型一致
BoolQueryBuilder
qb4
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
"alertTypeCode.keyword"
,
alertCalled
.
getAlertTypeCode
()));
//boolMust.should(qb4);
//事发单位名称一致
if
(!
ValidationUtil
.
isEmpty
(
alertCalled
.
getUnitInvolved
()))
{
BoolQueryBuilder
qb5
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
matchQuery
(
"unitInvolved"
,
alertCalled
.
getUnitInvolved
()));
boolMust
.
should
(
qb5
);
}
/**
* 一般火灾,条件构造
*/
boolMust
.
minimumShouldMatch
(
1
);
//至少满足一个
boolMustAll
.
must
(
boolMust
);
// 创建查询构造器
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
// 分页
.
withPageable
(
PageRequest
.
of
(
current
,
size
))
// 排序
// .withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
//过滤条件
.
withQuery
(
boolMustAll
)
.
withQuery
(
qb4
)
;
List
<
ESAlertCalledDto
>
list
=
new
LinkedList
<>();
long
totle
=
0
;
try
{
SearchHits
<
ESAlertCalled
>
searchHits
=
elasticsearchTemplate
.
search
(
queryBuilder
.
build
(),
ESAlertCalled
.
class
);
for
(
SearchHit
searchHit
:
searchHits
.
getSearchHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
searchHit
.
getContent
());
ESAlertCalledDto
eSAlertCalled
=
JSONObject
.
toJavaObject
(
jsonObject
,
ESAlertCalledDto
.
class
);
list
.
add
(
eSAlertCalled
);
}
totle
=
searchHits
.
getTotalHits
();
}
catch
(
Exception
e
)
{
// TODO: handle exception
}
result
.
setRecords
(
list
);
result
.
setTotal
(
totle
);
return
result
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment