Просмотр исходного кода

Merge branch 'ZJZGJ' of http://www.sri-robot.cn:30000/SRI-DINO/Server-py into ZJZGJ

Casper 2 месяцев назад
Родитель
Сommit
ef86f7f453

+ 1 - 3
sri-server-bg01/hub.py

@@ -16,9 +16,7 @@ class Global(object):
     #                                                            database='vms')
 
     # --- 业务数据数据库 ---
-    # mdb = importlib.import_module(f"clients.db_mongo").Client(host='sri-thirdparty-mongo', port=27017, database='ar',
-    #                                                           username='admin', password='admin')
-    mdb = importlib.import_module(f"xclient.xmongo").Client(host='58.34.94.176', port=7030, database='bg',
+    mdb = importlib.import_module(f"xclient.xmongo").Client(host='127.0.0.1', port=27017, database='bg',
                                                             username='admin', password='admin')
     # mysql = importlib.import_module(f"clients.db_maria2").Client(host='127.0.0.1', port=3306, database='ar',
     #                                                              username='root', password='20221212!')

+ 4 - 2
sri-server-bg01/test/test-1000.py

@@ -1,7 +1,8 @@
 import requests
 
 # --- test 获取token ---
-url = 'http://58.34.94.177:29101/v1/token'
+# url = 'http://58.34.94.177:29101/v1/token'
+url = 'http://127.0.0.1:9000/v1/token'
 data = {
     'username': 'admin',  # 登录账户
     'password': '123456',  # 登录密码
@@ -42,7 +43,8 @@ token = response.headers.get('authorization')
 # print(response.json())
 
 # --- test 1002 查询用户列表 ---
-url = 'http://58.34.94.177:29101/v6/api'
+# url = 'http://58.34.94.177:29101/v6/api'
+url = 'http://127.0.0.1:9000/v6/api'
 data = {
     'code': 1002,  # 接口号
     'page': 1,  # 页码

+ 4 - 2
sri-server-bg01/test/test-2000.py

@@ -1,7 +1,8 @@
 import requests
 
 # --- test 获取token ---
-url = 'http://58.34.94.177:29101/v1/token'
+# url = 'http://58.34.94.177:29101/v1/token'
+url = 'http://127.0.0.1:9000/v1/token'
 data = {
     'username': 'admin',  # 用户名
     'password': '123456',  # 密码
@@ -97,7 +98,8 @@ token = response.headers.get('authorization')
 # print(response.json())
 
 # --- test 2007 获取指定作业车辆详情 ---
-url = 'http://58.34.94.177:29101/v6/api'
+# url = 'http://58.34.94.177:29101/v6/api'
+url = 'http://127.0.0.1:9000/v6/api'
 data = {
     'code': 2007,  # 接口号
     'uuid': '65de9fa044b74ae33732d811',  # 车辆id(必须项)

+ 2 - 1
sri-server-bg01/test/test-3000.py

@@ -1,7 +1,8 @@
 import requests
 
 # --- test 获取token ---
-url = 'http://58.34.94.177:29101/v1/token'
+# url = 'http://58.34.94.177:29101/v1/token'
+url = 'http://127.0.0.1:9000/v1/token'
 data = {
     'username': 'admin',  # 用户名
     'password': '123456',  # 密码

+ 3 - 3
sri-server-bg02/hub.py

@@ -8,10 +8,10 @@ methods = importlib.import_module(f"xlib")
 
 class Global(object):
     # --- 中间件服务器 ---
-    emqx = importlib.import_module(f"xclient.xmqtt").Client(host='10.10.61.229', port=41883)
+    emqx = importlib.import_module(f"xclient.xmqtt").Client(host='127.0.0.1', port=41883)
 
     aps = importlib.import_module(f"xpip.xapscheduler").APS(db_type='mongo',
-                                                            db_host='58.34.94.176',
-                                                            db_port=7030,
+                                                            db_host='127.0.0.1',
+                                                            db_port=27017,
                                                             username='admin', password='admin',
                                                             database='bg', collection='LoopTask')

+ 9 - 2
sri-server-bg02/lib/JobManage.py

@@ -19,7 +19,7 @@ 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.job101_on_windows, 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
 
@@ -29,7 +29,14 @@ class JobManage(object):
         Global.aps.pause_all()
 
     @staticmethod
-    def job101():
+    def job101_on_windows():
+        """
+        每日22点清理30天之前的日志
+        """
+        pass
+
+    @staticmethod
+    def job101_on_linux():
         """
         每日22点清理30天之前的日志
         """

+ 2 - 1
sri-server-bg02/lib/MessageListener.py

@@ -6,7 +6,8 @@ import json
 
 
 class MessageListener(object):
-    """音柱循环检查"""
+    """
+    """
 
     @staticmethod
     def decorate_method(client, userdata, message):

+ 0 - 159
sri-server-bg02/lib/sound_columns.py

@@ -1,159 +0,0 @@
-from hub import methods, Global
-
-import threading
-import time
-
-
-class SoundColumns(object):
-    """音柱循环检查"""
-
-    mdb = Global.get_mongodb_client()
-    api = Global.get_audio_client()
-
-    @classmethod
-    def get_mp3_name_dict(cls):
-        mp3_name_dict = dict()
-        """
-        FaceType: 人脸类型表
-        FaceType.name: 类型名称
-        FaceType.mp3_name: 音频名称
-        """
-        for item in Global.mdb.get_all('FaceType'):
-            uuid = str(item.get('_id'))
-            mp3_name_dict[uuid] = item.get('mp3_name')
-        return mp3_name_dict
-
-    @classmethod
-    def get_column_service_url_and_sn(cls):
-        """
-        获取音柱信息 todo 建议增加ip校验
-        """
-        unique_dict = {'name': 'AudioConfig'}
-        item = cls.mdb.get_one('GlobalVariable', unique_dict)
-        data = item.get('args', {})
-        audio_sn = data.get('audio_sn')
-        audio_url = f"http://{data.get('audio_ipv4')}:{data.get('audio_port')}"
-        audio_vol = data.get('audio_vol')
-        return audio_url, audio_sn, audio_vol
-
-    @classmethod
-    def get_host_ip(cls):
-        """
-        获取本机ip
-        """
-        unique_dict = {'name': 'HostIpConfig'}
-        item = cls.mdb.get_one('GlobalVariable', unique_dict)
-        data = item.get('args', {})
-        host_ip = data.get('ipv4')
-
-        # --- check ---
-        if not host_ip:
-            ssh = Global.SSHClient('172.18.0.1', 22, 'server', 'server')
-            out = ssh.run_command("ifconfig")
-            for row in out.split('\n\n'):
-                if not row.startswith('eth0'):  # eth0 enp0s3
-                    continue
-                for one in row.split('\n'):
-                    one = one.strip()
-                    if one[:4] != 'inet':
-                        continue
-                    if one[:5] == 'inet6':
-                        continue
-                    one = [i for i in one.split(' ') if i]
-                    ipv4, netmask = one[1], one[3]
-                    host_ip = ipv4
-        return host_ip
-
-    @classmethod
-    def check_loop(cls):
-
-        # --- define ---
-        last_send_id = str()
-
-        while True:
-
-            # --- check --- 检查是否配置音柱
-            # while True:
-            #     unique_dict = {'name': 'AudioConfig'}
-            #     item = cls.mdb.get_one('GlobalVariable', unique_dict)
-            #     data = item.get('args', {})
-            #     audio_ipv4 = data.get('audio_ipv4')
-            #     if audio_ipv4:
-            #         break
-            #     else:
-            #         time.sleep(60)
-
-            try:
-
-                # --- get send_data ---
-                send_data = Global.rdb.get_one(key='send_data')
-
-                # --- check ---
-                if not send_data:
-                    continue
-
-                # --- check ---
-                send_id = send_data.get('send_id')
-                if not send_id:
-                    continue
-
-                # --- check ---
-                if send_id == last_send_id:
-                    continue
-
-                # --- check ---
-                """
-                send_list = [
-                    {
-                        base_face_uuid: 底库人脸id
-                        snap_face_image: 抓拍人脸
-                        base_face_image_path: 底库人脸路径
-                        face_similarity: 相似度
-                    }
-                ]
-                """
-                send_list = send_data.get('send_list')
-                if send_list is None or len(send_list) == 0:
-                    continue
-
-                # --- debug ---
-                # methods.debug_log(f"SoundColumns", f"m-122: run at {methods.now_string()} "
-                #                                    f"| send count is {len(send_list)} ")
-
-                # --- update ---
-                last_send_id = send_id
-
-                # --- call --- todo 建议界面上添加个开关,是否启用音响
-                """增加音柱配置写活"""
-                audio_url, audio_sn, audio_vol = cls.get_column_service_url_and_sn()
-                cls.api.api_service_url = audio_url
-                # cls.api.sn = audio_sn
-                cls.api.vol = audio_vol
-
-                host_ip = cls.get_host_ip()
-                cls.api.file_service_url = f'http://{host_ip}:9900'
-                methods.debug_log(f"SoundColumns", f"m-96: file_service_url -> {cls.api.file_service_url}")
-
-                for data in send_list:
-                    result_type = data.get('result_type')
-                    # result = cls.api.call_audio_make_sound_v3(result_type)
-                    result = cls.api.call_audio_make_sound_v4(result_type)
-                    methods.debug_log(f"SoundColumns", f"m-131: result is {result} | run at {methods.now_string()} |"
-                                                       f"send count is {len(send_list)}")
-
-            except Exception as exception:
-
-                methods.debug_log('SoundColumns', f"m-153: exception | {exception}")
-                methods.debug_log('SoundColumns', f"m-153: wait 10 minutes try again!")
-                time.sleep(600)
-                continue
-
-    @classmethod
-    def run_background(cls, is_back_run=True):
-        """"""
-        p1 = threading.Thread(target=cls.check_loop)
-        p1.start()
-
-
-if __name__ == '__main__':
-    SoundColumns.run_background()