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

Merge branch '26_0427_fix' into multi_camera_version

rambo 2 недель назад
Родитель
Сommit
6b7870ed35
4 измененных файлов с 34 добавлено и 17 удалено
  1. 5 7
      python/api.py
  2. 1 1
      python/config.ini
  3. 9 9
      python/mcu/DeviceControl.py
  4. 19 0
      python/settings.py

+ 5 - 7
python/api.py

@@ -1266,17 +1266,15 @@ def delete_all_goods_arts():
             raise UnicornException("没有可删除的货号")
 
         # 2. 清理文件目录 (复用现有的 handlerFolderDelete 逻辑)
-        limit_path = "{}/{}".format(settings.OUTPUT_DIR,
-                        time.strftime("%Y-%m-%d", time.localtime(time.time()))
-                    )
+        # limit_path = "{}/{}".format(settings.OUTPUT_DIR,
+        #                 time.strftime("%Y-%m-%d", time.localtime(time.time()))
+        #             )
         # 注意:handlerFolderDelete 内部可能涉及大量IO操作,如果数据量极大可能需要异步或后台任务
         # 这里保持同步以符合原接口风格,但需注意超时风险
-        handlerFolderDelete(limit_path, list(all_goods_art_nos), False)
+        # handlerFolderDelete(limit_path, list(all_goods_art_nos), False)
 
         # 3. 同步线上状态 (如果需要)
-        for item in all_goods_art_nos:
-            settings.syncPhotoRecord({"goods_art_no": item}, action_type=2)
-
+        settings.syncBatchPhotoRecordDelete()
         # 4. 批量删除数据库记录
         # 使用 deleteConditions 一次性删除所有符合条件的记录,比循环删除效率高
         photos.deleteConditions(session, conditions={"delete_time": None})

+ 1 - 1
python/config.ini

@@ -4,7 +4,7 @@ app_name=智慧拍-后端应用
 # 应用版本号
 version=1.0.0
 # 应用host地址
-host=127.0.0.1
+host=10.56.42.17
 # 应用服务启动名称
 app_run=api:app
 # 端口号

+ 9 - 9
python/mcu/DeviceControl.py

@@ -219,7 +219,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
                     pass
             except BaseException as e:
                 print("121231298908", e)
-                logger.info("121231298908", e)
+                logger.info(f"121231298908{e}")
                 break
 
         self.is_running = False
@@ -459,14 +459,14 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
             data = receive_data[1:].decode()
             if "设备初始化完成" in data:
                 self.init_state = True
-                logger.info("设备初始化完成:%s", data)
+                logger.info(f"设备初始化完成:%{data}")
                 self.sendSocketMessage(msg=data, device_status=2)
             else:
                 print("设备异常数据打印:", data)
-                logger.info("115  设备异常数据打印:%s", data)
+                logger.info(f"115  设备异常数据打印:%{data}")
         except BaseException as e:
             print("117 error {}".format(e))
-            logger.info("117 error %s", e)
+            logger.info(f"117 error %{e}")
         return
     def print_mcu_noraml_data(self, receive_data):
         # 扫码数据
@@ -501,12 +501,12 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
                 device_name_info = self.device_name_dict_mapping[device_id]
                 message_info = {"设备名称":device_name_info,"运动值":device_value}
                 print("【设备运动】消息回执:", message_info)
-                logger.info("设备运动消息回执:%s", message_info)
+                logger.info(f"设备运动消息回执:{message_info}")
             print("接收设备消息回执:", command_text)
-            logger.info("接收设备消息回执:%s", receive_data_temp_text)
+            logger.info(f"接收设备消息回执:{receive_data_temp_text}")
         except BaseException as e:
-            print("255 error {}".format(e))
-            logger.info("255 error %s", e)
+            print(f"255 error {e}")
+            logger.info(f"255 error {e}")
         return
     def get_from_mcu_move_respond_data(self, receive_data):
         self.last_from_mcu_move_respond_data = receive_data
@@ -1801,7 +1801,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         await asyncio.sleep(0.1)
         print("only_take_photo=====>", goods_art_no, image_index, record_id)
         logger.info(
-            "only_take_photo=====> %s %s %s", goods_art_no, image_index, record_id
+            f"only_take_photo=====> {goods_art_no} {image_index} {record_id}"
         )
         if goods_art_no == "":
             print("only_take_photo 数据查询异常")

+ 19 - 0
python/settings.py

@@ -346,6 +346,25 @@ def syncPhotoRecord(data,action_type=0):
     postData = {"data":data,"machine_type":machine_type,'action_type':action_type}
     response = requests.post(url=url,data=json.dumps(postData, ensure_ascii=False, default=str), headers=headers)
     print("用户token",response.content)
+
+
+def syncBatchPhotoRecordDelete():
+    """同步图片记录"""
+    headers = {
+        "Authorization": f"Bearer {USER_TOKEN}",
+        "content-type": "application/json",
+    }
+    machine_type = MACHINE_TYPE
+    url = getDoman(USER_ENV) + f"/api/ai_image/camera_machine/photo_records_handler"
+    postData = {"machine_type": machine_type, "action_type": 4}
+    response = requests.post(
+        url=url,
+        data=json.dumps(postData, ensure_ascii=False, default=str),
+        headers=headers,
+    )
+    print("用户token", response.content)
+
+
 def checkRecordSyncStatus():
     # check_photo_record_sync_status
     headers = {