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
8f0037e0
Commit
8f0037e0
authored
May 23, 2025
by
guibin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加获取车间工作时间接口
parent
7fb1f750
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
8 deletions
+49
-8
tht_project/controllers/controllers.py
+37
-0
tht_project/static/src/view/equipment_status.html
+12
-8
No files found.
tht_project/controllers/controllers.py
View file @
8f0037e0
...
@@ -3,10 +3,47 @@ from odoo import http
...
@@ -3,10 +3,47 @@ from odoo import http
from
odoo.http
import
request
from
odoo.http
import
request
from
odoo.addons.roke_mes_three_colour_light.controller.main
import
RokeMesThreeColourLight
from
odoo.addons.roke_mes_three_colour_light.controller.main
import
RokeMesThreeColourLight
import
os
import
os
import
math
from
datetime
import
datetime
,
time
from
jinja2
import
Environment
,
FileSystemLoader
from
jinja2
import
Environment
,
FileSystemLoader
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
templateloader
=
FileSystemLoader
(
searchpath
=
BASE_DIR
+
"/static/src/view"
)
templateloader
=
FileSystemLoader
(
searchpath
=
BASE_DIR
+
"/static/src/view"
)
env
=
Environment
(
loader
=
templateloader
)
env
=
Environment
(
loader
=
templateloader
)
class
ThtProject
(
http
.
Controller
):
@http.route
(
'/tht/get/equipment/working_time'
,
type
=
'json'
,
auth
=
"none"
,
csrf
=
False
,
cors
=
'*'
)
def
get_equipment_working_time
(
self
,
**
kwargs
):
jsonrequest
=
http
.
request
.
jsonrequest
plant_name
=
jsonrequest
.
get
(
"plant_name"
,
False
)
domain
=
[(
"code"
,
"!="
,
False
)]
if
plant_name
:
domain
.
append
((
"plant_id.name"
,
"="
,
plant_name
))
equipment_ids
=
http
.
request
.
env
[
'roke.mes.equipment'
]
.
sudo
()
.
search
(
domain
)
today
=
datetime
.
now
()
start_working_time_list
=
[]
end_working_time_list
=
[]
wait_time_list
=
[]
plant_ids
=
equipment_ids
.
mapped
(
"plant_id"
)
for
plant_id
in
plant_ids
:
config_id
=
http
.
request
.
env
[
'plant.working.time.config'
]
.
sudo
()
.
search
([(
"plant_id"
,
"="
,
plant_id
.
id
)],
limit
=
1
)
for
item
in
equipment_ids
.
filtered
(
lambda
x
:
x
.
plant_id
==
plant_id
):
start_hour
=
math
.
floor
(
config_id
.
start_time
)
start_working_time_list
.
append
({
item
.
code
:
datetime
.
combine
(
today
,
time
(
start_hour
,
int
((
config_id
.
start_time
-
start_hour
)
*
60
)))
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
})
end_hour
=
math
.
floor
(
config_id
.
end_time
)
end_working_time_list
.
append
({
item
.
code
:
datetime
.
combine
(
today
,
time
(
end_hour
,
int
((
config_id
.
end_time
-
end_hour
)
*
60
)))
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
})
wait_time_list
.
append
({
item
.
code
:
config_id
.
wait_time
})
return
{
"state"
:
"success"
,
"msgs"
:
"获取数据成功!"
,
"start_working_time_list"
:
start_working_time_list
,
"end_working_time_list"
:
end_working_time_list
,
"wait_time_list"
:
wait_time_list
}
class
RokeMesThreeColourLightExt
(
RokeMesThreeColourLight
):
class
RokeMesThreeColourLightExt
(
RokeMesThreeColourLight
):
#重写
#重写
@http.route
(
"/roke/three_color_light/device_state_list"
,
type
=
"http"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
@http.route
(
"/roke/three_color_light/device_state_list"
,
type
=
"http"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
...
...
tht_project/static/src/view/equipment_status.html
View file @
8f0037e0
...
@@ -401,19 +401,21 @@
...
@@ -401,19 +401,21 @@
// 发送请求获取计划运行时间
// 发送请求获取计划运行时间
const
response
=
await
axios
({
const
response
=
await
axios
({
method
:
"post"
,
method
:
"post"
,
url
:
this
.
dwsURL
+
"/
roke/workstation/equipment/get_plan
_time"
,
url
:
this
.
dwsURL
+
"/
tht/get/equipment/working
_time"
,
data
:
{},
data
:
{},
headers
:
{
"Content-Type"
:
"application/json"
},
headers
:
{
"Content-Type"
:
"application/json"
},
});
});
// 处理JSON-RPC格式的响应
// 处理JSON-RPC格式的响应
if
(
response
.
data
&&
response
.
data
.
result
&&
response
.
data
.
result
.
code
===
0
)
{
if
(
response
.
data
&&
response
.
data
.
result
&&
response
.
data
.
result
.
state
===
"success"
)
{
// 获取计划运行时间数据
// 获取计划运行时间数据
const
planTimeList
=
response
.
data
.
result
.
data
||
{};
const
start_working_time_list
=
response
.
data
.
result
.
start_working_time_list
||
[];
const
end_working_time_list
=
response
.
data
.
result
.
end_working_time_list
||
[];
const
wait_time_list
=
response
.
data
.
result
.
wait_time_list
||
[];
// 调用设备状态接口
// 调用设备状态接口
await
this
.
getDeviceStateList
(
planTimeL
ist
);
await
this
.
getDeviceStateList
(
start_working_time_list
,
end_working_time_list
,
wait_time_l
ist
);
return
planTimeL
ist
;
return
start_working_time_list
,
end_working_time_list
,
wait_time_l
ist
;
}
else
{
}
else
{
const
errorMsg
=
response
.
data
.
result
const
errorMsg
=
response
.
data
.
result
?
response
.
data
.
result
.
message
?
response
.
data
.
result
.
message
...
@@ -458,16 +460,18 @@
...
@@ -458,16 +460,18 @@
},
},
// 获取设备状态列表
// 获取设备状态列表
async
getDeviceStateList
(
planTimeL
ist
)
{
async
getDeviceStateList
(
start_working_time_list
,
end_working_time_list
,
wait_time_l
ist
)
{
try
{
try
{
// 使用CORS代理
// 使用CORS代理
// 发送请求获取设备状态
// 发送请求获取设备状态
const
response
=
await
axios
({
const
response
=
await
axios
({
method
:
"POST"
,
method
:
"POST"
,
url
:
this
.
baseURL
+
"/public/device_efficiency/device_state_list"
,
url
:
this
.
baseURL
+
"/public/device_efficiency/device_
working_time_
state_list"
,
data
:
{
data
:
{
factory_code
:
this
.
factoryCode
,
factory_code
:
this
.
factoryCode
,
plan_time_list
:
planTimeList
,
start_working_time_list
:
start_working_time_list
,
end_working_time_list
:
end_working_time_list
,
wait_time_list
:
wait_time_list
,
},
},
headers
:
{
headers
:
{
"Content-Type"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
...
...
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