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
76b869d4
Commit
76b869d4
authored
May 23, 2025
by
guibin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取车间工作时间接口修改
parent
79ada6d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
24 deletions
+19
-24
tht_project/controllers/controllers.py
+10
-15
tht_project/static/src/view/equipment_status.html
+9
-9
No files found.
tht_project/controllers/controllers.py
View file @
76b869d4
...
@@ -13,6 +13,7 @@ env = Environment(loader=templateloader)
...
@@ -13,6 +13,7 @@ env = Environment(loader=templateloader)
class
ThtProject
(
http
.
Controller
):
class
ThtProject
(
http
.
Controller
):
@http.route
(
'/tht/get/equipment/working_time'
,
type
=
'json'
,
auth
=
"none"
,
csrf
=
False
,
cors
=
'*'
)
@http.route
(
'/tht/get/equipment/working_time'
,
type
=
'json'
,
auth
=
"none"
,
csrf
=
False
,
cors
=
'*'
)
def
get_equipment_working_time
(
self
,
**
kwargs
):
def
get_equipment_working_time
(
self
,
**
kwargs
):
"""获取车间工作时间"""
jsonrequest
=
http
.
request
.
jsonrequest
jsonrequest
=
http
.
request
.
jsonrequest
plant_name
=
jsonrequest
.
get
(
"plant_name"
,
False
)
plant_name
=
jsonrequest
.
get
(
"plant_name"
,
False
)
domain
=
[(
"code"
,
"!="
,
False
)]
domain
=
[(
"code"
,
"!="
,
False
)]
...
@@ -20,28 +21,22 @@ class ThtProject(http.Controller):
...
@@ -20,28 +21,22 @@ class ThtProject(http.Controller):
domain
.
append
((
"plant_id.name"
,
"="
,
plant_name
))
domain
.
append
((
"plant_id.name"
,
"="
,
plant_name
))
equipment_ids
=
http
.
request
.
env
[
'roke.mes.equipment'
]
.
sudo
()
.
search
(
domain
)
equipment_ids
=
http
.
request
.
env
[
'roke.mes.equipment'
]
.
sudo
()
.
search
(
domain
)
today
=
datetime
.
now
()
today
=
datetime
.
now
()
start_working_time
_list
=
[]
start_working_time
=
{}
end_working_time
_list
=
[]
end_working_time
=
{}
wait_time
_list
=
[]
wait_time
=
{}
plant_ids
=
equipment_ids
.
mapped
(
"plant_id"
)
plant_ids
=
equipment_ids
.
mapped
(
"plant_id"
)
for
plant_id
in
plant_ids
:
for
plant_id
in
plant_ids
:
config_id
=
http
.
request
.
env
[
'plant.working.time.config'
]
.
sudo
()
.
search
([(
"plant_id"
,
"="
,
plant_id
.
id
)],
limit
=
1
)
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
):
for
item
in
equipment_ids
.
filtered
(
lambda
x
:
x
.
plant_id
==
plant_id
):
start_hour
=
math
.
floor
(
config_id
.
start_time
)
start_hour
=
math
.
floor
(
config_id
.
start_time
)
start_working_time_list
.
append
({
start_working_time
[
item
.
code
]
=
datetime
.
combine
(
today
,
time
(
start_hour
,
int
((
config_id
.
start_time
-
start_hour
)
*
60
)))
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
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_hour
=
math
.
floor
(
config_id
.
end_time
)
end_working_time_list
.
append
({
end_working_time
[
item
.
code
]
=
datetime
.
combine
(
today
,
time
(
end_hour
,
int
((
config_id
.
end_time
-
end_hour
)
*
60
)))
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
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
[
item
.
code
]
=
config_id
.
wait_time
})
wait_time_list
.
append
({
item
.
code
:
config_id
.
wait_time
})
return
{
"state"
:
"success"
,
"msgs"
:
"获取数据成功!"
,
return
{
"state"
:
"success"
,
"msgs"
:
"获取数据成功!"
,
"start_working_time
_list"
:
start_working_time_list
,
"start_working_time
"
:
start_working_time
,
"end_working_time
_list"
:
end_working_time_list
,
"end_working_time
"
:
end_working_time
,
"wait_time
_list"
:
wait_time_list
}
"wait_time
"
:
wait_time
}
class
RokeMesThreeColourLightExt
(
RokeMesThreeColourLight
):
class
RokeMesThreeColourLightExt
(
RokeMesThreeColourLight
):
...
...
tht_project/static/src/view/equipment_status.html
View file @
76b869d4
...
@@ -408,14 +408,14 @@
...
@@ -408,14 +408,14 @@
// 处理JSON-RPC格式的响应
// 处理JSON-RPC格式的响应
if
(
response
.
data
&&
response
.
data
.
result
&&
response
.
data
.
result
.
state
===
"success"
)
{
if
(
response
.
data
&&
response
.
data
.
result
&&
response
.
data
.
result
.
state
===
"success"
)
{
// 获取计划运行时间数据
// 获取计划运行时间数据
const
start_working_time
_list
=
response
.
data
.
result
.
start_working_time_list
||
[];
const
start_working_time
=
response
.
data
.
result
.
start_working_time
||
[];
const
end_working_time
_list
=
response
.
data
.
result
.
end_working_time_list
||
[];
const
end_working_time
=
response
.
data
.
result
.
end_working_time
||
[];
const
wait_time
_list
=
response
.
data
.
result
.
wait_time_list
||
[];
const
wait_time
=
response
.
data
.
result
.
wait_time
||
[];
// 调用设备状态接口
// 调用设备状态接口
await
this
.
getDeviceStateList
(
start_working_time
_list
,
end_working_time_list
,
wait_time_list
);
await
this
.
getDeviceStateList
(
start_working_time
,
end_working_time
,
wait_time
);
return
start_working_time
_list
,
end_working_time_list
,
wait_time_list
;
return
start_working_time
,
end_working_time
,
wait_time
;
}
else
{
}
else
{
const
errorMsg
=
response
.
data
.
result
const
errorMsg
=
response
.
data
.
result
?
response
.
data
.
result
.
message
?
response
.
data
.
result
.
message
...
@@ -460,7 +460,7 @@
...
@@ -460,7 +460,7 @@
},
},
// 获取设备状态列表
// 获取设备状态列表
async
getDeviceStateList
(
start_
working_time_list
,
end_working_time_list
,
wait_time_list
)
{
async
getDeviceStateList
(
start_
time
,
end_time
,
wait_time
)
{
try
{
try
{
// 使用CORS代理
// 使用CORS代理
// 发送请求获取设备状态
// 发送请求获取设备状态
...
@@ -469,9 +469,9 @@
...
@@ -469,9 +469,9 @@
url
:
this
.
baseURL
+
"/public/device_efficiency/device_working_time_state_list"
,
url
:
this
.
baseURL
+
"/public/device_efficiency/device_working_time_state_list"
,
data
:
{
data
:
{
factory_code
:
this
.
factoryCode
,
factory_code
:
this
.
factoryCode
,
start_time
:
start_
working_time_list
,
start_time
:
start_
time
,
end_time
:
end_
working_time_list
,
end_time
:
end_
time
,
wait_time
:
wait_time
_list
,
wait_time
:
wait_time
,
},
},
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