update : 09.07.2025 16:20:00,86

This commit is contained in:
Sabron 2025-07-09 16:20:00 +07:00
parent 250d759a4a
commit d407d18dee
8 changed files with 231 additions and 73 deletions

View File

@ -149,7 +149,7 @@
</td>
</tr>
<div class="modal fade" id="modal-edit_{{catalog.id}}">
<div class="modal fade" id="modal-edit_{{catalog.id}}" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" {% if catalog.level_event > 2 %} style="background-color:red;" {%endif%} >

View File

@ -148,7 +148,7 @@
</td>
</tr>
<div class="modal fade" id="modal-edit_{{catalog.id}}">
<div class="modal fade" id="modal-edit_{{catalog.id}}" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" {% if catalog.level_event > 2 %} style="background-color:red;" {%endif%} >

View File

@ -143,7 +143,7 @@
</a>
</td>
</tr>
<div class="modal fade" id="modal-edit_{{catalog.id}}">
<div class="modal fade" id="modal-edit_{{catalog.id}}" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" {% if catalog.level_event > 2 %} style="background-color:red;" {%endif%} >

View File

@ -148,7 +148,7 @@
</td>
</tr>
<div class="modal fade" id="modal-edit_{{catalog.id}}">
<div class="modal fade" id="modal-edit_{{catalog.id}}" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" {% if catalog.level_event > 2 %} style="background-color:red;" {%endif%} >

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from datetime import datetime
from django.db import models
from django.urls import \
reverse # Used to generate URLs by reversing the URL patterns
class TypeIncident(models.Model):
"""
Модель тип аварий
"""
name = models.CharField(
max_length=400,
blank=True,
help_text="",
default=" ",
verbose_name="Наименование",
)
def __str__(self):
return self.name
class Meta: # отображение в админики
ordering = ["name"]
verbose_name = "тип аварии"
verbose_name_plural = "типы аварий"
indexes = [
models.Index(
fields=["name",]
),
]

View File

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from datetime import datetime
from django.db import models
from django.urls import \
reverse # Used to generate URLs by reversing the URL patterns
class TypeIncident(models.Model):
"""
Модель журнала тревоги
"""
name = models.CharField(
max_length=70,
blank=True,
help_text="",
default=" ",
verbose_name="Наименование",
)
audio_file = models.FileField(blank=True, null=True, upload_to="sound/")
text_alarm = models.TextField(
max_length=1500, blank=True, verbose_name="Комментарий", default=" "
)
def __str__(self):
return self.name
class Meta: # отображение в админики
ordering = ["name"]
verbose_name = "файл тревоги"
verbose_name_plural = "файлы тревоги"
indexes = [
models.Index(
fields=[
"name",
]
),
]

View File

