Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
8a12de3b
提交
8a12de3b
authored
10月 29, 2020
作者:
Matrix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[核查模块] 核查周期保存功能-bug修复
上级
a65f5ced
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
24 行增加
和
8 行删除
+24
-8
TaskPeriod.java
...a/com/tykj/dev/device/confirmcheck/common/TaskPeriod.java
+3
-3
DeviceCheckController.java
...device/confirmcheck/controller/DeviceCheckController.java
+5
-3
ConfirmCheckServiceImpl.java
...ce/confirmcheck/service/impl/ConfirmCheckServiceImpl.java
+16
-2
没有找到文件。
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/common/TaskPeriod.java
浏览文件 @
8a12de3b
...
@@ -16,15 +16,15 @@ public enum TaskPeriod {
...
@@ -16,15 +16,15 @@ public enum TaskPeriod {
/**
/**
* 月度
* 月度
*/
*/
monthly
(
"0 0 0 1 *
?
*"
),
monthly
(
"0 0 0 1 * *"
),
/**
/**
* 季度
* 季度
*/
*/
quarterly
(
"0 0 0 1 3/3
?
*"
),
quarterly
(
"0 0 0 1 3/3 *"
),
/**
/**
* 年度
* 年度
*/
*/
yearly
(
"0 0 0 1
3/3 ?
*"
);
yearly
(
"0 0 0 1
1
*"
);
private
final
String
cron
;
private
final
String
cron
;
...
...
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/controller/DeviceCheckController.java
浏览文件 @
8a12de3b
...
@@ -35,6 +35,7 @@ import com.tykj.dev.misc.base.StatusEnum;
...
@@ -35,6 +35,7 @@ import com.tykj.dev.misc.base.StatusEnum;
import
com.tykj.dev.misc.utils.JacksonUtil
;
import
com.tykj.dev.misc.utils.JacksonUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
...
@@ -131,8 +132,9 @@ public class DeviceCheckController {
...
@@ -131,8 +132,9 @@ public class DeviceCheckController {
* @return
* @return
*/
*/
@ApiOperation
(
value
=
"更新自动核查周期"
,
notes
=
"更新自动核查周期"
)
@ApiOperation
(
value
=
"更新自动核查周期"
,
notes
=
"更新自动核查周期"
)
@PutMapping
(
"/task/{period}"
)
@PutMapping
(
"/task/{periodId}"
)
public
ResponseEntity
updateTaskPeriod
(
@PathVariable
Integer
periodId
)
{
public
ResponseEntity
updateTaskPeriod
(
@PathVariable
@ApiParam
(
value
=
"核查周期,1-月度 2-季度 3-年度"
,
example
=
"1"
)
Integer
periodId
)
{
if
(
periodId
<
1
||
periodId
>
3
)
{
if
(
periodId
<
1
||
periodId
>
3
)
{
return
ResponseEntity
.
status
(
400
).
body
(
new
ResultObj
<>(
"提供了错误的周期参数!应该是 1/2/3 , 您提供的是"
+
periodId
));
return
ResponseEntity
.
status
(
400
).
body
(
new
ResultObj
<>(
"提供了错误的周期参数!应该是 1/2/3 , 您提供的是"
+
periodId
));
}
}
...
@@ -146,7 +148,7 @@ public class DeviceCheckController {
...
@@ -146,7 +148,7 @@ public class DeviceCheckController {
if
(
startSuccess
)
{
if
(
startSuccess
)
{
String
nextTime
=
ccService
.
getNextTaskDate
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
String
nextTime
=
ccService
.
getNextTaskDate
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
return
ResponseEntity
.
ok
(
new
ResultObj
<>(
String
.
format
(
"更新自动核查周期成功,下一次任务的执行时间为%s
%n
"
,
nextTime
)));
return
ResponseEntity
.
ok
(
new
ResultObj
<>(
String
.
format
(
"更新自动核查周期成功,下一次任务的执行时间为%s"
,
nextTime
)));
}
else
{
}
else
{
return
ResponseEntity
.
status
(
400
).
body
(
"自动核查更新周期失败了!"
);
return
ResponseEntity
.
status
(
400
).
body
(
"自动核查更新周期失败了!"
);
}
}
...
...
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/service/impl/ConfirmCheckServiceImpl.java
浏览文件 @
8a12de3b
...
@@ -331,7 +331,13 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
...
@@ -331,7 +331,13 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
@Override
@Override
public
LocalDate
getNextTaskDate
()
{
public
LocalDate
getNextTaskDate
()
{
// 获得当前的period
// 获得当前的period
TaskPeriod
period
=
periodDao
.
findTopByOrderByIdDesc
().
getCronExpression
();
DeviceCheckPeriod
dcp
=
periodDao
.
findTopByOrderByIdDesc
();
TaskPeriod
period
;
if
(
dcp
==
null
)
{
period
=
TaskPeriod
.
yearly
;
}
else
{
period
=
dcp
.
getCronExpression
();
}
LocalDate
now
=
LocalDate
.
now
();
LocalDate
now
=
LocalDate
.
now
();
switch
(
period
)
{
switch
(
period
)
{
case
yearly:
case
yearly:
...
@@ -356,7 +362,13 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
...
@@ -356,7 +362,13 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
public
boolean
startAutoCheckCron
()
{
public
boolean
startAutoCheckCron
()
{
boolean
flag
=
false
;
boolean
flag
=
false
;
//从数据库动态获取执行周期
//从数据库动态获取执行周期
TaskPeriod
period
=
getCurrentTaskPeriod
().
getCronExpression
();
TaskPeriod
period
;
// 如果数据库里没有设置,那么就使用默认的年
if
(
getCurrentTaskPeriod
()
==
null
)
{
period
=
TaskPeriod
.
yearly
;
}
else
{
period
=
getCurrentTaskPeriod
().
getCronExpression
();
}
String
cron
=
period
.
getCron
();
String
cron
=
period
.
getCron
();
future
=
threadPoolTaskScheduler
.
schedule
(
this
::
autoCheck
,
new
CronTrigger
(
cron
));
future
=
threadPoolTaskScheduler
.
schedule
(
this
::
autoCheck
,
new
CronTrigger
(
cron
));
if
(
future
!=
null
)
{
if
(
future
!=
null
)
{
...
@@ -418,5 +430,7 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
...
@@ -418,5 +430,7 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
public
void
run
(
String
...
args
)
throws
Exception
{
public
void
run
(
String
...
args
)
throws
Exception
{
//开启计划任务
//开启计划任务
startAutoCheckCron
();
startAutoCheckCron
();
log
.
info
(
"[核查模块] 初始化开启任务成功"
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论