소스 검색

57提升数据交互效率-需解决3D图形构建失效问题

dev 1 주 전
부모
커밋
c03852bac5
71개의 변경된 파일62개의 추가작업 그리고 52개의 파일을 삭제
  1. BIN
      backend/api/__pycache__/__init__.cpython-310.pyc
  2. BIN
      backend/api/__pycache__/admin.cpython-310.pyc
  3. BIN
      backend/api/__pycache__/api_alert.cpython-310.pyc
  4. BIN
      backend/api/__pycache__/api_calculate.cpython-310.pyc
  5. BIN
      backend/api/__pycache__/api_graph.cpython-310.pyc
  6. BIN
      backend/api/__pycache__/api_graphicFile.cpython-310.pyc
  7. BIN
      backend/api/__pycache__/api_prepare.cpython-310.pyc
  8. BIN
      backend/api/__pycache__/api_rawDataTrans.cpython-310.pyc
  9. BIN
      backend/api/__pycache__/api_results.cpython-310.pyc
  10. BIN
      backend/api/__pycache__/api_system.cpython-310.pyc
  11. BIN
      backend/api/__pycache__/api_taskFile.cpython-310.pyc
  12. BIN
      backend/api/__pycache__/api_user.cpython-310.pyc
  13. BIN
      backend/api/__pycache__/apps.cpython-310.pyc
  14. BIN
      backend/api/__pycache__/scheduler.cpython-310.pyc
  15. BIN
      backend/api/__pycache__/serializers.cpython-310.pyc
  16. BIN
      backend/api/__pycache__/tokenAuthentication.cpython-310.pyc
  17. BIN
      backend/api/__pycache__/urls.cpython-310.pyc
  18. BIN
      backend/api/__pycache__/utils.cpython-310.pyc
  19. 8 4
      backend/api/api_prepare.py
  20. 1 1
      backend/api/api_rawDataTrans.py
  21. BIN
      backend/api/migrations/__pycache__/0001_initial.cpython-310.pyc
  22. BIN
      backend/api/migrations/__pycache__/0002_alter_user_options_user_last_login.cpython-310.pyc
  23. BIN
      backend/api/migrations/__pycache__/0003_view_file.cpython-310.pyc
  24. BIN
      backend/api/migrations/__pycache__/0004_rename_display_name_user_displayname_file_usage.cpython-310.pyc
  25. BIN
      backend/api/migrations/__pycache__/0005_file_associate_file_content.cpython-310.pyc
  26. BIN
      backend/api/migrations/__pycache__/0006_alter_file_associate.cpython-310.pyc
  27. BIN
      backend/api/migrations/__pycache__/0007_fileinfo.cpython-310.pyc
  28. BIN
      backend/api/migrations/__pycache__/0008_mission_result.cpython-310.pyc
  29. BIN
      backend/api/migrations/__pycache__/0009_alter_fileinfo_file_alter_mission_name.cpython-310.pyc
  30. BIN
      backend/api/migrations/__pycache__/0010_algorithm_plan.cpython-310.pyc
  31. BIN
      backend/api/migrations/__pycache__/0011_result_plan_result_state.cpython-310.pyc
  32. BIN
      backend/api/migrations/__pycache__/0012_result_edgefile_result_nodefile_alter_result_plan.cpython-310.pyc
  33. BIN
      backend/api/migrations/__pycache__/0013_remove_result_state_alter_file_usage.cpython-310.pyc
  34. BIN
      backend/api/migrations/__pycache__/0014_result_progress.cpython-310.pyc
  35. BIN
      backend/api/migrations/__pycache__/0015_mission_state.cpython-310.pyc
  36. BIN
      backend/api/migrations/__pycache__/0016_alter_result_edgefile_alter_result_nodefile.cpython-310.pyc
  37. BIN
      backend/api/migrations/__pycache__/0017_graph_graphtoken.cpython-310.pyc
  38. BIN
      backend/api/migrations/__pycache__/0018_rename_edgemap_graph_edges_and_more.cpython-310.pyc
  39. BIN
      backend/api/migrations/__pycache__/0019_alter_graph_user.cpython-310.pyc
  40. BIN
      backend/api/migrations/__pycache__/0020_alert_systemperformance.cpython-310.pyc
  41. BIN
      backend/api/migrations/__pycache__/0021_rename_indicator_alert_metric.cpython-310.pyc
  42. BIN
      backend/api/migrations/__pycache__/__init__.cpython-310.pyc
  43. BIN
      backend/api/models/__pycache__/__init__.cpython-310.pyc
  44. BIN
      backend/api/models/__pycache__/alert.cpython-310.pyc
  45. BIN
      backend/api/models/__pycache__/algorithm.cpython-310.pyc
  46. BIN
      backend/api/models/__pycache__/file.cpython-310.pyc
  47. BIN
      backend/api/models/__pycache__/graph.cpython-310.pyc
  48. BIN
      backend/api/models/__pycache__/mission.cpython-310.pyc
  49. BIN
      backend/api/models/__pycache__/plan.cpython-310.pyc
  50. BIN
      backend/api/models/__pycache__/result.cpython-310.pyc
  51. BIN
      backend/api/models/__pycache__/system.cpython-310.pyc
  52. BIN
      backend/api/models/__pycache__/user.cpython-310.pyc
  53. BIN
      backend/api/models/__pycache__/view.cpython-310.pyc
  54. 0 1
      backend/api/models/alert.py
  55. 1 0
      backend/api/models/file.py
  56. 1 1
      backend/api/scheduler.py
  57. BIN
      backend/backend/__pycache__/__init__.cpython-310.pyc
  58. BIN
      backend/backend/__pycache__/settings.cpython-310.pyc
  59. BIN
      backend/backend/__pycache__/urls.cpython-310.pyc
  60. BIN
      backend/backend/__pycache__/wsgi.cpython-310.pyc
  61. BIN
      backend/db.sqlite3
  62. BIN
      scheduler/__pycache__/processManager.cpython-310.pyc
  63. BIN
      scheduler/__pycache__/utils.cpython-310.pyc
  64. 10 26
      scheduler/algo1Folder/controller.py
  65. 10 5
      scheduler/processManager.py
  66. 2 2
      viewer/src/api/axios.js
  67. 1 0
      viewer/src/views/dashoard/analyze.vue
  68. 1 2
      viewer/src/views/dashoard/calculate.vue
  69. 5 1
      viewer/src/views/dashoard/plan.vue
  70. 8 7
      viewer/src/views/dashoard/view.vue
  71. 14 2
      viewer/src/views/welcome/welcome.vue

