Browse Source

Merge pull request 'dev-xjf' (#83) from dev-xjf into master

Reviewed-on: http://120.26.116.243:3000/root/alert-front/pulls/83
pull/85/head
xiaojinfei 4 weeks ago
parent
commit
cb2ed851af
  1. 17
      src/api/alert/run/instant/index.ts
  2. 4
      src/api/alert/warn/index.ts
  3. 3
      src/locales/lang/en/action.json
  4. 3
      src/locales/lang/zh-CN/action.json
  5. 54
      src/views/run/calc/calc.data.ts
  6. 231
      src/views/run/calc/index.vue
  7. 183
      src/views/warn/alarm/alarm.data.ts
  8. 117
      src/views/warn/alarm/index.vue

17
src/api/alert/run/instant/index.ts

@ -54,6 +54,16 @@ export interface EXAPoint {
Comment?: string
Note?: string
}
export interface InstantCalcReqVO {
startTime?: Date
endTime?: Date
interval?: string
mpId?: number
}
// 查询模型实例列表
export function getInstantPage(params: InstantPageReqVO) {
return defHttp.get({ url: '/alert/instant/page', params })
@ -92,3 +102,10 @@ export function getInstantPoint(mpId: number) {
export function getInstantChart(data: InstantChartReqVO) {
return defHttp.post({ url: `/alert/instant/getChart`, data })
}
// 回算模型实例
export function calcInstant(data: InstantCalcReqVO) {
return defHttp.post({ url: `/alert/instant/calc`, data })
}

4
src/api/alert/warn/index.ts

@ -21,6 +21,10 @@ export interface EXAHistoryReqVO {
export function getWarnPage(params: WarnPageReqVO) {
return defHttp.get({ url: '/alert/warn/page', params })
}
// 查询预警列表-分页-转换实时值
export function getWarnPageReal(params: WarnPageReqVO) {
return defHttp.get({ url: '/alert/warn/page-real', params })
}
// 修改预警
export function updateWarn(data: WarnVO) {

3
src/locales/lang/en/action.json

@ -15,5 +15,6 @@
"createInstant": "CreateInstant",
"pointConfig": "PointConfig",
"warnConfig": "WarnConfig",
"backCalc": "backCalc"
"backCalc": "backCalc",
"calcIng": "calcIng"
}

3
src/locales/lang/zh-CN/action.json

@ -16,5 +16,6 @@
"createInstant": "新增实例",
"pointConfig": "测点配置",
"warnConfig": "预警配置",
"backCalc": "回算"
"backCalc": "回算",
"calcIng": "回算中"
}

54
src/views/run/calc/calc.data.ts

@ -5,59 +5,62 @@ import type { BasicColumn, FormSchema } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import { optionListApi, subSystemListApi } from '@/api/alert/model/select'
import type { systemSelectParams } from '@/api/alert/model/model/optionsModel'
import {Tag} from "ant-design-vue";
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'id',
width: 80,
dataIndex: 'mpId',
width: 60,
fixed: 'left',
},
{
title: '模型名称',
dataIndex: 'modelName',
width: 250,
width: 200,
className: 'instant',
slots: { customRender: 'detail' },
fixed: 'left',
},
{
title: '算法',
dataIndex: 'Algorithm',
width: 200,
dataIndex: 'algorithmShortname',
width: 100,
},
{
title: '模式覆盖率',
dataIndex: 'CoveredPercent',
width: 200,
width: 100
},
{
title: '报警次数',
dataIndex: 'AlarmNumber',
width: 200,
width: 100,
},
{
title: '总报警时间(m)',
dataIndex: 'AlarmToatlMinutes',
width: 200,
width: 100,
},
{
title: '系统维度',
dataIndex: 'Dimension',
width: 200,
width: 100,
},
{
title: '计算耗时(s)',
dataIndex: 'CalcSeconds',
width: 200,
width: 100,
},
{
title: '状态',
dataIndex: 'status',
dataIndex: 'calcStatus',
width: 100,
slots: { customRender: 'status' },
fixed: 'right',
slots: { customRender: 'calcStatus' },
},
]
@ -65,13 +68,14 @@ const optionList = await optionListApi()
const systemOptions = ref<any>([])
systemOptions.value = optionList.systems
console.log(systemOptions.value)
export const searchFormSchema: FormSchema[] = [
{
label: '机组',
field: 'unit',
component: 'Select',
defaultValue: optionList.units[0].id || null,
colProps: { span: 4 },
colProps: { span: 5 },
componentProps: ({ formModel }) => {
return {
@ -80,10 +84,6 @@ export const searchFormSchema: FormSchema[] = [
placeholder: '请选择机组',
options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })),
onChange: async (e: any) => {
// const { reload } = tableAction
// reload()
// or
console.log(e)
const param: systemSelectParams = {
unitId: e,
typeId: formModel.type,
@ -99,22 +99,19 @@ export const searchFormSchema: FormSchema[] = [
field: 'type',
component: 'Select',
defaultValue: optionList.types[0].id || null,
colProps: { span: 4 },
colProps: { span: 5 },
componentProps: ({ formModel }) => {
return {
allowClear: false,
placeholder: '请选择系统',
options: optionList.types.map(type => ({ value: type.id, label: type.name })),
onChange: async (e: any) => {
// const { reload } = tableAction
// reload()
// or
console.log(e)
const param: systemSelectParams = {
unitId: formModel.unit,
typeId: e,
}
systemOptions.value = await subSystemListApi(param)
console.log(systemOptions.value)
},
}
},
@ -124,7 +121,7 @@ export const searchFormSchema: FormSchema[] = [
field: 'system',
component: 'Select',
defaultValue: systemOptions.value[0].id || null,
colProps: { span: 4 },
colProps: { span: 5 },
componentProps: () => {
return {
allowClear: false,
@ -143,7 +140,7 @@ export const searchFormSchema: FormSchema[] = [
componentProps: {
placeholder: '请输入模型名称',
},
colProps: { span: 4 },
colProps: { span: 6 },
},
]
@ -163,15 +160,18 @@ export const calcFormSchemas: FormSchema[] = [
onChange: (e: any) => {
console.log(e)
},
allowClear: false, // ← 必须用这个
},
required: true,
colProps: {
span: 8,
span: 10,
},
},
{
label: '回算采样周期',
label: '采样周期',
field: 'interval',
component: 'Select',
defaultValue: 60,
@ -181,7 +181,7 @@ export const calcFormSchemas: FormSchema[] = [
},
required: true,
colProps: {
span: 4,
span: 5,
},
},

231
src/views/run/calc/index.vue

@ -1,33 +1,38 @@
<script lang="ts" setup>
import { Badge, Button, Divider, Switch } from 'ant-design-vue'
import { onMounted, ref } from 'vue'
import {Space, Tag,Badge, Button, Divider, Switch} from 'ant-design-vue'
import {onMounted, ref, reactive} from 'vue'
import moment from 'moment'
import HistoryModal from '../../exa/config/HistoryModal.vue'
import { calcFormSchemas, columns, searchFormSchema } from './calc.data'
import {calcFormSchemas, columns, searchFormSchema} from './calc.data'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { BasicForm, useForm } from '@/components/Form'
import {BasicTable, TableAction, useTable} from '@/components/Table'
import {BasicForm, useForm} from '@/components/Form'
import { getInstantCount, getInstantPage, updateInstant } from '@/api/alert/run/instant'
import { getExaNow } from '@/api/alert/exa'
import { useI18n } from '@/hooks/web/useI18n'
import { router } from '@/router'
import { useMessage } from '@/hooks/web/useMessage'
import { IconEnum } from '@/enums/appEnum'
import { useModal } from '@/components/Modal'
import {calcInstant, getInstantCount, getInstantPage, updateInstant} from '@/api/alert/run/instant'
import {getExaNow} from '@/api/alert/exa'
import {useI18n} from '@/hooks/web/useI18n'
import {router} from '@/router'
import {useMessage} from '@/hooks/web/useMessage'
import {IconEnum} from '@/enums/appEnum'
import {useModal} from '@/components/Modal'
defineOptions({ name: 'InstantCalc' })
const { createMessage } = useMessage()
const { t } = useI18n()
const [registerHistoryModal, { openModal: openHistoryModal }] = useModal()
const [registerCreateModal, { openModal: openCreateModal }] = useModal()
const [registerUpdateModal, { openModal: openUpdateModal }] = useModal()
defineOptions({name: 'InstantCalc'})
const {createMessage} = useMessage()
const {t} = useI18n()
//
const statusMap = {
0: { label: '待计算', color: 'default' },
1: { label: '计算中', color: 'processing' },
2: { label: '计算成功', color: 'success' },
3: { label: '计算失败', color: 'error' },
}
const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({
//
const selectedRowss = ref<any[]>([])
const [registerTable, {getForm, reload, getDataSource, updateTableDataRecord}] = useTable({
title: '实例列表',
api: getInstantPage,
rowKey: 'id',
rowKey: 'mpId',
immediate: true,
columns,
formConfig: {
@ -36,6 +41,10 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
showResetButton: false,
actionColOptions: {
span: 2,
style: {
textAlign: 'left',
marginLeft: '10px',
},
},
},
@ -48,41 +57,35 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
dataIndex: 'action',
fixed: 'right',
},
})
const isShow = ref<boolean>(false)
function handleCreate() {
openCreateModal(true, { isUpdate: false })
isShow.value = true
}
function handleEdit(record: Recordable) {
openUpdateModal(true, { record, isUpdate: true })
}
async function handleDelete(record: Recordable) {
await deleteRole(record.id)
createMessage.success(t('common.delSuccessText'))
reload()
}
//
rowSelection: {
type: 'checkbox',
const itemName = ref<string>()
const legendName = ref<string[]>()
function handleHistory(record: Recordable) {
itemName.value = (JSON.parse(record.instantInfo)).model_state
legendName.value = []
legendName.value.push(`${record.mpName}-${itemName.value}`)
openHistoryModal(true, { record })
}
onChange: (selectedRowKeys, selectedRows) => {
console.log(24)
selectedRowss.value = selectedRows
}
},
//
// 使
// 👉 afterFetch
afterFetch: (data) =>
data.map(item => ({
...item,
CoveredPercent: '-',
AlarmNumber: '-',
AlarmToatlMinutes: '-',
CalcSeconds: '-',
Dimension:'-',
calcStatus: 0,
})),
function handleWarnConfig(record: Recordable) {
router.push(`/run/warnConfig?id=${record.id}`)
}
})
/**
* BasicForm绑定注册;
*/
const [registerForm] = useForm({
const [registerForm, {getFieldsValue, validate, validateFields}] = useForm({
//
schemas: calcFormSchemas,
// false
@ -92,70 +95,138 @@ const [registerForm] = useForm({
// // // 1
// alwaysShowLines: 1,
layout: 'horizontal',
model: { time: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')] },
model: {time: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')]},
fieldMapToTime: [
// datastartTimeendTime
['time', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss'],
['time', ['st', 'et'], 'YYYY-MM-DD HH:mm:ss']
],
actionColOptions: { span: 2 },
actionColOptions: {span: 5, style: {textAlign: 'left', marginLeft: '10px',}},
showSubmitButton: false,
showResetButton: false,
})
//
const calcLoading = ref<boolean>(false)
const rowCalcLoading = reactive({});
/**
* 点击提交按钮的value值----改为导出按钮
* 点击导出按钮
* @param values
*/
function handleSubmit(values: any) {
console.log('提交按钮数据::::', values)
function handleExport(values: any) {
console.log('导出按钮数据::::', values)
}
async function handlebeforeCalc(record?: Recordable) {
let targetRows: Recordable[] = []
// 1. 使mpId
if (record) {
targetRows = [record]
}
// 2. 使
else {
targetRows = selectedRowss.value
if (targetRows.length === 0) {
createMessage.error('请选择要回算的实例')
return
}
}
//
const formData = await validate()
// id
formData.records = targetRows;
handleCalc(formData)
}
//
function handleCalc(values: any) {
console.log('提交按钮数据::::', values)
async function handleCalc(formData: any) {
calcLoading.value = true
console.log('点击回算按钮数据::::', formData)
//
for (const record of formData.records) {
updateTableDataRecord(record.mpId, {calcStatus:1})
rowCalcLoading[record.mpId] = true
console.log('行内回算loading状态:', record.mpId, rowCalcLoading[record.mpId])
try {
// -
formData.mpId = record.mpId
// -
console.log(formData)
const res = await calcInstant(formData)
console.log('回算结果:', res)
console.log(record)
res.calcStatus = 2
//
updateTableDataRecord(record.mpId, res)
createMessage.success(t('common.successText'))
} catch (error) {
updateTableDataRecord(record.mpId, {calcStatus:3})
createMessage.error(t('common.failText'))
} finally {
rowCalcLoading[record.mpId] = false
}
}
calcLoading.value = false
}
onMounted(async () => {
const { setFieldsValue } = getForm()
await setFieldsValue({ system: null })
})
</script>
<template>
<div>
<BasicTable @register="registerTable">
<template #form-formFooter>
<!-- <a-button v-auth="['run:instant:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button> -->
<Divider orientation="left">
回算
</Divider>
<!-- <Divider orientation="left">-->
<!-- 回算-->
<!-- </Divider>-->
<!-- 自定义表单 -->
<BasicForm @register="registerForm">
<template #advanceBefore>
<a-button v-auth="['run:instant:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button>
<Space>
<a-button type="primary" :loading="calcLoading" :pre-icon="IconEnum.BACK_CALC"
@click="handlebeforeCalc()">
{{ t('action.backCalc') }}
</a-button>
<a-button type="primary" :pre-icon="IconEnum.EXPORT" @click="handleExport">
{{ t('action.export') }}
</a-button>
</Space>
</template>
</BasicForm>
</template>
<!-- 统计量点击跳转历史曲线 -->
<template #history="{ record }">
<a @click="handleHistory(record)">
{{ record.pointSte }}
</a>
<!-- <SlidersOutlined class="click-status" /> -->
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<!-- <TableAction-->
<!-- :actions="[-->
<!-- { icon: IconEnum.BACK_CALC,label: rowCalcLoading[record.mpId] ? t('action.calcIng') : t('action.backCalc'), onClick: handleCalc.bind(null, record) },-->
<!-- ]"-->
<!-- />-->
<TableAction
:actions="[
{ icon: IconEnum.BACK_CALC, label: t('action.backCalc'), onClick: handleWarnConfig.bind(null, record) },
{ icon: IconEnum.BACK_CALC,label: rowCalcLoading[record.mpId] ? t('action.calcIng') : t('action.backCalc'),
onClick: () => handlebeforeCalc(record),
disabled: rowCalcLoading[record.mpId]},
]"
@click.stop
/>
</template>
</template>
<!-- 修改calcStatus列的渲染 -->
<template #calcStatus="{ record }">
<Tag :color="statusMap[record.calcStatus].color">
{{ statusMap[record.calcStatus].label }}
</Tag>
</template>
</BasicTable>
<HistoryModal :item-name="itemName" :legend-name="legendName" @register="registerHistoryModal" />
<CreateModal :item-name="itemName" :legend-name="legendName" @register="registerCreateModal" @success="reload" />
<UpdateModal @register="registerUpdateModal" @success="reload" />
</div>
</template>

183
src/views/warn/alarm/alarm.data.ts

@ -0,0 +1,183 @@
import type { BasicColumn, FormSchema } from '@/components/Table'
import {optionListApi, subSystemListApi} from "@/api/alert/model/select";
import {h, ref} from "vue";
import {systemSelectParams} from "@/api/alert/model/model/optionsModel";
import {FileItem, UploadResultStatus} from "@/components/Upload/src/typing";
import {Progress} from "ant-design-vue";
const optionList = await optionListApi()
const systemOptions = ref<any>([])
systemOptions.value = optionList.systems
export const searchFormSchema: FormSchema[] = [
{
label: '机组',
field: 'unit',
component: 'Select',
defaultValue: optionList.units[0].id || null,
colProps: { span: 4 },
componentProps: ({ schema, tableAction, formActionType, formModel }) => {
return {
// xxxx props
allowClear: false,
placeholder: '请选择机组',
options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })),
onChange: async (e: any) => {
// const { reload } = tableAction
// reload()
// or
console.log(e)
const param: systemSelectParams = {
unitId: e,
typeId: formModel.type,
}
systemOptions.value = await subSystemListApi(param)
formModel.system = systemOptions.value[0].id
},
}
},
},
{
label: '系统',
field: 'type',
component: 'Select',
defaultValue: optionList.types[0].id || null,
colProps: { span: 4 },
componentProps: ({ formModel }) => {
return {
allowClear: false,
placeholder: '请选择系统',
options: optionList.types.map(type => ({ value: type.id, label: type.name })),
onChange: async (e: any) => {
// const { reload } = tableAction
// reload()
// or
console.log(e)
const param: systemSelectParams = {
unitId: formModel.unit,
typeId: e,
}
systemOptions.value = await subSystemListApi(param)
},
}
},
},
{
label: '子系统',
field: 'system',
component: 'Select',
defaultValue: systemOptions.value[0].id || null,
colProps: { span: 4 },
componentProps: () => {
return {
allowClear: false,
placeholder: '请选择子系统',
options: systemOptions.value.map(system => ({ value: system.id, label: system.name })),
}
},
},
{
label: '模型实例名称',
field: 'mpName',
component: 'Input',
labelWidth: 120,
defaultValue: '',
colProps: { span: 7 },
}
]
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'warnId',
width: 80,
fixed: 'left',
},
{
title: '机组',
dataIndex: 'unitName',
width: 80,
fixed: 'left',
},
{
title: '报警名称',
dataIndex: 'alarmName',
width: 180,
fixed: 'left',
// 将 JSX 改为 h 函数调用
customRender: ({ record }) => {
return h('div', [
h('div', record.pointName),
h('div', { style: 'color: #999; font-size: 12px' }, record.pointId)
]);
},
},
{
title: '单位',
dataIndex: 'unit',
width: 50,
fixed: 'left',
},
{
title: '测点值',
dataIndex: 'unit',
width: 150,
// 将 JSX 改为 h 函数调用
customRender: ({ record }) => {
return h('div', [
h('div', { style: 'color: #006400;font-weight:bold' },'实时值:'+record.pointValue),
h('div', { style: 'color: #0960BD;font-weight:bold' },'重构值:'+record.outputPointValue),
]);
},
},
{
title: '偏差值',
dataIndex: 'biasValue',
width: 50
},
{
title: '安全区间',
dataIndex: 'limit',
width: 100,
// 将 JSX 改为 h 函数调用
customRender: ({ record }) => {
return h('div', [
h('div', record.lowlimit),
h('div', record.uplimit),
]);
},
},
{
title: '模型实例名称',
dataIndex: 'mpName',
width: 150,
ellipsis: false, // ⭐ 关键
},
{
title: '预警时间',
dataIndex: 'createTime',
width: 150
},
{
title: '持续时长',
dataIndex: 'timeDiffStr',
width: 90,
ellipsis: false, // ⭐ 关键
},
{
title: '告警级别',
dataIndex: 'alarmModelRuleName',
width: 80,
ellipsis: false, // ⭐ 关键
},
{
title: '专业',
dataIndex: 'systemName',
width: 100,
}
]

117
src/views/warn/alarm/index.vue

@ -0,0 +1,117 @@
<script lang="ts" setup>
import { Switch } from 'ant-design-vue'
import { onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { columns, searchFormSchema } from './alarm.data'
// import UpdateModal from './UpdateModal.vue'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { getWarnPageReal, updateWarn } from '@/api/alert/warn'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { IconEnum } from '@/enums/appEnum'
import { useModal } from '@/components/Modal'
defineOptions({ name: 'Warn' })
const route = useRoute()
const { createMessage } = useMessage()
const { t } = useI18n()
const [registerUpdateModal, { openModal: openUpdateModal }] = useModal()
const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({
title: '预警测点列表',
api: getWarnPageReal,
rowKey: 'warnId',
immediate: true,
columns,
//,
useSearchForm: true,
formConfig: {
labelWidth: 80,
schemas: searchFormSchema,
showResetButton: false,
actionColOptions: {
span: 4,
style: {
marginLeft: '10px'
}
},
},
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 120,
title: t('common.action'),
dataIndex: 'action',
fixed: 'right',
}
})
async function updateStatus(record) {
await updateWarn(record)
createMessage.success(t('common.saveSuccessText'))
console.log(record)
reload()
}
function handleWarnConfig(record: Recordable) {
openUpdateModal(true, { record, isUpdate: true })
}
onMounted(async () => {
const { setFieldsValue } = getForm()
await setFieldsValue({ system: null })
})
</script>
<template>
<div>
<BasicTable @register="registerTable">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.WARN, label: t('action.warnConfig'), auth: 'run:instant:warnConfig', onClick: handleWarnConfig.bind(null, record) },
]"
/>
</template>
</template>
<template #warnStatus="{ record }">
<Switch
v-model:checked="record.warnStatus" :checked-value="1" :un-checked-value="0" checked-children="是"
un-checked-children="否" @change="updateStatus(record)"
/>
</template>
<template #shortMessageOnOff="{ record }">
<Switch
v-model:checked="record.shortMessageOnOff" :checked-value="1" :un-checked-value="0" checked-children="是"
un-checked-children="否" @change="updateStatus(record)"
/>
</template>
<template #gzpOnOff="{ record }">
<Switch
v-model:checked="record.gzpOnOff" :checked-value="1" :un-checked-value="0" checked-children="是"
un-checked-children="否" @change="updateStatus(record)"
/>
</template>
<template #copyToDiagOnOff="{ record }">
<Switch
v-model:checked="record.copyToDiagOnOff" :checked-value="1" :un-checked-value="0" checked-children="是"
un-checked-children="否" @change="updateStatus(record)"
/>
</template>
<template #timeDurationThreshold="{ record }">
{{ `${record.timeDurationThreshold}` }}
</template>
</BasicTable>
<!-- <UpdateModal @register="registerUpdateModal" @success="reload" />-->
</div>
</template>
<style lang="less" scoped>
</style>
Loading…
Cancel
Save