Skip to content

Commit dd1ae84

Browse files
committed
ADDED get_playlist_camera
1 parent 3a09ce8 commit dd1ae84

File tree

4 files changed

+46
-43
lines changed

4 files changed

+46
-43
lines changed

src/OrderView/utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,25 @@ def get_package_video_info(time: time, camera_ip: str) -> Dict[str, Any]:
5050
result["camera_ip"]: str = camera_ip
5151

5252
return result
53+
54+
55+
def get_playlist_camera(time_start, time_end, camera_ip):
56+
request_dat = {
57+
"timeStart": time_start,
58+
"timeEnd": time_end,
59+
"cameraIp": camera_ip
60+
}
61+
url = f"{ONVIF_SERVICE_URL}:3456/create_manifest/"
62+
try:
63+
response = requests.post(
64+
url=url,
65+
json=request_dat,
66+
)
67+
response.raise_for_status()
68+
return response.content
69+
except requests.exceptions.HTTPError as http_err:
70+
print(f"HTTP error occurred: {http_err}")
71+
print(f"Response content: {response.content}")
72+
except Exception as err:
73+
print(f"Other error occurred: {err}")
74+
return None

src/erp_5s/service.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
import base64
2+
import json
13
from datetime import datetime
4+
from email import encoders
5+
from email.mime.base import MIMEBase
6+
from email.mime.multipart import MIMEMultipart
7+
from email.mime.text import MIMEText
28

39
from django.db.models import Prefetch, Q
10+
from django.http import HttpResponse
411

512
from src.CameraAlgorithms.models import ZoneCameras
6-
from src.OrderView.utils import get_skany_video_info
13+
from src.OrderView.utils import get_skany_video_info, get_playlist_camera
714
from src.erp_5s.models import Orders, OrderItems, OrderOperations, OrderOperationTimespan, ReferenceItems
815
from src.erp_5s.models import Operations
916
from src.newOrderView.models import FiltrationOperationsTypeID
@@ -226,8 +233,13 @@ def get_detail_information_by_operation(operation_id):
226233
for zone_camera in cameras_zones:
227234
camera_id = zone_camera.camera.id
228235
video = get_skany_video_info(sTime, camera_id)
236+
get_playlist_camera(sTime, eTime, camera_id)
229237

230238
if video not in videos:
239+
if not eTime:
240+
eTime = int(datetime.now().timestamp() * 1000)
241+
playlist_content = get_playlist_camera(sTime, eTime, camera_id)
242+
video['playlist'] = base64.b64encode(playlist_content).decode('utf-8')
231243
videos.append(video)
232244

233245
if not timestamp.employee:
@@ -248,3 +260,4 @@ def get_detail_information_by_operation(operation_id):
248260
"videos": videos,
249261
}
250262
return result
263+

src/newOrderView/urls.py

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.urls import path
22

3-
from .views import (
3+
from src.newOrderView.views import (
44
GetOperation,
55
GetOrders,
66
GetOrderByDetail,
@@ -13,44 +13,12 @@
1313

1414

1515
urlpatterns = [
16-
path(
17-
"operations/",
18-
GetOperation.as_view(),
19-
name="get-list-operations",
20-
),
21-
path(
22-
"machine/",
23-
GetMachine.as_view(),
24-
name="get-list-machine",
25-
),
26-
path(
27-
"orders/",
28-
GetOrders.as_view(),
29-
name="get-list-order",
30-
),
31-
path(
32-
"order-detail/",
33-
GetOrderByDetail.as_view(),
34-
name="get-order-detail",
35-
),
36-
path(
37-
"whnet-operations/",
38-
GetWhnetOperation.as_view(),
39-
name="get-whnet-operation",
40-
),
41-
path(
42-
"filtration-data",
43-
FiltrationsDataView.as_view(),
44-
name="filtrations-data",
45-
),
46-
path(
47-
"avg-operations-duration",
48-
GetOperationsDuration.as_view(),
49-
name="avg-duration",
50-
),
51-
path(
52-
"order-packaging/",
53-
GetOrderPackaging.as_view(),
54-
name="order-packaging",
55-
)
16+
path("operations/", GetOperation.as_view(), name="get-list-operations"),
17+
path("machine/", GetMachine.as_view(), name="get-list-machine"),
18+
path("orders/", GetOrders.as_view(), name="get-list-order"),
19+
path("order-detail/", GetOrderByDetail.as_view(), name="get-order-detail"),
20+
path("whnet-operations/", GetWhnetOperation.as_view(), name="get-whnet-operation"),
21+
path("filtration-data", FiltrationsDataView.as_view(), name="filtrations-data"),
22+
path("avg-operations-duration", GetOperationsDuration.as_view(), name="avg-duration"),
23+
path("order-packaging/", GetOrderPackaging.as_view(), name="order-packaging")
5624
]

src/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
path("suppliers/", include("src.Suppliers.urls"), name="suppliers"),
2727
path("connector/", include("src.DatabaseConnections.urls"), name="connector"),
2828
path("healthcheck/", include("src.Healthcheck.urls"), name="healthcheck"),
29-
path("erp-reference/", include("src.references.urls"), name="reference-erp")
29+
path("erp-reference/", include("src.references.urls"), name="reference-erp"),
3030
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
3131

3232

0 commit comments

Comments
 (0)