Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
c7118aa892
@ -1,37 +1,46 @@
|
||||
<template>
|
||||
<div class="measurement">
|
||||
<el-table :columns="tableColumn" :data="tableData" @sort-change="sortChange" max-height="420">
|
||||
<el-table-column
|
||||
v-for="item in tableColumn"
|
||||
:key="item.prop"
|
||||
:label="item.label"
|
||||
:prop="item.prop"
|
||||
:width="item.width ?? ''"
|
||||
:align="item.align"
|
||||
:sortable="item.sortable"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-radio
|
||||
v-if="item.prop === 'index'"
|
||||
:label="scope.row.attributeCode"
|
||||
v-model="selectedIndex"
|
||||
@change="handleRadioChange(scope.row)"
|
||||
> </el-radio
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div>
|
||||
<el-pagination
|
||||
v-model:current-page="pageSetting.current"
|
||||
v-model:page-size="pageSetting.pageSize"
|
||||
:total="pageSetting.total"
|
||||
:page-sizes="pageSetting.pageSizes"
|
||||
background
|
||||
:pager-count="7"
|
||||
layout="prev, pager, next, jumper,sizes,total"
|
||||
@change="getcurrentPage"
|
||||
></el-pagination>
|
||||
<div class="transferHeader">
|
||||
<span class="transferTitle">可添加的测点</span>
|
||||
<el-radio-group v-model="radioActiveName" @change="typeChange">
|
||||
<el-radio :value="138">模拟量</el-radio>
|
||||
<el-radio :value="199">计算量</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<div class="main">
|
||||
<el-table :columns="tableColumn" :data="tableData" max-height="420">
|
||||
<el-table-column
|
||||
v-for="item in tableColumn"
|
||||
:key="item.prop"
|
||||
:label="item.label"
|
||||
:prop="item.prop"
|
||||
:width="item.width ?? ''"
|
||||
:align="item.align"
|
||||
:sortable="item.sortable"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-radio
|
||||
v-if="item.prop === 'index'"
|
||||
:label="scope.row.attributeCode"
|
||||
v-model="selectedIndex"
|
||||
@change="handleRadioChange(scope.row)"
|
||||
> </el-radio
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="display: flex; justify-content: right; margin-top: 5px">
|
||||
<el-pagination
|
||||
v-model:current-page="pageSetting.current"
|
||||
v-model:page-size="pageSetting.pageSize"
|
||||
:total="pageSetting.total"
|
||||
:page-sizes="pageSetting.pageSizes"
|
||||
background
|
||||
:pager-count="5"
|
||||
layout="prev, pager, next, jumper,sizes,total"
|
||||
@change="getcurrentPage"
|
||||
></el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -39,8 +48,7 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch, defineEmits } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { ModelAttributeFieldsEnums } from '/@/views/backend/auth/model/type'
|
||||
import { getModelAttributeListReq, getRealValueListReq } from '/@/api/backend/deviceModel/request'
|
||||
import { getModelAttributeListReq } from '/@/api/backend/deviceModel/request'
|
||||
|
||||
const props = defineProps({
|
||||
iotModelId: {
|
||||
@ -61,6 +69,10 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const radioActiveName = ref(138)
|
||||
const typeChange = () => {
|
||||
pageSetting.current == 1 ? getCompleteData() : (pageSetting.current = 1)
|
||||
}
|
||||
const selectedIndex: any = ref(null)
|
||||
const tableColumn = [
|
||||
{
|
||||
@ -107,31 +119,15 @@ const getAttributeList = () => {
|
||||
iotModelId: props.iotModelId,
|
||||
pageNum: pageSetting.current,
|
||||
pageSize: pageSetting.pageSize,
|
||||
attributeType: '138',
|
||||
orderColumn: sortData.orderColumn,
|
||||
orderType: sortData.orderType,
|
||||
attributeType: radioActiveName.value,
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
getModelAttributeListReq(requestData)
|
||||
.then((res) => {
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
const codeList: any = []
|
||||
const data = res.rows!.map((item) => {
|
||||
codeList.push(item.attributeCode)
|
||||
return {
|
||||
...item,
|
||||
attributeTypeName:
|
||||
item.attributeType === 138
|
||||
? '模拟量'
|
||||
: item.attributeType === 139
|
||||
? '累积量'
|
||||
: item.attributeType === 140
|
||||
? '离散量'
|
||||
: item.attributeType!,
|
||||
}
|
||||
})
|
||||
const data = res.rows
|
||||
pageSetting.total = res.total
|
||||
resolve({ data, codeList })
|
||||
resolve({ data })
|
||||
} else {
|
||||
if (res.rows && res.rows.length === 0) {
|
||||
tableData.value = []
|
||||
@ -146,54 +142,10 @@ const getAttributeList = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const getRealValueList = (data: { deviceId: string; attributes: string[] }, list?: any) => {
|
||||
return new Promise((resolve) => {
|
||||
getRealValueListReq([data]).then((res) => {
|
||||
if (res.success && res.data) {
|
||||
resolve({ realVal: res.data, list })
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const getCompleteData = () => {
|
||||
getAttributeList()
|
||||
.then(({ data, codeList }: any) => {
|
||||
return getRealValueList({ deviceId: props.deviceId, attributes: codeList }, data)
|
||||
})
|
||||
.then((realData: any) => {
|
||||
const data = realData.list.map((item: any) => {
|
||||
const realValItem = realData.realVal[props.deviceId]?.[item.attributeCode?.toLowerCase()]
|
||||
return {
|
||||
...item,
|
||||
realTimeValue: realValItem ? (realValItem % 1 === 0 ? realValItem : realValItem.toFixed(3)) : '-',
|
||||
}
|
||||
})
|
||||
|
||||
tableData.value = data
|
||||
})
|
||||
}
|
||||
|
||||
const sortData = reactive<{ orderColumn?: keyof typeof ModelAttributeFieldsEnums; orderType?: 'asc' | 'desc' }>({
|
||||
orderColumn: 'porder',
|
||||
orderType: 'asc',
|
||||
})
|
||||
|
||||
const sortChange = ({ prop, order }: { prop: keyof typeof ModelAttributeFieldsEnums; order: 'ascending' | 'descending' | null }) => {
|
||||
const propEnums = {
|
||||
attributeCode: 'attribute_code',
|
||||
attributeName: 'attribute_name',
|
||||
attributeTypeName: 'attribute_type',
|
||||
porder: 'porder',
|
||||
serviceCode: 'service_code',
|
||||
serviceName: 'service_name',
|
||||
serviceTypeName: 'service_type',
|
||||
}
|
||||
const orderType = order === 'ascending' ? 'asc' : order === 'descending' ? 'desc' : undefined
|
||||
const filed = propEnums[prop as keyof typeof propEnums] as keyof typeof ModelAttributeFieldsEnums
|
||||
sortData.orderColumn = orderType ? filed : undefined
|
||||
sortData.orderType = orderType
|
||||
getCompleteData()
|
||||
getAttributeList().then(({ data }: any) => {
|
||||
tableData.value = data
|
||||
})
|
||||
}
|
||||
|
||||
const pageSetting = reactive({
|
||||
@ -211,7 +163,7 @@ watch(
|
||||
() => props.show,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
getCompleteData()
|
||||
pageSetting.current == 1 ? getCompleteData() : (pageSetting.current = 1)
|
||||
selectedIndex.value = props.irn
|
||||
}
|
||||
},
|
||||
@ -221,4 +173,23 @@ watch(
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped>
|
||||
.measurement {
|
||||
border: 1px solid #e1edf6;
|
||||
border-radius: 6px;
|
||||
.transferHeader {
|
||||
height: 40px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
color: #333333;
|
||||
background: #f7f9fc;
|
||||
border-bottom: 1px solid #e1edf6;
|
||||
border-radius: 6px 6px 0 0;
|
||||
}
|
||||
.main {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -71,12 +71,15 @@ const { t } = useI18n()
|
||||
|
||||
const statAnalysisFatory = ref('')
|
||||
const statAnalysisFatoryList: any = ref([])
|
||||
const statAnalysisTime = ref('')
|
||||
const statAnalysisInterval = ref('')
|
||||
const statAnalysisInterval = ref('1h')
|
||||
const statAnalysisDeviceId = ref('')
|
||||
const statAnalysisSelectOptions: any = reactive({
|
||||
interval: [
|
||||
{ label: '一分钟', value: '1m' },
|
||||
{ label: '一分钟', value: '1m' },
|
||||
{ label: '五分钟', value: '5m' },
|
||||
{ label: '十分钟', value: '10m' },
|
||||
{ label: '十分钟', value: '10m' },
|
||||
{ label: '十五分钟', value: '15m' },
|
||||
{ label: '一小时', value: '1h' },
|
||||
{ label: '一天', value: '1d' },
|
||||
@ -85,6 +88,16 @@ const statAnalysisSelectOptions: any = reactive({
|
||||
deviceId: [],
|
||||
})
|
||||
|
||||
const getFormattedDate = (offset: number) => {
|
||||
const date = new Date()
|
||||
date.setDate(date.getDate() + offset)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
const statAnalysisTime = ref([getFormattedDate(0) + ' 00:00:00', getFormattedDate(0) + ' 23:59:59'])
|
||||
const chartContainer = ref<HTMLElement | null>(null)
|
||||
|
||||
const option: any = {
|
||||
@ -134,22 +147,6 @@ const chart: any = ref(null)
|
||||
onMounted(() => {
|
||||
if (chartContainer.value) {
|
||||
chart.value = echarts.init(chartContainer.value)
|
||||
chart.value.setOption({
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
name: 'm/s',
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
name: 'KW',
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'line',
|
||||
},
|
||||
],
|
||||
grid: {},
|
||||
})
|
||||
chart.value.on('legendselectchanged', function (event: any) {
|
||||
var isSelected = event.selected[event.name]
|
||||
var series = chart.value.getOption().series
|
||||
@ -161,7 +158,10 @@ onMounted(() => {
|
||||
chart.value.setOption({ series: series })
|
||||
})
|
||||
}
|
||||
queryWindTurbines()
|
||||
queryWindTurbines().then((res: any) => {
|
||||
statAnalysisDeviceId.value = res.value
|
||||
statAnalysisOperate()
|
||||
})
|
||||
queryfactoery()
|
||||
})
|
||||
|
||||
@ -174,16 +174,25 @@ const queryfactoery = () => {
|
||||
}
|
||||
|
||||
const queryWindTurbines = () => {
|
||||
queryWindTurbinesPages().then((res) => {
|
||||
if (res.code == 200) {
|
||||
statAnalysisSelectOptions.deviceId = res.data.map((item: any) => {
|
||||
return {
|
||||
value: `${item.madeinfactory}:${item.model}:${item.irn}`,
|
||||
label: item.name ?? '-',
|
||||
iotModelId: item.modelId,
|
||||
return new Promise((resolve) => {
|
||||
queryWindTurbinesPages()
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
statAnalysisSelectOptions.deviceId = res.data.map((item: any) => {
|
||||
return {
|
||||
value: `${item.madeinfactory}:${item.model}:${item.irn}`,
|
||||
label: item.name ?? '-',
|
||||
iotModelId: item.modelId,
|
||||
}
|
||||
})
|
||||
resolve(statAnalysisSelectOptions.deviceId[0])
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
.catch((err) => {
|
||||
ElMessage.error(err ?? '查询失败')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -229,15 +238,7 @@ const shortcuts = [
|
||||
},
|
||||
},
|
||||
]
|
||||
const getFormattedDate = (offset: number) => {
|
||||
const date = new Date()
|
||||
date.setDate(date.getDate() + offset)
|
||||
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
const getDateRange = (type: 'week' | 'month') => {
|
||||
const today = new Date()
|
||||
if (type === 'week') {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="contain">
|
||||
<div class="headerPart">
|
||||
<el-header class="headerPart">
|
||||
<div class="topLeft">
|
||||
<div class="selectPart">
|
||||
<span>{{ t('statAnalysis.deviceId') }}</span>
|
||||
@ -28,73 +28,73 @@
|
||||
<el-option v-for="v in statAnalysisSelectOptions.interval" :key="v.value" :label="v.label" :value="v.value"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<el-button class="addline" type="primary" :icon="Plus" @click="addTime()"> 增加</el-button>
|
||||
<el-button class="addline" type="primary" :icon="Plus" @click="addTime()"> 增加时间</el-button>
|
||||
</div>
|
||||
<div class="topRight">
|
||||
<el-button type="primary" :loading="isLoading" @click="statAnalysisOperate()">{{ t('statAnalysis.search') }}</el-button>
|
||||
<el-button style="color: #0064aa" @click="statAnalysisExport()">{{ t('statAnalysis.export') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-header>
|
||||
<div class="main">
|
||||
<div class="left">
|
||||
<div class="timeColumns">
|
||||
<div class="moduleRow" v-for="(time, index) in times" :key="index">
|
||||
<div class="item">
|
||||
<el-icon v-show="index !== 0" class="removeModule" @click="switchTime(index)">
|
||||
<Close />
|
||||
</el-icon>
|
||||
<div class="selectPart">
|
||||
<span>曲线名称</span>
|
||||
<el-input v-model="customName[index]" class="customName"></el-input>
|
||||
</div>
|
||||
<div class="selectPart">
|
||||
<span>{{ t('statAnalysis.time') }}</span>
|
||||
<el-date-picker
|
||||
class="datetime-picker"
|
||||
v-model="times[index]"
|
||||
:type="statAnalysisSelect.interval == '1d' ? 'daterange' : 'datetimerange'"
|
||||
:value-format="statAnalysisSelect.interval == '1d' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
|
||||
:teleported="false"
|
||||
:shortcuts="shortcuts"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
|
||||
@change="timechange(index)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
ref="chartContainer"
|
||||
style="height: calc(100% - 140px); width: calc(100% - 60px); border: 1px solid rgb(217, 217, 217); margin: 40px"
|
||||
></div>
|
||||
</div>
|
||||
<el-dialog v-model="showMeasure" title="选择测点" :width="800">
|
||||
<div class="measureSlot">
|
||||
<MeasurementPage :show="showMeasure" :iotModelId="iotModelId" :irn="irn" @handleRadioChange="handleRadioChange"></MeasurementPage>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="selectstatAnalysisAttributes"> 确认 </el-button>
|
||||
<el-button @click="showMeasure = false">取消</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="showTime" title="选择时间" :width="800">
|
||||
<div>
|
||||
<div class="selectPart">
|
||||
<span>{{ t('statAnalysis.time') }}</span>
|
||||
<el-date-picker
|
||||
class="datetime-picker"
|
||||
v-model="time"
|
||||
:type="statAnalysisSelect.interval == '1d' ? 'daterange' : 'datetimerange'"
|
||||
:value-format="statAnalysisSelect.interval == '1d' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
|
||||
:teleported="false"
|
||||
:shortcuts="shortcuts"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
|
||||
@change="timechange"
|
||||
/>
|
||||
</div>
|
||||
<div class="transferRight">
|
||||
<div class="transferHeader">
|
||||
<span class="transferTitle"
|
||||
>已选择<span>{{ times.length }}</span
|
||||
>项</span
|
||||
>
|
||||
<div @click="clearList" style="color: rgb(0, 100, 170); cursor: pointer">清空</div>
|
||||
</div>
|
||||
<el-main class="transferMain">
|
||||
<el-scrollbar>
|
||||
<div class="selectItem" v-for="(item, index) in times" :key="index">
|
||||
{{ statAnalysisSelect.attributes + (index + 1) }} : {{ item[0] }} 至 {{ item[1] }}
|
||||
<div>
|
||||
<el-icon :size="20" @click="switchTime(index)"><Close /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</el-main>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<div
|
||||
ref="chartContainer"
|
||||
style="
|
||||
position: absolute;
|
||||
top: 127px;
|
||||
width: calc(100% - 430px);
|
||||
height: calc(100% - 187px);
|
||||
border: 1px solid rgb(217, 217, 217);
|
||||
margin: 30px 0;
|
||||
"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="showTime = false"> 确认 </el-button>
|
||||
<el-button @click="showTime = false">取消</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<el-dialog v-model="showMeasure" title="测点名称" :width="800">
|
||||
<template #header>
|
||||
<div class="measureSlotHeader">
|
||||
<span style="font-size: 20px">测点名称</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="measureSlot">
|
||||
<MeasurementPage :show="showMeasure" :iotModelId="iotModelId" :irn="irn" @handleRadioChange="handleRadioChange"></MeasurementPage>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="selectstatAnalysisAttributes"> 确认 </el-button>
|
||||
<el-button @click="showMeasure = false">取消</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, markRaw } from 'vue'
|
||||
@ -103,13 +103,15 @@ import { queryWindTurbinesPages, historyReq, trendAnalyseExport } from '/@/api/b
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { DArrowRight, Plus, Delete, Close } from '@element-plus/icons-vue'
|
||||
import MeasurementPage from './analysisAttributes.vue'
|
||||
import { getModelAttributeListReq } from '/@/api/backend/deviceModel/request'
|
||||
|
||||
import * as echarts from 'echarts'
|
||||
const { t } = useI18n()
|
||||
const statAnalysisSelect = reactive({
|
||||
deviceId: '',
|
||||
attributes: '',
|
||||
attributeCode: '',
|
||||
interval: '',
|
||||
interval: '1h',
|
||||
time: '',
|
||||
unit: '',
|
||||
})
|
||||
@ -121,29 +123,45 @@ const getFormattedDate = (offset: number) => {
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
const time: any = ref([getFormattedDate(0) + ' 00:00:00', getFormattedDate(0) + ' 23:59:59'])
|
||||
const times: any = reactive([[getFormattedDate(0) + ' 00:00:00', getFormattedDate(0) + ' 23:59:59']])
|
||||
const addTime = () => {
|
||||
if (times.length < 4) {
|
||||
times.push([getFormattedDate(-times.length) + ' 00:00:00', getFormattedDate(-times.length) + ' 23:59:59'])
|
||||
customName.push(statAnalysisSelect.attributes + String(times.length))
|
||||
} else {
|
||||
ElMessage.info('最多可添加四条查询曲线!')
|
||||
}
|
||||
time.value = [getFormattedDate(0) + ' 00:00:00', getFormattedDate(0) + ' 23:59:59']
|
||||
showTime.value = true
|
||||
}
|
||||
const switchTime = (index: number) => {
|
||||
if (index == 0) {
|
||||
time.value = []
|
||||
}
|
||||
times.splice(index, 1)
|
||||
customName.splice(index, 1)
|
||||
calculate.value.splice(index, 1)
|
||||
}
|
||||
const timechange = (value: any) => {
|
||||
const count = getTimeIntervals(times[0][0], times[0][1])
|
||||
const count1 = getTimeIntervals(times[value][0], times[value][1])
|
||||
if (count !== count1) {
|
||||
times[value] = { time: '' }
|
||||
ElMessage.warning('查询时间点错误,请重新输入')
|
||||
if (times.length) {
|
||||
const count = getTimeIntervals(times[0][0], times[0][1])
|
||||
const count1 = getTimeIntervals(value[0], value[1])
|
||||
if (count !== count1) {
|
||||
ElMessage.warning('查询时间点错误,请重新输入')
|
||||
return
|
||||
} else if (hasDuplicateArrays(value)) {
|
||||
ElMessage.info('存在相同的查询时间!')
|
||||
return
|
||||
} else {
|
||||
times.push(value)
|
||||
customName.push(statAnalysisSelect.attributes + times.length)
|
||||
}
|
||||
} else {
|
||||
times.push(value)
|
||||
customName.push(statAnalysisSelect.attributes + times.length)
|
||||
}
|
||||
}
|
||||
|
||||
const showTime = ref(false)
|
||||
const clearList = () => {
|
||||
times.length = 0
|
||||
time.value = []
|
||||
}
|
||||
|
||||
const iotModelId = ref('')
|
||||
const irn = ref('')
|
||||
const attributesChange = () => {
|
||||
@ -172,7 +190,6 @@ const selectedAttrRow: any = ref({
|
||||
unit: '',
|
||||
})
|
||||
const handleRadioChange = (value: any) => {
|
||||
console.log('🚀 ~ handleRadioChange ~ value:', value)
|
||||
const { attributeCode, attributeName, unit } = { ...value }
|
||||
selectedAttrRow.attributeCode = attributeCode
|
||||
selectedAttrRow.attributeName = attributeName
|
||||
@ -180,7 +197,6 @@ const handleRadioChange = (value: any) => {
|
||||
}
|
||||
const selectstatAnalysisAttributes = () => {
|
||||
statAnalysisSelect.attributes = selectedAttrRow.attributeName
|
||||
console.log('🚀 ~ selectstatAnalysisAttributes ~ selectedAttrRow:', selectedAttrRow)
|
||||
statAnalysisSelect.attributeCode = selectedAttrRow.attributeCode
|
||||
statAnalysisSelect.unit = selectedAttrRow.unit
|
||||
showMeasure.value = false
|
||||
@ -212,7 +228,9 @@ const option: any = {
|
||||
|
||||
const statAnalysisSelectOptions: any = reactive({
|
||||
interval: [
|
||||
{ label: '一分钟', value: '1m' },
|
||||
{ label: '五分钟', value: '5m' },
|
||||
{ label: '十分钟', value: '10m' },
|
||||
{ label: '十五分钟', value: '15m' },
|
||||
{ label: '一小时', value: '1h' },
|
||||
{ label: '一天', value: '1d' },
|
||||
@ -226,37 +244,69 @@ const chart: any = ref(null)
|
||||
onMounted(() => {
|
||||
if (chartContainer.value) {
|
||||
chart.value = markRaw(echarts.init(chartContainer.value))
|
||||
chart.value.setOption({
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'line',
|
||||
},
|
||||
],
|
||||
grid: {},
|
||||
})
|
||||
}
|
||||
queryWindTurbines()
|
||||
queryWindTurbines().then((res: any) => {
|
||||
statAnalysisSelect.deviceId = res.value
|
||||
getAttributeList({
|
||||
iotModelId: res.iotModelId,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
attributeType: '138',
|
||||
}).then((attrRes: any) => {
|
||||
statAnalysisSelect.attributes = attrRes.attributeName
|
||||
statAnalysisSelect.attributeCode = attrRes.attributeCode
|
||||
statAnalysisSelect.unit = attrRes.unit
|
||||
selectedAttrRow.attributeCode = attrRes.attributeCode
|
||||
selectedAttrRow.attributeName = attrRes.attributeName
|
||||
selectedAttrRow.unit = attrRes.unit
|
||||
customName.forEach((item: any, index: number, arr: any) => {
|
||||
arr[index] = statAnalysisSelect.attributes + String(index + 1)
|
||||
})
|
||||
statAnalysisOperate()
|
||||
})
|
||||
})
|
||||
})
|
||||
const queryWindTurbines = () => {
|
||||
queryWindTurbinesPages().then((res) => {
|
||||
if (res.code == 200) {
|
||||
statAnalysisSelectOptions.deviceId = res.data.map((item: any) => {
|
||||
return {
|
||||
value: item.irn,
|
||||
label: item.name ?? '-',
|
||||
iotModelId: item.modelId,
|
||||
|
||||
const getAttributeList = (requestData: any) => {
|
||||
return new Promise((resolve) => {
|
||||
getModelAttributeListReq(requestData)
|
||||
.then((res: any) => {
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
resolve(res.rows[0])
|
||||
} else {
|
||||
}
|
||||
})
|
||||
}
|
||||
.catch((err: any) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const queryWindTurbines = () => {
|
||||
return new Promise((resolve) => {
|
||||
queryWindTurbinesPages()
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
statAnalysisSelectOptions.deviceId = res.data.map((item: any) => {
|
||||
return {
|
||||
value: item.irn,
|
||||
label: item.name ?? '-',
|
||||
iotModelId: item.modelId,
|
||||
}
|
||||
})
|
||||
resolve(statAnalysisSelectOptions.deviceId[0])
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err ?? '查询失败')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const radioActiveName = ref(138)
|
||||
|
||||
window.onresize = () => {
|
||||
chart.value.resize()
|
||||
}
|
||||
@ -328,12 +378,18 @@ const getTimeIntervals = (startTimestamp: number, endTimestamp: number) => {
|
||||
case 'NONE':
|
||||
count = Math.floor((endDate - startDate) / 1000)
|
||||
break
|
||||
case '1m':
|
||||
count = Math.floor((endDate - startDate) / (60 * 1000))
|
||||
break
|
||||
case '5m':
|
||||
count = Math.floor((endDate - startDate) / (5 * 60 * 1000))
|
||||
break
|
||||
case '15m':
|
||||
count = Math.floor((endDate - startDate) / (15 * 60 * 1000))
|
||||
break
|
||||
case '15m':
|
||||
count = Math.floor((endDate - startDate) / (15 * 60 * 1000))
|
||||
break
|
||||
case '1h':
|
||||
count = Math.floor((endDate - startDate) / (1 * 60 * 60 * 1000))
|
||||
break
|
||||
@ -350,8 +406,6 @@ const calculate: any = ref([{ max: '', min: '', average: '' }])
|
||||
var xDatas: any = []
|
||||
const isLoading = ref(false)
|
||||
const statAnalysisOperate = () => {
|
||||
console.log('🚀 ~ findTime ~ times:', times)
|
||||
|
||||
const findTime = times.filter((item: any) => {
|
||||
return Array.isArray(item)
|
||||
})
|
||||
@ -364,9 +418,6 @@ const statAnalysisOperate = () => {
|
||||
} else if (!findTime.length) {
|
||||
ElMessage.info('请选择查询时间!')
|
||||
return
|
||||
} else if (hasDuplicateArrays(times)) {
|
||||
ElMessage.info('存在相同的查询时间!')
|
||||
return
|
||||
}
|
||||
isLoading.value = true
|
||||
option.series = []
|
||||
@ -377,7 +428,6 @@ const statAnalysisOperate = () => {
|
||||
const promises: any = []
|
||||
|
||||
times.forEach((time: any, index: number) => {
|
||||
console.log('🚀 ~ times.forEach ~ time:', time)
|
||||
if (time && time[0] && time[1]) {
|
||||
const requestData = {
|
||||
devices: [
|
||||
@ -485,6 +535,8 @@ const statAnalysisExport = () => {
|
||||
requestData.push(devices)
|
||||
}
|
||||
})
|
||||
console.log('🚀 ~ times.forEach ~ requestData:', requestData)
|
||||
|
||||
trendAnalyseExport(requestData).then((res: any) => {
|
||||
const downloadUrl = window.URL.createObjectURL(res)
|
||||
const a = document.createElement('a')
|
||||
@ -498,6 +550,7 @@ const statAnalysisExport = () => {
|
||||
}
|
||||
|
||||
const hasDuplicateArrays = (arr: any) => {
|
||||
arr = [...times, arr]
|
||||
const seen = new Set()
|
||||
for (let subArray of arr) {
|
||||
const subArrayStr = JSON.stringify(subArray)
|
||||
@ -516,9 +569,15 @@ const getTimestamps = (start: any, end: any, interval: any) => {
|
||||
while (current < end) {
|
||||
timestamps.push(current)
|
||||
switch (interval) {
|
||||
case '1m':
|
||||
current += 60 * 1000
|
||||
break
|
||||
case '5m':
|
||||
current += 5 * 60 * 1000
|
||||
break
|
||||
case '15m':
|
||||
current += 15 * 60 * 1000
|
||||
break
|
||||
case '1d':
|
||||
current += 24 * 60 * 60 * 1000
|
||||
break
|
||||
@ -678,5 +737,48 @@ const timestampToTime = (timestamp: any) => {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
.transferRight {
|
||||
height: 400px;
|
||||
border: 1px solid #e1edf6;
|
||||
border-radius: 6px;
|
||||
margin-top: 20px;
|
||||
.transferHeader {
|
||||
height: 40px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
color: #333333;
|
||||
background: #f7f9fc;
|
||||
border-bottom: 1px solid #e1edf6;
|
||||
border-radius: 6px 6px 0 0;
|
||||
}
|
||||
.transferMain {
|
||||
padding: 0;
|
||||
:deep(.el-table__row) {
|
||||
height: 40px;
|
||||
padding: 0 20px;
|
||||
background: #eff0f1;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.selectItem {
|
||||
height: 40px;
|
||||
padding: 0 20px;
|
||||
background: #eff0f1;
|
||||
border-radius: 4px;
|
||||
margin: 10px;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.el-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
.mainFooter {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -44,10 +44,11 @@
|
||||
</div>
|
||||
<div class="mainPart">
|
||||
<el-table
|
||||
ref="tableDataLeftRef"
|
||||
:data="tableDataLeft"
|
||||
v-model:selection="selectedLeft"
|
||||
@selection-change="handleSelectionChange"
|
||||
row-key="id"
|
||||
row-key="irn"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="name" label="风机名称" width="120" />
|
||||
@ -56,7 +57,7 @@
|
||||
:data="tableDataRight"
|
||||
v-model:selection="selectedRight"
|
||||
@selection-change="handleSelectionChange1"
|
||||
row-key="id"
|
||||
row-key="irn"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="name" label="风机名称" width="120" />
|
||||
@ -71,7 +72,6 @@
|
||||
<el-radio-group v-model="radioActiveName" @change="typeChange">
|
||||
<el-radio :value="138">模拟量</el-radio>
|
||||
<el-radio :value="199">计算量</el-radio>
|
||||
<el-radio :value="140">状态量</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<div class="mainPart">
|
||||
@ -125,10 +125,12 @@ import { getModelAttributeListReq } from '/@/api/backend/deviceModel/request'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const statAnalysisInterval = ref('')
|
||||
const statAnalysisInterval = ref('1h')
|
||||
const statAnalysisSelectOptions: any = reactive({
|
||||
interval: [
|
||||
{ label: '一分钟', value: '1m' },
|
||||
{ label: '五分钟', value: '5m' },
|
||||
{ label: '十分钟', value: '10m' },
|
||||
{ label: '十五分钟', value: '15m' },
|
||||
{ label: '一小时', value: '1h' },
|
||||
{ label: '一天', value: '1d' },
|
||||
@ -180,23 +182,22 @@ const chart: any = ref(null)
|
||||
onMounted(() => {
|
||||
if (chartContainer.value) {
|
||||
chart.value = markRaw(echarts.init(chartContainer.value))
|
||||
chart.value.setOption({
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'line',
|
||||
},
|
||||
],
|
||||
grid: {},
|
||||
})
|
||||
}
|
||||
queryWindTurbines()
|
||||
getCompleteData()
|
||||
|
||||
queryWindTurbines().then((res) => {
|
||||
selectedLeft.value = [tableDataLeft.value[0]]
|
||||
getCompleteData().then((attrRes: any) => {
|
||||
console.log('🚀 ~ getCompleteData ~ attrRes:', attrRes)
|
||||
multipleSelection.value = [
|
||||
{
|
||||
attributeName: attrRes.attributeName,
|
||||
attributeCode: attrRes.attributeCode,
|
||||
unit: attrRes.unit,
|
||||
},
|
||||
]
|
||||
statAnalysisOperate()
|
||||
})
|
||||
})
|
||||
})
|
||||
const tableDataLeft = ref([])
|
||||
const tableDataRight = ref([])
|
||||
@ -207,19 +208,29 @@ const selectedRight = ref([])
|
||||
const radioActiveName = ref(138)
|
||||
const attributeTableRef = ref()
|
||||
const typeChange = () => {
|
||||
getCompleteData()
|
||||
pageSetting.current == 1 ? getCompleteData() : (pageSetting.current = 1)
|
||||
}
|
||||
|
||||
const queryWindTurbines = () => {
|
||||
queryWindTurbinesPages().then((res) => {
|
||||
if (res.code == 200) {
|
||||
const resData = res.data
|
||||
if (resData.length) {
|
||||
iotModelId.value = resData[0]['modelId']
|
||||
const middleIndex = Math.ceil(resData.length / 2)
|
||||
tableDataLeft.value = resData.slice(0, middleIndex)
|
||||
tableDataRight.value = resData.slice(middleIndex)
|
||||
}
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
queryWindTurbinesPages()
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
const resData = res.data
|
||||
if (resData.length) {
|
||||
iotModelId.value = resData[0]['modelId']
|
||||
const middleIndex = Math.ceil(resData.length / 2)
|
||||
tableDataLeft.value = resData.slice(0, middleIndex)
|
||||
tableDataRight.value = resData.slice(middleIndex)
|
||||
}
|
||||
resolve(resData[0])
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err ?? '查询失败')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -241,25 +252,28 @@ const getCompleteData = () => {
|
||||
pageSize: pageSetting.pageSize,
|
||||
attributeType: radioActiveName.value,
|
||||
}
|
||||
getModelAttributeListReq(requestData)
|
||||
.then((res: any) => {
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
attrTableData.value = res.rows
|
||||
pageSetting.total = res.total
|
||||
nextTick(() => {
|
||||
initSelect()
|
||||
})
|
||||
} else {
|
||||
if (res.rows && res.rows.length === 0) {
|
||||
attrTableData.value = []
|
||||
return new Promise((resolve) => {
|
||||
getModelAttributeListReq(requestData)
|
||||
.then((res: any) => {
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
attrTableData.value = res.rows
|
||||
pageSetting.total = res.total
|
||||
nextTick(() => {
|
||||
initSelect()
|
||||
})
|
||||
resolve(attrTableData.value[0])
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
if (res.rows && res.rows.length === 0) {
|
||||
attrTableData.value = []
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const initSelect = () => {
|
||||
@ -353,9 +367,16 @@ const getDateRange = (type: 'week' | 'month') => {
|
||||
}
|
||||
}
|
||||
|
||||
const tableDataLeftRef = ref()
|
||||
const openMeasure = () => {
|
||||
showMeasure.value = true
|
||||
pageSetting.current = 1
|
||||
nextTick(() => {
|
||||
selectedLeft.value.forEach((item) => {
|
||||
tableDataLeftRef.value?.toggleRowSelection(item, true)
|
||||
})
|
||||
initSelect()
|
||||
})
|
||||
}
|
||||
|
||||
const handleSelectionChange1 = (val: any) => {
|
||||
@ -378,6 +399,7 @@ function generateDeviceAttributes(devices: any, attributes: any) {
|
||||
|
||||
const statAnalysisOperate = () => {
|
||||
const allDevices = [...selectedLeft.value, ...selectedRight.value]
|
||||
console.log('🚀 ~ statAnalysisOperate ~ selectedRight.value:', selectedRight.value)
|
||||
if (!statAnalysisTime.value) {
|
||||
ElMessage.info('请选择查询时间!')
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user