From 78dc8444eb45d414338cf77a990ee0b9d46ea839 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 14 Feb 2022 10:16:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20ji?= =?UTF-8?q?ra=E6=A8=A1=E6=9D=BF=E6=B2=A1=E6=9C=89=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=A4=9A=E9=80=89=E6=A1=86=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/issue/AbstractIssuePlatform.java | 44 ++++++++++--------- .../metersphere/track/issue/JiraPlatform.java | 7 +++ 2 files changed, 30 insertions(+), 21 deletions(-) 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 dee9e31498..02a9e62c8f 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -396,6 +396,27 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { }); } + protected Object getSyncJsonParamValue(Object value) { + JSONObject valObj = ((JSONObject) value); + String accountId = valObj.getString("accountId"); + JSONObject child = valObj.getJSONObject("child"); + if (child != null) {// 级联框 + List values = new ArrayList<>(); + if (StringUtils.isNotBlank(valObj.getString("id"))) { + values.add(valObj.getString("id")); + } + if (StringUtils.isNotBlank(child.getString("id"))) { + values.add(child.getString("id")); + } + return values; + } else if (StringUtils.isNotBlank(accountId) && isThirdPartTemplate) { + // 用户选择框 + return accountId; + } else { + return valObj.getString("id"); + } + } + protected String syncIssueCustomField(String customFieldsStr, JSONObject issue) { List customFields = CustomFieldService.getCustomFields(customFieldsStr); Set names = issue.keySet(); @@ -404,31 +425,12 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { Object value = issue.get(fieldName); if (value != null) { if (value instanceof JSONObject) { - JSONObject valObj = ((JSONObject) value); - String accountId = valObj.getString("accountId"); - JSONObject child = valObj.getJSONObject("child"); - if (child != null) {// 级联框 - List values = new ArrayList<>(); - if (StringUtils.isNotBlank(valObj.getString("id"))) { - values.add(valObj.getString("id")); - } - if (StringUtils.isNotBlank(child.getString("id"))) { - values.add(child.getString("id")); - } - item.setValue(values); - } else if (StringUtils.isNotBlank(accountId)) { - // 用户选择框 - if (isThirdPartTemplate) { - item.setValue(accountId); - } - } else { - item.setValue(valObj.getString("id")); - } + item.setValue(getSyncJsonParamValue(value)); } else if (value instanceof JSONArray) { List values = new ArrayList<>(); ((JSONArray)value).forEach(attr -> { if (attr instanceof JSONObject) { - values.add(((JSONObject)attr).getString("id")); + values.add(getSyncJsonParamValue(attr)); } else { values.add(attr); } 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 13a8051440..0212c5fb36 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -524,6 +524,13 @@ public class JiraPlatform extends AbstractIssuePlatform { } else if (customType.contains("userpicker")) { value = CustomFieldType.SELECT.getValue(); customFieldDao.setOptions(userOptions); + } else if (customType.contains("people")) { + if (StringUtils.isNotBlank(schema.getType()) && StringUtils.equals(schema.getType(), "array")) { + value = CustomFieldType.MULTIPLE_SELECT.getValue(); + } else { + value = CustomFieldType.SELECT.getValue(); + } + customFieldDao.setOptions(userOptions); } else if (customType.contains("multicheckboxes")) { value = CustomFieldType.CHECKBOX.getValue(); customFieldDao.setDefaultValue(JSONObject.toJSONString(new ArrayList<>()));