BIN
backend/api/__pycache__/__init__.cpython-310.pyc


BIN
backend/api/__pycache__/admin.cpython-310.pyc


BIN
backend/api/__pycache__/api_alert.cpython-310.pyc


BIN
backend/api/__pycache__/api_calculate.cpython-310.pyc


BIN
backend/api/__pycache__/api_graph.cpython-310.pyc


BIN
backend/api/__pycache__/api_graphicFile.cpython-310.pyc


BIN
backend/api/__pycache__/api_prepare.cpython-310.pyc


BIN
backend/api/__pycache__/api_rawDataTrans.cpython-310.pyc


BIN
backend/api/__pycache__/api_results.cpython-310.pyc


BIN
backend/api/__pycache__/api_system.cpython-310.pyc


BIN
backend/api/__pycache__/api_taskFile.cpython-310.pyc


BIN
backend/api/__pycache__/api_user.cpython-310.pyc


BIN
backend/api/__pycache__/apps.cpython-310.pyc


BIN
backend/api/__pycache__/scheduler.cpython-310.pyc


BIN
backend/api/__pycache__/serializers.cpython-310.pyc


BIN
backend/api/__pycache__/tokenAuthentication.cpython-310.pyc


BIN
backend/api/__pycache__/urls.cpython-310.pyc


