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
d38fa189
Commit
d38fa189
authored
Dec 15, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
参数包装
parent
cf9123a9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
19 deletions
+134
-19
ApiFlowServiceImpl.java
...c/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
+3
-17
MakeUpScriptTaskCallbackRunTheLifeCycleCallback.java
...task/MakeUpScriptTaskCallbackRunTheLifeCycleCallback.java
+105
-0
ParamWrappedCallback.java
...ain/java/com/byit/strategy/task/ParamWrappedCallback.java
+25
-1
ScriptSpecialParametersTaskRunTheLifeCycleCallback.java
...k/ScriptSpecialParametersTaskRunTheLifeCycleCallback.java
+1
-1
No files found.
byit-myth-admin/src/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
View file @
d38fa189
...
...
@@ -1338,8 +1338,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if
(
CollectionUtil
.
isEmpty
(
publicParamMap
)){
publicParamMap
=
new
HashMap
<>(
8
);
}
publicParamMap
.
put
(
PlaceholderEnum
.
DATE_PLACEHOLDER
.
getName
(),
repairTime
);
publicParamMap
.
put
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
(),
repairTime
);
publicParamMap
.
put
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
(),
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
)
);
flowExtendedConfiguration
.
setPublicParam
(
JSON
.
toJSONString
(
publicParamMap
));
waitingRecord
.
setExtendedConfiguration
(
JSON
.
toJSONString
(
flowExtendedConfiguration
));
//需要按着时间先后来设置时间
...
...
@@ -1423,22 +1425,6 @@ public class ApiFlowServiceImpl implements ApiFlowService {
}
String
nowDateFormatPlaceholder
=
placeholder
.
get
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
());
if
(
StringUtils
.
isBlank
(
nowDateFormatPlaceholder
))
{
nowDateFormatPlaceholder
=
"yyyyMMdd"
;
}
String
nowDateFormatParam
=
param
.
get
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
());
if
(
StringUtils
.
isBlank
(
nowDateFormatPlaceholder
))
{
nowDateFormatPlaceholder
=
"yyyyMMdd"
;
}
param
.
put
(
PlaceholderEnum
.
DATE_PLACEHOLDER
.
getName
(),
repairTime
);
param
.
put
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
(),
DateUtil
.
format
(
new
Date
(),
nowDateFormatParam
));
placeholder
.
put
(
PlaceholderEnum
.
DATE_PLACEHOLDER
.
getName
(),
repairTime
);
placeholder
.
put
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
(),
DateUtil
.
format
(
new
Date
(),
nowDateFormatPlaceholder
));
scriptParamAndPlaceholderDto
.
setParam
(
param
);
scriptParamAndPlaceholderDto
.
setPlaceholder
(
placeholder
);
WaitingTask
waitingTaskCopy
=
new
WaitingTask
();
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/strategy/task/MakeUpScriptTaskCallbackRunTheLifeCycleCallback.java
0 → 100644
View file @
d38fa189
package
com
.
byit
.
strategy
.
task
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.annotations.MythRankOrder
;
import
com.byit.dto.executor.RunParamWrapped
;
import
com.byit.dto.executor.ScriptParamAndPlaceholderDto
;
import
com.byit.dto.plugin.FlowExtendedConfiguration
;
import
com.byit.enums.NodeTypeEnum
;
import
com.byit.enums.PlaceholderEnum
;
import
com.byit.enums.ScheduleTypeEnum
;
import
com.byit.mapper.RunRecordingMapper
;
import
com.byit.model.JobTaskSchedule
;
import
com.byit.model.RunRecording
;
import
com.byit.strategy.TaskRunTheLifeCycleCallback
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
java.util.Map
;
/**
* @author huangfu
*/
@Component
@Slf4j
@MythRankOrder
(
2
)
public
class
MakeUpScriptTaskCallbackRunTheLifeCycleCallback
implements
TaskRunTheLifeCycleCallback
{
public
static
final
String
SCRIPT
=
"SCRIPT"
;
private
final
RunRecordingMapper
runRecordingService
;
public
MakeUpScriptTaskCallbackRunTheLifeCycleCallback
(
RunRecordingMapper
runRecordingService
)
{
this
.
runRecordingService
=
runRecordingService
;
}
/**
* 判断是否匹配类型
*
* @param jobTaskSchedule 任务对象
* @return 是否匹配本次的执行对象
*/
@Override
public
boolean
matchType
(
JobTaskSchedule
jobTaskSchedule
)
{
String
jobType
=
jobTaskSchedule
.
getJobType
();
NodeTypeEnum
typeByCode
=
NodeTypeEnum
.
getTypeByCode
(
jobType
);
if
(
typeByCode
==
null
)
{
throw
new
RuntimeException
(
String
.
format
(
"调度暂不支持此种类型的任务:%s"
,
jobType
));
}
//是否是脚本类型的
boolean
isScript
=
typeByCode
.
getType
().
equals
(
SCRIPT
);
//是否是重跑或者补批
boolean
isNormal
=
ScheduleTypeEnum
.
REPEAT
.
getCode
().
equals
(
jobTaskSchedule
.
getScheduleType
())
||
ScheduleTypeEnum
.
REPAIR
.
getCode
().
equals
(
jobTaskSchedule
.
getScheduleType
());
return
isScript
&&
isNormal
;
}
/**
* 实例执行前
*
* @param jobTaskSchedule 任务对象
*/
@Override
public
void
postProcessAfterInitialization
(
JobTaskSchedule
jobTaskSchedule
)
{
String
runId
=
jobTaskSchedule
.
getRunId
();
String
flowName
=
jobTaskSchedule
.
getFlowName
();
RunRecording
runRecording
=
runRecordingService
.
findAllByRunIDAndFlowName
(
runId
,
flowName
);
String
extendedConfiguration
=
runRecording
.
getExtendedConfiguration
();
FlowExtendedConfiguration
flowExtendedConfiguration
=
JSON
.
parseObject
(
extendedConfiguration
,
FlowExtendedConfiguration
.
class
);
String
publicParam
=
flowExtendedConfiguration
.
getPublicParam
();
Map
<
String
,
String
>
publicParamMap
=
JSON
.
parseObject
(
publicParam
,
Map
.
class
);
String
runParam
=
jobTaskSchedule
.
getRunParam
();
RunParamWrapped
runParamWrapped
=
JSON
.
parseObject
(
runParam
,
RunParamWrapped
.
class
);
String
privateParam
=
runParamWrapped
.
getPrivateParam
();
ScriptParamAndPlaceholderDto
scriptParamAndPlaceholderDto
=
JSON
.
parseObject
(
privateParam
,
ScriptParamAndPlaceholderDto
.
class
);
Map
<
String
,
String
>
param
=
scriptParamAndPlaceholderDto
.
getParam
();
Map
<
String
,
String
>
placeholder
=
scriptParamAndPlaceholderDto
.
getPlaceholder
();
String
nowDateFormatPh
=
"yyyyMMdd"
;
String
nowDateFormatPr
=
"yyyyMMdd"
;
if
(
param
.
containsKey
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
()))
{
nowDateFormatPr
=
param
.
get
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
());
param
.
remove
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
());
}
if
(
placeholder
.
containsKey
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
()))
{
nowDateFormatPh
=
param
.
get
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
());
placeholder
.
remove
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
());
}
//获取公共参数里面的biz_date
String
bizDateStr
=
publicParamMap
.
get
(
PlaceholderEnum
.
DATE_PLACEHOLDER
.
getName
());
param
.
put
(
PlaceholderEnum
.
DATE_PLACEHOLDER
.
getName
(),
bizDateStr
);
placeholder
.
put
(
PlaceholderEnum
.
DATE_PLACEHOLDER
.
getName
(),
bizDateStr
);
//生成 now_date
param
.
put
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
(),
DateUtil
.
format
(
new
Date
(),
nowDateFormatPr
));
placeholder
.
put
(
PlaceholderEnum
.
NOW_DATE_PLACEHOLDER
.
getName
(),
DateUtil
.
format
(
new
Date
(),
nowDateFormatPh
));
//设置参数
scriptParamAndPlaceholderDto
.
setParam
(
param
);
scriptParamAndPlaceholderDto
.
setPlaceholder
(
placeholder
);
runParamWrapped
.
setPrivateParam
(
JSON
.
toJSONString
(
scriptParamAndPlaceholderDto
));
jobTaskSchedule
.
setRunParam
(
JSON
.
toJSONString
(
runParamWrapped
));
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/strategy/task/ParamWrappedCallback.java
View file @
d38fa189
package
com
.
byit
.
strategy
.
task
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.annotations.MythRankOrder
;
import
com.byit.dto.executor.RunParamWrapped
;
import
com.byit.dto.executor.ScriptParamAndPlaceholderDto
;
import
com.byit.model.JobTaskSchedule
;
import
com.byit.strategy.TaskRunTheLifeCycleCallback
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 参数对象包装
*
...
...
@@ -28,7 +33,26 @@ public class ParamWrappedCallback implements TaskRunTheLifeCycleCallback {
public
void
postProcessAfterInitialization
(
JobTaskSchedule
jobTaskSchedule
)
{
String
runParam
=
jobTaskSchedule
.
getRunParam
();
RunParamWrapped
runParamWrapped
=
new
RunParamWrapped
();
runParamWrapped
.
setPrivateParam
(
runParam
);
runParamWrapped
.
setPublicParamMap
(
new
HashMap
<>(
8
));
ScriptParamAndPlaceholderDto
scriptParamAndPlaceholderDto
=
JSON
.
parseObject
(
runParam
,
ScriptParamAndPlaceholderDto
.
class
);
if
(
scriptParamAndPlaceholderDto
==
null
)
{
scriptParamAndPlaceholderDto
=
new
ScriptParamAndPlaceholderDto
();
}
Map
<
String
,
String
>
placeholder
=
scriptParamAndPlaceholderDto
.
getPlaceholder
();
Map
<
String
,
String
>
param
=
scriptParamAndPlaceholderDto
.
getParam
();
if
(
CollectionUtil
.
isEmpty
(
placeholder
)){
placeholder
=
new
HashMap
<>(
8
);
}
if
(
CollectionUtil
.
isEmpty
(
param
)){
param
=
new
HashMap
<>(
8
);
}
scriptParamAndPlaceholderDto
.
setPlaceholder
(
placeholder
);
scriptParamAndPlaceholderDto
.
setParam
(
param
);
runParamWrapped
.
setPrivateParam
(
JSON
.
toJSONString
(
scriptParamAndPlaceholderDto
));
jobTaskSchedule
.
setRunParam
(
JSON
.
toJSONString
(
runParamWrapped
));
}
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/strategy/task/ScriptSpecialParametersTaskRunTheLifeCycleCallback.java
View file @
d38fa189
...
...
@@ -30,7 +30,7 @@ import java.util.Map;
*/
@Component
@Slf4j
@MythRankOrder
(
2
)
@MythRankOrder
(
3
)
public
class
ScriptSpecialParametersTaskRunTheLifeCycleCallback
implements
TaskRunTheLifeCycleCallback
{
/**
* 脚本类型的数据
...
...
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