气体检测记录
This commit is contained in:
parent
3b5c95ac5d
commit
f9c4b3eff1
|
@ -61,3 +61,4 @@ class Access(CommonADModel):
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
obj_cate = models.CharField('对象类型', max_length=20, help_text='employee/post')
|
obj_cate = models.CharField('对象类型', max_length=20, help_text='employee/post')
|
||||||
obj = models.CharField('关联对象', unique=True, max_length=50, null=True, blank=True)
|
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.hrm.models import Employee
|
||||||
from apps.system.models import User
|
from apps.system.models import User
|
||||||
from apps.third.clients import xxClient
|
from apps.third.clients import xxClient
|
||||||
|
from apps.third.models import TDevice
|
||||||
from apps.third.tapis import xxapis
|
from apps.third.tapis import xxapis
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,25 +62,40 @@ class EcmService:
|
||||||
"""
|
"""
|
||||||
# 判断区域是否超员
|
# 判断区域是否超员
|
||||||
area = Area.objects.filter(third_info__xx_rail__id=data['railId']).first()
|
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: # 如果是固定区域
|
blts = TDevice.objects.filter(code=data['userId']).first()
|
||||||
json = {"railId": data['railId'], "type": ""}
|
if blts and blts.obj_cate == 'employee': # 如果是人
|
||||||
_, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json)
|
if area and area.type == Area.AREA_TYPE_FIX: # 如果是固定区域
|
||||||
total_count = res['totalCount']
|
json = {"railId": data['railId'], "type": ""}
|
||||||
if total_count >= area.count_people_max:
|
_, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json)
|
||||||
# 触发超员事件
|
total_count = res['totalCount']
|
||||||
area.count_people = total_count
|
if total_count >= area.count_people_max:
|
||||||
area.save()
|
# 触发超员事件
|
||||||
pass
|
area.count_people = total_count
|
||||||
elif total_count < area.count_people_min:
|
area.save()
|
||||||
# 触发缺员事件
|
pass
|
||||||
area.count_people_min = total_count
|
elif total_count < area.count_people_min:
|
||||||
area.save()
|
# 触发缺员事件
|
||||||
pass
|
area.count_people_min = total_count
|
||||||
# 判断有无进入权限
|
area.save()
|
||||||
if ep.type == 'employee' and area.employee_yes:
|
pass
|
||||||
return
|
ep_blts = Employee.objects.filter(id=blts.obj).first() # 标签绑定人员
|
||||||
elif ep.type == 'remployee' and area.remployee_yes:
|
if ep_blts:
|
||||||
return
|
# 判断有无进入权限 进行匹配
|
||||||
elif ep.type == 'visitor' and area.visitor_yes:
|
if ep_blts.type == 'employee' and area.employee_yes:
|
||||||
return
|
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)
|
check_place = models.CharField('检测部位', max_length=100)
|
||||||
o2 = models.DecimalField(decimal_places=1, max_digits=3)
|
o2 = models.DecimalField(decimal_places=1, max_digits=3)
|
||||||
co = models.PositiveSmallIntegerField()
|
co = models.PositiveSmallIntegerField()
|
||||||
|
h2s = models.PositiveSmallIntegerField()
|
||||||
lel = models.DecimalField(decimal_places=1, max_digits=3)
|
lel = models.DecimalField(decimal_places=1, max_digits=3)
|
||||||
is_ok = models.BooleanField('是否正常', default=True)
|
is_ok = models.BooleanField('是否正常', default=True)
|
||||||
checker = models.ForeignKey(User, verbose_name='检测人', on_delete=models.CASCADE)
|
checker = models.ForeignKey(User, verbose_name='检测人', on_delete=models.CASCADE)
|
||||||
|
|
Loading…
Reference in New Issue