增加任务执行逻辑

master
dongzeliang 2023-12-05 09:43:49 +08:00
parent 5f31da6db2
commit 1f3eb43eb8
2 changed files with 67 additions and 14 deletions

View File

@ -131,3 +131,12 @@ export function unifiedStop() {
method: 'post' method: 'post'
}) })
} }
/**
* 一键执行任务状态
*/
export function unifiedStatus() {
return request({
url: `/vehicle/instance/unified/status`,
method: 'GET'
})
}

View File

@ -1,19 +1,33 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-row :gutter="10" style="margin-bottom: 10px;padding: 0 10px">
<el-col :span="24">
<el-button @click="addVehicleDrawer = true">添加车辆</el-button>
<el-button @click="genVehicleDialog = true" type="primary">生成车辆</el-button>
<el-button @click="vehicleUnifiedOnline" type="success">一键上线</el-button>
<el-button @click="vehicleUnifiedOffline" type="success">一键离线</el-button>
<el-button @click="vehicleUnifiedSend" type="primary">一键上报</el-button>
<el-button @click="vehicleUnifiedPosition" type="primary">一键重置路径</el-button>
<el-button @click="vehicleUnifiedStop" type="warning">一键取消上报</el-button>
<el-popover v-if="unifiedInfo.unifiedStatus"
style="margin-left: 15px"
placement="top-start"
title="任务执行状态"
width="200"
trigger="hover">
<el-progress :percentage="(unifiedInfo.taskSuccessSum+unifiedInfo.taskErrorSum)/unifiedInfo.taskExecutionSum*100" :color="customColors"></el-progress>
<div style="width: 100%; margin: 5px 0">任务描述<el-tag>{{unifiedInfo.taskName}}</el-tag></div>
<div style="width: 100%; margin: 5px 0">任务总数<el-tag>{{unifiedInfo.taskExecutionSum}}</el-tag></div>
<div style="width: 100%; margin: 5px 0">成功总数<el-tag>{{unifiedInfo.taskSuccessSum}}</el-tag></div>
<div style="width: 100%; margin: 5px 0">失败总数<el-tag>{{unifiedInfo.taskErrorSum}}</el-tag></div>
<el-button slot="reference">有任务在执行</el-button>
</el-popover>
</el-col>
</el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="10"> <el-col :span="10">
<el-row :gutter="10" style="height: 150px;"> <el-row :gutter="10" style="height: 100px;">
<el-row :gutter="10" style="margin-bottom: 10px;padding: 0 10px">
<el-col :span="24">
<el-button @click="addVehicleDrawer = true">添加车辆</el-button>
<el-button @click="genVehicleDialog = true" type="primary">生成车辆</el-button>
<el-button @click="vehicleUnifiedOnline" type="success">一键上线</el-button>
<el-button @click="vehicleUnifiedOffline" type="success">一键离线</el-button>
<el-button @click="vehicleUnifiedSend" type="primary">一键上报</el-button>
<el-button @click="vehicleUnifiedPosition" type="primary">一键重置路径</el-button>
<el-button @click="vehicleUnifiedStop" type="warning">一键取消上报</el-button>
</el-col>
</el-row>
<el-row :gutter="10" style="margin-bottom: 10px;padding: 0 10px"> <el-row :gutter="10" style="margin-bottom: 10px;padding: 0 10px">
<el-col :span="6"> <el-col :span="6">
<el-input v-model="queryParams.vin" prefix-icon="el-icon-search" placeholder="VIN检索(模糊)"></el-input> <el-input v-model="queryParams.vin" prefix-icon="el-icon-search" placeholder="VIN检索(模糊)"></el-input>
@ -240,7 +254,7 @@ import {
instanceClientInit, instanceData, instanceClientInit, instanceData,
instanceGear, instanceGear,
instanceList, instanceList,
instanceMsg, unifiedOffline, unifiedOnline, unifiedPosition, unifiedSend, unifiedStop instanceMsg, unifiedOffline, unifiedOnline, unifiedPosition, unifiedSend, unifiedStatus, unifiedStop
} from '@/api/vehicle/instance' } from '@/api/vehicle/instance'
import {positionList} from "@/api/vehicle/position"; import {positionList} from "@/api/vehicle/position";
import { create, gen } from '@/api/vehicle/vehicle' import { create, gen } from '@/api/vehicle/vehicle'
@ -282,7 +296,25 @@ export default {
// //
genForm: { genForm: {
number: 0 number: 0
} },
//
unifiedInfo: {
unifiedStatus: false,
taskName: null,
taskExecutionSum: null,
taskStartTime: null,
taskSuccessSum: null,
taskErrorSum: null
},
unifiedInfoInterval: null,
//
customColors: [
{ color: '#f56c6c', percentage: 20 },
{ color: '#e6a23c', percentage: 40 },
{ color: '#1989fa', percentage: 60 },
{ color: '#6f7ad3', percentage: 80 },
{ color: '#5cb87a', percentage: 100 }
]
} }
}, },
created() { created() {
@ -292,6 +324,17 @@ export default {
this.intervalVehicleDataContinued = setInterval(this.vehicleDataContinued, 1000); this.intervalVehicleDataContinued = setInterval(this.vehicleDataContinued, 1000);
}, },
methods: { methods: {
/**
* 获取状态
*/
vehicleUnifiedStatus() {
unifiedStatus().then(response => {
this.unifiedInfo = response.data;
if (!this.unifiedInfo.unifiedStatus){
clearInterval(this.unifiedInfoInterval);
}
})
},
/** /**
* 一键上线 * 一键上线
*/ */
@ -302,6 +345,7 @@ export default {
message: response.msg, message: response.msg,
type: response.code === 200 ? 'success' : 'error' type: response.code === 200 ? 'success' : 'error'
}) })
this.unifiedInfoInterval = setInterval(this.vehicleUnifiedStatus, 100)
}) })
}, },
/** /**