|
|
@@ -7,12 +7,17 @@ from utils.permissions import CbdDeviceDetailPermission
|
|
|
from .serializers import ZhiBaoSelectViewSerializer
|
|
|
from utils.JWTAuthentication_diy import MyJWTAuthentication
|
|
|
from utils.permissions import ModulePermission
|
|
|
+from rest_framework.views import APIView
|
|
|
|
|
|
from utils.db_utils import MongoDBTools
|
|
|
from utils.all_dict import insect_dict
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
|
+from apps.PestAnalysis.models import CbdAddrPest, HeNanAddr
|
|
|
+from apps.PestAnalysis.serializers import CbdAddrPestSerializer
|
|
|
+
|
|
|
+
|
|
|
class PestSelectView(GenericAPIView):
|
|
|
authentication_classes = [MyJWTAuthentication]
|
|
|
permission_classes = [ModulePermission]
|
|
|
@@ -209,3 +214,21 @@ class RecentMonthPestCount(GenericAPIView):
|
|
|
return Response({"data": [], "imgs": [], "msg": e.args})
|
|
|
|
|
|
|
|
|
+class PestCountAPIView(APIView):
|
|
|
+
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
+ try:
|
|
|
+ data = request.query_params
|
|
|
+ code = data.get("code")
|
|
|
+ start = data.get("start")
|
|
|
+ end = data.get("end")
|
|
|
+ if code:
|
|
|
+ hananaddr = HeNanAddr.objects.get(code=code)
|
|
|
+ if hananaddr.district:
|
|
|
+ query = CbdAddrPest.objects.filter(addr_code=code)
|
|
|
+ if start and end:
|
|
|
+ query = query.filter(format_date__range=[start, end])
|
|
|
+ data = CbdAddrPestSerializer(query, many=True).data
|
|
|
+ return Response(data)
|
|
|
+ except Exception as e:
|
|
|
+ return Response({"data": [], "imgs": [], "msg": e.args})
|