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
95703c75
Commit
95703c75
authored
Jul 05, 2020
by
李景熙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加查找我的任务列表功能
parent
18ba6e9a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
11 deletions
+118
-11
Relation.py
DAPlatform/Dao/Relation.py
+12
-2
Slice.py
DAPlatform/Dao/Slice.py
+10
-0
Task.py
DAPlatform/Dao/Task.py
+83
-8
task.py
DAPlatform/views/task.py
+13
-1
No files found.
DAPlatform/Dao/Relation.py
View file @
95703c75
...
@@ -41,7 +41,17 @@ def create_relation(slice_id, user_id, data_id):
...
@@ -41,7 +41,17 @@ def create_relation(slice_id, user_id, data_id):
return
Result
(
1
,
"create success"
,
{})
return
Result
(
1
,
"create success"
,
{})
def
find_slice_by_executor
(
user_id
):
try
:
slice_list
=
Relation
.
select
(
Relation
.
slice_id
)
.
where
(
Relation
.
user_id
==
user_id
)
except
:
return
False
else
:
return
slice_list
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
Relation
.
drop_table
()
# Relation.drop_table()
Relation
.
create_table
()
# Relation.create_table()
print
(
Relation
.
select
(
Relation
.
slice_id
)
.
where
(
Relation
.
user_id
==
1
)[
0
]
.
slice_id
)
# create_relation(3, 1, 2)
# create_relation(3, 1, 2)
DAPlatform/Dao/Slice.py
View file @
95703c75
...
@@ -168,6 +168,16 @@ def find_task_by_slice(slice_id):
...
@@ -168,6 +168,16 @@ def find_task_by_slice(slice_id):
return
s
.
task_id
return
s
.
task_id
# 通过一个sliceid数组查找taskid
def
find_task_by_slicelist
(
slice_list
):
try
:
task_list
=
Slice
.
select
(
Slice
.
task_id
)
.
where
(
Slice
.
slice_id
<<
slice_list
)
except
:
return
False
else
:
return
task_list
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
Slice
.
drop_table
()
Slice
.
drop_table
()
Slice
.
create_table
()
Slice
.
create_table
()
DAPlatform/Dao/Task.py
View file @
95703c75
from
peewee
import
*
from
peewee
import
*
import
datetime
import
datetime
import
math
import
math
from
Dao
import
User
from
Dao
import
User
,
Relation
,
Slice
from
Dao.model
import
mysql
from
Dao.model
import
mysql
...
@@ -42,7 +42,7 @@ def create_task(publish_id, task_name):
...
@@ -42,7 +42,7 @@ def create_task(publish_id, task_name):
return
Result
(
1
,
"create success"
,
task
.
task_id
,
0
)
return
Result
(
1
,
"create success"
,
task
.
task_id
,
0
)
# 根据任务名称查找任务
# 根据任务名称查找任务
(任务大厅搜索功能)
def
find_task_by_name
(
task_name
,
start
,
num
):
def
find_task_by_name
(
task_name
,
start
,
num
):
try
:
try
:
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
.
where
(
Task
.
task_name
.
contains
(
task_name
))
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
.
where
(
Task
.
task_name
.
contains
(
task_name
))
...
@@ -65,7 +65,7 @@ def find_task_by_name(task_name, start, num):
...
@@ -65,7 +65,7 @@ def find_task_by_name(task_name, start, num):
return
Result
(
1
,
"find success"
,
list
,
math
.
ceil
(
len
(
find
)
/
num
))
return
Result
(
1
,
"find success"
,
list
,
math
.
ceil
(
len
(
find
)
/
num
))
# 查找所有任务
# 查找所有任务
(用于任务大厅界面)
def
find_task
(
start
,
num
):
def
find_task
(
start
,
num
):
try
:
try
:
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
...
@@ -88,10 +88,85 @@ def find_task(start, num):
...
@@ -88,10 +88,85 @@ def find_task(start, num):
return
Result
(
1
,
"find success"
,
list
,
math
.
ceil
(
len
(
find
)
/
num
))
return
Result
(
1
,
"find success"
,
list
,
math
.
ceil
(
len
(
find
)
/
num
))
# 查找与该发布者相关的任务
# 查找与该发布者相关的任务
(用于我的发布界面,可对任务进行修改删除)
def
find_task_by_creator
(
creator
,
start
,
num
):
def
find_task_by_creator
(
creator
,
start
,
num
):
try
:
try
:
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
.
where
(
Task
.
publish_id
==
creator
)
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
.
where
(
Task
.
publish_id
==
creator
,
Task
.
task_state
==
0
)
index
=
0
list
=
[]
while
index
<
len
(
find
)
and
index
<
num
:
user
=
User
.
get_username
(
find
[
index
+
start
]
.
publish_id
)
list
.
append
(
{
'id'
:
find
[
index
+
start
]
.
task_id
,
'creator'
:
user
,
'name'
:
find
[
index
+
start
]
.
task_name
,
'date'
:
find
[
index
+
start
]
.
publish_time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
}
)
index
+=
1
except
:
return
Result
(
0
,
"find failed"
,
{},
0
)
else
:
return
Result
(
1
,
"find success"
,
list
,
math
.
ceil
(
len
(
find
)
/
num
))
# 寻找发布者发布的需要审核的任务
def
find_task_check
(
creator
,
start
,
num
):
try
:
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
.
where
(
Task
.
publish_id
==
creator
,
Task
.
task_state
==
2
)
index
=
0
list
=
[]
while
index
<
len
(
find
)
and
index
<
num
:
user
=
User
.
get_username
(
find
[
index
+
start
]
.
publish_id
)
list
.
append
(
{
'id'
:
find
[
index
+
start
]
.
task_id
,
'creator'
:
user
,
'name'
:
find
[
index
+
start
]
.
task_name
,
'date'
:
find
[
index
+
start
]
.
publish_time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
}
)
index
+=
1
except
:
return
Result
(
0
,
"find failed"
,
{},
0
)
else
:
return
Result
(
1
,
"find success"
,
list
,
math
.
ceil
(
len
(
find
)
/
num
))
# 寻找已完成任务
def
find_task_completed
(
executor
,
start
,
num
):
try
:
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
.
where
(
Task
.
task_state
==
3
)
index
=
0
list
=
[]
while
index
<
len
(
find
)
and
index
<
num
:
user
=
User
.
get_username
(
find
[
index
+
start
]
.
publish_id
)
list
.
append
(
{
'id'
:
find
[
index
+
start
]
.
task_id
,
'creator'
:
user
,
'name'
:
find
[
index
+
start
]
.
task_name
,
'date'
:
find
[
index
+
start
]
.
publish_time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
}
)
index
+=
1
except
:
return
Result
(
0
,
"find failed"
,
{},
0
)
else
:
return
Result
(
1
,
"find success"
,
list
,
math
.
ceil
(
len
(
find
)
/
num
))
# 寻找标注者选择的任务
def
find_task_my_task
(
executor
,
start
,
num
):
try
:
slice_list
=
Relation
.
find_slice_by_executor
(
executor
)
task_list
=
Slice
.
find_task_by_slicelist
(
slice_list
)
find
=
Task
.
select
(
Task
.
task_id
,
Task
.
task_name
,
Task
.
publish_id
,
Task
.
publish_time
)
.
where
(
Task
.
task_id
<<
task_list
)
index
=
0
index
=
0
list
=
[]
list
=
[]
while
index
<
len
(
find
)
and
index
<
num
:
while
index
<
len
(
find
)
and
index
<
num
:
...
@@ -166,6 +241,6 @@ def set_state(task_id, state):
...
@@ -166,6 +241,6 @@ def set_state(task_id, state):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# delete_task(10
)
find_task_my_task
(
1
,
1
,
1
)
Task
.
drop_table
()
#
Task.drop_table()
Task
.
create_table
()
#
Task.create_table()
DAPlatform/views/task.py
View file @
95703c75
...
@@ -20,7 +20,19 @@ def get_tasks():
...
@@ -20,7 +20,19 @@ def get_tasks():
if
keyword
:
if
keyword
:
ret
=
Task
.
find_task_by_name
(
keyword
,
pagesize
*
(
currentpage
-
1
),
pagesize
)
ret
=
Task
.
find_task_by_name
(
keyword
,
pagesize
*
(
currentpage
-
1
),
pagesize
)
elif
creator
:
elif
creator
:
ret
=
Task
.
find_task_by_creator
(
creator
,
pagesize
*
(
currentpage
-
1
),
pagesize
)
if
state
:
ret
=
Task
.
find_task_check
(
creator
,
pagesize
*
(
currentpage
-
1
),
pagesize
)
print
(
"checking"
)
else
:
ret
=
Task
.
find_task_by_creator
(
creator
,
pagesize
*
(
currentpage
-
1
),
pagesize
)
print
(
"wodefabu"
)
elif
executor
:
if
state
:
ret
=
Task
.
find_task_completed
(
executor
,
pagesize
*
(
currentpage
-
1
),
pagesize
)
print
(
"completed"
)
else
:
ret
=
Task
.
find_task_my_task
(
executor
,
pagesize
*
(
currentpage
-
1
),
pagesize
)
print
(
"woderenwu"
)
else
:
else
:
ret
=
Task
.
find_task
(
pagesize
*
(
currentpage
-
1
),
pagesize
)
ret
=
Task
.
find_task
(
pagesize
*
(
currentpage
-
1
),
pagesize
)
res
=
{
res
=
{
...
...
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