From 9aef75906cc9a43e3cf93a9d412db9ee7bec4336 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 26 Nov 2021 15:41:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=90=8C=E6=AD=A5=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E7=9A=84=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/commons/utils/ServiceUtils.java | 4 ++++ .../metersphere/track/issue/AbstractIssuePlatform.java | 8 +++----- .../java/io/metersphere/track/issue/JiraPlatform.java | 1 + .../java/io/metersphere/track/issue/TapdPlatform.java | 2 ++ .../java/io/metersphere/track/issue/ZentaoPlatform.java | 9 +++++++++ .../java/io/metersphere/track/service/IssuesService.java | 2 +- backend/src/main/java/io/metersphere/xpack | 2 +- frontend/src/network/test-plan.js | 3 ++- 8 files changed, 23 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java index 6d69db11eb..7c04b0ad8c 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java @@ -58,6 +58,10 @@ public class ServiceUtils { return orders; } + public static List getDefaultOrderByField(List orders, String field) { + return getDefaultOrderByField(null, orders, field); + } + /** * 获取前端全选的id列表 * diff --git a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java index e1193f5c7b..d5682f3d0a 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -401,10 +401,11 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { } protected Map getUuIdMap(List issues) { + HashMap issueMap = new HashMap<>(); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(issues)) { - return issues.stream().collect(Collectors.toMap(Issues::getPlatformId, i -> i)); + issues.forEach(item -> issueMap.put(item.getPlatformId(), item)); } - return new HashMap<>(); + return issueMap; } protected void deleteSyncIssue(List ids) { @@ -456,10 +457,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { issue.setProjectId(projectId); issue.setId(UUID.randomUUID().toString()); issue.setPlatformId(platformId); - issue.setCreateTime(System.currentTimeMillis()); - issue.setUpdateTime(System.currentTimeMillis()); issue.setCreator(SessionUtils.getUserId()); issue.setNum(nextNum); - issuesMapper.insert(issue); // 批量新增 } } diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index b1266e6598..4933644f23 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -76,6 +76,7 @@ public class JiraPlatform extends AbstractIssuePlatform { JSONObject assignee = (JSONObject) fields.get("assignee"); issue.setTitle(fields.getString("summary")); issue.setCreateTime(fields.getLong("created")); + issue.setUpdateTime(fields.getLong("updated")); issue.setLastmodify(assignee == null ? "" : assignee.getString("displayName")); issue.setDescription(description); issue.setPlatformStatus(status); diff --git a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java index 62590d9e11..e370617cfb 100644 --- a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java @@ -240,6 +240,8 @@ public class TapdPlatform extends AbstractIssuePlatform { issue.setDescription(htmlDesc2MsDesc(issue.getDescription())); issue.setCustomFields(syncIssueCustomField(issue.getCustomFields(), bug)); issue.setPlatform(key); + issue.setCreateTime(bug.getLong("created")); + issue.setUpdateTime(bug.getLong("modified")); return issue; } diff --git a/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java b/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java index 8a1c750cc4..d066f2c4ca 100644 --- a/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java @@ -143,6 +143,15 @@ public class ZentaoPlatform extends AbstractIssuePlatform { issue.setDescription(steps); issue.setReporter(bugObj.getOpenedBy()); issue.setPlatform(key); + try { + issue.setCreateTime(bug.getLong("openedDate")); + issue.setUpdateTime(bug.getLong("lastEditedDate")); + } catch (Exception e) { + LogUtil.error("update zentao time" + e.getMessage()); + } + if (issue.getUpdateTime() == null) { + issue.setUpdateTime(System.currentTimeMillis()); + } issue.setCustomFields(syncIssueCustomField(issue.getCustomFields(), bug)); return issue; } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index e00055144a..83240c91d1 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -338,7 +338,7 @@ public class IssuesService { } public List list(IssuesRequest request) { - request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); + request.setOrders(ServiceUtils.getDefaultOrderByField(request.getOrders(), "create_time")); List issues = extIssuesMapper.getIssues(request); List ids = issues.stream() diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 044899d938..269d23d500 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 044899d93802a7a30ba7453aaa58bd78af3a84a9 +Subproject commit 269d23d5004ee49a9e82a977027ca72757d3056a diff --git a/frontend/src/network/test-plan.js b/frontend/src/network/test-plan.js index 306f54ddbd..2c69395dfc 100644 --- a/frontend/src/network/test-plan.js +++ b/frontend/src/network/test-plan.js @@ -142,5 +142,6 @@ export function editTestPlanLoadCaseOrder(request, callback) { } export function getPlanStageOption(callback) { - return baseGet('/test/plan/get/stage/option/' + getCurrentWorkspaceId(), callback); + let wId = getCurrentWorkspaceId(); + return wId ? baseGet('/test/plan/get/stage/option/' + wId, callback) : {}; }