|
|
@@ -2987,6 +2987,8 @@ class QXZ_Warning_View(ListView):
|
|
|
print('user_name=', user_name)
|
|
|
current_user = MyUser.objects.get(username=user_name)
|
|
|
equip_list = Equip.objects.filter(equip_user=current_user,equip_type=5)
|
|
|
+ if current_user.is_staff:
|
|
|
+ equip_list = Equip.objects.filter(equip_type=5)
|
|
|
return render(request, 'backstageNet/warn/warnSet.html', context={"equip_list":equip_list})
|
|
|
def post(self,request):
|
|
|
equip_id = request.POST.get('equip_id')
|
|
|
@@ -3017,6 +3019,8 @@ class Production_Set(ListView):
|
|
|
print('user_name=', user_name)
|
|
|
current_user = MyUser.objects.get(username=user_name)
|
|
|
equip_list = Equip.objects.filter(equip_user=current_user,equip_type=5)
|
|
|
+ if current_user.is_staff:
|
|
|
+ equip_list = Equip.objects.filter(equip_type=5)
|
|
|
return render(request, 'backstageNet/warn/productionset.html', context={"equip_list":equip_list})
|
|
|
def post(self,request):
|
|
|
pass
|
|
|
@@ -3909,4 +3913,434 @@ class Equip_Location(ListView):
|
|
|
equip_obj.lng = lng
|
|
|
equip_obj.lat = lat
|
|
|
equip_obj.save()
|
|
|
- return HttpResponse("1")
|
|
|
+ return HttpResponse("1")
|
|
|
+
|
|
|
+
|
|
|
+import json
|
|
|
+class Add_Qxz_Test(ListView):
|
|
|
+ def get(self,request):
|
|
|
+ pass
|
|
|
+ def post(self, request):
|
|
|
+ payload = request.body
|
|
|
+ payload = json.loads(payload.decode())
|
|
|
+ print("payload",payload)
|
|
|
+ print("type",type(payload))
|
|
|
+ if payload.get("cmd") == "terminalData":
|
|
|
+ print("<-----uploading data!----->")
|
|
|
+ extdata = payload.get("ext")
|
|
|
+ print(type(extdata))
|
|
|
+ qxzdata = extdata['data']
|
|
|
+ print(qxzdata)
|
|
|
+ device_id = extdata['StationID']
|
|
|
+ print(device_id)
|
|
|
+ e1 = ''
|
|
|
+ e2 = ''
|
|
|
+ e3 = ''
|
|
|
+ e4 = ''
|
|
|
+ e5 = ''
|
|
|
+ e6 = ''
|
|
|
+ e7 = ''
|
|
|
+ e8 = ''
|
|
|
+ e9 = ''
|
|
|
+ e10 = ''
|
|
|
+ e11 = ''
|
|
|
+ e12 = ''
|
|
|
+ e13 = ''
|
|
|
+ e14 = ''
|
|
|
+ e15 = ''
|
|
|
+ e16 = ''
|
|
|
+ e17 = ''
|
|
|
+ e18 = ''
|
|
|
+ e19 = ''
|
|
|
+ e20 = ''
|
|
|
+ e21 = ''
|
|
|
+ e22 = ''
|
|
|
+ e23 = ''
|
|
|
+ e24 = ''
|
|
|
+ e25 = ''
|
|
|
+ e26 = ''
|
|
|
+ e27 = ''
|
|
|
+ e28 = ''
|
|
|
+ e29 = ''
|
|
|
+ e30 = ''
|
|
|
+
|
|
|
+
|
|
|
+ conf1 = ''
|
|
|
+ conf2 = ''
|
|
|
+ conf3 = ''
|
|
|
+ conf4 = ''
|
|
|
+ conf5 = ''
|
|
|
+ conf6 = ''
|
|
|
+ conf7 = ''
|
|
|
+ conf8 = ''
|
|
|
+ conf9 = ''
|
|
|
+ conf10 = ''
|
|
|
+ conf11 = ''
|
|
|
+ conf12 = ''
|
|
|
+ conf13 = ''
|
|
|
+ conf14 = ''
|
|
|
+ conf15 = ''
|
|
|
+ conf16 = ''
|
|
|
+ conf17 = ''
|
|
|
+ conf18 = ''
|
|
|
+ conf19 = ''
|
|
|
+ conf20 = ''
|
|
|
+ conf21 = ''
|
|
|
+ conf22 = ''
|
|
|
+ conf23 = ''
|
|
|
+ conf24 = ''
|
|
|
+ conf25 = ''
|
|
|
+ conf26 = ''
|
|
|
+ conf27 = ''
|
|
|
+ conf28 = ''
|
|
|
+ conf29 = ''
|
|
|
+ conf30 = ''
|
|
|
+ for i in qxzdata:
|
|
|
+ if i['eKey'] == 'e1':
|
|
|
+ e1 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf1 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e1[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e2':
|
|
|
+ e2 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf2 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e2[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e3':
|
|
|
+ e3 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf3 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e3[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e4':
|
|
|
+ e4 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf4 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e4[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e5':
|
|
|
+ e5 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf5 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e5[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e6':
|
|
|
+ e6 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf6 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e6[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e7':
|
|
|
+ e7 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf7 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e7[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e8':
|
|
|
+ e8 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf8 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e8[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e9':
|
|
|
+ e9 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf9 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e9[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e10':
|
|
|
+ e10 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf10 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e10[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e11':
|
|
|
+ e11 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf11 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e11[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e12':
|
|
|
+ e12 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf12 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e12[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e13':
|
|
|
+ e13 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf13 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e13[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e14':
|
|
|
+ e14 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf14 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e14[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e15':
|
|
|
+ e15 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf15 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e15[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e16':
|
|
|
+ e16 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf16 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e16[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e17':
|
|
|
+ e17 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf17 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e17[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e18':
|
|
|
+ e18 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf18 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e18[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e19':
|
|
|
+ e19 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf19 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e19[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e20':
|
|
|
+ e20 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf20 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e20[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e21':
|
|
|
+ e21 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf21 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e21[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e22':
|
|
|
+ e22 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf22 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e22[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e23':
|
|
|
+ e23 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf23 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e23[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e24':
|
|
|
+ e24 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf24 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e24[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e25':
|
|
|
+ e25 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf25 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e25[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e26':
|
|
|
+ e26 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf26 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e26[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e27':
|
|
|
+ e27 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf27 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e27[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e28':
|
|
|
+ e28 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf28 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e28[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e29':
|
|
|
+ e29 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf29 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e29[0] == "#":
|
|
|
+ continue
|
|
|
+ elif i['eKey'] == 'e30':
|
|
|
+ e30 = str(i['eValue']) + '#' + str(i['eNum']) + '#' + str(i['eKey'])
|
|
|
+ conf30 = qxz_dict[i['eNum']][1] + '#' + qxz_dict[i['eNum']][2]
|
|
|
+ if e30[0] == "#":
|
|
|
+ continue
|
|
|
+ qxz_exist = Equip.objects.filter(equip_id=device_id)
|
|
|
+ # print("extdata:", extdata)
|
|
|
+ # 设备存在,进一步判断状态表是否存在:
|
|
|
+ times = datetime.datetime.now()
|
|
|
+ if qxz_exist.exists():
|
|
|
+ print("<-----this equip is existed!----->")
|
|
|
+ try:
|
|
|
+ e_id = Equip.objects.get(device_id=device_id)
|
|
|
+ except:
|
|
|
+ print("<-----this equip didn't exist!----->")
|
|
|
+ try:
|
|
|
+ # 设备数据表直接储存数据
|
|
|
+ # QXZdata.objects.create(equip_id=e_id, qxz_data=extdata)
|
|
|
+ QXZdata_New.objects.create(device_id=device_id,
|
|
|
+ e1=e1,e2=e2,e3=e3,e4=e4,e5=e5,e6=e6,e7=e7,e8=e8,e9=e9,e10=e10,
|
|
|
+ e11=e11,e12=e12,e13=e13,e14=e14,e15=e15,e16=e16,e17=e17,e18=e18,e19=e19,e20=e20,
|
|
|
+ e21=e21,e22=e22,e23=e23,e24=e24,e25=e25,e26=e26,e27=e27,e28=e28,e29=e29,e30=e30)
|
|
|
+
|
|
|
+ print("<-----data update success!----->")
|
|
|
+ except:
|
|
|
+ print("<-----data update failed!----->")
|
|
|
+
|
|
|
+ if QXZstatus_New.objects.filter(equip_id=device_id).exists():
|
|
|
+ print("<-----this equip's status is existed!----->")
|
|
|
+ try:
|
|
|
+ sta = QXZstatus_New.objects.get(equip_id=device_id)
|
|
|
+
|
|
|
+ sta.e1 = e1
|
|
|
+ sta.e2 = e2
|
|
|
+ sta.e3 = e3
|
|
|
+ sta.e4 = e4
|
|
|
+ sta.e5 = e5
|
|
|
+ sta.e6 = e6
|
|
|
+ sta.e7 = e7
|
|
|
+ sta.e8 = e8
|
|
|
+ sta.e9 = e9
|
|
|
+ sta.e10 = e10
|
|
|
+ sta.e11 = e11
|
|
|
+ sta.e12 = e12
|
|
|
+ sta.e13 = e13
|
|
|
+ sta.e14 = e14
|
|
|
+ sta.e15 = e15
|
|
|
+ sta.e16 = e16
|
|
|
+ sta.e17 = e17
|
|
|
+ sta.e18 = e18
|
|
|
+ sta.e19 = e19
|
|
|
+ sta.e20 = e20
|
|
|
+ sta.e21 = e21
|
|
|
+ sta.e22 = e22
|
|
|
+ sta.e23 = e23
|
|
|
+ sta.e24 = e24
|
|
|
+ sta.e25 = e25
|
|
|
+ sta.e26 = e26
|
|
|
+ sta.e27 = e27
|
|
|
+ sta.e28 = e28
|
|
|
+ sta.e29 = e29
|
|
|
+ sta.e30 = e30
|
|
|
+ sta.is_online = "1"
|
|
|
+ sta.save()
|
|
|
+ print("<-----status update success!----->")
|
|
|
+ except:
|
|
|
+ print("<-----status update failed!----->")
|
|
|
+ else:
|
|
|
+ # 设备状态表不存在、创建状态表:
|
|
|
+ print("<-----this equip's status is not existed!----->")
|
|
|
+ try:
|
|
|
+ QXZstatus_New.objects.create(equip_id=device_id,
|
|
|
+ e1=e1,e2=e2,e3=e3,e4=e4,e5=e5,e6=e6,e7=e7,e8=e8,e9=e9,e10=e10,
|
|
|
+ e11=e11,e12=e12,e13=e13,e14=e14,e15=e15,e16=e16,e17=e17,e18=e18,e19=e19,e20=e20,
|
|
|
+ e21=e21,e22=e22,e23=e23,e24=e24,e25=e25,e26=e26,e27=e27,e28=e28,e29=e29,e30=e30,is_online="1")
|
|
|
+
|
|
|
+ # QXZstatus.objects.create(equip_id=e_id, qxz_status=extdata)
|
|
|
+ print("<-----this equip's status table re-create successed!----->")
|
|
|
+ except:
|
|
|
+ print("<-----this equip's status table re-create failed!----->")
|
|
|
+ # 判断标题配置表
|
|
|
+ if QXZ_Conf.objects.filter(equip_id=device_id).exists():
|
|
|
+ print("------conf create default-------")
|
|
|
+ else:
|
|
|
+ QXZ_Conf.objects.create(equip_id=device_id,
|
|
|
+ e1=conf1,e2=conf2,e3=conf3,e4=conf4,e5=conf5,e6=conf6,e7=conf7,e8=conf8,e9=conf9,e10=conf10,
|
|
|
+ e11=conf11,e12=conf12,e13=conf13,e14=conf14,e15=conf15,e16=conf16,e17=conf17,e18=conf18,e19=conf19,e20=conf20,
|
|
|
+ e21=conf21,e22=conf22,e23=conf23,e24=conf24,e25=conf25,e26=conf26,e27=conf27,e28=conf28,e29=conf29,e30=conf30)
|
|
|
+ QXZ_Default_Conf.objects.create(equip_id=device_id,
|
|
|
+ e1=conf1,e2=conf2,e3=conf3,e4=conf4,e5=conf5,e6=conf6,e7=conf7,e8=conf8,e9=conf9,e10=conf10,
|
|
|
+ e11=conf11,e12=conf12,e13=conf13,e14=conf14,e15=conf15,e16=conf16,e17=conf17,e18=conf18,e19=conf19,e20=conf20,
|
|
|
+ e21=conf21,e22=conf22,e23=conf23,e24=conf24,e25=conf25,e26=conf26,e27=conf27,e28=conf28,e29=conf29,e30=conf30)
|
|
|
+ print("------conf create success-------")
|
|
|
+ # 设备状态表存在、刷新状态表:
|
|
|
+ print("2222222")
|
|
|
+
|
|
|
+
|
|
|
+ else:
|
|
|
+ print("<-----this equip not existed!----->")
|
|
|
+ # 设备不存在,在设备列表中创建:
|
|
|
+ try:
|
|
|
+ e_id = Equip.objects.create(equip_id=device_id, equip_type_id="5",addtime=times,uptime=times)
|
|
|
+ print("<-----this imei add successed!----->")
|
|
|
+ try:
|
|
|
+ # 设备数据表直接储存数据
|
|
|
+ QXZdata_New.objects.create(equip_id=device_id,uptime=times,
|
|
|
+ e1=e1,e2=e2,e3=e3,e4=e4,e5=e5,e6=e6,e7=e7,e8=e8,e9=e9,e10=e10,
|
|
|
+ e11=e11,e12=e12,e13=e13,e14=e14,e15=e15,e16=e16,e17=e17,e18=e18,e19=e19,e20=e20,
|
|
|
+ e21=e21,e22=e22,e23=e23,e24=e24,e25=e25,e26=e26,e27=e27,e28=e28,e29=e29,e30=e30)
|
|
|
+ # QXZdata.objects.create(equip_id=e_id, qxz_data=extdata)
|
|
|
+ print("<-----data update success!----->")
|
|
|
+ except:
|
|
|
+ print("<-----data update failed!----->")
|
|
|
+ try:
|
|
|
+ QXZstatus_New.objects.create(equip_id=device_id,uptime=times,
|
|
|
+ e1=e1,e2=e2,e3=e3,e4=e4,e5=e5,e6=e6,e7=e7,e8=e8,e9=e9,e10=e10,
|
|
|
+ e11=e11,e12=e12,e13=e13,e14=e14,e15=e15,e16=e16,e17=e17,e18=e18,e19=e19,e20=e20,
|
|
|
+ e21=e21,e22=e22,e23=e23,e24=e24,e25=e25,e26=e26,e27=e27,e28=e28,e29=e29,e30=e30,is_online="1")
|
|
|
+ # QXZstatus.objects.create(equip_id=e_id, qxz_status=extdata)
|
|
|
+ print("<-----this imei register successed!----->")
|
|
|
+ except:
|
|
|
+ print("<-----this imei register failed!----->")
|
|
|
+
|
|
|
+ # 判断标题配置表
|
|
|
+ if QXZ_Conf.objects.filter(equip_id=device_id).exists():
|
|
|
+ print("------conf create default-------")
|
|
|
+ else:
|
|
|
+ QXZ_Conf.objects.create(equip_id=device_id,uptime=times,
|
|
|
+ e1=conf1,e2=conf2,e3=conf3,e4=conf4,e5=conf5,e6=conf6,e7=conf7,e8=conf8,e9=conf9,e10=conf10,
|
|
|
+ e11=conf11,e12=conf12,e13=conf13,e14=conf14,e15=conf15,e16=conf16,e17=conf17,e18=conf18,e19=conf19,e20=conf20,
|
|
|
+ e21=conf21,e22=conf22,e23=conf23,e24=conf24,e25=conf25,e26=conf26,e27=conf27,e28=conf28,e29=conf29,e30=conf30)
|
|
|
+ QXZ_Default_Conf.objects.create(equip_id=device_id,
|
|
|
+ e1=conf1,e2=conf2,e3=conf3,e4=conf4,e5=conf5,e6=conf6,e7=conf7,e8=conf8,e9=conf9,e10=conf10,
|
|
|
+ e11=conf11,e12=conf12,e13=conf13,e14=conf14,e15=conf15,e16=conf16,e17=conf17,e18=conf18,e19=conf19,e20=conf20,
|
|
|
+ e21=conf21,e22=conf22,e23=conf23,e24=conf24,e25=conf25,e26=conf26,e27=conf27,e28=conf28,e29=conf29,e30=conf30)
|
|
|
+ print("------conf create success-------")
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ print("<-----this imei add failed!----->")
|
|
|
+
|
|
|
+ if payload.get("cmd") == "Status":
|
|
|
+ extdata = payload.get("ext")['terminalStatus']
|
|
|
+ print(extdata)
|
|
|
+ try:
|
|
|
+ volt = extdata["VOLT"]
|
|
|
+ rssi = extdata["RSSI"]
|
|
|
+ iccid = extdata["ICCID"]
|
|
|
+ lng = extdata["longitude"]
|
|
|
+ lat = extdata["latitude"]
|
|
|
+ led = extdata["Dotled"]
|
|
|
+
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ try:
|
|
|
+ dver = extdata["Version"]
|
|
|
+ except:
|
|
|
+ dver = ""
|
|
|
+ if qxz_exist.exists():
|
|
|
+ print("<-----this equip is existed!----->")
|
|
|
+ try:
|
|
|
+ e_id = Equip.objects.get(equip_id=device_id)
|
|
|
+ except:
|
|
|
+ print("<-----this equip didn't exist!----->")
|
|
|
+ QXZ_Info_Record.objects.create(equip_id=device_id, volt=volt,rssi=rssi,uptime=times)
|
|
|
+ if QXZ_Base_Info.objects.filter(equip_id=device_id).exists():
|
|
|
+ print("<-----this qxz_base_info is existed!----->")
|
|
|
+ try:
|
|
|
+ sta = QXZ_Base_Info.objects.get(equip_id=device_id)
|
|
|
+ sta.volt = volt
|
|
|
+ sta.rssi = rssi
|
|
|
+ sta.iccid = iccid
|
|
|
+ sta.lng = lng
|
|
|
+ sta.lat = lat
|
|
|
+ sta.led = led
|
|
|
+ sta.dver = dver
|
|
|
+ sta.save()
|
|
|
+ sta1 = Equip.objects.get(equip_id=device_id)
|
|
|
+ sta1.lng = lng
|
|
|
+ sta1.lat = lat
|
|
|
+ sta1.save()
|
|
|
+ print("<-----qxz_base_info update success!----->")
|
|
|
+ except:
|
|
|
+ print("<-----qxz_base_info update failed!----->")
|
|
|
+ try:
|
|
|
+ sta = QXZ_Base_Info.objects.get(equip_id=device_id)
|
|
|
+ sta.volt = volt
|
|
|
+ sta.rssi = rssi
|
|
|
+ sta.save()
|
|
|
+ print("<-----qxz_base_info update success!!!----->")
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ # 设备阈值表不存在、创建阈值表:
|
|
|
+ print("<-----this qxz_base_info is not existed!----->")
|
|
|
+ try:
|
|
|
+ QXZ_Base_Info.objects.create(equip_id=device_id, volt=volt,rssi=rssi,iccid=iccid,lng=lng,lat=lat,led=led,uptime=times)
|
|
|
+ print("<-----this qxz_base_info table re-create successed!----->")
|
|
|
+ except:
|
|
|
+ print("<-----this qxz_base_info table re-create failed!----->")
|
|
|
+
|
|
|
+
|
|
|
+ return True
|