From 149e9a293889f661d10711f80e36d0010ebf307c Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 20 Jan 2022 14:53:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8B=BE=E9=80=89=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E6=A8=A1=E6=9D=BF=E6=8A=A5=E5=91=8A=E4=BA=BA=E9=80=89?= =?UTF-8?q?=E4=B8=8D=E4=B8=8A=20--bug=3D1009269=20--user=3D=E9=99=88?= =?UTF-8?q?=E5=BB=BA=E6=98=9F=20[=20github#8862]=E5=AF=B9=E6=8E=A5jira?= =?UTF-8?q?=E5=A1=AB=E5=AE=8C=E4=BA=86=E4=BD=86=E6=98=AF=E6=8A=A5=E2=80=9C?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E4=BA=BA=E4=B8=8D=E8=83=BD=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E2=80=9D=20https://www.tapd.cn/55049933/s/1095003?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/track/issue/JiraPlatform.java | 42 ++++++++++++------- .../track/issue/domain/jira/JiraUser.java | 1 + 2 files changed, 28 insertions(+), 15 deletions(-) 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 5609b6aa58..beb025a0d5 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -171,11 +171,10 @@ public class JiraPlatform extends AbstractIssuePlatform { } /** - * sprint 传参数比较特殊,需要要传数值 + * 参数比较特殊,需要特别处理 * @param fields */ - private void setSprintParam(JSONObject fields) { - String sprintKey = null; + private void setSpecialParam(JSONObject fields) { String projectKey = getProjectId(this.projectId); JiraConfig config = getConfig(); Map createMetadata = new HashMap<>(); @@ -186,19 +185,26 @@ public class JiraPlatform extends AbstractIssuePlatform { for (String name : createMetadata.keySet()) { JiraCreateMetadataResponse.Field item = createMetadata.get(name); JiraCreateMetadataResponse.Schema schema = item.getSchema(); + String key = item.getKey(); if (schema != null && schema.getCustom() != null && schema.getCustom().endsWith("sprint")) { - sprintKey = item.getKey(); - break; - } - } - - if (StringUtils.isNotBlank(sprintKey)) { - JSONObject field = fields.getJSONObject(sprintKey); - if (field != null) { + JSONObject field = fields.getJSONObject(key); try { - fields.put(sprintKey, field.getInteger("id")); + // sprint 传参数比较特殊,需要要传数值 + fields.put(key, field.getInteger("id")); } catch (Exception e) {} } + if (key.equals("reporter")) { + JSONObject field = fields.getJSONObject(key); + try { + UUID.fromString(field.getString("id")); + } catch (Exception e) { + // 如果不是uuid,则是用户的key,参数调整为key + JSONObject newField = new JSONObject(); + newField.put("key", field.getString("id")); + fields.put(key, newField); + } + } + } } @@ -232,7 +238,7 @@ public class JiraPlatform extends AbstractIssuePlatform { fields.put("description", desc); parseCustomFiled(issuesRequest, fields); } - setSprintParam(fields); + setSpecialParam(fields); return addJiraIssueParam; } @@ -405,7 +411,9 @@ public class JiraPlatform extends AbstractIssuePlatform { char filedKey = 'A'; for (String name : createMetadata.keySet()) { JiraCreateMetadataResponse.Field item = createMetadata.get(name); - if (ignoreSet.contains(name)) continue; // timetracking, attachment todo + if (ignoreSet.contains(name)) { + continue; // timetracking, attachment todo + } JiraCreateMetadataResponse.Schema schema = item.getSchema(); CustomFieldDao customFieldDao = new CustomFieldDao(); customFieldDao.setKey(String.valueOf(filedKey++)); @@ -560,7 +568,11 @@ public class JiraPlatform extends AbstractIssuePlatform { JSONArray options = new JSONArray(); userOptions.forEach(val -> { JSONObject jsonObject = new JSONObject(); - jsonObject.put("value", val.getAccountId()); + if (StringUtils.isNotBlank(val.getAccountId())) { + jsonObject.put("value", val.getAccountId()); + } else { + jsonObject.put("value", val.getKey()); + } jsonObject.put("text", val.getDisplayName()); options.add(jsonObject); }); diff --git a/backend/src/main/java/io/metersphere/track/issue/domain/jira/JiraUser.java b/backend/src/main/java/io/metersphere/track/issue/domain/jira/JiraUser.java index 84e0dc5f22..bf9e68e450 100644 --- a/backend/src/main/java/io/metersphere/track/issue/domain/jira/JiraUser.java +++ b/backend/src/main/java/io/metersphere/track/issue/domain/jira/JiraUser.java @@ -7,6 +7,7 @@ import lombok.Setter; @Getter public class JiraUser { private String accountId; + private String key; private String displayName; private String emailAddress; private Boolean active;