@ -402,13 +402,13 @@ def load_earthquake():
current_month=current_month,
current_year=current_year,
)
# load_seishub(
# dist=dist,
# lon=lon,
# lat=lat,
# current_day=current_day,
# current_month=current_month - 1,
# current_year=current_year,
# load_seishub(
# dist=dist,
# lon=lon,
# lat=lat,
# current_day=current_day,
# current_month=current_month - 1,
# current_year=current_year,
# )
load_usgs(
dist=dist,
@ -528,11 +528,11 @@ def add_sensor(**kwargs):
sensor_link =Sensors.objects.filter(equipment=kwargs['equipment']).filter(uid=kwargs['sensor_id']).first()
if sensor_link is None:
sensor_link = Sensors.objects.create(uid=kwargs['sensor_id'],
name=kwargs['sensor_name'],
type =type_sensor,
equipment=kwargs['equipment'],
time=kwargs['sensor_time']+ timedelta(hours=7),
value=0 if kwargs['sensor_value'] is None else kwargs['sensor_value'])
name=kwargs['sensor_name'],
type =type_sensor,
equipment=kwargs['equipment'],
time=kwargs['sensor_time']+ timedelta(hours=7),
value=0 if kwargs['sensor_value'] is None else kwargs['sensor_value'])
else:
sensor_link.time=kwargs['sensor_time']+ timedelta(hours=7)
sensor_link.value=0 if kwargs['sensor_value'] is None else kwargs['sensor_value']
@ -540,13 +540,13 @@ def add_sensor(**kwargs):
indicator_link = Indicators.objects.filter(sensor=sensor_link).order_by('time').first()
if indicator_link is None:
indicator_link = Indicators.objects.create(sensor=sensor_link,
time=kwargs['sensor_time']+ timedelta(hours=7),
value=0 if kwargs['sensor_value'] is None else kwargs['sensor_value'])
time=kwargs['sensor_time']+ timedelta(hours=7),
value=0 if kwargs['sensor_value'] is None else kwargs['sensor_value'])
else:
if indicator_link.value != float(0 if kwargs['sensor_value'] is None else kwargs['sensor_value']):
indicator_link = Indicators.objects.create(sensor=sensor_link,
time=kwargs['sensor_time']+ timedelta(hours=7),
value=0 if kwargs['sensor_value'] is None else kwargs['sensor_value'])
time=kwargs['sensor_time']+ timedelta(hours=7),
value=0 if kwargs['sensor_value'] is None else kwargs['sensor_value'])
@ -1109,9 +1109,9 @@ def test_circuit():
obj.save()
WorkersTracking.objects.create(worker=obj,
latitude=obj.latitude,
longitude=obj.longitude,
time=timezone.now())
latitude=obj.latitude,
longitude=obj.longitude,
time=timezone.now())
test_earthquakes = Earthquake.objects.filter(source="Тест")
for earthquake in test_earthquakes:
@ -1180,6 +1180,11 @@ def scan_polygon_danger_zones():
if is_now_inside:
alarm_type = "enter_danger_zone_allow" if has_access else "enter_danger_zone_disallow"
description = f'Сотрудник {worker.name or worker.uid} вошёл в зону "{zone.name}"'
eventsmodule.write_events(
level_event = settings.EVENT_LEVEL_WARNING,
section = settings.EVENT_SECTION_WORKERS,
text_event = description
)
else:
alarm_type = "exit_danger_zone"
description = f'Сотрудник {worker.name or worker.uid} покинул зону "{zone.name}"'
@ -1284,6 +1289,11 @@ def scan_danger_zones_around_equipment():
if is_now_inside:
alarm_type = "enter_equipment_danger_zone"
description = f'Сотрудник {worker.name or worker.uid} вошёл в опасную зону рядом с "{danger_equipment.full_name}"'
eventsmodule.write_events(
level_event = settings.EVENT_LEVEL_CRITICAL,
section = settings.EVENT_SECTION_WORKERS,
text_event = description
)
else:
alarm_type = "exit_equipment_danger_zone"
description = f'Сотрудник {worker.name or worker.uid} покинул опасную зону рядом с "{danger_equipment.full_name}"'

View File

