Commit e23d3438 authored by 黎博's avatar 黎博

test

parent 082c1939
......@@ -5,9 +5,20 @@ import cn.qg.holmes.entity.jira.SendScheduleVo;
import cn.qg.holmes.service.jira.JiraIssueService;
import cn.qg.holmes.utils.DingdingUtils;
import com.atlassian.jira.rest.client.api.domain.Issue;
import lombok.Data;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@CrossOrigin
@RestController
@RequestMapping("/jira")
......@@ -35,4 +46,27 @@ public class JiraController {
String markdownMsg = DingdingUtils.buildTestScheduleMarkdownMsg(issues, sendScheduleVo.getProgress(), sendScheduleVo.getRisk());
return JsonResult.buildSuccessResult(DingdingUtils.sendToDingding(markdownMsg, sendScheduleVo.getWebhook()));
}
@GetMapping("/test")
public JsonResult test() throws Exception{
String JQL = "project = XCX AND text ~ KA乐信 ORDER BY key ASC, priority DESC, updated DESC";
Iterable<Issue> issues = jiraIssueService.getIssueListByJQL(JQL);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<Map<String, String>> result = new ArrayList<>();
for (Issue issue: issues) {
Map<String, String> map = new HashMap<>();
map.put("标题", issue.getSummary());
map.put("报告人", issue.getReporter().getDisplayName());
map.put("经办人", issue.getAssignee().getDisplayName());
map.put("优先级", issue.getPriority().getName());
map.put("创建时间", simpleDateFormat.format(issue.getCreationDate().toDate()));
if (issue.getStatus().getName().equals("关闭") || issue.getStatus().getName().equals("已解决")) {
map.put("解决时间", simpleDateFormat.format(DateTime.parse(issue.getFieldByName("已解决").getValue().toString()).toDate()));
} else {
map.put("解决时间", null);
}
result.add(map);
}
return JsonResult.buildSuccessResult(result);
}
}
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