Commit f1825a5b authored by 黎博's avatar 黎博

新增BUG不存在的兼容处理

parent 93d6b618
...@@ -14,6 +14,6 @@ public interface JiraIssueService { ...@@ -14,6 +14,6 @@ public interface JiraIssueService {
Integer calculateBugFixTime(DateTime startDate, DateTime endDate); Integer calculateBugFixTime(DateTime startDate, DateTime endDate);
Issue getJiraIssueByKey(String key) throws Exception; Issue getJiraIssueByKey(String key);
} }
...@@ -76,8 +76,14 @@ public class JiraIssueServiceImpl implements JiraIssueService { ...@@ -76,8 +76,14 @@ public class JiraIssueServiceImpl implements JiraIssueService {
} }
@Override @Override
public Issue getJiraIssueByKey(String key) throws Exception { public Issue getJiraIssueByKey(String key) {
return jiraRestClient.getIssueClient().getIssue(key).get(); try {
Issue issue = jiraRestClient.getIssueClient().getIssue(key).get();
return issue;
} catch (Exception e) {
e.printStackTrace();
return null;
}
} }
/** /**
......
...@@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -64,21 +63,26 @@ public class JiraToDingding { ...@@ -64,21 +63,26 @@ public class JiraToDingding {
List<JiraBugPool> jiraBugPoolList = jiraBugPoolService.list(jiraBugPoolQueryWrapper); List<JiraBugPool> jiraBugPoolList = jiraBugPoolService.list(jiraBugPoolQueryWrapper);
for (JiraBugPool jiraBugPool: jiraBugPoolList) { for (JiraBugPool jiraBugPool: jiraBugPoolList) {
Issue issue = jiraIssueService.getJiraIssueByKey(jiraBugPool.getKey()); Issue issue = jiraIssueService.getJiraIssueByKey(jiraBugPool.getKey());
String resolveResult = issue.getStatus().getName(); if (issue != null) {
// 如果已解决或已关闭,仅修改状态 String resolveResult = issue.getStatus().getName();
if (resolveResult.equals("已解决") || resolveResult.equals("关闭")) { // 如果已解决或已关闭,仅修改状态
jiraBugPool.setEnable(0); if (resolveResult.equals("已解决") || resolveResult.equals("关闭")) {
// 更新状态 jiraBugPool.setEnable(0);
jiraBugPoolService.saveOrUpdate(jiraBugPool); // 更新状态
} else { jiraBugPoolService.saveOrUpdate(jiraBugPool);
DateTime startDate = issue.getCreationDate(); } else {
DateTime curDate = new DateTime(); DateTime startDate = issue.getCreationDate();
int duration = jiraIssueService.calculateBugFixTime(startDate, curDate); DateTime curDate = new DateTime();
log.info("{} BUG持续时间:{}小时", issue.getKey(), duration); int duration = jiraIssueService.calculateBugFixTime(startDate, curDate);
// 如果已超过4个小时,则发送钉钉通知 log.info("{} BUG持续时间:{}小时", issue.getKey(), duration);
if (duration >= 4) { // 如果已超过4个小时,则发送钉钉通知
DingdingUtils.sendToDingding(DingdingUtils.buildBugFixRemindMsg(issue, duration), jiraBugPool.getDingUrl()); if (duration >= 4) {
DingdingUtils.sendToDingding(DingdingUtils.buildBugFixRemindMsg(issue, duration), jiraBugPool.getDingUrl());
}
} }
} else {
log.info("JIRA上未找到该issue,将BUG: {} 置为无效", jiraBugPool.getKey());
jiraBugPool.setEnable(0);
} }
} }
} }
......
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