fix: 同步大华部门信息需要dahua_enabled
This commit is contained in:
parent
a2b2cbe153
commit
c2ad28ae4b
|
@ -7,7 +7,15 @@ from apps.third.dahua import dhClient
|
||||||
def sync_dahua_dept(dept: Dept):
|
def sync_dahua_dept(dept: Dept):
|
||||||
# 同步大华部门信息
|
# 同步大华部门信息
|
||||||
third_info = dept.third_info
|
third_info = dept.third_info
|
||||||
if settings.DAHUA_ENABLED and not third_info.get('dh_id', False):
|
if settings.DAHUA_ENABLED:
|
||||||
|
if third_info.get('dh_id', False):
|
||||||
|
data = {
|
||||||
|
"id": dept.third_info['dh_id'],
|
||||||
|
"parentId": 1,
|
||||||
|
"name": dept.name
|
||||||
|
}
|
||||||
|
dhClient.request(**dhapis['dept_update'], json=data)
|
||||||
|
else:
|
||||||
# 如果dh_id 不存在
|
# 如果dh_id 不存在
|
||||||
data = {
|
data = {
|
||||||
"parentId": 1,
|
"parentId": 1,
|
||||||
|
@ -18,11 +26,4 @@ def sync_dahua_dept(dept: Dept):
|
||||||
third_info['dh_id'] = res['id']
|
third_info['dh_id'] = res['id']
|
||||||
dept.third_info = third_info
|
dept.third_info = third_info
|
||||||
dept.save()
|
dept.save()
|
||||||
elif settings.DAHUA_ENABLED and dept.third_info.get('dh_id', False):
|
|
||||||
data = {
|
|
||||||
"id": dept.third_info['dh_id'],
|
|
||||||
"parentId": 1,
|
|
||||||
"name": dept.name
|
|
||||||
}
|
|
||||||
dhClient.request(**dhapis['dept_update'], json=data)
|
|
||||||
dhClient.face_bind()
|
dhClient.face_bind()
|
||||||
|
|
Loading…
Reference in New Issue