|
@@ -39,62 +39,56 @@ class Report(APIView):
|
|
return HttpResponse(status=404, content='软件已删除或不存在')
|
|
return HttpResponse(status=404, content='软件已删除或不存在')
|
|
software = software[0]
|
|
software = software[0]
|
|
|
|
|
|
- beidou_cases = BeidouCase.objects.order_by('-create_time')
|
|
|
|
-
|
|
|
|
- beidou_cases = beidou_cases.filter(software_id=software_id)
|
|
|
|
-
|
|
|
|
- version = request.GET.get('version')
|
|
|
|
- if version:
|
|
|
|
- beidou_cases = beidou_cases.filter(version=version)
|
|
|
|
-
|
|
|
|
- export_type = request.GET.get('export_type')
|
|
|
|
-
|
|
|
|
- file_name = software.name + '-全部测试用例.xls'
|
|
|
|
- if export_type:
|
|
|
|
- if export_type == '2':
|
|
|
|
- file_name = software.name + '-不合格测试用例.xls'
|
|
|
|
- beidou_cases = beidou_cases.filter(state=2)
|
|
|
|
-
|
|
|
|
- if not beidou_cases:
|
|
|
|
- logger.error("无符合要求的测试用例")
|
|
|
|
- return HttpResponse(status=404, content='无符合要求的测试用例')
|
|
|
|
-
|
|
|
|
- update_time = datetime.datetime.now()
|
|
|
|
- file_dir = SOFTWARE_ROOT + "/" + str(update_time)
|
|
|
|
- if not os.path.exists(file_dir):
|
|
|
|
- os.makedirs(file_dir)
|
|
|
|
- file_path = file_dir + "/" + file_name
|
|
|
|
-
|
|
|
|
- cases_info = [
|
|
|
|
- ['测试项目', '版本', '测试内容', '定位精度', '定时精度', '伪距测量精度', '载波测量精度', '测速精度',
|
|
|
|
- '捕获灵敏度', '接收灵敏度', '跟踪灵敏度', '功率范围', '自主完好性', '系统完好性', '首次捕获时间',
|
|
|
|
- '失锁重捕时间', '定位测速更新率', '跟踪通道数', '最大速度', '最大加速度', '执行结果', '测试人员', '备注']]
|
|
|
|
-
|
|
|
|
- for case in beidou_cases:
|
|
|
|
- power = ''
|
|
|
|
- if case.power_range_low and case.power_range_high:
|
|
|
|
- power = str(case.power_range_low) + '-' + str(case.power_range_high)
|
|
|
|
- state = '成功'
|
|
|
|
- if case.state == 2:
|
|
|
|
- state = '失败'
|
|
|
|
- executor_name = User.objects.filter(id=case.executor_id)[0].username
|
|
|
|
-
|
|
|
|
- cases_info.append(Report.convert_to_string(
|
|
|
|
- [software.name, case.version, case.title, case.positioning_accuracy, case.timing_accuracy,
|
|
|
|
- case.pseudo_range_measurement_accuracy, case.carrier_measurement_accuracy,
|
|
|
|
- case.speed_measurement_accuracy, case.sensitivity_capture, case.receiving_sensitivity,
|
|
|
|
- case.sensitivity_track, power, case.self_integrity, case.system_integrity, case.capture_time,
|
|
|
|
- case.recapture_time, case.update_rate, case.trace_channels, case.max_velocity, case.max_acceleration,
|
|
|
|
- state, executor_name, case.remark]
|
|
|
|
- ))
|
|
|
|
-
|
|
|
|
- sio = write_to_xlsx(file_path, cases_info)
|
|
|
|
- sio.seek(0)
|
|
|
|
- response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel')
|
|
|
|
- # response['Content-Disposition'] = 'attachment; filename*=UTF-8''{}'.format(escape_uri_path(file_name))
|
|
|
|
- response['Content-Disposition'] = 'attachment; filename="{0}"'.format(file_name).encode('utf-8',
|
|
|
|
- 'ISO-8859-1')
|
|
|
|
- response.write(sio.getvalue())
|
|
|
|
|
|
+ executor_id = request.GET.get('executor_id')
|
|
|
|
+ if not executor_id:
|
|
|
|
+ logger.error("测试人员id不能为空")
|
|
|
|
+ return HttpResponse(status=404, content="测试人员id不能为空")
|
|
|
|
+ cases_info = {}
|
|
|
|
+ cases = software.testcase_set.filter(executor_id=executor_id, delete=False)
|
|
|
|
+ executors = set()
|
|
|
|
+ if cases:
|
|
|
|
+ for case in cases:
|
|
|
|
+ state = '未执行'
|
|
|
|
+ if case.state == 1:
|
|
|
|
+ state = '执行成功'
|
|
|
|
+ elif case.state == 2:
|
|
|
|
+ state = '执行失败'
|
|
|
|
+ cases_info[case.id_in_task] = {
|
|
|
|
+ 'id': case.id_in_task,
|
|
|
|
+ 'version': case.version,
|
|
|
|
+ 'name': case.name,
|
|
|
|
+ 'requisite': case.requisite,
|
|
|
|
+ 'priority': case.priority,
|
|
|
|
+ 'environment': case.environment,
|
|
|
|
+ 'type': case.type,
|
|
|
|
+ 'process': case.process,
|
|
|
|
+ 'expected_result': case.expected_result,
|
|
|
|
+ 'actual_result': case.actual_result,
|
|
|
|
+ 'state': state,
|
|
|
|
+ 'writer': case.writer,
|
|
|
|
+ 'assessor': case.assessor,
|
|
|
|
+ 'executor': case.executor,
|
|
|
|
+ 'remark': case.remark,
|
|
|
|
+ 'execute_time': str(case.update_time)[:10]
|
|
|
|
+ }
|
|
|
|
+ executors.add(case.executor)
|
|
|
|
+
|
|
|
|
+ creators = []
|
|
|
|
+ plans = software.testplan_set.filter(delete=False)
|
|
|
|
+ if plans:
|
|
|
|
+ for plan in plans:
|
|
|
|
+ creators.append(plan.creator.name)
|
|
|
|
+
|
|
|
|
+ version_number = software.version_set.order_by('-create_time')[0].number
|
|
|
|
+
|
|
|
|
+ file_name = '软件测试报告.docx'
|
|
|
|
+ print(str(software.create_time).split(' ')[0])
|
|
|
|
+ document = util_doc.process_doc(software.name, software.type, version_number, str(software.create_time)
|
|
|
|
+ .split(' ')[0], executors, cases_info)
|
|
|
|
+
|
|
|
|
+ response = HttpResponse(content_type='application/octet-stream')
|
|
|
|
+ response['Content-Disposition'] = 'attachment; filename="{0}"'.format(file_name).encode('utf-8', 'ISO-8859-1')
|
|
|
|
+ document.save(response)
|
|
# executor, action, method = get_log(request)
|
|
# executor, action, method = get_log(request)
|
|
# gen_log(action, "测试任务", task.title, method, executor)
|
|
# gen_log(action, "测试任务", task.title, method, executor)
|
|
return response
|
|
return response
|