Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
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
liyuan
byit-myth-job
Commits
e9927964
Commit
e9927964
authored
Apr 14, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
b36ea651
4551b885
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
10 deletions
+78
-10
ApiNodeController.java
...h-admin/src/main/java/com/byit/api/ApiNodeController.java
+6
-0
ApiNodeService.java
...-admin/src/main/java/com/byit/service/ApiNodeService.java
+10
-0
ApiNodeServiceImpl.java
...c/main/java/com/byit/service/impl/ApiNodeServiceImpl.java
+44
-0
JavaTaskMapper.java
...in-core/src/main/java/com/byit/mapper/JavaTaskMapper.java
+2
-0
JavaTaskMapper.xml
...h-admin-core/src/main/resources/mapper/JavaTaskMapper.xml
+15
-9
JavaTask.java
...-dto-core/src/main/java/com/byit/dto/plugin/JavaTask.java
+1
-1
No files found.
byit-myth-admin/src/main/java/com/byit/api/ApiNodeController.java
View file @
e9927964
...
@@ -35,4 +35,10 @@ public class ApiNodeController {
...
@@ -35,4 +35,10 @@ public class ApiNodeController {
return
ResponseResult
.
ok
(
jobTaskRunLogList
);
return
ResponseResult
.
ok
(
jobTaskRunLogList
);
}
}
@PostMapping
(
"autoAddJavaTask"
)
public
String
autoAddJavaTask
(
String
param
)
throws
Exception
{
apiNodeService
.
autoAddJavaTask
(
param
);
return
"SUCCESS"
;
}
}
}
byit-myth-admin/src/main/java/com/byit/service/ApiNodeService.java
View file @
e9927964
...
@@ -2,6 +2,7 @@ package com.byit.service;
...
@@ -2,6 +2,7 @@ package com.byit.service;
import
com.byit.model.JobTaskRunLog
;
import
com.byit.model.JobTaskRunLog
;
import
java.text.ParseException
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -21,4 +22,13 @@ public interface ApiNodeService {
...
@@ -21,4 +22,13 @@ public interface ApiNodeService {
* @return
* @return
*/
*/
List
<
JobTaskRunLog
>
runHistory
(
String
nodeId
);
List
<
JobTaskRunLog
>
runHistory
(
String
nodeId
);
/**
* 功能描述 自动发布任务的接口
* @author gml
* @date 2020-04-14 10:55
* @param param
* @return void
*/
void
autoAddJavaTask
(
String
param
)
throws
Exception
;
}
}
byit-myth-admin/src/main/java/com/byit/service/impl/ApiNodeServiceImpl.java
View file @
e9927964
package
com
.
byit
.
service
.
impl
;
package
com
.
byit
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.dto.plugin.JavaTask
;
import
com.byit.dto.plugin.RunLog
;
import
com.byit.dto.plugin.RunLog
;
import
com.byit.dto.plugin.RunNode
;
import
com.byit.dto.plugin.RunNode
;
import
com.byit.enums.NodePropertyEnum
;
import
com.byit.enums.NodePropertyEnum
;
import
com.byit.enums.ScheduleTypeEnum
;
import
com.byit.enums.ScheduleTypeEnum
;
import
com.byit.job.WorkRoulette
;
import
com.byit.job.WorkRoulette
;
import
com.byit.job.utils.CronExpression
;
import
com.byit.job.utils.PlaceholderUtils
;
import
com.byit.job.utils.PlaceholderUtils
;
import
com.byit.mapper.JavaTaskMapper
;
import
com.byit.mapper.JobTaskRunLogMapper
;
import
com.byit.mapper.JobTaskRunLogMapper
;
import
com.byit.model.JobTaskRunLog
;
import
com.byit.model.JobTaskRunLog
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
...
@@ -18,9 +21,12 @@ import io.netty.util.TimerTask;
...
@@ -18,9 +21,12 @@ import io.netty.util.TimerTask;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
static
com
.
alibaba
.
fastjson
.
serializer
.
SerializerFeature
.
WriteClassName
;
import
static
com
.
alibaba
.
fastjson
.
serializer
.
SerializerFeature
.
WriteClassName
;
...
@@ -29,6 +35,7 @@ import static com.alibaba.fastjson.serializer.SerializerFeature.WriteClassName;
...
@@ -29,6 +35,7 @@ import static com.alibaba.fastjson.serializer.SerializerFeature.WriteClassName;
* @author guo_m
* @author guo_m
*/
*/
@Service
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
ApiNodeServiceImpl
implements
ApiNodeService
{
public
class
ApiNodeServiceImpl
implements
ApiNodeService
{
@Resource
@Resource
...
@@ -37,6 +44,9 @@ public class ApiNodeServiceImpl implements ApiNodeService {
...
@@ -37,6 +44,9 @@ public class ApiNodeServiceImpl implements ApiNodeService {
@Resource
@Resource
private
StringRedisTemplate
stringRedisTemplate
;
private
StringRedisTemplate
stringRedisTemplate
;
@Resource
private
JavaTaskMapper
javaTaskMapper
;
@Override
@Override
public
String
runNode
(
String
param
)
{
public
String
runNode
(
String
param
)
{
...
@@ -95,4 +105,38 @@ public class ApiNodeServiceImpl implements ApiNodeService {
...
@@ -95,4 +105,38 @@ public class ApiNodeServiceImpl implements ApiNodeService {
return
jobTaskRunLogList
;
return
jobTaskRunLogList
;
}
}
@Override
public
void
autoAddJavaTask
(
String
param
)
throws
Exception
{
ValidationUtil
.
dataNotBank
(
param
,
"请求参数不允许为空!"
);
JavaTask
javaTask
=
JSON
.
parseObject
(
param
,
JavaTask
.
class
);
ValidationUtil
.
dataNotBank
(
javaTask
.
getTaskName
(),
"任务实现类的名称不允许为空!"
);
ValidationUtil
.
dataNotBank
(
javaTask
.
getCron
(),
"任务的调度时间不允许为空!"
);
ValidationUtil
.
isTrueValidation
(!
CronExpression
.
isValidExpression
(
javaTask
.
getCron
()),
"工作流cron表达式不符合规范!"
);
//自动发布taskName默认为jobName
javaTask
.
setJobName
(
javaTask
.
getTaskName
());
//如果不为空且不为-1
if
(
null
!=
javaTask
.
getRepeatCount
()
&&
-
1
!=
javaTask
.
getRepeatCount
()){
javaTask
.
setRemainingCount
(
javaTask
.
getRemainingCount
());
}
if
(
null
!=
javaTask
.
getAlarmlAction
()
&&
"0"
.
equals
(
javaTask
.
getRepeatCount
())){
ValidationUtil
.
dataNotBank
(
javaTask
.
getAlarmEmail
(),
"设置为告警时告警邮箱不允许为空"
);
}
JavaTask
oldJavaTask
=
javaTaskMapper
.
findByJobName
(
javaTask
.
getJobName
());
if
(
null
!=
oldJavaTask
){
//更新配置项
oldJavaTask
.
setCron
(
javaTask
.
getCron
());
oldJavaTask
.
setRepeatCount
(
javaTask
.
getRepeatCount
());
oldJavaTask
.
setRemainingCount
(
javaTask
.
getRemainingCount
());
if
(
null
!=
javaTask
.
getAlarmlAction
()
&&
"0"
.
equals
(
javaTask
.
getRepeatCount
())){
oldJavaTask
.
setAlarmlAction
(
javaTask
.
getAlarmlAction
());
oldJavaTask
.
setAlarmEmail
(
javaTask
.
getAlarmEmail
());
}
javaTaskMapper
.
updateByIdSelective
(
oldJavaTask
);
}
else
{
javaTask
.
setTriggerTime
(
new
CronExpression
(
javaTask
.
getCron
()).
getNextValidTimeAfter
(
new
Date
()).
getTime
());
javaTask
.
setCreateTime
(
new
Date
());
javaTaskMapper
.
insertSelective
(
javaTask
);
}
}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/mapper/JavaTaskMapper.java
View file @
e9927964
...
@@ -11,4 +11,5 @@ public interface JavaTaskMapper {
...
@@ -11,4 +11,5 @@ public interface JavaTaskMapper {
int
updateByIdSelective
(
JavaTask
record
);
int
updateByIdSelective
(
JavaTask
record
);
JavaTask
findByJobName
(
String
jobName
);
}
}
\ No newline at end of file
byit-myth-core/myth-admin-core/src/main/resources/mapper/JavaTaskMapper.xml
View file @
e9927964
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"job_name"
jdbcType=
"VARCHAR"
property=
"jobName"
/>
<result
column=
"job_name"
jdbcType=
"VARCHAR"
property=
"jobName"
/>
<result
column=
"task_name"
jdbcType=
"VARCHAR"
property=
"taskName"
/>
<result
column=
"task_name"
jdbcType=
"VARCHAR"
property=
"taskName"
/>
<result
column=
"
scheduling_count"
jdbcType=
"INTEGER"
property=
"scheduling
Count"
/>
<result
column=
"
repeat_count"
jdbcType=
"INTEGER"
property=
"repeat
Count"
/>
<result
column=
"param"
jdbcType=
"VARCHAR"
property=
"param"
/>
<result
column=
"param"
jdbcType=
"VARCHAR"
property=
"param"
/>
<result
column=
"trigger_time"
jdbcType=
"BIGINT"
property=
"triggerTime"
/>
<result
column=
"trigger_time"
jdbcType=
"BIGINT"
property=
"triggerTime"
/>
<result
column=
"cron"
jdbcType=
"VARCHAR"
property=
"cron"
/>
<result
column=
"cron"
jdbcType=
"VARCHAR"
property=
"cron"
/>
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
<!-- generated @mbg.generated date: 2020-04-14 -->
<!-- generated @mbg.generated date: 2020-04-14 -->
id, job_name, task_name,
scheduling
_count, param, trigger_time, cron, remaining_count,
id, job_name, task_name,
repeat
_count, param, trigger_time, cron, remaining_count,
create_time, update_time, alarml_action, alarm_email
create_time, update_time, alarml_action, alarm_email
</sql>
</sql>
<select
id=
"getById"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
<select
id=
"getById"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
delete from java_task
delete from java_task
where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</delete>
</delete>
<insert
id=
"insertSelective"
parameterType=
"com.byit.dto.plugin.JavaTask"
>
<insert
id=
"insertSelective"
parameterType=
"com.byit.dto.plugin.JavaTask"
>
<!-- generated @mbg.generated date: 2020-04-14 -->
<!-- generated @mbg.generated date: 2020-04-14 -->
insert into java_task
insert into java_task
...
@@ -47,8 +46,8 @@
...
@@ -47,8 +46,8 @@
<if
test=
"taskName != null"
>
<if
test=
"taskName != null"
>
task_name,
task_name,
</if>
</if>
<if
test=
"
scheduling
Count != null"
>
<if
test=
"
repeat
Count != null"
>
scheduling
_count,
repeat
_count,
</if>
</if>
<if
test=
"param != null"
>
<if
test=
"param != null"
>
param,
param,
...
@@ -85,8 +84,8 @@
...
@@ -85,8 +84,8 @@
<if
test=
"taskName != null"
>
<if
test=
"taskName != null"
>
#{taskName,jdbcType=VARCHAR},
#{taskName,jdbcType=VARCHAR},
</if>
</if>
<if
test=
"
scheduling
Count != null"
>
<if
test=
"
repeat
Count != null"
>
#{
scheduling
Count,jdbcType=INTEGER},
#{
repeat
Count,jdbcType=INTEGER},
</if>
</if>
<if
test=
"param != null"
>
<if
test=
"param != null"
>
#{param,jdbcType=VARCHAR},
#{param,jdbcType=VARCHAR},
...
@@ -124,8 +123,8 @@
...
@@ -124,8 +123,8 @@
<if
test=
"taskName != null"
>
<if
test=
"taskName != null"
>
task_name = #{taskName,jdbcType=VARCHAR},
task_name = #{taskName,jdbcType=VARCHAR},
</if>
</if>
<if
test=
"
scheduling
Count != null"
>
<if
test=
"
repeat
Count != null"
>
scheduling_count = #{scheduling
Count,jdbcType=INTEGER},
repeat_count = #{repeat
Count,jdbcType=INTEGER},
</if>
</if>
<if
test=
"param != null"
>
<if
test=
"param != null"
>
param = #{param,jdbcType=VARCHAR},
param = #{param,jdbcType=VARCHAR},
...
@@ -154,5 +153,11 @@
...
@@ -154,5 +153,11 @@
</set>
</set>
where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</update>
<select
id=
"findByJobName"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from java_task
where job_name = #{jobName,jdbcType=VARCHAR}
</select>
</mapper>
</mapper>
\ No newline at end of file
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/plugin/JavaTask.java
View file @
e9927964
...
@@ -33,7 +33,7 @@ public class JavaTask implements Serializable {
...
@@ -33,7 +33,7 @@ public class JavaTask implements Serializable {
/**
/**
* 调度次数 -1周期性调度
* 调度次数 -1周期性调度
*/
*/
private
Integer
scheduling
Count
;
private
Integer
repeat
Count
;
/**
/**
* 参数
* 参数
...
...
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