Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
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
姚本章
jz-dmp-service
Commits
64d76dcb
Commit
64d76dcb
authored
Mar 09, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
14910f3f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
170 additions
and
35 deletions
+170
-35
DateUtils.java
src/main/java/com/jz/common/utils/DateUtils.java
+13
-0
ExecutionFlowsMapper.java
...ain/java/com/jz/dmp/azkaban/dao/ExecutionFlowsMapper.java
+1
-1
DmpDevExamplesController.java
...es/controller/dataOperation/DmpDevExamplesController.java
+1
-1
DmpDevTaskController.java
...odules/controller/dataOperation/DmpDevTaskController.java
+3
-0
DataDevTaskListDto.java
...les/controller/dataOperation/bean/DataDevTaskListDto.java
+11
-0
DmpApiMangeController.java
...modules/controller/dataService/DmpApiMangeController.java
+4
-3
DmpApiMangeService.java
...n/java/com/jz/dmp/modules/service/DmpApiMangeService.java
+1
-1
DmpApiMangeServiceImpl.java
...m/jz/dmp/modules/service/impl/DmpApiMangeServiceImpl.java
+2
-1
DmpDevelopTaskServiceImpl.java
...z/dmp/modules/service/impl/DmpDevelopTaskServiceImpl.java
+130
-27
ExecutionFlowsMapper.xml
src/main/resources/azkabanmapper/ExecutionFlowsMapper.xml
+4
-1
No files found.
src/main/java/com/jz/common/utils/DateUtils.java
View file @
64d76dcb
...
...
@@ -39,6 +39,8 @@ public class DateUtils {
private
static
final
SimpleDateFormat
timeFormat
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
private
static
final
SimpleDateFormat
hsFormat
=
new
SimpleDateFormat
(
"HH:mm"
);
final
static
long
daytimes
=
24
*
60
*
60
*
1000
;
final
static
long
hourtimes
=
1
*
60
*
60
*
1000
;
...
...
@@ -174,6 +176,17 @@ public class DateUtils {
return
timeFormat
.
format
(
date
);
}
/**
* 格式化时间
* <p>
* 时间格式HH:mm
*
* @return
*/
public
static
String
formatTimes
(
Date
date
)
{
return
hsFormat
.
format
(
date
);
}
/**
* 格式化日期
* <p>
...
...
src/main/java/com/jz/dmp/azkaban/dao/ExecutionFlowsMapper.java
View file @
64d76dcb
...
...
@@ -38,7 +38,7 @@ public interface ExecutionFlowsMapper {
*/
List
<
Map
>
queryExamplesLogByExecId
(
String
execId
)
throws
Exception
;
Map
<
String
,
Object
>
queryTaskInstanceStatus
()
throws
Exception
;
Map
<
String
,
Object
>
queryTaskInstanceStatus
(
@Param
(
"taskName"
)
String
[]
taskName
)
throws
Exception
;
/**
* 查询业务流程任务,最后一个执行实例的状态
...
...
src/main/java/com/jz/dmp/modules/controller/dataOperation/DmpDevExamplesController.java
View file @
64d76dcb
...
...
@@ -95,7 +95,7 @@ public class DmpDevExamplesController {
result
=
dmpDevelopTaskService
.
setSla
(
req
);
}
catch
(
Exception
e
)
{
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
result
.
setMessage
(
"failed!"
);
result
.
setMessage
(
e
.
getMessage
()
);
e
.
printStackTrace
();
}
return
result
;
...
...
src/main/java/com/jz/dmp/modules/controller/dataOperation/DmpDevTaskController.java
View file @
64d76dcb
...
...
@@ -142,6 +142,9 @@ public class DmpDevTaskController {
if
(
StringUtils
.
isEmpty
(
scheduleId
))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
,
"scheduleId不能为空!"
);
}
if
(
StringUtils
.
isEmpty
(
projectId
))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
,
"projectId不能为空!"
);
}
JsonResult
result
=
new
JsonResult
();
try
{
result
=
dmpDevelopTaskService
.
getSlaInfo
(
scheduleId
,
projectId
);
...
...
src/main/java/com/jz/dmp/modules/controller/dataOperation/bean/DataDevTaskListDto.java
View file @
64d76dcb
...
...
@@ -90,6 +90,9 @@ public class DataDevTaskListDto {
@ApiModelProperty
(
value
=
"scheduleId"
)
private
String
scheduleId
;
@ApiModelProperty
(
value
=
"sla状态:Y 已配置,N未配置"
)
private
String
slaStatus
;
public
String
getStatus
()
{
return
status
;
}
...
...
@@ -193,4 +196,12 @@ public class DataDevTaskListDto {
public
void
setScheduleId
(
String
scheduleId
)
{
this
.
scheduleId
=
scheduleId
;
}
public
String
getSlaStatus
()
{
return
slaStatus
;
}
public
void
setSlaStatus
(
String
slaStatus
)
{
this
.
slaStatus
=
slaStatus
;
}
}
src/main/java/com/jz/dmp/modules/controller/dataService/DmpApiMangeController.java
View file @
64d76dcb
...
...
@@ -399,11 +399,12 @@ public class DmpApiMangeController {
*/
@ApiOperation
(
value
=
"授权--组织名称查询"
,
notes
=
"授权--组织名称查询"
)
@GetMapping
(
value
=
"/getAuthOrgName"
)
@ApiImplicitParam
(
name
=
"orgName"
,
value
=
"组织名称"
,
required
=
true
)
public
JsonResult
getAuthOrgName
(
@RequestParam
String
orgName
)
{
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"orgName"
,
value
=
"组织名称"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"projectId"
,
value
=
"projectId"
,
required
=
true
)})
public
JsonResult
getAuthOrgName
(
@RequestParam
String
orgName
,
String
projectId
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiMangeService
.
getAuthOrgName
(
orgName
);
jsonResult
=
dmpApiMangeService
.
getAuthOrgName
(
orgName
,
projectId
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
...
...
src/main/java/com/jz/dmp/modules/service/DmpApiMangeService.java
View file @
64d76dcb
...
...
@@ -139,7 +139,7 @@ public interface DmpApiMangeService {
* @author Bellamy
* @since 2021-03-02
*/
JsonResult
getAuthOrgName
(
String
orgName
)
throws
Exception
;
JsonResult
getAuthOrgName
(
String
orgName
,
String
projectId
)
throws
Exception
;
/**
* API测试--下拉框
...
...
src/main/java/com/jz/dmp/modules/service/impl/DmpApiMangeServiceImpl.java
View file @
64d76dcb
...
...
@@ -461,10 +461,11 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
* @since 2021-03-02
*/
@Override
public
JsonResult
getAuthOrgName
(
String
orgName
)
throws
Exception
{
public
JsonResult
getAuthOrgName
(
String
orgName
,
String
projectId
)
throws
Exception
{
String
url
=
gatewayUrl
+
GatewayApiConstant
.
getOrgNameList
;
Map
params
=
new
HashMap
();
params
.
put
(
"orgName"
,
orgName
);
params
.
put
(
"projectId"
,
projectId
);
JsonResult
result
=
GatewayApiConstant
.
getRequest2GetData
(
url
,
params
);
return
result
;
}
...
...
src/main/java/com/jz/dmp/modules/service/impl/DmpDevelopTaskServiceImpl.java
View file @
64d76dcb
...
...
@@ -782,18 +782,6 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
String
azkabanApiUrl
=
publishToProjectSystemInfo
.
getAzkabanMonitorUrl
();
AzkabanApiUtils2
azkabanApiUtils
=
new
AzkabanApiUtils2
(
azkabanApiUrl
,
redisTemplate
);
PageInfoResponse
<
DataDevTaskListDto
>
pageInfoResponse
=
new
PageInfoResponse
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getTreeIdOrName
()))
{
//判断是否为整数 是整数返回true,否则返回false
Pattern
pattern
=
Pattern
.
compile
(
"^[-\\+]?[\\d]*$"
);
if
(
pattern
.
matcher
(
req
.
getTreeIdOrName
().
trim
()).
matches
())
{
req
.
setTaskId
(
req
.
getTreeIdOrName
());
//id
req
.
setTreeIdOrName
(
null
);
}
else
{
req
.
setTreeIdOrName
(
req
.
getTreeIdOrName
().
trim
());
//任务名称
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
if
(
FlowInstanceEnum
.
running
.
getCode
().
equals
(
req
.
getStatus
()))
{
req
.
setStatus
(
FlowInstanceEnum
.
running
.
getValue
());
...
...
@@ -805,6 +793,44 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
}
}
//查询实例最后执行状态
List
<
Map
>
flowList
=
executionFlowsMapper
.
queryLastStatus
(
null
,
req
.
getStatus
());
for
(
Map
strFlow
:
flowList
)
{
String
projectId
=
String
.
valueOf
(
strFlow
.
get
(
"projectId"
));
String
flowId
=
String
.
valueOf
(
strFlow
.
get
(
"taskName"
));
//获取调度配置
Map
responseData
=
(
Map
)
JSONObject
.
parse
(
azkabanApiUtils
.
getSchedule
(
projectId
,
flowId
));
if
(
responseData
!=
null
&&
responseData
.
size
()
>
0
)
{
Map
schedule
=
(
Map
)
responseData
.
get
(
"schedule"
);
strFlow
.
put
(
"scheduleId"
,
schedule
.
get
(
"scheduleId"
));
strFlow
.
put
(
"cronExpression"
,
schedule
.
get
(
"cronExpression"
));
//调度周期
//获取sla 是否已配置 状态
if
(
null
==
schedule
.
get
(
"scheduleId"
))
{
strFlow
.
put
(
"slaStatus"
,
"N"
);
}
else
{
//获取sla
String
resp
=
azkabanApiUtils
.
getSlaInfo
(
String
.
valueOf
(
schedule
.
get
(
"scheduleId"
)));
if
(
StringUtils
.
isNotBlank
(
resp
))
{
strFlow
.
put
(
"slaStatus"
,
"Y"
);
}
else
{
strFlow
.
put
(
"slaStatus"
,
"N"
);
}
}
}
}
PageInfoResponse
<
DataDevTaskListDto
>
pageInfoResponse
=
new
PageInfoResponse
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getTreeIdOrName
()))
{
//判断是否为整数 是整数返回true,否则返回false
Pattern
pattern
=
Pattern
.
compile
(
"^[-\\+]?[\\d]*$"
);
if
(
pattern
.
matcher
(
req
.
getTreeIdOrName
().
trim
()).
matches
())
{
req
.
setTaskId
(
req
.
getTreeIdOrName
());
//id
req
.
setTreeIdOrName
(
null
);
}
else
{
req
.
setTreeIdOrName
(
req
.
getTreeIdOrName
().
trim
());
//任务名称
}
}
//业务流程任务
PageHelper
.
startPage
(
req
.
getPageNum
(),
req
.
getPageSize
());
List
<
DataDevTaskListDto
>
list
=
dmpDevelopTaskDao
.
queryDevTaskListPage
(
req
);
PageInfo
<
DataDevTaskListDto
>
pageInfo
=
new
PageInfo
<>(
list
);
...
...
@@ -812,13 +838,29 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
pageInfoResponse
.
setCode
(
ResultCode
.
SUCCESS
);
pageInfoResponse
.
setMessage
(
"查询成功"
);
pageInfoResponse
.
setData
(
pageInfo
);
String
taskName
=
""
;
List
<
DataDevTaskListDto
>
listObj
=
pageInfoResponse
.
getData
().
getList
();
for
(
DataDevTaskListDto
str
:
listObj
)
{
taskName
+=
","
+
str
.
getTaskName
();
if
(
flowList
.
size
()
>
0
&&
flowList
!=
null
)
{
for
(
DataDevTaskListDto
str
:
listObj
)
{
//业务流程任务
for
(
Map
strFlow
:
flowList
)
{
//最后实例状态
if
(
str
.
getTaskName
().
equals
(
strFlow
.
get
(
"taskName"
)))
{
str
.
setStatus
(
String
.
valueOf
(
strFlow
.
get
(
"status"
)));
//实例执行最后状态
if
(
null
!=
strFlow
.
get
(
"cronExpression"
))
{
//调度周期
str
.
setSchedulinCycle
(
String
.
valueOf
(
strFlow
.
get
(
"cronExpression"
)));
}
if
(
null
!=
strFlow
.
get
(
"scheduleId"
))
{
str
.
setScheduleId
(
String
.
valueOf
(
strFlow
.
get
(
"scheduleId"
)));
}
if
(
null
!=
strFlow
.
get
(
"slaStatus"
))
{
str
.
setSlaStatus
(
String
.
valueOf
(
strFlow
.
get
(
"slaStatus"
)));
}
}
}
}
}
//查询实例最后执行状态
List
<
Map
>
flowList
=
executionFlowsMapper
.
queryLastStatus
(
taskName
.
substring
(
1
).
split
(
","
),
req
.
getStatus
());
/*
List<Map> flowList = executionFlowsMapper.queryLastStatus(taskName.substring(1).split(","), req.getStatus());
for (Map strFlow : flowList) {
String projectId = String.valueOf(strFlow.get("projectId"));
String flowId = String.valueOf(strFlow.get("taskName"));
...
...
@@ -854,7 +896,7 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
}
}
}
}
}
*/
return
pageInfoResponse
;
}
...
...
@@ -1626,7 +1668,12 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
List
<
Map
>
list
=
executionFlowsMapper
.
queryExamplesLogByExecId
(
execId
);
if
(
list
.
size
()
>
0
&&
list
!=
null
)
{
list
.
forEach
(
map
->
{
//map.put("log", map.get("log"));
try
{
map
.
put
(
"log"
,
new
String
(
String
.
valueOf
(
map
.
get
(
"log"
)).
getBytes
(
"ISO-8859-1"
),
"UTF-8"
));
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
});
}
return
JsonResult
.
ok
(
list
);
...
...
@@ -1646,15 +1693,35 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
//RUNNING, FAILED,SUCCESS
//实时任务状态
Map
<
String
,
Object
>
realTimeTask
=
dmpRealtimeSyncInfoDao
.
queryTaskStatus
(
projectId
);
Integer
realTimeRunNum
=
Integer
.
valueOf
(
String
.
valueOf
(
realTimeTask
.
get
(
"running"
)));
Integer
realTimeFailedNum
=
Integer
.
valueOf
(
String
.
valueOf
(
realTimeTask
.
get
(
"failed"
)));
Integer
realTimeRunNum
=
0
;
Integer
realTimeFailedNum
=
0
;
if
(
realTimeTask
!=
null
&&
realTimeTask
.
size
()
>
0
)
{
realTimeRunNum
=
Integer
.
valueOf
(
String
.
valueOf
(
realTimeTask
.
get
(
"running"
)));
realTimeFailedNum
=
Integer
.
valueOf
(
String
.
valueOf
(
realTimeTask
.
get
(
"failed"
)));
}
DataDevTaskListReq
req
=
new
DataDevTaskListReq
();
req
.
setProjectId
(
projectId
);
List
<
DataDevTaskListDto
>
list
=
dmpDevelopTaskDao
.
queryDevTaskListPage
(
req
);
String
taskName
=
""
;
if
(
list
.
size
()
>
0
&&
list
!=
null
)
{
for
(
DataDevTaskListDto
str
:
list
)
{
taskName
+=
","
+
str
.
getTaskName
();
}
}
//业务流程实例状态 :30-正在运行,50-运行成功,60-kill任务,70-运行失败
Map
<
String
,
Object
>
flowStatus
=
executionFlowsMapper
.
queryTaskInstanceStatus
();
Integer
flowRunNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"running"
)));
Integer
flowSuccessNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"success"
)));
Integer
flowFailedNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"failed"
)));
Integer
flowManualNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"manualNum"
)));
Map
<
String
,
Object
>
flowStatus
=
executionFlowsMapper
.
queryTaskInstanceStatus
(
taskName
.
substring
(
1
).
split
(
","
));
Integer
flowRunNum
=
0
;
Integer
flowSuccessNum
=
0
;
Integer
flowFailedNum
=
0
;
Integer
flowManualNum
=
0
;
if
(
flowStatus
!=
null
&&
flowStatus
.
size
()
>
0
)
{
flowRunNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"running"
)));
flowSuccessNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"success"
)));
flowFailedNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"failed"
)));
flowManualNum
=
Integer
.
valueOf
(
String
.
valueOf
(
flowStatus
.
get
(
"manualNum"
)));
}
taskStatus
.
put
(
"running"
,
realTimeRunNum
+
flowRunNum
);
taskStatus
.
put
(
"success"
,
flowSuccessNum
);
...
...
@@ -1726,7 +1793,7 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
yesterdayList
.
add
(
String
.
valueOf
(
entry
.
getValue
()));
}
}
//历史平均
List
<
String
>
historyAvgList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
historyAvgData
=
executionFlowsMapper
.
getTaskStatus
(
""
,
taskStatus
,
taskNames
);
Long
dayNum
=
executionFlowsMapper
.
queryDaysNumber
(
taskStatus
,
taskNames
);
...
...
@@ -1762,7 +1829,43 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
//调用azkaban服务
String
azkabanApiUrl
=
publishToProjectSystemInfo
.
getAzkabanMonitorUrl
();
AzkabanApiUtils2
azkabanApiUtils
=
new
AzkabanApiUtils2
(
azkabanApiUrl
,
redisTemplate
);
return
JsonResult
.
ok
(
JSONObject
.
parse
(
azkabanApiUtils
.
getSlaInfo
(
scheduleId
)));
Map
result
=
(
Map
)
JSONObject
.
parse
(
azkabanApiUtils
.
getSlaInfo
(
scheduleId
));
SetSlaReq
dto
=
new
SetSlaReq
();
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
List
<
Map
>
settings
=
(
List
<
Map
>)
result
.
get
(
"settings"
);
List
<
String
>
slaEmails
=
(
List
<
String
>)
JSONObject
.
parse
(
String
.
valueOf
(
result
.
get
(
"slaEmails"
)));
String
emails
=
""
;
for
(
String
email
:
slaEmails
)
{
emails
+=
","
+
email
;
}
dto
.
setSlaEmails
(
emails
.
substring
(
1
));
List
<
SetSlaRulesReq
>
list
=
new
ArrayList
<>();
if
(
settings
.
size
()
>
0
&&
null
!=
settings
)
{
for
(
Map
str
:
settings
)
{
SetSlaRulesReq
slaRules
=
new
SetSlaRulesReq
();
String
duration
=
String
.
valueOf
(
str
.
get
(
"duration"
)).
substring
(
0
,
String
.
valueOf
(
str
.
get
(
"duration"
)).
lastIndexOf
(
"m"
));
long
m
=
Long
.
parseLong
(
duration
);
long
minute
=
(
m
)
%
60
;
long
hour
=
(
m
/
60
)
%
24
;
slaRules
.
setDuration
(
hour
+
":"
+
minute
);
slaRules
.
setFlow
(
String
.
valueOf
(
str
.
get
(
"id"
)));
slaRules
.
setSlaRule
(
String
.
valueOf
(
str
.
get
(
"rule"
)));
List
<
String
>
actions
=
(
List
<
String
>)
JSONObject
.
parse
(
String
.
valueOf
(
str
.
get
(
"actions"
)));
slaRules
.
setEmailNotification
(
false
);
slaRules
.
setKill
(
false
);
for
(
String
action
:
actions
)
{
if
(
"EMAIL"
.
equals
(
action
))
{
slaRules
.
setEmailNotification
(
true
);
}
else
if
(
"KILL"
.
equals
(
action
))
{
slaRules
.
setKill
(
true
);
}
}
list
.
add
(
slaRules
);
}
}
dto
.
setSlaRule
(
list
);
}
return
JsonResult
.
ok
(
dto
);
}
/**
...
...
src/main/resources/azkabanmapper/ExecutionFlowsMapper.xml
View file @
64d76dcb
...
...
@@ -219,6 +219,7 @@
sum(case when status='60' then 1 else 0 end) killed,
sum(case when status='70' then 1 else 0 end) failed
FROM execution_flows
<include
refid=
"flowIdSql"
/>
)t
</select>
...
...
@@ -234,7 +235,9 @@
execution_flows
WHERE 1 = 1
<if
test=
"status != null and status !='' "
>
and status=#{status}
</if>
<include
refid=
"flowIdSql"
/>
<if
test=
"taskName != null and taskName !='' "
>
<include
refid=
"flowIdSql"
/>
</if>
group by flow_id
</select>
...
...
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