fix(测试跟踪): jira模板没有同步人员多选框字段

This commit is contained in:
chenjianxing 2022-02-14 10:16:45 +08:00 committed by 刘瑞斌
parent 848c057cb0
commit 78dc8444eb
2 changed files with 30 additions and 21 deletions

View File

@ -396,14 +396,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
}); });
} }
protected String syncIssueCustomField(String customFieldsStr, JSONObject issue) { protected Object getSyncJsonParamValue(Object value) {
List<CustomFieldItemDTO> customFields = CustomFieldService.getCustomFields(customFieldsStr);
Set<String> names = issue.keySet();
customFields.forEach(item -> {
String fieldName = item.getCustomData();
Object value = issue.get(fieldName);
if (value != null) {
if (value instanceof JSONObject) {
JSONObject valObj = ((JSONObject) value); JSONObject valObj = ((JSONObject) value);
String accountId = valObj.getString("accountId"); String accountId = valObj.getString("accountId");
JSONObject child = valObj.getJSONObject("child"); JSONObject child = valObj.getJSONObject("child");
@ -415,20 +408,29 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
if (StringUtils.isNotBlank(child.getString("id"))) { if (StringUtils.isNotBlank(child.getString("id"))) {
values.add(child.getString("id")); values.add(child.getString("id"));
} }
item.setValue(values); return values;
} else if (StringUtils.isNotBlank(accountId)) { } else if (StringUtils.isNotBlank(accountId) && isThirdPartTemplate) {
// 用户选择框 // 用户选择框
if (isThirdPartTemplate) { return accountId;
item.setValue(accountId);
}
} else { } else {
item.setValue(valObj.getString("id")); return valObj.getString("id");
} }
}
protected String syncIssueCustomField(String customFieldsStr, JSONObject issue) {
List<CustomFieldItemDTO> customFields = CustomFieldService.getCustomFields(customFieldsStr);
Set<String> names = issue.keySet();
customFields.forEach(item -> {
String fieldName = item.getCustomData();
Object value = issue.get(fieldName);
if (value != null) {
if (value instanceof JSONObject) {
item.setValue(getSyncJsonParamValue(value));
} else if (value instanceof JSONArray) { } else if (value instanceof JSONArray) {
List<Object> values = new ArrayList<>(); List<Object> values = new ArrayList<>();
((JSONArray)value).forEach(attr -> { ((JSONArray)value).forEach(attr -> {
if (attr instanceof JSONObject) { if (attr instanceof JSONObject) {
values.add(((JSONObject)attr).getString("id")); values.add(getSyncJsonParamValue(attr));
} else { } else {
values.add(attr); values.add(attr);
} }

View File

@ -524,6 +524,13 @@ public class JiraPlatform extends AbstractIssuePlatform {
} else if (customType.contains("userpicker")) { } else if (customType.contains("userpicker")) {
value = CustomFieldType.SELECT.getValue(); value = CustomFieldType.SELECT.getValue();
customFieldDao.setOptions(userOptions); 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")) { } else if (customType.contains("multicheckboxes")) {
value = CustomFieldType.CHECKBOX.getValue(); value = CustomFieldType.CHECKBOX.getValue();
customFieldDao.setDefaultValue(JSONObject.toJSONString(new ArrayList<>())); customFieldDao.setDefaultValue(JSONObject.toJSONString(new ArrayList<>()));