diff --git a/db_logic/control_log.py b/db_logic/control_log.py index de91850..0d9d146 100644 --- a/db_logic/control_log.py +++ b/db_logic/control_log.py @@ -3,12 +3,14 @@ ''' @Date:2022/07/18 16:41:18 ''' +import sys +sys.path.append(".") import json import datetime from sqlalchemy import or_, desc from db_logic.db_base import Repository from models.log_models import EntityLog -from common.utils import Utils +from Common.Utils import Utils from db_logic.user import BllUser #日志信息业务逻辑类 diff --git a/db_logic/user.py b/db_logic/user.py index 5b53386..74be613 100644 --- a/db_logic/user.py +++ b/db_logic/user.py @@ -24,7 +24,12 @@ class BllUser(Repository): #用户账号密码登录 def login(self, user_name, password): - user_info = self.findEntity(EntityUser.account == user_name) + user_info = self.findEntity( + or_( + EntityUser.account == user_name, + EntityUser.user_code == user_name + ) + ) if user_info: if user_info.is_enabled: if user_info.check_password(password): diff --git a/demo.py b/demo.py index 98e03ab..8338591 100644 --- a/demo.py +++ b/demo.py @@ -351,4 +351,18 @@ dic = {"bar_code":"789654","by_user_date":"","by_user_id":"","by_user_name":""," # for k,v in dic.items(): # if v == "": # dic.pop(k) -# print(dic) \ No newline at end of file +# print(dic) +data_list = [{"t1":0, "t2":2, "t3": 1}, {"t1":None, "t2":1, "t3": 1}] +new_data_list = [] +for i in data_list: + new_dic = {} + for k, v in i.items(): + if not v: + v = 0 + new_dic[k] = v + new_li = list(new_dic.values()) + new_dic.update(**{ + "t4": int(new_li[1]) - int(new_li[2]) + }) + new_data_list.append(new_dic) +print(new_data_list) \ No newline at end of file diff --git a/models/humiture_models.py b/models/humiture_models.py index efde902..7508659 100644 --- a/models/humiture_models.py +++ b/models/humiture_models.py @@ -22,6 +22,7 @@ class EntityHumitureRecord(Base): client_name = Column(String(50), comment='终端名称') # 终端名称 customer_id = Column(String(50), comment='客户id') # 客户ID temperature = Column(Float, comment='温度值') # 温度值 + temperature1 = Column(Float, comment='温度值') # 温度值 humidity = Column(Float, comment='湿度值') # 湿度值 voc_content = Column(Float, comment='voc含量') # voc含量 record_date = Column(String(50), comment='记录日期') # 记录日期