Browse Source

1.对接环境监测接口

2.开发环境监测-配置监测点位
2.修改监测中心多个时间筛选逻辑
temp
fks-yangshouda 3 months ago
parent
commit
3daeea7d3d
  1. 16
      hx-ai-intelligent/src/api/monitor.ts
  2. 74
      hx-ai-intelligent/src/view/monitor/energyMonitor/tree/index.vue
  3. 885
      hx-ai-intelligent/src/view/monitor/environmentMonitor/aggregateData/index.vue
  4. 52
      hx-ai-intelligent/src/view/monitor/environmentMonitor/averageData/config.ts
  5. 207
      hx-ai-intelligent/src/view/monitor/environmentMonitor/averageData/index.vue
  6. 12
      hx-ai-intelligent/src/view/monitor/environmentMonitor/historyData/config.ts
  7. 467
      hx-ai-intelligent/src/view/monitor/environmentMonitor/historyData/index.vue
  8. 441
      hx-ai-intelligent/src/view/monitor/environmentMonitor/index.vue

16
hx-ai-intelligent/src/api/monitor.ts

@ -11,4 +11,18 @@ export enum energyMonitor {
} }
// 环境监测 // 环境监测
export enum environmentMonitor {} export enum environmentMonitor {
getDeviceStatus = '/carbon-smart/api/monitor/getDeviceStatus', //环境监测-获取设备状态
getDeviceAverages = '/carbon-smart/api/monitor/getDeviceAverages', //环境监测-获取设备平均值
queryDeviceArea = '/carbon-smart/deviceInfo/queryDeviceArea', //查询区域位置组成树结构
getDeviceHotMap = '/carbon-smart/api/monitor/getDeviceHotMap', //环境监测-获取环境热力图
getDeviceHistory = '/carbon-smart/api/monitor/getDeviceHistory', //环境监测-历史数据-获取环境设备历史数据
getDeviceAveragesByRate = '/carbon-smart/api/monitor/getDeviceAveragesByRate', //环境监测-平均数据-获取环境设备平均数据
queryDeviceInfoListPage = '/carbon-smart/api/monitor/queryDeviceInfoListPage', //环境监测-根据条件查询设备数据(分页) 配置监测点位
startUpDevice = '/carbon-smart/api/monitor/startUpDevice', // 环境监测-配置启动设备
stopDevice = '/carbon-smart/api/monitor/stopDevice', // 环境监测-停用设备
}

74
hx-ai-intelligent/src/view/monitor/energyMonitor/tree/index.vue

@ -58,8 +58,9 @@
placeholder="请选择日期类型" placeholder="请选择日期类型"
style="width: 100%; margin-bottom: 10px" style="width: 100%; margin-bottom: 10px"
:options="options2" /> :options="options2" />
<a-date-picker <a-range-picker
style="width: 100%; margin-bottom: 10px" style="width: 100%; margin-bottom: 10px"
@change="onChangeDate"
v-model:value="dateValue" v-model:value="dateValue"
:picker="dateTypeValue" /> :picker="dateTypeValue" />
<a-button type="primary" style="width: 100%; margin-bottom: 10px" @click="getSelect"> <a-button type="primary" style="width: 100%; margin-bottom: 10px" @click="getSelect">
@ -105,7 +106,7 @@
// //
const dateTypeValue = ref<string | undefined>('month'); const dateTypeValue = ref<string | undefined>('month');
// //
const dateValue = ref<Dayjs | undefined>(dayjs()); const dateValue = ref<[Dayjs, Dayjs] | undefined>([dayjs(), dayjs()]);
// //
const getOptionsList = async () => { const getOptionsList = async () => {
@ -123,6 +124,10 @@
} }
options2.value = [ options2.value = [
{ {
value: 'date',
label: '日',
},
{
value: 'month', value: 'month',
label: '月', label: '月',
}, },
@ -159,15 +164,55 @@
} }
changeMode(); changeMode();
}; };
const startDate = ref<String>();
const endDate = ref<String>();
const onChangeDate = (val: RangeValue, dateStrings: any) => {
if (dateStrings && dateStrings.length === 2) {
dateValue.value = val;
startDate.value = dateStrings[0];
endDate.value = dateStrings[1];
}
};
const getSelect = () => { const getSelect = () => {
const date = dateValue.value; // const date = dateValue.value;
let year = 0; // let year = 0;
let month = 0; // let month = 0;
if (date) { // if (date) {
year = date.year(); // year = date.year();
month = date.month() + 1; // month = date.month() + 1;
// } else {
// return;
// }
let startTime = '';
let endTime = '';
if (startDate.value && endDate.value) {
if (dateTypeValue.value == 'month') {
startTime = startDate.value + '-01';
const [year, month] = endDate.value.split('-').map(Number);
//
const date = new Date(year, month, 1);
//
// date.setDate(date.getDate() - 1);
endTime = date.toISOString().split('T')[0];
// endTime = endDate.value + '-01';
} else if (dateTypeValue.value == 'year') {
startTime = startDate.value + '-01-01';
endTime = endDate.value + '-12-31';
} else {
startTime = startDate.value + '';
endTime = endDate.value + '';
}
} else { } else {
return; //
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0'); // getMonth() 0-11
const day = String(today.getDate()).padStart(2, '0');
startTime = year + '-' + month + '-' + day;
endTime = year + '-' + month + '-' + day;
} }
// //
@ -180,9 +225,10 @@
dateType: dateTypeValue.value == 'year' ? 0 : 1, //0 1 dateType: dateTypeValue.value == 'year' ? 0 : 1, //0 1
deviceInfoCodes: mode.value == '0' ? checkedKeys.value : [], // device_info_code deviceInfoCodes: mode.value == '0' ? checkedKeys.value : [], // device_info_code
energyQueryType: mode.value, // 0 1 energyQueryType: mode.value, // 0 1
month: month,
nodeIds: mode.value == '1' ? checkedKeys.value : [], nodeIds: mode.value == '1' ? checkedKeys.value : [],
year: year, startTime: startTime,
endTime: endTime,
}) })
.then((res) => { .then((res) => {
let selectedValueName = ''; let selectedValueName = '';
@ -209,9 +255,10 @@
dateType: dateTypeValue.value == 'year' ? 0 : 1, //0 1 dateType: dateTypeValue.value == 'year' ? 0 : 1, //0 1
deviceInfoCodes: mode.value == '0' ? checkedKeys.value : [], // device_info_code deviceInfoCodes: mode.value == '0' ? checkedKeys.value : [], // device_info_code
energyQueryType: mode.value, // 0 1 energyQueryType: mode.value, // 0 1
month: month,
nodeIds: mode.value == '1' ? checkedKeys.value : [], nodeIds: mode.value == '1' ? checkedKeys.value : [],
year: year, startTime: startTime,
endTime: endTime,
}) })
.then((res) => { .then((res) => {
pageData.analysisTableList = res.data.dataList; pageData.analysisTableList = res.data.dataList;
@ -350,6 +397,7 @@
treeLoading, treeLoading,
changeEnergyType, changeEnergyType,
shebei, shebei,
onChangeDate,
}; };
}, },
}); });

885
hx-ai-intelligent/src/view/monitor/environmentMonitor/aggregateData/index.vue

File diff suppressed because one or more lines are too long

52
hx-ai-intelligent/src/view/monitor/environmentMonitor/averageData/config.ts

@ -7,30 +7,30 @@ export const tableColumns = [
}, },
{ {
title: '时间', title: '时间',
dataIndex: 'areaName', dataIndex: 'time',
}, },
{ // {
title: '温度(℃)', // title: '温度(℃)',
dataIndex: 'point', // dataIndex: 'point',
}, // },
{ // {
title: '湿度(%)', // title: '湿度(%)',
dataIndex: 'date', // dataIndex: 'date',
}, // },
{ // {
title: 'CO2浓度(ppm)', // title: 'CO2浓度(ppm)',
dataIndex: 'areaName', // dataIndex: 'areaName',
}, // },
{ // {
title: 'PM2.5(μg/m³)', // title: 'PM2.5(μg/m³)',
dataIndex: 'point', // dataIndex: 'point',
}, // },
{ // {
title: 'TVOC(mg/m³)', // title: 'TVOC(mg/m³)',
dataIndex: 'date', // dataIndex: 'date',
}, // },
{ // {
title: 'TVOC(mg/m³)', // title: 'TVOC(mg/m³)',
dataIndex: '光照度(lux)', // dataIndex: '光照度(lux)',
}, // },
]; ];

207
hx-ai-intelligent/src/view/monitor/environmentMonitor/averageData/index.vue

