Browse Source

```
feat(api): 添加调试日志输出功能

添加了调试打印语句用于查看API响应结果

fix(config): 更新开发环境配置

将host地址从127.0.0.1更新为10.56.42.17
将环境变量从prod改为dev

refactor(smart_shooter): 优化相机配置处理逻辑

改进了ISO配置的处理方式,通过CameraKey进行精确匹配
添加了空配置检查避免错误

feat(settings): 新增系统配置同步功能

实现了本地配置同步到线上的功能
添加了sync_sys_configs2Online方法

refactor(message_handler): 改进相机操作的消息处理

修改了相机预览和属性获取的消息处理器
通过point_name参数动态获取对应的CameraKey
增强了相机信息获取的功能
```

rambo 2 tuần trước cách đây
mục cha
commit
7c30d72b98

+ 1 - 0
python/api.py

@@ -1579,6 +1579,7 @@ def sync_action_configs(params: SyncLocalConfigs):
         )
         sync_url = settings.DOMAIN + "/api/ai_image/camera_machine/sync_actions"
         result = requests.post(url=sync_url, headers=headers, data=data_json)
+        print("result<><><>",result.content)
         tabs = result.json().get("data", {}).get("tabs")
         actions = result.json().get("data", {}).get("actions")
         insert_action_ids = result.json().get("data", {}).get("insert_action_ids")

+ 2 - 2
python/config.ini

@@ -4,13 +4,13 @@ app_name=智慧拍-后端应用
 # 应用版本号
 version=1.0.0
 # 应用host地址
-host=127.0.0.1
+host=10.56.42.17
 # 应用服务启动名称
 app_run=api:app
 # 端口号
 port=7074
 debug=false
-env=prod
+env=dev
 # 线程数
 works=1
 project=惠利玛

+ 13 - 4
python/mcu/capture/smart_shooter_class.py

@@ -307,10 +307,17 @@ class SmartShooter(metaclass=SingletonType):
             "iso_config",
             None,
         )
-        for item in  enumerate(camera_configs):
-            pass
-        low_iso = camera_configs.get("low", 100)
-        high_iso = camera_configs.get("high", 6400)
+        Itemiso = {}
+        for idx, item in enumerate(camera_configs):
+            itemConfig = camera_configs[item]
+            if itemConfig == {}:
+                continue
+            ItemCameraKey = itemConfig.get("CameraKey")
+            if ItemCameraKey == CameraKey:
+                Itemiso = itemConfig.get("iso")
+                break
+        low_iso = Itemiso.get("low", 100)
+        high_iso = Itemiso.get("high", 6400)
         return low_iso, high_iso
 
     def initConfigIsoSettings(self, CameraLists=[]):
@@ -338,6 +345,8 @@ class SmartShooter(metaclass=SingletonType):
         sys_iso_config: SysConfigParams
         print("首次初始化", sys_iso_config)
         settings.updateSysConfigs(params=sys_iso_config)
+        # 同步本地到线上
+        settings.sync_sys_configs2Online()
     async def EnableCameraPreview(
         self, enable_status=True, msg_type="", CameraKey=None
     ):

+ 23 - 0
python/settings.py

@@ -64,6 +64,29 @@ def get_config_by_items(config_dict):
 keys = ["面料", "里料"]
 
 
+def sync_sys_configs2Online():
+    hlm_token = USER_TOKEN
+    headers = {
+        "Authorization": f"Bearer {hlm_token}",
+        "content-type": "application/json",
+    }
+    # 追加配置参数 machine_type 拍照机设备类型;0鞋;1服装
+    session = SqlQuery()
+    sysConfigs = CRUD(SysConfigs)
+    all_configs = sysConfigs.read_all(session)
+    localConfigData = {}
+    for local_config in all_configs:
+        localConfigData[local_config.key] = json.loads(local_config.value)
+    data_json = json.dumps(
+        {"configs": localConfigData, "machine_type": MACHINE_TYPE},
+        ensure_ascii=False,
+    )
+    # 同步本地到线上
+    url = DOMAIN + "/api/ai_image/camera_machine/update_all_user_configs"
+    requests.post(url=url, headers=headers, data=data_json)
+    session.close()
+
+
 def getSysConfigs(key, item, default=None):
     session = SqlQuery()
     crud = CRUD(SysConfigs)

+ 26 - 3
python/sockets/message_handler.py

@@ -424,6 +424,8 @@ async def handlerSend(
             """
             获取相机信息,是否连接
             """
+            # token
+            # env
             loop.create_task(
                 smart_shooter.GetCameraInfo(msg_type="smart_shooter_getinfo"),
                 name="smart_shooter_getinfo",
@@ -433,7 +435,14 @@ async def handlerSend(
             启动相机或关闭实时预览
             """
             value = data.get("value", True)
-            CameraKey = data.get("CameraKey", None)
+            PointName = data.get("point_name", "A")
+            camera_configs = settings.getSysConfigs(
+                "camera_configs",
+                "iso_config",
+                None,
+            )
+            temp_A_point = camera_configs.get(PointName, None)
+            CameraKey = temp_A_point.get("CameraKey", None) if temp_A_point else None
             loop.create_task(
                 smart_shooter.EnableCameraPreview(
                     enable_status=value, 
@@ -446,7 +455,14 @@ async def handlerSend(
             """
             启动相机或关闭实时预览
             """
-            CameraKey = data.get("CameraKey", None)
+            PointName = data.get("point_name", "A")
+            camera_configs = settings.getSysConfigs(
+                "camera_configs",
+                "iso_config",
+                None,
+            )
+            temp_A_point = camera_configs.get(PointName, None)
+            CameraKey = temp_A_point.get("CameraKey", None) if temp_A_point else None
             msg_type = "smart_shooter_get_camera_property"
             code = 0
             status, info = await smart_shooter.GetCameraProperty(CameraKey=CameraKey)
@@ -464,7 +480,14 @@ async def handlerSend(
             """
             获取相机信息,是否连接
             """
-            CameraKey = data.get("CameraKey", None)
+            PointName = data.get("point_name", "A")
+            camera_configs = settings.getSysConfigs(
+                "camera_configs",
+                "iso_config",
+                None,
+            )
+            temp_A_point = camera_configs.get(PointName, None)
+            CameraKey = temp_A_point.get("CameraKey", None) if temp_A_point else None
             device_ctrl = DeviceControl(
                 websocket_manager=manager, smart_shooter=smart_shooter
             )

+ 6 - 1
python/temp.py

@@ -45,4 +45,9 @@ camera_configs = settings.getSysConfigs(
             None,
         )
 for idx, item in enumerate(camera_configs):
-    print(camera_configs[item])
+    itemConfig = camera_configs[item]
+    if itemConfig == {}:
+        continue
+    ItemCameraKey = itemConfig.get("CameraKey")
+    Itemiso = itemConfig.get("iso")
+    print(ItemCameraKey)