|
@@ -427,18 +427,21 @@ async def update_gray_image_json(
|
|
|
|
|
|
|
|
# 遍历灰度图传来的新缺陷列表
|
|
# 遍历灰度图传来的新缺陷列表
|
|
|
for new_defect in gray_defects:
|
|
for new_defect in gray_defects:
|
|
|
- gray_id = new_defect.get("gray_id")
|
|
|
|
|
|
|
+ is_fusion = gray_image_type in (ImageType.front_fusion.value, ImageType.back_fusion.value)
|
|
|
|
|
+ key_to_check = "fusion_id" if is_fusion else "gray_id"
|
|
|
|
|
+
|
|
|
|
|
+ identifier = new_defect.get(key_to_check)
|
|
|
|
|
|
|
|
- # 只有带有 gray_id 的才进行特殊合并处理 (理论上前端编辑的都应该有,或者新生成的)
|
|
|
|
|
- # 如果没有 gray_id,视作普通新缺陷直接添加
|
|
|
|
|
- if not gray_id:
|
|
|
|
|
|
|
+ # 只有带有对应标识的才进行特殊合并处理
|
|
|
|
|
+ # 如果没有,视作普通新缺陷直接添加
|
|
|
|
|
+ if not identifier:
|
|
|
ring_defects.append(new_defect)
|
|
ring_defects.append(new_defect)
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
- # 在 Ring 图现有的缺陷中寻找匹配的 gray_id
|
|
|
|
|
|
|
+ # 在 Ring 图现有的缺陷中寻找匹配的标识
|
|
|
match_index = -1
|
|
match_index = -1
|
|
|
for i, old_defect in enumerate(ring_defects):
|
|
for i, old_defect in enumerate(ring_defects):
|
|
|
- if old_defect.get("gray_id") == gray_id:
|
|
|
|
|
|
|
+ if old_defect.get(key_to_check) == identifier:
|
|
|
match_index = i
|
|
match_index = i
|
|
|
break
|
|
break
|
|
|
|
|
|