Explorar o código

feat: 暂停、重启、中止任务

hum hai 1 ano
pai
achega
05e94bacb9

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ReportDataService.java

@@ -28,4 +28,6 @@ public interface ReportDataService {
 
     BerthingPointConfig getPointConfig (Long siteId, Long planid);
 
+    TaskResult getLatestTask (Long siteId);
+
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ReportDataServiceImpl.java

@@ -182,6 +182,11 @@ public class ReportDataServiceImpl implements ReportDataService {
         return berthingPointConfigMapper.queryByPlanid(siteId, planid);
     }
 
+    @Override
+    public TaskResult getLatestTask(Long siteId) {
+        return taskResultMapper.queryBySiteIdOne(siteId);
+    }
+
     private static LocalTime parseTime(Object timeStr) {
         return LocalTime.parse(timeStr.toString(), DateTimeFormatter.ofPattern("HH:mm"));
     }

+ 8 - 0
ruoyi-ui/src/api/analysis/achievement.js

@@ -95,6 +95,14 @@ export function getPointConfig(siteId) {
   })
 }
 
+export function getLatestTask(siteId) {
+  return request({
+    url: '/reportData/getLatestTask',
+    method: 'get',
+    params: { siteId },
+  })
+}
+
 export function getPointConfigByPlanid(siteId, planid) {
   return request({
     url: '/reportData/getPointConfigByPlanid',

+ 1 - 0
ruoyi-ui/src/assets/icons/svg/realtime-pause.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="40" height="40" viewBox="0 0 40 40"><defs><linearGradient x1="0.5" y1="0" x2="0.5" y2="1" id="master_svg0_211_00643"><stop offset="0%" stop-color="#FAFCFF" stop-opacity="1"/><stop offset="100%" stop-color="#E5EAF1" stop-opacity="1"/></linearGradient><linearGradient x1="0.5" y1="0" x2="0.5" y2="1" id="master_svg1_211_00755"><stop offset="0%" stop-color="#E7ECF3" stop-opacity="1"/><stop offset="100%" stop-color="#FEFEFF" stop-opacity="1"/></linearGradient><linearGradient x1="0.5" y1="0" x2="0.5" y2="1" id="master_svg2_109_39636"><stop offset="0%" stop-color="#FF5858" stop-opacity="1"/><stop offset="100%" stop-color="#F42626" stop-opacity="1"/></linearGradient></defs><g><g><ellipse cx="20" cy="20" rx="20" ry="20" fill="url(#master_svg0_211_00643)" fill-opacity="1"/><ellipse cx="20" cy="20" rx="18.5" ry="18.5" stroke="url(#master_svg1_211_00755)" fill-opacity="0" fill="none" stroke-width="3"/></g><g><rect x="13" y="13" width="14" height="14" rx="4" fill="url(#master_svg2_109_39636)" fill-opacity="1"/></g></g></svg>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
ruoyi-ui/src/assets/icons/svg/realtime-play.svg


+ 1 - 0
ruoyi-ui/src/assets/icons/svg/realtime-stop.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="40" height="40" viewBox="0 0 40 40"><defs><linearGradient x1="0.5" y1="0" x2="0.5" y2="1" id="master_svg0_211_00643"><stop offset="0%" stop-color="#FAFCFF" stop-opacity="1"/><stop offset="100%" stop-color="#E5EAF1" stop-opacity="1"/></linearGradient><linearGradient x1="0.5" y1="0" x2="0.5" y2="1" id="master_svg1_211_00755"><stop offset="0%" stop-color="#E7ECF3" stop-opacity="1"/><stop offset="100%" stop-color="#FEFEFF" stop-opacity="1"/></linearGradient><linearGradient x1="0.5" y1="0" x2="0.5" y2="1" id="master_svg2_109_39636"><stop offset="0%" stop-color="#FF5858" stop-opacity="1"/><stop offset="100%" stop-color="#F42626" stop-opacity="1"/></linearGradient></defs><g><g><ellipse cx="20" cy="20" rx="20" ry="20" fill="url(#master_svg0_211_00643)" fill-opacity="1"/><ellipse cx="20" cy="20" rx="18.5" ry="18.5" stroke="url(#master_svg1_211_00755)" fill-opacity="0" fill="none" stroke-width="3"/></g><g><rect x="13" y="13" width="14" height="14" rx="4" fill="url(#master_svg2_109_39636)" fill-opacity="1"/></g></g></svg>

+ 16 - 11
ruoyi-ui/src/views/analysis/task/realtime.vue

@@ -1,9 +1,9 @@
 <template>
-  <Realtime v-if="siteId" :siteId="siteId" :positions="positions" />
+  <Realtime v-if="task.taskid" :task="task" @refresh="loadTask" />
 </template>
 
 <script>
-import { getAchievement, getPointConfigByPlanid, getPointConfig } from '@/api/analysis/achievement';
+import {getAchievement, getLatestTask} from '@/api/analysis/achievement';
 import Realtime from './realtime/realtime';
 
 export default {
@@ -14,21 +14,26 @@ export default {
     return {
       siteId: 0,
       task: {},
-      positions: [],
     }
   },
   mounted() {
     const { siteId } = this.$route.params;
     this.siteId = siteId;
-    const { taskid } = this.$route.query;
-    const promise = taskid ? getAchievement(taskid).then((res) => {
-      this.task = res.data;
-      return getPointConfigByPlanid(siteId, res.data.planid);
-    }) : getPointConfig(siteId);
-    promise.then((res) => {
-      this.positions = JSON.parse(res.data.positions || '[]');
-    })
+    this.loadTask();
   },
+  methods: {
+    loadTask() {
+      const { taskid } = this.$route.query;
+      const promise = taskid ? getAchievement(taskid) : getLatestTask(this.siteId);
+      promise.then((res) => {
+        if (res.data === null) {
+          this.$message.error("测流任务不存在");
+        } else {
+          this.task = res.data;
+        }
+      })
+    }
+  }
 }
 </script>
 

+ 26 - 7
ruoyi-ui/src/views/analysis/task/realtime/realtime.vue

@@ -2,7 +2,14 @@
   <div class="hum-page-container">
     <el-row :gutter="10">
       <el-col :span="18">
-        <Simulation ref="simulation" :siteId="siteId" :positions="positions" :measureLine="measureLine" />
+        <Simulation
+          ref="simulation"
+          :siteId="siteId"
+          :positions="positions"
+          :measureLine="measureLine"
+          :siteRealTime="siteRealTime"
+          :task="task"
+          @refresh="$emit('refresh')" />
         <el-row :gutter="20" style="margin-top: 10px">
           <el-col :span="8">
             <Site :siteRealTime="siteRealTime" />
@@ -34,7 +41,14 @@ import Movie from './movie'
 import Flow from './flow'
 import Water from './water'
 import Report from './report'
-import { getCarInfo, getSiteRealTime, getTaskNotice, listMeasureLine, listWaterLevel, getPointConfig, getPointConfigByPlanid } from "@/api/analysis/achievement";
+import {
+  getCarInfo,
+  getSiteRealTime,
+  getTaskNotice,
+  listMeasureLine,
+  listWaterLevel,
+  getPointConfigByPlanid,
+} from "@/api/analysis/achievement";
 
 export default {
   components: {
@@ -48,11 +62,12 @@ export default {
     Report,
   },
   props: {
-    siteId: Number | String,
-    positions: Array,
+    task: Object,
   },
   data() {
     return {
+      siteId: this.$route.params.siteId,
+      positions: [],
       carInfo: {},
       siteRealTime: {},
       messages: [],
@@ -68,9 +83,7 @@ export default {
     loadMeasureLine() {
       const params = {
         siteId: this.siteId,
-      }
-      if (this.$route.query.taskid) {
-        params.taskId = this.$route.query.taskid;
+        taskId: this.task.taskid,
       }
       listMeasureLine(params).then((res) => {
         const measureLine = res.data || [];
@@ -110,8 +123,14 @@ export default {
         this.$refs.water.setOptions(res.data?.records || [])
       })
     },
+    loadPositions() {
+      getPointConfigByPlanid(this.siteId, this.task.planid).then((res) => {
+        this.positions = JSON.parse(res.data.positions || '[]');
+      })
+    }
   },
   mounted() {
+    this.loadPositions();
     this.loadCarInfo();
     this.timer1 = setInterval(() => this.loadCarInfo(), 5e3)
     this.loadMeasureLine();

+ 93 - 2
ruoyi-ui/src/views/analysis/task/realtime/simulation.vue

@@ -1,6 +1,27 @@
 <template>
   <div class="realtime-container">
-    <div ref="chart" class="chart" :style="{height: '500px', width: '100%'}" />
+    <div ref="chart" class="chart" :style="{height: '400px', width: '100%'}" />
+    <div class="realtime-foot">
+      <div class="realtime-foot-title">实时动态模拟</div>
+      <div class="realtime-foot-actions">
+        <div class="realtime-foot-action" v-if="task.status === 0">
+          <svg-icon icon-class="realtime-pause" class-name="realtime-foot-action-icon" @click="pause" />
+          <div class="realtime-foot-action-label">暂停任务</div>
+        </div>
+        <div class="realtime-foot-action" v-if="task.status === 3">
+          <svg-icon icon-class="realtime-play" class-name="realtime-foot-action-icon" @click="play" />
+          <div class="realtime-foot-action-label">开始任务</div>
+        </div>
+        <div class="realtime-foot-action" v-if="task.status === 0 || task.status === 3">
+          <svg-icon icon-class="realtime-stop" class-name="realtime-foot-action-icon" @click="stop" />
+          <div class="realtime-foot-action-label">中止任务</div>
+        </div>
+      </div>
+      <div class="realtime-foot-time">
+        <div class="realtime-foot-time-label">施测时间:</div>
+        <div class="realtime-foot-time-value">2024-4-2 12:50:32</div>
+      </div>
+    </div>
   </div>
 </template>
 
@@ -10,7 +31,7 @@ require('echarts/theme/macarons') // echarts theme
 import resize from '@/utils/resize'
 import { getConfig } from '@/api/site/site'
 import { getSiteSection } from '@/api/site/berthing'
-import { getCarLocation, getWaterLevel } from '@/api/analysis/achievement'
+import { getCarLocation, getWaterLevel, taskAction } from '@/api/analysis/achievement'
 import CarSvg from '@/assets/images/car.svg'
 
 export default {
@@ -19,6 +40,8 @@ export default {
     siteId: Number | String,
     positions: Array,
     measureLine: Array,
+    siteRealTime: Object,
+    task: Object,
   },
   data() {
     return {
@@ -48,6 +71,30 @@ export default {
     }
   },
   methods: {
+    pause() {
+      this.$modal.confirm('是否确认暂停当前任务?').then(() => {
+        return taskAction(this.siteId, 1);
+      }).then(() => {
+        this.$emit('refresh');
+        this.$modal.msgSuccess("暂停成功");
+      }).catch(() => {});
+    },
+    play() {
+      this.$modal.confirm('是否确认重启当前任务?').then(() => {
+        return taskAction(this.siteId, 2);
+      }).then(() => {
+        this.$emit('refresh');
+        this.$modal.msgSuccess("重启成功");
+      }).catch(() => {});
+    },
+    stop() {
+      this.$modal.confirm('是否确认中止当前任务?').then(() => {
+        return taskAction(this.siteId, 0);
+      }).then(() => {
+        this.$emit('refresh');
+        this.$modal.msgSuccess("中止成功");
+      }).catch(() => {});
+    },
     loadCarLocation() {
       getCarLocation(this.siteId).then((res) => {
         this.location = res.data?.position || 0;
@@ -253,5 +300,49 @@ export default {
   height: 500px;
   background: linear-gradient(0, #FFFFFF 57%, #D1E8FF 100%);
   border-radius: 4px;
+  padding: 0 20px;
+}
+.realtime-foot {
+  height: 100px;
+  background: #fff;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+.realtime-foot-title {
+  font-size: 18px;
+  font-weight: 600;
+  color: #1D2738;
+}
+.realtime-foot-actions {
+  display: flex;
+  align-items: center;
+}
+.realtime-foot-action {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  margin: 0 25px;
+  cursor: pointer;
+}
+.realtime-foot-action-icon {
+  width: 40px;
+  height: 40px;
+}
+.realtime-foot-action-label {
+  font-size: 12px;
+  line-height: 20px;
+  color: #54606C;
+}
+.realtime-foot-time {
+  display: flex;
+  align-items: center;
+  font-size: 14px;
+}
+.realtime-foot-time-label {
+  color: #54606C;
+}
+.realtime-foot-time-value {
+  color: #1D2738;
 }
 </style>

+ 7 - 0
waterAffairs-admin/src/main/java/com/ruoyi/web/controller/tool/ReportDataController.java

@@ -80,6 +80,13 @@ public class ReportDataController {
         return R.ok(reportDataService.getPointConfig(siteId));
     }
 
+    //获取最后一次任务详情
+    @GetMapping(value = "/getLatestTask")
+    @ApiOperation("获取最后一次任务详情")
+    public R<TaskResult> getLatestTask(Long siteId)  {
+        return R.ok(reportDataService.getLatestTask(siteId));
+    }
+
     //垂线点对应流量图
     @GetMapping(value = "/getPointConfigByPlanid")
     @ApiOperation("通过策略编号获取停泊点信息")

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio