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
c45b18cd
Commit
c45b18cd
authored
Apr 21, 2022
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预警消息查询接口
parent
f983f414
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
341 additions
and
58 deletions
+341
-58
AlertMsgDto.java
...com/yeejoin/amos/boot/module/tzs/api/dto/AlertMsgDto.java
+29
-0
EsCylinder.java
...m/yeejoin/amos/boot/module/tzs/api/entity/EsCylinder.java
+5
-5
CylinderInfoMapper.java
...os/boot/module/tzs/flc/api/mapper/CylinderInfoMapper.java
+8
-0
CylinderInfoMapper.xml
...-tzs-api/src/main/resources/mapper/CylinderInfoMapper.xml
+10
-0
AlertCalledController.java
...boot/module/tzs/biz/controller/AlertCalledController.java
+3
-35
SpecialEquipmentController.java
...module/tzs/biz/controller/SpecialEquipmentController.java
+51
-17
AlertCalledServiceImpl.java
...t/module/tzs/biz/service/impl/AlertCalledServiceImpl.java
+41
-0
ESCylinderServiceImpl.java
...ot/module/tzs/biz/service/impl/ESCylinderServiceImpl.java
+144
-1
MsgLogServiceImpl.java
...s/boot/module/tzs/biz/service/impl/MsgLogServiceImpl.java
+50
-0
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/dto/AlertMsgDto.java
0 → 100644
View file @
c45b18cd
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @author tb
* @date 2022-04-21.
*/
@Data
public
class
AlertMsgDto
{
@ApiModelProperty
(
value
=
"消息类别"
)
private
String
type
;
@ApiModelProperty
(
value
=
"消息来源"
)
private
String
from
;
@ApiModelProperty
(
value
=
"内容"
)
private
String
body
;
@ApiModelProperty
(
value
=
"消息时间"
)
private
Date
time
;
@ApiModelProperty
(
value
=
"消息关联业务id"
)
private
String
relationId
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/entity/EsCylinder.java
View file @
c45b18cd
...
...
@@ -48,11 +48,11 @@ public class EsCylinder {
// @Field(type = FieldType.Text)
// private String district;
//
//
/**
//
* 所属区域代码
//
*/
//
@Field(type = FieldType.Text, searchAnalyzer = "ik_max_word", analyzer = "ik_max_word")
//
private String regionCode;
/**
* 所属区域代码
*/
@Field
(
type
=
FieldType
.
Text
,
searchAnalyzer
=
"ik_max_word"
,
analyzer
=
"ik_max_word"
)
private
String
regionCode
;
/**
* 产权单位名称
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/mapper/CylinderInfoMapper.java
View file @
c45b18cd
...
...
@@ -65,4 +65,12 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
Page
<
CylinderInfoDto
>
queryPageListByEarlyWarningLevel
(
Page
<
CylinderInfoDto
>
page
,
@Param
(
"earlyWarningLevel"
)
String
earlyWarningLevel
);
CylinderInfoDto
getDetail
(
String
sequenceCode
);
/**
* 查询行政区划下的所有气瓶
*
* @param regionCode
* @return
*/
List
<
CylinderInfoDto
>
listWithRegionCode
(
Integer
regionCode
);
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/resources/mapper/CylinderInfoMapper.xml
View file @
c45b18cd
...
...
@@ -104,4 +104,14 @@
where
ci.sequence_code = #{sequenceCode}
</select>
<select
id=
"listWithRegionCode"
resultType=
"com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto"
>
SELECT
ci.*,
cu.region_code
FROM
`tz_cylinder_info` ci
LEFT JOIN tz_cylinder_unit cu ON cu.app_id = ci.app_id
WHERE
cu.region_code LIKE CONCAT("%", #{regionCode}, "%")
</select>
</mapper>
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 @
c45b18cd
...
...
@@ -131,7 +131,6 @@ public class AlertCalledController extends BaseController {
@Value
(
"${mqtt.topic.alertInfo.push}"
)
private
String
alertInfopushTopic
;
@Autowired
TzsAuthService
tzsAuthService
;
...
...
@@ -721,42 +720,11 @@ public class AlertCalledController extends BaseController {
@GetMapping
(
value
=
"/getActualAlert"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据regionCode 获取区域内实时警情"
,
notes
=
"根据regionCode 获取区域内实时警情"
)
public
ResponseModel
<
List
<
AlertPaperInfoDto
>>
getActualAlert
(
@RequestParam
(
name
=
"regionCodes"
,
required
=
false
)
List
<
String
>
regionCodes
)
{
// 警情id 警情地址 警情状态 警情类型 警情发生时间
List
<
String
>
useRegionCode
=
tzsAuthService
.
getUserRegionCode
();
if
(
regionCodes
==
null
)
{
regionCodes
=
useRegionCode
;
}
else
{
// 判断传入regionCodes 是否越权
List
<
String
>
tempList
=
new
ArrayList
<>();
Iterator
<
String
>
regionIt
=
regionCodes
.
iterator
();
while
(
regionIt
.
hasNext
())
{
String
tempCode
=
regionIt
.
next
();
String
districtCode
=
tempCode
.
substring
(
4
,
6
);
String
provinceCode
=
tempCode
.
substring
(
2
,
6
);
if
(
"0000"
.
equals
(
provinceCode
))
{
// 为省则默认使用用户现有权限查询数据
regionCodes
=
useRegionCode
;
}
else
{
if
(
"00"
.
equals
(
districtCode
))
{
// 为市
if
(!
useRegionCode
.
contains
(
tempCode
))
{
// 不包含该市权限 需要移除市搜索条件 添加 该市下区搜索条件
for
(
String
tempUsercode
:
useRegionCode
)
{
if
(
tempUsercode
.
indexOf
(
tempCode
.
substring
(
0
,
4
))
!=
-
1
)
{
tempList
.
add
(
tempUsercode
);
}
}
regionIt
.
remove
();
}
}
else
{
// 为区 不会出现越权情况
}
}
}
for
(
String
t
:
tempList
)
{
regionCodes
.
add
(
t
);
}
}
return
ResponseHelper
.
buildResponse
(
iAlertCalledService
.
getAlertPaperInfoList
(
regionCodes
,
false
));
return
ResponseHelper
.
buildResponse
(
iAlertCalledService
.
getAlertPaperInfoList
(
iAlertCalledService
.
authRegionCodeList
(
regionCodes
),
false
));
}
/**
* 根据regionCode 获取区域内历史警情 七日内
*/
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/SpecialEquipmentController.java
View file @
c45b18cd
...
...
@@ -9,6 +9,8 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import
com.yeejoin.amos.boot.biz.common.feign.AmosFeignService
;
import
com.yeejoin.amos.boot.biz.common.utils.NameUtils
;
import
com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertMsgDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.ESAlertCalledDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.ElevatorBaseInfoDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.ElevatorDto
;
...
...
@@ -35,20 +37,27 @@ import com.yeejoin.amos.boot.module.tzs.biz.service.impl.ESElevatorServiceImpl;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.ElevatorServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.EquipmentRegionNumServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.MaintainInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.MsgLogServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.TestInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInfoMapper
;
import
com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderInfoServiceImpl
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel
;
import
com.yeejoin.amos.feign.systemctl.model.RegionModel
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javafx.scene.shape.Cylinder
;
import
org.apache.commons.lang3.StringUtils
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -117,6 +126,11 @@ public class SpecialEquipmentController extends BaseController {
@Autowired
ESCylinderServiceImpl
esCylinderService
;
@Autowired
CylinderInfoMapper
cylinderInfoMapper
;
@Autowired
MsgLogServiceImpl
msgLogService
;
/**
* ES查询特种设备信息 带分页 加经纬度过滤 keyword 搜索
...
...
@@ -158,9 +172,12 @@ public class SpecialEquipmentController extends BaseController {
throw
new
BadRequest
(
"参数校验失败."
);
}
if
(
StringUtils
.
isNotBlank
(
esSpecialEquipmentDto
.
getCategoryCode
()))
{
// 查找特定设备
if
(
"3000"
.
equals
(
esSpecialEquipmentDto
.
getCategoryCode
()))
{
if
(
SpecialEquipmentCategoryEnum
.
ELEVATOR
.
getCode
()
.
equals
(
esSpecialEquipmentDto
.
getCategoryCode
()))
{
result
=
esElevatorService
.
queryByDto
(
esSpecialEquipmentDto
);
}
if
(
SpecialEquipmentCategoryEnum
.
PRESSURE_VESSEL
.
getCode
().
equals
(
esSpecialEquipmentDto
.
getCategoryCode
()))
{
result
=
esCylinderService
.
queryByDto
(
esSpecialEquipmentDto
);
}
}
return
ResponseHelper
.
buildResponse
(
result
);
}
...
...
@@ -201,21 +218,20 @@ public class SpecialEquipmentController extends BaseController {
public
ResponseModel
<
Map
<
String
,
Long
>>
queryEquipNum
(
@RequestBody
EsSpecialEquipmentDto
esSpecialEquipmentDto
){
Map
<
String
,
Long
>
result
=
new
HashMap
<>();
// 锅炉
Long
boiler
=
0
l
;
Long
boiler
=
0
L
;
result
.
put
(
"1000"
,
boiler
);
// 压力容器
Long
vessel
=
0
l
;
Long
vessel
=
esCylinderService
.
queryNumberByDto
(
esSpecialEquipmentDto
)
;
result
.
put
(
"2000"
,
vessel
);
// 电梯
Long
elevator
=
esElevatorService
.
queryNumberByDto
(
esSpecialEquipmentDto
);
result
.
put
(
"3000"
,
elevator
);
// 起重机械
Long
crane
=
0
l
;
Long
crane
=
0
L
;
result
.
put
(
"4000"
,
crane
);
// 大型游乐设施
Long
facility
=
0
l
;
Long
facility
=
0
L
;
result
.
put
(
"6000"
,
facility
);
// 大型游乐设施
return
ResponseHelper
.
buildResponse
(
result
);
}
...
...
@@ -238,7 +254,7 @@ public class SpecialEquipmentController extends BaseController {
RegionModel
province
=
userTree
.
get
(
0
);
if
(
"0"
.
equals
(
esSpecialEquipmentDto
.
getSelectType
()))
{
// 获取省聚合
List
<
EquipmentRegionNum
>
list
=
equipmentRegionNumServiceImpl
.
list
(
new
LambdaQueryWrapper
<
EquipmentRegionNum
>().
eq
(
EquipmentRegionNum:
:
getProvinceCode
,
province
.
getRegionCode
()).
eq
(
EquipmentRegionNum:
:
getCategoryCode
,
esSpecialEquipmentDto
.
getCategoryCode
()));
Long
count
=
0
l
;
Long
count
=
0
L
;
for
(
EquipmentRegionNum
t
:
list
)
{
count
+=
t
.
getNum
();
}
...
...
@@ -250,9 +266,9 @@ public class SpecialEquipmentController extends BaseController {
result
.
add
(
tepMap
);
}
else
if
(
"1"
.
equals
(
esSpecialEquipmentDto
.
getSelectType
()))
{
// 获取市聚合
List
<
RegionModel
>
citys
=
(
List
<
RegionModel
>)
province
.
getChildren
();
citys
.
stream
().
forEach
(
c
->
{
citys
.
forEach
(
c
->
{
List
<
EquipmentRegionNum
>
list
=
equipmentRegionNumServiceImpl
.
list
(
new
LambdaQueryWrapper
<
EquipmentRegionNum
>().
eq
(
EquipmentRegionNum:
:
getCityCode
,
c
.
getRegionCode
()).
eq
(
EquipmentRegionNum:
:
getCategoryCode
,
esSpecialEquipmentDto
.
getCategoryCode
()));
Long
count
=
0
l
;
Long
count
=
0
L
;
for
(
EquipmentRegionNum
t
:
list
)
{
count
+=
t
.
getNum
();
}
...
...
@@ -265,11 +281,11 @@ public class SpecialEquipmentController extends BaseController {
});
}
else
if
(
"2"
.
equals
(
esSpecialEquipmentDto
.
getSelectType
()))
{
// 获取县聚合
List
<
RegionModel
>
citys
=
(
List
<
RegionModel
>)
province
.
getChildren
();
citys
.
stream
().
forEach
(
c
->
{
citys
.
forEach
(
c
->
{
List
<
RegionModel
>
districts
=
(
List
<
RegionModel
>)
c
.
getChildren
();
districts
.
stream
().
forEach
(
d
->
{
districts
.
forEach
(
d
->
{
List
<
EquipmentRegionNum
>
list
=
equipmentRegionNumServiceImpl
.
list
(
new
LambdaQueryWrapper
<
EquipmentRegionNum
>().
eq
(
EquipmentRegionNum:
:
getDistrictCode
,
d
.
getRegionCode
()).
eq
(
EquipmentRegionNum:
:
getCategoryCode
,
esSpecialEquipmentDto
.
getCategoryCode
()));
Long
count
=
0
l
;
Long
count
=
0
L
;
for
(
EquipmentRegionNum
t
:
list
)
{
count
+=
t
.
getNum
();
}
...
...
@@ -298,9 +314,9 @@ public class SpecialEquipmentController extends BaseController {
// 按照最低级来查询数量 保存地址
RegionModel
start
=
tree
.
get
(
0
);
// 省
List
<
RegionModel
>
city
=
(
List
<
RegionModel
>)
start
.
getChildren
();
city
.
stream
().
forEach
(
c
->
{
city
.
forEach
(
c
->
{
List
<
RegionModel
>
district
=
(
List
<
RegionModel
>)
c
.
getChildren
();
district
.
stream
().
forEach
(
d
->
{
district
.
forEach
(
d
->
{
List
<
Elevator
>
list
=
elevatorService
.
list
(
new
LambdaQueryWrapper
<
Elevator
>().
eq
(
Elevator:
:
getIsDelete
,
false
).
like
(
Elevator:
:
getRegionCode
,
d
.
getRegionCode
()));
EquipmentRegionNum
temp
=
new
EquipmentRegionNum
();
temp
.
setCategoryCode
(
"3000"
);
...
...
@@ -311,9 +327,19 @@ public class SpecialEquipmentController extends BaseController {
temp
.
setLongitude
(
d
.
getLongitude
());
temp
.
setNum
((
long
)
list
.
size
());
equipmentRegionNumServiceImpl
.
save
(
temp
);
});
List
<
CylinderInfoDto
>
cylinderInfoList
=
cylinderInfoMapper
.
listWithRegionCode
(
d
.
getRegionCode
());
EquipmentRegionNum
temp1
=
new
EquipmentRegionNum
();
temp1
.
setCategoryCode
(
"2000"
);
temp1
.
setCityCode
(
c
.
getRegionCode
()+
""
);
temp1
.
setDistrictCode
(
d
.
getRegionCode
()+
""
);
temp1
.
setProvinceCode
(
start
.
getRegionCode
()+
""
);
temp1
.
setLatitude
(
d
.
getLatitude
());
temp1
.
setLongitude
(
d
.
getLongitude
());
temp1
.
setNum
((
long
)
cylinderInfoList
.
size
());
equipmentRegionNumServiceImpl
.
save
(
temp1
);
});
});
}
...
...
@@ -328,6 +354,14 @@ public class SpecialEquipmentController extends BaseController {
}
/**
* 根据regionCode 获取区域内实时预警
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/getAlertMsg"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据regionCode 获取区域内实时预警"
,
notes
=
"根据regionCode 获取区域内实时预警"
)
public
ResponseModel
<
List
<
AlertMsgDto
>>
getActualAlert
(
@RequestParam
(
name
=
"regionCodes"
,
required
=
false
)
List
<
String
>
regionCodes
)
{
return
ResponseHelper
.
buildResponse
(
msgLogService
.
queryForAlertMsg
(
regionCodes
));
}
}
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 @
c45b18cd
...
...
@@ -35,6 +35,7 @@ import com.yeejoin.amos.boot.module.tzs.api.enums.DispatchPaperEnums;
import
com.yeejoin.amos.boot.module.tzs.api.enums.TzsCommonParam
;
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.TzsAuthService
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
...
...
@@ -45,6 +46,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
...
...
@@ -53,6 +55,7 @@ import java.util.ArrayList;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -106,6 +109,9 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
@Autowired
VoiceRecordFileServiceImpl
voiceRecordFileServiceImpl
;
@Autowired
TzsAuthService
tzsAuthService
;
private
final
Logger
logger
=
LogManager
.
getLogger
(
AlertCalledServiceImpl
.
class
);
...
...
@@ -683,6 +689,41 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
return
temp
;
}
public
List
<
String
>
authRegionCodeList
(
List
<
String
>
regionCodes
)
{
// 警情id 警情地址 警情状态 警情类型 警情发生时间
List
<
String
>
useRegionCode
=
tzsAuthService
.
getUserRegionCode
();
if
(
regionCodes
==
null
)
{
regionCodes
=
useRegionCode
;
}
else
{
// 判断传入regionCodes 是否越权
List
<
String
>
tempList
=
new
ArrayList
<>();
Iterator
<
String
>
regionIt
=
regionCodes
.
iterator
();
while
(
regionIt
.
hasNext
())
{
String
tempCode
=
regionIt
.
next
();
String
districtCode
=
tempCode
.
substring
(
4
,
6
);
String
provinceCode
=
tempCode
.
substring
(
2
,
6
);
if
(
"0000"
.
equals
(
provinceCode
))
{
// 为省则默认使用用户现有权限查询数据
regionCodes
=
useRegionCode
;
}
else
{
if
(
"00"
.
equals
(
districtCode
))
{
// 为市
if
(!
useRegionCode
.
contains
(
tempCode
))
{
// 不包含该市权限 需要移除市搜索条件 添加 该市下区搜索条件
for
(
String
tempUsercode
:
useRegionCode
)
{
if
(
tempUsercode
.
contains
(
tempCode
.
substring
(
0
,
4
)))
{
tempList
.
add
(
tempUsercode
);
}
}
regionIt
.
remove
();
}
}
else
{
// 为区 不会出现越权情况
}
}
}
regionCodes
.
addAll
(
tempList
);
}
return
regionCodes
;
}
@Override
public
List
<
AlertPaperInfoDto
>
getEquipmentHistory
(
List
<
String
>
regionCodes
,
String
equipmentClassCode
,
Integer
current
,
Integer
pageNum
,
String
equipmentCode
)
{
current
=
pageNum
*
(
current
-
1
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/ESCylinderServiceImpl.java
View file @
c45b18cd
...
...
@@ -10,14 +10,15 @@ import com.yeejoin.amos.boot.module.tzs.api.entity.EsCylinder;
import
com.yeejoin.amos.boot.module.tzs.api.enums.SpecialEquipmentCategoryEnum
;
import
com.yeejoin.amos.boot.module.tzs.biz.dao.ESCylinderRepository
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderUnit
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.entity.EndUser
;
import
com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderUnitServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.EndUserServiceImpl
;
import
org.apache.commons.lang3.StringUtils
;
import
org.elasticsearch.common.geo.GeoPoint
;
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
;
...
...
@@ -50,6 +51,9 @@ public class ESCylinderServiceImpl {
@Autowired
private
EndUserServiceImpl
endUserService
;
@Autowired
private
CylinderUnitServiceImpl
cylinderUnitService
;
/**
* <pre>
* 保存气瓶信息
...
...
@@ -74,6 +78,12 @@ public class ESCylinderServiceImpl {
if
(!
ValidationUtil
.
isEmpty
(
endUser
))
{
esCylinder
.
setAddress
(
endUser
.
getAddress
());
}
CylinderUnit
cylinderUnit
=
cylinderUnitService
.
getOne
(
new
LambdaQueryWrapper
<
CylinderUnit
>().
eq
(
CylinderUnit:
:
getAppId
,
cylinderInfo
.
getAppId
()));
if
(!
ValidationUtil
.
isEmpty
(
cylinderUnit
))
{
esCylinder
.
setRegionCode
(
cylinderUnit
.
getRegionCode
());
}
esCylinder
.
setFactoryNum
(
cylinderInfo
.
getFactoryNum
());
esCylinder
.
setUnitName
(
cylinderInfo
.
getUnitName
());
if
(
StringUtils
.
isNotBlank
(
cylinderInfo
.
getLatitude
())
&&
StringUtils
.
isNotBlank
(
cylinderInfo
.
getLongitude
()))
{
...
...
@@ -161,4 +171,137 @@ public class ESCylinderServiceImpl {
return
result
;
}
public
Long
queryNumberByDto
(
EsSpecialEquipmentDto
esSpecialEquipmentDto
)
{
Double
startLongitude
=
esSpecialEquipmentDto
.
getStartLongitude
();
Double
startLatitude
=
esSpecialEquipmentDto
.
getStartLatitude
();
Double
endLongitude
=
esSpecialEquipmentDto
.
getEndLongitude
();
Double
endLatitude
=
esSpecialEquipmentDto
.
getEndLatitude
();
String
regionCode
=
esSpecialEquipmentDto
.
getRegionCode
();
String
keyword
=
esSpecialEquipmentDto
.
getKeyword
();
/**
* 通用匹配规则,条件构建
*/
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
// 经度比start 大比end 小 纬度比start 小 比end 大
if
(!
ValidationUtil
.
isEmpty
(
startLongitude
)
&&
!
ValidationUtil
.
isEmpty
(
startLatitude
)
&&
!
ValidationUtil
.
isEmpty
(
endLongitude
)
&&
!
ValidationUtil
.
isEmpty
(
endLatitude
))
{
BoolQueryBuilder
longLatMust
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
qb1
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
"longitude"
).
gte
(
startLongitude
).
lte
(
endLongitude
));
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
"latitude"
).
gte
(
endLatitude
).
lte
(
startLatitude
));
longLatMust
.
must
(
qb1
);
longLatMust
.
must
(
qb2
);
boolMust
.
must
(
longLatMust
);
}
if
(!
ValidationUtil
.
isEmpty
(
regionCode
))
{
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
().
filter
(
QueryBuilders
.
matchPhraseQuery
(
"regionCode"
,
regionCode
));
boolMust
.
must
(
qb2
);
}
if
(!
ValidationUtil
.
isEmpty
(
keyword
))
{
BoolQueryBuilder
qb0
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
matchQuery
(
"factoryNum"
,
keyword
));
boolMust
.
should
(
qb0
);
BoolQueryBuilder
qb1
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
matchQuery
(
"address"
,
keyword
));
boolMust
.
should
(
qb1
);
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
matchQuery
(
"unitName"
,
keyword
));
boolMust
.
should
(
qb2
);
boolMust
.
minimumShouldMatch
(
1
);
}
// 创建查询构造器
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
// 分页
// .withPageable(PageRequest.of(current, size))
// 排序
// .withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
//过滤条件
.
withQuery
(
boolMust
);
long
total
=
0
;
try
{
SearchHits
<
EsCylinder
>
searchHits
=
elasticsearchTemplate
.
search
(
queryBuilder
.
build
(),
EsCylinder
.
class
);
total
=
searchHits
.
getTotalHits
();
}
catch
(
Exception
e
)
{
// TODO: handle exception
}
return
total
;
}
/**
* 根据特种设备搜索类查找气瓶相关信息
*
* @param esSpecialEquipmentDto
* @return
*/
public
List
<
SpecialEquipmentDto
>
queryByDto
(
EsSpecialEquipmentDto
esSpecialEquipmentDto
)
{
Double
startLongitude
=
esSpecialEquipmentDto
.
getStartLongitude
();
Double
startLatitude
=
esSpecialEquipmentDto
.
getStartLatitude
();
Double
endLongitude
=
esSpecialEquipmentDto
.
getEndLongitude
();
Double
endLatitude
=
esSpecialEquipmentDto
.
getEndLatitude
();
String
regionCode
=
esSpecialEquipmentDto
.
getRegionCode
();
String
keyword
=
esSpecialEquipmentDto
.
getKeyword
();
// 如果传入经纬度则根据经纬度过滤 如果传入regionCode 根据regionCode过滤 如果是 单独查电梯 则返回最多3000条 否则为 400条
/**
* 通用匹配规则,条件构建
*/
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
// 经度比start 大比end 小 纬度比start 小 比end 大
if
(!
ValidationUtil
.
isEmpty
(
startLongitude
)
&&
!
ValidationUtil
.
isEmpty
(
startLatitude
)
&&
!
ValidationUtil
.
isEmpty
(
endLongitude
)
&&
!
ValidationUtil
.
isEmpty
(
endLatitude
))
{
BoolQueryBuilder
longLatMust
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
qb1
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
"longitude"
).
gte
(
startLongitude
).
lte
(
endLongitude
));
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
"latitude"
).
gte
(
endLatitude
).
lte
(
startLatitude
));
longLatMust
.
must
(
qb1
);
longLatMust
.
must
(
qb2
);
boolMust
.
must
(
longLatMust
);
}
if
(!
ValidationUtil
.
isEmpty
(
regionCode
))
{
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
().
filter
(
QueryBuilders
.
matchPhraseQuery
(
"regionCode"
,
regionCode
));
boolMust
.
must
(
qb2
);
}
if
(!
ValidationUtil
.
isEmpty
(
keyword
))
{
BoolQueryBuilder
qb0
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
matchQuery
(
"factoryNum"
,
keyword
));
boolMust
.
should
(
qb0
);
BoolQueryBuilder
qb1
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
matchQuery
(
"address"
,
keyword
));
boolMust
.
should
(
qb1
);
BoolQueryBuilder
qb2
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
matchQuery
(
"unitName"
,
keyword
));
boolMust
.
should
(
qb2
);
boolMust
.
minimumShouldMatch
(
1
);
}
// 创建查询构造器
NativeSearchQuery
query
=
new
NativeSearchQueryBuilder
()
// 分页
// .withPageable(PageRequest.of(0, size))
// 排序
// .withSort(SortBuilders.fieldSort("callTimeLong").order(SortOrder.DESC))
//过滤条件
.
withQuery
(
boolMust
).
build
();
query
.
setTrackTotalHits
(
true
);
query
.
setMaxResults
(
10000
);
List
<
SpecialEquipmentDto
>
list
=
new
LinkedList
<>();
SearchHits
<
EsCylinder
>
searchHits
=
elasticsearchTemplate
.
search
(
query
,
EsCylinder
.
class
);
for
(
SearchHit
searchHit
:
searchHits
.
getSearchHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
searchHit
.
getContent
());
SpecialEquipmentDto
esCylinderDto
=
JSONObject
.
toJavaObject
(
jsonObject
,
SpecialEquipmentDto
.
class
);
esCylinderDto
.
setCategoryCode
(
SpecialEquipmentCategoryEnum
.
PRESSURE_VESSEL
.
getCode
());
esCylinderDto
.
setUnitName
(
jsonObject
.
getString
(
"unitName"
));
esCylinderDto
.
setRegisterCode
(
jsonObject
.
getString
(
"factoryNum"
));
list
.
add
(
esCylinderDto
);
}
return
list
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/MsgLogServiceImpl.java
View file @
c45b18cd
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
service
.
impl
;
import
com.google.common.collect.Lists
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertMsgDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog
;
import
com.yeejoin.amos.boot.module.tzs.api.mapper.MsgLogMapper
;
import
com.yeejoin.amos.boot.module.tzs.api.service.IMsgLogService
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.MsgLogDto
;
import
org.checkerframework.checker.units.qual.A
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -17,6 +25,12 @@ import java.util.List;
*/
@Service
public
class
MsgLogServiceImpl
extends
BaseService
<
MsgLogDto
,
MsgLog
,
MsgLogMapper
>
implements
IMsgLogService
{
Logger
logger
=
LoggerFactory
.
getLogger
(
MsgLogServiceImpl
.
class
);
@Autowired
AlertCalledServiceImpl
alertCalledService
;
/**
* 分页查询
*/
...
...
@@ -30,4 +44,39 @@ public class MsgLogServiceImpl extends BaseService<MsgLogDto,MsgLog,MsgLogMapper
public
List
<
MsgLogDto
>
queryForMsgLogList
()
{
return
this
.
queryForList
(
""
,
false
);
}
public
List
<
MsgLogDto
>
queryForWebMsgLogList
(
String
terminalType
)
{
return
this
.
queryForList
(
""
,
false
,
terminalType
);
}
public
List
<
AlertMsgDto
>
queryForAlertMsg
(
List
<
String
>
regionCodes
)
{
List
<
AlertMsgDto
>
alertMsgDtoList
=
Lists
.
newArrayList
();
// 查询电梯警情预报消息
List
<
AlertPaperInfoDto
>
alertPaperInfoDtoList
=
alertCalledService
.
getAlertPaperInfoList
(
alertCalledService
.
authRegionCodeList
(
regionCodes
),
false
);
if
(!
ValidationUtil
.
isEmpty
(
alertPaperInfoDtoList
))
{
alertPaperInfoDtoList
.
forEach
(
msg
->
{
AlertMsgDto
alertMsgDto
=
new
AlertMsgDto
();
alertMsgDto
.
setBody
(
msg
.
getAddress
());
alertMsgDto
.
setFrom
(
"elevator"
);
alertMsgDto
.
setRelationId
(
String
.
valueOf
(
msg
.
getAlertId
()));
alertMsgDto
.
setTime
(
msg
.
getCallTime
());
alertMsgDto
.
setType
(
msg
.
getAlarmType
());
});
}
// 查询气瓶预警消息
List
<
MsgLogDto
>
msgLogDtoList
=
queryForWebMsgLogList
(
"WEB"
);
if
(!
ValidationUtil
.
isEmpty
(
msgLogDtoList
))
{
msgLogDtoList
.
forEach
(
msg
->
{
AlertMsgDto
alertMsgDto
=
new
AlertMsgDto
();
alertMsgDto
.
setBody
(
msg
.
getBody
());
alertMsgDto
.
setFrom
(
"elevator"
);
alertMsgDto
.
setRelationId
(
String
.
valueOf
(
msg
.
getSequenceNbr
()));
alertMsgDto
.
setTime
(
msg
.
getSendTime
());
alertMsgDto
.
setType
(
msg
.
getMsgTypeName
());
});
}
return
alertMsgDtoList
;
}
}
\ No newline at end of file
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