Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dwsproject
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
dws
dwsproject
Commits
bc0e854f
Commit
bc0e854f
authored
Jan 09, 2025
by
liuyongcheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sdddl_project' of
http://git.rokedata.com/dws/dwsproject
into sdddl_project
parents
5db3e921
ea82a21b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
0 deletions
+189
-0
sdddl_project/controllers/inherit_production_task.py
+189
-0
sdddl_project/controllers/roke_dws_process_design.py
+0
-0
No files found.
sdddl_project/controllers/inherit_production_task.py
0 → 100644
View file @
bc0e854f
import
logging
from
odoo
import
models
,
fields
,
api
,
http
,
SUPERUSER_ID
,
_
from
odoo.addons.roke_workstation_api.controllers.product_task
import
RokeWorkstationProductionTask
_logger
=
logging
.
getLogger
(
__name__
)
class
InheritRokeWorkstationProductionTask
(
RokeWorkstationProductionTask
):
@http.route
(
'/roke/workstation/product_task/machine_get_list'
,
type
=
'json'
,
auth
=
'user'
,
csrf
=
False
,
cors
=
"*"
)
def
product_task_machine_get_list
(
self
):
"""
获取当前用户权限下所有任务的数据
workstation_id: int 工位ID
limit: int 条数
page: int 页数
"""
_self
=
http
.
request
workstation_id
=
_self
.
jsonrequest
.
get
(
"workstation_id"
,
False
)
priority
=
_self
.
jsonrequest
.
get
(
"priority"
,
False
)
customer_id
=
_self
.
jsonrequest
.
get
(
"customer_id"
,
False
)
limit
=
_self
.
jsonrequest
.
get
(
"limit"
,
20
)
page
=
_self
.
jsonrequest
.
get
(
"page"
,
1
)
search_code
=
_self
.
jsonrequest
.
get
(
"search_code"
,
False
)
if
not
workstation_id
:
return
{
"code"
:
1
,
"message"
:
f
"入参错误! “工位ID”为必传数据。"
,
"data"
:
[]}
workstation
=
_self
.
env
[
"roke.work.center"
]
.
search
(
[(
"id"
,
"="
,
workstation_id
)])
if
not
workstation
:
return
{
"code"
:
1
,
"message"
:
"校验错误! 未找到该工位数据。"
,
"data"
:
[]}
user_id
=
_self
.
env
[
'roke.employee'
]
.
search
(
[(
'user_id'
,
'='
,
http
.
request
.
uid
)],
limit
=
1
)
process_ids
=
_self
.
env
[
'roke.process'
]
.
search
(
[(
'workstation_ids'
,
'='
,
workstation_id
)])
# process_list = list(set(process_ids.ids) & set(user_id.process_ids.ids))
process_list
=
process_ids
.
ids
if
not
process_ids
:
return
{
"code"
:
0
,
"message"
:
"获取成功!"
,
"data"
:
[],
"process_ids"
:
[],
"count"
:
0
}
domain
=
[
"|"
,
(
"work_center_id"
,
"="
,
workstation
.
workshop_id
.
id
),
"&"
,
(
"work_center_id"
,
"="
,
False
),
(
"task_id.workshop_id"
,
"="
,
workstation
.
workshop_id
.
id
),
(
"process_id"
,
"in"
,
process_list
),
(
"state"
,
"in"
,
[
"未完工"
,
"暂停"
])
]
if
priority
:
domain
.
append
((
'task_id.priority'
,
'='
,
priority
))
if
customer_id
:
domain
.
append
((
'task_id.customer_id'
,
'='
,
customer_id
))
if
search_code
:
domain
.
append
(
"|"
)
domain
.
append
(
"|"
)
domain
.
append
(
"|"
)
domain
.
append
(
"|"
)
domain
.
append
(
"|"
)
domain
.
append
(
"|"
)
domain
.
append
((
"task_id.code"
,
"ilike"
,
search_code
))
domain
.
append
((
'task_id.customer_id.name'
,
'ilike'
,
search_code
))
domain
.
append
((
"code"
,
"ilike"
,
search_code
))
domain
.
append
((
"task_id.product_id.name"
,
"ilike"
,
search_code
))
domain
.
append
((
"task_id.lot_code"
,
"ilike"
,
search_code
))
domain
.
append
((
"process_id.name"
,
"ilike"
,
search_code
))
domain
.
append
((
"task_id.product_id.specification"
,
"ilike"
,
search_code
))
work_order
=
_self
.
env
[
"roke.work.order"
]
.
search
(
domain
)
sql
=
f
"""
SELECT id, type, create_date
FROM (
{f'''SELECT roke_production_task.id, 'task' as "type", roke_production_task.create_date
FROM roke_production_task LEFT JOIN roke_work_order on roke_work_order.task_id = roke_production_task.id
WHERE roke_work_order.id in ({" , ".join([f"{v}" for v in work_order.ids])})
and roke_production_task.state in ('未完工', '暂停')
group by roke_production_task.id
union all''' if work_order.ids else ""}
SELECT id, 'work' as "type", create_date
FROM roke_work_order
WHERE type in ('返修', '补件')
and process_id in ({" , ".join([f"{v}" for v in process_list])})
and state = '未完工'
and repair_task_id is not null {f''' and code ilike '
%
{search_code}
%
' ''' if search_code else ""}
group by id
) as task_repair_work
ORDER BY create_date desc
LIMIT {limit}
offset {(page - 1) * limit}
"""
_self
.
env
.
cr
.
execute
(
sql
)
results
=
_self
.
env
.
cr
.
dictfetchall
()
count_sql
=
f
"""
SELECT count(id)
FROM (
{f'''SELECT roke_production_task.id
FROM roke_production_task LEFT JOIN roke_work_order on roke_work_order.task_id = roke_production_task.id
WHERE roke_work_order.id in ({" , ".join([f"{v}" for v in work_order.ids])})
and roke_production_task.state in ('未完工', '暂停')
group by roke_production_task.id
union all''' if work_order.ids else ""}
SELECT id
FROM roke_work_order
WHERE type in ('返修', '补件')
and process_id in ({" , ".join([f"{v}" for v in process_list])})
and state = '未完工'
and repair_task_id is not null {f''' and code ilike '
%
{search_code}
%
' ''' if search_code else ""}
group by id
) as task_repair_work
"""
_self
.
env
.
cr
.
execute
(
count_sql
)
task_count
=
_self
.
env
.
cr
.
dictfetchall
()[
0
]
.
get
(
"count"
,
0
)
ids_list
=
[]
task_id_list
=
[]
work_id_list
=
[]
for
v
in
results
:
data_type
=
v
.
get
(
"type"
,
''
)
data_id
=
v
.
get
(
"id"
,
0
)
# 排序后的列表数据,【ID,该条数据类型】(为了作分页)
ids_list
.
append
([
data_id
,
data_type
])
if
data_type
==
'task'
:
task_id_list
.
append
(
data_id
)
if
data_type
==
'work'
:
work_id_list
.
append
(
data_id
)
task_ids
=
_self
.
env
[
"roke.production.task"
]
.
search
(
[(
"id"
,
"in"
,
task_id_list
)])
work_ids
=
_self
.
env
[
"roke.work.order"
]
.
search
(
[(
"id"
,
"in"
,
work_id_list
)])
task_data_dict
=
{}
for
v
in
task_ids
:
current_process
=
''
current_process_num
=
len
(
v
.
work_order_ids
)
for
record
in
v
.
work_order_ids
:
if
record
.
wo_start_state
==
'未开工'
or
record
.
state
in
(
'未完工'
,
'暂停'
):
current_process
=
record
.
process_id
.
name
current_process_num
-=
1
break
else
:
current_process_num
-=
1
continue
task_data_dict
[
str
(
v
.
id
)]
=
{
"id"
:
v
.
id
,
"code"
:
v
.
code
,
"state"
:
v
.
state
,
"partner"
:
{
"id"
:
v
.
customer_id
.
id
or
None
,
"name"
:
v
.
customer_id
.
name
or
""
},
"plan_qty"
:
v
.
plan_qty
or
0
,
"product"
:
{
"id"
:
v
.
product_id
.
id
or
None
,
"name"
:
v
.
product_id
.
name
or
""
},
"priority"
:
v
.
priority
,
"planned_start_time"
:
v
.
plan_start_date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
v
.
plan_start_date
else
""
,
"plan_date"
:
v
.
plan_date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
v
.
plan_date
else
""
,
"specification"
:
v
.
product_id
.
specification
or
""
,
"model"
:
v
.
product_id
.
model
or
""
,
"order_type"
:
"task"
,
"type"
:
""
,
"current_process"
:
current_process
,
"current_process_num"
:
current_process_num
}
work_data_dict
=
{}
for
v
in
work_ids
:
work_data_dict
[
str
(
v
.
id
)]
=
{
"id"
:
v
.
id
,
"code"
:
v
.
code
,
"state"
:
v
.
state
,
"partner"
:
{
"id"
:
v
.
repair_task_id
.
customer_id
.
id
or
None
,
"name"
:
v
.
repair_task_id
.
customer_id
.
name
or
""
},
"plan_qty"
:
v
.
plan_qty
or
0
,
"product"
:
{
"id"
:
v
.
product_id
.
id
or
None
,
"name"
:
v
.
product_id
.
name
or
""
},
"priority"
:
v
.
priority
,
"planned_start_time"
:
v
.
planned_start_time
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
v
.
planned_start_time
else
""
,
"plan_date"
:
v
.
plan_date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
v
.
plan_date
else
""
,
"specification"
:
v
.
product_id
.
specification
or
""
,
"model"
:
v
.
product_id
.
model
or
""
,
"order_type"
:
"work"
,
"type"
:
v
.
type
,
"current_process"
:
v
.
process_id
.
name
,
"current_process_num"
:
len
(
v
.
task_id
.
work_order_ids
.
filtered
(
lambda
wo
:
wo
.
sequence
>
v
.
sequence
))
}
data
=
[]
for
v
in
ids_list
:
l_id
=
v
[
0
]
l_type
=
v
[
1
]
if
l_type
==
"task"
:
task_data
=
task_data_dict
.
get
(
str
(
l_id
),
False
)
if
not
task_data
:
continue
data
.
append
(
task_data
)
if
l_type
==
"work"
:
work_data
=
work_data_dict
.
get
(
str
(
l_id
),
False
)
if
not
work_data
:
continue
data
.
append
(
work_data
)
return
{
"code"
:
0
,
"message"
:
"获取成功!"
,
"data"
:
data
,
"process_ids"
:
process_list
,
"count"
:
task_count
}
\ No newline at end of file
sdddl_project/controllers/
or
ke_dws_process_design.py
→
sdddl_project/controllers/
ro
ke_dws_process_design.py
View file @
bc0e854f
File moved
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