From de019eee974f69a54b360297fd5d5b93f27497f9 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期五, 08 十一月 2024 09:43:22 +0800 Subject: [PATCH] 模型运行 --- src/views/model/pre/item/MmPredictItemForm.vue | 425 ++++++++++++++++++++-------------------------------- 1 files changed, 167 insertions(+), 258 deletions(-) diff --git a/src/views/model/pre/item/MmPredictItemForm.vue b/src/views/model/pre/item/MmPredictItemForm.vue index b3806b7..9e5fb9f 100644 --- a/src/views/model/pre/item/MmPredictItemForm.vue +++ b/src/views/model/pre/item/MmPredictItemForm.vue @@ -5,24 +5,25 @@ v-loading="formLoading" :model="dataForm" :rules="formRules" - label-width="120px" + label-width="100px" > <el-divider content-position="left">基本信息</el-divider> <el-row> <el-col :span="12"> - <el-form-item label="预测项名"> - <el-input v-model="dataForm.mmPredictItem.itemname" placeholder="预测项名"/> + <el-form-item label="预测项名" prop="mmPredictItem.itemname"> + <el-input v-model="dataForm.mmPredictItem.itemname" placeholder="预测项名" + maxlength="50"/> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="编号"> - <el-input v-model="dataForm.mmPredictItem.itemno" placeholder="编号" maxlength="50"/> + <el-form-item label="编号" prop="mmPredictItem.itemno"> + <el-input v-model="dataForm.mmPredictItem.itemno" placeholder="编号" maxlength="50" readonly/> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> - <el-form-item label="类型"> + <el-form-item label="类型" prop="mmPredictItem.itemtypeid"> <el-select v-model="dataForm.mmPredictItem.itemtypeid" @change="changeItemtype" placeholder="请选择"> @@ -35,40 +36,47 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="粒度"> - <el-input - v-model="dataForm.mmPredictItem.granularity" placeholder="粒度" - maxlength="5"/> + <el-form-item label="粒度" prop="mmPredictItem.granularity"> + <el-select v-model="dataForm.mmPredictItem.granularity" placeholder="请选择"> + <el-option + v-for="dict in getIntDictOptions(DICT_TYPE.TIME_GRANULARITY)" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> + </el-select> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> - <el-form-item label="是否检查"> + <el-form-item label="是否检查" prop="mmPredictItem.workchecked"> <el-select v-model="dataForm.mmPredictItem.workchecked" placeholder="请选择"> <el-option - v-for="item in isList" - :key="item.code" - :label="item.name" - :value="item.code"/> + v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> </el-select> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="是否启用"> - <el-select v-model="dataForm.dmModuleItem.status" placeholder="请选择"> + <el-form-item label="是否启用" prop="mmPredictItem.status"> + <el-select v-model="dataForm.mmPredictItem.status" placeholder="请选择"> <el-option - v-for="item in isList" - :key="item.code" - :label="item.name" - :value="item.code"/> + v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> </el-select> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> - <el-form-item label="管网"> + <el-form-item label="管网" prop="dmModuleItem.moduleid"> <el-select v-model="dataForm.dmModuleItem.moduleid" placeholder="请选择"> <el-option v-for="item in moduleList" @@ -86,12 +94,13 @@ </el-row> <el-row> <el-col :span="12"> - <el-form-item label="排序"> - <el-input v-model="dataForm.dmModuleItem.itemorder" placeholder="排序" maxlength="36"/> + <el-form-item label="排序" prop="dmModuleItem.itemorder"> + <el-input-number v-model="dataForm.dmModuleItem.itemorder" :min="1" clearable + controls-position="right"/> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="数据点"> + <el-form-item label="数据点" prop="mmItemOutput.pointid"> <el-select v-model="dataForm.mmItemOutput.pointid" filterable @@ -100,25 +109,12 @@ <el-option v-for="item in pointList" :key="item.id" - :label="item.pointname" + :label="item.pointName" :value="item.id"/> </el-select> </el-form-item> </el-col> </el-row> - <!-- <el-row> - <el-col :span="12"> - <el-form-item label="保存点位"> - <el-select v-model="dataForm.mmPredictItem.saveindex" placeholder="请选择"> - <el-option - v-for="item in saveIndexList" - :key="item.code" - :label="item.name" - :value="item.code"/> - </el-select> - </el-form-item> - </el-col> - </el-row>--> <el-row v-if="dataForm.itemtypename === 'MergeItem'"> <el-col :span="12"> <el-form-item label="预测长度"> @@ -130,8 +126,8 @@ </el-row> <el-divider content-position="left" v-if="dataForm.itemtypename === 'NormalItem'">模型信息 </el-divider> - <el-row v-if="dataForm.itemtypename === 'NormalItem'"> - <el-col :span="24"> + <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'"> + <el-col :span="12"> <el-form-item label="模型名称"> <el-input v-model="dataForm.mmPredictModel.modelname" placeholder="模型名称" @@ -139,34 +135,30 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="编号" v-if="!!dataForm.id"> - <el-input - v-model="dataForm.mmPredictModel.modelno" placeholder="编号" maxlength="32" - disabled/> - </el-form-item> + <el-upload + class="upload-demo" + :limit="1" + :file-list="fileList" + :before-upload="beforeUpload" + :on-success="uploadModelSuccess" + :on-error="uploadModelError" + :action="uploadUrl" + :http-request="httpRequest"> + <el-button type="primary" @click="setReplaceModelOnly(false)"> + <Icon icon="ep:upload"/> + 上传模型 + </el-button> + <el-button + size="small" type="primary" @click="setReplaceModelOnly(true)" + v-if="formType.value === 'update'"> + <Icon icon="ep:upload"/> + 更新模型 + </el-button> + </el-upload> </el-col> </el-row> <el-row v-if="dataForm.itemtypename === 'NormalItem'"> - <el-col :span="12"> - <el-form-item label="上传模型"> - <el-upload - class="upload-demo" - :limit="1" - :file-list="fileList" - :before-upload="beforeUpload" - :on-success="uploadModelSuccess" - :on-error="uploadModelError" - :action="uploadModelUrl"> - <el-button size="small" type="primary" @click="setReplaceModelOnly(0)">点击上传 - </el-button> - <el-button - size="small" type="primary" @click="setReplaceModelOnly(1)" - v-if="!!dataForm.id">只替换模型 - </el-button> - </el-upload> - </el-form-item> - </el-col> - <el-col :span="12"> + <el-col :span="8"> <el-form-item label="结果"> <el-select v-model="dataForm.mmPredictModel.resultstrid" placeholder="请选择"> <el-option @@ -177,8 +169,26 @@ </el-select> </el-form-item> </el-col> + <el-col :span="8"> + <el-form-item label="关联项目"> + <el-select v-model="dataForm.mmPredictModel.mpkprojectid" placeholder="请选择"> + <el-option + v-for="item in mpkProjectList" + :key="item.id" + :label="item.projectName" + :value="item.id"/> + </el-select> + </el-form-item> + </el-col> + <el-col :span="8"> + <el-form-item label="编号"> + <el-input + v-model="dataForm.mmPredictModel.modelno" placeholder="编号" maxlength="30" readonly + disabled/> + </el-form-item> + </el-col> </el-row> - <el-row v-if="dataForm.itemtypename === 'NormalItem'"> + <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'"> <el-col :span="24"> <el-form-item label="路径"> <el-input @@ -187,7 +197,7 @@ </el-form-item> </el-col> </el-row> - <el-row v-if="dataForm.itemtypename === 'NormalItem'"> + <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'"> <el-col :span="24"> <el-form-item label="类名"> <el-input @@ -196,7 +206,7 @@ </el-form-item> </el-col> </el-row> - <el-row v-if="dataForm.itemtypename === 'NormalItem'"> + <el-row :gutter="8" v-if="dataForm.itemtypename === 'NormalItem'"> <el-col :span="12"> <el-form-item label="方法名"> <el-input @@ -220,13 +230,13 @@ <el-table-column prop="key" label="键" align="center"/> <el-table-column prop="name" label="名称" align="center"/> <el-table-column prop="valuetype" label="类型" align="center"/> - <el-table-column prop="" label="值" align="center"> + <el-table-column prop="" label="值" align="center" min-width="150"> <template #default="scope"> - <el-input v-model="scope.row.value" maxlength="256" style="width:100%;height:100%"/> + <el-input size="mini" v-model="scope.row.value" maxlength="256" + style="width:100%;height:100%"/> </template> </el-table-column> </el-table> - <el-divider content-position="left" v-if="dataForm.itemtypename === 'NormalItem'">输入参数 </el-divider> <el-table @@ -238,14 +248,13 @@ <el-table-column prop="modelparamorder" label="序号" width="60" align="center"/> <el-table-column prop="" label="类型" width="200" align="center"> <template #default="scope"> - <el-select - v-model="scope.row.modelparamtype" - @change="changeModelparamtype(value, scope.row)" placeholder="请选择"> + <el-select v-model="scope.row.modelparamtype" placeholder="请选择"> <el-option - v-for="item in dataForm.modelparamtypeList" - :key="item" - :label="item" - :value="item"/> + v-for="dict in getStrDictOptions(DICT_TYPE.MODEL_PARAM_TYPE)" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> </el-select> </template> </el-table-column> @@ -266,9 +275,9 @@ </el-table-column> <el-table-column prop="" label="参数长度" width="120" align="center"> <template #default="scope"> - <el-input - v-model="scope.row.datalength" maxlength="50" - style="width:100%;height:100%"/> + <el-input-number v-model="scope.row.datalength" :min="0" clearable + controls-position="right" + style="width:100%;hight:100%"/> </template> </el-table-column> <el-table-column prop="" label="操作" width="140" align="center"> @@ -359,71 +368,50 @@ </Dialog> </template> <script lang="ts" setup> +import {DICT_TYPE, getIntDictOptions, getStrDictOptions} from '@/utils/dict' import * as MmPredictItem from '@/api/model/pre/predict' import * as MmItemType from '@/api/model/pre/item' 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/predict' import * as ScheduleModelApi from '@/api/model/sche/model' + +const {uploadUrl, httpRequest} = useUpload() defineOptions({name: 'DataMmPredictItemForm'}) const {t} = useI18n() // 国际化 const message = useMessage() // 消息弹窗 const dialogVisible = ref(false) // 弹窗的是否展示 -const pointLoading = ref(false) // 弹窗的是否展示 const dialogTitle = ref('') // 弹窗的标题 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 const formType = ref('') // 表单的类型:create - 新增;update - 修改 -const uploadModelUrl = '' const itemTypeList = ref([]) const itemTypeMap = ref({}) const moduleList = ref([]) -const resulttableList = ref([]) const resultstridList = ref([]) +const mpkProjectList = ref([]) const pointNoList = ref([]) const pointList = ref([]) const pointMap = ref({}) -const predictList = ref([]) const predictItemList = ref([]) -const modelparamList = ref([]) -const modelparamListMap = ref([]) +const modelparamListMap = ref({}) const modelparamMap = ref({}) const expressionList = ref([]) const fileList = ref([]) const operatorList = ['+', '-'] -const replaceModelOnly = ref(0) +const replaceModelOnly = ref(false) const queryParams = reactive({ pageNo: 1, pageSize: 10, pointNo: undefined, pointName: undefined, }) -const isList = ref([ - { - code: 0, - name: '否' - }, - { - code: 1, - name: '是' - }]) -/*const saveIndexList = ref([ - { - code: '2', - name: 'T+2' - }, - { - code: '30', - name: 'T+30' - }, - { - code: 'n', - name: 'T+n' - }])*/ const dataForm = ref({ id: undefined, - itemtypename: undefined, + itemtypename: 'NormalItem', mmPredictItem: { id: undefined, itemno: undefined, @@ -431,11 +419,11 @@ caltypeid: undefined, itemtypeid: undefined, predictlength: undefined, - granularity: undefined, + granularity: 60, status: undefined, isfuse: undefined, predictphase: undefined, - workchecked: '', + workchecked: 0, unittransfactor: undefined, saveindex: undefined }, @@ -443,7 +431,7 @@ id: undefined, moduleid: undefined, itemid: undefined, - itemorder: undefined, + itemorder: 1, status: undefined, categoryid: undefined }, @@ -473,7 +461,8 @@ methodname: undefined, modelparamstructure: undefined, resultstrid: undefined, - settingmap: undefined + settingmap: undefined, + mpkprojectid: undefined }, mmPredictMergeItem: { id: undefined, @@ -481,42 +470,81 @@ expression: undefined, num: undefined }, - modelparamtypeList: ['DATAPOINT', 'PREDICTITEM', 'DAYWORKPROCESSPLAN', 'MONTHWORKPROCESSPLAN', 'ST_PLAN_NQ', 'ST_PLAN_BQ', 'ST_PLAN_NQ_HI', 'ST_PLAN_BQ_HI'], mmModelArithSettingsList: [], mmModelParamList: [] }) const formRules = reactive({ - // itemno: [{required: true, message: '编号不能为空', trigger: 'blur'}], - // itemname: [{required: true, message: '预测项名不能为空', trigger: 'blur'}], + 'mmPredictItem.itemname': [{required: true, message: '预测项名不能为空', trigger: 'blur'}], + 'mmPredictItem.itemtypeid': [{required: true, message: '类型不能为空', trigger: 'blur'}], + 'mmPredictItem.granularity': [{ + required: true, + message: '粒度不能为空', + trigger: 'blur' + }], + 'mmPredictItem.workchecked': [{ + required: true, + message: '是否检查不能为空', + trigger: 'blur' + }], + 'mmPredictItem.status': [{required: true, message: '是否启用不能为空', trigger: 'blur'}], + 'dmModuleItem.moduleid': [{required: true, message: '管网不能为空', trigger: 'blur'}], + 'dmModuleItem.itemorder': [{required: true, message: '排序不能为空', trigger: 'blur'}], + 'mmItemOutput.pointid': [{required: true, message: '数据点不能为空', trigger: 'blur'}], + }) const formRef = ref() // 表单 Ref /** 打开弹窗 */ const open = async (type: string, id?: number, itemtypename?: string) => { + formType.value = type dialogVisible.value = true dialogTitle.value = t('action.' + type) - formType.value = type dataForm.value.itemtypename = itemtypename || 'NormalItem' - console.info(dataForm.value.itemtypename) - // resetForm() + resetForm() resetFields(dataForm.value) setDefaultFields() - getItemTypeList() - getModuleList() - getPointList() - getModelparamList() - getResulttableList() - getResultstridList() // 修改时,设置数据 if (id) { formLoading.value = true try { - debugger getInfo(id) } finally { - formLoading.value = false + /*formLoading.value = false*/ } } + + // 加载参数列表 + modelparamListMap.value = await ScheduleModelApi.getModelParamList() + + // 获取预测项类型列表 + itemTypeList.value = await MmItemType.getItemTypeList() + itemTypeList.value.forEach(function (value) { + itemTypeMap[value.id] = value.itemtypename + }) + if (!dataForm.value.id) { + dataForm.value.mmPredictItem.itemtypeid = itemTypeList.value[0].id + } + dataForm.value.itemtypename = itemTypeMap[dataForm.value.mmPredictItem.itemtypeid] + + // 获取管网列表 + moduleList.value = await DmModule.getModuleList() + + // 获取结果字符串列表 + resultstridList.value = await MmResultTable.getResultstridList() + + // 获取mpk项目列表 + mpkProjectList.value = await ProjectApi.list() + + // 获取数据点列表 + pointNoList.value = await DaPoint.getPointList(queryParams) + if (pointNoList.value.length > 0) { + pointNoList.value.forEach(function (value) { + pointList.value.push(value) + pointMap[value.id] = value.pointname + }) + } + + formLoading.value = false } defineExpose({open}) // 提供 open 方法,用于打开弹窗 @@ -531,7 +559,6 @@ formLoading.value = true try { const data = dataForm.value as unknown as MmPredictItem.MmPredictItemVO - debugger if (expressionList.value && expressionList.value.length > 0) { let expression = '' for (let i = 0; i < expressionList.value.length; i++) { @@ -624,7 +651,7 @@ if (response.code === 0) { message.success(t('上传成功')) dataForm.value.mmModelArithSettingsList = [] - if (!replaceModelOnly) { + if (!replaceModelOnly.value) { dataForm.value.mmModelParamList = [] } dataForm.value.mmPredictModel.modelpath = '' @@ -641,6 +668,7 @@ } }) } + dataForm.value.mmPredictModel.modelname = response.data.originalFilename dataForm.value.mmPredictModel.classname = response.data.className dataForm.value.mmPredictModel.methodname = response.data.methodName if (response.data.paramPathList) { @@ -649,7 +677,7 @@ if (response.data.paramsArray) { dataForm.value.mmPredictModel.modelparamstructure = response.data.paramsArray.join(',') } - if (response.data.paramsCount && !replaceModelOnly) { + if (response.data.paramsCount && !replaceModelOnly.value) { for (let i = 0; i < response.data.paramsCount; i++) { dataForm.value.mmModelParamList.push({ modelparamportorder: (i + 1), @@ -680,7 +708,6 @@ function changeItemtype(value) { dataForm.value.itemtypename = itemTypeMap[value] - console.info(dataForm.value.itemtypename) } function changeModelparamtype(value, row) { @@ -728,123 +755,6 @@ }) } -// 获取预测项类型列表 -const getItemTypeList = async () => { - itemTypeList.value = [] - itemTypeList.value = await MmItemType.getItemTypeList() - itemTypeList.value.forEach(function (value) { - itemTypeMap[value.id] = value.itemtypename - }) - if (!dataForm.value.id) { - dataForm.value.mmPredictItem.itemtypeid = itemTypeList.value[0].id - } -} - -// 获取管网列表 -const getModuleList = async () => { - moduleList.value = [] - moduleList.value = await DmModule.getModuleList() -} - -const getResulttableList = async () => { - resulttableList.value = [] - resulttableList.value = await MmResultTable.getResulttableList() -} - -const getResultstridList = async () => { - resultstridList.value = [] - resultstridList.value = await MmResultTable.getResultstridList() -} - -const getPointList = async () => { - pointLoading.value = true - pointNoList.value = await DaPoint.getPointList(queryParams) - if (pointNoList.value.length > 0) { - pointNoList.value.forEach(function (value) { - pointList.value.push(value) - pointMap[value.id] = value.pointname - }) - } -} - -const getModelparamList = async () => { - modelparamListMap.value = [] - modelparamList.value = [] - predictItemList.value = [] - pointNoList.value = await DaPoint.getPointList(queryParams) - let paramList = [] - if (pointNoList.value.length > 0) { - pointNoList.value.forEach(function (value) { - paramList.push({ - id: value.id, - code: value.pointno, - name: value.pointname, - type: 'DATAPOINT' - }) - modelparamMap[value.id] = value.pointname - }) - modelparamListMap['DATAPOINT'] = paramList; - } - - predictList.value = await MmPredictItem.getMmPredictItemList() - paramList = [] - if (predictList.value.length > 0) { - predictList.value.forEach(function (value) { - paramList.push({ - id: value.id, - code: value.itemno, - name: value.itemname, - type: 'PREDICTITEM' - }) - if (value.id !== dataForm.value.id) { - predictItemList.value.push({ - id: value.id, - code: value.itemno, - name: value.itemname - }) - } - modelparamMap[value.id] = value.itemname - }) - modelparamListMap['PREDICTITEM'] = paramList; - } - - /*const dayParams = { - 'processType': '日计划' - } - let dayScheduleRes = await ScheduleModelApi.getScheduleWorkPrecessList(dayParams) - paramList = [] - if (dayScheduleRes !== null) { - dayScheduleRes.forEach(function (value) { - paramList.push({ - id: value.id, - code: value.code, - name: value.aliasName, - type: 'DAYWORKPROCESSPLAN' - }) - modelparamMap[value.id] = value.aliasName - }) - modelparamListMap['DAYWORKPROCESSPLAN'] = paramList; - } - - const monthParams = { - 'processType': '月计划' - } - let monthScheduleRes = await ScheduleModelApi.getScheduleWorkPrecessList(monthParams) - paramList = [] - if (monthScheduleRes !== null) { - monthScheduleRes.forEach(function (value) { - paramList.push({ - id: value.id, - code: value.code, - name: value.aliasName, - type: 'MONTHWORKPROCESSPLAN' - }) - modelparamMap[value.id] = value.aliasName - }) - modelparamListMap['MONTHWORKPROCESSPLAN'] = paramList; - }*/ -} - const setDefaultFields = () => { dataForm.value.mmPredictItem.workchecked = 0 dataForm.value.mmPredictItem.status = 1 @@ -866,13 +776,12 @@ } /** 重置表单 */ -/*const resetForm = () => { +const resetForm = () => { dataForm.value = { mmModelArithSettingsList: [], mmModelParamList: [], - modelparamtypeList: [], id: '', - itemtypename: '', + itemtypename: 'NormalItem', mmPredictItem: { id: '', itemno: '', @@ -880,11 +789,11 @@ caltypeid: '', itemtypeid: '', predictlength: '', - granularity: '', + granularity: 60, status: '', isfuse: '', predictphase: '', - workchecked: '', + workchecked: 0, unittransfactor: '', saveindex: '' }, @@ -892,7 +801,7 @@ id: '', moduleid: '', itemid: '', - itemorder: '', + itemorder: 1, status: 1, categoryid: '' }, @@ -932,7 +841,7 @@ } } formRef.value?.resetFields() -}*/ +} onMounted(() => { init() -- Gitblit v1.9.3