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
4121d04d
Commit
4121d04d
authored
Jun 02, 2022
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetching the timezone info from project collection while calculating the oee for equipments/
parent
fae9999e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
126 additions
and
11 deletions
+126
-11
live_dashboard.py
live_dashboard.py
+9
-1
scripts/constants/__init__.py
scripts/constants/__init__.py
+10
-0
scripts/core/handlers/common_handler.py
scripts/core/handlers/common_handler.py
+1
-0
scripts/core/handlers/oee_handlers.py
scripts/core/handlers/oee_handlers.py
+1
-10
scripts/db/mongo/ilens_configuration/aggregations/customer_projects.py
...ngo/ilens_configuration/aggregations/customer_projects.py
+15
-0
scripts/db/mongo/ilens_configuration/collections/customer_projects.py
...ongo/ilens_configuration/collections/customer_projects.py
+90
-0
No files found.
live_dashboard.py
View file @
4121d04d
...
...
@@ -7,14 +7,20 @@ import time
from
datetime
import
datetime
,
timedelta
from
scripts.constants
import
CommonConstants
,
TagCategoryConstants
from
scripts.constants.db_connections
import
mongo_client
from
scripts.core.engine.oee_calculator
import
OEEEngine
from
scripts.core.handlers.batch_oee_calc_handler
import
CalculateBatchOEEHandler
from
scripts.core.handlers.common_handler
import
CommonHandler
from
scripts.db.mongo.ilens_configuration.aggregations.customer_projects
import
ProjectAggregate
from
scripts.db.mongo.ilens_configuration.collections.customer_projects
import
CustomerProjects
from
scripts.logging
import
logger
from
scripts.schemas.batch_oee
import
MachineOEERequest
,
BatchOEEData
,
OEEDataInsertRequest
,
OEEDataSaveRequest
from
scripts.utils.common_utils
import
CommonUtils
from
scripts.utils.kafka_util
import
DataPush
customer_conn
=
CustomerProjects
(
mongo_client
=
mongo_client
)
customer_agg
=
ProjectAggregate
()
class
MachineOEECalculator
:
def
__init__
(
self
,
project_id
=
None
):
...
...
@@ -75,10 +81,12 @@ class MachineOEECalculator:
if
__name__
==
'__main__'
:
while
True
:
project_dict
=
customer_conn
.
find_project_by_aggregate
(
customer_agg
.
get_tz_mapping_query_with_project_id
())
project_dict
=
project_dict
[
0
]
if
project_dict
else
{}
projects_list
=
os
.
environ
.
get
(
"OEE_PROJECTS"
,
default
=
"project_170"
)
monitor_start_time
=
os
.
environ
.
get
(
"OEE_START_TIME"
,
default
=
"00:00"
)
for
project
in
projects_list
.
split
(
","
):
MachineOEECalculator
()
.
calculate_machine_oee
(
request_data
=
MachineOEERequest
(
project_id
=
project
,
monitor_time
=
"00:00"
,
tz
=
"Asia/Kolkata"
))
tz
=
project_dict
.
get
(
project
,
"Asia/Kolkata"
)
))
time
.
sleep
(
10
)
scripts/constants/__init__.py
View file @
4121d04d
...
...
@@ -76,6 +76,7 @@ class DBConstants:
collection_tag_hierarchy
=
"tag_hierarchy"
collection_oee_layouts
=
"oee_layouts"
collection_lookup_table
=
"lookup_table"
collection_customer_projects
=
"customer_projects"
class
EndpointConstants
:
...
...
@@ -150,3 +151,12 @@ class TagHierarchyKeys:
KEY_ASSET_MODEL_ID
=
"asset_model_id"
KEY_ASSET_VERSION
=
"asset_version"
KEY_additional_fields
=
"additional_fields"
class
CustomerProjectKeys
:
KEY_CUSTOMER_PROJECT_ID
=
"customer_project_id"
KEY_CUSTOMER_PROJECT_NAME
=
"customer_project_name"
KEY_SITE_TEMPLT_ID
=
"site_templt_id"
KEY_PROCESS_TEMPLT_ID
=
"process_templt_id"
KEY_SOURCE_META
=
"source_meta"
KEY_ADD_PREFIX_TO_DATABASE
=
"add_prefix_to_database"
scripts/core/handlers/common_handler.py
View file @
4121d04d
...
...
@@ -3,6 +3,7 @@ import os
from
scripts.constants
import
TagCategoryConstants
from
scripts.constants.db_connections
import
mongo_client
from
scripts.core.handlers.tag_handler
import
TagHierarchyHandler
from
scripts.db.mongo.ilens_configuration.collections.customer_projects
import
CustomerProjects
from
scripts.db.mongo.ilens_configuration.collections.lookup_table
import
LookupTable
from
scripts.db.mongo.schema.tag_hierarchy
import
OutputTagsList
from
scripts.logging
import
logger
...
...
scripts/core/handlers/oee_handlers.py
View file @
4121d04d
import
traceback
from
scripts.constants.db_connections
import
mongo_client
from
scripts.constants.db_connections
import
mongo_connection
from
scripts.db.mongo.ilens_configuration.collections
import
collection_constants
from
scripts.logging
import
logger
from
scripts.schemas.oee_config_schema
import
Oee_Tag_Mapping_List
,
Get_Oee_Tag
,
Update_Oee_Tags
,
Get_Project_Id
from
scripts.constants.db_connections
import
mongo_connection
class
Oee_Services
:
...
...
@@ -83,12 +83,3 @@ class Oee_Services:
logger
.
exception
(
tb
)
logger
.
exception
(
f
"Exception occurred while fetching data as {e}"
)
raise
def
get_project_tz
(
self
):
connection
=
self
.
mongo_connect
project_tz
=
connection
.
find
()
return_json
=
{}
for
each_project
in
project_tz
:
for
each_tz
in
each_project
:
return_json
.
update
({
str
(
each_tz
.
get
(
"customer_project_name"
)):
str
(
each_tz
.
get
(
"timezone"
))})
return
return_json
scripts/db/mongo/ilens_configuration/aggregations/customer_projects.py
0 → 100644
View file @
4121d04d
class
ProjectAggregate
:
@
staticmethod
def
get_tz_mapping_query_with_project_id
():
query_json
=
[
{
'$group'
:
{
'_id'
:
None
,
'data'
:
{
'$push'
:
{
'k'
:
{
'$ifNull'
:
[
'$customer_project_id'
,
''
]},
'v'
:
{
'$ifNull'
:
[
'$timezone'
,
''
]},
}
},
}},
{
'$replaceRoot'
:
{
'newRoot'
:
{
'$arrayToObject'
:
'$data'
}}}]
return
query_json
scripts/db/mongo/ilens_configuration/collections/customer_projects.py
0 → 100644
View file @
4121d04d
from
typing
import
Optional
,
Dict
from
scripts.constants
import
DBConstants
,
CustomerProjectKeys
from
scripts.db.mongo.schema
import
MongoBaseSchema
from
scripts.utils.mongo_util
import
MongoCollectionBaseClass
class
CustomerProjectsSchema
(
MongoBaseSchema
):
"""
This is the Schema for the Mongo DB Collection.
All datastore and general responses will be following the schema.
"""
customer_project_name
:
Optional
[
str
]
description
:
Optional
[
str
]
site_templt_id
:
Optional
[
str
]
logo_name
:
Optional
[
str
]
logo_url
:
Optional
[
str
]
process_templt_id
:
Optional
[
str
]
update_details
:
Optional
[
Dict
]
user_id
:
Optional
[
str
]
customer_project_id
:
Optional
[
str
]
product_encrypted
:
Optional
[
bool
]
timezone
:
Optional
[
str
]
country
:
Optional
[
str
]
client_name
:
Optional
[
str
]
add_prefix_to_database
:
Optional
[
bool
]
class
CustomerProjects
(
MongoCollectionBaseClass
):
def
__init__
(
self
,
mongo_client
,
project_id
=
None
):
super
()
.
__init__
(
mongo_client
,
database
=
DBConstants
.
db_metadata
,
collection
=
DBConstants
.
collection_customer_projects
)
self
.
project_id
=
project_id
@
property
def
key_customer_project_id
(
self
):
return
CustomerProjectKeys
.
KEY_CUSTOMER_PROJECT_ID
@
property
def
key_customer_project_name
(
self
):
return
CustomerProjectKeys
.
KEY_CUSTOMER_PROJECT_NAME
def
find_project
(
self
,
project_id
=
None
,
project_name
=
None
,
filter_dict
=
None
):
"""
The following function will give one record for a given set of
search parameters as keyword arguments
:param filter_dict:
:param project_id:
:param project_name
:return:
"""
query
=
dict
()
if
project_id
:
query
.
update
({
self
.
key_customer_project_id
:
project_id
})
if
project_name
:
query
.
update
({
self
.
key_customer_project_name
:
project_name
})
record
=
self
.
find_one
(
query
=
query
,
filter_dict
=
filter_dict
)
if
not
record
:
return
dict
()
return
CustomerProjectsSchema
(
**
record
)
.
dict
()
def
find_project_by_query
(
self
,
query
,
filter_dict
=
None
):
record
=
self
.
find
(
query
=
query
,
filter_dict
=
filter_dict
)
if
record
:
return
record
return
list
()
def
insert_one_project
(
self
,
data
):
"""
The following function will insert one project in the
customer_projects collections
:param self:
:param data:
:return:
"""
return
self
.
insert_one
(
data
)
def
update_one_project
(
self
,
project_id
,
data
):
query
=
{
self
.
key_customer_project_id
:
project_id
}
return
self
.
update_one
(
query
=
query
,
data
=
data
)
def
delete_one_project
(
self
,
project_id
):
if
project_id
:
query
=
{
self
.
key_customer_project_id
:
project_id
}
return
self
.
delete_one
(
query
)
else
:
return
False
def
find_project_by_aggregate
(
self
,
query
):
return
list
(
self
.
aggregate
(
pipelines
=
query
))
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