|
@@ -248,47 +248,131 @@ async def optim(request: Request, Authorize: AuthJWT = Depends()):
|
|
|
total = 0
|
|
|
flowchange = 0
|
|
|
|
|
|
- for temp in db.query(statement):
|
|
|
- print(temp['value'])
|
|
|
- x=temp['value']
|
|
|
- statement2 = 'SELECT value FROM record_tower WHERE record_tower.key = "coldTempData2"'
|
|
|
- for temp2 in db.query(statement2):
|
|
|
- print(temp2['value'])
|
|
|
- y=temp2['value']
|
|
|
- statement3 = 'SELECT value FROM record_tower WHERE record_tower.key = "wetTemp"'
|
|
|
- for temp3 in db.query(statement3):
|
|
|
- print(temp3['value'])
|
|
|
- z=temp3['value']
|
|
|
- statement4 = 'SELECT value FROM record_tower WHERE record_tower.key = "count"'
|
|
|
- for tower in db.query(statement4):
|
|
|
- print(tower['value'])
|
|
|
- count=tower['value']
|
|
|
- statement5 = 'SELECT value FROM record_tower WHERE record_tower.key = "waterflow"'
|
|
|
- for tower in db.query(statement5):
|
|
|
- waterflow=tower['value']
|
|
|
- statement6 = 'SELECT value FROM record_tower WHERE record_tower.key = "fannum"'
|
|
|
- for tower in db.query(statement6):
|
|
|
- fannum=tower['value']
|
|
|
- statement7 = 'SELECT value FROM record_tower WHERE record_tower.key = "flowchange"'
|
|
|
- for tower in db.query(statement7):
|
|
|
- flowchange=tower['value']
|
|
|
- statement8 = 'SELECT value FROM record_tower WHERE record_tower.key = "savewater"'
|
|
|
- for tower in db.query(statement8):
|
|
|
- savewater=tower['value']
|
|
|
- statement9 = 'SELECT value FROM record_tower WHERE record_tower.key = "fanchange"'
|
|
|
- for tower in db.query(statement9):
|
|
|
- fanchange=tower['value']
|
|
|
- statement10 = 'SELECT value FROM record_tower WHERE record_tower.key = "saveelec"'
|
|
|
- for tower in db.query(statement10):
|
|
|
- saveelec=tower['value']
|
|
|
- statement11 = 'SELECT value FROM record_tower WHERE record_tower.key = "total"'
|
|
|
- for tower in db.query(statement11):
|
|
|
- total=tower['value']
|
|
|
try:
|
|
|
Authorize.jwt_required()
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return RedirectResponse('/login')
|
|
|
+ current_user = Authorize.get_jwt_subject()
|
|
|
+ print(check_role_type(current_user))
|
|
|
+ role = int(check_role_type(current_user))
|
|
|
+ print(check_role_type(current_user))
|
|
|
+ if role == 1:
|
|
|
+ statement = 'SELECT value FROM record_tower WHERE record_tower.key = "hotTemp"'
|
|
|
+ for temp in db.query(statement):
|
|
|
+ print(temp['value'])
|
|
|
+ x=temp['value']
|
|
|
+ statement2 = 'SELECT value FROM record_tower WHERE record_tower.key = "coldTempData1"'
|
|
|
+ for temp2 in db.query(statement2):
|
|
|
+ print(temp2['value'])
|
|
|
+ y=temp2['value']
|
|
|
+ statement3 = 'SELECT value FROM record_tower WHERE record_tower.key = "wetTemp"'
|
|
|
+ for temp3 in db.query(statement3):
|
|
|
+ print(temp3['value'])
|
|
|
+ z=temp3['value']
|
|
|
+ statement4 = 'SELECT value FROM record_tower WHERE record_tower.key = "count"'
|
|
|
+ for tower in db.query(statement4):
|
|
|
+ print(tower['value'])
|
|
|
+ count=tower['value']
|
|
|
+ statement5 = 'SELECT value FROM record_tower WHERE record_tower.key = "waterflow"'
|
|
|
+ for tower in db.query(statement5):
|
|
|
+ waterflow=tower['value']
|
|
|
+ statement6 = 'SELECT value FROM record_tower WHERE record_tower.key = "fannum"'
|
|
|
+ for tower in db.query(statement6):
|
|
|
+ fannum=tower['value']
|
|
|
+ statement7 = 'SELECT value FROM record_tower WHERE record_tower.key = "flowchange"'
|
|
|
+ for tower in db.query(statement7):
|
|
|
+ flowchange=tower['value']
|
|
|
+ statement8 = 'SELECT value FROM record_tower WHERE record_tower.key = "savewater"'
|
|
|
+ for tower in db.query(statement8):
|
|
|
+ savewater=tower['value']
|
|
|
+ statement9 = 'SELECT value FROM record_tower WHERE record_tower.key = "fanchange"'
|
|
|
+ for tower in db.query(statement9):
|
|
|
+ fanchange=tower['value']
|
|
|
+ statement10 = 'SELECT value FROM record_tower WHERE record_tower.key = "saveelec"'
|
|
|
+ for tower in db.query(statement10):
|
|
|
+ saveelec=tower['value']
|
|
|
+ statement11 = 'SELECT value FROM record_tower WHERE record_tower.key = "total"'
|
|
|
+ for tower in db.query(statement11):
|
|
|
+ total=tower['value']
|
|
|
+ elif role == 3 :
|
|
|
+ statement = 'SELECT value FROM record_tower WHERE record_tower.key = "hotTemp1"'
|
|
|
+ for temp in db.query(statement):
|
|
|
+ print(temp['value'])
|
|
|
+ x=temp['value']
|
|
|
+ statement2 = 'SELECT value FROM record_tower WHERE record_tower.key = "coldTempData2"'
|
|
|
+ for temp2 in db.query(statement2):
|
|
|
+ print(temp2['value'])
|
|
|
+ y=temp2['value']
|
|
|
+ statement3 = 'SELECT value FROM record_tower WHERE record_tower.key = "wetTemp1"'
|
|
|
+ for temp3 in db.query(statement3):
|
|
|
+ print(temp3['value'])
|
|
|
+ z=temp3['value']
|
|
|
+ statement4 = 'SELECT value FROM record_tower WHERE record_tower.key = "count1"'
|
|
|
+ for tower in db.query(statement4):
|
|
|
+ print(tower['value'])
|
|
|
+ count=tower['value']
|
|
|
+ statement5 = 'SELECT value FROM record_tower WHERE record_tower.key = "waterflow1"'
|
|
|
+ for tower in db.query(statement5):
|
|
|
+ waterflow=tower['value']
|
|
|
+ statement6 = 'SELECT value FROM record_tower WHERE record_tower.key = "fannum1"'
|
|
|
+ for tower in db.query(statement6):
|
|
|
+ fannum=tower['value']
|
|
|
+ statement7 = 'SELECT value FROM record_tower WHERE record_tower.key = "flowchange1"'
|
|
|
+ for tower in db.query(statement7):
|
|
|
+ flowchange=tower['value']
|
|
|
+ statement8 = 'SELECT value FROM record_tower WHERE record_tower.key = "savewater1"'
|
|
|
+ for tower in db.query(statement8):
|
|
|
+ savewater=tower['value']
|
|
|
+ statement9 = 'SELECT value FROM record_tower WHERE record_tower.key = "fanchange1"'
|
|
|
+ for tower in db.query(statement9):
|
|
|
+ fanchange=tower['value']
|
|
|
+ statement10 = 'SELECT value FROM record_tower WHERE record_tower.key = "saveelec1"'
|
|
|
+ for tower in db.query(statement10):
|
|
|
+ saveelec=tower['value']
|
|
|
+ statement11 = 'SELECT value FROM record_tower WHERE record_tower.key = "total1"'
|
|
|
+ for tower in db.query(statement11):
|
|
|
+ total=tower['value']
|
|
|
+ elif role == 4 :
|
|
|
+ statement = 'SELECT value FROM record_tower WHERE record_tower.key = "hotTemp2"'
|
|
|
+ for temp in db.query(statement):
|
|
|
+ print(temp['value'])
|
|
|
+ x=temp['value']
|
|
|
+ statement2 = 'SELECT value FROM record_tower WHERE record_tower.key = "coldTempData3"'
|
|
|
+ for temp2 in db.query(statement2):
|
|
|
+ print(temp2['value'])
|
|
|
+ y=temp2['value']
|
|
|
+ statement3 = 'SELECT value FROM record_tower WHERE record_tower.key = "wetTemp2"'
|
|
|
+ for temp3 in db.query(statement3):
|
|
|
+ print(temp3['value'])
|
|
|
+ z=temp3['value']
|
|
|
+ statement4 = 'SELECT value FROM record_tower WHERE record_tower.key = "count2"'
|
|
|
+ for tower in db.query(statement4):
|
|
|
+ print(tower['value'])
|
|
|
+ count=tower['value']
|
|
|
+ statement5 = 'SELECT value FROM record_tower WHERE record_tower.key = "waterflow2"'
|
|
|
+ for tower in db.query(statement5):
|
|
|
+ waterflow=tower['value']
|
|
|
+ statement6 = 'SELECT value FROM record_tower WHERE record_tower.key = "fannum2"'
|
|
|
+ for tower in db.query(statement6):
|
|
|
+ fannum=tower['value']
|
|
|
+ statement7 = 'SELECT value FROM record_tower WHERE record_tower.key = "flowchange2"'
|
|
|
+ for tower in db.query(statement7):
|
|
|
+ flowchange=tower['value']
|
|
|
+ statement8 = 'SELECT value FROM record_tower WHERE record_tower.key = "savewater2"'
|
|
|
+ for tower in db.query(statement8):
|
|
|
+ savewater=tower['value']
|
|
|
+ statement9 = 'SELECT value FROM record_tower WHERE record_tower.key = "fanchange2"'
|
|
|
+ for tower in db.query(statement9):
|
|
|
+ fanchange=tower['value']
|
|
|
+ statement10 = 'SELECT value FROM record_tower WHERE record_tower.key = "saveelec2"'
|
|
|
+ for tower in db.query(statement10):
|
|
|
+ saveelec=tower['value']
|
|
|
+ statement11 = 'SELECT value FROM record_tower WHERE record_tower.key = "total2"'
|
|
|
+ for tower in db.query(statement11):
|
|
|
+ total=tower['value']
|
|
|
+ else :
|
|
|
+ print("noright")
|
|
|
return templates.TemplateResponse(name='optim.html',context=
|
|
|
{
|
|
|
'request': request,"x":x,"y":y,"z":z,"count":count,"waterflow":waterflow
|