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
680cebd0
Commit
680cebd0
authored
Aug 04, 2021
by
李腾威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日常管理-警情填报及归并逻辑处理
parent
33983f8a
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
948 additions
and
45 deletions
+948
-45
pom.xml
...ule/amos-boot-module-api/amos-boot-module-tzs-api/pom.xml
+5
-0
AlertCalledDto.java
.../yeejoin/amos/boot/module/tzs/api/dto/AlertCalledDto.java
+5
-1
ESAlertCalledDto.java
...eejoin/amos/boot/module/tzs/api/dto/ESAlertCalledDto.java
+93
-0
ESAlertCalledRequestDto.java
...amos/boot/module/tzs/api/dto/ESAlertCalledRequestDto.java
+23
-0
AlertCalled.java
.../yeejoin/amos/boot/module/tzs/api/entity/AlertCalled.java
+30
-0
ESAlertCalled.java
...eejoin/amos/boot/module/tzs/api/entity/ESAlertCalled.java
+99
-0
AlertStageEnums.java
...ejoin/amos/boot/module/tzs/api/enums/AlertStageEnums.java
+1
-1
AlertCalledController.java
...boot/module/tzs/biz/controller/AlertCalledController.java
+130
-40
AlertFormController.java
...s/boot/module/tzs/biz/controller/AlertFormController.java
+177
-0
ESAlertCalledRepository.java
...amos/boot/module/tzs/biz/dao/ESAlertCalledRepository.java
+18
-0
AlertCalledServiceImpl.java
...t/module/tzs/biz/service/impl/AlertCalledServiceImpl.java
+122
-3
ESAlertCalledService.java
...oot/module/tzs/biz/service/impl/ESAlertCalledService.java
+245
-0
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/pom.xml
View file @
680cebd0
...
@@ -15,6 +15,11 @@
...
@@ -15,6 +15,11 @@
<artifactId>
amos-boot-biz-common
</artifactId>
<artifactId>
amos-boot-biz-common
</artifactId>
<version>
${amos-biz-boot.version}
</version>
<version>
${amos-biz-boot.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.amosframework.boot
</groupId>
<artifactId>
amos-boot-module-common-api
</artifactId>
<version>
${amos-biz-boot.version}
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/dto/AlertCalledDto.java
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
dto
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
dto
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
...
@@ -27,6 +28,9 @@ public class AlertCalledDto extends BaseDto {
...
@@ -27,6 +28,9 @@ public class AlertCalledDto extends BaseDto {
@ApiModelProperty
(
value
=
"警情来源类型"
)
@ApiModelProperty
(
value
=
"警情来源类型"
)
private
String
alertSource
;
private
String
alertSource
;
@ApiModelProperty
(
value
=
"警情来源类型code"
)
private
String
alertSourceCode
;
@ApiModelProperty
(
value
=
"接警时间"
)
@ApiModelProperty
(
value
=
"接警时间"
)
private
Date
callTime
;
private
Date
callTime
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/dto/ESAlertCalledDto.java
0 → 100644
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
dto
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.util.Date
;
/**
*
* <pre>
* 警情信息ES dto对象
* </pre>
*
* @author gwb
* @version $Id: ESAlertCalledDto.java, v 0.1 2021年6月23日 下午1:52:07 gwb Exp $
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"ESAlertCalledDto"
,
description
=
"ES警情信息"
)
public
class
ESAlertCalledDto
extends
BaseDto
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
/**
* 警情状态
*/
@ApiModelProperty
(
value
=
"警情状态"
)
private
Boolean
alertStatus
;
/**
* 警情阶段
*/
@ApiModelProperty
(
value
=
"警情阶段"
)
private
String
alertStage
;
/**
* 联系人姓名
*/
@ApiModelProperty
(
value
=
"联系人姓名"
)
private
String
contactUser
;
/**
* 联系人电话
*/
@ApiModelProperty
(
value
=
"联系人电话"
)
private
String
contactPhone
;
/**
* 接警时间
*/
@ApiModelProperty
(
value
=
"接警时间"
)
private
Date
callTime
;
/**
* 接警时间
*/
@ApiModelProperty
(
value
=
"接警时间戳"
)
private
Long
callTimeLong
;
/**
* 警情类型
*/
@ApiModelProperty
(
value
=
"警情类型"
)
private
String
alarmType
;
/**
* 警情类型code
*/
@ApiModelProperty
(
value
=
"警情类型code"
)
private
String
alarmTypeCode
;
/**
* 事发单位
*/
@ApiModelProperty
(
value
=
"使用单位"
)
private
String
useUnit
;
/**
* 地址
*/
@ApiModelProperty
(
value
=
"地址"
)
private
String
address
;
/**
* 设备识别码
*/
@ApiModelProperty
(
value
=
"设备识别码"
)
private
String
deviceId
;
/**
* 求援人电话
*/
@ApiModelProperty
(
value
=
"求援人电话"
)
private
String
emergencyCall
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/dto/ESAlertCalledRequestDto.java
0 → 100644
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
*
* <pre>
* 警情信息ES请求参数对象
* </pre>
*
* @author gwb
* @version $Id: ESAlertCalledRequestDto.java, v 0.1 2021年6月24日 下午3:30:40 gwb Exp $
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
ESAlertCalledRequestDto
extends
AlertCalledObjsDto
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"警情状态"
)
private
String
[]
alertStatus
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/entity/AlertCalled.java
View file @
680cebd0
...
@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.tzs.api.entity;
...
@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.tzs.api.entity;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
...
@@ -35,6 +37,12 @@ public class AlertCalled extends BaseEntity {
...
@@ -35,6 +37,12 @@ public class AlertCalled extends BaseEntity {
private
String
alertSource
;
private
String
alertSource
;
/**
/**
* 警情来源类型Code
*/
@TableField
(
"alert_source_code"
)
private
String
alertSourceCode
;
/**
* 接警时间
* 接警时间
*/
*/
@TableField
(
"call_time"
)
@TableField
(
"call_time"
)
...
@@ -154,4 +162,26 @@ public class AlertCalled extends BaseEntity {
...
@@ -154,4 +162,26 @@ public class AlertCalled extends BaseEntity {
@TableField
(
"org_code"
)
@TableField
(
"org_code"
)
private
String
orgCode
;
private
String
orgCode
;
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"使用单位"
)
private
String
useUnit
;
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"地址"
)
private
String
address
;
@ApiModelProperty
(
value
=
"接警时间开始---用于列表过滤"
)
@TableField
(
exist
=
false
)
private
Date
callTimeStart
;
@ApiModelProperty
(
value
=
"接警时间结束---用于列表过滤"
)
@TableField
(
exist
=
false
)
private
Date
callTimeEnd
;
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"是否处警"
)
private
Boolean
isFatherAlert
=
false
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/entity/ESAlertCalled.java
0 → 100644
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
entity
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.elasticsearch.annotations.DateFormat
;
import
org.springframework.data.elasticsearch.annotations.Document
;
import
org.springframework.data.elasticsearch.annotations.Field
;
import
org.springframework.data.elasticsearch.annotations.FieldType
;
import
java.util.Date
;
/**
*
* <pre>
* 警情信息ES实体
* </pre>
*
* @author litw
* @date 2021-08-04
*/
@Data
@Accessors
(
chain
=
true
)
@Document
(
indexName
=
"tzs"
,
type
=
"alertCalled"
,
shards
=
1
,
replicas
=
0
)
public
class
ESAlertCalled
{
/** 主键 */
@Id
private
Long
sequenceNbr
;
/**
* 警情状态
*/
@Field
(
type
=
FieldType
.
Boolean
,
index
=
false
)
private
Boolean
alertStatus
;
/**
* 警情状态
*/
@Field
(
type
=
FieldType
.
Text
)
private
String
alertStatusStr
;
/**
* 警情阶段
*/
@Field
(
type
=
FieldType
.
Text
,
index
=
false
)
private
String
alertStage
;
/**
* 联系人姓名
*/
@Field
(
type
=
FieldType
.
Text
)
private
String
contactUser
;
/**
* 联系人电话
*/
@Field
(
type
=
FieldType
.
Text
)
private
String
contactPhone
;
/**
* 接警时间
*/
@Field
(
type
=
FieldType
.
Date
,
format
=
DateFormat
.
basic_date_time
,
index
=
false
)
private
Date
callTime
;
/**
* 接警时间
*/
@Field
(
type
=
FieldType
.
Long
)
private
Long
callTimeLong
;
/**
* 警情类型
*/
@Field
(
type
=
FieldType
.
Text
,
index
=
false
)
private
String
alarmType
;
/**
* 警情类型Code
*/
@Field
(
type
=
FieldType
.
Text
)
private
String
alarmTypeCode
;
/**
* 使用单位
*/
@Field
(
type
=
FieldType
.
Text
,
searchAnalyzer
=
"ik_max_word"
,
analyzer
=
"ik_max_word"
)
private
String
useUnit
;
/**
* 地址
*/
@Field
(
type
=
FieldType
.
Text
,
searchAnalyzer
=
"ik_max_word"
,
analyzer
=
"ik_max_word"
)
private
String
address
;
/**
* 电梯识别码
*/
@Field
(
type
=
FieldType
.
Text
,
searchAnalyzer
=
"ik_max_word"
,
analyzer
=
"ik_max_word"
)
private
String
deviceId
;
/**
* 求援人电话
*/
@Field
(
type
=
FieldType
.
Text
)
private
String
emergencyCall
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/enums/AlertStageEnums.java
View file @
680cebd0
...
@@ -22,7 +22,7 @@ public enum AlertStageEnums {
...
@@ -22,7 +22,7 @@ public enum AlertStageEnums {
DHBJ
(
"233"
,
"电话报警"
),
DHBJ
(
"233"
,
"电话报警"
),
// 警情阶段
// 警情阶段
JJ
(
"
240
"
,
"接警"
),
JJ
(
"
JJQK-247
"
,
"接警"
),
PQ
(
"241"
,
"派遣"
),
PQ
(
"241"
,
"派遣"
),
DD
(
"242"
,
"抵达"
),
DD
(
"242"
,
"抵达"
),
HF
(
"243"
,
"回访"
),
HF
(
"243"
,
"回访"
),
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/AlertCalledController.java
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
controller
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto
;
import
com.yeejoin.amos.boot.biz.common.utils.NameUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledRequestDto
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.AlertCalledServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.AlertCalledServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.ESAlertCalledService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -16,12 +26,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -16,12 +26,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
java.util.Arrays
;
import
java.util.stream.Stream
;
/**
/**
* 警情接警填报记录
* 警情接警填报记录
...
@@ -34,8 +47,12 @@ import java.util.List;
...
@@ -34,8 +47,12 @@ import java.util.List;
@RequestMapping
(
value
=
"/tzs/alert-called"
)
@RequestMapping
(
value
=
"/tzs/alert-called"
)
public
class
AlertCalledController
extends
BaseController
{
public
class
AlertCalledController
extends
BaseController
{
@Autowired
@Autowired
AlertCalledServiceImpl
alertCalledServiceImpl
;
RedisUtils
redisUtils
;
@Autowired
AlertCalledServiceImpl
iAlertCalledService
;
@Autowired
private
ESAlertCalledService
eSAlertCalledService
;
/**
/**
* 新增警情接警填报记录
* 新增警情接警填报记录
...
@@ -45,25 +62,47 @@ public class AlertCalledController extends BaseController {
...
@@ -45,25 +62,47 @@ public class AlertCalledController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/save"
)
@PostMapping
(
value
=
"/save"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增警情接警填报记录"
,
notes
=
"新增警情接警填报记录"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增警情接警填报记录"
,
notes
=
"新增警情接警填报记录"
)
public
ResponseModel
<
AlertCalledDto
>
save
(
@RequestBody
AlertCalledDto
model
)
{
public
ResponseModel
<
AlertCalled
>
save
(
@RequestBody
AlertCalledObjsDto
alertCalledObjsDto
)
{
model
=
alertCalledServiceImpl
.
createWithModel
(
model
);
if
(
ValidationUtil
.
isEmpty
(
alertCalledObjsDto
)
return
ResponseHelper
.
buildResponse
(
model
);
||
ValidationUtil
.
isEmpty
(
alertCalledObjsDto
.
getAlertCalled
())){
throw
new
BadRequest
(
"参数校验失败."
);
}
ReginParams
reginParams
=
JSONObject
.
parseObject
(
null
!=
redisUtils
.
get
(
buildKey
(
getToken
()))
?
redisUtils
.
get
(
buildKey
(
getToken
())).
toString
()
:
null
,
ReginParams
.
class
);
//获取当前登录人公司
Integer
code
=
reginParams
.
getCompany
().
getCompanyOrgCode
();
AlertCalled
alertCalled
=
alertCalledObjsDto
.
getAlertCalled
();
alertCalled
.
setOrgCode
(
String
.
valueOf
(
code
));
alertCalledObjsDto
.
setAlertCalled
(
alertCalled
);
alertCalledObjsDto
=
iAlertCalledService
.
createAlertCalled
(
alertCalledObjsDto
);
return
ResponseHelper
.
buildResponse
(
alertCalledObjsDto
.
getAlertCalled
());
}
}
/**
/**
* 根据id删除
*
*
* <pre>
* @param id 主键
* 相似警情分页查询
* @return
* </pre>
*/
*
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
* @param
@DeleteMapping
(
value
=
"/{id}"
)
* @param current
@ApiOperation
(
httpMethod
=
"DELETE"
,
value
=
"根据id删除警情接警填报记录"
,
notes
=
"根据id删除警情接警填报记录"
)
* @param size
public
ResponseModel
<
Boolean
>
deleteByid
(
HttpServletRequest
request
,
@PathVariable
(
value
=
"id"
)
Long
id
){
* @return
return
ResponseHelper
.
buildResponse
(
alertCalledServiceImpl
.
removeById
(
id
));
* @throws Exception
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
value
=
"相似警情分页查询"
)
@PostMapping
(
value
=
"/page/similar"
)
public
ResponseModel
<
Page
<
ESAlertCalledDto
>>
pageBySimilar
(
@RequestBody
ESAlertCalledRequestDto
alertCalledVo
,
@RequestParam
(
value
=
"current"
)
int
current
,
@RequestParam
(
value
=
"size"
)
int
size
)
throws
Exception
{
return
ResponseHelper
.
buildResponse
(
eSAlertCalledService
.
queryByKeys
(
alertCalledVo
,
current
,
size
));
}
}
/**
/**
* 根据id查询
* 根据id查询
*
*
...
@@ -73,37 +112,88 @@ public class AlertCalledController extends BaseController {
...
@@ -73,37 +112,88 @@ public class AlertCalledController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/{id}"
)
@GetMapping
(
value
=
"/{id}"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据id查询单个警情接警填报记录"
,
notes
=
"根据id查询单个警情接警填报记录"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据id查询单个警情接警填报记录"
,
notes
=
"根据id查询单个警情接警填报记录"
)
public
ResponseModel
<
AlertCalledDto
>
selectOne
(
@PathVariable
Long
id
)
{
public
ResponseModel
<
Object
>
selectOne
(
@PathVariable
Long
id
)
{
return
ResponseHelper
.
buildResponse
(
alertCalledServiceImpl
.
queryBySeq
(
id
));
return
ResponseHelper
.
buildResponse
(
iAlertCalledService
.
selectAlertCalledById
(
id
));
}
}
/**
/**
* 列表分页查询
* 列表分页查询
*
*
* @param
current
当前页
* @param
pageNum
当前页
* @param
current
每页大小
* @param
pageSize
每页大小
* @return
* @return
*/
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/
page
"
)
@GetMapping
(
value
=
"/
list
"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"警情接警填报记录分页查询"
,
notes
=
"警情接警填报记录分页查询"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"警情接警填报记录分页查询"
,
notes
=
"警情接警填报记录分页查询"
)
public
ResponseModel
<
Page
<
AlertCalledDto
>>
queryForPage
(
@RequestParam
(
value
=
"current"
)
int
current
,
@RequestParam
public
ResponseModel
<
IPage
<
AlertCalled
>>
queryForPage
(
String
pageNum
,
String
pageSize
,
String
sort
,
AlertCalled
alertCalled
)
{
(
value
=
"size"
)
int
size
)
{
Page
<
AlertCalled
>
pageBean
;
Page
<
AlertCalledDto
>
page
=
new
Page
<
AlertCalledDto
>();
IPage
<
AlertCalled
>
page
;
page
.
setCurrent
(
current
);
QueryWrapper
<
AlertCalled
>
alertCalledQueryWrapper
=
new
QueryWrapper
<>();
page
.
setSize
(
size
);
return
ResponseHelper
.
buildResponse
(
alertCalledServiceImpl
.
queryForAlertCalledPage
(
page
));
setQueryWrapper
(
alertCalledQueryWrapper
,
alertCalled
,
sort
);
if
(
StringUtils
.
isBlank
(
pageNum
)
||
StringUtils
.
isBlank
(
pageSize
))
{
pageBean
=
new
Page
<>(
0
,
Long
.
MAX_VALUE
);
}
else
{
pageBean
=
new
Page
<>(
Integer
.
parseInt
(
pageNum
),
Integer
.
parseInt
(
pageSize
));
}
page
=
iAlertCalledService
.
page
(
pageBean
,
alertCalledQueryWrapper
);
return
ResponseHelper
.
buildResponse
(
page
);
}
}
/**
private
QueryWrapper
<
AlertCalled
>
setQueryWrapper
(
QueryWrapper
<
AlertCalled
>
queryWrapper
,
AlertCalled
alertCalled
,
String
sort
){
* 列表全部数据查询
Class
<?
extends
AlertCalled
>
aClass
=
alertCalled
.
getClass
();
*
queryWrapper
.
eq
(
"is_delete"
,
0
);
* @return
*/
if
(
sort
!=
null
)
{
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
// String[] date= sort.split(",");
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"警情接警填报记录列表全部数据查询"
,
notes
=
"警情接警填报记录列表全部数据查询"
)
// if(date[1].equals("ascend")) {
@GetMapping
(
value
=
"/list"
)
// queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
public
ResponseModel
<
List
<
AlertCalledDto
>>
selectForList
()
{
// }else {
return
ResponseHelper
.
buildResponse
(
alertCalledServiceImpl
.
queryForAlertCalledList
());
// queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
// }
}
else
{
queryWrapper
.
orderByDesc
(
"call_time"
);
}
if
(
alertCalled
.
getCallTimeStart
()
!=
null
&&
alertCalled
.
getCallTimeEnd
()
!=
null
)
{
queryWrapper
.
between
(
"call_time"
,
alertCalled
.
getCallTimeStart
(),
alertCalled
.
getCallTimeEnd
());
}
if
(
alertCalled
.
getIsFatherAlert
())
{
// 0:接警;1:处警
queryWrapper
.
isNull
(
"father_alert"
);
}
Stream
<
Field
>
fieldStream
=
Arrays
.
stream
(
aClass
.
getDeclaredFields
()).
filter
(
field
->
{
String
name
=
NameUtils
.
camel2Underline
(
field
.
getName
());
return
!(
"IS_FATHER_ALERT"
.
equals
(
name
));
});
fieldStream
.
forEach
(
field
->
{
try
{
field
.
setAccessible
(
true
);
Object
o
=
field
.
get
(
alertCalled
);
if
(
o
!=
null
&&
!
"serialVersionUID"
.
equals
(
field
.
getName
()))
{
Class
<?>
type
=
field
.
getType
();
String
name
=
NameUtils
.
camel2Underline
(
field
.
getName
());
if
(
type
.
equals
(
Integer
.
class
))
{
Integer
fileValue
=
(
Integer
)
field
.
get
(
alertCalled
);
queryWrapper
.
eq
(
name
,
fileValue
);
}
else
if
(
type
.
equals
(
String
.
class
))
{
String
fileValue
=
(
String
)
field
.
get
(
alertCalled
);
queryWrapper
.
eq
(
name
,
fileValue
);
}
else
if
(
type
.
equals
(
Boolean
.
class
))
{
Boolean
fileValue
=
(
Boolean
)
field
.
get
(
alertCalled
);
queryWrapper
.
eq
(
name
,
fileValue
);
}
else
if
(
type
.
equals
(
Long
.
class
)
||
"long"
.
equals
(
type
.
toString
()))
{
Long
fileValue
=
(
Long
)
field
.
get
(
alertCalled
);
queryWrapper
.
eq
(
name
,
fileValue
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"系统异常"
);
}
});
return
queryWrapper
;
}
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/AlertFormController.java
0 → 100644
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.biz.common.utils.NameUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertFormInitDto
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertForm
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.AlertFormServiceImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* 警情表单
*
* @author tb
* @date 2021-06-17
*/
@RestController
@Api
(
tags
=
"警情表单Api"
)
@RequestMapping
(
value
=
"/alert-form"
)
public
class
AlertFormController
extends
BaseController
{
@Autowired
AlertFormServiceImpl
iAlertFormService
;
@Autowired
RedisUtils
redisUtils
;
@Value
(
"${redis.cache.failure.time}"
)
private
long
time
;
/**
* 新增警情表单
* @return
*/
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/save"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增警情表单"
,
notes
=
"新增警情表单"
)
public
boolean
saveAlertForm
(
HttpServletRequest
request
,
@RequestBody
AlertForm
alertForm
){
return
iAlertFormService
.
save
(
alertForm
);
}
/**
* 根据id删除
* @param id
* @return
*/
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@ApiOperation
(
httpMethod
=
"DELETE"
,
value
=
"根据id删除"
,
notes
=
"根据id删除"
)
public
boolean
deleteById
(
HttpServletRequest
request
,
@PathVariable
Long
id
){
return
iAlertFormService
.
removeById
(
id
);
}
/**
* 修改警情表单
* @return
*/
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/updateById"
,
method
=
RequestMethod
.
PUT
)
@ApiOperation
(
httpMethod
=
"PUT"
,
value
=
"修改警情表单"
,
notes
=
"修改警情表单"
)
public
boolean
updateByIdAlertForm
(
HttpServletRequest
request
,
@RequestBody
AlertForm
alertForm
){
return
iAlertFormService
.
updateById
(
alertForm
);
}
/**
* 根据id查询
* @param id
* @return
*/
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据id查询"
,
notes
=
"根据id查询"
)
public
AlertForm
selectById
(
HttpServletRequest
request
,
@PathVariable
Long
id
){
return
iAlertFormService
.
getById
(
id
);
}
/**
* 根据表态类型code查询表单数据项
* @param code
* @return
*/
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/form/{code}"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据表态类型code查询表单数据项"
,
notes
=
"根据表态类型code查询表单数据项"
)
public
ResponseModel
<
Object
>
selectFormdItem
(
HttpServletRequest
request
,
@PathVariable
String
code
){
List
<
AlertFormInitDto
>
list
=
new
ArrayList
<
AlertFormInitDto
>();
if
(
redisUtils
.
hasKey
(
RedisKey
.
FORM_CODE
+
code
)){
Object
obj
=
redisUtils
.
get
(
RedisKey
.
FORM_CODE
+
code
);
return
ResponseHelper
.
buildResponse
(
obj
);
}
else
{
list
=
iAlertFormService
.
getFormlist
(
code
);
redisUtils
.
set
(
RedisKey
.
FORM_CODE
+
code
,
JSON
.
toJSON
(
list
),
time
);
return
ResponseHelper
.
buildResponse
(
list
);
}
}
/**
* 列表分页查询
* @return
*/
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"列表分页查询"
,
notes
=
"列表分页查询"
)
public
IPage
<
AlertForm
>
listPage
(
String
pageNum
,
String
pageSize
,
AlertForm
alertForm
){
Page
<
AlertForm
>
pageBean
;
QueryWrapper
<
AlertForm
>
alertFormQueryWrapper
=
new
QueryWrapper
<>();
Class
<?
extends
AlertForm
>
aClass
=
alertForm
.
getClass
();
Arrays
.
stream
(
aClass
.
getDeclaredFields
()).
forEach
(
field
->
{
try
{
field
.
setAccessible
(
true
);
Object
o
=
field
.
get
(
alertForm
);
if
(
o
!=
null
)
{
Class
<?>
type
=
field
.
getType
();
String
name
=
NameUtils
.
camel2Underline
(
field
.
getName
());
if
(
type
.
equals
(
Integer
.
class
))
{
Integer
fileValue
=
(
Integer
)
field
.
get
(
alertForm
);
alertFormQueryWrapper
.
eq
(
name
,
fileValue
);
}
else
if
(
type
.
equals
(
Long
.
class
))
{
Long
fileValue
=
(
Long
)
field
.
get
(
alertForm
);
alertFormQueryWrapper
.
eq
(
name
,
fileValue
);
}
else
if
(
type
.
equals
(
String
.
class
))
{
String
fileValue
=
(
String
)
field
.
get
(
alertForm
);
alertFormQueryWrapper
.
eq
(
name
,
fileValue
);
}
else
{
String
fileValue
=
(
String
)
field
.
get
(
alertForm
);
alertFormQueryWrapper
.
eq
(
name
,
fileValue
);
}
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"系统异常"
);
}
});
IPage
<
AlertForm
>
page
;
if
(
StringUtils
.
isBlank
(
pageNum
)
||
StringUtils
.
isBlank
(
pageSize
))
{
pageBean
=
new
Page
<>(
0
,
Long
.
MAX_VALUE
);
}
else
{
pageBean
=
new
Page
<>(
Integer
.
parseInt
(
pageNum
),
Integer
.
parseInt
(
pageSize
));
}
page
=
iAlertFormService
.
page
(
pageBean
,
alertFormQueryWrapper
);
return
page
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/dao/ESAlertCalledRepository.java
0 → 100644
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
dao
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.ESAlertCalled
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.stereotype.Repository
;
/**
*
* <pre>
* 警情信息ES数据查询
* </pre>
*
* @author gwb
* @version $Id: ESAlertCalledRepository.java, v 0.1 2021年6月19日 下午5:12:50 gwb Exp $
*/
@Repository
public
interface
ESAlertCalledRepository
extends
PagingAndSortingRepository
<
ESAlertCalled
,
Long
>
{
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/AlertCalledServiceImpl.java
View file @
680cebd0
...
@@ -2,22 +2,30 @@ package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
...
@@ -2,22 +2,30 @@ package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.FormValue
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.FormValue
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.RepairConsult
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.Template
;
import
com.yeejoin.amos.boot.module.tzs.api.enums.AlertStageEnums
;
import
com.yeejoin.amos.boot.module.tzs.api.mapper.AlertCalledMapper
;
import
com.yeejoin.amos.boot.module.tzs.api.mapper.AlertCalledMapper
;
import
com.yeejoin.amos.boot.module.tzs.api.service.IAlertCalledService
;
import
com.yeejoin.amos.boot.module.tzs.api.service.IAlertCalledService
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -38,6 +46,15 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
...
@@ -38,6 +46,15 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
@Autowired
@Autowired
private
AlertFormValueServiceImpl
iAlertFormValueService
;
private
AlertFormValueServiceImpl
iAlertFormValueService
;
@Autowired
TemplateServiceImpl
templateService
;
@Autowired
private
ESAlertCalledService
eSAlertCalledService
;
@Autowired
private
RepairConsultServiceImpl
repairConsultService
;
/**
/**
* 分页查询
* 分页查询
...
@@ -80,4 +97,105 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
...
@@ -80,4 +97,105 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
return
alertCalledFormVo
;
return
alertCalledFormVo
;
}
}
}
}
/**
*
* <pre>
* 保存警情信息
* </pre>
*
* @param alertCalledObjsDto
* @return
*/
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AlertCalledObjsDto
createAlertCalled
(
AlertCalledObjsDto
alertCalledObjsDto
)
{
try
{
// 警情基本信息
AlertCalled
alertCalled
=
alertCalledObjsDto
.
getAlertCalled
();
alertCalled
.
setCallTime
(
new
Date
());
// 判断是否归并警情
if
(
alertCalled
.
getFatherAlert
()
!=
null
)
{
// 警情归并,设置当前警情状态为结束。
alertCalled
.
setAlertStatus
(
true
);
alertCalled
.
setAlertStage
(
AlertStageEnums
.
JJ
.
getValue
());
alertCalled
.
setAlertStageCode
(
AlertStageEnums
.
JJ
.
getCode
());
alertCalled
.
setType
(
AlertStageEnums
.
JQGB
.
getValue
());
alertCalled
.
setTypeCode
(
AlertStageEnums
.
JQGB
.
getCode
());
this
.
save
(
alertCalled
);
// 动态表单
List
<
AlertFormValue
>
alertFormValuelist
=
alertCalledObjsDto
.
getAlertFormValue
();
// 填充警情主键
alertFormValuelist
.
stream
().
forEach
(
alertFormValue
->
{
alertFormValue
.
setAlertCalledId
(
alertCalled
.
getSequenceNbr
());
alertFormValue
.
setAlertTypeCode
(
alertCalled
.
getAlarmTypeCode
());
});
// 保存动态表单数据
iAlertFormValueService
.
saveBatch
(
alertFormValuelist
);
}
else
{
// 警情报送
// ****************************************************待确认开发
alertCalled
.
setAlertStatus
(
false
);
alertCalled
.
setIsDelete
(
false
);
alertCalled
.
setAlertStage
(
AlertStageEnums
.
JJ
.
getValue
());
alertCalled
.
setAlertStageCode
(
AlertStageEnums
.
JJ
.
getCode
());
alertCalled
.
setType
(
AlertStageEnums
.
JQCB
.
getValue
());
alertCalled
.
setTypeCode
(
AlertStageEnums
.
JQCB
.
getCode
());
this
.
save
(
alertCalled
);
// 动态表单
List
<
AlertFormValue
>
alertFormValuelist
=
alertCalledObjsDto
.
getAlertFormValue
();
// 填充警情主键
alertFormValuelist
.
stream
().
forEach
(
alertFormValue
->
{
alertFormValue
.
setAlertCalledId
(
alertCalled
.
getSequenceNbr
());
alertFormValue
.
setAlertTypeCode
(
alertCalled
.
getAlarmTypeCode
());
});
// 保存动态表单数据
iAlertFormValueService
.
saveBatch
(
alertFormValuelist
);
alertCalledObjsDto
.
setAlertCalled
(
alertCalled
);
alertCalledObjsDto
.
setAlertFormValue
(
alertFormValuelist
);
//保存处置记录-接警
if
(
AlertStageEnums
.
KRJY
.
getCode
().
equals
(
alertCalled
.
getAlarmTypeCode
()))
{
saveRapairConsylt
(
AlertStageEnums
.
JJ
.
getCode
(),
alertCalled
);
}
else
if
(
AlertStageEnums
.
GZWX
.
getCode
().
equals
(
alertCalled
.
getAlarmTypeCode
()))
{
saveRapairConsylt
(
AlertStageEnums
.
JJ
.
getCode
(),
alertCalled
);
}
else
{
saveRapairConsylt
(
AlertStageEnums
.
JJ
.
getCode
(),
alertCalled
);
}
}
/**
* 同步保存ES
*/
eSAlertCalledService
.
saveAlertCalledToES
(
alertCalled
);
return
alertCalledObjsDto
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"报送失败,系统异常!"
);
}
}
private
void
saveRapairConsylt
(
String
typeCode
,
AlertCalled
alertCalled
)
throws
ParseException
{
// 获取警情接警处置记录模板
Template
template
=
templateService
.
getOne
(
new
QueryWrapper
<
Template
>().
eq
(
"type_code"
,
typeCode
).
eq
(
"format"
,
false
));
String
templateContent
=
template
.
getContent
();
String
transferDetails
=
templateContent
.
replace
(
"callTime"
,
DateUtils
.
dateTimeToDateString
(
alertCalled
.
getCallTime
()))
.
replace
(
"user"
,
alertCalled
.
getRecUserName
()).
replace
(
"emergencyCall"
,
alertCalled
.
getEmergencyCall
());
RepairConsult
repairConsult
=
new
RepairConsult
();
repairConsult
.
setParentId
(
alertCalled
.
getSequenceNbr
());
repairConsult
.
setType
(
alertCalled
.
getAlarmTypeCode
());
repairConsult
.
setAlertStageCode
(
alertCalled
.
getAlertStageCode
());
repairConsult
.
setAlertStatus
(
alertCalled
.
getAlertStage
());
repairConsult
.
setContactUser
(
alertCalled
.
getEmergencyPerson
());
repairConsult
.
setContactPhone
(
alertCalled
.
getContactPhone
());
repairConsult
.
setDescription
(
transferDetails
);
repairConsultService
.
save
(
repairConsult
);
}
}
}
\ No newline at end of file
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/ESAlertCalledService.java
0 → 100644
View file @
680cebd0
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledRequestDto
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.ESAlertCalled
;
import
com.yeejoin.amos.boot.module.tzs.api.enums.AlertStatusEnum
;
import
com.yeejoin.amos.boot.module.tzs.biz.dao.ESAlertCalledRepository
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.SearchHit
;
import
org.springframework.data.elasticsearch.core.SearchHits
;
import
org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
javax.annotation.PostConstruct
;
import
java.util.Date
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
*
* <pre>
* 警情信息ES检索服务
* </pre>
*
* @author gwb
* @version $Id: ESAlertCalledService.java, v 0.1 2021年6月19日 下午5:12:01 gwb Exp $
*/
@Service
public
class
ESAlertCalledService
{
@Autowired
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
@Autowired
private
ESAlertCalledRepository
esAlertCalledRepository
;
@Autowired
private
AlertCalledServiceImpl
alertCalledService
;
@Value
(
"${alertcall.es.synchrony.time}"
)
private
Long
time
;
@PostConstruct
public
void
init
()
throws
Exception
{
//初始化ES,重建索引
initEs
();
}
/**
* 重建索引
*/
public
Boolean
initEs
()
throws
Exception
{
esAlertCalledRepository
.
deleteAll
();
/**
* 同步历史48小时以内的警情处置记录
*/
QueryWrapper
<
AlertCalled
>
wrapper
=
new
QueryWrapper
<>();
long
currentTime
=
System
.
currentTimeMillis
()
;
if
(
ValidationUtil
.
isEmpty
(
time
))
//默认为同步48小时
{
currentTime
=
currentTime
-
48
*
60
*
60
*
1000
;
}
else
{
currentTime
=
currentTime
-
time
*
60
*
60
*
1000
;
}
Date
date
=
new
Date
(
currentTime
);
wrapper
.
ge
(
"call_time"
,
date
);
List
<
AlertCalled
>
alertCalleds
=
alertCalledService
.
list
(
wrapper
);
if
(!
ValidationUtil
.
isEmpty
(
alertCalleds
))
{
for
(
AlertCalled
alertCalled
:
alertCalleds
)
{
saveAlertCalledToES
(
alertCalled
);
}
}
return
true
;
}
/**
*
* <pre>
* 根据警情记录批量保存
* </pre>
*
* @param alertCalled 警情信息列表
*/
public
ESAlertCalled
saveAlertCalledToES
(
AlertCalled
alertCalled
)
throws
Exception
{
ESAlertCalled
esAlertCalled
=
new
ESAlertCalled
();
esAlertCalled
.
setSequenceNbr
(
alertCalled
.
getSequenceNbr
());
esAlertCalled
.
setAlarmType
(
alertCalled
.
getAlarmType
());
esAlertCalled
.
setAlarmTypeCode
(
alertCalled
.
getAlarmTypeCode
());
esAlertCalled
.
setCallTime
(
alertCalled
.
getCallTime
());
esAlertCalled
.
setCallTimeLong
(
alertCalled
.
getCallTime
()!=
null
?
alertCalled
.
getCallTime
().
getTime
():
null
);
esAlertCalled
.
setContactPhone
(
alertCalled
.
getContactPhone
());
esAlertCalled
.
setAddress
(
alertCalled
.
getAddress
());
esAlertCalled
.
setAlertStage
(
alertCalled
.
getAlertStage
());
esAlertCalled
.
setAlertStatus
(
alertCalled
.
getAlertStatus
());
esAlertCalled
.
setEmergencyCall
(
alertCalled
.
getEmergencyCall
());
esAlertCalled
.
setDeviceId
(
alertCalled
.
getDeviceId
());
if
(
alertCalled
.
getAlertStatus
())
{
esAlertCalled
.
setAlertStatusStr
(
AlertStatusEnum
.
CLOSED
.
getCode
());
}
else
{
esAlertCalled
.
setAlertStatusStr
(
AlertStatusEnum
.
UNCLOSED
.
getCode
());
}
esAlertCalledRepository
.
save
(
esAlertCalled
);
return
esAlertCalled
;
}
/**
* 根据关键字查询文档,关键字不为空时按相关性从大到小排序
*
* @param alertCalledVo 关键字
* @param current 当前页码
* @param size 页面大小
* @return
*/
@SuppressWarnings
({
"rawtypes"
})
public
Page
<
ESAlertCalledDto
>
queryByKeys
(
ESAlertCalledRequestDto
alertCalledVo
,
int
current
,
int
size
)
{
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
boolMust
=
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
()));
}
}
boolMust
.
must
(
qb0
);
//接警时间,距离当前时间不超过两个小时的
long
currentTime
=
System
.
currentTimeMillis
()
;
currentTime
=
currentTime
-
120
*
60
*
1000
;
BoolQueryBuilder
qb1
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
rangeQuery
(
"callTimeLong"
).
gte
(
currentTime
));
boolMust
.
should
(
qb1
);
//报警电话一致
if
(!
ValidationUtil
.
isEmpty
(
alertCalled
.
getEmergencyCall
())
&&
!
ValidationUtil
.
isEmpty
(
alertCalled
.
getContactPhone
()))
{
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
"emergencyCall.keyword"
,
alertCalled
.
getEmergencyCall
()))
.
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
.
getAlarmTypeCode
()));
boolMust
.
should
(
qb4
);
//使用单位名称一致
if
(!
ValidationUtil
.
isEmpty
(
alertCalled
.
getUseUnit
()))
{
BoolQueryBuilder
qb5
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
"useUnit.keyword"
,
alertCalled
.
getUseUnit
()));
boolMust
.
should
(
qb5
);
}
//电梯识别码一致
if
(!
ValidationUtil
.
isEmpty
(
alertCalled
.
getDeviceId
()))
{
BoolQueryBuilder
qb6
=
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
"deviceId.keyword"
,
alertCalled
.
getDeviceId
()));
boolMust
.
should
(
qb6
);
}
/**
* 困人救援,故障报修,投诉咨询 条件构造
*/
// 创建查询构造器
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
// 分页
.
withPageable
(
PageRequest
.
of
(
current
,
size
))
// 排序
// .withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
//过滤条件
.
withQuery
(
boolMust
);
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