|
@@ -76,7 +76,7 @@ class QxzDeviceDetailView(APIView):
|
|
|
request_data = serializer.validated_data
|
|
request_data = serializer.validated_data
|
|
|
|
|
|
|
|
conf_wheres = {
|
|
conf_wheres = {
|
|
|
- "device_id":request_data["device_id"],
|
|
|
|
|
|
|
+ "device_id":request_data["device_id"]
|
|
|
}
|
|
}
|
|
|
conf_m = MongoDBTools(db_name='smartfarming', table_name='sa_qxz_conf')
|
|
conf_m = MongoDBTools(db_name='smartfarming', table_name='sa_qxz_conf')
|
|
|
conf_data = conf_m.find_one(wheres=conf_wheres)
|
|
conf_data = conf_m.find_one(wheres=conf_wheres)
|
|
@@ -88,11 +88,10 @@ class QxzDeviceDetailView(APIView):
|
|
|
result = {"conf":conf_data,"total_counts":0,"items":[]}
|
|
result = {"conf":conf_data,"total_counts":0,"items":[]}
|
|
|
|
|
|
|
|
data_m = MongoDBTools(db_name='smartfarming', table_name='sa_qxz_data')
|
|
data_m = MongoDBTools(db_name='smartfarming', table_name='sa_qxz_data')
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": request_data["device_id"]
|
|
"device_id": request_data["device_id"]
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": request_data["device_id"],
|
|
"device_id": request_data["device_id"],
|
|
@@ -101,7 +100,7 @@ class QxzDeviceDetailView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
for item in data:
|
|
for item in data:
|
|
@@ -194,12 +193,10 @@ class ScdDeviceDetailView(APIView):
|
|
|
"device_data": "$device_data"
|
|
"device_data": "$device_data"
|
|
|
}
|
|
}
|
|
|
data_m = MongoDBTools(db_name='smartfarming', table_name='sa_device_scd_data')
|
|
data_m = MongoDBTools(db_name='smartfarming', table_name='sa_device_scd_data')
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id
|
|
"device_id": d_id
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id,
|
|
"device_id": d_id,
|
|
@@ -208,7 +205,7 @@ class ScdDeviceDetailView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
|
|
|
|
@@ -306,11 +303,10 @@ class CbdDeviceDetailView(APIView):
|
|
|
"addtime": "$addtime",
|
|
"addtime": "$addtime",
|
|
|
"device_data": "$device_data"
|
|
"device_data": "$device_data"
|
|
|
}
|
|
}
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id
|
|
"device_id": d_id
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id,
|
|
"device_id": d_id,
|
|
@@ -319,7 +315,7 @@ class CbdDeviceDetailView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
|
|
|
|
@@ -385,11 +381,10 @@ class CbdDevicePhotoView(APIView):
|
|
|
"addr": "$addr"
|
|
"addr": "$addr"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": str(d_id)
|
|
"device_id": str(d_id)
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": str(d_id),
|
|
"device_id": str(d_id),
|
|
@@ -398,7 +393,7 @@ class CbdDevicePhotoView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
for item in data:
|
|
for item in data:
|
|
@@ -513,11 +508,10 @@ class BzyDeviceDetailView(APIView):
|
|
|
"device_data": "$device_data"
|
|
"device_data": "$device_data"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id
|
|
"device_id": d_id
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id,
|
|
"device_id": d_id,
|
|
@@ -526,7 +520,7 @@ class BzyDeviceDetailView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
|
|
|
|
@@ -581,11 +575,10 @@ class BzyDevicePhotoView(APIView):
|
|
|
"addtime": "$addtime",
|
|
"addtime": "$addtime",
|
|
|
"addr": "$addr"
|
|
"addr": "$addr"
|
|
|
}
|
|
}
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": str(d_id)
|
|
"device_id": str(d_id)
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": str(d_id),
|
|
"device_id": str(d_id),
|
|
@@ -594,7 +587,7 @@ class BzyDevicePhotoView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
|
|
|
|
@@ -692,11 +685,10 @@ class XycbDeviceDetailView(APIView):
|
|
|
"device_data": "$device_data"
|
|
"device_data": "$device_data"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id
|
|
"device_id": d_id
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id,
|
|
"device_id": d_id,
|
|
@@ -705,7 +697,7 @@ class XycbDeviceDetailView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
|
|
|
|
@@ -800,11 +792,10 @@ class XctDeviceDetailView(APIView):
|
|
|
"device_data": "$device_data"
|
|
"device_data": "$device_data"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id
|
|
"device_id": d_id
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": d_id,
|
|
"device_id": d_id,
|
|
@@ -813,7 +804,7 @@ class XctDeviceDetailView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
|
|
|
|
@@ -870,11 +861,10 @@ class XctDevicePhotoView(APIView):
|
|
|
"indentify_photo":"$indentify_photo",
|
|
"indentify_photo":"$indentify_photo",
|
|
|
"indentify_result":"$indentify_result"
|
|
"indentify_result":"$indentify_result"
|
|
|
}
|
|
}
|
|
|
- if request_data["req"] == "new":
|
|
|
|
|
|
|
+ if request_data.get("start_timestamp") == 0:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": str(d_id)
|
|
"device_id": str(d_id)
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["offset"],limit=request_data["page_size"])
|
|
|
|
|
else:
|
|
else:
|
|
|
data_wheres = {
|
|
data_wheres = {
|
|
|
"device_id": str(d_id),
|
|
"device_id": str(d_id),
|
|
@@ -883,7 +873,7 @@ class XctDevicePhotoView(APIView):
|
|
|
"$lte": request_data["end_timestamp"]
|
|
"$lte": request_data["end_timestamp"]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- data = data_m.find_many(wheres=data_wheres,options=data_project,is_reverse=False,skip=(request_data["page"]-1)*request_data["page_size"],limit=request_data["page_size"])
|
|
|
|
|
|
|
+ data = data_m.find_many(wheres=data_wheres,options=data_project,skip=request_data["page_start"],limit=request_data["page_size"])
|
|
|
total_counts = data.count()
|
|
total_counts = data.count()
|
|
|
result["total_counts"] = total_counts
|
|
result["total_counts"] = total_counts
|
|
|
|
|
|