parent
77fcc6907d
commit
65b4ee425d
|
@ -343,14 +343,42 @@ public class ApiScenarioReportService {
|
||||||
ids = allIds.stream().filter(id -> !reportRequest.getUnSelectIds().contains(id)).collect(Collectors.toList());
|
ids = allIds.stream().filter(id -> !reportRequest.getUnSelectIds().contains(id)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//为预防数量太多,调用删除方法时引起SQL过长的Bug,此处采取分批执行的方式。
|
||||||
|
//每次处理的数据数量
|
||||||
|
int handleCount = 7000;
|
||||||
|
//每次处理的集合
|
||||||
|
List<String> handleIdList = new ArrayList<>(handleCount);
|
||||||
|
while (ids.size() > handleCount){
|
||||||
|
handleIdList = new ArrayList<>(handleCount);
|
||||||
|
List<String> otherIdList = new ArrayList<>();
|
||||||
|
for (int index = 0;index < ids.size();index++){
|
||||||
|
if(index<handleCount){
|
||||||
|
handleIdList.add(ids.get(index));
|
||||||
|
}else{
|
||||||
|
otherIdList.add(ids.get(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//处理本次的数据
|
||||||
|
ApiScenarioReportDetailExample detailExample = new ApiScenarioReportDetailExample();
|
||||||
|
detailExample.createCriteria().andReportIdIn(handleIdList);
|
||||||
|
apiScenarioReportDetailMapper.deleteByExample(detailExample);
|
||||||
|
ApiScenarioReportExample apiTestReportExample = new ApiScenarioReportExample();
|
||||||
|
apiTestReportExample.createCriteria().andIdIn(handleIdList);
|
||||||
|
apiScenarioReportMapper.deleteByExample(apiTestReportExample);
|
||||||
|
//转存剩余的数据
|
||||||
|
ids = otherIdList;
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理最后剩余的数据
|
||||||
|
if(!ids.isEmpty()){
|
||||||
ApiScenarioReportDetailExample detailExample = new ApiScenarioReportDetailExample();
|
ApiScenarioReportDetailExample detailExample = new ApiScenarioReportDetailExample();
|
||||||
detailExample.createCriteria().andReportIdIn(ids);
|
detailExample.createCriteria().andReportIdIn(ids);
|
||||||
apiScenarioReportDetailMapper.deleteByExample(detailExample);
|
apiScenarioReportDetailMapper.deleteByExample(detailExample);
|
||||||
|
|
||||||
ApiScenarioReportExample apiTestReportExample = new ApiScenarioReportExample();
|
ApiScenarioReportExample apiTestReportExample = new ApiScenarioReportExample();
|
||||||
apiTestReportExample.createCriteria().andIdIn(ids);
|
apiTestReportExample.createCriteria().andIdIn(ids);
|
||||||
apiScenarioReportMapper.deleteByExample(apiTestReportExample);
|
apiScenarioReportMapper.deleteByExample(apiTestReportExample);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public long countByProjectID(String projectId) {
|
public long countByProjectID(String projectId) {
|
||||||
return extApiScenarioReportMapper.countByProjectID(projectId);
|
return extApiScenarioReportMapper.countByProjectID(projectId);
|
||||||
|
|
Loading…
Reference in New Issue