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
be52d2ce
Commit
be52d2ce
authored
May 20, 2022
by
hemanthkumar.pasham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding oee services
parent
15ccf0a8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
0 deletions
+147
-0
scripts/constants/__init__.py
scripts/constants/__init__.py
+5
-0
scripts/core/handlers/oee_handlers.py
scripts/core/handlers/oee_handlers.py
+80
-0
scripts/schemas/batch_oee.py
scripts/schemas/batch_oee.py
+7
-0
scripts/services/oee_services.py
scripts/services/oee_services.py
+55
-0
No files found.
scripts/constants/__init__.py
View file @
be52d2ce
...
...
@@ -18,6 +18,11 @@ class Endpoints:
api_hierarchy
=
"/hierarchy"
hierarchy_api
=
'ilens_config/get_site_level_hierarchy'
#OEE SERVICES
oee_services
=
"/oee"
oee_services
=
"/oee_post"
class
StatusCodes
:
SUCCESS
=
[
200
,
201
,
204
]
...
...
scripts/core/handlers/oee_handlers.py
0 → 100644
View file @
be52d2ce
from
scripts.logging
import
logger
from
scripts.utils.mongo_util
import
MongoCollectionBaseClass
from
scripts.constants.db_connections
import
mongo_client
class
Oee_services
:
def
__init__
(
self
):
try
:
self
.
connect
=
MongoCollectionBaseClass
(
mongo_client
=
mongo_client
,
database
=
"ilens_configuration"
,
collection
=
"oee_tag_mapping"
)
except
Exception
as
e
:
logger
.
exception
(
"Error while connecting to mongodb"
)
async
def
oee_tag_mapping
(
self
,
oee_tag_mapping_list
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"message"
:
"data not inserted in to mongodb"
}
insert_json
=
{
"hierarchy"
:
oee_tag_mapping_list
.
get
(
"hierarchy"
,
""
),
"project_id"
:
oee_tag_mapping_list
.
get
(
"project_id"
,
""
),
"meta"
:
oee_tag_mapping_list
.
get
(
"project_id"
,
""
),
"oee_tag_mapping"
:
oee_tag_mapping_list
.
get
(
"oee_tag_mapping"
,
{})
}
result
=
self
.
connect
.
insert_one
(
data
=
insert_json
)
if
result
:
logger
.
info
(
"Data inserted in to mongodb successfully"
)
return_json
[
"message"
]
=
"success"
return_json
[
"status"
]
=
"success"
else
:
logger
.
info
(
"Unable to insert data in to Mongodb"
)
except
Exception
as
e
:
logger
.
exception
(
"Error occured while inserting data"
)
return
return_json
async
def
get_oee_tag_mapping
(
self
,
get_oee_tag
,
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"data"
:
"data not found"
}
query
=
{
'project_id'
:
get_oee_tag
.
get
(
"project_id"
,
""
)}
skips
=
get_oee_tag
.
get
(
"page_size"
)
*
(
get_oee_tag
(
"page_num"
)
-
1
)
no_of_documents
=
self
.
connect
.
count_documents
(
query
=
query
)
result
=
self
.
connect
.
find
(
query
=
query
)
.
skip
(
skips
)
.
limit
(
get_oee_tag
.
get
(
"page_num"
))
if
result
:
return_json
[
"message"
]
=
"success"
return_json
[
"status"
]
=
"success"
return_json
[
"data"
]
=
result
return_json
[
"total_records"
]
=
no_of_documents
if
skips
<
no_of_documents
:
return_json
[
"endOfrecords"
]
=
False
else
:
return_json
[
"endOfrecords"
]
=
True
except
Exception
as
e
:
logger
.
exception
(
f
"Exception occured while fetching data as {e}"
)
return
result
async
def
delete_oee_tags
(
self
,
project_id
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"data"
:
"data not found"
}
query
=
{
"project_id"
:
project_id
}
result
=
self
.
connect
.
delete_one
(
query
=
query
)
if
result
:
return_json
[
"message"
]
=
"success"
return_json
[
"status"
]
=
"success"
return_json
[
"data"
]
=
result
except
Exception
as
e
:
logger
.
exception
(
f
"Exception occured while fetching data as {e}"
)
return
result
async
def
update_oee_tags
(
self
,
update_oee_tags
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"data"
:
"data not found"
}
query
=
{
"project_id"
:
update_oee_tags
[
'projec_id'
]}
result
=
self
.
connect
.
update_one
(
query
=
query
,
data
=
return_json
)
if
result
:
return_json
[
"message"
]
=
"success"
return_json
[
"status"
]
=
"success"
return_json
[
"data"
]
=
result
except
Exception
as
e
:
logger
.
exception
(
f
"Exception occured while fetching data as {e}"
)
return
return_json
scripts/schemas/batch_oee.py
View file @
be52d2ce
...
...
@@ -144,3 +144,10 @@ class GetOEERequestOneBatch(BaseModel):
class
GetBatches
(
GetOEERequest
):
pass
class
GetOeeServices
(
BaseModel
):
hierarchy
:
str
project_id
:
str
meta
:
dict
oee_tag_mapping
:
str
scripts/services/oee_services.py
0 → 100644
View file @
be52d2ce
from
fastapi
import
APIRouter
from
scripts.logging
import
logger
from
scripts.constants
import
Endpoints
from
scripts.schemas.batch_oee
import
GetOeeServices
from
scripts.core.handlers
import
oee_handlers
oee_services
=
APIRouter
(
prefix
=
Endpoints
.
oee_services
,
tags
=
[
"OEE Calculator"
])
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
oee_tag_mapping
(
oee_tag_mapping_list
:
GetOeeServices
):
try
:
tag_mapping
=
oee_tag_mapping_list
.
dict
()
result
=
oee_handlers
.
Oee_services
.
oee_tag_mapping
(
tag_mapping
)
except
Exception
as
e
:
logger
.
exception
(
"Exception occured while inserting data"
)
return
result
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
get_oee_tag_mapping
(
get_oee_tags
:
GetOeeServices
):
try
:
get_oee_tags
=
get_oee_tags
.
dict
()
return_json
=
oee_handlers
.
Oee_services
.
get_oee_tag_mapping
(
get_oee_tags
)
except
Exception
as
e
:
logger
.
exception
(
f
"Error while getting information as {e}"
)
return
return_json
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
delete_oee_tagging
(
delete_oee_tags
:
GetOeeServices
):
try
:
delete_oee_tags
=
delete_oee_tags
.
dict
()
return_json
=
oee_handlers
.
Oee_services
.
delete_oee_tags
(
projec_id
=
delete_oee_tags
[
"project_id"
])
except
Exception
as
e
:
logger
.
exception
(
f
"Error while getting information as {e}"
)
return
return_json
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
updaye_oee_tagging
(
update_oee_tags
:
GetOeeServices
):
try
:
update_oee_tags
=
update_oee_tags
.
dict
()
return_json
=
oee_handlers
.
Oee_services
.
update_oee_services
(
update_oee_tags
)
except
Exception
as
e
:
logger
.
exception
(
f
"Error while getting information as {e}"
)
return
return_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