Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DA-Platform
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
文档服务地址:
http://47.92.0.57:3000/
周报索引地址:
http://47.92.0.57:3000/s/NruNXRYmV
Open sidebar
Berlin
DA-Platform
Commits
f43bf59a
Commit
f43bf59a
authored
Jun 26, 2020
by
李景熙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加后端发布任务时数据库中文件相关信息的修改
parent
a0a1bc40
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
7 deletions
+37
-7
Data.py
DAPlatform/Dao/Data.py
+6
-2
Slice.py
DAPlatform/Dao/Slice.py
+12
-0
task.py
DAPlatform/views/task.py
+19
-5
No files found.
DAPlatform/Dao/Data.py
View file @
f43bf59a
from
peewee
import
*
from
peewee
import
*
from
Dao.model
import
mysql
from
Dao.model
import
mysql
from
Dao
import
Slice
class
Result
:
class
Result
:
...
@@ -16,6 +17,7 @@ class Result:
...
@@ -16,6 +17,7 @@ class Result:
class
Data
(
Model
):
class
Data
(
Model
):
data_id
=
AutoField
(
primary_key
=
True
,
unique
=
True
)
data_id
=
AutoField
(
primary_key
=
True
,
unique
=
True
)
slice_id
=
IntegerField
(
null
=
False
)
slice_id
=
IntegerField
(
null
=
False
)
name
=
CharField
(
null
=
False
,
max_length
=
30
)
url
=
CharField
(
null
=
False
,
unique
=
True
)
url
=
CharField
(
null
=
False
,
unique
=
True
)
class
Meta
:
class
Meta
:
...
@@ -23,9 +25,10 @@ class Data(Model):
...
@@ -23,9 +25,10 @@ class Data(Model):
# 向数据库中添加原始数据
# 向数据库中添加原始数据
def
create_data
(
slice_id
,
url
):
def
create_data
(
slice_id
,
name
,
url
):
try
:
try
:
data
=
Data
(
slice_id
=
slice_id
,
url
=
url
)
Slice
.
add_file
(
slice_id
)
data
=
Data
(
slice_id
=
slice_id
,
name
=
name
,
url
=
url
)
data
.
save
()
data
.
save
()
except
Exception
:
except
Exception
:
return
Result
(
0
,
"create failed"
,
{})
return
Result
(
0
,
"create failed"
,
{})
...
@@ -44,4 +47,5 @@ def find_data(id):
...
@@ -44,4 +47,5 @@ def find_data(id):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
Data
.
drop_table
()
Data
.
create_table
()
Data
.
create_table
()
DAPlatform/Dao/Slice.py
View file @
f43bf59a
...
@@ -103,6 +103,18 @@ def find_slice_by_task(task_id):
...
@@ -103,6 +103,18 @@ def find_slice_by_task(task_id):
return
Result
(
1
,
"find success"
,
list
)
return
Result
(
1
,
"find success"
,
list
)
# 添加文件
def
add_file
(
slice_id
):
try
:
s
=
Slice
.
get
(
Slice
.
slice_id
==
slice_id
)
except
:
return
False
else
:
s
.
document_number
+=
1
s
.
save
()
return
True
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# create_text_slice(1,1)
# create_text_slice(1,1)
# create_pic_slice(1, "标注坐标(30,100)")
# create_pic_slice(1, "标注坐标(30,100)")
...
...
DAPlatform/views/task.py
View file @
f43bf59a
import
json
import
json
from
flask
import
Blueprint
from
flask
import
Blueprint
from
flask
import
request
from
flask
import
request
from
Dao
import
Task
,
Slice
from
Dao
import
Task
,
Slice
,
Data
task
=
Blueprint
(
"task"
,
__name__
,
url_prefix
=
"/api/task"
)
task
=
Blueprint
(
"task"
,
__name__
,
url_prefix
=
"/api/task"
)
...
@@ -42,16 +42,30 @@ def create_task():
...
@@ -42,16 +42,30 @@ def create_task():
i
=
0
i
=
0
print
(
data
)
print
(
data
)
while
i
<
len
(
data
[
'task'
][
'domains'
]):
while
i
<
len
(
data
[
'task'
][
'domains'
]):
# 创建分片具体内容还有问题,待修复
s
=
Slice
.
create_text_slice
(
tid
,
data
[
'task'
][
'domains'
][
i
][
'piecesOptions'
])
Slice
.
create_text_slice
(
tid
,
data
[
'task'
][
'domains'
][
i
][
'piecesOptions'
])
j
=
0
while
j
<
len
(
data
[
'task'
][
'domains'
][
i
][
'fileName'
]):
Data
.
create_data
(
s
.
data
,
data
[
'task'
][
'domains'
][
i
][
'fileName'
][
j
][
'name'
],
data
[
'task'
][
'domains'
][
i
][
'fileName'
][
j
][
'url'
])
j
+=
1
i
+=
1
i
+=
1
i
=
0
i
=
0
while
i
<
len
(
data
[
'task'
][
'pictureDomains'
]):
while
i
<
len
(
data
[
'task'
][
'pictureDomains'
]):
Slice
.
create_pic_slice
(
tid
,
data
[
'task'
][
'pictureDomains'
][
i
][
'textarea'
])
s
=
Slice
.
create_pic_slice
(
tid
,
data
[
'task'
][
'pictureDomains'
][
i
][
'textarea'
])
j
=
0
while
j
<
len
(
data
[
'task'
][
'pictureDomains'
][
i
][
'fileName'
]):
Data
.
create_data
(
s
.
data
,
data
[
'task'
][
'pictureDomains'
][
i
][
'fileName'
][
j
][
'name'
],
data
[
'task'
][
'pictureDomains'
][
i
][
'fileName'
][
j
][
'url'
])
j
+=
1
i
+=
1
i
+=
1
i
=
0
i
=
0
while
i
<
len
(
data
[
'task'
][
'layerDomains'
]):
while
i
<
len
(
data
[
'task'
][
'layerDomains'
]):
Slice
.
create_layer_slice
(
tid
,
data
[
'task'
][
'layerDomains'
][
i
][
'textarea'
])
s
=
Slice
.
create_layer_slice
(
tid
,
data
[
'task'
][
'layerDomains'
][
i
][
'textarea'
])
j
=
0
while
j
<
len
(
data
[
'task'
][
'layerDomains'
][
i
][
'fileName'
]):
Data
.
create_data
(
s
.
data
,
data
[
'task'
][
'layerDomains'
][
i
][
'fileName'
][
j
][
'name'
],
data
[
'task'
][
'layerDomains'
][
i
][
'fileName'
][
j
][
'url'
])
j
+=
1
i
+=
1
i
+=
1
res
=
{
res
=
{
'code'
:
ret
.
code
,
'code'
:
ret
.
code
,
...
...
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