BIN
backend/api/__pycache__/utils.cpython-310.pyc


+ 8 - 4
backend/api/api_prepare.py

@@ -98,6 +98,9 @@ class UploadFileAPI(APIView):
             successUploadedFiles.append({
                 "id": mission.id,
                 "name": mission.name,
+                # 防止近义词错误
+                "state": mission.state,
+                "status": mission.state,
                 "content": "mission",
             })
             
@@ -183,6 +186,7 @@ class InputFileAPI(APIView):
             mission.nodeFile = nodesFile
             mission.edgeFile = edgesFile
             mission.user = user
+            mission.state = 'init'
             mission.save()
             successUploadedFiles.append({
                 "id": mission.id,
@@ -216,7 +220,7 @@ class PlanAPI(APIView):
         try:
             mission = Mission.objects.get(id=request.GET.get('mission'))
         except Mission.DoesNotExist:
-            print("处理规划所属任务不存在", request.GET.get('mission'))
+            logger.error(f"处理规划所属任务不存在{request.GET.get('mission')}")
             return failed(message="未找到规划任务所属任务")
         plans = mission.own_plans.all()
         response = []
@@ -245,7 +249,7 @@ class PlanAPI(APIView):
         try:
             mission = Mission.objects.get(id=request.data.get('mission'))
         except Mission.DoesNotExist:
-            print("处理规划所属任务不存在")
+            logger.error("处理规划所属任务不存在")
             return failed(message="未找到规划任务所属任务")
         # 重复提交同一Mission的规划将覆盖
         if mission.own_plans.exists():
@@ -273,7 +277,7 @@ class PlanAPI(APIView):
             try:
                 algorithm = Algorithm.objects.get(name=pJson['algorithm'])
             except Algorithm.DoesNotExist:
-                print("Not Exist Algorithm")
+                logger.error("传递算法不存在")
                 return failed(message=str(pJson['id']) + "规划选定算法不存在")
             pModel = Plan(mission=mission, parent=rootPlan, algorithm=algorithm, user=user)
             pModel.save()
@@ -293,7 +297,7 @@ class PlanAPI(APIView):
                 try:
                     algorithm = Algorithm.objects.get(name=childJson['algorithm'])
                 except Algorithm.DoesNotExist:
-                    print("Not Exist Algorithm")
+                    logger.error("传递算法不存在")
                     return failed(message=str(pJson['id']) + "规划选定算法不存在")
                 childModel = Plan(mission=mission, parent=pModel, algorithm=algorithm, user=user)
                 childModel.save()

+ 1 - 1
backend/api/api_rawDataTrans.py

@@ -36,6 +36,7 @@ class RawDataTrans(APIView):
     def post(self, request):
         # 处理进程反馈计算结果
         progress_result = request.data.get('result')
+        logger.info(progress_result)
         performance = request.data.get('performance')
 
         for progress_data in progress_result:
@@ -123,6 +124,5 @@ class RawDataTrans(APIView):
                 'algorithm': process['algorithm'],
                 'creator': Mission.objects.get(id=int(process['missionId'])).user.username,
             })
-        logger.info(PROCESSPERFORMANCE)
 
         return success(message="汇报结果文件成功")

BIN
backend/api/migrations/__pycache__/0001_initial.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0002_alter_user_options_user_last_login.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0003_view_file.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0004_rename_display_name_user_displayname_file_usage.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0005_file_associate_file_content.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0006_alter_file_associate.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0007_fileinfo.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0008_mission_result.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0009_alter_fileinfo_file_alter_mission_name.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0010_algorithm_plan.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0011_result_plan_result_state.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0012_result_edgefile_result_nodefile_alter_result_plan.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0013_remove_result_state_alter_file_usage.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0014_result_progress.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0015_mission_state.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0016_alter_result_edgefile_alter_result_nodefile.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0017_graph_graphtoken.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0018_rename_edgemap_graph_edges_and_more.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0019_alter_graph_user.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0020_alert_systemperformance.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/0021_rename_indicator_alert_metric.cpython-310.pyc


BIN
backend/api/migrations/__pycache__/__init__.cpython-310.pyc


BIN
backend/api/models/__pycache__/__init__.cpython-310.pyc


BIN
backend/api/models/__pycache__/alert.cpython-310.pyc


BIN
backend/api/models/__pycache__/algorithm.cpython-310.pyc


BIN
backend/api/models/__pycache__/file.cpython-310.pyc


BIN
backend/api/models/__pycache__/graph.cpython-310.pyc


BIN
backend/api/models/__pycache__/mission.cpython-310.pyc


BIN
backend/api/models/__pycache__/plan.cpython-310.pyc


BIN
backend/api/models/__pycache__/result.cpython-310.pyc


BIN
backend/api/models/__pycache__/system.cpython-310.pyc


BIN
backend/api/models/__pycache__/user.cpython-310.pyc


BIN
backend/api/models/__pycache__/view.cpython-310.pyc


+ 0 - 1
backend/api/models/alert.py

@@ -27,7 +27,6 @@ class AlertManager(models.Manager):
     def checkAlert(self):
         triggeredAlert = []
         for alert in self.get_queryset().filter(state='enable'):
-            print(SYSTEMPERFORMANCE)
             # 系统级检测
             if alert.level == 'system':
                 if alert.metric == 'cpu' and alert.threshold <= float(SYSTEMPERFORMANCE['cpu']):

+ 1 - 0
backend/api/models/file.py

@@ -266,6 +266,7 @@ class File(models.Model):
                     # 如果有额外数据,则放入第三个字段中
                     node = {'id': line[0], 'type': line[1], 'meta': []}
                     for el in range(2, len(line)):
+                        logger.error(el)
                         node['meta'].append(json.loads(el))
                     
                     # 测试用,添加optimize

+ 1 - 1
backend/api/scheduler.py

@@ -55,7 +55,7 @@ def start_scheduler():
             scheduler.add_job(
                 checkAlert,
                 'interval',
-                seconds=5,
+                seconds=2,
                 id="5_seconds_job",
                 replace_existing=True,
             )

BIN
backend/backend/__pycache__/__init__.cpython-310.pyc


BIN
backend/backend/__pycache__/settings.cpython-310.pyc


BIN
backend/backend/__pycache__/urls.cpython-310.pyc


BIN
backend/backend/__pycache__/wsgi.cpython-310.pyc


BIN
backend/db.sqlite3


BIN
scheduler/__pycache__/processManager.cpython-310.pyc


BIN
scheduler/__pycache__/utils.cpython-310.pyc


+ 10 - 26
scheduler/algo1Folder/controller.py

@@ -36,38 +36,22 @@ progressData = {
     'progress': 0,
 }
 print(json.dumps({'msg': 'progress', 'data': progressData}), flush=True)
-start_time = time.perf_counter()
-count = 0
-while True:
-    count += 1
-    if time.perf_counter() - start_time >= 10.0:
-        break   
-progressData['progress'] = 20
-print(json.dumps({'msg': 'progress', 'data': progressData}), flush=True)
-start_time = time.perf_counter()
-count = 0
-while True:
-    count += 1
-    if time.perf_counter() - start_time >= 10.0:
-        break   
+while progressData['progress'] < 100:
+    start_time = time.perf_counter()
+    count = 0
+    while True:
+        count += 1
+        if time.perf_counter() - start_time >= 1.0:
+            break   
+    progressData['progress'] += 5
+    print(json.dumps({'msg': 'progress', 'data': progressData}), flush=True)
 
-progressData['progress'] = 40
-print(json.dumps({'msg': 'progress', 'data': progressData}), flush=True)
 start_time = time.perf_counter()
 count = 0
 while True:
     count += 1
-    if time.perf_counter() - start_time >= 10.0:
+    if time.perf_counter() - start_time >= 5.0:
         break   
-progressData['progress'] = 60
-print(json.dumps({'msg': 'progress', 'data': progressData}), flush=True)
-start_time = time.perf_counter()
-count = 0
-while True:
-    count += 1
-    if time.perf_counter() - start_time >= 10.0:
-        break   
-
 
 ''' 完成计算 '''
 result = {

+ 10 - 5
scheduler/processManager.py

@@ -31,8 +31,10 @@ class ProcessManager:
         self.report_queue = Queue()
         self._report_thread = threading.Thread(target=self._report_loop, daemon=True)
         self.max_batch = 20
-        self.report_interval = 5 # 5s发送一次数据
-
+        self.report_interval = 1 # 1s发送一次数据
+        # 创建长连接session,避免多次握手开销
+        self.report_session = requests.Session()
+        
         # 配置日志
         self.log_dir: str = "process_logs"
         # 确保日志目录存在
@@ -86,7 +88,7 @@ class ProcessManager:
             report_progress.append(item)
         # 汇报系统性能信息
         report_performance = {}
-        cpu_system = psutil.cpu_percent(interval=1)
+        cpu_system = psutil.cpu_percent()
         mem_system = psutil.virtual_memory()
         mem_total = float(mem_system.total) / (1024**3)
         mem_used = float(mem_system.used) / (1024**3)
@@ -118,7 +120,7 @@ class ProcessManager:
                 'algorithm': self.processes[pid]['meta']['algorithm'],
             })
         # 发送汇报请求
-        response = requests.post(BACKEND_BASE_URL + "/rawDataTrans/", json={
+        response = self.report_session.post(BACKEND_BASE_URL + "/rawDataTrans/", json={
             'result': report_progress,
             'performance': report_performance,
         })
@@ -512,4 +514,7 @@ class ProcessManager:
         self.logger.error(f"进程超时处理 PID={pid} | 运行时间: {time.time() - info['start_time']:.1f}s")
         # 调用store终止该mission
         store.removeMission(missionId=info['meta']['mission']['id'])
-        self.logger.error(f"任务进程发生超时,Mission {info['meta']['mission']['id']}已终止")
+        self.logger.error(f"任务进程发生超时,Mission {info['meta']['mission']['id']}已终止")
+        
+    def __del__(self):
+        self.report_session.close()

+ 2 - 2
viewer/src/api/axios.js

@@ -1,7 +1,7 @@
 import axios from 'axios';
 
-// const baseURL = "http://localhost:8000/api";
-const baseURL = "http://8.149.247.53:9174/api";
+const baseURL = "http://localhost:8000/api";
+// const baseURL = "http://8.149.247.53:9174/api";
 
 let csrfToken = "";
 let userToken = "";

+ 1 - 0
viewer/src/views/dashoard/analyze.vue

@@ -436,6 +436,7 @@ const preparePlan = (response) => {
     if (file.content === 'mission') {
       useAnalyzeInfo.analyzeInfo.value.mission.id = file.id
       useAnalyzeInfo.analyzeInfo.value.mission.name = file.name
+      useAnalyzeInfo.analyzeInfo.value.mission.status = file.status
     }
   })
   // 将获取到的数据写入页面缓存,防止刷新丢失

+ 1 - 2
viewer/src/views/dashoard/calculate.vue

@@ -333,7 +333,6 @@ const startCalculate = async () => {
     try {
       const response = await getData('/results', { 'mission': JSON.stringify(mission) })
       // 成功获取进度更新信息,将进度赋值给progress
-      console.log(response)
       if (response.status === "success") {
         // 任务是否全部完成
         let missionComplete = true
@@ -367,7 +366,7 @@ const startCalculate = async () => {
       console.log("catch error when start interval", error)
       clearInterval(progressInterval.value)
     }
-  }, 2000) // 2s更新一次
+  }, 1000) // 1s更新一次
 }
 
 const pauseCalculate = async () => {

+ 5 - 1
viewer/src/views/dashoard/plan.vue

@@ -626,6 +626,11 @@ watch(
           if (mission.value.id === null) {
             fetchData()
           }
+          if (mission.value.id === null) {
+            // 从sessionstorage中仍未获取到数据,则需要继续跳回
+            router.push("/dashboard")
+            return 
+          }
           const response = await getData('/plan/', { mission: mission.value.id })
           const rootBtn = response.data.find(p => p.parent === null)
           let findStack = [rootBtn]
@@ -682,7 +687,6 @@ watch(
           ElMessage.error("获取规划任务数据出错,返回规划页面")
           planning.value = true
           calculating.value = false
-          router.push('/dashboard/analyze/plan')
         }
       } else {
         // 缓存中有数据,不做处理

+ 8 - 7
viewer/src/views/dashoard/view.vue

@@ -123,20 +123,19 @@ const handleCardClick = (id) => {
   // 如果已经计算,应进入calculate界面
   let mission = missions.value.find(mission => mission.id == id)
   preparePlan(mission)
-  if(mission.status == "init"){
+  if(mission.status === "init"){
     // 初始状态,应进入流程规划
     // 切换显示plan的routeview
-    showMissions.value = falseq
-    router.push(`/dashboard/view/plan`)
+    showMissions.value = false
+    router.push(`/dashboard/analyze/plan`)
   }else{
+    showMissions.value = false
     // 否则进入calculate界面,可查看计算过程或结果
-    router.push(`/dashboard/view/plan/calculate`)
+    router.push(`/dashboard/analyze/plan/calculate`)
   } 
 }
 
 const preparePlan = (mission) => {
-  console.log("选中的Mission:")
-  console.log(mission)
   useAnalyzeInfo.analyzeInfo.value.nodeFile.amount = mission.nodesInfo.S + mission.nodesInfo.D + mission.nodesInfo.I
   useAnalyzeInfo.analyzeInfo.value.nodeFile.sNodes = mission.nodesInfo.S
   useAnalyzeInfo.analyzeInfo.value.nodeFile.dNodes = mission.nodesInfo.D
@@ -150,6 +149,8 @@ const preparePlan = (mission) => {
     status: mission.status,
   }
   console.log(useAnalyzeInfo.analyzeInfo.value)
+  // 将获取到的数据写入页面缓存,防止刷新丢失
+  sessionStorage.setItem('analyze-info', JSON.stringify(useAnalyzeInfo.analyzeInfo.value))
 }
 
 //加载数据
@@ -167,7 +168,7 @@ const loadMissions = async () => {
       status: mission.status,
       // 需要后续完善描述输入
       description: "This is description",
-    }));
+    })).sort((a, b) => b.id - a.id);
     pagination.value.total = missions.value.length;
   } catch (error) {
     console.error(error);

+ 14 - 2
viewer/src/views/welcome/welcome.vue

@@ -1,7 +1,7 @@
 <template>
     <el-carousel :height="car_height">
-        <el-carousel-item v-for="item in 4" :key="item">
-            <h3 class="small justify-center" text="2xl">{{ item }}</h3>
+        <el-carousel-item v-for="(img, index) in carouselImages" :key="index">
+          <el-image :src="img" fit="cover" style="width: 100%; height: 100%"/>
         </el-carousel-item>
     </el-carousel>
 </template>
@@ -31,6 +31,18 @@
 import { ref, provide, watch, computed, onActivated, onMounted } from "vue";
 import { onBeforeRouteLeave } from "vue-router";
 
+const imgModules = import.meta.glob('@/assets/*.png', { eager: true })
+
+const carouselImages = ref(
+  Object.values(imgModules)
+    .map(module => module.default)
+    .sort((a, b) => {
+      const numA = parseInt(a.match(/(\d+)\.png$/)[1])
+      const numB = parseInt(b.match(/(\d+)\.png$/)[1])
+      return numA - numB
+    })
+)
+
 defineOptions({
     name: "Welcome"
 });