Commit f278aa17 authored by 黎博's avatar 黎博

BUG通知新增条件判断

parent b80fc74d
......@@ -42,16 +42,20 @@ public class DingRobotServiceImpl extends ServiceImpl<DingRobotMapper, DingRobot
String priority = JsonPath.read(jiraData, "$.issue.fields.priority.name");
String module = JsonPath.read(jiraData, "$.issue.fields.components[0].name");
String robotUrl = null;
Integer dingRobotId = null;
Integer status = null;
List<DingRobot> dingRobots = dingRobotMapper.selectList(null);
for (DingRobot dingRobot : dingRobots) {
String projectName = "【" + dingRobot.getProjectName() + "】";
if (summary.contains(projectName)) {
robotUrl = dingRobot.getDingUrl();
dingRobotId = dingRobot.getId();
status = dingRobot.getStatus();
break;
}
}
// 只有创建了dingRobot的项目的BUG才会被放到BUG池子里
if (robotUrl != null) {
if (robotUrl != null && dingRobotId != null) {
// 首次提交的BUG放入bug池子
JiraBugPool jiraBugPool = new JiraBugPool();
jiraBugPool.setKey(key);
......@@ -61,9 +65,11 @@ public class DingRobotServiceImpl extends ServiceImpl<DingRobotMapper, DingRobot
jiraBugPool.setAssignee(assignee);
jiraBugPool.setUrl("http://jira2.quantgroup.cn/browse/" + key);
jiraBugPool.setDingUrl(robotUrl);
jiraBugPool.setDingRobotId(dingRobotId);
jiraBugPoolService.save(jiraBugPool);
}
if (robotUrl != null) {
// 只有项目是进行中才会发送通知
if (robotUrl != null && status == 1) {
String markdownMsg = DingdingUtils.buildBugCommitMarkdownMsg(key, summary, creator, assignee, priority, module);
return DingdingUtils.sendToDingding(markdownMsg, robotUrl);
}
......
package cn.qg.holmes.task.jira;
import cn.qg.holmes.entity.jira.DingRobot;
import cn.qg.holmes.entity.jira.JiraBugPool;
import cn.qg.holmes.service.jira.DingRobotService;
import cn.qg.holmes.service.jira.JiraBugPoolService;
import cn.qg.holmes.service.jira.JiraIssueService;
import cn.qg.holmes.utils.DingdingUtils;
......@@ -28,6 +30,9 @@ public class JiraToDingding {
@Autowired
JiraBugPoolService jiraBugPoolService;
@Autowired
DingRobotService dingRobotService;
@Value("${sjgd.ding.url}")
private String sjgdDingUrl;
......@@ -80,9 +85,13 @@ public class JiraToDingding {
log.info("{} BUG持续时间:{}小时", issue.getKey(), duration);
// 如果已超过4个小时,则发送钉钉通知
if (duration >= 4) {
DingRobot dingRobot = dingRobotService.getById(jiraBugPool.getDingRobotId());
// 项目进行中才发送通知
if (dingRobot.getStatus() == 1) {
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