Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
9a92cec7
Commit
9a92cec7
authored
May 18, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将源码打包进jar包
parent
9e4c89ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
11 deletions
+44
-11
PlanRegister.java
...main/java/com.yanzuoguang.redis/service/PlanRegister.java
+44
-11
No files found.
yzg-util-redis/src/main/java/com.yanzuoguang.redis/service/PlanRegister.java
View file @
9a92cec7
...
...
@@ -6,6 +6,8 @@ import com.yanzuoguang.redis.def.PlanNameDefault;
import
com.yanzuoguang.redis.def.PlanStartDefault
;
import
com.yanzuoguang.redis.vo.PlanConfigVo
;
import
com.yanzuoguang.redis.vo.PlanLevelType
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
org.springframework.stereotype.Component
;
...
...
@@ -34,14 +36,7 @@ public class PlanRegister {
public
PlanRegister
(
Optional
<
List
<
Plan
>>
plans
,
List
<
PlanLevelNamespaceDefault
>
planLevelNamespaceDefaults
)
{
// 先注册默认命名空间处理
planLevelNamespaceDefaults
.
forEach
(
k
->
{
PlanLevelType
level
=
k
.
getLevel
();
if
(
mapLevelTypeNamespaceDefault
.
containsKey
(
level
))
{
Log
.
error
(
PlanRegister
.
class
,
"默认命名级别处理%s已经存在!"
,
level
.
getName
());
return
;
}
mapLevelTypeNamespaceDefault
.
put
(
level
,
k
);
});
planLevelNamespaceDefaults
.
forEach
(
this
::
registerNamespaceDefault
);
// 再注册所有任务
plans
.
ifPresent
(
planList
->
planList
.
forEach
(
this
::
register
));
}
...
...
@@ -65,12 +60,29 @@ public class PlanRegister {
return
mapPlan
.
get
(
key
);
}
/**
* 任务命名级别
*
* @param planLevelNamespaceDefault 默认任务命名级别命名空间
*/
public
void
registerNamespaceDefault
(
PlanLevelNamespaceDefault
planLevelNamespaceDefault
)
{
if
(
planLevelNamespaceDefault
==
null
)
{
return
;
}
PlanLevelType
level
=
planLevelNamespaceDefault
.
getLevel
();
if
(
mapLevelTypeNamespaceDefault
.
containsKey
(
level
))
{
Log
.
error
(
PlanRegister
.
class
,
"默认命名级别处理%s已经存在!"
,
level
.
getName
());
return
;
}
mapLevelTypeNamespaceDefault
.
put
(
level
,
planLevelNamespaceDefault
);
}
/**
* 注册任务
*
* @param plan 待注册的任务
*/
p
rivate
void
register
(
Plan
plan
)
{
p
ublic
void
register
(
Plan
plan
)
{
if
(
plan
==
null
)
{
return
;
}
...
...
@@ -86,9 +98,30 @@ public class PlanRegister {
// 任务关键字
PlanName
planName
=
getPlanName
(
plan
);
// 任务配置信息
PlanConfigVo
planConfigVo
=
new
PlanConfigVo
(
plan
,
planName
,
planStart
,
planLevelNamespace
);
PlanConfigVo
planConfig
=
new
PlanConfigVo
(
plan
,
planName
,
planStart
,
planLevelNamespace
);
// 任务配置
register
(
planConfig
);
}
/**
* 注册中心
*
* @param planConfig 任务配置
*/
public
void
register
(
PlanConfigVo
planConfig
)
{
if
(
planConfig
==
null
)
{
return
;
}
if
(
planConfig
.
getPlan
()
==
null
||
planConfig
.
getPlanStart
()
==
null
||
planConfig
.
getPlanName
()
==
null
||
planConfig
.
getPlanLevelNamespace
()
==
null
||
StringHelper
.
isEmpty
(
planConfig
.
getPlanName
().
getPlanKey
())
)
{
throw
new
CodeException
(
"注册任务失败,参数不能为空"
);
}
// 任务配置
mapPlan
.
put
(
plan
Name
.
getPlanKey
(),
planConfigVo
);
mapPlan
.
put
(
plan
Config
.
getPlanName
().
getPlanKey
(),
planConfig
);
}
/**
...
...
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