Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
holmes
Commits
6602c0b2
Commit
6602c0b2
authored
May 25, 2021
by
黎博
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jira'
parents
b14357ad
a773c977
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
JiraController.java
...ain/java/cn/qg/holmes/controller/jira/JiraController.java
+32
-0
JiraIssueServiceImpl.java
.../cn/qg/holmes/service/jira/impl/JiraIssueServiceImpl.java
+1
-1
JiraToDingding.java
src/main/java/cn/qg/holmes/task/jira/JiraToDingding.java
+2
-2
No files found.
src/main/java/cn/qg/holmes/controller/jira/JiraController.java
View file @
6602c0b2
package
cn
.
qg
.
holmes
.
controller
.
jira
;
import
cn.qg.holmes.common.JsonResult
;
import
cn.qg.holmes.entity.jira.JiraBugPool
;
import
cn.qg.holmes.entity.jira.SendScheduleVo
;
import
cn.qg.holmes.service.jira.JiraBugPoolService
;
import
cn.qg.holmes.service.jira.JiraIssueService
;
import
cn.qg.holmes.utils.DingdingUtils
;
import
com.atlassian.jira.rest.client.api.domain.Issue
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.joda.time.DateTime
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -23,6 +26,9 @@ public class JiraController {
@Autowired
JiraIssueService
jiraIssueService
;
@Autowired
JiraBugPoolService
jiraBugPoolService
;
@GetMapping
(
"/report/project"
)
public
void
sendReportToDingdingGroup
(
String
project
,
String
webhook
)
throws
Exception
{
Iterable
<
Issue
>
issues
=
jiraIssueService
.
getUnsolvedIssueListByProject
(
project
);
...
...
@@ -66,4 +72,30 @@ public class JiraController {
}
return
JsonResult
.
buildSuccessResult
(
result
);
}
@GetMapping
(
"/bug/pool/caculate"
)
public
JsonResult
bugPoolCaculateFixTime
()
throws
Exception
{
QueryWrapper
<
JiraBugPool
>
jiraBugPoolQueryWrapper
=
new
QueryWrapper
<>();
jiraBugPoolQueryWrapper
.
eq
(
"enable"
,
1
);
List
<
JiraBugPool
>
jiraBugPoolList
=
jiraBugPoolService
.
list
(
jiraBugPoolQueryWrapper
);
List
<
Map
<
String
,
Object
>>
mapList
=
new
ArrayList
<>();
for
(
JiraBugPool
jiraBugPool
:
jiraBugPoolList
)
{
Issue
issue
=
jiraIssueService
.
getJiraIssueByKey
(
jiraBugPool
.
getKey
());
String
resolveResult
=
issue
.
getStatus
().
getName
();
DateTime
startDate
=
issue
.
getCreationDate
();
DateTime
endDate
;
// 如果已解决或已关闭,仅修改状态
if
(
resolveResult
.
equals
(
"已解决"
)
||
resolveResult
.
equals
(
"关闭"
))
{
endDate
=
DateTime
.
parse
(
issue
.
getFieldByName
(
"已解决"
).
getValue
().
toString
());
}
else
{
endDate
=
new
DateTime
();
}
int
duration
=
jiraIssueService
.
calculateBugFixTime
(
startDate
,
endDate
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"title"
,
issue
.
getSummary
());
map
.
put
(
"持续时长"
,
duration
);
mapList
.
add
(
map
);
}
return
JsonResult
.
buildSuccessResult
(
mapList
);
}
}
src/main/java/cn/qg/holmes/service/jira/impl/JiraIssueServiceImpl.java
View file @
6602c0b2
...
...
@@ -91,7 +91,7 @@ public class JiraIssueServiceImpl implements JiraIssueService {
int
startHour
=
startDate
.
getHourOfDay
();
int
endHour
=
endDate
.
getHourOfDay
();
int
startMinute
=
startDate
.
getMinuteOfHour
();
int
endMinute
=
endDate
.
get
SecondOfMinute
();
int
endMinute
=
endDate
.
get
MinuteOfHour
();
int
startSecond
=
startDate
.
getSecondOfMinute
();
int
endSecond
=
endDate
.
getSecondOfMinute
();
boolean
daySubFlag
=
true
;
...
...
src/main/java/cn/qg/holmes/task/jira/JiraToDingding.java
View file @
6602c0b2
...
...
@@ -72,8 +72,8 @@ public class JiraToDingding {
jiraBugPoolService
.
saveOrUpdate
(
jiraBugPool
);
}
else
{
DateTime
startDate
=
issue
.
getCreationDate
();
DateTime
endDate
=
issue
.
getUpdateDat
e
();
int
duration
=
jiraIssueService
.
calculateBugFixTime
(
startDate
,
end
Date
);
DateTime
curDate
=
new
DateTim
e
();
int
duration
=
jiraIssueService
.
calculateBugFixTime
(
startDate
,
cur
Date
);
log
.
info
(
"{} BUG持续时间:{}小时"
,
issue
.
getKey
(),
duration
);
// DingdingUtils.sendToDingding(DingdingUtils.buildBugFixRemindMsg(issue), jiraBugPool.getDingUrl());
// 如果已超过4个小时,则发送钉钉通知
...
...
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