fix: 缺陷状态同步

--bug=1007517 --user=lyh 【我的工作台】我的仪表盘,我创建的缺陷,新建了3个本地缺陷,状态都显示了新建
https://www.tapd.cn/55049933/s/1059995
This commit is contained in:
shiziyuan9527 2021-10-27 17:25:24 +08:00 committed by 刘瑞斌
parent d01e9d748f
commit 6a36eb3cf5
1 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.track.issue; package io.metersphere.track.issue;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.IssuesDao;
import io.metersphere.base.domain.IssuesWithBLOBs; import io.metersphere.base.domain.IssuesWithBLOBs;
import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.IssuesManagePlatform;
@ -9,6 +10,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.dto.DemandDTO;
import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesRequest;
import io.metersphere.track.request.testcase.IssuesUpdateRequest; import io.metersphere.track.request.testcase.IssuesUpdateRequest;
import io.metersphere.track.request.testcase.TestCaseBatchRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.List; import java.util.List;
@ -39,13 +41,23 @@ public class LocalPlatform extends LocalAbstractPlatform {
@Override @Override
public void addIssue(IssuesUpdateRequest issuesRequest) { public void addIssue(IssuesUpdateRequest issuesRequest) {
String issueStatus = "new";
if (StringUtils.isNotBlank(issuesRequest.getCustomFields())) {
List<TestCaseBatchRequest.CustomFiledRequest> fields = JSONObject.parseArray(issuesRequest.getCustomFields(), TestCaseBatchRequest.CustomFiledRequest.class);
for (TestCaseBatchRequest.CustomFiledRequest field : fields) {
if (StringUtils.equals("状态", field.getName())) {
issueStatus = (String) field.getValue();
break;
}
}
}
SessionUser user = SessionUtils.getUser(); SessionUser user = SessionUtils.getUser();
String id = UUID.randomUUID().toString(); String id = UUID.randomUUID().toString();
IssuesWithBLOBs issues = new IssuesWithBLOBs(); IssuesWithBLOBs issues = new IssuesWithBLOBs();
BeanUtils.copyBean(issues, issuesRequest); BeanUtils.copyBean(issues, issuesRequest);
issues.setId(id); issues.setId(id);
issues.setPlatformId(id); issues.setPlatformId(id);
issues.setStatus("new"); issues.setStatus(issueStatus);
issues.setReporter(user.getId()); issues.setReporter(user.getId());
issues.setCreateTime(System.currentTimeMillis()); issues.setCreateTime(System.currentTimeMillis());
issues.setUpdateTime(System.currentTimeMillis()); issues.setUpdateTime(System.currentTimeMillis());