fix: 勾选第三方模板报告人选不上

--bug=1009269 --user=陈建星 [ github#8862]对接jira填完了但是报“报告人不能为空” https://www.tapd.cn/55049933/s/1095003
This commit is contained in:
chenjianxing 2022-01-20 14:53:35 +08:00 committed by jianxing
parent 3774b91928
commit 4f8723656e
2 changed files with 28 additions and 15 deletions

View File

@ -171,11 +171,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
} }
/** /**
* sprint 传参数比较特殊需要要传数值 * 参数比较特殊需要特别处理
* @param fields * @param fields
*/ */
private void setSprintParam(JSONObject fields) { private void setSpecialParam(JSONObject fields) {
String sprintKey = null;
String projectKey = getProjectId(this.projectId); String projectKey = getProjectId(this.projectId);
JiraConfig config = getConfig(); JiraConfig config = getConfig();
Map<String, JiraCreateMetadataResponse.Field> createMetadata = new HashMap<>(); Map<String, JiraCreateMetadataResponse.Field> createMetadata = new HashMap<>();
@ -186,19 +185,26 @@ public class JiraPlatform extends AbstractIssuePlatform {
for (String name : createMetadata.keySet()) { for (String name : createMetadata.keySet()) {
JiraCreateMetadataResponse.Field item = createMetadata.get(name); JiraCreateMetadataResponse.Field item = createMetadata.get(name);
JiraCreateMetadataResponse.Schema schema = item.getSchema(); JiraCreateMetadataResponse.Schema schema = item.getSchema();
String key = item.getKey();
if (schema != null && schema.getCustom() != null && schema.getCustom().endsWith("sprint")) { if (schema != null && schema.getCustom() != null && schema.getCustom().endsWith("sprint")) {
sprintKey = item.getKey(); JSONObject field = fields.getJSONObject(key);
break; try {
// 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);
} }
} }
if (StringUtils.isNotBlank(sprintKey)) {
JSONObject field = fields.getJSONObject(sprintKey);
if (field != null) {
try {
fields.put(sprintKey, field.getInteger("id"));
} catch (Exception e) {}
}
} }
} }
@ -232,7 +238,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
fields.put("description", desc); fields.put("description", desc);
parseCustomFiled(issuesRequest, fields); parseCustomFiled(issuesRequest, fields);
} }
setSprintParam(fields); setSpecialParam(fields);
return addJiraIssueParam; return addJiraIssueParam;
} }
@ -405,7 +411,9 @@ public class JiraPlatform extends AbstractIssuePlatform {
char filedKey = 'A'; char filedKey = 'A';
for (String name : createMetadata.keySet()) { for (String name : createMetadata.keySet()) {
JiraCreateMetadataResponse.Field item = createMetadata.get(name); 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(); JiraCreateMetadataResponse.Schema schema = item.getSchema();
CustomFieldDao customFieldDao = new CustomFieldDao(); CustomFieldDao customFieldDao = new CustomFieldDao();
customFieldDao.setKey(String.valueOf(filedKey++)); customFieldDao.setKey(String.valueOf(filedKey++));
@ -560,7 +568,11 @@ public class JiraPlatform extends AbstractIssuePlatform {
JSONArray options = new JSONArray(); JSONArray options = new JSONArray();
userOptions.forEach(val -> { userOptions.forEach(val -> {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
if (StringUtils.isNotBlank(val.getAccountId())) {
jsonObject.put("value", val.getAccountId()); jsonObject.put("value", val.getAccountId());
} else {
jsonObject.put("value", val.getKey());
}
jsonObject.put("text", val.getDisplayName()); jsonObject.put("text", val.getDisplayName());
options.add(jsonObject); options.add(jsonObject);
}); });

View File

@ -7,6 +7,7 @@ import lombok.Setter;
@Getter @Getter
public class JiraUser { public class JiraUser {
private String accountId; private String accountId;
private String key;
private String displayName; private String displayName;
private String emailAddress; private String emailAddress;
private Boolean active; private Boolean active;