@ -1,7 +1,12 @@
<!-- eslint-disable vue/v-on-event-hyphenation --> <!-- eslint-disable vue/v-on-event-hyphenation -->
<template> <template>
<div> <div>
<a-table :columns="tableColumns" :data-source="data" bordered :pagination="false"> <a-table
:columns="tableColumns"
:data-source="pageData"
bordered
:pagination="false"
:scroll="{ x: 100, y: 450 }">
<template #title> <template #title>
<div <div
style="display: flex; align-items: center; justify-content: space-between; width: 100%"> style="display: flex; align-items: center; justify-content: space-between; width: 100%">
@ -12,8 +17,10 @@
v-model:value="frequencyValue" v-model:value="frequencyValue"
placeholder="请选择频率" placeholder="请选择频率"
style="width: 17%; margin-left: 10px" style="width: 17%; margin-left: 10px"
:options="frequencyOptions" /> :options="frequencyOptions"
@change="changeFrequency" />
<!-- <a-date-picker style="width: 13%; margin-left: 10px" v-model:value="timeValue" /> --> <!-- <a-date-picker style="width: 13%; margin-left: 10px" v-model:value="timeValue" /> -->
<!-- :picker="dateTypeValue" -->
<a-range-picker <a-range-picker
:value="hackValue || dateRange" :value="hackValue || dateRange"
:disabled-date="disabledDate" :disabled-date="disabledDate"
@ -22,7 +29,9 @@
@calendarChange="onCalendarChange" @calendarChange="onCalendarChange"
style="width: 17%; margin-left: 10px" style="width: 17%; margin-left: 10px"
:placeholder="['请选择日期', '请选择日期']" /> :placeholder="['请选择日期', '请选择日期']" />
<a-button type="primary" style="margin-left: 10px" @click="getSelect"> 查询 </a-button> <a-button type="primary" style="margin-left: 10px" @click="getTableList">
查询
</a-button>
</div> </div>
<a-button type="primary"> 导出 </a-button> <a-button type="primary"> 导出 </a-button>
</div> </div>
@ -42,11 +51,15 @@
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
// import { http } from '/nerv-lib/util/http'; // import { http } from '/nerv-lib/util/http';
import { Pagination, SelectProps, TreeSelectProps, TableColumnType } from 'ant-design-vue'; import { Pagination, SelectProps, TreeSelectProps, TableColumnType } from 'ant-design-vue';
import { tableColumns } from './config'; import { tableColumns as tableColumnsA } from './config';
import type { Dayjs } from 'dayjs'; import type { Dayjs } from 'dayjs';
import dayjs from 'dayjs';
import { http } from '/nerv-lib/util';
import { dict, getEnum } from '/@/api';
import { environmentMonitor } from '/@/api/monitor';
// import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary'; // import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary';
defineOptions({ defineOptions({
energyType: 'AverageData', // name name: 'AverageData', // name
components: { components: {
'a-pagination': Pagination, 'a-pagination': Pagination,
}, },
@ -61,7 +74,8 @@
const treeData2 = ref<TreeSelectProps['treeData']>([]); const treeData2 = ref<TreeSelectProps['treeData']>([]);
const data = ref([]); const data = ref([]);
// let tableColumns = ref<TableColumnType[]>([]); const pageData = ref([]);
let tableColumns = ref<TableColumnType[]>([]);
const total = ref<number>(); const total = ref<number>();
const queryParams = ref({ const queryParams = ref({
@ -75,10 +89,17 @@
type RangeValue = [Dayjs, Dayjs]; type RangeValue = [Dayjs, Dayjs];
const dates = ref<RangeValue>(); const dates = ref<RangeValue>();
const hackValue = ref<RangeValue>(); const hackValue = ref<RangeValue>();
const dateRange = ref<[Dayjs, Dayjs] | undefined>(); const dateRange = ref<[Dayjs, Dayjs] | undefined>([dayjs(), dayjs()]);
// const dateTypeValue = ref<string | undefined>('year');
const startDate = ref<String>();
const endDate = ref<String>();
const onChangeDate = (val: RangeValue) => { const onChangeDate = (val: RangeValue, dateStrings: any) => {
dateRange.value = val; dateRange.value = val;
if (dateStrings && dateStrings.length === 2) {
startDate.value = dateStrings[0];
endDate.value = dateStrings[1];
}
}; };
const onOpenChange = (open: boolean) => { const onOpenChange = (open: boolean) => {
if (open) { if (open) {
@ -89,46 +110,122 @@
} }
}; };
const disabledDate = (current: Dayjs) => { const disabledDate = (current: Dayjs) => {
if (!dates.value || (dates.value as any).length === 0) { if (frequencyValue.value == '1' || frequencyValue.value == '2') {
return false; if (!dates.value || (dates.value as any).length === 0) {
return false;
}
const tooLate = dates.value[0] && current.diff(dates.value[0], 'days') > 6;
const tooEarly = dates.value[1] && dates.value[1].diff(current, 'days') > 6;
return tooEarly || tooLate;
} }
const tooLate = dates.value[0] && current.diff(dates.value[0], 'days') > 2;
const tooEarly = dates.value[1] && dates.value[1].diff(current, 'days') > 2;
return tooEarly || tooLate;
}; };
const onCalendarChange = (val: RangeValue) => { const onCalendarChange = (val: RangeValue) => {
dates.value = val; dates.value = val;
}; };
//
const changeFrequency = () => {
//
// if (frequencyValue.value == '0' || frequencyValue.value == '1' || frequencyValue.value == '2') {
// dateTypeValue.value = 'date';
// } else if (frequencyValue.value == '3') {
// dateTypeValue.value = 'month';
// } else if (frequencyValue.value == '4') {
// dateTypeValue.value = 'year';
// }
dateRange.value = undefined;
};
// //
const getTableList = () => { const getTableList = () => {
// fetch(energyConsumption.pageList, queryParams.value).then((res) => { //
// data.value = res.data.records; if (!startDate.value || !endDate.value) {
// total.value = res.data.total; const nowDate = new Date();
// }); let nowDateString = nowDate.toISOString().split('T')[0];
const [year, month, day] = nowDateString.split('-').map(Number);
if (frequencyValue.value == '3') {
startDate.value = year + '-' + month;
endDate.value = year + '-' + month;
} else if (frequencyValue.value == '4') {
startDate.value = year + '';
endDate.value = year + '';
}
}
let startTime = '';
let endTime = '';
if (frequencyValue.value == '3') {
startTime = startDate.value + '-01';
const [year, month] = endDate.value.split('-').map(Number);
//
const date = new Date(year, month, 1);
//
// date.setDate(date.getDate() - 1);
endTime = date.toISOString().split('T')[0];
// endTime = endDate.value + '-01';
} else if (frequencyValue.value == '4') {
startTime = startDate.value + '-01-01';
endTime = endDate.value + '-12-31';
} else {
startTime = startDate.value + '';
endTime = endDate.value + '';
}
http
.post(environmentMonitor.getDeviceAveragesByRate, {
orgId: orgId.value,
startTime: startTime, //
endTime: endTime, //
timeRate: frequencyValue.value, //
})
.then((res) => {
//
let headerList = res.data.headerList;
let tableColumnsB = [];
for (let i = 0; i < headerList.length; i++) {
tableColumnsB.push({
title: headerList[i],
dataIndex: headerList[i],
});
}
let columnA: any[] = [...tableColumnsA];
columnA.push(...tableColumnsB);
tableColumns.value = columnA;
//
data.value = res.data.data;
total.value = res.data.data.length;
onChange(1, 10);
});
}; };
onMounted(() => { onMounted(async () => {
frequencyOptions.value = [ //
{ let frequency = await getEnum({ params: { enumType: 'TimeFlagEnum' } });
value: '1', frequencyOptions.value = frequency.data;
label: '30分钟', if (frequencyOptions.value && frequencyOptions.value.length > 0) {
}, frequencyValue.value = frequencyOptions.value[frequencyOptions.value.length - 1].value;
{ }
value: '2', // frequencyOptions.value = [
label: '小时', // {
}, // value: '1',
{ // label: '30',
value: '3', // },
label: '天', // {
}, // value: '2',
{ // label: '',
value: '4', // },
label: '月', // {
}, // value: '3',
{ // label: '',
value: '5', // },
label: '年', // {
}, // value: '4',
]; // label: '',
// },
// {
// value: '5',
// label: '',
// },
// ];
typeList.value = [ typeList.value = [
{ {
id: 1, id: 1,
@ -203,35 +300,19 @@
], ],
}, },
]; ];
// let tableColumnsB = [ getTableList();
// {
// title: '1:00',
// dataIndex: '1:00',
// },
// {
// title: '2:00',
// dataIndex: '2:00',
// },
// {
// title: '3:00',
// dataIndex: '3:00',
// },
// {
// title: '4:00',
// dataIndex: '4:00',
// },
// ];
// let columnA: any[] = [...tableColumnsA];
// columnA.push(...tableColumnsB);
// tableColumns.value = columnA;
}); });
getTableList(); // getTableList();
// //
const onChange = (pageNumber: number, size: number) => { const onChange = (pageNumber: number, size: number) => {
queryParams.value.pageNum = pageNumber; queryParams.value.pageNum = pageNumber;
queryParams.value.pageSize = size; queryParams.value.pageSize = size;
getTableList();
const start = (pageNumber - 1) * size;
const end = start + size;
pageData.value = data.value.slice(start, end);
// getTableList();
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">

12
hx-ai-intelligent/src/view/monitor/environmentMonitor/historyData/config.ts

@ -7,14 +7,14 @@ export const tableColumns = [
}, },
{ {
title: '区域名称', title: '区域名称',
dataIndex: 'areaName', dataIndex: 'location',
}, },
{ {
title: '点位', title: '点位',
dataIndex: 'point', dataIndex: 'pointName',
},
{
title: '日期',
dataIndex: 'date',
}, },
// {
// title: '日期',
// dataIndex: 'date',
// },
]; ];

467
hx-ai-intelligent/src/view/monitor/environmentMonitor/historyData/index.vue

@ -3,7 +3,7 @@
<div> <div>
<a-table <a-table
:columns="tableColumns" :columns="tableColumns"
:data-source="data" :data-source="pageData"
bordered bordered
:pagination="false" :pagination="false"
:scroll="{ x: 100 }"> :scroll="{ x: 100 }">
@ -15,12 +15,17 @@
<a-select <a-select
v-model:value="typeValue" v-model:value="typeValue"
placeholder="请选择环境参数" placeholder="请选择环境参数"
style="width: 15%" style="width: 17%"
:options="typeList" /> :options="typeList" />
<a-tree-select <a-tree-select
v-model:value="quyuvalue" v-model:value="quyuvalue"
style="width: 15%; margin-left: 10px" style="width: 17%; margin-left: 10px"
:tree-data="treeData2" :tree-data="treeData2"
:field-names="{
children: 'childList',
label: 'name',
value: 'id',
}"
tree-checkable tree-checkable
allow-clear allow-clear
placeholder="请选择区域" placeholder="请选择区域"
@ -29,23 +34,45 @@
<a-select <a-select
v-model:value="frequencyValue" v-model:value="frequencyValue"
placeholder="请选择采集频率" placeholder="请选择采集频率"
style="width: 17%; margin-left: 10px"
:options="frequencyOptions"
@change="changeFrequency" />
<!-- <a-date-picker
:picker="dateTypeValue"
style="width: 15%; margin-left: 10px" style="width: 15%; margin-left: 10px"
:options="frequencyOptions" /> v-model:value="timeValue" /> -->
<a-date-picker style="width: 15%; margin-left: 10px" v-model:value="timeValue" />
<a-button type="primary" style="margin-left: 10px" @click="getSelect"> 查询 </a-button> <!-- :picker="dateTypeValue" -->
<a-range-picker
:value="dateRange"
:disabled-date="disabledDate"
@change="onChangeDate"
@openChange="onOpenChange"
@calendarChange="onCalendarChange"
style="width: 17%; margin-left: 10px"
:placeholder="['请选择日期', '请选择日期']" />
<a-button type="primary" style="margin-left: 10px" @click="getTableList">
查询
</a-button>
</div> </div>
<a-button type="primary"> 导出 </a-button> <a-button type="primary"> 导出 </a-button>
</div> </div>
</template> </template>
</a-table> </a-table>
<a-pagination <!-- <a-pagination
:current="queryParams.pageNum" :current="queryParams.pageNum"
:total="total" :total="total"
:page-size="queryParams.pageSize" :page-size="queryParams.pageSize"
style="display: flex; justify-content: center; margin-top: 16px" style="display: flex; justify-content: center; margin-top: 16px"
:show-size-changer="true" :show-size-changer="true"
:show-quick-jumper="true" :show-quick-jumper="true"
@change="onChange" /> @change="onChange" /> -->
<a-pagination
:total="total"
show-size-changer
show-quick-jumper
@change="onChange"
style="display: flex; justify-content: center; margin-top: 10px" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -53,10 +80,14 @@
// import { http } from '/nerv-lib/util/http'; // import { http } from '/nerv-lib/util/http';
import { Pagination, SelectProps, TreeSelectProps, TableColumnType } from 'ant-design-vue'; import { Pagination, SelectProps, TreeSelectProps, TableColumnType } from 'ant-design-vue';
import { tableColumns as tableColumnsA } from './config'; import { tableColumns as tableColumnsA } from './config';
import { environmentMonitor } from '/@/api/monitor';
import { http } from '/nerv-lib/util';
import { dict, getEnum } from '/@/api';
import type { Dayjs } from 'dayjs'; import type { Dayjs } from 'dayjs';
import dayjs from 'dayjs';
// import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary'; // import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary';
defineOptions({ defineOptions({
energyType: 'HistoryData', // name name: 'HistoryData', // name
components: { components: {
'a-pagination': Pagination, 'a-pagination': Pagination,
}, },
@ -66,13 +97,16 @@
const quyuvalue = ref<string[]>([]); const quyuvalue = ref<string[]>([]);
// //
const frequencyValue = ref<string | undefined>(); const frequencyValue = ref<string | undefined>();
// const dateTypeValue = ref<string | undefined>('year');
// list // list
const frequencyOptions = ref<SelectProps['options']>([]); const frequencyOptions = ref<SelectProps['options']>([]);
const treeData2 = ref<TreeSelectProps['treeData']>([]); const treeData2 = ref<TreeSelectProps['treeData']>([]);
const data = ref([]); const data = ref([]);
const timeValue = ref<Dayjs>(); const pageData = ref([]);
// const timeValue = ref<Dayjs>();
let tableColumns = ref<TableColumnType[]>([]); let tableColumns = ref<TableColumnType[]>([]);
const total = ref<number>(); const total = ref<number>();
@ -92,139 +126,308 @@
// queryParams.value.year = selectYear.value.format('YYYY'); // queryParams.value.year = selectYear.value.format('YYYY');
// getTableList(); // getTableList();
// }; // };
type RangeValue = [Dayjs, Dayjs];
const dates = ref<RangeValue>();
const startDate = ref<String>();
const endDate = ref<String>();
const dateRange = ref<[Dayjs, Dayjs] | undefined>([dayjs(), dayjs()]);
const onChangeDate = (val: RangeValue, dateStrings: any) => {
dateRange.value = val;
if (dateStrings && dateStrings.length === 2) {
startDate.value = dateStrings[0];
endDate.value = dateStrings[1];
}
};
const onOpenChange = (open: boolean) => {
if (open) {
dates.value = [] as any;
}
};
const disabledDate = (current: Dayjs) => {
if (frequencyValue.value == '0' || frequencyValue.value == '1') {
if (!dates.value || (dates.value as any).length === 0) {
return false;
}
const tooLate = dates.value[0] && current.diff(dates.value[0], 'days') > 6;
const tooEarly = dates.value[1] && dates.value[1].diff(current, 'days') > 6;
return tooEarly || tooLate;
}
};
const onCalendarChange = (val: RangeValue) => {
dates.value = val;
};
//
const changeFrequency = () => {
//
// if (frequencyValue.value == '0' || frequencyValue.value == '1' || frequencyValue.value == '2') {
// dateTypeValue.value = 'date';
// } else if (frequencyValue.value == '3') {
// dateTypeValue.value = 'month';
// } else if (frequencyValue.value == '4') {
// dateTypeValue.value = 'year';
// }
dateRange.value = undefined;
};
// //
const getTableList = () => { const getTableList = () => {
// fetch(energyConsumption.pageList, queryParams.value).then((res) => { // fetch(energyConsumption.pageList, queryParams.value).then((res) => {
// data.value = res.data.records; // data.value = res.data.records;
// total.value = res.data.total; // total.value = res.data.total;
// }); // });
let environmentType = '';
for (let i = 0; i < typeList.value.length; i++) {
if (typeList.value[i].value == typeValue.value) {
environmentType = typeList.value[i].code;
break;
}
}
//
if (!startDate.value || !endDate.value) {
const nowDate = new Date();
let nowDateString = nowDate.toISOString().split('T')[0];
const [year, month, day] = nowDateString.split('-').map(Number);
if (frequencyValue.value == '3') {
startDate.value = year + '-' + month;
endDate.value = year + '-' + month;
} else if (frequencyValue.value == '4') {
startDate.value = year + '';
endDate.value = year + '';
}
}
let startTime = '';
let endTime = '';
if (frequencyValue.value == '3') {
startTime = startDate.value + '-01';
const [year, month] = endDate.value.split('-').map(Number);
//
const date = new Date(year, month, 1);
//
// date.setDate(date.getDate() - 1);
endTime = date.toISOString().split('T')[0];
// endTime = endDate.value + '-01';
} else if (frequencyValue.value == '4') {
startTime = startDate.value + '-01-01';
endTime = endDate.value + '-12-31';
} else {
startTime = startDate.value + '';
endTime = endDate.value + '';
}
http
.post(environmentMonitor.getDeviceHistory, {
orgId: orgId.value,
environmentType: environmentType, // code
location: quyuvalue.value, // idname
startTime: startTime, //
endTime: endTime, //
timeRate: frequencyValue.value, //
})
.then((res) => {
//
let headerList = res.data.headerList;
let tableColumnsB = [];
for (let i = 0; i < headerList.length; i++) {
tableColumnsB.push({
title: headerList[i],
dataIndex: headerList[i],
});
}
// let tableColumnsB = [
// {
// title: '1:00',
// dataIndex: '1:00',
// },
// {
// title: '2:00',
// dataIndex: '2:00',
// },
// {
// title: '3:00',
// dataIndex: '3:00',
// },
// {
// title: '4:00',
// dataIndex: '4:00',
// },
// ];
let columnA: any[] = [...tableColumnsA];
columnA.push(...tableColumnsB);
tableColumns.value = columnA;
//
data.value = res.data.data;
total.value = res.data.data.length;
onChange(1, 10);
});
};
//
const queryDeviceArea = () => {
http
.get(environmentMonitor.queryDeviceArea, { orgId: orgId.value, point: typeValue.value })
.then((res) => {
treeData2.value = res.data;
if (treeData2.value && treeData2.value.length > 0) {
quyuvalue.value = [treeData2.value[0].childList[0].id];
}
});
}; };
onMounted(() => { onMounted(async () => {
frequencyOptions.value = [ //
{ let frequency = await getEnum({ params: { enumType: 'TimeFlagEnum' } });
value: '1', frequencyOptions.value = frequency.data;
label: '5分钟', if (frequencyOptions.value && frequencyOptions.value.length > 0) {
}, frequencyValue.value = frequencyOptions.value[frequencyOptions.value.length - 1].value;
{ }
value: '2', //
label: '10分钟', let typeData = await getEnum({ params: { enumType: 'EnvironmentTypeEnum' } });
}, typeData.data.forEach((item: any) => {
{ item.code = item.value;
value: '3', item.value = item.flag;
label: '30分钟', });
}, typeList.value = typeData.data;
{ if (typeList.value && typeList.value.length > 0) {
value: '4', typeValue.value = typeList.value[0].value;
label: '1小时', }
}, //
{ await queryDeviceArea();
value: '5',
label: '天', // frequencyOptions.value = [
}, // {
]; // value: '1',
typeList.value = [ // label: '30',
{ // },
id: 1, // {
value: '温度', // value: '2',
}, // label: '',
{ // },
id: 2, // {
value: 'CO2浓度', // value: '3',
}, // label: '',
{ // },
id: 3, // {
value: 'PM2.5', // value: '4',
}, // label: '',
{ // },
id: 4, // {
value: '光照度', // value: '5',
}, // label: '',
{ // },
id: 5, // ];
value: 'TVOC', // typeList.value = [
}, // {
{ // id: 1,
id: 6, // value: '',
value: '湿度', // },
}, // {
]; // id: 2,
treeData2.value = [ // value: 'CO2',
{ // },
label: '办公区', // {
value: '0-0', // id: 3,
children: [ // value: 'PM2.5',
{ // },
label: '办公一区', // {
value: '0-0-0', // id: 4,
}, // value: '',
{ // },
label: '办公二区', // {
value: '0-0-1', // id: 5,
}, // value: 'TVOC',
{ // },
label: '办公三区', // {
value: '0-0-2', // id: 6,
}, // value: '湿',
{ // },
label: '办公四区', // ];
value: '0-0-3', // treeData2.value = [
}, // {
], // label: '',
}, // value: '0-0',
{ // children: [
label: '站厅', // {
value: '0-1', // label: '',
// value: '0-0-0',
children: [ // },
{ // {
label: '站厅一区', // label: '',
value: '0-1-0', // value: '0-0-1',
// disabled: true, // },
}, // {
{ // label: '',
label: '站厅二区', // value: '0-0-2',
value: '0-1-1', // },
}, // {
{ // label: '',
label: '站厅三区', // value: '0-0-3',
value: '0-1-2', // },
}, // ],
{ // },
label: '站厅四区', // {
value: '0-1-3', // label: '',
}, // value: '0-1',
],
}, // children: [
]; // {
let tableColumnsB = [ // label: '',
{ // value: '0-1-0',
title: '1:00', // // disabled: true,
dataIndex: '1:00', // },
}, // {
{ // label: '',
title: '2:00', // value: '0-1-1',
dataIndex: '2:00', // },
}, // {
{ // label: '',
title: '3:00', // value: '0-1-2',
dataIndex: '3:00', // },
}, // {
{ // label: '',
title: '4:00', // value: '0-1-3',
dataIndex: '4:00', // },
}, // ],
]; // },
let columnA: any[] = [...tableColumnsA]; // ];
columnA.push(...tableColumnsB); // let tableColumnsB = [
tableColumns.value = columnA; // {
// title: '1:00',
// dataIndex: '1:00',
// },
// {
// title: '2:00',
// dataIndex: '2:00',
// },
// {
// title: '3:00',
// dataIndex: '3:00',
// },
// {
// title: '4:00',
// dataIndex: '4:00',
// },
// ];
// let columnA: any[] = [...tableColumnsA];
// columnA.push(...tableColumnsB);
// tableColumns.value = columnA;
await getTableList();
}); });
getTableList(); // getTableList();
// //
const onChange = (pageNumber: number, size: number) => { const onChange = (pageNumber: number, size: number) => {
queryParams.value.pageNum = pageNumber; // queryParams.value.pageNum = pageNumber;
queryParams.value.pageSize = size; // queryParams.value.pageSize = size;
getTableList(); // data.value;
// debugger;
const start = (pageNumber - 1) * size;
const end = start + size;
pageData.value = data.value.slice(start, end);
// getTableList();
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">

441
hx-ai-intelligent/src/view/monitor/environmentMonitor/index.vue

@ -1,26 +1,447 @@
<template> <template>
<a-tabs v-model:activeKey="activeKey" style="height: 5%"> <div style="background: #f2f6fd; width: 100%; height: 100%">
<a-tab-pane key="1" tab="综合数据" /> <div style="display: flex">
<a-tab-pane key="2" tab="历史数据" force-render /> <a-tabs v-model:activeKey="activeKey" style="height: 5%; width: 100%; background: #ffffff">
<a-tab-pane key="3" tab="平均数据" /> <a-tab-pane key="1" tab="综合数据" />
</a-tabs> <a-tab-pane key="2" tab="历史数据" force-render />
<a-tab-pane key="3" tab="平均数据" />
<aggregate-data ref="aggregateDataRef" v-if="activeKey == '1'" style="height: 85%" /> </a-tabs>
<history-data v-if="activeKey == '2'" /> <a-button
<average-data v-if="activeKey == '3'" /> type="primary"
style="position: absolute; margin-right: 30px; margin-top: 10px; right: 30px"
@click="configurePoint">
配置监测点位
</a-button>
</div>
<aggregate-data ref="aggregateDataRef" v-if="activeKey == '1'" style="height: 85%" />
<history-data ref="historyDataRef" v-if="activeKey == '2'" />
<average-data ref="averageDataRef" v-if="activeKey == '3'" />
</div>
<a-modal
:visible="openModal"
title="配置监测点位"
style="width: 65%"
@ok="handleOk"
@cancel="closeOpenUpload">
<div style="display: flex">
<div style="width: 15%">
<a-tabs
v-model:activeKey="typeValue"
tab-position="left"
@tabScroll="callback"
@change="queryDeviceArea">
<a-tab-pane v-for="item in typeList" :key="item.value" :tab="item.label" />
</a-tabs>
</div>
<div style="width: 85%; height: 100%">
<a-table
:columns="tableColumns"
:data-source="data"
bordered
:pagination="false"
rowKey="deviceInfoCode"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
<template #bodyCell="{ text, column, record }">
<template v-if="column.dataIndex === 'useFlag'">
<a-switch
:checked="text"
:checked-value="1"
:unCheckedValue="0"
@change="(checked) => updateShowed(record)" />
</template>
</template>
<template #title>
<div
style="
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
">
<div style="display: flex; align-items: center; width: 85%">
<div style="width: 10%">数据列表</div>
<!-- <a-select
v-model:value="typeValue"
placeholder="请选择环境参数"
style="width: 15%"
:options="typeList" /> -->
<!-- <a-tree-select
v-model:value="quyuvalue"
style="width: 35%; margin-left: 10px"
:tree-data="treeData2"
:field-names="{
children: 'childList',
label: 'name',
value: 'id',
}"
tree-checkable
allow-clear
placeholder="请选择区域"
tree-node-filter-prop="label"
:maxTagCount="1" /> -->
<a-cascader
:options="treeData2"
v-model:value="quyuvalue"
placeholder="请选择所属区域"
:field-names="{
children: 'childList',
label: 'name',
value: 'id',
}"
multiple
max-tag-count="responsive" />
<a-select
v-model:value="useFlag"
placeholder="请选择监测状态"
style="width: 20%; margin-left: 1%"
:options="useFlagList" />
<a-input
v-model:value="areaName"
placeholder="请输入设备名称"
style="width: 20%; margin-left: 1%" />
<!-- <a-select
v-model:value="frequencyValue"
placeholder="请选择采集频率"
style="width: 15%; margin-left: 10px"
:options="frequencyOptions" /> -->
<!-- <a-date-picker style="width: 15%; margin-left: 10px" v-model:value="timeValue" /> -->
<a-button style="margin-left: 10px" @click="resetting"> 重置 </a-button>
<a-button type="primary" style="margin-left: 10px" @click="queryDeviceInfoListPage">
搜索
</a-button>
</div>
<!-- <a-button type="primary"> 导出 </a-button> -->
</div>
<div>
<a-divider />
<a-button
type="primary"
size="small"
@click="startOrEnd(true)"
:disabled="selectedRowKeys.length == 0">
批量开启
</a-button>
<a-button
type="primary"
size="small"
style="margin-left: 10px"
@click="startOrEnd(false)"
:disabled="selectedRowKeys.length == 0">
批量关闭
</a-button>
</div>
</template>
</a-table>
<a-pagination
:current="queryParams.pageNum"
:total="total"
:page-size="queryParams.pageSize"
style="display: flex; justify-content: center; margin-top: 16px"
:show-size-changer="true"
:show-quick-jumper="true"
@change="onChange" />
</div>
</div>
</a-modal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref, onMounted } from 'vue';
import aggregateData from './aggregateData/index.vue'; import aggregateData from './aggregateData/index.vue';
import historyData from './historyData/index.vue'; import historyData from './historyData/index.vue';
import averageData from './averageData/index.vue'; import averageData from './averageData/index.vue';
import { Pagination, TabsProps, TableColumnType, TreeSelectProps } from 'ant-design-vue';
import { environmentMonitor } from '/@/api/monitor';
import { http } from '/nerv-lib/util';
import { dict, getEnum } from '/@/api';
const total = ref<number>();
const queryParams = ref({
pageNum: 1,
pageSize: 10,
});
const aggregateDataRef = ref(); const aggregateDataRef = ref();
const historyDataRef = ref();
const averageDataRef = ref();
var activeKey = ref('1'); var activeKey = ref('1');
var typeValue = ref();
const openModal = ref<boolean>(false);
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
defineOptions({ defineOptions({
name: 'EnvironmentMonitorIndex', // name name: 'EnvironmentMonitorIndex', // name
components: {
'a-pagination': Pagination,
},
});
const typeList = ref();
const quyuvalue = ref<string[]>([]);
const useFlag = ref<Number>();
const useFlagList = ref();
useFlagList.value = [
{
value: 0,
label: '关闭',
},
{
value: 1,
label: '开启',
},
];
const areaName = ref<string>();
let tableColumns = ref<TableColumnType[]>([]);
const treeData2 = ref<TreeSelectProps['treeData']>([]);
const data = ref();
const selectedRowKeys = ref([]);
const onSelectChange = (selectedRowKey: string | number[]) => {
console.log('selectedRowKeys changed: ', selectedRowKey);
selectedRowKeys.value = selectedRowKey;
};
//
const onChange = (pageNumber: number, size: number) => {
queryParams.value.pageNum = pageNumber;
queryParams.value.pageSize = size;
// getTableList();
};
const configurePoint = () => {
openModal.value = true;
};
//
const handleOk = (e: MouseEvent) => {
console.log(e);
openModal.value = false;
};
//
const closeOpenUpload = () => {
openModal.value = false;
};
const callback: TabsProps['onTabScroll'] = (val) => {
console.log(val);
};
//
const resetting = () => {
quyuvalue.value = [];
areaName.value = '';
};
//
const updateShowed = (record: any) => {
debugger;
let url = '';
if (record.useFlag == 0) {
record.useFlag = 1;
url = environmentMonitor.startUpDevice;
} else {
record.useFlag = 0;
url = environmentMonitor.stopDevice;
}
let params = [
{
orgId: orgId.value,
code: typeValue.value, // flag
deviceInfoCode: record.deviceInfoCode,
},
];
http.post(url, params).then((res) => {
debugger;
});
};
//
const startOrEnd = (flag: Boolean) => {
let url = '';
if (flag) {
url = environmentMonitor.startUpDevice;
} else {
url = environmentMonitor.stopDevice;
}
let params = [];
for (let i = 0; i < selectedRowKeys.value.length; i++) {
params.push({
orgId: orgId.value,
code: typeValue.value, // flag
deviceInfoCode: selectedRowKeys.value[i],
});
}
// let params = [
// {
// orgId: orgId.value,
// code: typeValue.value, // flag
// deviceInfoCode: record.deviceInfoCode,
// },
// ];
http.post(url, params).then((res) => {
selectedRowKeys.value = [];
queryDeviceInfoListPage();
});
};
const queryDeviceInfoListPage = () => {
http
.post(environmentMonitor.queryDeviceInfoListPage, {
orgId: orgId.value,
pointCode: typeValue.value, //flag
pageNum: queryParams.value.pageNum,
pageSize: queryParams.value.pageSize,
deviceName: areaName.value, //
useFlag: useFlag.value, //
area2: quyuvalue.value, //
})
.then((res) => {
total.value = res.data.total;
data.value = res.data.records;
});
};
//
const queryDeviceArea = () => {
http
.get(environmentMonitor.queryDeviceArea, { orgId: orgId.value, point: typeValue.value })
.then((res) => {
treeData2.value = res.data;
// if (treeData2.value && treeData2.value.length > 0) {
// quyuvalue.value = [treeData2.value[0].childList[0].id];
// }
});
};
onMounted(async () => {
//
let typeData = await getEnum({ params: { enumType: 'EnvironmentTypeEnum' } });
typeData.data.forEach((item: any) => {
item.code = item.value;
item.value = item.flag;
});
typeList.value = typeData.data;
if (typeList.value && typeList.value.length > 0) {
typeValue.value = typeList.value[0].value;
await queryDeviceArea();
}
//
//
// typeList.value = [
// {
// id: 1,
// value: '',
// },
// {
// id: 2,
// value: 'CO2',
// },
// {
// id: 3,
// value: 'PM2.5',
// },
// {
// id: 4,
// value: '',
// },
// {
// id: 5,
// value: 'TVOC',
// },
// {
// id: 6,
// value: '湿',
// },
// ];
//
// pointKey.value = typeList.value[0].id;
//
tableColumns.value = [
{
title: '序号',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '设备名称',
dataIndex: 'deviceName',
},
{
title: '设备型号',
dataIndex: 'deviceRatepay',
},
{
title: '设备一级区域',
dataIndex: 'device1Area',
},
{
title: '设备二级区域',
dataIndex: 'device2Area',
},
{
title: '设备详细位置',
dataIndex: 'deviceAddress',
},
{
title: '是否纳入计算',
dataIndex: 'useFlag',
},
];
//
// treeData2.value = [
// {
// label: '',
// value: '0-0',
// children: [
// {
// label: '',
// value: '0-0-0',
// },
// {
// label: '',
// value: '0-0-1',
// },
// {
// label: '',
// value: '0-0-2',
// },
// {
// label: '',
// value: '0-0-3',
// },
// ],
// },
// {
// label: '',
// value: '0-1',
// children: [
// {
// label: '',
// value: '0-1-0',
// // disabled: true,
// },
// {
// label: '',
// value: '0-1-1',
// },
// {
// label: '',
// value: '0-1-2',
// },
// {
// label: '',
// value: '0-1-3',
// },
// ],
// },
// ];
//
// data.value = [
// { areaName: '', showed: '1' },
// { areaName: '', showed: '1' },
// ];
queryDeviceInfoListPage();
}); });
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped></style>

Loading…
Cancel
Save