检查未带定位卡
This commit is contained in:
parent
e1f1cb1715
commit
b654655fd1
|
@ -20,7 +20,10 @@ import os
|
||||||
from apps.utils.speech import generate_voice
|
from apps.utils.speech import generate_voice
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from apps.utils.tools import timestamp_to_time
|
from apps.utils.tools import timestamp_to_time
|
||||||
|
from apps.third.clients import xxClient
|
||||||
|
from apps.third.tapis import xxapis
|
||||||
|
import logging
|
||||||
|
myLogger = logging.getLogger('log')
|
||||||
from apps.vm.models import Visit
|
from apps.vm.models import Visit
|
||||||
requests.packages.urllib3.disable_warnings()
|
requests.packages.urllib3.disable_warnings()
|
||||||
|
|
||||||
|
@ -210,6 +213,28 @@ def create_remind(event: Event, params: dict):
|
||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
|
|
||||||
|
def check_miss_lcard(ep: Employee, area: Area):
|
||||||
|
# 获取当前区域下的定位卡列表
|
||||||
|
try:
|
||||||
|
railId = area.third_info['xx_rail']['id']
|
||||||
|
json = {
|
||||||
|
"railId": railId,
|
||||||
|
"type": ""
|
||||||
|
}
|
||||||
|
is_ok, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json, raise_exception=False)
|
||||||
|
if is_ok:
|
||||||
|
blt_list = res['recordList']
|
||||||
|
macs = [] # 所有该区域在线标签
|
||||||
|
for i in blt_list:
|
||||||
|
macs.append(i['mac'])
|
||||||
|
td = TDevice.objects.filter(type=TDevice.DEVICE_BLT, employee=ep).first()
|
||||||
|
if td:
|
||||||
|
if td.code not in macs:
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
myLogger.error('检查未带定位卡失败', exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
def dispatch_dahua_event(data: dict):
|
def dispatch_dahua_event(data: dict):
|
||||||
"""分发大华事件进行处理
|
"""分发大华事件进行处理
|
||||||
"""
|
"""
|
||||||
|
@ -227,9 +252,16 @@ def dispatch_dahua_event(data: dict):
|
||||||
global_img_o = dhClient.get_full_pic(data['info']['extend']['globalScenePicUrl'])
|
global_img_o = dhClient.get_full_pic(data['info']['extend']['globalScenePicUrl'])
|
||||||
obj_cate = 'people'
|
obj_cate = 'people'
|
||||||
ep = None # 对应人员
|
ep = None # 对应人员
|
||||||
|
ec_codes_origin = {}
|
||||||
if alarm_type == 1001003: # 内部人员
|
if alarm_type == 1001003: # 内部人员
|
||||||
ep = Employee.objects.filter(id_number=data['info']['extend']['candidateInfo'][0]['id']).first()
|
ep = Employee.objects.filter(id_number=data['info']['extend']['candidateInfo'][0]['id']).first()
|
||||||
|
# 检查是否携带定位卡只针对内部员工和相关方
|
||||||
|
if 'miss_lcard' in algo_codes and ep:
|
||||||
|
is_happend = check_miss_lcard(ep=ep, area=area)
|
||||||
|
if is_happend:
|
||||||
|
ec_codes_origin.update({'miss_lcard': None})
|
||||||
ec_codes = ai_analyse(codes=algo_codes, global_img=global_img_o, face_img=face_img_o) # 算法处理
|
ec_codes = ai_analyse(codes=algo_codes, global_img=global_img_o, face_img=face_img_o) # 算法处理
|
||||||
|
ec_codes.update(ec_codes_origin)
|
||||||
if ec_codes: # 如果触发事件
|
if ec_codes: # 如果触发事件
|
||||||
# 获取本次所有发生事件种类
|
# 获取本次所有发生事件种类
|
||||||
ecs = EventCate.objects.filter(code__in=ec_codes.keys())
|
ecs = EventCate.objects.filter(code__in=ec_codes.keys())
|
||||||
|
|
|
@ -32,13 +32,13 @@ class Operation(CommonBDModel):
|
||||||
OP_AUDIT = 20
|
OP_AUDIT = 20
|
||||||
OP_WAIT = 30
|
OP_WAIT = 30
|
||||||
OP_WORK = 40
|
OP_WORK = 40
|
||||||
OP_CLOSE = 50
|
OP_DONE = 50
|
||||||
OP_STATE_CHOICES = (
|
OP_STATE_CHOICES = (
|
||||||
(OP_CREATE, '创建中'),
|
(OP_CREATE, '创建中'),
|
||||||
(OP_AUDIT, '审批中'),
|
(OP_AUDIT, '审批中'),
|
||||||
(OP_WAIT, '待作业'),
|
(OP_WAIT, '待作业'),
|
||||||
(OP_WORK, '作业中'),
|
(OP_WORK, '作业中'),
|
||||||
(OP_CLOSE, '已关闭')
|
(OP_DONE, '已结束')
|
||||||
)
|
)
|
||||||
number = models.CharField('作业编号', max_length=20, null=True, blank=True)
|
number = models.CharField('作业编号', max_length=20, null=True, blank=True)
|
||||||
name = models.CharField('作业简述', max_length=200)
|
name = models.CharField('作业简述', max_length=200)
|
||||||
|
|
|
@ -179,7 +179,7 @@ class OplCreateUpdateSerializer(CustomModelSerializer):
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
operation = validated_data['operation']
|
operation = validated_data['operation']
|
||||||
if operation.state == Operation.OP_CLOSE:
|
if operation.state == Operation.OP_DONE:
|
||||||
raise ParseError('作业已关闭不可创建许可')
|
raise ParseError('作业已关闭不可创建许可')
|
||||||
return super().create(validated_data)
|
return super().create(validated_data)
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,8 @@ def opl_start(ticket: Ticket):
|
||||||
if op.vchannels:
|
if op.vchannels:
|
||||||
vc_codes = list(op.vchannels.all().values_list('code', flat=True))
|
vc_codes = list(op.vchannels.all().values_list('code', flat=True))
|
||||||
else:
|
else:
|
||||||
vc_codes = list(TDevice.objects.filter(type=TDevice.DEVICE_VCHANNEL, area=op.area).values_list('code', flat=True))
|
vc_codes = list(TDevice.objects.filter(type=TDevice.DEVICE_VCHANNEL,
|
||||||
|
area=op.area).values_list('code', flat=True))
|
||||||
opl_id = opl.id
|
opl_id = opl.id
|
||||||
task = opl_task.delay(vc_codes, opl_id)
|
task = opl_task.delay(vc_codes, opl_id)
|
||||||
opl.mtask_id = task.task_id
|
opl.mtask_id = task.task_id
|
||||||
|
@ -115,5 +116,5 @@ def opl_end(ticket: Ticket):
|
||||||
if 0 in states or 1 in states: # 查看工单状态
|
if 0 in states or 1 in states: # 查看工单状态
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
operation.state = Operation.OP_CLOSE
|
operation.state = Operation.OP_DONE
|
||||||
operation.save()
|
operation.save()
|
|
@ -61,14 +61,20 @@ class XxTestView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
ok, res = xxClient.request(
|
json = {
|
||||||
url='/api/application/build/buildListV2', json={})
|
"railId": "bc0ed1151524490589a9a519685f188f",
|
||||||
if ok == 'success':
|
"type": ""
|
||||||
|
}
|
||||||
|
_, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json)
|
||||||
return Response(res)
|
return Response(res)
|
||||||
elif ok == 'fail':
|
# ok, res = xxClient.request(
|
||||||
raise ParseError(**res)
|
# url='/api/application/build/buildListV2', json={})
|
||||||
else:
|
# if ok == 'success':
|
||||||
raise APIException(**res)
|
# return Response(res)
|
||||||
|
# elif ok == 'fail':
|
||||||
|
# raise ParseError(**res)
|
||||||
|
# else:
|
||||||
|
# raise APIException(**res)
|
||||||
|
|
||||||
# 寻息事件订阅
|
# 寻息事件订阅
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue