Przeglądaj źródła

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJServer into linhaohong

linhaohong 1 rok temu
rodzic
commit
cc8910759f

+ 40 - 0
AdminController/CloudServiceManage/AgentDeviceController.py

@@ -0,0 +1,40 @@
+# -*- encoding: utf-8 -*-
+"""
+@File    : AgentDeviceController.py
+@Time    : 2024/3/8 13:55
+@Author  : stephen
+@Email   : zhangdongming@asj6.wecom.work
+@Software: PyCharm
+"""
+from django.http import QueryDict
+from django.views import View
+
+
+class AgentDeviceView(View):
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.GET, request, operation)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.POST, request, operation)
+
+    def delete(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        delete = QueryDict(request.body)
+        if not delete:
+            delete = request.GET
+        return self.validation(delete, request, operation)
+
+    def put(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        put = QueryDict(request.body)
+        return self.validation(put, request, operation)
+
+    def validation(self, request_dict, request, operation):
+
+        pass

+ 4 - 0
Ansjer/urls.py

@@ -5,6 +5,7 @@ from django.urls import re_path
 from AdminController import UserManageController, RoleController, MenuController, TestServeController, \
     ServeManagementController, LogManagementController, DeviceManagementController, VersionManagementController, \
     AiServeController, SurveysManageController, SerialManageController, IcloudManagementController
+from AdminController.CloudServiceManage import AgentDeviceController, AgentCustomerController
 from Controller import FeedBack, EquipmentOTA, EquipmentInfo, AdminManage, AppInfo, \
     Test, MealManage, DeviceManage, EquipmentStatus, SysManage, DeviceLog, LogAccess, \
     AppColophon, DateController, \
@@ -302,6 +303,9 @@ urlpatterns = [
     re_path(r'^dataManagement/', include("Ansjer.server_urls.datasystem_url")),
     # 数据系统模块
     re_path(r'^icloudserve/(?P<operation>.*)', IcloudManagementController.IcloudServeView.as_view()),
+    # 代理平台模块
+    re_path(r'^agent/customer/manage/(?P<operation>.*)', AgentCustomerController.AgentCustomerView.as_view()),
+    re_path(r'^agent/device/manage/(?P<operation>.*)', AgentDeviceController.AgentDeviceView.as_view()),
     # 后台界面接口 -------------------------------------------------------------------------------------------------------
 
     # 定时任务接口

+ 12 - 14
Controller/SensorGateway/SmartSceneController.py

@@ -1087,7 +1087,7 @@ class SmartSceneView(View):
                     minutes = conditions_dict['time']['minutes']
                     repeat = conditions_dict['time']['repeat']
 
-                    task_temp['task_id'], task_temp['time_dict'] = cls.create_aps_job(
+                    task_temp['task_id'] = cls.create_aps_job(
                         minutes, delay_time, tz, now_time, repeat, sensor_type, event_type, serial_number)
                 mqtt_task_list.append(task_temp)
             else:
@@ -1364,26 +1364,22 @@ class SmartSceneView(View):
         # 判断条件是否为设置时间
         time_type = scene_data_dict['condition'].get('time')
         if time_type:
-            time_task_list = scene_data_dict['task_list']
             apscheduler_obj = ApschedulerObject()
             # 关闭: 暂停任务, 打开: 恢复任务
             if scene_status == SCENE_STATUS_OFF:
-                cls.pause_job(apscheduler_obj, time_task_list)
+                cls.pause_time_job(apscheduler_obj, scene_data_dict)
             else:
-                time_stamp = cls.resume_job(apscheduler_obj, time_type, time_task_list)
-                # 返回时间戳,则更新
-                if time_stamp:
-                    scene_data_dict['condition']['time_dict']['time_stamp'] = time_stamp
-                    return scene_data_dict
+                cls.resume_time_job(apscheduler_obj, time_type, scene_data_dict)
 
     @staticmethod
-    def pause_job(apscheduler_obj, time_task_list):
+    def pause_time_job(apscheduler_obj, scene_data_dict):
         """
         暂停定时任务
         @param apscheduler_obj: apscheduler对象
-        @param time_task_list: 定时任务列表
+        @param scene_data_dict: 场景数据
         @return:
         """
+        time_task_list = scene_data_dict['task_list']
         for time_task in time_task_list:
             task_id = time_task.get('task_id')
             if task_id:
@@ -1393,14 +1389,15 @@ class SmartSceneView(View):
                     continue
 
     @classmethod
-    def resume_job(cls, apscheduler_obj, time_type, time_task_list):
+    def resume_time_job(cls, apscheduler_obj, time_type, scene_data_dict):
         """
         恢复定时任务
         @param apscheduler_obj: apscheduler对象
         @param time_type: 时间类型: date, cron
-        @param time_task_list: 定时任务列表
+        @param scene_data_dict: 场景数据
         @return: None or time_stamp
         """
+        time_task_list = scene_data_dict['task_list']
         if time_type == 'cron':
             for time_task in time_task_list:
                 task_id = time_task.get('task_id')
@@ -1412,7 +1409,7 @@ class SmartSceneView(View):
             return None
         else:
             now_time = int(time.time())
-            time_stamp = time_task_list[0]['time_dict']['time_stamp']
+            time_stamp = scene_data_dict['condition']['time_dict']['time_stamp']
             if time_stamp > now_time:
                 for time_task in time_task_list:
                     task_id = time_task.get('task_id')
@@ -1434,7 +1431,8 @@ class SmartSceneView(View):
                                                     args=(device_type, event_type, serial_number))
                     # 更新task_id
                     time_task['task_id'] = task_id
-                return time_stamp
+                # 更新场景数据的时间戳
+                scene_data_dict['condition']['time_dict']['time_stamp'] = time_stamp
 
 
 #