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
71c46ac9
Commit
71c46ac9
authored
Jun 25, 2023
by
刘林
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop_dl' into develop_dl
parents
85388bb5
dd88276d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
30 deletions
+33
-30
MqttReceiveServiceImpl.java
...join/equipmanage/service/impl/MqttReceiveServiceImpl.java
+28
-24
ThreadCarMileageTreatment.java
...yeejoin/equipmanage/thread/ThreadCarMileageTreatment.java
+2
-4
application-dev.properties
...ystem-equip/src/main/resources/application-dev.properties
+3
-2
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java
View file @
71c46ac9
...
...
@@ -78,7 +78,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private
static
Map
<
String
,
TemperatureAlarmDto
>
temperatureMap
=
new
HashMap
<>();
static
IEquipmentSpecificIndexService
equipmentSpecificIndexService
;
@Value
(
"${iot.async.flag}"
)
private
boolean
iotAsyncExecutorFlag
;
@Autowired
public
void
setEquipmentSpecificIndexService
(
IEquipmentSpecificIndexService
equipmentSpecificIndexService
)
{
MqttReceiveServiceImpl
.
equipmentSpecificIndexService
=
equipmentSpecificIndexService
;
...
...
@@ -2547,29 +2548,32 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@PostConstruct
public
void
iotAsyncExecutor
()
{
ThreadPoolTaskExecutor
workExecutor
=
new
ThreadPoolTaskExecutor
();
// 设置核心线程数
int
length
=
Runtime
.
getRuntime
().
availableProcessors
();
int
size
=
Math
.
max
(
length
,
80
);
workExecutor
.
setCorePoolSize
(
size
*
2
);
log
.
info
(
"装备服务初始化,系统线程数:{},运行线程数:{}"
,
length
,
size
);
// 设置最大线程数
workExecutor
.
setMaxPoolSize
(
workExecutor
.
getCorePoolSize
());
//配置队列大小
workExecutor
.
setQueueCapacity
(
Integer
.
MAX_VALUE
);
// 设置线程活跃时间(秒)
workExecutor
.
setKeepAliveSeconds
(
60
);
// 设置默认线程名称
workExecutor
.
setThreadNamePrefix
(
"装备服务-Iot透传消息消费线程池"
+
"-"
);
// 等待所有任务结束后再关闭线程池
//当调度器shutdown被调用时,等待当前被调度的任务完成
workExecutor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
//执行初始化
workExecutor
.
initialize
();
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
// CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
workExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
this
.
dataExecutor
=
workExecutor
;
if
(
iotAsyncExecutorFlag
)
{
System
.
out
.
println
(
"-----------------iotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlag"
);
ThreadPoolTaskExecutor
workExecutor
=
new
ThreadPoolTaskExecutor
();
// 设置核心线程数
int
length
=
Runtime
.
getRuntime
().
availableProcessors
();
int
size
=
Math
.
max
(
length
,
80
);
workExecutor
.
setCorePoolSize
(
size
*
2
);
log
.
info
(
"装备服务初始化,系统线程数:{},运行线程数:{}"
,
length
,
size
);
// 设置最大线程数
workExecutor
.
setMaxPoolSize
(
workExecutor
.
getCorePoolSize
());
//配置队列大小
workExecutor
.
setQueueCapacity
(
Integer
.
MAX_VALUE
);
// 设置线程活跃时间(秒)
workExecutor
.
setKeepAliveSeconds
(
60
);
// 设置默认线程名称
workExecutor
.
setThreadNamePrefix
(
"装备服务-Iot透传消息消费线程池"
+
"-"
);
// 等待所有任务结束后再关闭线程池
//当调度器shutdown被调用时,等待当前被调度的任务完成
workExecutor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
//执行初始化
workExecutor
.
initialize
();
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
// CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
workExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
this
.
dataExecutor
=
workExecutor
;
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/thread/ThreadCarMileageTreatment.java
View file @
71c46ac9
...
...
@@ -79,9 +79,7 @@ public class ThreadCarMileageTreatment extends Thread {
&&
Obj
.
getDoubleValue
(
"FireCar_Latitude"
)
!=
0
)
{
filterList
.
add
(
list
.
get
(
j
));
// 获取第一个不为空的坐标
if
(
lastObj
==
null
)
{
lastObj
=
Obj
;
}
lastObj
=
Obj
;
}
}
Log
.
info
(
"----------------------------------------lastobj----------------------"
+
lastObj
.
toJSONString
());
...
...
@@ -116,7 +114,7 @@ public class ThreadCarMileageTreatment extends Thread {
}
last
.
setTravel
(
new
BigDecimal
(
travel
/
1000
).
setScale
(
1
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
());
Log
.
info
(
"----------------------------------------last----------------------"
+
lastObj
.
toJSONString
());
wlCarMileageServiceImpl
.
updateById
(
last
);
//
wlCarMileageServiceImpl.updateById(last);
}
}
}
...
...
amos-boot-system-equip/src/main/resources/application-dev.properties
View file @
71c46ac9
...
...
@@ -149,4 +149,5 @@ spring.influx.database=iot_platform
spring.influx.retention_policy
=
default
spring.influx.retention_policy_time
=
30d
spring.influx.actions
=
10000
spring.influx.bufferLimit
=
20000
\ No newline at end of file
spring.influx.bufferLimit
=
20000
iot.async.flag
=
false
\ 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