Commit 6602c0b2 authored by 黎博's avatar 黎博

Merge branch 'jira'

parents b14357ad a773c977
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);
}
}
......@@ -91,7 +91,7 @@ public class JiraIssueServiceImpl implements JiraIssueService {
int startHour = startDate.getHourOfDay();
int endHour = endDate.getHourOfDay();
int startMinute = startDate.getMinuteOfHour();
int endMinute = endDate.getSecondOfMinute();
int endMinute = endDate.getMinuteOfHour();
int startSecond = startDate.getSecondOfMinute();
int endSecond = endDate.getSecondOfMinute();
boolean daySubFlag = true;
......
......@@ -72,8 +72,8 @@ public class JiraToDingding {
jiraBugPoolService.saveOrUpdate(jiraBugPool);
} else {
DateTime startDate = issue.getCreationDate();
DateTime endDate = issue.getUpdateDate();
int duration = jiraIssueService.calculateBugFixTime(startDate, endDate);
DateTime curDate = new DateTime();
int duration = jiraIssueService.calculateBugFixTime(startDate, curDate);
log.info("{} BUG持续时间:{}小时", issue.getKey(), duration);
// DingdingUtils.sendToDingding(DingdingUtils.buildBugFixRemindMsg(issue), jiraBugPool.getDingUrl());
// 如果已超过4个小时,则发送钉钉通知
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment