气体检测记录
This commit is contained in:
parent
3b5c95ac5d
commit
f9c4b3eff1
|
@ -61,3 +61,4 @@ class Access(CommonADModel):
|
|||
on_delete=models.CASCADE)
|
||||
obj_cate = models.CharField('对象类型', max_length=20, help_text='employee/post')
|
||||
obj = models.CharField('关联对象', unique=True, max_length=50, null=True, blank=True)
|
||||
sort = models.PositiveSmallIntegerField('排序', default=1)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
|
||||
from apps.am.models import Area
|
||||
from apps.am.models import Access, Area
|
||||
from apps.hrm.models import Employee
|
||||
from apps.system.models import User
|
||||
from apps.third.clients import xxClient
|
||||
from apps.third.models import TDevice
|
||||
from apps.third.tapis import xxapis
|
||||
|
||||
|
||||
|
@ -61,25 +62,40 @@ class EcmService:
|
|||
"""
|
||||
# 判断区域是否超员
|
||||
area = Area.objects.filter(third_info__xx_rail__id=data['railId']).first()
|
||||
ep = Employee.objects.filter(third_info__xx_userId=data['userId']).first()
|
||||
if area and area.type == Area.AREA_TYPE_FIX: # 如果是固定区域
|
||||
json = {"railId": data['railId'], "type": ""}
|
||||
_, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json)
|
||||
total_count = res['totalCount']
|
||||
if total_count >= area.count_people_max:
|
||||
# 触发超员事件
|
||||
area.count_people = total_count
|
||||
area.save()
|
||||
pass
|
||||
elif total_count < area.count_people_min:
|
||||
# 触发缺员事件
|
||||
area.count_people_min = total_count
|
||||
area.save()
|
||||
pass
|
||||
# 判断有无进入权限
|
||||
if ep.type == 'employee' and area.employee_yes:
|
||||
return
|
||||
elif ep.type == 'remployee' and area.remployee_yes:
|
||||
return
|
||||
elif ep.type == 'visitor' and area.visitor_yes:
|
||||
return
|
||||
# 判断进入对象
|
||||
blts = TDevice.objects.filter(code=data['userId']).first()
|
||||
if blts and blts.obj_cate == 'employee': # 如果是人
|
||||
if area and area.type == Area.AREA_TYPE_FIX: # 如果是固定区域
|
||||
json = {"railId": data['railId'], "type": ""}
|
||||
_, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json)
|
||||
total_count = res['totalCount']
|
||||
if total_count >= area.count_people_max:
|
||||
# 触发超员事件
|
||||
area.count_people = total_count
|
||||
area.save()
|
||||
pass
|
||||
elif total_count < area.count_people_min:
|
||||
# 触发缺员事件
|
||||
area.count_people_min = total_count
|
||||
area.save()
|
||||
pass
|
||||
ep_blts = Employee.objects.filter(id=blts.obj).first() # 标签绑定人员
|
||||
if ep_blts:
|
||||
# 判断有无进入权限 进行匹配
|
||||
if ep_blts.type == 'employee' and area.employee_yes:
|
||||
return
|
||||
elif ep_blts.type == 'remployee' and area.remployee_yes:
|
||||
return
|
||||
elif ep_blts.type == 'visitor' and area.visitor_yes:
|
||||
return
|
||||
for i in Access.objects.filter(area=area).order_by('sort'):
|
||||
if i.obj_cate == 'employee':
|
||||
ep_acess = Employee.objects.filter(id=i.obj).first()
|
||||
if ep_blts == ep_acess and i.type == 10:
|
||||
return
|
||||
elif ep_blts == ep_acess and i.type == 20:
|
||||
# 触发非法进入事件
|
||||
pass
|
||||
else:
|
||||
# 触发未知标签进入事件
|
||||
pass
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.2.12 on 2022-06-25 09:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('opm', '0002_operation_state'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='gascheck',
|
||||
name='h2s',
|
||||
field=models.PositiveSmallIntegerField(default=1),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -155,6 +155,7 @@ class GasCheck(CommonADModel):
|
|||
check_place = models.CharField('检测部位', max_length=100)
|
||||
o2 = models.DecimalField(decimal_places=1, max_digits=3)
|
||||
co = models.PositiveSmallIntegerField()
|
||||
h2s = models.PositiveSmallIntegerField()
|
||||
lel = models.DecimalField(decimal_places=1, max_digits=3)
|
||||
is_ok = models.BooleanField('是否正常', default=True)
|
||||
checker = models.ForeignKey(User, verbose_name='检测人', on_delete=models.CASCADE)
|
||||
|
|
Loading…
Reference in New Issue