Browse Source

拍照消息转发

rambo 7 months ago
parent
commit
7faf3c24ff
1 changed files with 16 additions and 3 deletions
  1. 16 3
      python/mcu/capture/module_watch_dog.py

+ 16 - 3
python/mcu/capture/module_watch_dog.py

@@ -117,7 +117,9 @@ class FileEventHandler(FileSystemEventHandler, metaclass=SingletonType):
         crud = CRUD(PhotoRecord)
         crud.read()
 
-    async def sendCallback(self, file_path, msg_type="run_mcu_single"):
+    async def sendCallback(
+        self, file_path, goods_art_no=None, image_index=-1, msg_type="run_mcu_single"
+    ):
         await asyncio.sleep(1)
         self.mcu.msg_type = msg_type
         # print("货号不存在,监听不写入", self.mcu.msg_type)
@@ -125,7 +127,11 @@ class FileEventHandler(FileSystemEventHandler, metaclass=SingletonType):
             code=0,
             msg="主图测试拍摄完成",
             device_status=2,
-            data={"file_path": file_path.replace("\\", "/")},
+            data={
+                "file_path": file_path.replace("\\", "/"),
+                "goods_art_no": goods_art_no,
+                "image_index": image_index,
+            },
         )
         self.msg_type = "mcu"
 
@@ -163,7 +169,14 @@ class FileEventHandler(FileSystemEventHandler, metaclass=SingletonType):
                 )
                 loop = asyncio.new_event_loop()
                 asyncio.set_event_loop(loop)
-                loop.run_until_complete(self.sendCallback(file_path,msg_type="run_mcu_update"))
+                loop.run_until_complete(
+                    self.sendCallback(
+                        file_path,
+                        goods_art_no=self.goods_art_no,
+                        image_index=self.image_index,
+                        msg_type="run_mcu_update",
+                    )
+                )
                 loop.close()
             except BaseException as e:
                 print("获取文件create_time失败", e)