фикс визуала
This commit is contained in:
parent
4bd5950477
commit
15db7a7fab
@ -30,4 +30,4 @@ class AccidentStopAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(Position)
|
||||
class PositionAdmin(admin.ModelAdmin):
|
||||
list_display = ['title', 'tag']
|
||||
list_display = ['title']
|
||||
|
||||
@ -70,7 +70,13 @@ class Position(models.Model):
|
||||
Модель для хранения позиций, по которым работают весы
|
||||
"""
|
||||
title = models.CharField(max_length=100, blank=True)
|
||||
tag = models.CharField(max_length=128, blank=True)
|
||||
tag = models.CharField(max_length=80, blank=True)
|
||||
aver_smena_tag = models.CharField(max_length=80, blank=True)
|
||||
aver_pred_smena_tag = models.CharField(max_length=80, blank=True)
|
||||
smena_tag = models.CharField(max_length=80, blank=True)
|
||||
pred_smena_tag = models.CharField(max_length=80, blank=True)
|
||||
month_tag = models.CharField(max_length=80, blank=True)
|
||||
sutki_tag = models.CharField(max_length=80, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Позиция'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -79,30 +79,32 @@ def get_scales_value(positions: QuerySet, interval: str) -> dict:
|
||||
|
||||
|
||||
def get_scales_value_by_shifts(positions: QuerySet, interval: str) -> dict:
|
||||
# f"""
|
||||
# Получает показания весов с базы данных.
|
||||
# Возвращает словарь.
|
||||
# 0 int - Показание меньше нуля либо равно нулю
|
||||
# 0 str - Показания нет в базе
|
||||
# """
|
||||
res = {}
|
||||
current_work_shift = {}
|
||||
previous_work_shift = {}
|
||||
now = timezone.now()
|
||||
today = now.date()
|
||||
start_of_today = timezone.make_aware(datetime.combine(today, time.min), timezone.get_current_timezone())
|
||||
eight_am_today = timezone.make_aware(datetime.combine(today, time(8, 0)), timezone.get_current_timezone())
|
||||
|
||||
for position in positions:
|
||||
try:
|
||||
previous_work_shift_scale_data = ScalesControl.objects.filter(name__endswith=f'{position.tag}.{interval}',
|
||||
date__range=(
|
||||
start_of_today, eight_am_today)).latest(
|
||||
'date')
|
||||
previous_shift_tag = position.aver_pred_smena_tag if interval == 'Aver' else position.pred_smena_tag
|
||||
previous_shift_obj = ScalesControl.objects.filter(name=previous_shift_tag).latest('date')
|
||||
previous_work_shift[position.title] = int(
|
||||
previous_work_shift_scale_data.value) if previous_work_shift_scale_data.value >= 0 else 0
|
||||
previous_shift_obj.value) if previous_shift_obj.value >= 0 else 0
|
||||
except ScalesControl.DoesNotExist:
|
||||
previous_work_shift[position.title] = '0'
|
||||
previous_work_shift[position.title] = "0"
|
||||
|
||||
try:
|
||||
current_work_shift_scale_data = ScalesControl.objects.filter(
|
||||
name__endswith=f'{position.tag}.{interval}').latest('date')
|
||||
current_work_shift[position.title] = int(
|
||||
current_work_shift_scale_data.value) if current_work_shift_scale_data.value >= 0 else 0
|
||||
current_shift_tag = position.aver_smena_tag if interval == 'Aver' else position.smena_tag
|
||||
current_shift_obj = ScalesControl.objects.filter(name=current_shift_tag).latest('date')
|
||||
current_work_shift[position.title] = int(current_shift_obj.value) if current_shift_obj.value >= 0 else 0
|
||||
except ScalesControl.DoesNotExist:
|
||||
current_work_shift[position.title] = '0'
|
||||
current_work_shift[position.title] = "0"
|
||||
|
||||
res['previous_work_shift'] = previous_work_shift
|
||||
res['current_work_shift'] = current_work_shift
|
||||
return res
|
||||
@ -110,14 +112,14 @@ def get_scales_value_by_shifts(positions: QuerySet, interval: str) -> dict:
|
||||
|
||||
@base_view
|
||||
def get_scales_data(request):
|
||||
positions = Position.objects.all()
|
||||
positions = Position.objects.all().order_by('id')
|
||||
monthly = get_scales_value(positions, 'Month')
|
||||
productivity = get_scales_value_by_shifts(positions, 'Productivity')
|
||||
daily = get_scales_value_by_shifts(positions, 'Sutki')
|
||||
productivity = get_scales_value_by_shifts(positions, 'Aver')
|
||||
daily = get_scales_value_by_shifts(positions, 'Smena')
|
||||
return JsonResponse({'daily': daily, 'monthly': monthly, 'productivity': productivity})
|
||||
|
||||
|
||||
@base_view
|
||||
def get_positions(request):
|
||||
positions = Position.objects.all().values_list('title', flat=True)
|
||||
positions = Position.objects.all().order_by('id').values_list('title', flat=True)
|
||||
return JsonResponse(list(positions), safe=False)
|
||||
|
||||
@ -22,7 +22,7 @@ def get_scales_data() -> list:
|
||||
SELECT "Name", "Values", "Date", "Check"
|
||||
FROM public.vesi
|
||||
ORDER BY id DESC
|
||||
LIMIT 5000;
|
||||
LIMIT 15000;
|
||||
""")
|
||||
|
||||
data = cursor.fetchall()
|
||||
@ -48,7 +48,6 @@ def write_scales_data(data: list):
|
||||
DECLARE
|
||||
value_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- Check if the value already exists in the existing record
|
||||
SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM public.main_scalescontrol
|
||||
@ -65,9 +64,9 @@ def write_scales_data(data: list):
|
||||
END IF;
|
||||
END $$;
|
||||
""", (
|
||||
name, value, # Check if value exists
|
||||
date, name, value, # Update date if value exists
|
||||
name, value, date, check # Insert new record if value does not exist
|
||||
name, value,
|
||||
date, name, value,
|
||||
name, value, date, check
|
||||
))
|
||||
postgres_conn.commit()
|
||||
except Exception:
|
||||
|
||||
@ -1,404 +1,404 @@
|
||||
// Заглушки
|
||||
(function () {
|
||||
(function () {
|
||||
let options = {
|
||||
chart: {
|
||||
type: 'donut',
|
||||
height: '200px'
|
||||
},
|
||||
labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
series: [20, 2, 2],
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
legend: {
|
||||
position: 'bottom',
|
||||
formatter: function (val, opts) {
|
||||
return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
}
|
||||
}
|
||||
}
|
||||
let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_11"), options);
|
||||
chart.render();
|
||||
})();
|
||||
(function () {
|
||||
let options = {
|
||||
chart: {
|
||||
type: 'donut',
|
||||
height: '200px'
|
||||
},
|
||||
labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
series: [150, 10, 8],
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
legend: {
|
||||
position: 'bottom',
|
||||
formatter: function (val, opts) {
|
||||
return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
}
|
||||
}
|
||||
}
|
||||
let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_12"), options);
|
||||
chart.render();
|
||||
})();
|
||||
(function () {
|
||||
let options = {
|
||||
chart: {
|
||||
type: 'donut',
|
||||
height: '200px'
|
||||
},
|
||||
labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
series: [650, 100, 20],
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
legend: {
|
||||
position: 'bottom',
|
||||
formatter: function (val, opts) {
|
||||
return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
}
|
||||
}
|
||||
}
|
||||
let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_13"), options);
|
||||
chart.render();
|
||||
})();
|
||||
})();
|
||||
(function () {
|
||||
(function () {
|
||||
let options = {
|
||||
chart: {
|
||||
type: 'donut'
|
||||
},
|
||||
labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
series: [20, 2, 2],
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
legend: {
|
||||
position: 'right',
|
||||
formatter: function (val, opts) {
|
||||
if (opts.w.globals.series[opts.seriesIndex]) {
|
||||
return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
} else {
|
||||
return "Загрузка"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_131"), options);
|
||||
chart.render();
|
||||
})();
|
||||
(function () {
|
||||
let options = {
|
||||
chart: {
|
||||
type: 'donut'
|
||||
},
|
||||
labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
series: [150, 10, 8],
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
legend: {
|
||||
position: 'right',
|
||||
formatter: function (val, opts) {
|
||||
return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
}
|
||||
}
|
||||
}
|
||||
let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_132"), options);
|
||||
chart.render();
|
||||
})();
|
||||
(function () {
|
||||
let options = {
|
||||
chart: {
|
||||
type: 'donut'
|
||||
},
|
||||
labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
series: [650, 100, 20],
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
legend: {
|
||||
position: 'right',
|
||||
formatter: function (val, opts) {
|
||||
return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
}
|
||||
}
|
||||
}
|
||||
let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_133"), options);
|
||||
chart.render();
|
||||
})();
|
||||
})();
|
||||
|
||||
// Показания весов
|
||||
|
||||
|
||||
// <script>
|
||||
// {#const height = 'auto'#}
|
||||
// {#const labelColor = '#9d9d9d'#}
|
||||
// {#const borderColor = '#d8d8d8';#}
|
||||
// {#const baseColor = '#7ff9ac';#}
|
||||
// {#const secondaryColor = '#c3afaf';#}
|
||||
// {#const baseLightColor = '#fbbdbd'#}
|
||||
// {#const secondLightColor = '#ee132c'#}
|
||||
// {#const options = {#}
|
||||
// {# series: [#}
|
||||
// {# {#}
|
||||
// {# name: 'Работает',#}
|
||||
// {# data: [#}
|
||||
// {# {#}
|
||||
// {# x: 'Фабрика',#}
|
||||
// {# y: [#}
|
||||
// {# new Date('2024-05-22T00:00+07:00').getTime(),#}
|
||||
// {# new Date('2024-05-22T23:00+07:00').getTime()#}
|
||||
// {# ]#}
|
||||
// {# },#}
|
||||
// {# ]#}
|
||||
// {# },#}
|
||||
// {# {#}
|
||||
// {# name: 'Работает под нагрузкой',#}
|
||||
// {# data: [#}
|
||||
// {# {#}
|
||||
// {# x: 'Фабрика',#}
|
||||
// {# y: [#}
|
||||
// {# new Date('2024-05-22T00:00+07:00').getTime(),#}
|
||||
// {# new Date('2024-05-22T12:00+07:00').getTime()#}
|
||||
// {# ]#}
|
||||
// {# },#}
|
||||
// {# {#}
|
||||
// {# x: 'Фабрика',#}
|
||||
// {# y: [#}
|
||||
// {# new Date('2024-05-22T14:02+07:00').getTime(),#}
|
||||
// {# new Date('2024-05-22T23:00+07:00').getTime()#}
|
||||
// {# ]#}
|
||||
// {# }#}
|
||||
// {# ]#}
|
||||
// {# },#}
|
||||
// {# {#}
|
||||
// {# name: 'Работает без нагрузки',#}
|
||||
// {# data: [#}
|
||||
// {# {#}
|
||||
// {# x: 'Фабрика',#}
|
||||
// {# y: [#}
|
||||
// {# new Date('2024-05-22T12:00+07:00').getTime(),#}
|
||||
// {# new Date('2024-05-22T14:00+07:00').getTime()#}
|
||||
// {# ]#}
|
||||
// {# },#}
|
||||
// {# ]#}
|
||||
// {# },#}
|
||||
// {# {#}
|
||||
// {# name: 'Не работала',#}
|
||||
// {# data: [#}
|
||||
// {# {#}
|
||||
// {# x: 'Фабрика',#}
|
||||
// {# y: [#}
|
||||
// {# new Date('2024-05-22T23:00+07:00').getTime(),#}
|
||||
// {# new Date('2024-05-22T23:59+07:00').getTime()#}
|
||||
// {# ]#}
|
||||
// {# },#}
|
||||
// {# ]#}
|
||||
// {# }#}
|
||||
// {# ],#}
|
||||
// {# chart: {#}
|
||||
// {# type: 'rangeBar',#}
|
||||
// {# fontFamily: 'inherit',#}
|
||||
// {# height: height,#}
|
||||
// {# toolbar: {#}
|
||||
// {# show: false#}
|
||||
// {# }#}
|
||||
// {# },#}
|
||||
// {# colors: [baseColor, secondaryColor, baseLightColor, secondLightColor],#}
|
||||
// {# plotOptions: {#}
|
||||
// {# bar: {#}
|
||||
// {# horizontal: true,#}
|
||||
// {# barHeight: '80%'#}
|
||||
// {# }#}
|
||||
// {# },#}
|
||||
// {# xaxis: {#}
|
||||
// {# type: 'datetime',#}
|
||||
// {# labels: {#}
|
||||
// {# datetimeUTC: false,#}
|
||||
// {# datetimeFormatter: {#}
|
||||
// {# year: 'yyyy',#}
|
||||
// {# month: "MMM 'yy",#}
|
||||
// {# day: 'dd MMM',#}
|
||||
// {# hour: 'HH:mm',#}
|
||||
// {# },#}
|
||||
// {# }#}
|
||||
// {# },#}
|
||||
// {# stroke: {#}
|
||||
// {# width: 1#}
|
||||
// {# },#}
|
||||
// {# fill: {#}
|
||||
// {# type: 'solid',#}
|
||||
// {# opacity: 1#}
|
||||
// {# },#}
|
||||
// {# legend: {#}
|
||||
// {# position: 'top',#}
|
||||
// {# horizontalAlign: 'left'#}
|
||||
// {# }#}
|
||||
// {# }; #}
|
||||
// {#const chart = new ApexCharts(document.querySelector("#kt_apexcharts_1"), options);#}
|
||||
// {##}
|
||||
// {#chart.render();#}
|
||||
// </script>
|
||||
|
||||
{/*<table>*/
|
||||
}
|
||||
{/* <thead>*/
|
||||
}
|
||||
{/* <tr>*/
|
||||
}
|
||||
{/* <th rowSpan="2">Весовой контроль</th>*/
|
||||
}
|
||||
{/* <th colSpan="2">поз. 22</th>*/
|
||||
}
|
||||
{/* <th colSpan="2">поз. 13</th>*/
|
||||
}
|
||||
{/* <th colSpan="2">поз. 4</th>*/
|
||||
}
|
||||
{/* <th rowSpan="2">к-та %</th>*/
|
||||
}
|
||||
{/* <th rowSpan="2">отсева %</th>*/
|
||||
}
|
||||
{/* <th rowSpan="2">поз. 22,2</th>*/
|
||||
}
|
||||
{/* <th rowSpan="2">поз. 22,3</th>*/
|
||||
}
|
||||
{/* </tr>*/
|
||||
}
|
||||
{/* <tr>*/
|
||||
}
|
||||
{/* <th>т/ч</th>*/
|
||||
}
|
||||
{/* <th>т</th>*/
|
||||
}
|
||||
{/* <th>т/ч</th>*/
|
||||
}
|
||||
{/* <th>т</th>*/
|
||||
}
|
||||
{/* <th>т/ч</th>*/
|
||||
}
|
||||
{/* <th>т</th>*/
|
||||
}
|
||||
{/* </tr>*/
|
||||
}
|
||||
{/* </thead>*/
|
||||
}
|
||||
{/* <tbody>*/
|
||||
}
|
||||
{/* <tr>*/
|
||||
}
|
||||
{/* <th>текущая смена</th>*/
|
||||
}
|
||||
{/* <td>299</td>*/
|
||||
}
|
||||
{/* <td>579</td>*/
|
||||
}
|
||||
{/* <td>70</td>*/
|
||||
}
|
||||
{/* <td>56</td>*/
|
||||
}
|
||||
{/* <td>460</td>*/
|
||||
}
|
||||
{/* <td>768</td>*/
|
||||
}
|
||||
{/* <td>65</td>*/
|
||||
}
|
||||
{/* <td>15</td>*/
|
||||
}
|
||||
{/* <td>144</td>*/
|
||||
}
|
||||
{/* <td>35</td>*/
|
||||
}
|
||||
{/* </tr>*/
|
||||
}
|
||||
{/* <tr>*/
|
||||
}
|
||||
{/* <th>пред. смена</th>*/
|
||||
}
|
||||
{/* <td>391</td>*/
|
||||
}
|
||||
{/* <td>4686</td>*/
|
||||
}
|
||||
{/* <td>78</td>*/
|
||||
}
|
||||
{/* <td>902</td>*/
|
||||
}
|
||||
{/* <td>565</td>*/
|
||||
}
|
||||
{/* <td>6453</td>*/
|
||||
}
|
||||
{/* <td>69</td>*/
|
||||
}
|
||||
{/* <td>14</td>*/
|
||||
}
|
||||
{/* <td>144</td>*/
|
||||
}
|
||||
{/* <td>35</td>*/
|
||||
}
|
||||
{/* </tr>*/
|
||||
}
|
||||
{/* <tr>*/
|
||||
}
|
||||
{/* <th>сутки, т</th>*/
|
||||
}
|
||||
{/* <td>579</td>*/
|
||||
}
|
||||
{/* <td>579</td>*/
|
||||
}
|
||||
{/* <td>56</td>*/
|
||||
}
|
||||
{/* <td>56</td>*/
|
||||
}
|
||||
{/* <td>768</td>*/
|
||||
}
|
||||
{/* <td>768</td>*/
|
||||
}
|
||||
{/* <td>75</td>*/
|
||||
}
|
||||
{/* <td>7</td>*/
|
||||
}
|
||||
{/* <td>0</td>*/
|
||||
}
|
||||
{/* <td>0</td>*/
|
||||
}
|
||||
{/* </tr>*/
|
||||
}
|
||||
{/* <tr>*/
|
||||
}
|
||||
{/* <th>месяц, т</th>*/
|
||||
}
|
||||
{/* <td>142357</td>*/
|
||||
}
|
||||
{/* <td>142357</td>*/
|
||||
}
|
||||
{/* <td>57976</td>*/
|
||||
}
|
||||
{/* <td>57976</td>*/
|
||||
}
|
||||
{/* <td>230952</td>*/
|
||||
}
|
||||
{/* <td>230952</td>*/
|
||||
}
|
||||
{/* <td>62</td>*/
|
||||
}
|
||||
{/* <td>25</td>*/
|
||||
}
|
||||
{/* <td>9</td>*/
|
||||
}
|
||||
{/* <td>-1</td>*/
|
||||
}
|
||||
{/* </tr>*/
|
||||
}
|
||||
{/* </tbody>*/
|
||||
}
|
||||
{/* </table>*/
|
||||
}
|
||||
// // Заглушки
|
||||
// (function () {
|
||||
// (function () {
|
||||
// let options = {
|
||||
// chart: {
|
||||
// type: 'donut',
|
||||
// height: '200px'
|
||||
// },
|
||||
// labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
// series: [20, 2, 2],
|
||||
// dataLabels: {
|
||||
// enabled: false
|
||||
// },
|
||||
// colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
// legend: {
|
||||
// position: 'bottom',
|
||||
// formatter: function (val, opts) {
|
||||
// return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_11"), options);
|
||||
// chart.render();
|
||||
// })();
|
||||
// (function () {
|
||||
// let options = {
|
||||
// chart: {
|
||||
// type: 'donut',
|
||||
// height: '200px'
|
||||
// },
|
||||
// labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
// series: [150, 10, 8],
|
||||
// dataLabels: {
|
||||
// enabled: false
|
||||
// },
|
||||
// colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
// legend: {
|
||||
// position: 'bottom',
|
||||
// formatter: function (val, opts) {
|
||||
// return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_12"), options);
|
||||
// chart.render();
|
||||
// })();
|
||||
// (function () {
|
||||
// let options = {
|
||||
// chart: {
|
||||
// type: 'donut',
|
||||
// height: '200px'
|
||||
// },
|
||||
// labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
// series: [650, 100, 20],
|
||||
// dataLabels: {
|
||||
// enabled: false
|
||||
// },
|
||||
// colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
// legend: {
|
||||
// position: 'bottom',
|
||||
// formatter: function (val, opts) {
|
||||
// return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_13"), options);
|
||||
// chart.render();
|
||||
// })();
|
||||
// })();
|
||||
// (function () {
|
||||
// (function () {
|
||||
// let options = {
|
||||
// chart: {
|
||||
// type: 'donut'
|
||||
// },
|
||||
// labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
// series: [20, 2, 2],
|
||||
// dataLabels: {
|
||||
// enabled: false
|
||||
// },
|
||||
// colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
// legend: {
|
||||
// position: 'right',
|
||||
// formatter: function (val, opts) {
|
||||
// if (opts.w.globals.series[opts.seriesIndex]) {
|
||||
// return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
// } else {
|
||||
// return "Загрузка"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_131"), options);
|
||||
// chart.render();
|
||||
// })();
|
||||
// (function () {
|
||||
// let options = {
|
||||
// chart: {
|
||||
// type: 'donut'
|
||||
// },
|
||||
// labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
// series: [150, 10, 8],
|
||||
// dataLabels: {
|
||||
// enabled: false
|
||||
// },
|
||||
// colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
// legend: {
|
||||
// position: 'right',
|
||||
// formatter: function (val, opts) {
|
||||
// return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_132"), options);
|
||||
// chart.render();
|
||||
// })();
|
||||
// (function () {
|
||||
// let options = {
|
||||
// chart: {
|
||||
// type: 'donut'
|
||||
// },
|
||||
// labels: ['Под нагрузкой', 'Без нагрузки', 'Не работала'],
|
||||
// series: [650, 100, 20],
|
||||
// dataLabels: {
|
||||
// enabled: false
|
||||
// },
|
||||
// colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
// legend: {
|
||||
// position: 'right',
|
||||
// formatter: function (val, opts) {
|
||||
// return val + ": " + opts.w.globals.series[opts.seriesIndex] + 'ч.';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// let chart = new ApexCharts(document.querySelector("#m_chart_personal_income_quater_133"), options);
|
||||
// chart.render();
|
||||
// })();
|
||||
// })();
|
||||
//
|
||||
// // Показания весов
|
||||
//
|
||||
//
|
||||
// // <script>
|
||||
// // {#const height = 'auto'#}
|
||||
// // {#const labelColor = '#9d9d9d'#}
|
||||
// // {#const borderColor = '#d8d8d8';#}
|
||||
// // {#const baseColor = '#7ff9ac';#}
|
||||
// // {#const secondaryColor = '#c3afaf';#}
|
||||
// // {#const baseLightColor = '#fbbdbd'#}
|
||||
// // {#const secondLightColor = '#ee132c'#}
|
||||
// // {#const options = {#}
|
||||
// // {# series: [#}
|
||||
// // {# {#}
|
||||
// // {# name: 'Работает',#}
|
||||
// // {# data: [#}
|
||||
// // {# {#}
|
||||
// // {# x: 'Фабрика',#}
|
||||
// // {# y: [#}
|
||||
// // {# new Date('2024-05-22T00:00+07:00').getTime(),#}
|
||||
// // {# new Date('2024-05-22T23:00+07:00').getTime()#}
|
||||
// // {# ]#}
|
||||
// // {# },#}
|
||||
// // {# ]#}
|
||||
// // {# },#}
|
||||
// // {# {#}
|
||||
// // {# name: 'Работает под нагрузкой',#}
|
||||
// // {# data: [#}
|
||||
// // {# {#}
|
||||
// // {# x: 'Фабрика',#}
|
||||
// // {# y: [#}
|
||||
// // {# new Date('2024-05-22T00:00+07:00').getTime(),#}
|
||||
// // {# new Date('2024-05-22T12:00+07:00').getTime()#}
|
||||
// // {# ]#}
|
||||
// // {# },#}
|
||||
// // {# {#}
|
||||
// // {# x: 'Фабрика',#}
|
||||
// // {# y: [#}
|
||||
// // {# new Date('2024-05-22T14:02+07:00').getTime(),#}
|
||||
// // {# new Date('2024-05-22T23:00+07:00').getTime()#}
|
||||
// // {# ]#}
|
||||
// // {# }#}
|
||||
// // {# ]#}
|
||||
// // {# },#}
|
||||
// // {# {#}
|
||||
// // {# name: 'Работает без нагрузки',#}
|
||||
// // {# data: [#}
|
||||
// // {# {#}
|
||||
// // {# x: 'Фабрика',#}
|
||||
// // {# y: [#}
|
||||
// // {# new Date('2024-05-22T12:00+07:00').getTime(),#}
|
||||
// // {# new Date('2024-05-22T14:00+07:00').getTime()#}
|
||||
// // {# ]#}
|
||||
// // {# },#}
|
||||
// // {# ]#}
|
||||
// // {# },#}
|
||||
// // {# {#}
|
||||
// // {# name: 'Не работала',#}
|
||||
// // {# data: [#}
|
||||
// // {# {#}
|
||||
// // {# x: 'Фабрика',#}
|
||||
// // {# y: [#}
|
||||
// // {# new Date('2024-05-22T23:00+07:00').getTime(),#}
|
||||
// // {# new Date('2024-05-22T23:59+07:00').getTime()#}
|
||||
// // {# ]#}
|
||||
// // {# },#}
|
||||
// // {# ]#}
|
||||
// // {# }#}
|
||||
// // {# ],#}
|
||||
// // {# chart: {#}
|
||||
// // {# type: 'rangeBar',#}
|
||||
// // {# fontFamily: 'inherit',#}
|
||||
// // {# height: height,#}
|
||||
// // {# toolbar: {#}
|
||||
// // {# show: false#}
|
||||
// // {# }#}
|
||||
// // {# },#}
|
||||
// // {# colors: [baseColor, secondaryColor, baseLightColor, secondLightColor],#}
|
||||
// // {# plotOptions: {#}
|
||||
// // {# bar: {#}
|
||||
// // {# horizontal: true,#}
|
||||
// // {# barHeight: '80%'#}
|
||||
// // {# }#}
|
||||
// // {# },#}
|
||||
// // {# xaxis: {#}
|
||||
// // {# type: 'datetime',#}
|
||||
// // {# labels: {#}
|
||||
// // {# datetimeUTC: false,#}
|
||||
// // {# datetimeFormatter: {#}
|
||||
// // {# year: 'yyyy',#}
|
||||
// // {# month: "MMM 'yy",#}
|
||||
// // {# day: 'dd MMM',#}
|
||||
// // {# hour: 'HH:mm',#}
|
||||
// // {# },#}
|
||||
// // {# }#}
|
||||
// // {# },#}
|
||||
// // {# stroke: {#}
|
||||
// // {# width: 1#}
|
||||
// // {# },#}
|
||||
// // {# fill: {#}
|
||||
// // {# type: 'solid',#}
|
||||
// // {# opacity: 1#}
|
||||
// // {# },#}
|
||||
// // {# legend: {#}
|
||||
// // {# position: 'top',#}
|
||||
// // {# horizontalAlign: 'left'#}
|
||||
// // {# }#}
|
||||
// // {# }; #}
|
||||
// // {#const chart = new ApexCharts(document.querySelector("#kt_apexcharts_1"), options);#}
|
||||
// // {##}
|
||||
// // {#chart.render();#}
|
||||
// // </script>
|
||||
//
|
||||
// {/*<table>*/
|
||||
// }
|
||||
// {/* <thead>*/
|
||||
// }
|
||||
// {/* <tr>*/
|
||||
// }
|
||||
// {/* <th rowSpan="2">Весовой контроль</th>*/
|
||||
// }
|
||||
// {/* <th colSpan="2">поз. 22</th>*/
|
||||
// }
|
||||
// {/* <th colSpan="2">поз. 13</th>*/
|
||||
// }
|
||||
// {/* <th colSpan="2">поз. 4</th>*/
|
||||
// }
|
||||
// {/* <th rowSpan="2">к-та %</th>*/
|
||||
// }
|
||||
// {/* <th rowSpan="2">отсева %</th>*/
|
||||
// }
|
||||
// {/* <th rowSpan="2">поз. 22,2</th>*/
|
||||
// }
|
||||
// {/* <th rowSpan="2">поз. 22,3</th>*/
|
||||
// }
|
||||
// {/* </tr>*/
|
||||
// }
|
||||
// {/* <tr>*/
|
||||
// }
|
||||
// {/* <th>т/ч</th>*/
|
||||
// }
|
||||
// {/* <th>т</th>*/
|
||||
// }
|
||||
// {/* <th>т/ч</th>*/
|
||||
// }
|
||||
// {/* <th>т</th>*/
|
||||
// }
|
||||
// {/* <th>т/ч</th>*/
|
||||
// }
|
||||
// {/* <th>т</th>*/
|
||||
// }
|
||||
// {/* </tr>*/
|
||||
// }
|
||||
// {/* </thead>*/
|
||||
// }
|
||||
// {/* <tbody>*/
|
||||
// }
|
||||
// {/* <tr>*/
|
||||
// }
|
||||
// {/* <th>текущая смена</th>*/
|
||||
// }
|
||||
// {/* <td>299</td>*/
|
||||
// }
|
||||
// {/* <td>579</td>*/
|
||||
// }
|
||||
// {/* <td>70</td>*/
|
||||
// }
|
||||
// {/* <td>56</td>*/
|
||||
// }
|
||||
// {/* <td>460</td>*/
|
||||
// }
|
||||
// {/* <td>768</td>*/
|
||||
// }
|
||||
// {/* <td>65</td>*/
|
||||
// }
|
||||
// {/* <td>15</td>*/
|
||||
// }
|
||||
// {/* <td>144</td>*/
|
||||
// }
|
||||
// {/* <td>35</td>*/
|
||||
// }
|
||||
// {/* </tr>*/
|
||||
// }
|
||||
// {/* <tr>*/
|
||||
// }
|
||||
// {/* <th>пред. смена</th>*/
|
||||
// }
|
||||
// {/* <td>391</td>*/
|
||||
// }
|
||||
// {/* <td>4686</td>*/
|
||||
// }
|
||||
// {/* <td>78</td>*/
|
||||
// }
|
||||
// {/* <td>902</td>*/
|
||||
// }
|
||||
// {/* <td>565</td>*/
|
||||
// }
|
||||
// {/* <td>6453</td>*/
|
||||
// }
|
||||
// {/* <td>69</td>*/
|
||||
// }
|
||||
// {/* <td>14</td>*/
|
||||
// }
|
||||
// {/* <td>144</td>*/
|
||||
// }
|
||||
// {/* <td>35</td>*/
|
||||
// }
|
||||
// {/* </tr>*/
|
||||
// }
|
||||
// {/* <tr>*/
|
||||
// }
|
||||
// {/* <th>сутки, т</th>*/
|
||||
// }
|
||||
// {/* <td>579</td>*/
|
||||
// }
|
||||
// {/* <td>579</td>*/
|
||||
// }
|
||||
// {/* <td>56</td>*/
|
||||
// }
|
||||
// {/* <td>56</td>*/
|
||||
// }
|
||||
// {/* <td>768</td>*/
|
||||
// }
|
||||
// {/* <td>768</td>*/
|
||||
// }
|
||||
// {/* <td>75</td>*/
|
||||
// }
|
||||
// {/* <td>7</td>*/
|
||||
// }
|
||||
// {/* <td>0</td>*/
|
||||
// }
|
||||
// {/* <td>0</td>*/
|
||||
// }
|
||||
// {/* </tr>*/
|
||||
// }
|
||||
// {/* <tr>*/
|
||||
// }
|
||||
// {/* <th>месяц, т</th>*/
|
||||
// }
|
||||
// {/* <td>142357</td>*/
|
||||
// }
|
||||
// {/* <td>142357</td>*/
|
||||
// }
|
||||
// {/* <td>57976</td>*/
|
||||
// }
|
||||
// {/* <td>57976</td>*/
|
||||
// }
|
||||
// {/* <td>230952</td>*/
|
||||
// }
|
||||
// {/* <td>230952</td>*/
|
||||
// }
|
||||
// {/* <td>62</td>*/
|
||||
// }
|
||||
// {/* <td>25</td>*/
|
||||
// }
|
||||
// {/* <td>9</td>*/
|
||||
// }
|
||||
// {/* <td>-1</td>*/
|
||||
// }
|
||||
// {/* </tr>*/
|
||||
// }
|
||||
// {/* </tbody>*/
|
||||
// }
|
||||
// {/* </table>*/
|
||||
// }
|
||||
@ -3,25 +3,121 @@
|
||||
positions = await fetch('positions/').then(response => {
|
||||
return response.json()
|
||||
})
|
||||
const locales = [{
|
||||
"name": "ru",
|
||||
"options": {
|
||||
"months": ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентрябрь", "Октябрь", "Ноябрь", "Декабрь"],
|
||||
"shortMonths": ["Янв", "Фев", "Мар", "Апр", "Май", "Июнь", "Июль ", "Авг", "Сент", "Окт", "Нояб", "Дек"],
|
||||
"days": ["Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"],
|
||||
"shortDays": ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
|
||||
"toolbar": {
|
||||
"exportToSVG": "Скачать SVG",
|
||||
"exportToPNG": "Скачать PNG",
|
||||
"exportToCSV": "Скачать CSV",
|
||||
"menu": "Меню",
|
||||
"selection": "Выборка",
|
||||
"selectionZoom": "Приближение выборки",
|
||||
"zoomIn": "Приблизить",
|
||||
"zoomOut": "Отдалить",
|
||||
"pan": "Панорамирование",
|
||||
"reset": "Сбросить приближение"
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
||||
const hoursBarOptions = {
|
||||
series: [],
|
||||
chart: {
|
||||
type: 'bar',
|
||||
height: 300,
|
||||
locales: locales,
|
||||
defaultLocale: "ru",
|
||||
animations: {
|
||||
enabled: true,
|
||||
easing: 'easeinout',
|
||||
speed: 800,
|
||||
animateGradually: {
|
||||
enabled: true,
|
||||
delay: 150
|
||||
},
|
||||
dynamicAnimation: {
|
||||
enabled: true,
|
||||
speed: 350
|
||||
}
|
||||
}
|
||||
},
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: true,
|
||||
},
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
textAnchor: 'start',
|
||||
offsetX: -3,
|
||||
dropShadow: {
|
||||
enabled: false
|
||||
},
|
||||
formatter: function (val) {
|
||||
return val;
|
||||
},
|
||||
},
|
||||
stroke: {
|
||||
show: true,
|
||||
width: 2,
|
||||
colors: ['transparent']
|
||||
},
|
||||
xaxis: {
|
||||
categories: positions,
|
||||
},
|
||||
fill: {
|
||||
opacity: 1
|
||||
},
|
||||
tooltip: {
|
||||
y: {
|
||||
formatter: function (val) {
|
||||
return val + " тонн в час";
|
||||
}
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: 'часовая нагрузка'
|
||||
},
|
||||
noData: {
|
||||
text: 'Загрузка...'
|
||||
}
|
||||
};
|
||||
|
||||
const hoursBarChart = new ApexCharts(document.querySelector("#byHourScales"), hoursBarOptions);
|
||||
hoursBarChart.render();
|
||||
|
||||
const DailyBarOptions = {
|
||||
series: [{
|
||||
name: 'Текущая смена',
|
||||
data: []
|
||||
}, {
|
||||
name: 'Предыдущая смена',
|
||||
data: []
|
||||
}],
|
||||
series: [],
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
chart: {
|
||||
type: 'bar',
|
||||
height: 350,
|
||||
height: 300,
|
||||
stacked: true,
|
||||
toolbar: {
|
||||
show: true
|
||||
},
|
||||
locales: locales,
|
||||
defaultLocale: "ru",
|
||||
zoom: {
|
||||
enabled: true
|
||||
},
|
||||
animations: {
|
||||
enabled: true,
|
||||
easing: 'easeinout',
|
||||
speed: 800,
|
||||
animateGradually: {
|
||||
enabled: true,
|
||||
delay: 150
|
||||
},
|
||||
dynamicAnimation: {
|
||||
enabled: true,
|
||||
speed: 350
|
||||
}
|
||||
}
|
||||
},
|
||||
responsive: [{
|
||||
@ -60,29 +156,30 @@
|
||||
},
|
||||
title: {
|
||||
text: 'тонн за сутки'
|
||||
}, noData: {
|
||||
},
|
||||
noData: {
|
||||
text: 'Загрузка...'
|
||||
}
|
||||
};
|
||||
|
||||
const dailyScalesChart = new ApexCharts(document.querySelector("#dailyScales"), DailyBarOptions);
|
||||
dailyScalesChart.render();
|
||||
|
||||
const monthlyBarOptions = {
|
||||
series: [{
|
||||
name: 'Месяц',
|
||||
data: []
|
||||
}],
|
||||
series: [],
|
||||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||||
chart: {
|
||||
type: 'bar',
|
||||
height: 350,
|
||||
height: 300,
|
||||
stacked: true,
|
||||
toolbar: {
|
||||
show: true
|
||||
},
|
||||
zoom: {
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
locales: locales,
|
||||
defaultLocale: "ru",
|
||||
},
|
||||
responsive: [{
|
||||
breakpoint: 480,
|
||||
@ -96,18 +193,18 @@
|
||||
}],
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: false,
|
||||
dataLabels: {
|
||||
total: {
|
||||
enabled: true,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
fontWeight: 900,
|
||||
}
|
||||
},
|
||||
|
||||
position: 'top'
|
||||
}
|
||||
}
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
style: {
|
||||
colors: ['#000']
|
||||
},
|
||||
offsetY: -20,
|
||||
textAnchor: 'start',
|
||||
},
|
||||
xaxis: {
|
||||
type: 'category',
|
||||
@ -136,98 +233,37 @@
|
||||
const monthlyScalesChart = new ApexCharts(document.querySelector("#monthlyScales"), monthlyBarOptions);
|
||||
monthlyScalesChart.render();
|
||||
|
||||
const hoursBarOptions = {
|
||||
series: [{
|
||||
name: 'Текущая смена',
|
||||
data: []
|
||||
}, {
|
||||
name: 'Предыдущая смена',
|
||||
data: []
|
||||
},
|
||||
],
|
||||
chart: {
|
||||
type: 'bar',
|
||||
height: 350
|
||||
},
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: true,
|
||||
columnWidth: '55%',
|
||||
endingShape: 'rounded'
|
||||
},
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
textAnchor: 'start',
|
||||
offsetX: 6,
|
||||
dropShadow: {
|
||||
enabled: false // Disable drop shadow to avoid white edges
|
||||
},
|
||||
formatter: function (val) {
|
||||
// Custom formatter to return an empty string for certain values
|
||||
if (val === 100 || val === 200) {
|
||||
return ''; // Remove white labels
|
||||
}
|
||||
return val; // Keep black labels
|
||||
}
|
||||
},
|
||||
stroke: {
|
||||
show: true,
|
||||
width: 2,
|
||||
colors: ['transparent']
|
||||
},
|
||||
xaxis: {
|
||||
categories: positions,
|
||||
},
|
||||
fill: {
|
||||
opacity: 1
|
||||
},
|
||||
tooltip: {
|
||||
y: {
|
||||
formatter: function (val) {
|
||||
return val + " тонн в час"
|
||||
}
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: 'часовая нагрузка'
|
||||
},
|
||||
noData: {
|
||||
text: 'Загрузка...'
|
||||
}
|
||||
}
|
||||
const hoursBarChart = new ApexCharts(document.querySelector("#byHourScales"), hoursBarOptions);
|
||||
hoursBarChart.render();
|
||||
function setChartsData() {
|
||||
fetch('scales/').then(response => {
|
||||
return response.json()
|
||||
}).then(json => {
|
||||
monthlyScalesChart.updateSeries([{
|
||||
name: 'Месяц',
|
||||
data: Object.values(json.monthly)
|
||||
}], true)
|
||||
|
||||
fetch('scales/').then(response => {
|
||||
return response.json()
|
||||
}).then(json => {
|
||||
monthlyScalesChart.updateSeries([{
|
||||
name: 'Месяц',
|
||||
data: Object.values(json.monthly)
|
||||
}])
|
||||
|
||||
hoursBarChart.updateSeries([{
|
||||
name: 'Текущая смена',
|
||||
data: Object.values(json.productivity.current_work_shift)
|
||||
},
|
||||
{
|
||||
hoursBarChart.updateSeries([{
|
||||
name: 'Текущая смена',
|
||||
data: Object.values(json.productivity.current_work_shift)
|
||||
}, {
|
||||
name: 'Предыдущая смена',
|
||||
data: Object.values(json.productivity.previous_work_shift)
|
||||
}])
|
||||
}], true)
|
||||
|
||||
dailyScalesChart.updateSeries([{
|
||||
name: 'Текущая смена',
|
||||
data: Object.values(json.daily.current_work_shift)
|
||||
}, {
|
||||
name: 'Предыдущая смена',
|
||||
data: Object.values(json.daily.previous_work_shift)
|
||||
}])
|
||||
})
|
||||
dailyScalesChart.updateSeries([{
|
||||
name: 'Текущая смена',
|
||||
data: Object.values(json.daily.current_work_shift)
|
||||
}, {
|
||||
name: 'Предыдущая смена',
|
||||
data: Object.values(json.daily.previous_work_shift)
|
||||
}], true)
|
||||
})
|
||||
}
|
||||
|
||||
setChartsData()
|
||||
setInterval(setChartsData, 5000)
|
||||
|
||||
})
|
||||
();
|
||||
})();
|
||||
|
||||
|
||||
(function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user