Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
A
acc_cdc
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Ce projet est archivé. Le dépôt et les autres ressources du projet sont en lecture seule.
Afficher davantage de fils d'Ariane
Le Filament
Opération Auto-Consommation Collective
acc_cdc
Validations
e676cadf
Valider
e676cadf
rédigé
Il y a 4 ans
par
Juliana
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[FIX] Bug curve line day/week + add prm id
parent
7434fd1e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
models/enercoop_operation.py
+179
-46
179 ajouts, 46 suppressions
models/enercoop_operation.py
static/src/js/operation_graph.js
+1
-7
1 ajout, 7 suppressions
static/src/js/operation_graph.js
avec
180 ajouts
et
53 suppressions
models/enercoop_operation.py
+
179
−
46
Voir le fichier @
e676cadf
...
@@ -48,11 +48,19 @@ class EnercoopOperation(models.Model):
...
@@ -48,11 +48,19 @@ class EnercoopOperation(models.Model):
operation_ids
=
self
.
env
[
'
enercoop.operation
'
].
search
(
domain
)
operation_ids
=
self
.
env
[
'
enercoop.operation
'
].
search
(
domain
)
if
operation_ids
:
if
operation_ids
:
# # Get date start and date end depending on type of scale if scale fill
# if scale:
# date_start, date_end = self.get_last_day(scale)
#
# # Get scale depending on the date start and date end
# if date_start and date_end:
# scale = self.get_scale(date_start, date_end)
# Get date start and date end depending on type of scale
# Get date start and date end depending on type of scale
date_start
,
date_end
=
operation_ids
.
get_last_day
(
scale
)
date_start
,
date_end
=
operation_ids
.
get_last_day
(
scale
)
# Get the data to display in chart
# Get the data to display in chart
chart_data
=
operation_ids
.
get_cdc
(
scale
,
date_start
,
date_end
)
chart_data
=
operation_ids
.
get_cdc
(
scale
,
date_start
,
date_end
,
19
)
# Build the chart depending on data calculated
# Build the chart depending on data calculated
result_graph
=
operation_ids
.
chart_data_cons
(
chart_data
)
result_graph
=
operation_ids
.
chart_data_cons
(
chart_data
)
...
@@ -260,7 +268,7 @@ class EnercoopOperation(models.Model):
...
@@ -260,7 +268,7 @@ class EnercoopOperation(models.Model):
result
[
'
histo_chart_conso
'
]
=
{
result
[
'
histo_chart_conso
'
]
=
{
'
type
'
:
'
bar
'
,
'
type
'
:
'
bar
'
,
'
data
'
:
{
'
data
'
:
{
'
labels
'
:
chart_data
[
'
label
'
],
'
labels
'
:
chart_data
[
'
label
_histo
'
],
'
datasets
'
:
[
'
datasets
'
:
[
{
{
'
label
'
:
'
AutoConso
'
,
'
label
'
:
'
AutoConso
'
,
...
@@ -345,7 +353,7 @@ class EnercoopOperation(models.Model):
...
@@ -345,7 +353,7 @@ class EnercoopOperation(models.Model):
result
[
'
histo_chart_prod
'
]
=
{
result
[
'
histo_chart_prod
'
]
=
{
'
type
'
:
'
bar
'
,
'
type
'
:
'
bar
'
,
'
data
'
:
{
'
data
'
:
{
'
labels
'
:
chart_data
[
'
label
'
],
'
labels
'
:
chart_data
[
'
label
_histo
'
],
'
datasets
'
:
[
'
datasets
'
:
[
{
{
'
label
'
:
'
AutoConso
'
,
'
label
'
:
'
AutoConso
'
,
...
@@ -364,7 +372,7 @@ class EnercoopOperation(models.Model):
...
@@ -364,7 +372,7 @@ class EnercoopOperation(models.Model):
}
}
return
result
return
result
def
get_cdc
(
self
,
type
,
date_start
,
date_end
):
def
get_cdc
(
self
,
type
,
date_start
,
date_end
,
prm_id
):
"""
"""
Fonction permettant de récupérer les données pour la
Fonction permettant de récupérer les données pour la
construction des chart pour une ou des opérations données
construction des chart pour une ou des opérations données
...
@@ -379,6 +387,7 @@ class EnercoopOperation(models.Model):
...
@@ -379,6 +387,7 @@ class EnercoopOperation(models.Model):
cdc_jour
=
[]
cdc_jour
=
[]
label_line_cons
=
[]
label_line_cons
=
[]
label_histo_cons
=
[]
data_autocons
=
[]
data_autocons
=
[]
data_autocons_line
=
[]
data_autocons_line
=
[]
data_cons
=
[]
data_cons
=
[]
...
@@ -396,35 +405,111 @@ class EnercoopOperation(models.Model):
...
@@ -396,35 +405,111 @@ class EnercoopOperation(models.Model):
if
type
==
'
day
'
:
if
type
==
'
day
'
:
type_date
=
'
date_slot:hour
'
type_date
=
'
date_slot:hour
'
type_date_abs
=
'
date_slot:day
'
type_date_abs
=
'
date_slot:day
'
type_date_histo
=
'
date_slot:hour
'
elif
type
==
'
year
'
:
elif
type
==
'
year
'
:
type_date
=
'
date_slot:month
'
type_date
=
'
date_slot:month
'
type_date_abs
=
'
date_slot:month
'
type_date_abs
=
'
date_slot:month
'
type_date_histo
=
'
date_slot:month
'
else
:
else
:
type_date
=
'
date_slot:day
'
type_date
=
'
date_slot:day
'
type_date_abs
=
'
date_slot:day
'
type_date_abs
=
'
date_slot:day
'
type_date_histo
=
'
date_slot:day
'
if
type
==
'
week
'
:
if
type
==
'
week
'
:
type_date
=
'
date_slot:hour
'
type_date
=
'
date_slot:hour
'
enercoop_counter_id
=
self
.
env
[
'
enercoop.counter
'
].
browse
(
prm_id
)
if
enercoop_counter_id
:
# Get all data group by curves type and date
# Get all data group by curves type and date
cdc_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
cdc_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
)],
(
'
date_slot
'
,
'
<
'
,
date_end
),
'
|
'
,
(
'
enercoop_counter_id
'
,
'
=
'
,
False
),
(
'
enercoop_counter_id
'
,
'
=
'
,
enercoop_counter_id
.
id
)
],
[
'
power
'
,
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
'
power
'
,
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
'
comp_data_type
'
,
type_date
],
orderby
=
'
comp_data_type, date_slot ASC
'
,
lazy
=
False
)
[
'
comp_data_type
'
,
type_date
],
orderby
=
'
comp_data_type, date_slot ASC
'
,
lazy
=
False
)
if
type
==
'
week
'
:
cdc_histo_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
),
'
|
'
,
(
'
enercoop_counter_id
'
,
'
=
'
,
False
),
(
'
enercoop_counter_id
'
,
'
=
'
,
enercoop_counter_id
.
id
)
],
[
'
power
'
,
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
'
comp_data_type
'
,
type_date_histo
],
orderby
=
'
comp_data_type, date_slot ASC
'
,
lazy
=
False
)
# Get the date for the abscissa axis
# Get the date for the abscissa axis
cdc_date_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
cdc_date_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
)],
(
'
date_slot
'
,
'
<
'
,
date_end
),
'
|
'
,
(
'
enercoop_counter_id
'
,
'
=
'
,
False
),
(
'
enercoop_counter_id
'
,
'
=
'
,
enercoop_counter_id
.
id
)
],
[
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
type_date_abs
],
orderby
=
'
date_slot ASC
'
,
lazy
=
False
)
# Get the date for the abscissa axis (histo)
if
type
==
'
day
'
:
cdc_date_histo_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
),
'
|
'
,
(
'
enercoop_counter_id
'
,
'
=
'
,
False
),
(
'
enercoop_counter_id
'
,
'
=
'
,
enercoop_counter_id
.
id
)
],
[
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
type_date
],
orderby
=
'
date_slot ASC
'
,
lazy
=
False
)
else
:
# Get all data group by curves type and date
cdc_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
)
],
[
'
power
'
,
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
'
comp_data_type
'
,
type_date
],
orderby
=
'
comp_data_type, date_slot ASC
'
,
lazy
=
False
)
if
type
==
'
week
'
:
cdc_histo_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
)
],
[
'
power
'
,
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
'
comp_data_type
'
,
type_date_histo
],
orderby
=
'
comp_data_type, date_slot ASC
'
,
lazy
=
False
)
# Get the date for the abscissa axis
cdc_date_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
),
],
[
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
type_date_abs
],
orderby
=
'
date_slot ASC
'
,
lazy
=
False
)
[
type_date_abs
],
orderby
=
'
date_slot ASC
'
,
lazy
=
False
)
# Get the date for the abscissa axis (histo)
if
type
==
'
day
'
:
cdc_date_histo_ids
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
),
],
[
'
enercoop_operation_id
'
,
'
date_slot
'
],
[
type_date
],
orderby
=
'
date_slot ASC
'
,
lazy
=
False
)
# Build the abscissa axis with the right format date
# Build the abscissa axis with the right format date
for
cdc
in
cdc_date_ids
:
for
cdc
in
cdc_date_ids
:
value_hour
=
cdc
[
type_date_abs
]
value_hour
=
cdc
[
type_date_abs
]
label_line_cons
.
append
(
value_hour
)
label_line_cons
.
append
(
value_hour
)
label_histo_cons
.
append
(
value_hour
)
# Build the abscissa axis with the right format date (histo)
if
type
==
'
day
'
:
label_histo_cons
=
[]
for
cdc
in
cdc_date_histo_ids
:
value_hour
=
cdc
[
type_date
]
label_histo_cons
.
append
(
value_hour
)
# Build the ordinate axis for each data type (autoconso/conso/prod/surplus)
# Build the ordinate axis for each data type (autoconso/conso/prod/surplus)
for
cdc
in
cdc_ids
:
for
cdc
in
cdc_ids
:
...
@@ -442,7 +527,45 @@ class EnercoopOperation(models.Model):
...
@@ -442,7 +527,45 @@ class EnercoopOperation(models.Model):
if
cdc
[
'
comp_data_type
'
]
==
'
surplus
'
:
if
cdc
[
'
comp_data_type
'
]
==
'
surplus
'
:
data_surplus
.
append
(
value_power
)
data_surplus
.
append
(
value_power
)
# Build the ordinate axis for each data type (autoconso/conso/prod/surplus) for histo graph
if
type
==
'
week
'
:
data_autocons
=
[]
data_cons
=
[]
data_prod
=
[]
data_surplus
=
[]
for
cdc
in
cdc_histo_ids
:
value_power
=
round
((
cdc
[
'
power
'
]
/
2
),
2
)
if
cdc
[
'
comp_data_type
'
]
==
'
autocons
'
:
data_autocons
.
append
(
value_power
)
if
cdc
[
'
comp_data_type
'
]
==
'
cons
'
:
data_cons
.
append
(
value_power
)
if
cdc
[
'
comp_data_type
'
]
==
'
prod
'
:
data_prod
.
append
(
value_power
)
if
cdc
[
'
comp_data_type
'
]
==
'
surplus
'
:
data_surplus
.
append
(
value_power
)
if
type
==
'
day
'
or
type
==
'
week
'
:
if
type
==
'
day
'
or
type
==
'
week
'
:
if
enercoop_counter_id
:
query
=
"""
SELECT
A.comp_data_type AS comp_data_type,
A.date_slot AS date_slot,
SUM(A.power) AS power
FROM enercoop_enedis_cdc A
JOIN enercoop_operation E ON E.id = A.enercoop_operation_id
WHERE A.enercoop_operation_id IS NOT NULL
AND A.enercoop_operation_id IN %s
AND ( A.enercoop_counter_id = %s
OR A.enercoop_counter_id = NULL )
AND A.date_slot >= %s
AND A.date_slot < %s
GROUP BY A.comp_data_type, A.date_slot
ORDER BY A.comp_data_type, A.date_slot ASC;
"""
query_params
=
(
tuple
(
self
.
ids
),
enercoop_counter_id
.
id
,
date_start
,
date_end
)
self
.
env
.
cr
.
execute
(
query
,
query_params
)
raw_data
=
self
.
env
.
cr
.
dictfetchall
()
else
:
query
=
"""
query
=
"""
SELECT
SELECT
A.comp_data_type AS comp_data_type,
A.comp_data_type AS comp_data_type,
...
@@ -476,6 +599,15 @@ class EnercoopOperation(models.Model):
...
@@ -476,6 +599,15 @@ class EnercoopOperation(models.Model):
data_surplus_line
.
append
({
'
t
'
:
value_hour
,
'
y
'
:
value_power
})
data_surplus_line
.
append
({
'
t
'
:
value_hour
,
'
y
'
:
value_power
})
# Get the data to build the chart Bilan
# Get the data to build the chart Bilan
if
enercoop_counter_id
:
bilan_cdc
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
<
'
,
date_end
),
'
|
'
,
(
'
enercoop_counter_id
'
,
'
=
'
,
False
),
(
'
enercoop_counter_id
'
,
'
=
'
,
enercoop_counter_id
.
id
)],
[
'
power
'
,
'
enercoop_operation_id
'
],
[
'
comp_data_type
'
],
orderby
=
'
comp_data_type
'
,
lazy
=
False
)
else
:
bilan_cdc
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
bilan_cdc
=
self
.
env
[
'
enercoop.enedis.cdc
'
].
sudo
().
read_group
(
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
[(
'
enercoop_operation_id
'
,
'
in
'
,
self
.
ids
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
(
'
date_slot
'
,
'
>=
'
,
date_start
),
...
@@ -521,6 +653,7 @@ class EnercoopOperation(models.Model):
...
@@ -521,6 +653,7 @@ class EnercoopOperation(models.Model):
'
surplus
'
:
data_surplus
,
'
surplus
'
:
data_surplus
,
'
surplus_line
'
:
data_surplus_line
,
'
surplus_line
'
:
data_surplus_line
,
'
label
'
:
label_line_cons
,
'
label
'
:
label_line_cons
,
'
label_histo
'
:
label_histo_cons
,
'
label_doughnut
'
:
[
'
Autoconso
'
,
'
Alloconso
'
],
'
label_doughnut
'
:
[
'
Autoconso
'
,
'
Alloconso
'
],
'
doughnut_cons
'
:
[
percent_autocons
,
percent_cons
],
'
doughnut_cons
'
:
[
percent_autocons
,
percent_cons
],
'
label_doughnut_prod
'
:
[
'
Autoconso
'
,
'
Surplus
'
],
'
label_doughnut_prod
'
:
[
'
Autoconso
'
,
'
Surplus
'
],
...
@@ -532,7 +665,7 @@ class EnercoopOperation(models.Model):
...
@@ -532,7 +665,7 @@ class EnercoopOperation(models.Model):
# ------------------------------------------------------
# ------------------------------------------------------
# Functions to manage route
# Functions to manage route
# ------------------------------------------------------
# ------------------------------------------------------
def
graph_view_conso
(
self
,
scale
=
None
,
date_start
=
None
,
date_end
=
None
):
def
graph_view_conso
(
self
,
scale
=
None
,
date_start
=
None
,
date_end
=
None
,
prm_id
=
None
):
"""
"""
Fonction appelée pour l
'
affichage des courbes consommation
Fonction appelée pour l
'
affichage des courbes consommation
sur le portail
sur le portail
...
@@ -553,7 +686,7 @@ class EnercoopOperation(models.Model):
...
@@ -553,7 +686,7 @@ class EnercoopOperation(models.Model):
scale
=
self
.
get_scale
(
date_start
,
date_end
)
scale
=
self
.
get_scale
(
date_start
,
date_end
)
# Get the data to display in chart
# Get the data to display in chart
chart_data
=
self
.
get_cdc
(
scale
,
date_start
,
date_end
)
chart_data
=
self
.
get_cdc
(
scale
,
date_start
,
date_end
,
prm_id
)
# Build the chart depending on data calculated
# Build the chart depending on data calculated
result_graph
=
self
.
chart_data_cons
(
chart_data
)
result_graph
=
self
.
chart_data_cons
(
chart_data
)
...
@@ -572,7 +705,7 @@ class EnercoopOperation(models.Model):
...
@@ -572,7 +705,7 @@ class EnercoopOperation(models.Model):
})
})
return
result_graph
return
result_graph
def
graph_view_prod
(
self
,
scale
=
None
,
date_start
=
None
,
date_end
=
None
):
def
graph_view_prod
(
self
,
scale
=
None
,
date_start
=
None
,
date_end
=
None
,
prm_id
=
None
):
"""
"""
Fonction appelée pour l
'
affichage des courbes production
Fonction appelée pour l
'
affichage des courbes production
sur le portail
sur le portail
...
@@ -592,7 +725,7 @@ class EnercoopOperation(models.Model):
...
@@ -592,7 +725,7 @@ class EnercoopOperation(models.Model):
scale
=
self
.
get_scale
(
date_start
,
date_end
)
scale
=
self
.
get_scale
(
date_start
,
date_end
)
# Get the data to display in chart
# Get the data to display in chart
chart_data
=
self
.
get_cdc
(
scale
,
date_start
,
date_end
)
chart_data
=
self
.
get_cdc
(
scale
,
date_start
,
date_end
,
prm_id
)
# Build the chart depending on data calculated
# Build the chart depending on data calculated
result_graph
=
self
.
chart_data_prod
(
chart_data
)
result_graph
=
self
.
chart_data_prod
(
chart_data
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
static/src/js/operation_graph.js
+
1
−
7
Voir le fichier @
e676cadf
...
@@ -83,13 +83,6 @@ odoo.define('enercoop_cdc.operation_graph', function (require) {
...
@@ -83,13 +83,6 @@ odoo.define('enercoop_cdc.operation_graph', function (require) {
Object
.
assign
({},
result
.
line_chart_conso_line
,
options_line
)
Object
.
assign
({},
result
.
line_chart_conso_line
,
options_line
)
);
);
}
}
// else {
// var chart = new Chart(
// line_conso,
// Object.assign({}, result.line_chart_conso, options)
// );
// }
console
.
log
(
chart
);
var
chart
=
new
Chart
(
var
chart
=
new
Chart
(
donuts_conso
,
donuts_conso
,
...
@@ -100,6 +93,7 @@ odoo.define('enercoop_cdc.operation_graph', function (require) {
...
@@ -100,6 +93,7 @@ odoo.define('enercoop_cdc.operation_graph', function (require) {
histo_conso
,
histo_conso
,
Object
.
assign
({},
result
.
histo_chart_conso
,
options_stacked
)
Object
.
assign
({},
result
.
histo_chart_conso
,
options_stacked
)
);
);
console
.
log
(
chart
);
if
(
result
.
scale
==
'
week
'
||
result
.
scale
==
'
day
'
){
if
(
result
.
scale
==
'
week
'
||
result
.
scale
==
'
day
'
){
var
chart
=
new
Chart
(
var
chart
=
new
Chart
(
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter