Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mancheng
Commits
aacfe3b9
Commit
aacfe3b9
authored
Apr 01, 2024
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
554851e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
1 deletions
+68
-1
apps/import_project/view.py
+68
-1
No files found.
apps/import_project/view.py
View file @
aacfe3b9
import
json
import
json
import
xlwt
from
flask
import
current_app
,
jsonify
,
request
from
flask
import
current_app
,
jsonify
,
request
from
apps.models
import
*
from
apps.models
import
*
...
@@ -427,4 +428,69 @@ def list():
...
@@ -427,4 +428,69 @@ def list():
# 导出数据
# 导出数据
@api_import.route
(
"/keyproject/keyproject/export"
,
methods
=
[
"POST"
])
@api_import.route
(
"/keyproject/keyproject/export"
,
methods
=
[
"POST"
])
def
export
():
def
export
():
pass
req_dic
=
request
.
get_json
()
token
=
request
.
headers
[
'token'
]
# path = './apps/statics/project_file/'
# pro_path = 'http://39.100.39.50:5050/statics/project_file/' # 项目路径
path
=
'/root/code/dist_mancheng/aaa_statics/project_file/'
pro_path
=
'https://mancheng.industrychain.online'
+
'/aaa_statics/project_file/'
# 项目路径
target_data_list
=
[]
project_obj_li
=
TKeyproject
.
query
.
all
()
for
project_obj
in
project_obj_li
:
try
:
data_list
=
[
project_obj
.
project_name
,
project_obj
.
project_leader
,
project_obj
.
leading_department
,
project_obj
.
project_introduce
,
project_obj
.
project_progress
,
project_obj
.
clogging_point
,
project_obj
.
advance_requirement
,
project_obj
.
responsible_department
,
project_obj
.
deadline_completion
,
project_obj
.
investment_entity
,
project_obj
.
total_money
,
project_obj
.
floor_space
,
project_obj
.
construction_address
,
project_obj
.
policy_statement
,
project_obj
.
investment_commitment
,
project_obj
.
project_status
,
project_obj
.
project_day
,
project_obj
.
county
]
target_data_list
.
append
(
data_list
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库查询错误!"
)
head_list
=
''
sheet
=
''
try
:
sheet_name_titles
=
{
"sheet1"
:
[
"项目名称"
,
"包联领导"
,
"牵头部门"
,
"项目介绍"
,
"项目进展"
,
"当前堵点"
,
"推进要求"
,
"责任部门"
,
"完成期限"
,
"投资主体"
,
"总投资"
,
"占地面积(亩)"
,
"建设地址"
,
"政策述求"
,
"投资承诺"
,
"项目状态"
,
"项目用时"
,
"所属区县"
]}
excel
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
# 写入表头
for
i
in
range
(
len
(
sheet_name_titles
)):
for
k
,
v
in
sheet_name_titles
.
items
():
sheet_name
=
k
sheet
=
excel
.
add_sheet
(
sheet_name
)
head_list
=
v
# print(head_list)
for
j
in
range
(
len
(
head_list
)):
sheet
.
write
(
0
,
j
,
head_list
[
j
])
# 写入数据,从第二行(i+1)
rows
=
len
(
target_data_list
)
cols
=
len
(
head_list
)
for
i
in
range
(
rows
):
for
j
in
range
(
cols
):
sheet
.
write
(
i
+
1
,
j
,
target_data_list
[
i
][
j
])
file_name
=
"重点项目.xlsx"
excel
.
save
(
path
+
file_name
)
record_log
(
token
,
"导出了项目台账"
)
return
jsonify
(
code
=
RET
.
OK
,
url
=
pro_path
+
file_name
,
msg
=
"导出/下载成功!"
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"批量导出操作失败!"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment