feat: face_data中字典形式存储json数据
This commit is contained in:
parent
973c48bd7d
commit
72372c3215
|
@ -44,7 +44,7 @@ class Employee(CommonBModel):
|
||||||
not_work_remark = models.CharField('当前未打卡说明', null=True, blank=True, max_length=200)
|
not_work_remark = models.CharField('当前未打卡说明', null=True, blank=True, max_length=200)
|
||||||
third_info = models.JSONField('三方信息', default=dict, null=False, blank=True) # 主要是定位卡信息
|
third_info = models.JSONField('三方信息', default=dict, null=False, blank=True) # 主要是定位卡信息
|
||||||
post = models.ForeignKey(Post, verbose_name='所属岗位', on_delete=models.SET_NULL, null=True, blank=True)
|
post = models.ForeignKey(Post, verbose_name='所属岗位', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
face_data = models.JSONField('人脸数据', null=True, blank=True)
|
face_data = models.JSONField('人脸数据', null=True, blank=True) # 存储的是字典(模型名:人脸数据)
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = '员工补充信息'
|
verbose_name = '员工补充信息'
|
||||||
verbose_name_plural = verbose_name
|
verbose_name_plural = verbose_name
|
||||||
|
|
|
@ -73,9 +73,15 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer):
|
||||||
if old_photo != instance.photo: # 如果照片有变动,需要更新人脸库
|
if old_photo != instance.photo: # 如果照片有变动,需要更新人脸库
|
||||||
# 使用的是face_recongition
|
# 使用的是face_recongition
|
||||||
face_data, msg = HrmService.get_facedata_from_img_x(settings.BASE_DIR + instance.photo)
|
face_data, msg = HrmService.get_facedata_from_img_x(settings.BASE_DIR + instance.photo)
|
||||||
|
in_face_data = instance.face_data
|
||||||
if face_data:
|
if face_data:
|
||||||
instance.face_data = face_data
|
if isinstance(in_face_data, dict):
|
||||||
instance.save()
|
in_face_data['dlib'] = face_data
|
||||||
|
instance.face_data = in_face_data
|
||||||
|
instance.save()
|
||||||
|
else:
|
||||||
|
instance.face_data = {'dlib': face_data}
|
||||||
|
instance.save()
|
||||||
else:
|
else:
|
||||||
raise ParseError(msg)
|
raise ParseError(msg)
|
||||||
from apps.hrm.tasks import update_all_facedata_cache
|
from apps.hrm.tasks import update_all_facedata_cache
|
||||||
|
|
|
@ -97,7 +97,7 @@ def update_all_facedata_cache():
|
||||||
"""
|
"""
|
||||||
更新人脸数据缓存
|
更新人脸数据缓存
|
||||||
"""
|
"""
|
||||||
facedata_queyset = Employee.objects.filter(face_data__isnull=False).values('id', 'face_data')
|
facedata_queyset = Employee.objects.filter(face_data__dlib__isnull=False).values('id', 'face_data')
|
||||||
face_eps = []
|
face_eps = []
|
||||||
face_datas = []
|
face_datas = []
|
||||||
for i in facedata_queyset:
|
for i in facedata_queyset:
|
||||||
|
|
Loading…
Reference in New Issue