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
94572d37
Commit
94572d37
authored
Sep 20, 2023
by
刘林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(equip):添加tdengine
parent
820d798e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
19 deletions
+86
-19
EquipmentIndexCacheRunner.java
...a/com/yeejoin/equip/config/EquipmentIndexCacheRunner.java
+3
-11
RedisConfig.java
...p/src/main/java/com/yeejoin/equip/config/RedisConfig.java
+47
-0
EquipmentIndexVO.java
.../main/java/com/yeejoin/equip/entity/EquipmentIndexVO.java
+6
-0
MessageTransfer.java
...src/main/java/com/yeejoin/equip/mqtt/MessageTransfer.java
+2
-2
RedisUtils.java
...uip/src/main/java/com/yeejoin/equip/utils/RedisUtils.java
+27
-3
application-dev.properties
...-data-equip/src/main/resources/application-dev.properties
+1
-3
No files found.
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/config/EquipmentIndexCacheRunner.java
View file @
94572d37
package
com
.
yeejoin
.
equip
.
config
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.equip.entity.EquipmentIndexVO
;
import
com.yeejoin.equip.mapper.mysql.EquipmentSpecificIndexMapper
;
import
com.yeejoin.equip.service.HandleESMessage2TDService
;
import
com.yeejoin.equip.service.InitTDEngineDbService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
...
...
@@ -27,11 +25,6 @@ public class EquipmentIndexCacheRunner implements CommandLineRunner {
@Resource
private
EquipmentSpecificIndexMapper
equipmentSpecificIndexMapper
;
@Autowired
private
InitTDEngineDbService
initTDEngineDbService
;
@Autowired
private
HandleESMessage2TDService
handleESMessage2TDService
;
@Value
(
"${spring.redis.host}"
)
private
String
redisHost
;
...
...
@@ -42,15 +35,14 @@ public class EquipmentIndexCacheRunner implements CommandLineRunner {
private
String
redisPassword
;
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
public
void
run
(
String
...
args
)
{
Jedis
jedis
=
new
Jedis
(
redisHost
,
redisPort
);
jedis
.
auth
(
redisPassword
);
Pipeline
pipeline
=
jedis
.
pipelined
();
List
<
EquipmentIndexVO
>
equipSpecificIndexList
=
equipmentSpecificIndexMapper
.
getEquipSpecificIndexList
(
null
);
equipSpecificIndexList
.
forEach
(
vo
->{
String
key
=
vo
.
getIndexAddress
()
+
"_"
+
vo
.
getGatewayId
();
pipeline
.
del
(
key
);
pipeline
.
set
(
key
,
String
.
valueOf
(
vo
));
pipeline
.
set
(
key
,
JSONObject
.
toJSONString
(
vo
));
});
pipeline
.
syncAndReturnAll
();
log
.
info
(
">>>>>>>>>>>>>>>>服务启动执行Redis缓存预加载指标数据完成!>>>>>>>>>>>>>>>>"
);
...
...
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/config/RedisConfig.java
0 → 100644
View file @
94572d37
package
com
.
yeejoin
.
equip
.
config
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
* @description:
* @author: duanwei
**/
@Configuration
public
class
RedisConfig
{
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
factory
)
{
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<>();
template
.
setConnectionFactory
(
factory
);
Jackson2JsonRedisSerializer
<
Object
>
j2jrs
=
new
Jackson2JsonRedisSerializer
<>(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
// 解决jackson2无法反序列化LocalDateTime的问题
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
om
.
registerModule
(
new
JavaTimeModule
());
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
,
JsonTypeInfo
.
As
.
PROPERTY
);
j2jrs
.
setObjectMapper
(
om
);
// 序列化 value 时使用此序列化方法
//template.setValueSerializer(j2jrs);
template
.
setHashValueSerializer
(
j2jrs
);
StringRedisSerializer
srs
=
new
StringRedisSerializer
();
// 序列化 key 时
template
.
setKeySerializer
(
srs
);
template
.
setHashKeySerializer
(
srs
);
template
.
afterPropertiesSet
();
// 序列化 value 时
template
.
setValueSerializer
(
srs
);
return
template
;
}
}
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/entity/EquipmentIndexVO.java
View file @
94572d37
...
...
@@ -2,11 +2,17 @@ package com.yeejoin.equip.entity;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
value
=
"性能指标详情返回vo实体"
,
description
=
"性能指标详情返回vo实体"
)
public
class
EquipmentIndexVO
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
)
...
...
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/mqtt/MessageTransfer.java
View file @
94572d37
...
...
@@ -37,8 +37,8 @@ public class MessageTransfer {
String
[]
topicItems
=
topic
.
split
(
TOPIC_SPLITTER
);
indicatorData
.
setMqttTopicEnum
(
MqttTopicEnum
.
of
(
topicItems
[
topicItems
.
length
-
1
]));
String
key
=
indicatorData
.
getAddress
()
+
"_"
+
indicatorData
.
getGatewayId
();
if
(
redisUtils
.
get
(
key
)!=
null
)
{
EquipmentIndexVO
equipmentSpeIndex
=
(
EquipmentIndexVO
)
redisUtils
.
get
(
key
)
;
if
(
redisUtils
.
hasKey
(
key
)
)
{
EquipmentIndexVO
equipmentSpeIndex
=
JSONObject
.
parseObject
(
redisUtils
.
get
(
key
),
EquipmentIndexVO
.
class
)
;
String
valueLabel
=
valueTranslate
(
indicatorData
.
getValue
(),
equipmentSpeIndex
.
getValueEnum
());
indicatorData
.
setIsAlarm
(
String
.
valueOf
(
equipmentSpeIndex
.
getIsAlarm
()));
indicatorData
.
setEquipmentIndexName
(
equipmentSpeIndex
.
getEquipmentIndexName
());
...
...
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/utils/RedisUtils.java
View file @
94572d37
...
...
@@ -10,14 +10,38 @@ import org.springframework.stereotype.Component;
public
class
RedisUtils
{
@Autowired
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
/**
* 普通缓存获取
*
* @param key 键
* @return 值
*/
public
Object
get
(
String
key
)
{
return
redisTemplate
.
opsForValue
().
get
(
key
);
public
String
get
(
String
key
)
{
return
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
}
/**
* 普通缓存放入
*
* @param key 键
* @param value 值
* @return true成功 false失败
*/
public
boolean
set
(
String
key
,
Object
value
)
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
);
return
true
;
}
/**
* 判断key是否存在
*
* @param key 键
* @return true 存在 false不存在
*/
public
boolean
hasKey
(
String
key
)
{
return
Boolean
.
TRUE
.
equals
(
redisTemplate
.
hasKey
(
key
));
}
}
amos-boot-data/amos-boot-data-equip/src/main/resources/application-dev.properties
View file @
94572d37
...
...
@@ -18,7 +18,7 @@ spring.datasource.tdengine-server.jdbc-url = jdbc:TAOS-RS://139.9.170.47:6041/io
spring.datasource.tdengine-server.username
=
root
spring.datasource.tdengine-server.password
=
taosdata
spring.redis.database
=
1
spring.redis.database
=
0
spring.redis.host
=
172.16.11.201
spring.redis.port
=
6379
spring.redis.password
=
yeejoin@2020
...
...
@@ -42,7 +42,6 @@ eureka.client.serviceUrl.defaultZone=http://${spring.security.user.name}:${sprin
spring.security.user.name
=
admin
spring.security.user.password
=
a1234560
## emqx
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${random.int[1024,65536]}
emqx.biz-client-id
=
consumer-${random.int[1024,65536]}
...
...
@@ -80,7 +79,6 @@ spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.Str
spring.kafka.consumer.value-deserializer
=
org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.fetch-max-wait
=
1000
spring.kafka.consumer.max-poll-records
=
1000
spring.kafka.listener.ack-mode
=
manual_immediate
spring.kafka.listener.type
=
batch
kafka.alarm.topic
=
EQUIPMENT_ALARM
...
...
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