Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lingxi-lxy-yanshou
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
后端-黄柯铭
lingxi-lxy-yanshou
Commits
22fee9ca
Commit
22fee9ca
authored
Jul 14, 2021
by
技术总监-万宁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加修改任务启动时间接口
parent
52b0c49a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
123 additions
and
21 deletions
+123
-21
ResponseCode.java
...ain/java/com/ssy/lingxi/common/response/ResponseCode.java
+2
-1
ScheduleTaskFallback.java
...y/lingxi/scheduler/api/fallback/ScheduleTaskFallback.java
+13
-4
ScheduleTaskFeign.java
...com/ssy/lingxi/scheduler/api/feign/ScheduleTaskFeign.java
+9
-4
ScheduleTaskUpdateExecTimeVO.java
...gxi/scheduler/api/model/ScheduleTaskUpdateExecTimeVO.java
+46
-0
ScheduleTaskController.java
...y/lingxi/scheduler/controller/ScheduleTaskController.java
+11
-4
IScheduleTaskService.java
...om/ssy/lingxi/scheduler/service/IScheduleTaskService.java
+8
-4
ScheduleTaskServiceImpl.java
...lingxi/scheduler/serviceimpl/ScheduleTaskServiceImpl.java
+34
-4
No files found.
common/src/main/java/com/ssy/lingxi/common/response/ResponseCode.java
View file @
22fee9ca
...
...
@@ -3160,7 +3160,8 @@ public enum ResponseCode {
//**scheduler-service 状态码:54000-54299***
//************************************************
SS_TASK_CREATE_FAILED
(
54000
,
"定时任务创建失败"
),
SS_TASK_DELETE_FAILED
(
54001
,
"定时任务删除失败"
)
SS_TASK_DELETE_FAILED
(
54001
,
"定时任务删除失败"
),
SS_TASK_DOES_NOT_EXIST
(
54002
,
"定时任务不存在或已执行完毕"
)
...
...
scheduler-service/scheduler-service-api/src/main/java/com/ssy/lingxi/scheduler/api/fallback/ScheduleTaskFallback.java
View file @
22fee9ca
...
...
@@ -3,11 +3,9 @@ package com.ssy.lingxi.scheduler.api.fallback;
import
com.ssy.lingxi.common.response.ResponseCode
;
import
com.ssy.lingxi.common.response.Wrapper
;
import
com.ssy.lingxi.scheduler.api.feign.ScheduleTaskFeign
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskDefinitionVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskIdVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskQueryVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskVO
;
import
com.ssy.lingxi.scheduler.api.model.*
;
import
javax.validation.Valid
;
import
java.util.List
;
/**
...
...
@@ -40,6 +38,17 @@ public class ScheduleTaskFallback implements ScheduleTaskFeign {
}
/**
* 修改任务的启动时间
*
* @param updateVO 接口参数
* @return 修改结果
*/
@Override
public
Wrapper
<
Void
>
updateScheduleTaskExecTime
(
@Valid
ScheduleTaskUpdateExecTimeVO
updateVO
)
{
return
Wrapper
.
fail
(
ResponseCode
.
SERVICE_SCHEDULER_ERROR
);
}
/**
* 调用方执行完成定时任务后,通知定时任务服务删除任务
*
* @param idVO 接口参数
...
...
scheduler-service/scheduler-service-api/src/main/java/com/ssy/lingxi/scheduler/api/feign/ScheduleTaskFeign.java
View file @
22fee9ca
package
com
.
ssy
.
lingxi
.
scheduler
.
api
.
feign
;
import
com.ssy.lingxi.common.response.Wrapper
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskDefinitionVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskIdVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskQueryVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskVO
;
import
com.ssy.lingxi.scheduler.api.model.*
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -39,6 +36,14 @@ public interface ScheduleTaskFeign {
Wrapper
<
List
<
ScheduleTaskDefinitionVO
>>
listScheduleTask
(
@RequestBody
@Valid
ScheduleTaskQueryVO
queryVO
);
/**
* 修改任务的启动时间
* @param updateVO 接口参数
* @return 修改结果
*/
@RequestMapping
(
value
=
"/schedule/task/time/update"
,
method
=
RequestMethod
.
POST
)
Wrapper
<
Void
>
updateScheduleTaskExecTime
(
@RequestBody
@Valid
ScheduleTaskUpdateExecTimeVO
updateVO
);
/**
* 删除任务
* @param idVO 接口参数
* @return 通知结果
...
...
scheduler-service/scheduler-service-api/src/main/java/com/ssy/lingxi/scheduler/api/model/ScheduleTaskUpdateExecTimeVO.java
0 → 100644
View file @
22fee9ca
package
com
.
ssy
.
lingxi
.
scheduler
.
api
.
model
;
import
com.ssy.lingxi.scheduler.api.handler.annotation.TimestampAnnotation
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Positive
;
import
java.io.Serializable
;
/**
* 修改任务启动时间接口参数
* @author 万宁
* @version 2.0.0
* @date 2021-07-14
*/
public
class
ScheduleTaskUpdateExecTimeVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
4975993025367994877L
;
/**
* 定时任务Id
*/
@NotNull
(
message
=
"定时任务Id要大于0"
)
@Positive
(
message
=
"定时任务Id要大于0"
)
private
Long
taskId
;
/**
* 任务开始执行的时间,(Unix时间戳格式,精确到毫秒)
*/
@TimestampAnnotation
private
Long
execTime
;
public
Long
getTaskId
()
{
return
taskId
;
}
public
void
setTaskId
(
Long
taskId
)
{
this
.
taskId
=
taskId
;
}
public
Long
getExecTime
()
{
return
execTime
;
}
public
void
setExecTime
(
Long
execTime
)
{
this
.
execTime
=
execTime
;
}
}
scheduler-service/src/main/java/com/ssy/lingxi/scheduler/controller/ScheduleTaskController.java
View file @
22fee9ca
package
com
.
ssy
.
lingxi
.
scheduler
.
controller
;
import
com.ssy.lingxi.common.response.Wrapper
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskDefinitionVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskIdVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskQueryVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskVO
;
import
com.ssy.lingxi.scheduler.api.model.*
;
import
com.ssy.lingxi.scheduler.service.IScheduleTaskService
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -49,6 +46,16 @@ public class ScheduleTaskController {
}
/**
* 修改任务的启动时间
* @param updateVO 接口参数
* @return 修改结果
*/
@RequestMapping
(
value
=
"/time/update"
,
method
=
RequestMethod
.
POST
)
public
Wrapper
<
Void
>
updateScheduleTaskExecTime
(
@RequestBody
@Valid
ScheduleTaskUpdateExecTimeVO
updateVO
)
{
return
scheduleTaskService
.
updateScheduleTaskExecTime
(
updateVO
);
}
/**
* 调用方执行完成定时任务后,通知定时任务模块删除任务
* @param idVO 接口参数
* @return 通知结果
...
...
scheduler-service/src/main/java/com/ssy/lingxi/scheduler/service/IScheduleTaskService.java
View file @
22fee9ca
package
com
.
ssy
.
lingxi
.
scheduler
.
service
;
import
com.ssy.lingxi.common.response.Wrapper
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskDefinitionVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskIdVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskQueryVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskVO
;
import
com.ssy.lingxi.scheduler.api.model.*
;
import
org.quartz.JobDetail
;
import
org.quartz.Trigger
;
...
...
@@ -33,6 +30,13 @@ public interface IScheduleTaskService {
Wrapper
<
List
<
ScheduleTaskDefinitionVO
>>
listScheduleTask
(
ScheduleTaskQueryVO
queryVO
);
/**
* 修改任务的启动时间
* @param updateVO 接口参数
* @return 修改结果
*/
Wrapper
<
Void
>
updateScheduleTaskExecTime
(
ScheduleTaskUpdateExecTimeVO
updateVO
);
/**
* 调用方执行完成定时任务后,通知定时任务模块
* @param idVO 接口参数
* @return 通知结果
...
...
scheduler-service/src/main/java/com/ssy/lingxi/scheduler/serviceimpl/ScheduleTaskServiceImpl.java
View file @
22fee9ca
...
...
@@ -3,10 +3,7 @@ package com.ssy.lingxi.scheduler.serviceimpl;
import
com.ssy.lingxi.common.exception.BusinessException
;
import
com.ssy.lingxi.common.response.ResponseCode
;
import
com.ssy.lingxi.common.response.Wrapper
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskDefinitionVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskIdVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskQueryVO
;
import
com.ssy.lingxi.scheduler.api.model.ScheduleTaskVO
;
import
com.ssy.lingxi.scheduler.api.model.*
;
import
com.ssy.lingxi.scheduler.entity.ScheduleTaskDefinition
;
import
com.ssy.lingxi.scheduler.listener.ScheduleJob
;
import
com.ssy.lingxi.scheduler.model.ServiceConstants
;
...
...
@@ -154,6 +151,39 @@ public class ScheduleTaskServiceImpl implements IScheduleTaskService {
}
/**
* 修改任务的启动时间
*
* @param updateVO 接口参数
* @return 修改结果
*/
@Override
public
Wrapper
<
Void
>
updateScheduleTaskExecTime
(
ScheduleTaskUpdateExecTimeVO
updateVO
)
{
ScheduleTaskDefinition
taskDefinition
=
taskDefinitionRepository
.
findById
(
updateVO
.
getTaskId
()).
orElse
(
null
);
if
(
taskDefinition
==
null
)
{
return
Wrapper
.
fail
(
ResponseCode
.
SS_TASK_DOES_NOT_EXIST
);
}
taskDefinition
.
setExecTime
(
updateVO
.
getExecTime
());
Trigger
trigger
=
TriggerBuilder
.
newTrigger
().
withIdentity
(
taskDefinition
.
getTaskName
(),
taskDefinition
.
getTaskGroup
())
.
withSchedule
(
SimpleScheduleBuilder
.
simpleSchedule
()
.
withIntervalInMinutes
(
ServiceConstants
.
TASK_INTERVAL_MINUTES
)
.
withRepeatCount
(
ServiceConstants
.
TASK_REPEAT_TIMES
))
.
startAt
(
new
Date
(
updateVO
.
getExecTime
()))
.
build
();
TriggerKey
triggerKey
=
TriggerKey
.
triggerKey
(
taskDefinition
.
getTaskName
(),
taskDefinition
.
getTaskGroup
());
try
{
scheduler
.
rescheduleJob
(
triggerKey
,
trigger
);
}
catch
(
Exception
e
)
{
return
Wrapper
.
fail
(
ResponseCode
.
SERVICE_ERROR
,
e
.
getMessage
());
}
taskDefinitionRepository
.
saveAndFlush
(
taskDefinition
);
return
Wrapper
.
success
();
}
/**
* 调用方执行完成定时任务后,通知定时任务模块
*
* @param idVO 接口参数
...
...
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