From da47a3349dcfd87db23ab8e64fbf35fe1aea5685 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 14 十一月 2024 16:52:21 +0800 Subject: [PATCH] 预测项数据 --- src/views/model/pre/item/MmPredictItemForm.vue | 6 - /dev/null | 149 ------------------------ src/views/model/pre/item/MmPredictItemChart.vue | 143 +++++++++++++++++------ src/api/model/pre/dm/index.ts | 2 src/api/model/mcs/index.ts | 23 +++ 5 files changed, 126 insertions(+), 197 deletions(-) diff --git a/src/api/model/mcs/index.ts b/src/api/model/mcs/index.ts new file mode 100644 index 0000000..0433f38 --- /dev/null +++ b/src/api/model/mcs/index.ts @@ -0,0 +1,23 @@ +import request from '@/config/axios' + +export interface PreDataBarLineReqVO { + queryIds: string[], + predictTime: string, + startTime: string, + endTime: string +} + +export interface PreDataItemChartReqVO { + itemId: string, + startTime: string, + endTime: string +} + + +export const getPreDataCharts = (data: PreDataBarLineReqVO) => { + return request.post({ url: '/model/api/mcs/predict-data/charts', data }) +} + +export const getPreDataItemChart = (data: PreDataItemChartReqVO) => { + return request.post({ url: '/model/api/mcs/predict-data/item-chart', data }) +} diff --git a/src/api/model/pre/dm/index.ts b/src/api/model/pre/dm/index.ts index aa652b6..69e13c3 100644 --- a/src/api/model/pre/dm/index.ts +++ b/src/api/model/pre/dm/index.ts @@ -1,7 +1,7 @@ import request from '@/config/axios' export interface DmModuleVO { - id: string + id: string, modulename: string, moduletype: string, cycle: string diff --git a/src/api/model/pre/result/index.ts b/src/api/model/pre/result/index.ts deleted file mode 100644 index 5561e94..0000000 --- a/src/api/model/pre/result/index.ts +++ /dev/null @@ -1,46 +0,0 @@ -import request from '@/config/axios' - -export interface MmResultTableVO { - id: string - tablename: string, -} - -export interface MmResultTablePageReqVO extends PageParam { - tablename?: string -} - -// 查询MmResultTable列表 -export const getMmResultTablePage = (params: MmResultTablePageReqVO) => { - return request.get({ url: '/model/pre/result-table/page', params }) -} - -// 查询MmResultTable详情 -export const getMmResultTable = (id: number) => { - return request.get({ url: `/model/pre/result-table/get/${id}`}) -} - -// 新增MmResultTable -export const createMmResultTable = (data: MmResultTableVO) => { - return request.post({ url: '/model/pre/result-table/create', data }) -} - -// 修改MmResultTable -export const updateMmResultTable = (data: MmResultTableVO) => { - return request.put({ url: '/model/pre/result-table/update', data }) -} - -// 删除MmResultTable -export const deleteMmResultTable = (id: number) => { - return request.delete({ url: '/model/pre/result-table/delete?id=' + id }) -} - - -// 查询getResulttableList详情 -export const getResulttableList = () => { - return request.get({ url: `/model/pre/result-table/list`}) -} - -// 查询getResulttableList详情 -export const getResultstridList = () => { - return request.get({ url: `/model/pre/model-resultstr/list`}) -} diff --git a/src/views/model/pre/item/MmPredictItemChart.vue b/src/views/model/pre/item/MmPredictItemChart.vue index 215c854..3fd55b5 100644 --- a/src/views/model/pre/item/MmPredictItemChart.vue +++ b/src/views/model/pre/item/MmPredictItemChart.vue @@ -1,6 +1,6 @@ <template> <el-dialog - title="采集值" + title="预测数据" :close-on-click-modal="false" width="50%" v-model="visible" @@ -39,47 +39,48 @@ plain @click="handleExport" :loading="exportLoading" - v-hasPermi="['data:point:export']" > - <Icon icon="ep:download" />导出 + <Icon icon="ep:download"/> + 导出 </el-button> </el-form-item> </el-form> - <div ref="chartDom" class="result-chart"></div> + <div ref="chartDomPre" class="result-chart"></div> </el-dialog> </template> <script lang="ts" setup> import {ref} from 'vue'; import * as echarts from 'echarts'; -import * as DaPoint from '@/api/data/da/point/daPointChart' +import * as McsApi from '@/api/model/mcs' import {getYMDHM0} from "@/utils/dateUtil" import download from "@/utils/download"; + const message = useMessage() // 消息弹窗 const visible = ref(false); -const chartDom = ref(null); +const chartDomPre = ref(null); let myChart = null; const chartParams = reactive({ - codes:[], - startDate : undefined, - endDate: undefined, + itemId: undefined, + startTime: undefined, + endTime: undefined, }) const dataForm = ref({ id: "", - pointNo: "", - pointName: "", - pointTypeName: "", + itemName: "", startTime: getYMDHM0(new Date() - 60 * 60 * 1000), - endTime: "", + endTime: getYMDHM0(new Date() + 60 * 60 * 1000), }); /** 打开弹窗 */ const open = async (row: object) => { visible.value = true + resetForm() dataForm.value.id = row.id; - dataForm.value.pointNo = row.pointNo; - dataForm.value.pointName = row.pointName; - getDataList(); + dataForm.value.itemName = row.itemname; + if (row.id) { + getDataList(); + } } defineExpose({open}) // 提供 open 方法,用于打开弹窗 @@ -88,31 +89,79 @@ visible.value = true; if (dataForm.value.id) { try { - chartParams.codes=[dataForm.value.pointNo]; - chartParams.startDate = dataForm.value.startTime; - chartParams.endDate = dataForm.value.endTime; - const data = await DaPoint.getPointDaChart(chartParams) + chartParams.itemId = dataForm.value.id; + chartParams.startTime = dataForm.value.startTime; + chartParams.endTime = dataForm.value.endTime; + const data = await McsApi.getPreDataItemChart(chartParams) + let legendData = [] + if (data.legend && data.legend.length > 0) { + data.legend.forEach(item => { + legendData.push(item + ":" + '真实值') + legendData.push(item + ":" + '预测值') + }) + } + let seriesData = [] - data.series.forEach(item => { + if (data.lastTime) { seriesData.push({ - name: item.name, - type: "line", - data: item.data, - showSymbol: true, - smooth: false, - lineStyle: { - normal: { - color: "#5B8FF9", - width: 1, + name: '', + data: [null], + type: 'line', + smooth: true, + color: 'green', + markLine: { + silent: true, + lineStyle: { + color: '#32a487', + width: 2 }, + data: [{ + xAxis: data.lastTime + }], + label: { + normal: { + formatter: data.lastTime + } + }, + symbol: ['circle', 'none'], }, }); - }) + } - myChart = echarts.init(chartDom.value); + if (data.viewMap) { + Object.keys(data.viewMap).forEach(key => { + let viewData = data.viewMap[key] + seriesData.push({ + name: key + ":" + '真实值', + type: "line", + data: viewData.realData, + showSymbol: false, + smooth: false, + lineStyle: { + normal: { + width: 1, + }, + }, + }) + seriesData.push({ + name: key + ":" + '预测值', + type: "line", + data: viewData.preDataN, + showSymbol: false, + smooth: false, + lineStyle: { + normal: { + width: 1, + }, + }, + }) + }) + } + + myChart = echarts.init(chartDomPre.value); const option = { title: { - text: dataForm.value.pointName, + text: dataForm.value.itemName, top: 0, left: "1%", textStyle: { @@ -131,11 +180,12 @@ }, }, legend: { - show: false, - top: 10, + show: true, + top: 20, + data: legendData }, grid: { - top: 30, + top: "20%", left: "3%", right: "5%", bottom: 10, @@ -162,24 +212,35 @@ } } } + /** 导出按钮操作 */ const exportLoading = ref(false) const handleExport = async () => { - chartParams.codes=[dataForm.value.pointNo]; - chartParams.startDate = dataForm.value.startTime; - chartParams.endDate = dataForm.value.endTime; + chartParams.itemId = dataForm.value.id; + chartParams.startTime = dataForm.value.startTime; + chartParams.endTime = dataForm.value.endTime; try { // 导出的二次确认 await message.exportConfirm() // 发起导出 exportLoading.value = true - const data = await DaPoint.exportDaPointValue(chartParams) - download.excel(data, dataForm.value.pointName +'.xls') + /*const data = await DaPoint.exportDaPointValue(chartParams) + download.excel(data, dataForm.value.pointName + '.xls')*/ } catch { } finally { exportLoading.value = false } } + +/** 重置表单 */ +const resetForm = () => { + dataForm.value = { + id: undefined, + itemName: undefined, + startTime: undefined, + endTime: undefined + } +} </script> <style> .el-select { diff --git a/src/views/model/pre/item/MmPredictItemForm.vue b/src/views/model/pre/item/MmPredictItemForm.vue index 8a18596..e10af7d 100644 --- a/src/views/model/pre/item/MmPredictItemForm.vue +++ b/src/views/model/pre/item/MmPredictItemForm.vue @@ -414,12 +414,10 @@ import * as MmPredictItem from '@/api/model/pre/item' import * as MmItemType from '@/api/model/pre/type' import * as DmModule from '@/api/model/pre/dm' -import * as MmResultTable from '@/api/model/pre/result' import * as ProjectApi from '@/api/model/mpk/project' import * as DaPoint from '@/api/data/da/point' import {useUpload} from '@/api/model/pre/item' import * as ScheduleModelApi from '@/api/model/sche/model' -import request from "@/config/axios"; const {uploadUrl, httpRequest} = useUpload() @@ -434,7 +432,6 @@ const itemTypeList = ref([]) const itemTypeMap = ref({}) const moduleList = ref([]) -const resultstridList = ref([]) const mpkProjectList = ref([]) const pointNoList = ref([]) const pointList = ref([]) @@ -553,9 +550,6 @@ // 获取管网列表 moduleList.value = await DmModule.getModuleList() - - // 获取结果字符串列表 - resultstridList.value = await MmResultTable.getResultstridList() // 获取mpk项目列表 mpkProjectList.value = await ProjectApi.list() diff --git a/src/views/model/pre/result/MmResultTableForm.vue b/src/views/model/pre/result/MmResultTableForm.vue deleted file mode 100644 index bcb0afa..0000000 --- a/src/views/model/pre/result/MmResultTableForm.vue +++ /dev/null @@ -1,96 +0,0 @@ -<template> - <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%"> - <el-form - ref="formRef" - v-loading="formLoading" - :model="formData" - :rules="formRules" - label-width="120px" - > - <el-row> - <el-col :span="12"> - <el-form-item label="表名" prop="tablename"> - <el-input v-model="formData.tablename" placeholder="请输入表名"/> - </el-form-item> - </el-col> - </el-row> - </el-form> - <template #footer> - <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> - <el-button @click="dialogVisible = false">取 消</el-button> - </template> - </Dialog> -</template> -<script lang="ts" setup> -import * as MmResultTable from '@/api/model/pre/result' - -defineOptions({name: 'DataMmResultTableForm'}) - -const {t} = useI18n() // 国际化 -const message = useMessage() // 消息弹窗 -const dialogVisible = ref(false) // 弹窗的是否展示 -const dialogTitle = ref('') // 弹窗的标题 -const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 -const formType = ref('') // 表单的类型:create - 新增;update - 修改 -const formData = ref({ - id: undefined, - tablename: undefined, -}) -const formRules = reactive({ - tablename: [{required: true, message: '表名不能为空', trigger: 'blur'}], -}) -const formRef = ref() // 表单 Ref - -/** 打开弹窗 */ -const open = async (type: string, id?: number) => { - dialogVisible.value = true - dialogTitle.value = t('action.' + type) - formType.value = type - resetForm() - // 修改时,设置数据 - if (id) { - formLoading.value = true - try { - formData.value = await MmResultTable.getMmResultTable(id) - } finally { - formLoading.value = false - } - } -} -defineExpose({open}) // 提供 open 方法,用于打开弹窗 - -/** 提交表单 */ -const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 -const submitForm = async () => { - // 校验表单 - if (!formRef) return - const valid = await formRef.value.validate() - if (!valid) return - // 提交请求 - formLoading.value = true - try { - const data = formData.value as unknown as MmResultTable.MmResultTableVO - if (formType.value === 'create') { - await MmResultTable.createMmResultTable(data) - message.success(t('common.createSuccess')) - } else { - await MmResultTable.updateMmResultTable(data) - message.success(t('common.updateSuccess')) - } - dialogVisible.value = false - // 发送操作成功的事件 - emit('success') - } finally { - formLoading.value = false - } -} - -/** 重置表单 */ -const resetForm = () => { - formData.value = { - id: undefined, - tablename: undefined, - } - formRef.value?.resetFields() -} -</script> diff --git a/src/views/model/pre/result/index.vue b/src/views/model/pre/result/index.vue deleted file mode 100644 index 271e8d6..0000000 --- a/src/views/model/pre/result/index.vue +++ /dev/null @@ -1,149 +0,0 @@ -<template> - <!-- 搜索 --> - <ContentWrap> - <el-form - class="-mb-15px" - :model="queryParams" - ref="queryFormRef" - :inline="true" - label-width="68px" - > - <el-form-item label="表名" prop="tablename"> - <el-input - v-model="queryParams.tablename" - placeholder="请输入表名" - clearable - @keyup.enter="handleQuery" - class="!w-240px" - /> - </el-form-item> - <el-form-item> - <el-button @click="handleQuery"> - <Icon icon="ep:search" class="mr-5px" /> - 搜索 - </el-button> - <el-button @click="resetQuery"> - <Icon icon="ep:refresh" class="mr-5px" /> - 重置 - </el-button> - <el-button - type="primary" - plain - @click="openForm('create')" - v-hasPermi="['model:pre-result:create']" - > - <Icon icon="ep:plus" class="mr-5px" /> - 新增 - </el-button> - </el-form-item> - </el-form> - </ContentWrap> - - <!-- 列表 --> - <ContentWrap> - <el-table v-loading="loading" :data="list"> - <el-table-column label="表名" align="center" prop="tablename" /> - - <el-table-column label="操作" align="center" min-width="110" fixed="right"> - <template #default="scope"> - <el-button - link - type="primary" - @click="openForm('update', scope.row.id)" - v-hasPermi="['model:pre-result:update']" - > - 编辑 - </el-button> - <el-button - link - type="danger" - @click="handleDelete(scope.row.id)" - v-hasPermi="['model:pre-result:delete']" - > - 删除 - </el-button> - </template> - </el-table-column> - </el-table> - <!-- 分页 --> - <Pagination - :total="total" - v-model:page="queryParams.pageNo" - v-model:limit="queryParams.pageSize" - @pagination="getList" - /> - </ContentWrap> - - <!-- 表单弹窗:添加/修改 --> - <MmResultTableForm ref="formRef" @success="getList" /> - -</template> -<script lang="ts" setup> -import MmResultTableForm from './MmResultTableForm.vue' -import * as MmResultTable from '@/api/model/pre/result' - -defineOptions({name: 'DataMmResultTable'}) - - const message = useMessage() // 消息弹窗 - const {t} = useI18n() // 国际化 - - const loading = ref(true) // 列表的加载中 - const total = ref(0) // 列表的总页数 - const list = ref([]) // 列表的数据 - const queryParams = reactive({ - pageNo: 1, - pageSize: 10, - tablename: undefined, - }) - const queryFormRef = ref() // 搜索的表单 - const exportLoading = ref(false) // 导出的加载中 - - /** 查询列表 */ - const getList = async () => { - loading.value = true - try { - const page = await MmResultTable.getMmResultTablePage(queryParams) - list.value = page.list - total.value = page.total - } finally { - loading.value = false - } - } - - /** 搜索按钮操作 */ - const handleQuery = () => { - queryParams.pageNo = 1 - getList() - } - - /** 重置按钮操作 */ - const resetQuery = () => { - queryFormRef.value.resetFields() - handleQuery() - } - - /** 添加/修改操作 */ - const formRef = ref() - const openForm = (type: string, id?: number) => { - formRef.value.open(type, id) - } - - /** 删除按钮操作 */ - const handleDelete = async (id: number) => { - try { - // 删除的二次确认 - await message.delConfirm() - // 发起删除 - await MmResultTable.deleteMmResultTable(id) - message.success(t('common.delSuccess')) - // 刷新列表 - await getList() - } catch { - } - } - - /** 初始化 **/ - onMounted(async () => { - await getList() - }) -</script> -- Gitblit v1.9.3