增加rcertificate url

This commit is contained in:
曹前明 2022-06-27 17:41:34 +08:00
parent 97b657f4b4
commit b01db62406
5 changed files with 70 additions and 2 deletions

0
apps/am/services.py Normal file
View File

0
apps/am/tasks.py Normal file
View File

View File

@ -7,6 +7,14 @@ from apps.third.clients import xxClient
from apps.third.models import TDevice
from apps.third.tapis import xxapis
from apps.utils.queryset import get_child_queryset2
from django.core.cache import cache
import time
ep_loc_dict = {
"area": None, # 当前所在区域
"time1": None, # 首次在该区域时间戳
"time2": None, # 当前在该区域时间戳
}
class EcmService:
@ -39,6 +47,9 @@ class EcmService:
elif data.type == 'onKeyAlarm':
# 一键呼救
cls.one_key_alarm(data=data)
elif data.type == 'location':
# 定位信息
cls.loc_change(data=data)
elif data.type == 'onOffLine':
if data.data.online:
# 标签定位在线
@ -117,8 +128,27 @@ class EcmService:
@classmethod
def low_power(cls, data):
pass
# 有绑定对象再提示低电量
blts = TDevice.objects.filter(code=data['userId']).first()
if blts.employee:
# 触发低电量提醒事件
pass
@classmethod
def one_key_alarm(cls, data):
pass
@classmethod
def loc_change(cls, data):
blts = TDevice.objects.filter(code=data['userId']).first()
if blts.employee:
time2 = int(time.time())
key_str = f'ep_{blts.employee.id}'
ep_default_dict = {
"area": None, # 当前所在区域
"time1": None, # 首次在该区域时间戳
"time2": time2, # 当前在该区域时间戳
}
ep_loc_dict = cache.get_or_set(
key_str, ep_default_dict, 60*60*24*7
)

View File

@ -1,4 +1,4 @@
from apps.rpm.views import RpartyViewSet, RemployeeViewSet, RfileViewSet, RpjViewSet, RpjfileViewSet, RpjmemberViewSet
from apps.rpm.views import RcertificateViewSet, RpartyViewSet, RemployeeViewSet, RfileViewSet, RpjViewSet, RpjfileViewSet, RpjmemberViewSet
from django.urls import path, include
from rest_framework.routers import DefaultRouter
@ -8,6 +8,7 @@ HTML_BASE_URL = 'rpm/'
router = DefaultRouter()
router.register('rparty', RpartyViewSet, basename='rparty')
router.register('remployee', RemployeeViewSet, basename='remployee')
router.register('rcertificate', RcertificateViewSet, basename='rcertificate')
router.register('rfile', RfileViewSet, basename='rfile')
router.register('rpj', RpjViewSet, basename='rpj')
router.register('rpj_member', RpjmemberViewSet, basename='rpj_member')

View File

@ -1,6 +1,7 @@
import textwrap
import random
import string
import time
def print_roundtrip(response, *args, **kwargs):
@ -32,3 +33,39 @@ def ranstr(num):
def rannum(num):
salt = ''.join(random.sample(string.digits, num))
return salt
def p_in_poly(p, poly):
px = p['x']
py = p['y']
flag = False
i = 0
l = len(poly)
j = l - 1
# for(i = 0, l = poly.length, j = l - 1; i < l; j = i, i++):
while i < l:
sx = poly[i]['x']
sy = poly[i]['y']
tx = poly[j]['x']
ty = poly[j]['y']
# 点与多边形顶点重合
if (sx == px and sy == py) or (tx == px and ty == py):
return (px, py)
# 判断线段两端点是否在射线两侧
if (sy < py and ty >= py) or (sy >= py and ty < py):
# 线段上与射线 Y 坐标相同的点的 X 坐标
x = sx + (py - sy) * (tx - sx) / (ty - sy)
# 点在多边形的边上
if x == px:
return (px, py)
# 射线穿过多边形的边界
if x > px:
flag = not flag
j = i
i += 1
# 射线穿过多边形边界的次数为奇数时点在多边形内
return (px, py) if flag else 'out'