| 
					
				 | 
			
			
				@@ -185,7 +185,7 @@ async def optim(request: Request, Authorize: AuthJWT = Depends()): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/Water_tower?charset=utf8mb4') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     table=db['record_tower'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     temp = table.find_one(key = 'hotTemp') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     statement2 = 'SELECT  value FROM record_tower WHERE record_tower.key = "coldTempData2"' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    statement2 = 'SELECT  value FROM record_tower WHERE record_tower.key = "coldTempData2"' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for temp2 in db.query(statement2): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         print(temp2['value']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     statement3 = 'SELECT  value FROM record_tower WHERE record_tower.key = "wetTemp"' 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -253,10 +253,10 @@ async def get_member(request: Request, Authorize: AuthJWT = Depends()): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/Water_tower?charset=utf8mb4') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     statement = 'SELECT  id,username,isAdmin FROM users' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    json_dic = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    json_dic = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for row in db.query(statement): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         #print(row['id'],row['username']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        json_dic[row['username']] = {'isAdmin':row['isAdmin'],'roleType':check_role_acl(row['username'])} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        json_dic.append({'username':row['username'],'isAdmin':row['isAdmin'],'roleType':get_role_name(check_role_type(row['username'])) }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     result  = json.dumps(json_dic,ensure_ascii=False) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     current_user = Authorize.get_jwt_subject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return result 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -331,10 +331,9 @@ async def member_authority(request:Request,edit_one: int,Authorize: AuthJWT = De 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     current_user_roleType = check_role_type(current_user) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if edit_one == None: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return templates.TemplateResponse(name='notice.html', context={'"request":request,msg':'no role' }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return templates.TemplateResponse(name='notice.html', context={"request":request,'msg':'no role' }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     elif int(current_user_roleType)>int(edit_one) or int(current_user_roleType)==int(edit_one): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return templates.TemplateResponse(name='notice.html', context={"request":request,'msg':"沒有權限" }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     result = check_role_acl(edit_one) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if result == []: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -379,7 +378,7 @@ async def member_authority(request: Request): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if check_role_acl(edit_one.role_id) == []: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for module in row : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 new_dict = edit_one.get_acl_from_module_name(module) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                new_dict["id"]= pymysql.NULL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new_dict["id"]= None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 table = db['role_acl'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 table.insert(new_dict) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         else: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -634,6 +633,16 @@ def check_role_acl(role:int): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             result.append(dic) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def get_role_name(role_id:int): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/Water_tower?charset=utf8mb4') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    cmd = 'SELECT * FROM role where id = '+str(role_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    role:str 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for row in db.query(cmd) : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        role = row['name'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return role 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def get_user_under_organization(user_name:str): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """查看所屬公司""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/Water_tower?charset=utf8mb4') 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -766,10 +775,10 @@ def get_tower_info(tower_id:str): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     cmd = 'SELECT * FROM  `record_tower` where device_id = "'+tower_id+'"' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for row in db.query(cmd) : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         result['Fan'][row['key']]=row['value'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    result['Moter'] = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     cmd = 'SELECT * FROM  `vibration` where device_id = "'+tower_id+'"' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for row in db.query(cmd) : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        result['Moter'][row['channelName']]={'Vrms':row['DataValue'],'CV' :row['CVIndex']} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result['Moter'].append({'channel_name':row['channelName'],'Vrms':row['DataValue'],'CV' :row['CVIndex'],'threshold':row['threshold']}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |