|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.inscloudtech.functional.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.http.*; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
@ -19,6 +20,7 @@ import com.inscloudtech.functional.mapper.FuncCarApiMapper; |
|
|
|
import com.inscloudtech.functional.service.IFuncCarApiService; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 兼容可靠性测试系统-API接口兼容性测试工具Service业务层处理 |
|
|
@ -47,6 +49,47 @@ public class FuncCarApiServiceImpl implements IFuncCarApiService { |
|
|
|
public TableDataInfo<FuncCarApi> queryPageList(FuncCarApi bo, PageQuery pageQuery) { |
|
|
|
LambdaQueryWrapper<FuncCarApi> lqw = buildQueryWrapper(bo); |
|
|
|
Page<FuncCarApi> result = baseMapper.selectPage(pageQuery.build(), lqw); |
|
|
|
List<FuncCarApi> records = result.getRecords(); |
|
|
|
if(CollectionUtil.isNotEmpty(records)){ |
|
|
|
Set<String> urlSet = records.stream().map(FuncCarApi::getApiUrl).collect(Collectors.toSet()); |
|
|
|
Set<Long> ids = records.stream().map(FuncCarApi::getOperId).collect(Collectors.toSet()); |
|
|
|
LambdaQueryWrapper<FuncCarApi> lqw2 = Wrappers.lambdaQuery(); |
|
|
|
lqw2.eq(FuncCarApi::getUserId, records.get(0).getUserId()); |
|
|
|
lqw2.in(FuncCarApi::getApiUrl, urlSet); |
|
|
|
lqw2.notIn(FuncCarApi::getOperId, ids); |
|
|
|
List<FuncCarApi> funcCarApis = baseMapper.selectList(lqw2); |
|
|
|
funcCarApis.addAll(records); |
|
|
|
if(CollectionUtil.isNotEmpty(funcCarApis)){ |
|
|
|
Map<String, List<FuncCarApi>> collect = funcCarApis.stream().collect(Collectors.groupingBy(FuncCarApi::getApiUrl)); |
|
|
|
for (FuncCarApi record : records) { |
|
|
|
String flagVal = record.getOs() + record.getBrowser() + record.getEquipment() + record.getNetwork(); |
|
|
|
if(collect.containsKey(record.getApiUrl())){ |
|
|
|
List<FuncCarApi> apis = collect.get(record.getApiUrl()); |
|
|
|
for (FuncCarApi api : apis) { |
|
|
|
if(api.getJsonResult().equals(record.getJsonResult()) && !api.getOperId().equals(record.getOperId())){ |
|
|
|
String s = api.getOs() + api.getBrowser() + api.getEquipment() + api.getNetwork(); |
|
|
|
if(!flagVal.equals(s)){ |
|
|
|
record.setTestResult("接口兼容性测试通过"); |
|
|
|
break; |
|
|
|
}else { |
|
|
|
record.setTestResult("该记录无比对样本"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
record.setTestResult("该记录无比对样本"); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
for (FuncCarApi record : records) { |
|
|
|
record.setTestResult("该记录无比对样本"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TableDataInfo.build(result); |
|
|
|
} |
|
|
|
|
|
|
@ -112,7 +155,7 @@ public class FuncCarApiServiceImpl implements IFuncCarApiService { |
|
|
|
request.header(Header.USER_AGENT,"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
if(StringUtils.isNotEmpty(bo.getNetwork())){ |
|
|
|
if(!bo.getNetwork().toLowerCase().equals("wifi")){ |
|
|
|
if(!bo.getNetwork().toLowerCase().equals("wifi") || !bo.getNetwork().toLowerCase().equals("有线网络")){ |
|
|
|
// 模拟网络延迟 |
|
|
|
Random random = new Random(); |
|
|
|
int delayMillis = random.nextInt(500); // 随机延迟0-500毫秒 |
|
|
|