Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
oee-services
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harshavardhan.c
oee-services
Commits
1dd752e0
Commit
1dd752e0
authored
Jun 06, 2022
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
calculating the downtime based on UOM Type.
parent
289577a1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
live_dashboard.py
live_dashboard.py
+10
-6
scripts/services/ui_services.py
scripts/services/ui_services.py
+3
-1
scripts/utils/common_utils.py
scripts/utils/common_utils.py
+3
-2
No files found.
live_dashboard.py
View file @
1dd752e0
...
@@ -33,15 +33,16 @@ class MachineOEECalculator:
...
@@ -33,15 +33,16 @@ class MachineOEECalculator:
self
.
data_push
=
DataPush
()
self
.
data_push
=
DataPush
()
def
calculate_machine_oee
(
self
,
request_data
:
MachineOEERequest
):
def
calculate_machine_oee
(
self
,
request_data
:
MachineOEERequest
):
try
:
try
:
hierarchy_dict
=
self
.
common_handler
.
get_valid_oee_monitoring_hierarchy
(
project_id
=
request_data
.
project_id
)
hierarchy_dict
=
self
.
common_handler
.
get_valid_oee_monitoring_hierarchy
(
project_id
=
request_data
.
project_id
)
now
=
datetime
.
today
()
-
timedelta
(
days
=
3
)
now
=
datetime
.
today
()
-
timedelta
(
days
=
1
)
oee_start_time
=
datetime
.
strptime
(
request_data
.
monitor_time
,
'
%
H:
%
M'
)
.
replace
(
year
=
now
.
year
,
oee_start_time
=
datetime
.
strptime
(
request_data
.
monitor_time
,
'
%
H:
%
M'
)
.
replace
(
year
=
now
.
year
,
month
=
now
.
month
,
month
=
now
.
month
,
day
=
now
.
day
)
.
strftime
(
day
=
now
.
day
)
.
strftime
(
CommonConstants
.
USER_META_TIME_FORMAT
)
CommonConstants
.
USER_META_TIME_FORMAT
)
oee_end_time
=
datetime
.
now
()
.
astimezone
(
tz
=
pytz
.
timezone
(
request_data
.
tz
))
.
strftime
(
CommonConstants
.
USER_META_TIME_FORMAT
)
curr_end_time
=
datetime
.
now
()
.
astimezone
(
tz
=
pytz
.
timezone
(
request_data
.
tz
))
curr_timestamp
=
int
(
curr_end_time
.
timestamp
())
*
1000
oee_end_time
=
curr_end_time
.
strftime
(
CommonConstants
.
USER_META_TIME_FORMAT
)
for
k
,
v
in
hierarchy_dict
.
items
():
for
k
,
v
in
hierarchy_dict
.
items
():
site_id
=
k
.
split
(
"$"
)[
0
]
site_id
=
k
.
split
(
"$"
)[
0
]
if
not
v
.
get
(
TagCategoryConstants
.
OEE_CYCLE_DESIGN_CATEGORY
):
if
not
v
.
get
(
TagCategoryConstants
.
OEE_CYCLE_DESIGN_CATEGORY
):
...
@@ -52,8 +53,9 @@ class MachineOEECalculator:
...
@@ -52,8 +53,9 @@ class MachineOEECalculator:
if
isinstance
(
cycle_time
,
bool
)
and
not
cycle_time
:
if
isinstance
(
cycle_time
,
bool
)
and
not
cycle_time
:
logger
.
debug
(
f
"OEE Cycle Design parameter details not found for selected hierarchy"
)
logger
.
debug
(
f
"OEE Cycle Design parameter details not found for selected hierarchy"
)
continue
continue
cal_type
=
self
.
common_util
.
get_uom_type
(
uom_type
=
os
.
environ
.
get
(
"DEFAULT_UOM_TYPE"
,
default
=
"mins"
))
downtime
=
self
.
common_util
.
get_downtime_details_by_hierarchy
(
downtime
=
self
.
common_util
.
get_downtime_details_by_hierarchy
(
hierarchy
=
k
,
project_id
=
request_data
.
project_id
)
hierarchy
=
k
,
project_id
=
request_data
.
project_id
,
uom_type
=
cal_type
)
input_data
=
OEEDataInsertRequest
(
prod_start_time
=
oee_start_time
,
input_data
=
OEEDataInsertRequest
(
prod_start_time
=
oee_start_time
,
prod_end_time
=
oee_end_time
,
downtime
=
downtime
,
prod_end_time
=
oee_end_time
,
downtime
=
downtime
,
hierarchy
=
k
,
cycle_time
=
cycle_time
,
hierarchy
=
k
,
cycle_time
=
cycle_time
,
...
@@ -81,7 +83,7 @@ class MachineOEECalculator:
...
@@ -81,7 +83,7 @@ class MachineOEECalculator:
"gw_id"
:
""
,
"gw_id"
:
""
,
"pd_id"
:
""
,
"pd_id"
:
""
,
"p_id"
:
request_data
.
project_id
,
"p_id"
:
request_data
.
project_id
,
"timestamp"
:
int
(
time
.
time
()
*
1000
)
,
"timestamp"
:
curr_timestamp
,
"msg_id"
:
1
,
"msg_id"
:
1
,
"retain_flag"
:
False
"retain_flag"
:
False
}
}
...
@@ -102,4 +104,6 @@ if __name__ == '__main__':
...
@@ -102,4 +104,6 @@ if __name__ == '__main__':
MachineOEECalculator
()
.
calculate_machine_oee
(
MachineOEECalculator
()
.
calculate_machine_oee
(
request_data
=
MachineOEERequest
(
project_id
=
project
,
monitor_time
=
"00:00"
,
request_data
=
MachineOEERequest
(
project_id
=
project
,
monitor_time
=
"00:00"
,
tz
=
project_dict
.
get
(
project
,
"Asia/Kolkata"
)))
tz
=
project_dict
.
get
(
project
,
"Asia/Kolkata"
)))
time
.
sleep
(
10
)
sleep_time_in_mins
=
int
(
os
.
environ
.
get
(
"AUTOMATION_SLEEP_TIME_IN_MINS"
,
default
=
1
))
sleep_time_in_seconds
=
sleep_time_in_mins
*
60
time
.
sleep
(
sleep_time_in_seconds
)
scripts/services/ui_services.py
View file @
1dd752e0
...
@@ -7,7 +7,7 @@ from scripts.constants import Endpoints, ResponseCodes
...
@@ -7,7 +7,7 @@ from scripts.constants import Endpoints, ResponseCodes
from
scripts.core.handlers.api_handler
import
APIHandler
from
scripts.core.handlers.api_handler
import
APIHandler
from
scripts.core.handlers.layout_handler
import
LayoutHandler
from
scripts.core.handlers.layout_handler
import
LayoutHandler
from
scripts.db.psql.databases
import
get_db
from
scripts.db.psql.databases
import
get_db
from
scripts.errors
import
ILensError
from
scripts.errors
import
ILensError
,
DataNotFound
from
scripts.logging
import
logger
from
scripts.logging
import
logger
from
scripts.schemas.batch_oee
import
BatchesGet
,
ChartRequest
from
scripts.schemas.batch_oee
import
BatchesGet
,
ChartRequest
from
scripts.schemas.layout
import
GetLayoutRequest
,
SaveLayoutRequest
from
scripts.schemas.layout
import
GetLayoutRequest
,
SaveLayoutRequest
...
@@ -47,6 +47,8 @@ async def get_chart_data(request_data: ChartRequest, db: Session = Depends(get_d
...
@@ -47,6 +47,8 @@ async def get_chart_data(request_data: ChartRequest, db: Session = Depends(get_d
status
=
ResponseCodes
.
SUCCESS
,
status
=
ResponseCodes
.
SUCCESS
,
message
=
"Chart data fetched successfully"
,
message
=
"Chart data fetched successfully"
,
)
)
except
DataNotFound
:
return
DefaultResponse
(
message
=
"Data not Found for selected filters"
,
status
=
"info"
)
except
ILensError
as
e
:
except
ILensError
as
e
:
return
DefaultResponse
(
message
=
e
.
args
[
0
],
status
=
"info"
)
return
DefaultResponse
(
message
=
e
.
args
[
0
],
status
=
"info"
)
except
Exception
as
e
:
except
Exception
as
e
:
...
...
scripts/utils/common_utils.py
View file @
1dd752e0
...
@@ -44,14 +44,15 @@ class CommonUtils:
...
@@ -44,14 +44,15 @@ class CommonUtils:
logger
.
exception
(
f
"Exception in getting data: {e}"
)
logger
.
exception
(
f
"Exception in getting data: {e}"
)
raise
raise
def
get_downtime_details_by_hierarchy
(
self
,
hierarchy
,
project_id
,
user_id
=
None
):
def
get_downtime_details_by_hierarchy
(
self
,
hierarchy
,
project_id
,
user_id
=
None
,
uom_type
=
"minutes"
):
connection_obj
=
ILensRequest
(
url
=
PathToServices
.
downtime_proxy
,
connection_obj
=
ILensRequest
(
url
=
PathToServices
.
downtime_proxy
,
project_id
=
project_id
)
project_id
=
project_id
)
try
:
try
:
cookies
=
{
'login-token'
:
self
.
create_token
(
user_id
=
user_id
),
"user_id"
:
user_id
}
cookies
=
{
'login-token'
:
self
.
create_token
(
user_id
=
user_id
),
"user_id"
:
user_id
}
downtime_response
=
connection_obj
.
post
(
path
=
EndpointConstants
.
hierarchy_downtime
,
downtime_response
=
connection_obj
.
post
(
path
=
EndpointConstants
.
hierarchy_downtime
,
json
=
{
"project_id"
:
project_id
,
json
=
{
"project_id"
:
project_id
,
"hierarchy"
:
hierarchy
})
"hierarchy"
:
hierarchy
,
"display_type"
:
uom_type
},
cookies
=
cookies
)
response
=
downtime_response
.
json
()
response
=
downtime_response
.
json
()
return
response
.
get
(
"data"
,
0
)
return
response
.
get
(
"data"
,
0
)
except
AuthenticationError
:
except
AuthenticationError
:
...
...
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