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
d012287e
Commit
d012287e
authored
Mar 13, 2023
by
tangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物联数据存储es
parent
fcd49c43
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
416 additions
and
118 deletions
+416
-118
pom.xml
...e/amos-boot-module-api/amos-boot-module-equip-api/pom.xml
+4
-0
EquiplistSpecificBySystemESVO.java
...equipmanage/common/dto/EquiplistSpecificBySystemESVO.java
+77
-0
EquipmentSpecificVo.java
...oin/equipmanage/common/entity/vo/EquipmentSpecificVo.java
+1
-1
ElasticSearchClientConfig.java
...yeejoin/equipmanage/config/ElasticSearchClientConfig.java
+55
-0
EquipmentSpecificAlarmLogController.java
...anage/controller/EquipmentSpecificAlarmLogController.java
+13
-2
ESequiplistSpecificBySystemRepository.java
...quipmanage/dao/ESequiplistSpecificBySystemRepository.java
+16
-0
IESeqService.java
...in/java/com/yeejoin/equipmanage/service/IESeqService.java
+26
-0
ESeqServiceImpl.java
...com/yeejoin/equipmanage/service/impl/ESeqServiceImpl.java
+151
-0
EquipmentSpecificAlarmLogServiceImpl.java
...ge/service/impl/EquipmentSpecificAlarmLogServiceImpl.java
+26
-62
MqttReceiveServiceImpl.java
...join/equipmanage/service/impl/MqttReceiveServiceImpl.java
+7
-0
AlertSubmittedServiceImpl.java
...odule/jcs/biz/service/impl/AlertSubmittedServiceImpl.java
+16
-52
application.properties
...ot-system-equip/src/main/resources/application.properties
+19
-0
EquipmentSpecificMapper.xml
...uip/src/main/resources/mapper/EquipmentSpecificMapper.xml
+5
-1
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/pom.xml
View file @
d012287e
...
...
@@ -46,6 +46,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-elasticsearch
</artifactId>
</dependency>
<dependency>
<groupId>
com.yeejoin
</groupId>
<artifactId>
amos-component-rule
</artifactId>
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/dto/EquiplistSpecificBySystemESVO.java
0 → 100644
View file @
d012287e
package
com
.
yeejoin
.
equipmanage
.
common
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
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
org.springframework.data.annotation.Id
;
import
java.util.Date
;
/**
* @description:
* @author: tw
* @createDate: 2023/3/13
*/
@Data
@Accessors
(
chain
=
true
)
@Document
(
indexName
=
"equipmen_date"
,
type
=
"eq"
,
shards
=
1
,
replicas
=
0
)
public
class
EquiplistSpecificBySystemESVO
{
@ApiModelProperty
(
value
=
"uuid"
)
@Id
private
String
id
;
@ApiModelProperty
(
value
=
"设备名"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
equipmentSpecificName
;
@ApiModelProperty
(
value
=
"设备id"
)
@Field
(
type
=
FieldType
.
Long
)
private
Long
equipmentSpecificId
;
@ApiModelProperty
(
value
=
"设备编码"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
code
;
@ApiModelProperty
(
value
=
"iot编码"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
iotCode
;
@ApiModelProperty
(
value
=
"指标值"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
value
;
@ApiModelProperty
(
value
=
"指标颜色"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
emergencyLevelColor
;
@ApiModelProperty
(
value
=
"指标值说明"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
valueLabel
;
@ApiModelProperty
(
value
=
"紧急程度"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
emergencyLevel
;
@ApiModelProperty
(
value
=
"紧急程度描述"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
emergencyLevelDescribe
;
@ApiModelProperty
(
value
=
"指标单位"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
unit
;
@ApiModelProperty
(
value
=
"指标名称"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
equipmentIndexName
;
@ApiModelProperty
(
value
=
"指标key"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
equipmentIndexKey
;
@ApiModelProperty
(
value
=
"是否告警"
)
@Field
(
type
=
FieldType
.
Integer
)
private
Integer
isAlarm
;
@ApiModelProperty
(
value
=
"所属系统"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
systemId
;
@ApiModelProperty
(
value
=
"所属系统名称"
)
@Field
(
type
=
FieldType
.
Text
)
private
String
systemName
;
@ApiModelProperty
(
value
=
"上报时间"
)
@Field
(
type
=
FieldType
.
Long
)
private
Long
time
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/vo/EquipmentSpecificVo.java
View file @
d012287e
...
...
@@ -34,7 +34,7 @@ public class EquipmentSpecificVo implements Serializable {
private
int
single
;
@ApiModelProperty
(
value
=
"所属系统"
)
private
int
systemId
;
private
Long
systemId
;
@ApiModelProperty
(
value
=
"物联code"
)
private
String
iotCode
;
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/config/ElasticSearchClientConfig.java
0 → 100644
View file @
d012287e
package
com
.
yeejoin
.
equipmanage
.
config
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpHost
;
import
org.apache.http.auth.AuthScope
;
import
org.apache.http.auth.UsernamePasswordCredentials
;
import
org.apache.http.client.CredentialsProvider
;
import
org.apache.http.impl.client.BasicCredentialsProvider
;
import
org.elasticsearch.client.RestClient
;
import
org.elasticsearch.client.RestClientBuilder
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
ElasticSearchClientConfig
{
@Value
(
"${spring.elasticsearch.rest.uris}"
)
private
String
uris
;
@Value
(
"${elasticsearch.username}"
)
private
String
username
;
@Value
(
"${elasticsearch.password}"
)
private
String
password
;
@Bean
@Qualifier
(
"highLevelClient"
)
public
RestHighLevelClient
restHighLevelClient
()
{
final
CredentialsProvider
credentialsProvider
=
new
BasicCredentialsProvider
();
credentialsProvider
.
setCredentials
(
AuthScope
.
ANY
,
new
UsernamePasswordCredentials
(
username
,
password
));
try
{
String
url
=
uris
.
replace
(
"http://"
,
""
);
final
String
[]
parts
=
StringUtils
.
split
(
url
,
":"
);
HttpHost
httpHost
=
new
HttpHost
(
parts
[
0
],
Integer
.
parseInt
(
parts
[
1
]),
"http"
);
RestClientBuilder
builder
=
RestClient
.
builder
(
httpHost
);
builder
.
setHttpClientConfigCallback
(
httpClientBuilder
->
{
httpClientBuilder
.
disableAuthCaching
();
return
httpClientBuilder
.
setDefaultCredentialsProvider
(
credentialsProvider
);
});
builder
.
setRequestConfigCallback
((
requestConfigBuilder
)->
requestConfigBuilder
.
setConnectTimeout
(
5000
*
1000
).
setSocketTimeout
(
6000
*
1000
));
return
new
RestHighLevelClient
(
builder
);
}
catch
(
Exception
e
)
{
throw
new
IllegalStateException
(
"Invalid ES nodes "
+
"property '"
+
uris
+
"'"
,
e
);
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/EquipmentSpecificAlarmLogController.java
View file @
d012287e
...
...
@@ -5,6 +5,7 @@ import com.yeejoin.equipmanage.common.entity.EquipmentSpecific;
import
com.yeejoin.equipmanage.common.entity.FireFightingSystemEntity
;
import
com.yeejoin.equipmanage.common.utils.CommonResponseUtil
;
import
com.yeejoin.equipmanage.mapper.FireFightingSystemMapper
;
import
com.yeejoin.equipmanage.service.IESeqService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -31,8 +32,8 @@ public class EquipmentSpecificAlarmLogController extends AbstractBaseController
@Autowired
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
;
@Autowired
IESeqService
eSeqService
;
/**
* 获取告警设备日月环比信息
*
...
...
@@ -64,6 +65,16 @@ public class EquipmentSpecificAlarmLogController extends AbstractBaseController
@RequestParam
(
required
=
false
)
int
current
)
{
return
CommonResponseUtil
.
success
(
equipmentSpecificAlarmLogService
.
getEquipAlarmLog
(
code
,
startTime
,
endTime
,
pageSize
,
current
));
}
@RequestMapping
(
value
=
"/getEquipAlarmLogtest"
,
method
=
RequestMethod
.
GET
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"获取设备物联日志"
,
notes
=
"获取设备物联日志"
)
public
ResponseModel
getEquipAlarmLog
(
)
{
eSeqService
.
deleteESEquiplistSpecificBySystemES
();
return
CommonResponseUtil
.
success
();
}
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/dao/ESequiplistSpecificBySystemRepository.java
0 → 100644
View file @
d012287e
package
com
.
yeejoin
.
equipmanage
.
dao
;
import
com.yeejoin.equipmanage.common.dto.EquiplistSpecificBySystemESVO
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.stereotype.Repository
;
/**
* @description:
* @author: tw
* @createDate: 2022/8/24
*/
@Repository
public
interface
ESequiplistSpecificBySystemRepository
extends
PagingAndSortingRepository
<
EquiplistSpecificBySystemESVO
,
Long
>
{
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IESeqService.java
0 → 100644
View file @
d012287e
package
com
.
yeejoin
.
equipmanage
.
service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.equipmanage.common.dto.EquiplistSpecificBySystemESVO
;
import
com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex
;
import
com.yeejoin.equipmanage.common.entity.dto.EquipmentAlarmLogDto
;
import
java.util.List
;
/**
* @description:
* @author: tw
* @createDate: 2023/3/13
*/
public
interface
IESeqService
{
//新增记录
public
EquiplistSpecificBySystemESVO
saveESEquiplistSpecificBySystemESVO
(
EquipmentSpecificIndex
equipmentSpecificIndex
,
String
systemId
,
String
systemName
);
//根据系统id分页查询
public
Page
<
EquipmentAlarmLogDto
>
findAllBySystemId
(
String
systemId
,
Long
startTime
,
Long
endTime
,
int
pageSize
,
int
current
);
//删除数据距今一年前的数据。
public
void
deleteESEquiplistSpecificBySystemES
();
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/ESeqServiceImpl.java
0 → 100644
View file @
d012287e
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.healthmarketscience.jackcess.impl.query.DeleteQueryImpl
;
import
com.healthmarketscience.jackcess.query.BaseSelectQuery
;
import
com.healthmarketscience.jackcess.query.DeleteQuery
;
import
com.yeejoin.equipmanage.common.dto.EquiplistSpecificBySystemESVO
;
import
com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex
;
import
com.yeejoin.equipmanage.common.entity.dto.EquipmentAlarmLogDto
;
import
com.yeejoin.equipmanage.common.exception.BaseException
;
import
com.yeejoin.equipmanage.dao.ESequiplistSpecificBySystemRepository
;
import
com.yeejoin.equipmanage.service.IESeqService
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.index.query.*
;
import
org.elasticsearch.index.reindex.BulkByScrollResponse
;
import
org.elasticsearch.index.reindex.DeleteByQueryAction
;
import
org.elasticsearch.index.reindex.DeleteByQueryRequest
;
import
org.elasticsearch.index.reindex.DeleteByQueryRequestBuilder
;
import
org.elasticsearch.search.sort.SortBuilders
;
import
org.elasticsearch.search.sort.SortOrder
;
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.mapping.IndexCoordinates
;
import
org.springframework.data.elasticsearch.core.query.CriteriaQuery
;
import
org.springframework.data.elasticsearch.core.query.NativeSearchQuery
;
import
org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder
;
import
org.springframework.data.elasticsearch.core.query.Query
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.beans.BeanUtils
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
static
jdk
.
nashorn
.
internal
.
objects
.
Global
.
println
;
/**
* @description:
* @author: tw
* @createDate: 2023/3/13
*/
@Service
public
class
ESeqServiceImpl
implements
IESeqService
{
@Autowired
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
@Autowired
private
ESequiplistSpecificBySystemRepository
esequiplistSpecificBySystemRepository
;
@Value
(
"${es.ESEquiplistSpecific.flag}"
)
private
boolean
flag
;
@Value
(
"${es.ESEquiplistSpecific.year}"
)
private
int
year
;
@Override
@Async
(
"equipAsyncExecutor"
)
public
EquiplistSpecificBySystemESVO
saveESEquiplistSpecificBySystemESVO
(
EquipmentSpecificIndex
equipmentSpecificIndex
,
String
systemId
,
String
systemName
)
{
EquiplistSpecificBySystemESVO
equiplistSpecificBySystemESVO
=
new
EquiplistSpecificBySystemESVO
();
try
{
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equiplistSpecificBySystemESVO
);
equiplistSpecificBySystemESVO
.
setId
(
UUID
.
randomUUID
().
toString
());
equiplistSpecificBySystemESVO
.
setTime
(
new
Date
().
getTime
());
equiplistSpecificBySystemESVO
.
setSystemId
(
systemId
);
equiplistSpecificBySystemESVO
.
setSystemName
(
systemName
);
esequiplistSpecificBySystemRepository
.
save
(
equiplistSpecificBySystemESVO
);
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
"es新增报错"
);
}
return
equiplistSpecificBySystemESVO
;
}
@Override
public
Page
<
EquipmentAlarmLogDto
>
findAllBySystemId
(
String
systemId
,
Long
startTime
,
Long
endTime
,
int
pageSize
,
int
current
)
{
Page
<
EquipmentAlarmLogDto
>
pageBean
=
new
Page
<
EquipmentAlarmLogDto
>(
current
,
pageSize
);
//组装查询
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
.
withQuery
(
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
"systemId"
,
systemId
))
.
must
(
QueryBuilders
.
termQuery
(
"isAlarm"
,
0
))
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lte
(
endTime
))
)
.
withPageable
(
PageRequest
.
of
(
current
-
1
,
pageSize
))
.
withSort
(
SortBuilders
.
fieldSort
(
"time"
).
order
(
SortOrder
.
DESC
));
List
<
EquipmentAlarmLogDto
>
list
=
new
LinkedList
<
EquipmentAlarmLogDto
>();
try
{
SearchHits
<
EquiplistSpecificBySystemESVO
>
searchHits
=
elasticsearchTemplate
.
search
(
queryBuilder
.
build
(),
EquiplistSpecificBySystemESVO
.
class
);
for
(
SearchHit
<
EquiplistSpecificBySystemESVO
>
searchHit
:
searchHits
.
getSearchHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSON
.
toJSON
(
searchHit
.
getContent
());
EquiplistSpecificBySystemESVO
equiplistSpecificBySystemESVO
=
JSON
.
toJavaObject
(
jsonObject
,
EquiplistSpecificBySystemESVO
.
class
);
EquipmentAlarmLogDto
da
=
new
EquipmentAlarmLogDto
();
da
.
setId
(
UUID
.
randomUUID
().
toString
());
da
.
setName
(
equiplistSpecificBySystemESVO
.
getEquipmentSpecificName
());
SimpleDateFormat
ft
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
daf
=
new
Date
(
equiplistSpecificBySystemESVO
.
getTime
());
String
time
=
ft
.
format
(
daf
);
da
.
setTime
(
time
);
String
value
=
equiplistSpecificBySystemESVO
.
getValue
();
value
=
getReadableStatus
(
value
);
da
.
setContent
(
equiplistSpecificBySystemESVO
.
getEquipmentIndexName
()+
":"
+
value
);
list
.
add
(
da
);
}
pageBean
.
setRecords
(
list
);
pageBean
.
setTotal
(
searchHits
.
getTotalHits
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
BadRequest
(
"系统异常"
);
}
return
pageBean
;
}
@Override
@Scheduled
(
cron
=
"${es.ESEquiplistSpecific.time}"
)
public
void
deleteESEquiplistSpecificBySystemES
()
{
if
(
flag
){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
calendar
.
add
(
Calendar
.
YEAR
,
-
year
);
Long
endTime
=
calendar
.
getTime
().
getTime
();
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
queryBuilder
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
lte
(
endTime
));
Query
query
=
new
NativeSearchQuery
(
queryBuilder
);
elasticsearchTemplate
.
delete
(
query
,
EquiplistSpecificBySystemESVO
.
class
,
IndexCoordinates
.
of
(
"equipmen_date"
));
}
}
public
String
getReadableStatus
(
String
value
)
{
if
(
"true"
.
equals
(
value
)){
return
"是"
;
}
return
"false"
.
equals
(
value
)?
"否"
:
value
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EquipmentSpecificAlarmLogServiceImpl.java
View file @
d012287e
...
...
@@ -16,6 +16,7 @@ import com.yeejoin.equipmanage.fegin.IotFeign;
import
com.yeejoin.equipmanage.fegin.VideoFeignClient
;
import
com.yeejoin.equipmanage.mapper.EquipmentSpecificAlarmLogMapper
;
import
com.yeejoin.equipmanage.mapper.FireFightingSystemMapper
;
import
com.yeejoin.equipmanage.service.IESeqService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -24,6 +25,8 @@ import org.springframework.stereotype.Service;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.text.SimpleDateFormat
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
/**
...
...
@@ -47,8 +50,8 @@ public class EquipmentSpecificAlarmLogServiceImpl extends ServiceImpl<EquipmentS
@Autowired
IotFeign
iotFeign
;
@Autowired
IESeqService
eSeqService
;
@Override
public
void
updateAlarmLogByIotCodeAndIndexKey
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
...
...
@@ -92,64 +95,30 @@ public class EquipmentSpecificAlarmLogServiceImpl extends ServiceImpl<EquipmentS
}
@Override
public
Page
<
EquipmentAlarmLogDto
>
getEquipAlarmLog
(
String
code
,
String
startTime
,
String
endTime
,
long
pageSize
,
long
current
)
{
public
Page
<
EquipmentAlarmLogDto
>
getEquipAlarmLog
(
String
code
,
String
startTime
,
String
endTime
,
long
pageSize
,
long
current
)
{
Page
<
EquipmentAlarmLogDto
>
pageBean
=
new
Page
<
EquipmentAlarmLogDto
>(
current
,
pageSize
);
QueryWrapper
<
FireFightingSystemEntity
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"code"
,
code
);
FireFightingSystemEntity
sys
=
fireFightingSystemMapper
.
selectOne
(
wrapper
);
if
(
sys
==
null
){
throw
new
BadRequest
(
"系统不存在!"
);
}
String
id
=
sys
.
getId
().
toString
();
//iotcode集合
List
<
String
>
iotCodes
=
new
ArrayList
<>();
//物联参数判断集合
Map
<
String
,
EquiplistSpecificBySystemVO
>
mapkey
=
new
HashMap
<>();
//存储整理后的数据
List
<
EquipmentAlarmLogDto
>
listDate
=
new
ArrayList
<>();
//获取系统下所有装备物联指标
this
.
getEquiplistBySystemIdList
(
id
,
mapkey
,
iotCodes
);
//装备为空返回空
if
(
iotCodes
.
isEmpty
()||
mapkey
.
isEmpty
()){
return
pageBean
;
}
String
iotCode
=
String
.
join
(
","
,
iotCodes
);
try
{
QueryWrapper
<
FireFightingSystemEntity
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"code"
,
code
);
FireFightingSystemEntity
sys
=
fireFightingSystemMapper
.
selectOne
(
wrapper
);
if
(
sys
==
null
){
throw
new
BadRequest
(
"系统不存在!"
);
}
String
systemId
=
sys
.
getId
().
toString
();
//获取时间梭
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
endTime
=
endTime
.
replace
(
"00:00:00"
,
"23:59:59"
);
IndexLogsRequest
indexLogsRequest
=
new
IndexLogsRequest
(
startTime
,
endTime
,
"YJ210093SBMC0001FHS_FirePump_PowerRunStatus"
,
current
,
pageSize
);
Long
LongstartTime
=
format
.
parse
(
startTime
).
getTime
(
);
//调用iot 获取数据
ResponseModel
<
Map
<
String
,
Object
>>
date
=
iotFeign
.
getEquipAlarmLog
(
indexLogsRequest
);
if
(
date
.
getStatus
()
!=
200
)
{
throw
new
BadRequest
(
"系统错误!"
);
}
Map
<
String
,
Object
>
listObject
=
date
.
getResult
();
if
(
listObject
!=
null
)
{
List
<
Map
<
String
,
Object
>>
listObjectdate
=(
List
<
Map
<
String
,
Object
>>)
listObject
.
get
(
"records"
);
//数据处理
for
(
Map
<
String
,
Object
>
map
:
listObjectdate
)
{
//过滤告警
String
key
=
map
.
get
(
"iotCode"
).
toString
()+
map
.
get
(
"indexName"
);
if
(
mapkey
.
containsKey
(
key
)){
EquipmentAlarmLogDto
da
=
new
EquipmentAlarmLogDto
();
da
.
setId
(
UUID
.
randomUUID
().
toString
());
da
.
setName
(
mapkey
.
get
(
key
).
getEquipmentName
());
da
.
setTime
(
map
.
get
(
"createdTime"
).
toString
());
String
value
=
map
.
get
(
"indexValue"
).
toString
();
value
=
getReadableStatus
(
value
);
da
.
setContent
(
mapkey
.
get
(
key
).
getIndexName
()+
":"
+
value
);
listDate
.
add
(
da
);
}
}
}
pageBean
.
setRecords
(
listDate
);
//由于iot 分页 ,没有数据时返回int,有数据时返回字符串,还是Double类型字符串,需统一处理。
Double
tot
=
Double
.
valueOf
(
listObject
.
get
(
"total"
).
toString
());
pageBean
.
setTotal
(
tot
.
intValue
());
Long
LongendTime
=
format
.
parse
(
endTime
.
replace
(
"00:00:00"
,
"23:59:59"
)).
getTime
();
pageBean
=
eSeqService
.
findAllBySystemId
(
systemId
,
LongstartTime
,
LongendTime
,
(
int
)
pageSize
,
(
int
)
current
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
BadRequest
(
"系统异常"
);
}
return
pageBean
;
}
...
...
@@ -157,12 +126,7 @@ public class EquipmentSpecificAlarmLogServiceImpl extends ServiceImpl<EquipmentS
public
String
getReadableStatus
(
String
value
)
{
if
(
"true"
.
equals
(
value
)){
return
"是"
;
}
return
"false"
.
equals
(
value
)?
"否"
:
value
;
}
public
void
getEquiplistBySystemIdList
(
String
id
,
Map
<
String
,
EquiplistSpecificBySystemVO
>
map
,
List
<
String
>
iotCodes
)
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java
View file @
d012287e
...
...
@@ -189,6 +189,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Autowired
private
TopographyService
topographyService
;
@Autowired
IESeqService
eSeqService
;
@Autowired
private
IEquipmentService
equipmentService
;
...
...
@@ -389,6 +391,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpeIndex
.
setUpdateDate
(
new
Date
());
equipmentSpeIndex
.
setEquipmentType
(
topicEntity
.
getType
());
equipmentSpeIndex
.
setUUID
(
UUIDUtils
.
getUUID
());
//es存储数据
eSeqService
.
saveESEquiplistSpecificBySystemESVO
(
equipmentSpeIndex
,
String
.
valueOf
(
vo
.
getSystemId
()),
vo
.
getSystemName
());
equipmentSpecificIndexService
.
updateById
(
equipmentSpeIndex
);
// 更新设备表指标状态
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/AlertSubmittedServiceImpl.java
View file @
d012287e
...
...
@@ -134,6 +134,7 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.component.rule.config.RuleConfig
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
...
...
@@ -759,7 +760,6 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
map
.
put
(
"usIds"
,
""
);
}
// alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
for
(
AlertSubmittedObject
object
:
alertSubmittedObjectList
)
{
alertSubmittedObjectServiceImpl
.
save
(
object
);
}
...
...
@@ -820,7 +820,6 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
// 更新所有车辆状态为执勤
equipFeignClient
.
updateCarStatus
(
carStatusInfoDtoList
);
// //跟车辆状态
// powerTransferCompanyResourcesService.update(new UpdateWrapper<PowerTransferCompanyResources>().eq("resources_id", transferCarIdList).set("status", FireCarStatusEnum.返队.getCode()));
}
...
...
@@ -846,7 +845,6 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
SerializerFeature
.
WriteMapNullValue
):
""
;
}
// String json=list4!=null&&list4.size()>0?JSON.toJSONString(list4.get(0), SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue):"";
emqKeeper
.
getMqttClient
().
publish
(
topicJa
,
json
.
getBytes
(),
RuleConfig
.
DEFAULT_QOS
,
false
);
}
...
...
@@ -870,7 +868,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
return
map
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"报送失败,系统异常!"
);
throw
new
BadRequest
(
"报送失败,系统异常!"
);
}
}
...
...
@@ -912,10 +910,6 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
report
.
setToTime
((
DateUtils
.
dateFormat
(
date
,
DateUtils
.
HOUR_PATTERN
)));
// report.setArriveTime((DateUtils.dateFormat(date,DateUtils.HOUR_PATTERN)));
//
// dto.setArriveTime((DateUtils.dateFormat(date,DateUtils.HOUR_PATTERN)));
// list.add(dto);
// 人数
if
(!
ObjectUtils
.
isEmpty
(
dto
.
getPersonNum
())){
totalPeople
=
totalPeople
.
add
(
new
BigDecimal
(
dto
.
getPersonNum
()));
...
...
@@ -958,11 +952,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
AlertCalledPowerInfoDto
dto
=
new
AlertCalledPowerInfoDto
();
handleFunc
(
dto
,
other
.
get
(
i
));
// LocalDateTime dateTime = (LocalDateTime)other.get(i).get("recDate");
// Date date = Date.from(dateTime.toInstant(ZoneOffset.of("+8")));
//
// dto.setArriveTime((DateUtils.dateFormat(date,DateUtils.HOUR_PATTERN)));
// list.add(dto);
if
(!
ObjectUtils
.
isEmpty
(
dto
.
getPersonNum
())){
totalPeople
=
totalPeople
.
add
(
new
BigDecimal
(
dto
.
getPersonNum
()));
}
...
...
@@ -1018,22 +1008,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}
// // 查询应急指挥辅屏值班人员
// List<Map<String, Object>> mapList = iDutyPersonService.listOnDutyPerson();
// List<AlertCallCommandDto> list1 = new ArrayList<>();
// mapList.forEach(e->{
// AlertCallCommandDto dto = new AlertCallCommandDto();
// dto.setName(e.get("userName").toString());
// dto.setDuty(e.get("postTypeName").toString());
// list1.add(dto);
// });
//
// if (mapList.size() == 0) {
// AlertCallCommandDto commandDto = new AlertCallCommandDto();
// commandDto.setName("");
// commandDto.setDuty("");
// list1.add(commandDto);
// }
report
.
setTotalWater
(
String
.
valueOf
(
totalWater
));
report
.
setTotalFoam
(
String
.
valueOf
(
totalFoam
));
...
...
@@ -1048,19 +1023,14 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
String
os
=
System
.
getProperty
(
"os.name"
);
InputStream
resourceAsStream
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
"templates/check-report-template.docx"
);
String
path
=
this
.
getClass
().
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
();
// String checkReportTemplatePath = this.getClass().getClassLoader().getResource("templates/check-report-template" +
// ".docx").getFile();
// String filePath = this.getClass().getClassLoader().getResource("templates").getPath();
String
filePath
=
""
;
String
fileName
=
""
;
if
(
os
.
toLowerCase
().
startsWith
(
"win"
))
{
filePath
=
this
.
getClass
().
getClassLoader
().
getResource
(
"templates"
).
getPath
();
fileName
=
filePath
+
"/"
+
System
.
currentTimeMillis
()
+
".docx"
;
}
else
{
// String [] arr = path.split("amos-boot-system-jcs-1.0.0.jar!");
// System.out.println(arr[0].substring(0,arr[0].lastIndexOf("/")));
// fileName = arr[0].substring(0,arr[0].lastIndexOf("/")) + "/" + System.currentTimeMillis() + ".docx";
fileName
=
"/opt/file/"
+
System
.
currentTimeMillis
()
+
".docx"
;
}
...
...
@@ -1111,13 +1081,10 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
document
.
saveToFile
(
pa1
,
FileFormat
.
Doc
);
}
else
{
document
.
loadFromFile
(
fileName
);
System
.
out
.
println
(
fileName
);
newFileName
=
"/opt/file/"
+
System
.
currentTimeMillis
()+
".doc"
;
System
.
out
.
println
(
newFileName
);
document
.
saveToFile
(
newFileName
,
FileFormat
.
Doc
);
pa1
=
newFileName
;
}
System
.
out
.
println
(
pa1
);
FeignClientResult
<
Map
<
String
,
String
>>
date
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
WordConverterUtils
.
fileToMultipartFile
(
new
File
(
pa1
)));
...
...
@@ -1128,7 +1095,6 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
urlString
=
it
.
next
();
}
}
System
.
out
.
println
(
urlString
);
// 更新警情信息
alertCalled
.
setRecordUrl
(
urlString
);
...
...
@@ -1465,7 +1431,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
});
// 获取归并得警情信息
LambdaQueryWrapper
<
AlertCalled
>
queryWrapper
=
new
LambdaQueryWrapper
();
LambdaQueryWrapper
<
AlertCalled
>
queryWrapper
=
new
LambdaQueryWrapper
<
AlertCalled
>
();
queryWrapper
.
eq
(
AlertCalled:
:
getFatherAlert
,
id
);
List
<
AlertCalled
>
alertCalleds
=
alertCalledService
.
getBaseMapper
().
selectList
(
queryWrapper
);
alertCalleds
.
stream
().
forEach
(
e
->{
...
...
@@ -1482,7 +1448,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
});
//增加自定义指令信息:实战指挥需求【1575】
LambdaQueryWrapper
<
JcSituationDetail
>
qw
=
new
LambdaQueryWrapper
();
LambdaQueryWrapper
<
JcSituationDetail
>
qw
=
new
LambdaQueryWrapper
<
JcSituationDetail
>
();
qw
.
eq
(
JcSituationDetail:
:
getAlertCalledId
,
id
);
List
<
JcSituationDetail
>
jcSituationDetailList
=
jcSituationDetailMapper
.
selectList
(
qw
);
...
...
@@ -1495,7 +1461,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
if
(
item
.
getInfo
().
contains
(
"/photos:"
)){
String
[]
info
=
item
.
getInfo
().
split
(
"/photos:"
);
String
photoUrl
=
info
[
1
];
StringBu
ffer
stringBuffer
=
new
StringBuff
er
();
StringBu
ilder
stringBuffer
=
new
StringBuild
er
();
if
(
photoUrl
.
contains
(
","
)){
List
<
String
>
list
=
Arrays
.
asList
(
photoUrl
.
split
(
","
));
...
...
@@ -1563,7 +1529,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
@SuppressWarnings
(
"unchecked"
)
public
void
ruleCallbackActionForPowerTransferForCar
(
String
smsCode
,
List
sendIds
,
Object
object
,
List
<
Map
<
String
,
Object
>>
pList
)
public
void
ruleCallbackActionForPowerTransferForCar
(
String
smsCode
,
List
<
Object
>
sendIds
,
Object
object
,
List
<
Map
<
String
,
Object
>>
pList
)
throws
IllegalAccessException
,
MqttPersistenceException
,
MqttException
{
List
<
AlertSubmittedObject
>
alertSubmittedObjectList
=
Lists
.
newArrayList
();
...
...
@@ -1608,12 +1574,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}
}
});
List
<
Object
>
companyDetail
=
JSON
Array
.
parseArray
(
JSON
.
toJSON
(
calledRo
.
getCompany
()).
toString
(),
Object
.
class
);
List
<
Object
>
companyDetail
=
JSON
.
parseArray
(
JSON
.
toJSON
(
calledRo
.
getCompany
()).
toString
(),
Object
.
class
);
for
(
Object
powerTransferCompanyDto
:
companyDetail
)
{
PowerTransferCompanyDto
powerDto
=
JSON
.
parseObject
(
JSON
.
toJSON
(
powerTransferCompanyDto
).
toString
(),
PowerTransferCompanyDto
.
class
);
Long
companyId
=
powerDto
.
getCompanyId
();
String
companyName
=
powerDto
.
getCompanyName
();
StringBu
ffer
resourcesNum
=
new
StringBuff
er
();
StringBu
ilder
resourcesNum
=
new
StringBuild
er
();
Set
<
Map
<
String
,
Object
>>
sendUserIds
=
new
HashSet
<
Map
<
String
,
Object
>>();
FireTeam
fireTeam
=
fireTeamServiceImpl
.
getById
(
companyId
);
sendIds
.
stream
().
forEach
(
e
->
{
...
...
@@ -1789,10 +1755,8 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
// 发送任务消息
// 组织短信内容
// 调用短信发送接口
try
{
alertCalledAction
.
sendAlertCalleCmd
(
smsCode
,
mobiles
,
smsParams
);
}
catch
(
Exception
e
)
{
}
alertCalledAction
.
sendAlertCalleCmd
(
smsCode
,
mobiles
,
smsParams
);
Map
<
String
,
String
>
besidesMap
=
new
HashMap
<
String
,
String
>();
besidesMap
.
put
(
"responseLevelString"
,
responseLevelString
);
//响应级别
besidesMap
.
put
(
"alterId"
,
alertCalledId
);
...
...
@@ -1828,7 +1792,7 @@ public Set<Map<String, Object>> getwone(Set<Map<String, Object>> sendUserIds){
@SuppressWarnings
(
"unchecked"
)
public
void
ruleCallbackActionForPowerTransferForSurvBrigade
(
String
smsCode
,
List
sendIds
,
Object
object
,
List
<
Map
<
String
,
Object
>>
pList
)
throws
MqttPersistenceException
,
MqttException
{
public
void
ruleCallbackActionForPowerTransferForSurvBrigade
(
String
smsCode
,
List
<
Object
>
sendIds
,
Object
object
,
List
<
Map
<
String
,
Object
>>
pList
)
throws
MqttPersistenceException
,
MqttException
{
List
<
AlertSubmittedObject
>
alertSubmittedObjectList
=
Lists
.
newArrayList
();
// 查询已绑定车辆人员id
...
...
@@ -1842,7 +1806,7 @@ public Set<Map<String, Object>> getwone(Set<Map<String, Object>> sendUserIds){
String
alertSubmittedId
=
calledRo
.
getAlertSubmittedId
();
alertCalledId
=
calledRo
.
getSequenceNbr
();
Set
<
Map
<
String
,
Object
>>
userIds
=
new
HashSet
<
Map
<
String
,
Object
>>();
List
<
Object
>
companyDetail
=
JSON
Array
.
parseArray
(
JSON
.
toJSON
(
calledRo
.
getCompany
()).
toString
(),
Object
.
class
);
List
<
Object
>
companyDetail
=
JSON
.
parseArray
(
JSON
.
toJSON
(
calledRo
.
getCompany
()).
toString
(),
Object
.
class
);
for
(
Object
e:
sendIds
)
{
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
e
));
if
(
jsonObject
.
containsKey
(
"type"
)
&&(
(
jsonObject
.
getString
(
"type"
).
equals
(
AlertStageEnums
.
ZH
.
getCode
()))
||
jsonObject
.
getString
(
"type"
).
equals
(
AlertStageEnums
.
XJ
.
getCode
())))
{
...
...
@@ -1963,7 +1927,7 @@ public Set<Map<String, Object>> getwone(Set<Map<String, Object>> sendUserIds){
public
void
ruleCallbackActionForPowerTransferForAid
(
String
smsCode
,
List
sendIds
,
Object
object
,
List
<
Map
<
String
,
Object
>>
pList
)
throws
MqttPersistenceException
,
MqttException
{
public
void
ruleCallbackActionForPowerTransferForAid
(
String
smsCode
,
List
<
Object
>
sendIds
,
Object
object
,
List
<
Map
<
String
,
Object
>>
pList
)
throws
MqttPersistenceException
,
MqttException
{
// 查询已绑定车辆人员id
List
<
UserCar
>
userCars
=
userCarMapper
.
selectList
(
new
QueryWrapper
<
UserCar
>().
lambda
().
eq
(
UserCar:
:
getIsDelete
,
false
));
List
<
Long
>
userCarIds
=
userCars
.
stream
().
map
(
UserCar:
:
getAmosUserId
).
collect
(
Collectors
.
toList
());
...
...
amos-boot-system-equip/src/main/resources/application.properties
View file @
d012287e
spring.application.name
=
AMOS-EQUIPMANAGE
server.servlet.context-path
=
/equip
server.port
=
8100
#server.servlet.context-path=/case
spring.profiles.active
=
dev
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
...
...
@@ -95,6 +97,23 @@ dcs.x.hw.appKey=s+YkvQhwilx91TRJHhNDmw==
equip.enabled
=
false
#es储存物联日志是否删除开关
es.ESEquiplistSpecific.flag
=
true
#es储存数据时间年
es.ESEquiplistSpecific.year
=
1
#es储存物联日志定时删除
es.ESEquiplistSpecific.time
=
0 */1 * * * ?
## ES properties:
biz.elasticsearch.address
=
172.16.11.201
spring.data.elasticsearch.cluster-name
=
elasticsearch
spring.data.elasticsearch.cluster-nodes
=
${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris
=
http://${biz.elasticsearch.address}:9200
elasticsearch.username
=
elastic
elasticsearch.password
=
Yeejoin@2020
# 权限标识-物联区域
auth-key-area
=
area_info
# 权限标识-消防系统
...
...
amos-boot-system-equip/src/main/resources/mapper/EquipmentSpecificMapper.xml
View file @
d012287e
...
...
@@ -160,13 +160,17 @@
(SELECT GROUP_CONCAT(fs.system_type_code) FROM f_fire_fighting_system fs WHERE find_in_set(
`fs`.`id`,
`wes`.`system_id`
)) AS `code`
)) AS `code`,
wes.system_id systemId,
(SELECT fs.name FROM f_fire_fighting_system fs WHERE `wes`.`system_id`=fs.id) AS systemName
FROM
wl_equipment_specific AS wes
where TRIM(wes.iot_code) != '' AND wes.iot_code IS NOT NULL
UNION ALL
SELECT
wc.id,
'' systemId,
'' systemName,
wc.iot_code AS iotCode,
'' as ecode,
'car' AS type,
...
...
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