Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-task-scheduler
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ed56c8ce
authored
May 06, 2022
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
开发设备激活补充定时激活位置点数据定时任务
1 parent
d2c810f0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
117 additions
and
0 deletions
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/DeviceActiveSchedulerJobService.java
src/main/java/cn/com/glsx/schedulerjob/task/taskscheduler/DeviceActiveSchedulerJob.java
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/DeviceActiveSchedulerJobServiceTest.java
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/DeviceActiveSchedulerJobService.java
0 → 100644
View file @
ed56c8c
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
modules
.
service
;
import
cn.com.glsx.stdinterface.api.DeviceActiveClient
;
import
cn.com.glsx.stdinterface.dto.DeviceActiveDto
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.core.web.R
;
import
com.google.gson.reflect.TypeToken
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* 定时任务更新设备激活定位数据
*
* @author yangll
*/
@Slf4j
@Service
public
class
DeviceActiveSchedulerJobService
{
@Autowired
private
DeviceActiveClient
deviceActiveClient
;
/**
* 定时任务更新设备激活定位数据
*/
public
void
updateDeviceActiveInfoEveryDay
()
{
log
.
info
(
"开始更新设备激活数据==="
);
R
<
List
<
String
>>
unActiveSnListR
=
deviceActiveClient
.
getUnActiveInfoSnList
();
List
<
String
>
unActiveSnList
=
unActiveSnListR
.
getDataList
(
new
TypeToken
<
List
<
String
>>()
{
}.
getType
());
log
.
info
(
"设备号集合:"
+
JSONUtil
.
toJsonStr
(
unActiveSnList
));
if
(
CollectionUtil
.
isEmpty
(
unActiveSnList
))
{
log
.
info
(
"unActiveSnList is null"
);
return
;
}
DeviceActiveDto
deviceActiveDto
=
new
DeviceActiveDto
();
deviceActiveDto
.
setSnList
(
unActiveSnList
);
R
statisticsR
=
deviceActiveClient
.
saveActiveInfo
(
deviceActiveDto
);
log
.
info
(
"更新设备激活数据的返回结果==="
+
JSON
.
toJSONString
(
statisticsR
));
}
}
src/main/java/cn/com/glsx/schedulerjob/task/taskscheduler/DeviceActiveSchedulerJob.java
0 → 100644
View file @
ed56c8c
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
taskscheduler
;
import
cn.com.glsx.schedulerjob.task.modules.service.DeviceActiveSchedulerJobService
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob
;
import
com.glsx.plat.common.utils.DateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
* 更新设备激活定位数据
*
* @author yangll
*/
@Slf4j
@Component
@ElasticSimpleJob
(
jobName
=
"DeviceActiveSchedulerJob"
,
cron
=
"0 30 5 * * ?"
)
public
class
DeviceActiveSchedulerJob
implements
SimpleJob
{
@Autowired
private
DeviceActiveSchedulerJobService
deviceActiveSchedulerJobService
;
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
log
.
info
(
"Thread ID: {}, 作业分片总数: {}, "
+
"当前分片项: {}.当前参数: {},"
+
"作业名称: {}.作业自定义参数: {}"
,
Thread
.
currentThread
().
getId
(),
shardingContext
.
getShardingTotalCount
(),
shardingContext
.
getShardingItem
(),
shardingContext
.
getShardingParameter
(),
shardingContext
.
getJobName
(),
shardingContext
.
getJobParameter
()
);
String
normalDate
=
DateUtils
.
formatNormal
(
new
Date
());
log
.
info
(
"---------------{}-开始----------------"
,
normalDate
);
deviceActiveSchedulerJobService
.
updateDeviceActiveInfoEveryDay
();
log
.
info
(
"---------------{}-结束--------------"
,
normalDate
);
}
}
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/DeviceActiveSchedulerJobServiceTest.java
0 → 100644
View file @
ed56c8c
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
modules
.
service
;
import
cn.com.glsx.Application
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.jupiter.api.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
@Slf4j
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
public
class
DeviceActiveSchedulerJobServiceTest
{
@Autowired
private
DeviceActiveSchedulerJobService
deviceActiveSchedulerJobService
;
@Test
public
void
updateDeviceActiveInfoEveryDay
()
{
System
.
out
.
println
(
"start==="
);
deviceActiveSchedulerJobService
.
updateDeviceActiveInfoEveryDay
();
System
.
out
.
println
(
"end==="
);
}
}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment