+
+
+
+
+
+
+
+
+
@@ -26,13 +47,49 @@
diff --git a/mondumas/views/parametres.py b/mondumas/views/parametres.py
index 2831831..830a260 100644
--- a/mondumas/views/parametres.py
+++ b/mondumas/views/parametres.py
@@ -656,6 +656,11 @@ def stats_delais(request):
# debut = aujourd'hui - 12 mois
datedeb = datefin + relativedelta(months=-12)
+ societes = ['PE','ME','PL']
+ # si societe a été changé par le user
+ if 'societe' in request.params:
+ societe = request.params["societe"]
+
# lire les groupes
groupes = get_stats_delai_groupe(request, societe, datedeb, datefin)
# mémoriser le 1er de la liste
@@ -666,22 +671,66 @@ def stats_delais(request):
groupe = request.params["groupe"]
# lire les délais CONTACT du groupe
- items = get_stats_delais(request, societe, datedeb, datefin, groupe)
- barChart_annee=[]
- barChart_annee.append(('Mois', groupe, {'role': 'annotation'}, 'Moyenne'))
- title = ''
+ items = get_stats_delais(request, societe, datedeb, datefin, groupe, 'delai_contact')
+ barChart_annee1 = []
+ barChart_annee1.append(('Mois', 'Moy. ' + groupe, {'role': 'annotation'}, { 'type':'string','role': 'tooltip'} , 'Moy. Dumas'))
+ title1 = '1er CONTACT'
for item in items:
# construire la liste pour donut cible
- title = '%s - %s' % (item.group2_lib, item.group2)
- d = (item.group1_lib[:4], round(item.moyenne), str(item.moyenne)+'j ('+str(item.population)+')', round(item.moy_ref))
- barChart_annee.append(d)
+ tooltip = item.group1_lib + '\nMoyennne: -'+str(round(item.moyenne))+' j\nDossiers: '+str(round(item.population))
+ # ('+str(item.population)+')/n'
+ d = (item.group1_lib[:3], round(item.moyenne), str(round(item.moyenne))+'j', tooltip, round(item.moy_ref))
+ barChart_annee1.append(d)
+ # lire les délais RENDEZ-VOUS du groupe
+ items = get_stats_delais(request, societe, datedeb, datefin, groupe, 'delai_rdv')
+ barChart_annee2=[]
+ barChart_annee2.append(('Mois', 'Moy. ' + groupe, {'role': 'annotation'}, { 'type':'string','role': 'tooltip'} , 'Moy. Dumas'))
+ title2 = '1er RENDEZ-VOUS'
+ for item in items:
+ # construire la liste pour donut cible
+ tooltip = item.group1_lib + '\nMoyennne: -'+str(round(item.moyenne))+' j\nDossiers: '+str(round(item.population))
+ # ('+str(item.population)+')/n'
+ d = (item.group1_lib[:3], round(item.moyenne), str(round(item.moyenne))+'j', tooltip, round(item.moy_ref))
+ barChart_annee2.append(d)
+
+ # lire les délais DEVIS du groupe
+ items = get_stats_delais(request, societe, datedeb, datefin, groupe, 'delai_devis')
+ barChart_annee3=[]
+ barChart_annee3.append(('Mois', 'Moy. ' + groupe, {'role': 'annotation'}, { 'type':'string','role': 'tooltip'} , 'Moy. Dumas'))
+ title3 = '1er DEVIS'
+ for item in items:
+ # construire la liste pour donut cible
+ tooltip = item.group1_lib + '\nMoyennne: -'+str(round(item.moyenne))+' j\nDossiers: '+str(round(item.population))
+ # ('+str(item.population)+')/n'
+ d = (item.group1_lib[:3], round(item.moyenne), str(round(item.moyenne))+'j', tooltip, round(item.moy_ref))
+ barChart_annee3.append(d)
+
+ # lire les délais FACTURE du groupe
+ items = get_stats_delais(request, societe, datedeb, datefin, groupe, 'delai_facture')
+ barChart_annee4 = []
+ barChart_annee4.append(('Mois', 'Moy. ' + groupe, {'role': 'annotation'}, { 'type':'string','role': 'tooltip'} , 'Moy. Dumas'))
+ title4 = '1ère FACTURE'
+ for item in items:
+ # construire la liste pour donut cible
+ tooltip = item.group1_lib + '\nMoyennne: -'+str(round(item.moyenne))+' j\nDossiers: '+str(round(item.population))
+ # ('+str(item.population)+')/n'
+ d = (item.group1_lib[:3], round(item.moyenne), str(round(item.moyenne))+'j', tooltip, round(item.moy_ref))
+ barChart_annee4.append(d)
return {
- 'page_title': "Délais par groupe",
+ 'page_title': "Indices de performances",
'url': url,
- 'barChart_annee': json.dumps(barChart_annee),
- 'title': title,
+ 'barChart_annee1': json.dumps(barChart_annee1),
+ 'barChart_annee2': json.dumps(barChart_annee2),
+ 'barChart_annee3': json.dumps(barChart_annee3),
+ 'barChart_annee4': json.dumps(barChart_annee4),
+ 'title1': title1,
+ 'title2': title2,
+ 'title3': title3,
+ 'title4': title4,
+ 'societes': societes,
+ 'societe': societe,
'groupes': groupes,
'groupe': groupe,
}
diff --git a/mondumas/views/utils.py b/mondumas/views/utils.py
index 47f213b..c998cbc 100644
--- a/mondumas/views/utils.py
+++ b/mondumas/views/utils.py
@@ -9,6 +9,7 @@ from pyramid_mailer.message import Message, Attachment
from time import sleep
from datetime import *
+from dateutil.relativedelta import *
from ..models.utils import *
@@ -176,7 +177,18 @@ def batch_test(request):
# à revoir
# update_chantiers_status(request)
- update_chantiers_delais(request, '2020/12/01')
+ # update_chantiers_delais(request, '2020/12/01')
+ # calculer les délais de traitements des dossiers sur 1 an
+ societes = ['PL', 'ME', 'PE']
+ datejour = date.today()
+ groupes = ['MAIF', 'AXA', 'X']
+ for i in range(12):
+ for societe in societes:
+ for groupe in groupes:
+ update_stats_delais(request, societe, datejour.strftime('%Y%m%d'), groupe)
+ # recule d'un mois
+ datejour = datejour + relativedelta(months=-1)
+
return Response('Batch nuit terminé OK')