casper 1 tháng trước cách đây
mục cha
commit
71c55961c5

+ 0 - 1
sri-server-bg01/api/v6/code1000.py

@@ -89,7 +89,6 @@ async def code1002(**sources):
         item['role_type'] = str(item.get('role_type'))
         item['sex'] = str(item.get('sex'))
         item['state'] = str(item.get('state'))
-
         item['uuid'] = str(item.get('_id'))
         item.pop('_id')
         item.pop('password')

+ 2 - 4
sri-server-bg01/key/v1.py

@@ -71,6 +71,8 @@ async def get_token(request: Request, response: Response):
         }
         Global.mdb.add('UserLoginLog', data)
         code = 3
+    elif int(user.get('state')) == 1:
+        code = 4
     else:
         data = {
             'username': username,
@@ -94,10 +96,6 @@ async def get_token(request: Request, response: Response):
     }
     token = serializer.dumps(data).decode('utf-8')
     content = dict(
-        # message='authorization passed.',
-        # username=username,
-        # uid=str(user['_id']),
-        # rid=user.get('role_id'), code=0
         code=0,
         message='authorization passed.',
         data={

+ 8 - 4
sri-server-bg02/lib/JobManage.py

@@ -26,9 +26,10 @@ class JobManage(object):
         # Global.aps.create_job(func=cls.job20102, trigger='date', run_date='2022-07-28 17:15:30')  # 定时测试
 
         # --- release ---
-        Global.aps.create_job(func=cls.job101, trigger='cron', hour=22)  # 每天晚10点  release
-        # Global.aps.create_job(func=cls.job20102, trigger='interval', seconds=600)  # 每10分钟  release
-        # Global.aps.create_job(func=cls.job301, trigger='interval', seconds=300)  # 每5分钟  release
+        # Global.aps.create_job(func=cls.job101, trigger='cron', hour=22)  # 每天晚10点 
+        Global.aps.create_job(func=cls.job101, trigger='interval', seconds=600)  # 每10分钟 
+        # Global.aps.create_job(func=cls.job101, trigger='interval', seconds=300)  # 每5分钟 
+        # Global.aps.create_job(func=cls.job101, trigger='interval', seconds=3600)  # 每1小时 
 
     @classmethod
     def end(cls):
@@ -44,6 +45,9 @@ class JobManage(object):
 
         todo 根据UserWorkRecordList.start_at来判断过去7天的数据
         """
+        # --- log ---
+        methods.debug_log("JobManage|49", f"------------------------------ start")
+
         # --- get log_file_uuid_list ---
         log_file_list = methods.get_file_path_list(save_dir)
         log_file_name_list = [i.split('\\')[-1] for i in log_file_list]
@@ -54,7 +58,7 @@ class JobManage(object):
             
             # --- check ---
             file_path = os.path.join(save_dir, f"{log_file_uuid}.log")
-            item = Global.mdb.get_one_by_id('UserWorkRecordList', log_file_uuid)
+            item = Global.mdb.updage_one_by_id('UserWorkRecordList', log_file_uuid)
             if not item:
                 methods.remove_file(file_path)
 

+ 15 - 8
sri-server-bg02/lib/MessageListenerC001.py

@@ -1,6 +1,7 @@
 from hub import methods, Global
 
 import threading
+import traceback
 import time
 import json
 import os
@@ -73,20 +74,26 @@ def method_c001(client, userdata, message):
     """
     # --- print ---
     # methods.debug_log(f"method_c001|75", f"#message.payload: {message.payload}")
-    # log_dict = json.loads(message.payload)
-    # try:
-    #     log_dict = json.loads(message.payload)
-    #     methods.debug_log(f"MessageListenerC001|19", f"#message.payload: {repr(log_dict)}")
-    # except Exception as e:
-    #     pass
+    try:
+        log_dict = json.loads(message.payload)
+    except Exception as exception:
+        methods.debug_log("method_c001|79", f"#message.payload: {message.payload}")
+        methods.debug_log("method_c001|79", f"#exception: {exception.__class__.__name__}")
+        methods.debug_log("method_c001|79", f"#traceback: {traceback.format_exc()}")
+        return
 
-    # --- fill log_list ---
-    log_dict = json.loads(message.payload)
+    # --- check ---
+    # log_dict = json.loads(message.payload)
     log_time = int(log_dict.get('timeStamp')) / 1000
     user_uuid = log_dict.get('userID')
     vehicle_id = log_dict.get('vehicleID')
     cockpit_id = log_dict.get('cockpitID')
     log_uuid = UserWorkRecord.get_log_uuid(user_uuid, log_time, vehicle_id, cockpit_id)
+    methods.debug_log(f"method_c001|92", f"user_uuid: {user_uuid}, log_time: {log_time}")
+    if not log_uuid:
+        return
+
+    # --- fill log_list ---
     log_list = [
 
         f"timeStamp: {methods.ts_to_string(log_time)}",  # 时间

+ 2 - 2
sri-server-bg02/lib/UserWorkRecord.py

@@ -39,8 +39,8 @@ class UserWorkRecord(object):
         """
         # --- check ---
         if not user_uuid or not log_time:
-            methods.debug_log(f"UserWorkRecord|40", f"#error40")
-            return 'error40'
+            methods.debug_log(f"UserWorkRecord|40", f"#error40, user_uuid: {user_uuid}, log_time: {log_time}")
+            return None
 
         # --- check ---
         r1 = user_uuid not in cls.users or log_time > cls.users[user_uuid].get('end_at') + 300  # 距离上次操作间隔300s,当做新的记录

+ 3 - 1
sri-server-bg03/lib/Connection_e1.py

@@ -295,7 +295,9 @@ class SRIConnection(asyncio.Protocol):
         uuid = ''
         if not user:
             ret = False
-        elif not check_password_hash(user['password'], object.password):
+        elif not check_password_hash(user.get('password'), object.password):
+            ret = False
+        elif int(user.get('state')) == 1:
             ret = False
         else:
             name = user.get('name')