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
f0a9df5e
Commit
f0a9df5e
authored
Sep 25, 2023
by
刘林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(equip):优化对接IOT代码,添加ES同步时间
parent
bf88f772
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
13 deletions
+31
-13
EquipmentIndexCacheRunner.java
...a/com/yeejoin/equip/config/EquipmentIndexCacheRunner.java
+9
-1
ESEquipmentsMapper.java
...com/yeejoin/equip/mapper/tdengine/ESEquipmentsMapper.java
+2
-1
HandleESMessage2TDService.java
.../com/yeejoin/equip/service/HandleESMessage2TDService.java
+5
-1
application-dev.properties
...-data-equip/src/main/resources/application-dev.properties
+4
-3
ESEquipmentsMapper.xml
...src/main/resources/mapper/tdengine/ESEquipmentsMapper.xml
+11
-7
No files found.
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/config/EquipmentIndexCacheRunner.java
View file @
f0a9df5e
...
...
@@ -34,8 +34,14 @@ public class EquipmentIndexCacheRunner implements CommandLineRunner {
@Value
(
"${spring.redis.password}"
)
private
String
redisPassword
;
//@Autowired
//private HandleESMessage2TDService handleESMessage2TDService;
//@Autowired
//private InitTDEngineDbService initTDEngineDbService;
@Override
public
void
run
(
String
...
args
)
{
public
void
run
(
String
...
args
)
throws
Exception
{
Jedis
jedis
=
new
Jedis
(
redisHost
,
redisPort
);
jedis
.
auth
(
redisPassword
);
Pipeline
pipeline
=
jedis
.
pipelined
();
...
...
@@ -47,5 +53,6 @@ public class EquipmentIndexCacheRunner implements CommandLineRunner {
pipeline
.
syncAndReturnAll
();
log
.
info
(
">>>>>>>>>>>>>>>>服务启动执行Redis缓存预加载指标数据完成!>>>>>>>>>>>>>>>>"
);
//initTDEngineDbService.init();
//handleESMessage2TDService.syncEsData2TDEngine();
}
}
\ No newline at end of file
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/mapper/tdengine/ESEquipmentsMapper.java
View file @
f0a9df5e
...
...
@@ -2,6 +2,7 @@ package com.yeejoin.equip.mapper.tdengine;
import
com.yeejoin.equip.entity.ESEquipments
;
import
com.yeejoin.equip.entity.IndicatorData
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
...
...
@@ -14,7 +15,7 @@ import java.util.List;
*/
@Component
public
interface
ESEquipmentsMapper
{
int
batchInsert
(
List
<
ESEquipments
>
esEquipmentsList
);
int
batchInsert
(
@Param
(
"list"
)
List
<
ESEquipments
>
esEquipmentsList
,
@Param
(
"time"
)
String
time
);
int
insert
(
ESEquipments
esEquipments
);
...
...
amos-boot-data/amos-boot-data-equip/src/main/java/com/yeejoin/equip/service/HandleESMessage2TDService.java
View file @
f0a9df5e
...
...
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.text.SimpleDateFormat
;
import
java.util.List
;
/**
* @author LiuLin
...
...
@@ -26,6 +27,7 @@ public class HandleESMessage2TDService {
private
ESEquipmentsMapper
esEquipmentsMapper
;
@Autowired
private
ElasticSearchUtil
elasticSearchUtil
;
private
static
final
String
datePattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
;
/**
* 十分钟拉取ES数据存入TdEngine
...
...
@@ -33,11 +35,13 @@ public class HandleESMessage2TDService {
@Scheduled
(
cron
=
"0 */10 * * * ?"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
syncEsData2TDEngine
()
throws
Exception
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
datePattern
);
List
<
ESEquipments
>
result
=
elasticSearchUtil
.
searchResponse
(
ES_INDEX
,
null
,
hit
->
JSONObject
.
parseObject
(
hit
.
getSourceAsString
(),
ESEquipments
.
class
));
List
<
List
<
ESEquipments
>>
allDataList
=
Lists
.
partition
(
result
,
SIZE
);
String
time
=
format
.
format
(
System
.
currentTimeMillis
());
for
(
List
<
ESEquipments
>
tempDataList
:
allDataList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
tempDataList
))
{
esEquipmentsMapper
.
batchInsert
(
tempDataList
);
esEquipmentsMapper
.
batchInsert
(
tempDataList
,
time
);
}
}
log
.
info
(
"同步ES数据至TDEngine成功!共同步{}条!"
,
result
.
size
());
...
...
amos-boot-data/amos-boot-data-equip/src/main/resources/application-dev.properties
View file @
f0a9df5e
...
...
@@ -22,9 +22,10 @@ spring.redis.database=0
spring.redis.host
=
172.16.11.201
spring.redis.port
=
6379
spring.redis.password
=
yeejoin@2020
spring.redis.lettuce.pool.max-active
=
200
spring.redis.timeout
=
3000
spring.redis.lettuce.pool.max-active
=
300
spring.redis.lettuce.pool.max-wait
=
-1
spring.redis.lettuce.pool.max-idle
=
10
spring.redis.lettuce.pool.max-idle
=
64
spring.redis.lettuce.pool.min-idle
=
0
eureka.client.registry-fetch-interval-seconds
=
5
...
...
@@ -38,7 +39,7 @@ eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs
=
http://localhost:${server.port}${server.servlet.context-path}/doc.html
eureka.instance.hostname
=
172.16.11.201
eureka.instance.prefer-ip-address
=
true
eureka.client.serviceUrl.defaultZone
=
http://${spring.security.user.name}:${spring.security.user.password}@172.16.1
0.220
:10001/eureka/
eureka.client.serviceUrl.defaultZone
=
http://${spring.security.user.name}:${spring.security.user.password}@172.16.1
1.201
:10001/eureka/
spring.security.user.name
=
admin
spring.security.user.password
=
a1234560
...
...
amos-boot-data/amos-boot-data-equip/src/main/resources/mapper/tdengine/ESEquipmentsMapper.xml
View file @
f0a9df5e
...
...
@@ -4,7 +4,7 @@
<mapper
namespace=
"com.yeejoin.equip.mapper.tdengine.ESEquipmentsMapper"
>
<insert
id=
"batchInsert"
parameterType=
"java.util.List"
>
insert into indicator_data
(
createdTime
,
(
ts
,
id,
address,
gateway_id,
...
...
@@ -17,7 +17,8 @@
`value_f` ,
value_label,
equipment_number,
display_name)
display_name,
created_time)
values
<foreach
separator=
" "
collection=
"list"
item=
"equip"
index=
"index"
>
(now + #{index}a,
...
...
@@ -33,7 +34,8 @@
#{equip.valueF},
#{equip.valueLabel},
#{equip.equipmentNumber},
#{equip.displayName})
#{equip.displayName},
#{time})
</foreach>
</insert>
...
...
@@ -73,7 +75,7 @@
<!--创建表-->
<update
id=
"createTable"
>
create table if not exists indicator_data
(
createdTime timestamp
,
(
ts TIMESTAMP
,
id binary(64),
address binary(64),
gateway_id binary(64),
...
...
@@ -83,9 +85,10 @@
equipment_index_name VARCHAR(255) ,
equipment_specific_name VARCHAR(255),
`value` VARCHAR(12),
`value_f`
float
,
`value_f`
FLOAT
,
value_label VARCHAR(64),
equipment_number binary(64),
display_name VARCHAR(200));
equipment_number BINARY(64),
display_name VARCHAR(200),
created_time VARCHAR(64));
</update>
</mapper>
\ 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