fix(接口定义): 修复已知问题并完成优化需求 #1003813
--story=1003813 --user=赵勇 场景上传 csv 文件优化 https://www.tapd.cn/55049933/s/1065761
This commit is contained in:
parent
407e177d81
commit
884e13acd8
|
@ -35,8 +35,8 @@ public class FixedTask {
|
|||
ReportCounter counter = MessageCache.cache.get(key);
|
||||
LogUtil.info("集成报告:【" + key + "】总执行场景:【" + counter.getReportIds().size() + "】已经执行完成场景:【" + counter.getCompletedIds().size() + "】");
|
||||
List<String> filterList = counter.getReportIds().stream().filter(t -> !counter.getCompletedIds().contains(t)).collect(Collectors.toList());
|
||||
LogUtil.info("剩余要执行的报告" + JSON.toJSONString(filterList));
|
||||
|
||||
LogUtil.debug("剩余要执行的报告" + JSON.toJSONString(filterList));
|
||||
// 合并
|
||||
if (counter.getCompletedIds().size() >= counter.getReportIds().size()) {
|
||||
scenarioReportService.margeReport(key, counter.getReportIds());
|
||||
|
@ -55,7 +55,7 @@ public class FixedTask {
|
|||
// 资源池中已经没有执行的请求了
|
||||
int runningCount = scenarioReportService.get(key, counter);
|
||||
if (runningCount == 0) {
|
||||
LogUtil.info("发生未知异常,进行资源合并,请检查资源池是否正常运行");
|
||||
LogUtil.error("发生未知异常,进行资源合并,请检查资源池是否正常运行");
|
||||
scenarioReportService.margeReport(key, counter.getReportIds());
|
||||
guardTask.remove(key);
|
||||
MessageCache.cache.remove(key);
|
||||
|
|
|
@ -1361,23 +1361,16 @@ public class ApiAutomationService {
|
|||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioReportMapper batchMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
|
||||
// 开始并发执行
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String reportId : executeQueue.keySet()) {
|
||||
//存储报告
|
||||
APIScenarioReportResult report = executeQueue.get(reportId).getReport();
|
||||
batchMapper.insert(report);
|
||||
// 增加一个本地锁,防止并发找不到资源
|
||||
MessageCache.scenarioExecResourceLock.put(reportId, report);
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
sqlSession.commit();
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
for (String reportId : executeQueue.keySet()) {
|
||||
// 增加一个本地锁,防止并发找不到资源
|
||||
if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) {
|
||||
String testPlanScenarioId = "";
|
||||
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(executeQueue.get(reportId).getTestId())) {
|
||||
|
|
|
@ -519,11 +519,18 @@ public class ApiScenarioReportService {
|
|||
ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample();
|
||||
scenarioReportExample.createCriteria().andScenarioIdIn(list);
|
||||
List<ApiScenarioReport> reportList = apiScenarioReportMapper.selectByExample(scenarioReportExample);
|
||||
list.forEach(item ->{
|
||||
if(MessageCache.scenarioExecResourceLock.containsKey(item)) {
|
||||
|
||||
if (CollectionUtils.isEmpty(reportList)) {
|
||||
ApiScenarioReportExample example = new ApiScenarioReportExample();
|
||||
example.createCriteria().andIdIn(list);
|
||||
reportList = apiScenarioReportMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
for (String item : list) {
|
||||
if (MessageCache.scenarioExecResourceLock.containsKey(item)) {
|
||||
reportList.add(MessageCache.scenarioExecResourceLock.get(item));
|
||||
}
|
||||
});
|
||||
}
|
||||
for (ApiScenarioReport report : reportList) {
|
||||
report.setStatus("Error");
|
||||
apiScenarioReportMapper.updateByPrimaryKey(report);
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {downloadFile} from "@/common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsApiBodyFileUpload",
|
||||
data() {
|
||||
|
@ -50,7 +52,7 @@ export default {
|
|||
download() {
|
||||
// 本地文件
|
||||
if (this.parameter.files && this.parameter.files.length > 0 && this.parameter.files[0].file) {
|
||||
console.log("local",this.parameter.files[0].file)
|
||||
downloadFile(this.parameter.files[0].file.name, this.parameter.files[0].file);
|
||||
}
|
||||
// 远程下载文件
|
||||
if (this.parameter.files && this.parameter.files.length > 0 && !this.parameter.files[0].file) {
|
||||
|
@ -63,9 +65,9 @@ export default {
|
|||
};
|
||||
this.result = this.$request(conf).then(response => {
|
||||
const content = response.data;
|
||||
const blob = new Blob([content]);
|
||||
console.log(content)
|
||||
|
||||
if(content && this.parameter.files[0]) {
|
||||
downloadFile(this.parameter.files[0].name, content);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue