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 4e72dbcd
authored
Oct 18, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
开发不在店试驾统计任务
1 parent
54783cd5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
1 deletions
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/InStoreSchedulerJobService.java
src/main/java/cn/com/glsx/schedulerjob/task/taskscheduler/InStoreSchedulerJob.java
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/InStoreSchedulerJobServiceTest.java
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobServiceTest.java
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/InStoreSchedulerJobService.java
0 → 100644
View file @
4e72dbc
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
modules
.
service
;
import
cn.com.glsx.stdinterface.api.ElectricInStoreClient
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* @author liuyf
* @date 2021年01月26日 下午2:37:40
*/
@Slf4j
@Service
public
class
InStoreSchedulerJobService
{
@Autowired
private
ElectricInStoreClient
electricInStoreClient
;
public
void
calculateInStoreDateEveryDay
()
{
log
.
info
(
"开始统计并插入非工作设备的无在店统计数据==="
);
R
statisticsR
=
electricInStoreClient
.
calculateInStoreDateEveryDay
();
log
.
info
(
"统计的返回结果==="
+
JSON
.
toJSONString
(
statisticsR
));
}
}
src/main/java/cn/com/glsx/schedulerjob/task/taskscheduler/InStoreSchedulerJob.java
0 → 100644
View file @
4e72dbc
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
taskscheduler
;
import
cn.com.glsx.schedulerjob.task.modules.service.InStoreSchedulerJobService
;
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
;
@Slf4j
@Component
@ElasticSimpleJob
(
jobName
=
"InStoreSchedulerJob"
,
cron
=
"0 15 4 * * ?"
)
public
class
InStoreSchedulerJob
implements
SimpleJob
{
@Autowired
private
InStoreSchedulerJobService
inStoreSchedulerJobService
;
@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
);
inStoreSchedulerJobService
.
calculateInStoreDateEveryDay
();
log
.
info
(
"---------------{}-结束--------------"
,
normalDate
);
}
}
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/InStoreSchedulerJobServiceTest.java
0 → 100644
View file @
4e72dbc
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
)
class
InStoreSchedulerJobServiceTest
{
@Autowired
InStoreSchedulerJobService
inStoreSchedulerJobService
;
@Test
void
calculateInStoreDateEveryDay
()
{
System
.
out
.
println
(
"inStoreSchedulerJobService start==="
);
inStoreSchedulerJobService
.
calculateInStoreDateEveryDay
();
System
.
out
.
println
(
"inStoreSchedulerJobService end==="
);
}
}
\ No newline at end of file
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobServiceTest.java
View file @
4e72dbc
...
...
@@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
class
MySimpleJobServiceTest
{
@Autowired
MySimpleJobService
mySimpleJobService
;
private
MySimpleJobService
mySimpleJobService
;
@Autowired
private
StatisticsDriveClient
statisticsDriveClient
;
...
...
@@ -47,4 +47,9 @@ class MySimpleJobServiceTest {
System
.
out
.
println
(
"statisticsDriveR = "
+
JSON
.
toJSONString
(
statisticsDriveR
));
}
@Test
public
void
test04
()
{
System
.
out
.
println
(
"开始调用 ==== "
+
JSON
.
toJSONString
(
statisticsDriveClient
));
mySimpleJobService
.
statisticsDriveDataEveryDay
();
}
}
\ 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