Commit 15fb7211 authored by 王英豪's avatar 王英豪

no message

parent a92c1e5e
......@@ -4,12 +4,13 @@
# @File : testing_progress_url.py
# @desc:
from django.urls import path
from automated_main.view.testing_progress.personnel_allocation.personnel_allocation_view import PersonnelAllocationView,PersonnelAllocationListView
from automated_main.view.testing_progress.personnel_allocation.personnel_allocation_view import PersonnelAllocationView,PersonnelAllocationListView, dataExportGanttView
urlpatterns = [
path("api/backend/personnel_allocation/", PersonnelAllocationView.as_view()),
path("api/backend/personnel_allocation/<int:pid>/", PersonnelAllocationView.as_view()),
path("api/backend/personnel_allocation/dataExportGantt/", dataExportGanttView.as_view()),
path("api/backend/personnel_allocation_list/", PersonnelAllocationListView.as_view()),
]
\ No newline at end of file
......@@ -13,17 +13,17 @@ class ApiYapiServer:
@staticmethod
def api_yapi_server_data(yapi_id):
data = {"email": "wangyinghao@qike366.com", "password": "123456"}
data = {"email": "yinghao.wang", "password": "wangyinghao123!"}
header = {
"Content-Type": "application/json"
}
# YaPi登录接口
r = requests.post(url="http://yapi.rd.com/api/user/login_by_ldap", json=data, headers=header)
r = requests.post(url="http://yapi.quantgroups.com/api/user/login_by_ldap", json=data, headers=header)
cookie = r.cookies
yapi_api_url = "http://yapi.rd.com/api/interface/get?id=" + str(yapi_id)
yapi_api_url = "http://yapi.quantgroups.com/api/interface/get?id=" + str(yapi_id)
# YaPi接口数据
yapi_api_data = requests.get(url=yapi_api_url, headers=header, cookies=cookie).json()
......@@ -118,7 +118,7 @@ class ApiYapiServer:
if __name__ == '__main__':
sen = ApiYapiServer()
print(sen.api_yapi_server_data(4201))
print(sen.api_yapi_server_data(47240))
# 2646 json
# 20066 from
......@@ -27,11 +27,6 @@ class PersonnelAllocationView(View):
return response_success()
data = json.loads(body)
ENV_PROFILE = os.getenv("ENV")
logger.info('222222222222')
logger.info(ENV_PROFILE)
logger.info('222222222222')
if 'color' in data.keys():
TestingProgress.objects.create(testing_progress_title=data['text'],
start_date=data['start_date'],
......@@ -176,3 +171,86 @@ class PersonnelAllocationListView(View):
pass
return response_success(testing_progress_list)
class dataExportGanttView(View):
def post(self, request, *args, **kwargs):
"""
导出数据
"""
body = request.body
data = json.loads(body)
# 查询时间
date_list_query = []
begin_date_query = datetime.datetime.strptime(data['data_time_personnel'][0], "%Y-%m-%d")
end_date_query = datetime.datetime.strptime(data['data_time_personnel'][1], "%Y-%m-%d")
while begin_date_query <= end_date_query:
date_str = begin_date_query.strftime("%Y-%m-%d")
date_list_query.append(date_str)
begin_date_query += datetime.timedelta(days=1)
testing_progress_data = TestingProgress.objects.all()
testing_progress_list = []
for testing_progress in testing_progress_data:
if testing_progress.group == 1:
render = "split"
testing_progress_dict = {
"text": testing_progress.testing_progress_title,
"id": testing_progress.id,
"render": render,
"parent": testing_progress.parent,
"group": str(testing_progress.group),
"color": testing_progress.type,
"description": testing_progress.description
}
testing_progress_list.append(testing_progress_dict)
else:
render = ""
# 任务的开始时间 转换 年月日时分
dates_start_date = time.strptime(testing_progress.start_date, "%Y-%m-%d %H:%M")
dates_start_date = time.strftime("%Y-%m-%d", dates_start_date)
# 任务的结束时间 年月日时分
dates_end_date = time.strptime(testing_progress.end_date, "%Y-%m-%d %H:%M")
dates_end_date = time.strftime("%Y-%m-%d", dates_end_date)
data_list_task = []
date_start = datetime.datetime.strptime(dates_start_date, '%Y-%m-%d')
date_end = datetime.datetime.strptime(dates_end_date, '%Y-%m-%d')
data_list_task.append(date_start.strftime('%Y-%m-%d'))
while date_start < date_end:
date_start += datetime.timedelta(days=1)
data_list_task.append(date_start.strftime('%Y-%m-%d'))
set_c = set(date_list_query) & set(data_list_task)
list_c = list(set_c)
if len(list_c) > 0:
if testing_progress.parent == "0":
parent = ""
else:
parent = testing_progress.parent
testing_progress_dict = {
"text": testing_progress.testing_progress_title,
"start_date": testing_progress.start_date,
"id": testing_progress.id,
"duration": testing_progress.duration,
"parent": parent,
"type": testing_progress.type,
"end_date": testing_progress.end_date,
"render": render,
"progress": testing_progress.testing_progress,
"group": str(testing_progress.group),
"color": testing_progress.type,
"description": testing_progress.description
}
testing_progress_list.append(testing_progress_dict)
else:
pass
print(testing_progress_list)
return response_success()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment