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
06cc2029
Commit
06cc2029
authored
Apr 03, 2020
by
guominglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提供统计数据接口开发和修改
parent
313d2ce8
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
304 additions
and
58 deletions
+304
-58
ApiFlowController.java
...h-admin/src/main/java/com/byit/api/ApiFlowController.java
+19
-0
ApiFlowService.java
...-admin/src/main/java/com/byit/service/ApiFlowService.java
+7
-0
ApiFlowServiceImpl.java
...c/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
+123
-38
WaitingRecordMapper.java
...re/src/main/java/com/byit/mapper/WaitingRecordMapper.java
+16
-0
WaitingTaskMapper.java
...core/src/main/java/com/byit/mapper/WaitingTaskMapper.java
+9
-0
StatusSnapshootThreadRunHelper.java
...om/byit/thread/helper/StatusSnapshootThreadRunHelper.java
+45
-13
JobTaskRunLogMapper.xml
...in-core/src/main/resources/mapper/JobTaskRunLogMapper.xml
+2
-2
RunRecordingMapper.xml
...min-core/src/main/resources/mapper/RunRecordingMapper.xml
+2
-2
WaitingRecordMapper.xml
...in-core/src/main/resources/mapper/WaitingRecordMapper.xml
+18
-0
WaitingTaskMapper.xml
...dmin-core/src/main/resources/mapper/WaitingTaskMapper.xml
+12
-0
CollectData.java
...o-core/src/main/java/com/byit/dto/plugin/CollectData.java
+7
-2
JobUtils.java
...xecutor-plugin/src/main/java/com/byit/utils/JobUtils.java
+44
-1
No files found.
byit-myth-admin/src/main/java/com/byit/api/ApiFlowController.java
View file @
06cc2029
...
...
@@ -161,9 +161,28 @@ public class ApiFlowController {
return
ResponseResult
.
ok
(
"SUCCESS"
);
}
/**
* 获取整体运行的统计数据
* @param param
* @return
*/
@PostMapping
(
"/loadStatisticData"
)
@ApiOperation
(
"获取运行的统计数据"
)
public
ResponseResult
loadStatisticData
(
String
param
){
CollectData
collectData
=
apiFlowService
.
loadStatisticData
(
param
);
return
ResponseResult
.
ok
(
collectData
);
}
/**
* 获取节点运行的统计数据
* @param param
* @return
*/
@PostMapping
(
"/loadNodeStatisticData"
)
@ApiOperation
(
"获取运行的统计数据"
)
public
ResponseResult
loadNodeStatisticData
(
String
param
){
CollectData
collectData
=
apiFlowService
.
loadNodeStatisticData
(
param
);
return
ResponseResult
.
ok
(
collectData
);
}
}
byit-myth-admin/src/main/java/com/byit/service/ApiFlowService.java
View file @
06cc2029
...
...
@@ -88,4 +88,11 @@ public interface ApiFlowService {
* @return
*/
CollectData
loadStatisticData
(
String
param
);
/**
* 获取节点的汇总数据
* @param param
* @return
*/
CollectData
loadNodeStatisticData
(
String
param
);
}
byit-myth-admin/src/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
View file @
06cc2029
...
...
@@ -709,64 +709,149 @@ public class ApiFlowServiceImpl implements ApiFlowService {
ValidationUtil
.
dataNotNull
(
endTime
,
"结束时间不允许为空!"
);
ValidationUtil
.
isTrueValidation
(
String
.
valueOf
(
startTime
).
length
()
<
13
||
String
.
valueOf
(
endTime
).
length
()
<
13
,
"时间格式必须是毫秒"
);
//获取工作流名称
String
flowName
=
jsonObject
.
getString
(
"flowName"
);
List
<
Integer
>
flowIdList
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotEmpty
(
flowName
)){
Flow
flow
=
flowMapper
.
getByWorkSpaceAndName
(
workspace
.
getWorkspaceId
(),
flowName
);
ValidationUtil
.
dataNotNull
(
flow
,
"工作流不存在!"
);
flowIdList
.
add
(
flow
.
getFlowId
());
if
(
FlowPropertyEnum
.
IS_INNER
.
getCode
().
equals
(
flow
.
getIsInner
())){
List
<
RunRecording
>
runRecordingList
=
runRecordingMapper
.
findByStartAndEndTime
(
startTime
,
endTime
,
flowIdList
,
null
,
null
);
flowIdList
.
clear
();
runRecordingList
.
forEach
(
runRecording
->
flowIdList
.
add
(
runRecording
.
getFlowId
()));
}
}
else
{
List
<
Flow
>
flowList
=
flowMapper
.
findByWorkspace
(
workspace
.
getWorkspaceId
());
if
(
flowList
!=
null
&&
flowList
.
size
()
>
0
){
flowList
.
forEach
(
flow
->
flowIdList
.
add
(
flow
.
getFlowId
()));
}
}
//如果工作空间下面有数据
if
(
flowIdList
.
size
()
>
0
){
StatisticData
flowStatisticData
=
runRecordingMapper
.
findStatusByStartAndEndTime
(
startTime
,
endTime
,
flowIdList
);
StatisticData
unstartflowStatisticData
=
waitingRecordMapper
.
findStatusByStartAndEndTime
(
flowIdList
);
if
(
null
!=
unstartflowStatisticData
){
flowStatisticData
.
setUnstart
(
flowStatisticData
.
getUnstart
()
+
unstartflowStatisticData
.
getUnstart
());
}
StatisticData
nodeStatisticData
=
jobTaskRunLogMapper
.
findStatusByStartAndEndTime
(
startTime
,
endTime
,
flowIdList
);
StatisticData
unstartNodeStatisticData
=
waitingTaskMapper
.
findStatusByStartAndEndTime
(
flowIdList
);
if
(
null
!=
unstartNodeStatisticData
){
nodeStatisticData
.
setUnstart
(
nodeStatisticData
.
getUnstart
()
+
unstartNodeStatisticData
.
getUnstart
());
}
List
<
FlowStatusSnapshoot
>
flowStatusSnapshootList
=
flowStatusSnapshootMapper
.
findByTime
(
startTime
,
endTime
);
Map
<
String
,
StatisticData
>
collectMap
=
new
HashMap
<>();
Map
<
String
,
StatisticData
>
flowCollectMap
=
new
HashMap
<>();
Map
<
String
,
StatisticData
>
nodeCollectMap
=
new
HashMap
<>();
flowStatusSnapshootList
.
forEach
(
flowStatusSnapshoot
->
{
String
key
=
flowStatusSnapshoot
.
getDay
()
+
" "
+
flowStatusSnapshoot
.
getHour
();
StatisticData
statisticData
=
collectMap
.
get
(
key
);
if
(
null
==
statisticData
){
statisticData
=
new
StatisticData
();
statisticData
.
setUnstart
(
flowStatusSnapshoot
.
getUnstartNode
());
statisticData
.
setRunIng
(
flowStatusSnapshoot
.
getRuningNode
());
statisticData
.
setSuccess
(
flowStatusSnapshoot
.
getSuccessNode
());
statisticData
.
setFail
(
flowStatusSnapshoot
.
getFailNode
());
statisticData
.
setKill
(
flowStatusSnapshoot
.
getKillNode
());
collectMap
.
put
(
key
,
statisticData
);
StatisticData
nodeHourStatisticData
=
nodeCollectMap
.
get
(
key
);
StatisticData
flowHourStatisticData
=
flowCollectMap
.
get
(
key
);
if
(
null
==
nodeHourStatisticData
){
flowHourStatisticData
=
new
StatisticData
();
buildFlowHourStatisticData
(
flowHourStatisticData
,
flowStatusSnapshoot
);
nodeHourStatisticData
=
new
StatisticData
();
nodeHourStatisticData
.
setUnstart
(
flowStatusSnapshoot
.
getUnstartNode
());
nodeHourStatisticData
.
setRunIng
(
flowStatusSnapshoot
.
getRuningNode
());
nodeHourStatisticData
.
setSuccess
(
flowStatusSnapshoot
.
getSuccessNode
());
nodeHourStatisticData
.
setFail
(
flowStatusSnapshoot
.
getFailNode
());
nodeHourStatisticData
.
setKill
(
flowStatusSnapshoot
.
getKillNode
());
}
else
{
statisticData
.
setUnstart
(
statisticData
.
getUnstart
()
+
flowStatusSnapshoot
.
getUnstartNode
());
statisticData
.
setRunIng
(
statisticData
.
getRunIng
()
+
flowStatusSnapshoot
.
getRuningNode
());
statisticData
.
setSuccess
(
statisticData
.
getSuccess
()
+
flowStatusSnapshoot
.
getSuccessNode
());
statisticData
.
setFail
(
statisticData
.
getFail
()
+
flowStatusSnapshoot
.
getFailNode
());
statisticData
.
setKill
(
statisticData
.
getKill
()
+
flowStatusSnapshoot
.
getKillNode
());
collectMap
.
put
(
key
,
statisticData
);
}
buildFlowHourStatisticData
(
flowHourStatisticData
,
flowStatusSnapshoot
);
nodeHourStatisticData
.
setUnstart
(
nodeHourStatisticData
.
getUnstart
()
+
flowStatusSnapshoot
.
getUnstartNode
());
nodeHourStatisticData
.
setRunIng
(
nodeHourStatisticData
.
getRunIng
()
+
flowStatusSnapshoot
.
getRuningNode
());
nodeHourStatisticData
.
setSuccess
(
nodeHourStatisticData
.
getSuccess
()
+
flowStatusSnapshoot
.
getSuccessNode
());
nodeHourStatisticData
.
setFail
(
nodeHourStatisticData
.
getFail
()
+
flowStatusSnapshoot
.
getFailNode
());
nodeHourStatisticData
.
setKill
(
nodeHourStatisticData
.
getKill
()
+
flowStatusSnapshoot
.
getKillNode
());
}
flowCollectMap
.
put
(
key
,
flowHourStatisticData
);
nodeCollectMap
.
put
(
key
,
nodeHourStatisticData
);
});
CollectData
collectData
=
new
CollectData
();
collectData
.
setFlowData
(
flowStatisticData
);
collectData
.
setNodeData
(
nodeStatisticData
);
collectData
.
setCollectMap
(
collectMap
);
collectData
.
setNodeCollectMap
(
nodeCollectMap
);
collectData
.
setFlowCollectMap
(
flowCollectMap
);
return
collectData
;
}
return
null
;
}
/**
* 构建统计数据
* @param flowHourStatisticData
* @param flowStatusSnapshoot
*/
private
void
buildFlowHourStatisticData
(
StatisticData
flowHourStatisticData
,
FlowStatusSnapshoot
flowStatusSnapshoot
){
switch
(
flowStatusSnapshoot
.
getFlowStatus
()){
case
1
:
flowHourStatisticData
.
setUnstart
(
flowHourStatisticData
.
getUnstart
()
+
1
);
break
;
case
2
:
flowHourStatisticData
.
setRunIng
(
flowHourStatisticData
.
getRunIng
()
+
1
);
break
;
case
3
:
flowHourStatisticData
.
setStop
(
flowHourStatisticData
.
getStop
()
+
1
);
break
;
case
4
:
flowHourStatisticData
.
setSuccess
(
flowHourStatisticData
.
getSuccess
()
+
1
);
break
;
case
5
:
flowHourStatisticData
.
setFail
(
flowHourStatisticData
.
getFail
()
+
1
);
break
;
case
6
:
flowHourStatisticData
.
setKill
(
flowHourStatisticData
.
getFail
()
+
1
);
break
;
default
:
break
;
}
}
public
static
void
main
(
String
[]
args
)
throws
ParseException
{
String
str
=
"20200401"
;
SimpleDateFormat
ssss
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh"
);
Date
date
=
new
Date
();
System
.
out
.
println
(
ssss
.
format
(
date
));
System
.
out
.
println
(
sdf
.
parse
(
str
));
@Override
public
CollectData
loadNodeStatisticData
(
String
param
){
ValidationUtil
.
dataNotBank
(
param
,
"请求参数不允许为空!"
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
param
);
//获取工作空间名称
String
workspaceName
=
jsonObject
.
getString
(
"workspaceName"
);
ValidationUtil
.
dataNotBank
(
workspaceName
,
"工作空间名称不允许为空!"
);
//开始校验
Workspace
workspace
=
workspaceMapper
.
getByName
(
workspaceName
);
ValidationUtil
.
dataNotNull
(
workspace
,
workspaceName
+
"工作空间不存在"
);
//获取时间间隔
Long
startTime
=
jsonObject
.
getLong
(
"startTime"
);
ValidationUtil
.
dataNotNull
(
startTime
,
"开始时间不允许为空!"
);
Long
endTime
=
jsonObject
.
getLong
(
"endTime"
);
ValidationUtil
.
dataNotNull
(
endTime
,
"结束时间不允许为空!"
);
//校验时间间隔
ValidationUtil
.
isTrueValidation
(
String
.
valueOf
(
startTime
).
length
()
<
13
||
String
.
valueOf
(
endTime
).
length
()
<
13
,
"时间格式必须是毫秒"
);
//获取工作流名称
String
flowName
=
jsonObject
.
getString
(
"flowName"
);
ValidationUtil
.
dataNotBank
(
flowName
,
"工作流名称不允许为空!"
);
Flow
flow
=
flowMapper
.
getByWorkSpaceAndName
(
workspace
.
getWorkspaceId
(),
flowName
);
ValidationUtil
.
dataNotNull
(
flow
,
"工作流不存在!"
);
List
<
Integer
>
flowIdList
=
new
ArrayList
<>();
Queue
<
Integer
>
queue
=
new
LinkedList
<>();
flowIdList
.
add
(
flow
.
getFlowId
());
queue
.
offer
(
flow
.
getFlowId
());
while
(!
queue
.
isEmpty
()){
List
<
Node
>
innerFlowList
=
nodeMapper
.
findVirtualByFlowId
(
queue
.
poll
());
if
(
null
!=
innerFlowList
&&
innerFlowList
.
size
()
>
0
){
innerFlowList
.
forEach
(
node
->
{
flowIdList
.
add
(
node
.
getMapFlowId
());
queue
.
offer
(
node
.
getMapFlowId
());
});
}
}
StatisticData
nodeStatisticData
=
jobTaskRunLogMapper
.
findStatusByStartAndEndTime
(
startTime
,
endTime
,
flowIdList
);
StatisticData
unstartNodeStatisticData
=
waitingTaskMapper
.
findStatusByStartAndEndTime
(
flowIdList
);
if
(
null
!=
unstartNodeStatisticData
){
nodeStatisticData
.
setUnstart
(
nodeStatisticData
.
getUnstart
()
+
unstartNodeStatisticData
.
getUnstart
());
}
List
<
FlowStatusSnapshoot
>
flowStatusSnapshootList
=
flowStatusSnapshootMapper
.
findByTime
(
startTime
,
endTime
);
Map
<
String
,
StatisticData
>
nodeCollectMap
=
new
HashMap
<>();
flowStatusSnapshootList
.
forEach
(
flowStatusSnapshoot
->
{
String
key
=
flowStatusSnapshoot
.
getDay
()
+
" "
+
flowStatusSnapshoot
.
getHour
();
StatisticData
nodeHourStatisticData
=
nodeCollectMap
.
get
(
key
);
if
(
null
==
nodeHourStatisticData
){
nodeHourStatisticData
=
new
StatisticData
();
nodeHourStatisticData
.
setUnstart
(
flowStatusSnapshoot
.
getUnstartNode
());
nodeHourStatisticData
.
setRunIng
(
flowStatusSnapshoot
.
getRuningNode
());
nodeHourStatisticData
.
setSuccess
(
flowStatusSnapshoot
.
getSuccessNode
());
nodeHourStatisticData
.
setFail
(
flowStatusSnapshoot
.
getFailNode
());
nodeHourStatisticData
.
setKill
(
flowStatusSnapshoot
.
getKillNode
());
}
else
{
nodeHourStatisticData
.
setUnstart
(
nodeHourStatisticData
.
getUnstart
()
+
flowStatusSnapshoot
.
getUnstartNode
());
nodeHourStatisticData
.
setRunIng
(
nodeHourStatisticData
.
getRunIng
()
+
flowStatusSnapshoot
.
getRuningNode
());
nodeHourStatisticData
.
setSuccess
(
nodeHourStatisticData
.
getSuccess
()
+
flowStatusSnapshoot
.
getSuccessNode
());
nodeHourStatisticData
.
setFail
(
nodeHourStatisticData
.
getFail
()
+
flowStatusSnapshoot
.
getFailNode
());
nodeHourStatisticData
.
setKill
(
nodeHourStatisticData
.
getKill
()
+
flowStatusSnapshoot
.
getKillNode
());
}
nodeCollectMap
.
put
(
key
,
nodeHourStatisticData
);
});
CollectData
collectData
=
new
CollectData
();
collectData
.
setNodeData
(
nodeStatisticData
);
collectData
.
setNodeCollectMap
(
nodeCollectMap
);
return
collectData
;
}
/**
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/mapper/WaitingRecordMapper.java
View file @
06cc2029
package
com
.
byit
.
mapper
;
import
com.byit.dto.plugin.StatisticData
;
import
com.byit.model.WaitingRecord
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
...
...
@@ -31,4 +33,17 @@ public interface WaitingRecordMapper {
* @return
*/
Integer
findOrderByFlowId
(
Integer
flowId
);
/**
* 根据工作流id获取运行实例
* @param flowId
* @return
*/
List
<
WaitingRecord
>
findByFlowId
(
Integer
flowId
);
/**
* 查询运行汇总
* @param flowIdList
* @return
*/
StatisticData
findStatusByStartAndEndTime
(
@Param
(
"flowIdList"
)
List
<
Integer
>
flowIdList
);
}
\ No newline at end of file
byit-myth-core/myth-admin-core/src/main/java/com/byit/mapper/WaitingTaskMapper.java
View file @
06cc2029
package
com
.
byit
.
mapper
;
import
com.byit.dto.plugin.StatisticData
;
import
com.byit.model.WaitingTask
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
...
...
@@ -22,4 +24,10 @@ public interface WaitingTaskMapper {
int
updateByIdSelective
(
WaitingTask
record
);
/**
* 查询运行汇总
* @param flowIdList
* @return
*/
StatisticData
findStatusByStartAndEndTime
(
@Param
(
"flowIdList"
)
List
<
Integer
>
flowIdList
);
}
\ No newline at end of file
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/helper/StatusSnapshootThreadRunHelper.java
View file @
06cc2029
package
com
.
byit
.
thread
.
helper
;
import
com.byit.dto.plugin.StatisticData
;
import
com.byit.mapper.FlowMapper
;
import
com.byit.mapper.FlowStatusSnapshootMapper
;
import
com.byit.mapper.JobTaskRunLogMapper
;
import
com.byit.mapper.RunRecordingMapper
;
import
com.byit.model.Flow
;
import
com.byit.model.FlowStatusSnapshoot
;
import
com.byit.model.RunRecording
;
import
com.byit.mapper.*
;
import
com.byit.model.*
;
import
com.byit.thread.BaseThreadRunHelper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -39,6 +34,10 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
@Resource
private
JobTaskRunLogMapper
jobTaskRunLogMapper
;
@Resource
private
WaitingRecordMapper
waitingRecordMapper
;
@Resource
private
WaitingTaskMapper
waitingTaskMapper
;
@Resource
private
DataSource
dataSource
;
@Value
(
"${myth-job.snapshoot-date}"
)
private
Integer
snapshootDate
;
...
...
@@ -66,9 +65,6 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
List
<
FlowStatusSnapshoot
>
flowStatusSnapshootList
=
new
ArrayList
<>();
flowList
.
forEach
(
flow
->
{
RunRecording
runRecording
=
runRecordingMapper
.
findMaxByFlowId
(
flow
.
getFlowId
());
if
(
runRecording
!=
null
){
//获取凌晨的时间戳
Long
time
=
LocalDate
.
now
().
atStartOfDay
(
ZoneOffset
.
ofHours
(
8
)).
toInstant
().
toEpochMilli
();
FlowStatusSnapshoot
flowStatusSnapshoot
=
new
FlowStatusSnapshoot
();
flowStatusSnapshoot
.
setDay
(
date
);
flowStatusSnapshoot
.
setFlowId
(
flow
.
getFlowId
());
...
...
@@ -76,10 +72,18 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
flowStatusSnapshoot
.
setFlowName
(
flow
.
getFlowName
());
flowStatusSnapshoot
.
setWorkspaceId
(
flow
.
getWorkspaceId
());
flowStatusSnapshoot
.
setSnapshootTime
(
hourTime
);
if
(
time
.
longValue
()
>
runRecording
.
getTriggerTime
().
longValue
()){
//统计运行实例的数据
//如果存在实例
if
(
runRecording
!=
null
){
//获取凌晨的时间戳
Long
time
=
LocalDate
.
now
().
atStartOfDay
(
ZoneOffset
.
ofHours
(
8
)).
toInstant
().
toEpochMilli
();
//从凌晨到现在是否有运行实例
if
(
time
.
longValue
()
>
runRecording
.
getTriggerTime
().
longValue
()){
//今天不存在工作流的运行实例
flowStatusSnapshoot
.
setFlowStatus
(
1
);
flowStatusSnapshoot
.
setUnstartNode
(
flow
.
getFlowNodeCount
());
}
else
{
}
else
{
//存在工作流的运行实例
//判断运行状态
if
(
runRecording
.
getFlowStatus
().
equals
(
"1"
)
||
runRecording
.
getFlowStatus
().
equals
(
"2"
)
||
runRecording
.
getFlowStatus
().
equals
(
"3"
)){
flowStatusSnapshoot
.
setFlowStatus
(
Integer
.
valueOf
(
runRecording
.
getFlowStatus
()));
}
else
{
...
...
@@ -94,6 +98,8 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
}
//获取运行实例下各类状态的节点数目
StatisticData
nodeStatistic
=
jobTaskRunLogMapper
.
findStatisticDataByRunIdAndFlowId
(
runRecording
.
getRunId
(),
flow
.
getFlowId
());
//判断是否存在节点的运行日志
//存在节点运行日志
if
(
nodeStatistic
!=
null
){
int
sum
=
nodeStatistic
.
getFail
()
+
nodeStatistic
.
getSuccess
()
+
nodeStatistic
.
getRunIng
()
+
nodeStatistic
.
getKill
();
flowStatusSnapshoot
.
setUnstartNode
(
flow
.
getFlowNodeCount
()
-
sum
);
...
...
@@ -102,12 +108,38 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
flowStatusSnapshoot
.
setFailNode
(
nodeStatistic
.
getFail
());
flowStatusSnapshoot
.
setKillNode
(
nodeStatistic
.
getKill
());
}
else
{
//不存在节点的运行日志
nodeStatistic
.
setUnstart
(
flow
.
getFlowNodeCount
());
}
}
}
else
{
//如果不存在运行实例
flowStatusSnapshoot
.
setUnstartNode
(
flow
.
getFlowNodeCount
());
}
flowStatusSnapshootList
.
add
(
flowStatusSnapshoot
);
//获取排队的运行实例
List
<
WaitingRecord
>
waitingRecordList
=
waitingRecordMapper
.
findByFlowId
(
flow
.
getFlowId
());
if
(
waitingRecordList
!=
null
&&
waitingRecordList
.
size
()
>
0
){
//如果存在正在排队的实例
waitingRecordList
.
forEach
(
waitingRecord
->
{
//创建工作流快照
FlowStatusSnapshoot
waitingStatusSnapshoot
=
new
FlowStatusSnapshoot
();
waitingStatusSnapshoot
.
setDay
(
date
);
waitingStatusSnapshoot
.
setFlowId
(
flow
.
getFlowId
());
waitingStatusSnapshoot
.
setHour
(
hour
);
waitingStatusSnapshoot
.
setFlowName
(
flow
.
getFlowName
());
waitingStatusSnapshoot
.
setWorkspaceId
(
flow
.
getWorkspaceId
());
waitingStatusSnapshoot
.
setSnapshootTime
(
hourTime
);
waitingStatusSnapshoot
.
setFlowStatus
(
1
);
//获取排队的节点数目
List
<
WaitingTask
>
waitingTaskList
=
waitingTaskMapper
.
findAllByWaitId
(
waitingRecord
.
getWaitId
());
if
(
waitingTaskList
!=
null
&&
waitingTaskList
.
size
()
>
0
){
waitingStatusSnapshoot
.
setUnstartNode
(
waitingTaskList
.
size
());
}
flowStatusSnapshootList
.
add
(
waitingStatusSnapshoot
);
});
}
});
if
(
flowList
!=
null
&&
flowList
.
size
()
>
0
){
flowStatusSnapshootMapper
.
saveList
(
flowStatusSnapshootList
);
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/JobTaskRunLogMapper.xml
View file @
06cc2029
...
...
@@ -129,9 +129,9 @@
from job_task_run_log
where start_time
>
= ${startDate}
and end_time
<
= ${endDate}
<if
test=
"flowId
s
!= null"
>
<if
test=
"flowId
List
!= null"
>
and flow_id in (
<foreach
collection=
"flowId
s
"
item=
"flowId"
separator=
","
>
<foreach
collection=
"flowId
List
"
item=
"flowId"
separator=
","
>
#{flowId}
</foreach>
)
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/RunRecordingMapper.xml
View file @
06cc2029
...
...
@@ -158,9 +158,9 @@
from run_recording
where start_time
>
= ${startDate}
and end_time
<
= ${endDate}
<if
test=
"flowId
s
!= null"
>
<if
test=
"flowId
List
!= null"
>
and flow_id in (
<foreach
collection=
"flowId
s
"
item=
"flowId"
separator=
","
>
<foreach
collection=
"flowId
List
"
item=
"flowId"
separator=
","
>
#{flowId}
</foreach>
)
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/WaitingRecordMapper.xml
View file @
06cc2029
...
...
@@ -48,6 +48,24 @@
from waiting_record
where flow_id = #{flowId}
</select>
<select
id=
"findByFlowId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from waiting_record
where flow_id = #{flowId}
</select>
<select
id=
"findStatusByStartAndEndTime"
resultType=
"com.byit.dto.plugin.StatisticData"
>
select count(1) unstart
from waiting_record
where 1 = 1
<if
test=
"flowIdList != null"
>
and flow_id in (
<foreach
collection=
"flowIdList"
item=
"flowId"
separator=
","
>
#{flowId}
</foreach>
)
</if>
</select>
<delete
id=
"deleteById"
parameterType=
"java.lang.Integer"
>
<!-- generated @mbg.generated date: 2020-03-12 -->
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/WaitingTaskMapper.xml
View file @
06cc2029
...
...
@@ -70,6 +70,18 @@
from waiting_task
where wait_id=#{waitId,jdbcType=INTEGER}
</select>
<select
id=
"findStatusByStartAndEndTime"
resultType=
"com.byit.dto.plugin.StatisticData"
>
select count(1) unstart
from waiting_task
where 1 = 1
<if
test=
"flowIdList != null"
>
and flow_id in (
<foreach
collection=
"flowIdList"
item=
"flowId"
separator=
","
>
#{flowId}
</foreach>
)
</if>
</select>
<delete
id=
"deleteById"
parameterType=
"java.lang.Integer"
>
<!-- generated @mbg.generated date: 2020-03-12 -->
...
...
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/plugin/CollectData.java
View file @
06cc2029
...
...
@@ -22,8 +22,13 @@ public class CollectData {
private
StatisticData
nodeData
;
/**
* 按时间段的汇总
*
节点
按时间段的汇总
*/
private
Map
<
String
,
StatisticData
>
collectMap
;
private
Map
<
String
,
StatisticData
>
nodeCollectMap
;
/**
* 工作流按时间段的汇总
*/
private
Map
<
String
,
StatisticData
>
flowCollectMap
;
}
byit-myth-executor/myth-executor-plugin/src/main/java/com/byit/utils/JobUtils.java
View file @
06cc2029
...
...
@@ -91,7 +91,14 @@ public class JobUtils {
* 获取运行实例日志
*/
public
static
final
String
REQUEST_LOADSCHEDULELOG
=
"/api/flow/loadScheduleLog"
;
/**
* 获取运行的统计数据
*/
public
static
final
String
REQUEST_LOADSTATISTICDATA
=
"/api/flow/loadStatisticData"
;
/**
* 获取节点运行的统计数据
*/
public
static
final
String
REQUEST_LOADNODESTATISTICDATA
=
"/api/flow/loadNodeStatisticData"
;
/**
* 补批工作流
*/
...
...
@@ -344,6 +351,42 @@ public class JobUtils {
}
/**
* 获取运行的统计数据接口
* @param startTime 开始时间 毫秒级别时间
* @param endTime 开始时间 毫秒级别时间
* @param workspaceName 工作空间名称
* @return
*/
public
static
ResponseResult
loadStatisticData
(
Long
startTime
,
Long
endTime
,
String
workspaceName
){
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"startTime"
,
startTime
);
param
.
put
(
"endTime"
,
endTime
);
param
.
put
(
"workspaceName"
,
workspaceName
);
String
response
=
createHttpRequest
(
REQUEST_LOADSTATISTICDATA
,
"param="
+
JSON
.
toJSONString
(
param
));
log
.
info
(
"--------------------获取运行的统计数据接口调用成功,结果为:{}------------------------"
,
response
);
return
JSON
.
parseObject
(
response
,
ResponseResult
.
class
);
}
/**
* 获取节点运行的统计数据
* @param startTime 开始时间 毫秒级别时间
* @param endTime 结束时间 毫秒级别时间
* @param workspaceName 工作空间名称
* @param flowName 工作流名称
* @return
*/
public
static
ResponseResult
loadNodeStatisticData
(
Long
startTime
,
Long
endTime
,
String
workspaceName
,
String
flowName
){
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"startTime"
,
startTime
);
param
.
put
(
"endTime"
,
endTime
);
param
.
put
(
"workspaceName"
,
workspaceName
);
param
.
put
(
"flowName"
,
flowName
);
String
response
=
createHttpRequest
(
REQUEST_LOADNODESTATISTICDATA
,
"param="
+
JSON
.
toJSONString
(
param
));
log
.
info
(
"--------------------获取节点运行的统计数据接口调用成功,结果为:{}------------------------"
,
response
);
return
JSON
.
parseObject
(
response
,
ResponseResult
.
class
);
}
/**
* 补批工作流
* @param workspaceName 工作空间名称
* @param flowName 工作流名称
...
...
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