@ -1,5 +1,6 @@
<html lang="ru">
{% load static %} {% load mysettings %}
{% load static %}
{% load mysettings %}
<head>
@ -31,65 +32,32 @@
<link type="image/x-icon" href="{% static '/img/logo.png' %}?ver={% settings_value 'APP_VER' %}" rel="shortcut icon">
<link type="Image/x-icon" href="{% static 'img/logo.png' %}?ver={% settings_value 'APP_VER' %}" rel="icon">
<!-- Google Font: Source Sans Pro -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&amp;display=fallback"
/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&amp;display=fallback">
<!-- Font Awesome -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/fontawesome-free/css/all.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/fontawesome-free/css/all.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- Tempusdominus Bootstrap 4 -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- Select2 -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/select2/css/select2.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link
rel="stylesheet"
href="{% static 'lte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/select2/css/select2.min.css' %}?ver={% settings_value 'APP_VER' %}">
<link rel="stylesheet" href="{% static 'lte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- Bootstrap4 Duallistbox -->
<link rel="stylesheet" href="{% static 'lte/plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- iCheck -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- JQVMap -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/jqvmap/jqvmap.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/jqvmap/jqvmap.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- <link rel="stylesheet" href="{% static 'lte/plugins/icheck-bootstrap/icheck-bootstrap.min.css' %}?ver={% settings_value 'APP_VER' %}">-->
<!-- Theme style -->
<link
rel="stylesheet"
href="{% static 'lte/dist/css/adminlte.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/dist/css/adminlte.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- overlayScrollbars -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/overlayScrollbars/css/OverlayScrollbars.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/overlayScrollbars/css/OverlayScrollbars.min.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- Daterange picker -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/daterangepicker/daterangepicker.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/daterangepicker/daterangepicker.css' %}?ver={% settings_value 'APP_VER' %}">
<!-- summernote -->
<link
rel="stylesheet"
href="{% static 'lte/plugins/summernote/summernote-bs4.min.css' %}?ver={% settings_value 'APP_VER' %}"
/>
<link rel="stylesheet" href="{% static 'lte/plugins/summernote/summernote-bs4.min.css' %}?ver={% settings_value 'APP_VER' %}">
{% block header_link %} {% endblock header_link %}
<style type="text/css">
@ -131,12 +99,16 @@
><i class="fas fa-bars"></i
></a>
</li>
<li class="nav-item d-none d-sm-inline-block">
<button type="button" class="btn btn-block bg-gradient-warning" data-toggle="modal" data-target="#modal-event">Событие</button>
</li>
</ul>
<!-- Right navbar links -->
<ul class="navbar-nav ml-auto">
<!--<li class="nav-item d-none d-sm-inline-block">
<a href="/alarm/" class="nav-link" style="color:red;">АВАРИЙНАЯ СИТУАЦИЯ</a>
</li>-->
<li class="nav-item d-none d-sm-inline-block">
<button type="button" class="btn btn-block bg-gradient-danger" data-toggle="modal" data-target="#modal-danger"> Авария</button>
</li>
<li class="nav-item dropdown">
<a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="far fa-comments"></i>
@ -368,6 +340,93 @@
</div>
</div>
<!-- /.content-wrapper -->
<div class="modal fade" id="modal-danger" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header bg-danger" >
<h4 class="modal-title">Авария</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-primary">Добавить</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<div class="modal fade" id="modal-event" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header bg-warning" >
<h4 class="modal-title">Событие</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group row">
<label for="id_level_event" class="col-sm-2 col-form-label">Уровень : </label>
<div class="col-sm-10">
<select id="id_level_event" name = "level_event" class="form-control select2" style="width: 100%;" >
<option value="0">Информация</option>
<option value="1">Предупреждение</option>
<option value="2">Ошибка</option>
<option value="3">Критическое</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="id_section" class="col-sm-2 col-form-label">Источник : </label>
<div class="col-sm-10">
<select id="id_section" name = "section" class="form-control select2" style="width: 100%;">
<option value="1">Горнотранспортное оборудование</option>
<option value="2">Персонал</option>
<option value="10">Прочие</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="id_text_event" class="col-sm-2 col-form-label">Подробности : </label>
<div class="col-sm-10">
<textarea id="id_text_event" name="text_event" class="form-control"></textarea>
</div>
</div>
<div class="form-group row">
<label for="id_recipients" class="col-sm-2 col-form-label">Получатели : </label>
<div class="col-sm-10">
<select id="id_recipients" name="recipients" class="duallistbox" multiple="multiple">
<option value="0">Пользователь</option>
<option value="1">Администратор</option>
<option value="3">Начальник участка</option>
<option value="4">Главный инженер</option>
<option value="5">Главный геолог</option>
<option value="6">Главный технолог</option>
</select>
</div>
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-primary">Добавить</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
{% block footer %}
<footer class="main-footer">
<div class="float-right d-none d-sm-block">
@ -411,6 +470,8 @@
<script src="{% static 'lte/plugins/inputmask/jquery.inputmask.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<!-- Select2 -->
<script src="{% static 'lte/plugins/select2/js/select2.full.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<!-- Bootstrap4 Duallistbox -->
<script src="{% static 'lte/plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<!-- ChartJS -->
<script src="{% static 'lte/plugins/chart.js/Chart.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
<!-- Sparkline -->
@ -491,6 +552,20 @@
await updateEvents();
setInterval(updateEvents, 3000);
//Initialize Select2 Elements
$('.select2').select2()
//Bootstrap Duallistbox
$('.duallistbox').bootstrapDualListbox({
infoText: '',
filterTextClear: 'Показать всех',
filterPlaceHolder: 'Поиск',
moveSelectedLabel: 'Выбрать отмеченных',
moveAllLabel: 'Выбрать всех',
removeAllLabel: 'Удалить всех',
removeSelectedLabel: 'Удалить выбранных'
}
)
});
</script>