Commit 8e530355 authored by 罗林杰's avatar 罗林杰

修改获取数据重复bug

parent a7323a08
......@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.TTestPlanRecord;
import com.ruoyi.domain.vo.ItemsByUseCaseVO;
import com.ruoyi.domain.vo.RecaordUseCasesVO;
import com.ruoyi.domain.vo.UseCaseUrlVO;
import com.ruoyi.service.TTestPlanRecordService;
import com.ruoyi.mapper.TTestPlanRecordMapper;
......@@ -19,6 +20,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author W_YI
......@@ -75,7 +78,34 @@ public class TTestPlanRecordServiceImpl extends ServiceImpl<TTestPlanRecordMappe
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
// List listUseCase = new ArrayList();
List listUseCase = jsonObject.getJSONObject("data").getJSONObject("regulationByName").getList("itemsByUseCase", ItemsByUseCaseVO.class);
List<ItemsByUseCaseVO> listUseCase = jsonObject.getJSONObject("data").getJSONObject("regulationByName").getList("itemsByUseCase", ItemsByUseCaseVO.class);
// 遍历listUseCase
for (ItemsByUseCaseVO itemsByUseCaseVO : listUseCase) {
//进行去重
Map<String, RecaordUseCasesVO> map = itemsByUseCaseVO.getUseCases().stream()
.filter(useCase -> useCase.getCustomizedID() != null)
.collect(Collectors.toMap(
RecaordUseCasesVO::getCustomizedID,
useCase -> useCase,
(existing, replacement) -> existing
// 如果遇到重复的ID,选择保留原来的那个
));
itemsByUseCaseVO.setUseCases(new ArrayList<>(map.values()));
//根据customizedID进行排序
itemsByUseCaseVO.getUseCases().sort((o1, o2) -> {
String id1 = o1.getCustomizedID();
String id2 = o2.getCustomizedID();
// 提取子版本号部分("-"后面的部分)
String subVersion1 = id1.substring(id1.lastIndexOf('-') + 1);
String subVersion2 = id2.substring(id2.lastIndexOf('-') + 1);
// 比较子版本号
return Integer.compare(Integer.parseInt(subVersion1), Integer.parseInt(subVersion2));
});
}
return listUseCase;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment