Commit db2e0f0c authored by JonathanMM's avatar JonathanMM

Retrait de la station DeleteMe…

parent 3241d4f6
......@@ -38,43 +38,44 @@ def getAllStation():
for etatStation in data:
infoStation = etatStation['station']
codeStation = int(infoStation['code'])
if codeStation not in stations:
longitude = infoStation['gps']['longitude']
latitude = infoStation['gps']['latitude']
if infoStation['state'] != 'Operative' :
strDateOuverture = 'NULL'
else:
strDateOuverture = 'CURDATE()'
requete = mysql.cursor()
requete.execute('INSERT INTO stations (code, name, longitude, latitude, type, dateOuverture, adresse) VALUES \
('+str(codeStation)+', "'+str(infoStation['name'])+'", '+str(longitude)+', '+str(latitude)+', "'+str(infoStation['type'])+'", '+strDateOuverture+', "'+getAdresse(latitude, longitude)+'")')
stations.append(codeStation)
#Et on prend les infos de l'état actuel de la station
ok = True
if infoStation['state'] == 'Work in progress' and codeStation == 10006:
#Exception pour le moment sur cette station
ok = False
if ok:
nbEDock = etatStation['nbDock']+etatStation['nbEDock']
requete = mysql.cursor()
requete.execute('INSERT INTO status (code, idConso, state, nbBike, nbEBike, nbFreeEDock, nbEDock, nbBikeOverflow, nbEBikeOverflow, maxBikeOverflow) VALUES \
('+str(codeStation)+', '+strIdConso+', "'+str(infoStation['state'])+'", '+str(etatStation['nbBike'])+', '+str(etatStation['nbEbike'])+', '+str((etatStation['nbFreeDock']+etatStation['nbFreeEDock']))+', '+str(nbEDock)+', '+str(etatStation['nbBikeOverflow'])+', '+str(etatStation['nbEBikeOverflow'])+', '+str(etatStation['maxBikeOverflow'])+')')
if codeStation > 0:
if codeStation not in stations:
longitude = infoStation['gps']['longitude']
latitude = infoStation['gps']['latitude']
if infoStation['state'] != 'Operative' :
strDateOuverture = 'NULL'
else:
strDateOuverture = 'CURDATE()'
requete = mysql.cursor()
requete.execute('INSERT INTO stations (code, name, longitude, latitude, type, dateOuverture, adresse) VALUES \
('+str(codeStation)+', "'+str(infoStation['name'])+'", '+str(longitude)+', '+str(latitude)+', "'+str(infoStation['type'])+'", '+strDateOuverture+', "'+getAdresse(latitude, longitude)+'")')
stations.append(codeStation)
#Et on prend les infos de l'état actuel de la station
ok = True
if infoStation['state'] == 'Work in progress' and codeStation == 10006:
#Exception pour le moment sur cette station
ok = False
#On met à jour la station au besoin
if codeStation in stationsFutur and nbEDock > 0:
if ok:
nbEDock = etatStation['nbDock']+etatStation['nbEDock']
requete = mysql.cursor()
requete.execute('UPDATE stations \
SET dateOuverture = CURDATE() WHERE code = '+str(codeStation))
requete.execute('INSERT INTO status (code, idConso, state, nbBike, nbEBike, nbFreeEDock, nbEDock, nbBikeOverflow, nbEBikeOverflow, maxBikeOverflow) VALUES \
('+str(codeStation)+', '+strIdConso+', "'+str(infoStation['state'])+'", '+str(etatStation['nbBike'])+', '+str(etatStation['nbEbike'])+', '+str((etatStation['nbFreeDock']+etatStation['nbFreeEDock']))+', '+str(nbEDock)+', '+str(etatStation['nbBikeOverflow'])+', '+str(etatStation['nbEBikeOverflow'])+', '+str(etatStation['maxBikeOverflow'])+')')
#On met à jour la station au besoin
if codeStation in stationsFutur and nbEDock > 0:
requete = mysql.cursor()
requete.execute('UPDATE stations \
SET dateOuverture = CURDATE() WHERE code = '+str(codeStation))
#On ajoute a la conso
nbTotalBike += int(etatStation['nbBike'])
nbTotalEBike += int(etatStation['nbEbike'])
nbTotalFreeEDock += int(etatStation['nbFreeDock'])+int(etatStation['nbFreeEDock'])
nbTotalEDock += int(etatStation['nbDock'])+int(etatStation['nbEDock'])
if infoStation['state'] == "Operative":
nbStationsOuvertes += 1
#On ajoute a la conso
nbTotalBike += int(etatStation['nbBike'])
nbTotalEBike += int(etatStation['nbEbike'])
nbTotalFreeEDock += int(etatStation['nbFreeDock'])+int(etatStation['nbFreeEDock'])
nbTotalEDock += int(etatStation['nbDock'])+int(etatStation['nbEDock'])
if infoStation['state'] == "Operative":
nbStationsOuvertes += 1
os.remove(tmpFileName)
#On insert tout dans le statut
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment