fix(测试跟踪): Jira同步经办人及项目集字段有误 (#18280)

--bug=1017197 --user=宋昌昌 【测试跟踪】github #17764,MS和Jira集成已经成功,在MS中创建缺陷,拉取的Jira缺陷模板,少一个自定义字段【项目集】,其他的自定义字段都可以拉取到。 https://www.tapd.cn/55049933/s/1252392

Co-authored-by: song-cc-rock <changchang.song@fit2cloud.com>
This commit is contained in:
MeterSphere Bot 2022-09-27 10:27:09 +08:00 committed by GitHub
parent 67d47348d7
commit 5a8cb928aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 11 deletions

View File

@ -419,7 +419,11 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
Object value = issue.get(fieldName);
if (value != null) {
if (value instanceof JSONObject) {
item.setValue(getSyncJsonParamValue(value));
if (StringUtils.equals(fieldName, "assignee")) {
item.setValue(((JSONObject) value).get("displayName"));
} else {
item.setValue(getSyncJsonParamValue(value));
}
} else if (value instanceof JSONArray) {
List<Object> values = new ArrayList<>();
((JSONArray)value).forEach(attr -> {

View File

@ -27,6 +27,7 @@ import io.metersphere.track.request.testcase.IssuesUpdateRequest;
import io.metersphere.track.service.IssuesService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;
@ -411,21 +412,26 @@ public class JiraPlatform extends AbstractIssuePlatform {
private void parseCustomFiled(IssuesUpdateRequest issuesRequest, List<CustomFieldItemDTO> customFields, JSONObject fields) {
customFields.forEach(item -> {
String fieldName = item.getCustomData();
String name = item.getName();
if (StringUtils.isNotBlank(fieldName)) {
if (item.getValue() != null) {
if (ObjectUtils.isNotEmpty(item.getValue())) {
if (StringUtils.isNotBlank(item.getType())) {
if (StringUtils.equalsAny(item.getType(), "select", "radio", "member")) {
JSONObject param = new JSONObject();
if (fieldName.equals("assignee") || fieldName.equals("reporter")) {
if (issuesRequest.isThirdPartPlatform()) {
param.put("id", item.getValue());
} else {
param.put("name", item.getValue());
}
if (StringUtils.equalsAnyIgnoreCase(name, "PML", "PMLinkTest", "PMLink")) {
fields.put(fieldName, item.getValue());
} else {
param.put("id", item.getValue());
JSONObject param = new JSONObject();
if (fieldName.equals("assignee") || fieldName.equals("reporter")) {
if (issuesRequest.isThirdPartPlatform()) {
param.put("id", item.getValue());
} else {
param.put("accountId", item.getValue());
}
} else {
param.put("id", item.getValue());
}
fields.put(fieldName, param);
}
fields.put(fieldName, param);
} else if (StringUtils.equalsAny(item.getType(), "multipleSelect", "checkbox", "multipleMember")) {
JSONArray attrs = new JSONArray();
if (item.getValue() != null) {