新增问题单详情界面
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,8 @@ from django.shortcuts import get_object_or_404
|
||||
from django.db.models.functions import Replace
|
||||
from django.db.models import F, Value
|
||||
from typing import List
|
||||
from faker import Faker
|
||||
from datetime import datetime
|
||||
from django.utils import timezone
|
||||
from utils.chen_response import ChenResponse
|
||||
from utils.chen_crud import multi_delete_case
|
||||
@@ -373,6 +375,24 @@ class CaseController(ControllerBase):
|
||||
@route.post("/case/timeReplace/", url_name='case-time-replace')
|
||||
@transaction.atomic
|
||||
def bulk_replace_time(self, payload: ExetimeReplaceSchema):
|
||||
selected_case_ids = payload.selectRows
|
||||
if not selected_case_ids:
|
||||
return ChenResponse(status=500, code=50999, message='未选择行!', data="")
|
||||
# 随机日期
|
||||
start, end = payload.exetime
|
||||
start_date = datetime.strptime(start, "%Y-%m-%d").date()
|
||||
end_date = datetime.strptime(end, "%Y-%m-%d").date()
|
||||
# 更新的case的id列表
|
||||
updated_cases = []
|
||||
# 替换设计人员
|
||||
case_qs = Case.objects.filter(id__in=payload.selectRows)
|
||||
case_qs.update(exe_time=payload.exetime)
|
||||
faker = Faker()
|
||||
# 逐个更新
|
||||
for case in case_qs:
|
||||
random_date = faker.date_between(start_date=start_date, end_date=end_date)
|
||||
formatted_date = random_date.strftime("%Y-%m-%d")
|
||||
case.exe_time = formatted_date
|
||||
updated_cases.append(case)
|
||||
Case.objects.bulk_update(updated_cases, ['exe_time'])
|
||||
return ChenResponse(status=200, code=200, data=len(updated_cases),
|
||||
message=f"成功更新{len(updated_cases)}个用例执行时间")
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import re
|
||||
from copy import deepcopy
|
||||
from ninja_extra import api_controller, ControllerBase, route
|
||||
from ninja import Query
|
||||
from ninja_jwt.authentication import JWTAuth
|
||||
@@ -209,3 +211,33 @@ class DesignController(ControllerBase):
|
||||
auto_create_renji(user_name, dut_qs, project_obj)
|
||||
return ChenResponse(status=200, message='自动生成人机界面交互测试成功!', data=dut_qs.key)
|
||||
return ChenResponse(status=402, message='您还未录入需求规格说明文档,请录入后再试')
|
||||
|
||||
# 复制design到当前dut下面接口
|
||||
@route.get("/copy_current", url_name='copy-design-current')
|
||||
@transaction.atomic
|
||||
def copy_current(self, dut_id: int, design_id: int):
|
||||
dut_obj = get_object_or_404(Dut, id=dut_id)
|
||||
design_obj = get_object_or_404(Design, id=design_id)
|
||||
# 首先查询该dut下design个数,设置为新增设计需求的key末尾
|
||||
key_index = dut_obj.rsField.count()
|
||||
new_design_obj = deepcopy(design_obj)
|
||||
# 修改新design内容
|
||||
new_design_obj.pk = None
|
||||
new_design_obj.key = "".join([dut_obj.key, "-", str(key_index)])
|
||||
new_design_obj.title = "".join([design_obj.title, "(复制)"])
|
||||
new_design_obj.name = "".join([design_obj.name, "(复制)"])
|
||||
# ident容错,查询是否有拼接的
|
||||
current_ident = "".join([new_design_obj.ident, "1"])
|
||||
project_obj = dut_obj.project
|
||||
exit_ident = project_obj.psField.filter(ident=current_ident).exists()
|
||||
if exit_ident:
|
||||
match = re.search(r'(\d+)$', current_ident)
|
||||
if match:
|
||||
num = int(match.group(1)) + 1
|
||||
current_ident = re.sub(r'\d+$', str(num), current_ident)
|
||||
else:
|
||||
current_ident = current_ident + "1"
|
||||
new_design_obj.ident = current_ident
|
||||
# 最后记得save
|
||||
new_design_obj.save()
|
||||
return ChenResponse(status=200, code=200, message='复制当前设计需求成功', data="")
|
||||
|
||||
@@ -35,19 +35,25 @@ class ProblemController(ControllerBase):
|
||||
def get_problem_list(self, data: ProblemFilterSchema = Query(...)):
|
||||
project_id = data.project_id
|
||||
conditionNoneToBlank(data)
|
||||
case_key = "".join([data.round_id, '-', data.dut_id, '-', data.design_id, '-', data.test_id, '-', data.case_id])
|
||||
# 先查询出对应的case
|
||||
case_obj = Case.objects.filter(project_id=project_id, key=case_key).first()
|
||||
# 然后进行过滤
|
||||
qs = case_obj.caseField.filter(project__id=data.project_id,
|
||||
ident__icontains=data.ident,
|
||||
name__icontains=data.name,
|
||||
status__icontains=data.status,
|
||||
type__icontains=data.type,
|
||||
grade__icontains=data.grade,
|
||||
operation__icontains=data.operation,
|
||||
postPerson__icontains=data.postPerson,
|
||||
).order_by("id")
|
||||
# 组装查询条件
|
||||
query_params = {
|
||||
"project__id":data.project_id,
|
||||
"ident__icontains":data.ident,
|
||||
"name__icontains":data.name,
|
||||
"status__icontains":data.status,
|
||||
"type__icontains":data.type,
|
||||
"grade__icontains":data.grade,
|
||||
"operation__icontains":data.operation,
|
||||
"postPerson__icontains":data.postPerson
|
||||
}
|
||||
# 如果没有多个key传递则是汇总界面
|
||||
if data.dut_id and data.design_id and data.test_id and data.case_id:
|
||||
case_key = "".join(
|
||||
[data.round_id, '-', data.dut_id, '-', data.design_id, '-', data.test_id, '-', data.case_id])
|
||||
query_params['case__key'] = case_key
|
||||
else:
|
||||
query_params['case__round__key'] = data.round_id
|
||||
qs = Problem.objects.filter(**query_params).order_by("id")
|
||||
|
||||
# 遍历通过代码不通过ORM查询闭环方式-巧妙使用numpy中array对象的in方法来判断
|
||||
closeMethod1 = self.context.request.GET.get("closeMethod[0]")
|
||||
@@ -73,9 +79,7 @@ class ProblemController(ControllerBase):
|
||||
@paginate(MyPagination)
|
||||
def get_all_problems(self, round_key: Optional[str] = False, data: ProblemFilterWithHangSchema = Query(...)):
|
||||
project_id = data.project_id
|
||||
for attr, value in data.__dict__.items():
|
||||
if getattr(data, attr) is None:
|
||||
setattr(data, attr, '')
|
||||
conditionNoneToBlank(data)
|
||||
# 先查询当前项目
|
||||
qs = Problem.objects.filter(project__id=data.project_id,
|
||||
ident__icontains=data.ident,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -167,4 +167,4 @@ class PersonReplaceSchema(Schema):
|
||||
# 时间替换Schema
|
||||
class ExetimeReplaceSchema(Schema):
|
||||
selectRows: List[int] = None
|
||||
exetime: str
|
||||
exetime: List[str]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from pydantic import AliasChoices
|
||||
|
||||
from apps.project.models import Problem
|
||||
from ninja import Field, Schema, ModelSchema
|
||||
from typing import List, Optional
|
||||
@@ -59,7 +61,7 @@ class ProblemCreateOutSchema(ModelSchema):
|
||||
|
||||
# 更新,新增schema
|
||||
class ProblemCreateInputSchema(Schema):
|
||||
project_id: int = Field(..., alias="projectId")
|
||||
project_id: int = Field(..., validation_alias=AliasChoices('project_id', 'projectId'))
|
||||
round_key: str = Field(None, alias="round")
|
||||
dut_key: str = Field(None, alias="dut")
|
||||
design_key: str = Field(None, alias="designDemand")
|
||||
|
||||
Reference in New Issue
Block a user