Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
4f01d03b
提交
4f01d03b
authored
10月 09, 2020
作者:
邓砥奕
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[自查模块]增加自查定时任务
上级
80810f3e
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
74 行增加
和
29 行删除
+74
-29
TaskBeanConfig.java
...fig/src/main/java/com/tykj/dev/config/TaskBeanConfig.java
+13
-0
SelfCheckSchedulerTask.java
...ykj/dev/device/selfcheck/base/SelfCheckSchedulerTask.java
+61
-29
SelfCheckController.java
.../dev/device/selfcheck/controller/SelfCheckController.java
+0
-0
没有找到文件。
dev-config/src/main/java/com/tykj/dev/config/TaskBeanConfig.java
浏览文件 @
4f01d03b
package
com
.
tykj
.
dev
.
config
;
import
lombok.Data
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
...
...
@@ -8,6 +9,18 @@ import org.springframework.stereotype.Component;
@Component
public
class
TaskBeanConfig
{
private
static
final
ThreadPoolTaskScheduler
THREAD_POOL_TASK_SCHEDULER
;
static
{
THREAD_POOL_TASK_SCHEDULER
=
new
ThreadPoolTaskScheduler
();
THREAD_POOL_TASK_SCHEDULER
.
setPoolSize
(
10
);
THREAD_POOL_TASK_SCHEDULER
.
initialize
();
}
public
static
ThreadPoolTaskScheduler
getThreadPoolTaskScheduler
()
{
return
THREAD_POOL_TASK_SCHEDULER
;
}
@Bean
public
TaskScheduler
taskScheduler
()
{
ThreadPoolTaskScheduler
taskScheduler
=
new
ThreadPoolTaskScheduler
();
...
...
dev-selfcheck/src/main/java/com/tykj/dev/device/selfcheck/base/SelfCheckSchedulerTask.java
浏览文件 @
4f01d03b
package
com
.
tykj
.
dev
.
device
.
selfcheck
.
base
;
import
com.tykj.dev.config.GlobalMap
;
import
com.tykj.dev.config.TaskBeanConfig
;
import
com.tykj.dev.device.task.service.TaskService
;
import
com.tykj.dev.device.task.subject.bto.TaskBto
;
import
com.tykj.dev.device.user.subject.dao.UnitsDao
;
import
com.tykj.dev.device.user.subject.entity.Units
;
import
com.tykj.dev.misc.base.BeanHelper
;
import
com.tykj.dev.misc.base.StatusEnum
;
import
com.tykj.dev.misc.utils.SpringUtils
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.scheduling.support.CronTrigger
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.Proxy
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ScheduledFuture
;
/**
* @author dengdiyi
*/
@Slf4j
@Component
@EnableAsync
@Data
public
class
SelfCheckSchedulerTask
{
/**
* 月度
*/
private
String
cron1
=
"0 0 0 1 1/1 ? "
;
/**
* 季度
*/
private
String
cron2
=
"0 0 0 1 3,6,9,12 ? "
;
/**
* 年度
*/
private
String
cron3
=
"0 0 0 1 1 ? *"
;
// @Async
// @Scheduled(cron = "0 0 0 1 1/1 ? ")
// public void createSelfCheckTask() {
// UnitsDao unitsDao = SpringUtils.getBean("unitsDao");
// TaskService taskService = SpringUtils.getBean("taskServiceImpl");
// if (unitsDao != null && taskService!=null) {
// List<Units> unitsList = unitsDao.findAll();
// unitsList.forEach(units -> {
// //发起待自查任务
// List<Integer> userIds = new ArrayList<>();
// userIds.add(0);
// TaskBto taskBto = new TaskBto(StatusEnum.WAIT_SELF_CHECK.id,"自查业务",null,".",0,4,units.getUnitId(),0,null,userIds);
// taskService.start(taskBto);
// });
// }
// }
private
String
cron
=
"0 0 0 1 3,6,9,12 ? "
;
private
UnitsDao
unitsDao
=
SpringUtils
.
getBean
(
"unitsDao"
);
private
TaskService
taskService
=
SpringUtils
.
getBean
(
"taskServiceImpl"
);
private
ScheduledFuture
scheduledFuture
;
public
SelfCheckSchedulerTask
()
{
scheduledFuture
=
TaskBeanConfig
.
getThreadPoolTaskScheduler
().
schedule
(
new
SelfCheckTask
(),
triggerContext
->
new
CronTrigger
(
cron
).
nextExecutionTime
(
triggerContext
));
}
public
class
SelfCheckTask
implements
Runnable
{
@Override
public
void
run
()
{
if
(
unitsDao
!=
null
&&
taskService
!=
null
)
{
List
<
Units
>
unitsList
=
unitsDao
.
findAll
();
unitsList
.
forEach
(
units
->
{
//发起待自查任务
List
<
Integer
>
userIds
=
new
ArrayList
<>();
userIds
.
add
(
0
);
TaskBto
taskBto
=
new
TaskBto
(
StatusEnum
.
WAIT_SELF_CHECK
.
id
,
"自查业务"
,
null
,
"."
,
0
,
4
,
units
.
getUnitId
(),
0
,
null
,
userIds
);
taskService
.
start
(
taskBto
);
});
}
log
.
info
(
"[自查模块]:自查定时任务执行了"
);
}
}
public
void
startTask
(){
scheduledFuture
=
TaskBeanConfig
.
getThreadPoolTaskScheduler
().
schedule
(
new
SelfCheckTask
(),
triggerContext
->
new
CronTrigger
(
cron
).
nextExecutionTime
(
triggerContext
));
}
}
dev-selfcheck/src/main/java/com/tykj/dev/device/selfcheck/controller/SelfCheckController.java
浏览文件 @
4f01d03b
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论