fix(测试跟踪): 更新禅道缺陷状态失败

--bug=1013654 --user=李玉号 【测试跟踪】github#14036
单项同步(MS创建的缺陷同步禅道)-缺陷模版上有添加关联字段,MS更新缺陷状态同步失败
https://www.tapd.cn/55049933/s/1172626

Closes #14036
This commit is contained in:
shiziyuan9527 2022-06-02 14:29:29 +08:00 committed by f2c-ci-robot[bot]
parent 34f55fe3f7
commit bf6c552bc5
1 changed files with 27 additions and 0 deletions

View File

@ -38,6 +38,7 @@ import org.springframework.web.client.RestTemplate;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -228,9 +229,35 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
setUserConfig();
MultiValueMap<String, Object> param = buildUpdateParam(request);
handleIssueUpdate(request);
this.handleZentaoBugStatus(param);
zentaoClient.updateIssue(request.getPlatformId(), param);
}
private void handleZentaoBugStatus(MultiValueMap<String, Object> param) {
if (!param.containsKey("status")) {
return;
}
List<Object> status = param.get("status");
if (CollectionUtils.isEmpty(status)) {
return;
}
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = (String) status.get(0);
if (StringUtils.equals(str, "resolved")) {
param.add("resolvedDate", format.format(new Date()));
} else if (StringUtils.equals(str, "closed")) {
param.add("closedDate", format.format(new Date()));
if (!param.containsKey("resolution")) {
// 解决方案默认为已解决
param.add("resolution", "fixed");
}
}
} catch (Exception e) {
//
}
}
private MultiValueMap<String, Object> buildUpdateParam(IssuesUpdateRequest issuesRequest) {
issuesRequest.setPlatform(key);
String projectId = getProjectId(issuesRequest.getProjectId());