diff --git a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java index 7d9bb92d..f0213747 100644 --- a/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java +++ b/das/src/main/java/com/das/modules/equipment/service/impl/SysEquipmentServiceImpl.java @@ -96,6 +96,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { SysEquipment sysEquipment = new SysEquipment(); BeanCopyUtils.copy(sysEquipmentDto, sysEquipment); SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); + SysEquipment oldModelSysEquipInfo = sysEquipmentMapper.selectById(sysEquipmentDto.getId()); SysEquipmentVo oldSysEquipment = sysEquipmentMapper.queryEquipmentInfoByCode(sysEquipmentDto.getCode()); // 判断设备编码是否存在 if (sysEquipmentMapper.queryEquipmentByCode(sysEquipment.getCode()) > 0) { @@ -106,7 +107,8 @@ public class SysEquipmentServiceImpl implements SysEquipmentService { sysEquipment.setUpdatedTime(new Date()); sysEquipment.setUpdatedBy(sysUserVo.getAccount()); sysEquipmentMapper.updateById(sysEquipment); - if (oldSysEquipment.getIotModelId() == null && sysEquipment.getIotModelId() != null){ + + if (oldModelSysEquipInfo.getIotModelId() == null && sysEquipment.getIotModelId() != null){ dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString())); } SysEquipmentVo sysEquipmentVo = new SysEquipmentVo(); diff --git a/ui/dasadmin/src/api/backend/statAnalysis/request.ts b/ui/dasadmin/src/api/backend/statAnalysis/request.ts index c615dfd7..42abf4c3 100644 --- a/ui/dasadmin/src/api/backend/statAnalysis/request.ts +++ b/ui/dasadmin/src/api/backend/statAnalysis/request.ts @@ -7,14 +7,7 @@ export const queryWindTurbinesPages = () => { }) } -export const historyReq = (data: { - devices: { - deviceId: string - attributes: string - } - startTime: string - endTime: string -}) => { +export const historyReq = (data: any) => { return createAxios({ url: '/api/data/history', method: 'post', diff --git a/ui/dasadmin/src/views/backend/alarms/index.vue b/ui/dasadmin/src/views/backend/alarms/index.vue index 8c46d056..82c73284 100644 --- a/ui/dasadmin/src/views/backend/alarms/index.vue +++ b/ui/dasadmin/src/views/backend/alarms/index.vue @@ -17,12 +17,17 @@ />
{{ t('airBlower.airBlowerNumber') }}
- +
{{ t('alarm.type') }}
- +
@@ -153,7 +158,7 @@ const searchalarms = (): GetAlarmsTableParam => { const start = timeRange.value[0] const end = timeRange.value[1] const deviceCode: any = [] - if (airBlowerNumberValue.value.length) { + if (airBlowerNumberValue.value && airBlowerNumberValue.value.length) { deviceCode.push(airBlowerNumberValue.value) } else { airBlowerList.value.forEach((item: any) => { diff --git a/ui/dasadmin/src/views/backend/dashboard.vue b/ui/dasadmin/src/views/backend/dashboard.vue index 76f8dd94..4741df41 100644 --- a/ui/dasadmin/src/views/backend/dashboard.vue +++ b/ui/dasadmin/src/views/backend/dashboard.vue @@ -22,7 +22,7 @@
全场实时有功
{{realData.attributeMap.windfarmactivepower}} - MW + kW
@@ -349,6 +349,7 @@ const getTableData = (deviceCode) => { limit: 100, eventLevel:2 } + // console.log(JSON.stringify(data)) getAlarmListReq(data).then((res) => { if (res.code == 200) { //tableData.value = res.rows @@ -430,11 +431,7 @@ const createScroll = () => { -const activeName = ref('first') -//let autoUpdateTimer: any = null let autoUpdateForSecondTimer: any = null -let autoUpdateTimerForMinuteTimer: any = null -let autoUpdateTimerForHourTimer: any = null const autoUpdate = () => { if (!autoUpdateForSecondTimer) { autoUpdateForSecondTimer = setInterval(() => { @@ -473,7 +470,7 @@ onMounted(() => { equipList({ objectType: 10002 }).then((res) => { res.data.map((item: any) => { - deviceCode.value.push(item.name) + deviceCode.value.push(item.code) }) getTableData(deviceCode.value) @@ -484,10 +481,6 @@ onUnmounted(() => { window.removeEventListener('resize', sizeChange) clearInterval(timer) autoUpdateForSecondTimer && clearInterval(autoUpdateForSecondTimer) - /*const chartKeys = Object.keys(state.charts) as Array - chartKeys.forEach((key) => { - state.charts[key].dispose() - })*/ }) diff --git a/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue b/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue index 5a2e1c15..dc3052ce 100644 --- a/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue +++ b/ui/dasadmin/src/views/backend/statAnalysis/powerCurveAnalysis.vue @@ -10,7 +10,7 @@
- {{ t('statAnalysis.search') }} + {{ t('statAnalysis.search') }} {{ t('statAnalysis.export') }}
@@ -95,6 +95,7 @@ const option: any = { itemGap: 20, itemWidth: 8, itemHeight: 8, + selectedMode: true, data: [], }, xAxis: { @@ -165,31 +166,6 @@ const queryfactoery = () => { }) } -const querytheoretical = (val: any) => { - const madeinfactory = val.split(':')[0] - const model = val.split(':')[1] - powerCurveQuery(madeinfactory, model).then((res) => { - if (res.code == 200) { - const resData = res.data - if (resData.length) { - const seriesData = resData.map((item: any) => { - return [item.speed, item.power] - }) - const series = { - type: 'line', - data: seriesData, - name: '理论值', - smooth: true, - } - option.series.push(series) - option.legend.data.push('理论值') - chart.value.setOption(option) - } - } else { - ElMessage.warning('查询失败') - } - }) -} const queryWindTurbines = () => { queryWindTurbinesPages().then((res) => { if (res.code == 200) { @@ -276,10 +252,12 @@ const getDateRange = (type: 'week' | 'month') => { } } +const isLoading = ref(false) const statAnalysisOperate = () => { + isLoading.value = true option.series = [] + option.legend.data = [] chart.value.setOption(option, { notMerge: true }) - // chart.value.clear() const requestData = { devices: [ { @@ -292,36 +270,85 @@ const statAnalysisOperate = () => { endTime: new Date(statAnalysisTime.value[1]).getTime(), } const params = statAnalysisFatory.value ? statAnalysisFatory.value : statAnalysisDeviceId.value - querytheoretical(params) - historyDataReq(requestData) -} -const historyDataReq = (data: any) => { - historyReq(data).then((res) => { - if (res.code == 200) { - const resData = res.data[statAnalysisDeviceId.value.split(':')[2]] - if (resData) { - const iGenPower = resData['iGenPower']['values'] - const iWindSpeed = resData['iWindSpeed']['values'] - const seriesData = iGenPower.map((item: any, index: number) => { - return [iWindSpeed[index], item] - }) - seriesData.sort((a: any, b: any) => { - return a[0] - b[0] + const promise1 = new Promise((resolve, reject) => { + const madeinfactory = params.split(':')[0] + const model = params.split(':')[1] + powerCurveQuery(madeinfactory, model) + .then((res) => { + if (res.code == 200) { + resolve(res.data) + } else { + isLoading.value = false + ElMessage.warning('查询失败') + } + }) + .catch((error) => { + resolve(error) + }) + }) + const promise2 = new Promise((resolve, reject) => { + historyReq(requestData) + .then((res) => { + if (res.code == 200) { + resolve(res.data) + } else { + isLoading.value = false + ElMessage.warning('查询失败') + } + }) + .catch((error) => { + resolve(error) + }) + }) + + Promise.all([promise1, promise2]) + .then((results: any) => { + isLoading.value = false + const resData0 = results[1][statAnalysisDeviceId.value.split(':')[2]] + const resData1 = results[0] + if (resData0) { + const iGenPower = resData0['iGenPower']['values'] + const iWindSpeed = resData0['iWindSpeed']['values'] + if (!iWindSpeed.length) { + ElMessage.info(`实时值数据为空`) + } else { + const seriesData = iGenPower.map((item: any, index: number) => { + return [iWindSpeed[index], item] + }) + seriesData.sort((a: any, b: any) => { + return a[0] - b[0] + }) + const series = { + type: 'line', + data: seriesData, + name: '实际值', + smooth: true, + animation: false, + } + option.series.push(series) + option.legend.data.push('实际值') + } + } + if (resData1.length) { + const seriesData = resData1.map((item: any) => { + return [item.speed, item.power] }) const series = { type: 'line', data: seriesData, - name: '实际值', + name: '理论值', smooth: true, + animation: false, } option.series.push(series) - option.legend.data.push('实际值') - chart.value.setOption(option) + option.legend.data.push('理论值') } - } else { - ElMessage.warning('查询失败') - } - }) + chart.value.setOption(option) + }) + .catch((error) => { + isLoading.value = false + ElMessage.warning(error) + }) } const statAnalysisExport = () => { diff --git a/ui/dasadmin/src/views/backend/statAnalysis/trendAnalysis.vue b/ui/dasadmin/src/views/backend/statAnalysis/trendAnalysis.vue index 62bd605d..b9db81f5 100644 --- a/ui/dasadmin/src/views/backend/statAnalysis/trendAnalysis.vue +++ b/ui/dasadmin/src/views/backend/statAnalysis/trendAnalysis.vue @@ -30,7 +30,7 @@
- {{ t('statAnalysis.search') }} + {{ t('statAnalysis.search') }} {{ t('statAnalysis.export') }}
@@ -121,7 +121,7 @@ const addTime = (index: any) => { const switchTime = (index: number) => { times.splice(index, 1) customName.splice(index, 1) - calculate.splice(index, 1) + calculate.value.splice(index, 1) } const timechange = (value: any) => { const count = getTimeIntervals(times[0][0], times[0][1]) @@ -324,7 +324,6 @@ const getTimeIntervals = (startTimestamp: number, endTimestamp: number) => { const startDate: any = new Date(startTimestamp) const endDate: any = new Date(endTimestamp) let count = 0 - switch (statAnalysisSelect.interval) { case 'NONE': count = Math.floor((endDate - startDate) / 1000) @@ -341,19 +340,23 @@ const getTimeIntervals = (startTimestamp: number, endTimestamp: number) => { case '1d': count = Math.floor((endDate - startDate) / (1 * 24 * 60 * 60 * 1000)) break - // default: - // throw new Error('Invalid interval') + default: + count = Math.floor((endDate - startDate) / (5 * 60 * 1000)) } return count } -const calculate: any = reactive([{ max: '', min: '', average: '' }]) +const calculate: any = ref([{ max: '', min: '', average: '' }]) var xDatas: any = [] +const isLoading = ref(false) const statAnalysisOperate = () => { + isLoading.value = true option.series = [] option.legend.data = [] xDatas = [] + calculate.value = [] chart.value.setOption(option, { notMerge: true }) + const promises: any = [] times.forEach((time: any, index: number) => { if (time[0] && time[1]) { const requestData = { @@ -367,21 +370,40 @@ const statAnalysisOperate = () => { startTime: new Date(time[0]).getTime(), endTime: new Date(time[1]).getTime(), } - historyDataReq(requestData, index) + const promise = new Promise((resolve, reject) => { + historyReq(requestData) + .then((res) => { + if (res.code == 200) { + resolve(res.data) + } else { + ElMessage.warning('查询失败') + } + }) + .catch((error) => { + reject(error) + }) + }) + promises.push(promise) } }) + historyDataReq(promises) } -const historyDataReq = (data: any, index: number) => { - historyReq(data).then((res) => { - if (res.code == 200) { +const historyDataReq = (promises: any) => { + Promise.all(promises) + .then((results: any) => { + isLoading.value = false const deviceId = statAnalysisSelect.deviceId const attributeCode = statAnalysisSelect.attributeCode - const resData = (res.data && deviceId in res.data && res.data[deviceId][attributeCode]) || undefined - if (resData) { + results.forEach((res: any, index: number) => { + const resData = (res && deviceId in res && res[deviceId][attributeCode]) || undefined const xData = resData['times'] const yData = resData['values'] - calculate[index] = calculateStats(yData) + if (!yData.length) { + ElMessage.info(`${customName[index]}数据为空`) + return + } + calculate.value[index] = calculateStats(yData) xDatas.push({ series: String(customName[index]), data: xData, @@ -405,17 +427,18 @@ const historyDataReq = (data: any, index: number) => { type: 'line', data: yData, showSymbol: true, + animation: false, } option.legend.data.push(customName[index]) option.series.push(seriesData) chart.value.setOption(option) - } else { - ElMessage.warning('查询失败1') - } - } else { - ElMessage.warning('查询失败') - } - }) + }) + }) + .catch((error) => { + isLoading.value = false + console.error(error) + ElMessage.warning(error) + }) } const statAnalysisExport = () => { @@ -437,7 +460,6 @@ const statAnalysisExport = () => { requestData.push(devices) } }) - console.log(requestData) trendAnalyseExport(requestData).then((res: any) => { const downloadUrl = window.URL.createObjectURL(res) const a = document.createElement('a') diff --git a/ui/dasadmin/src/views/backend/statAnalysis/trendComparison.vue b/ui/dasadmin/src/views/backend/statAnalysis/trendComparison.vue index 992e8ba0..f3e41ac9 100644 --- a/ui/dasadmin/src/views/backend/statAnalysis/trendComparison.vue +++ b/ui/dasadmin/src/views/backend/statAnalysis/trendComparison.vue @@ -22,7 +22,7 @@
- {{ t('statAnalysis.search') }} + {{ t('statAnalysis.search') }} {{ t('statAnalysis.export') }}
@@ -138,7 +138,7 @@ const switchDevice = (index: number) => { statAnalysisAttributes.splice(index, 1) statAnalysisAttributeCode.splice(index, 1) customName.splice(index, 1) - calculate.splice(index, 1) + calculate.value.splice(index, 1) } const isExpand = ref(false) @@ -323,53 +323,73 @@ const getDateRange = (type: 'week' | 'month') => { } } +const isLoading = ref(false) + const statAnalysisOperate = () => { + isLoading.value = true + option.series = [] + option.legend.data = [] + calculate.value = [] + chart.value.setOption(option, { notMerge: true }) historyDataReq(getRequestData()) } -const calculate: any = reactive([{ max: '', min: '', average: '' }]) +const calculate: any = ref([{ max: '', min: '', average: '' }]) const historyDataReq = (data: any) => { - historyReq(data).then((res) => { - if (res.code == 200) { - const resData = res.data - const deviceIdKeys = Object.keys(resData) - const attributeKeys = [] - if (deviceIdKeys.length) { - deviceIdKeys.forEach((item) => { - const indexList1 = findAllOccurrences(statAnalysisDeviceId, item) - Object.keys(resData[item]).forEach((value) => { - const indexList2 = findAllOccurrences(statAnalysisAttributeCode, value) - const dataIndex = getCommonElements(indexList1, indexList2)[0] - const historyData = resData[item][value] - const xData = historyData['times'] - const yData = historyData['values'] - const seriesData = { - name: customName[dataIndex], - type: 'line', - data: yData, - } - calculate[dataIndex] = calculateStats(yData) - option.tooltip = { - show: true, - trigger: 'axis', - formatter: function (params: any) { - return params - .map((item: any) => { - return `${item.marker} ${item.seriesName} (${timestampToTime(xData[item.dataIndex])}): ${item.data}` - }) - .join('
') - }, - } - option.legend.data.push(customName[dataIndex]) - option.xAxis.data = xData.map((item: any) => timestampToTime(item)) - option.series.push(seriesData) - chart.value.setOption(option) + historyReq(data) + .then((res) => { + isLoading.value = false + if (res.code == 200) { + const resData = res.data + const deviceIdKeys = Object.keys(resData) + const attributeKeys = [] + if (deviceIdKeys.length) { + deviceIdKeys.forEach((item) => { + const indexList1 = findAllOccurrences(statAnalysisDeviceId, item) + Object.keys(resData[item]).forEach((value) => { + const indexList2 = findAllOccurrences(statAnalysisAttributeCode, value) + const dataIndex = getCommonElements(indexList1, indexList2)[0] + const historyData = resData[item][value] + const xData = historyData['times'] + const yData = historyData['values'] + if (!yData.length) { + ElMessage.info(`${customName[dataIndex]}数据为空`) + return + } + const seriesData = { + name: customName[dataIndex], + type: 'line', + data: yData, + animation: false, + } + calculate.value[dataIndex] = calculateStats(yData) + option.tooltip = { + show: true, + trigger: 'axis', + formatter: function (params: any) { + return params + .map((item: any) => { + return `${item.marker} ${item.seriesName} (${timestampToTime(xData[item.dataIndex])}): ${item.data}` + }) + .join('
') + }, + } + option.legend.data.push(customName[dataIndex]) + option.xAxis.data = xData.map((item: any) => timestampToTime(item)) + option.series.push(seriesData) + chart.value.setOption(option) + }) }) - }) + } + } else { + isLoading.value = false + ElMessage.warning('查询失败') } - } else { - ElMessage.warning('查询失败') - } - }) + }) + .catch((error) => { + isLoading.value = false + console.error(error) + ElMessage.warning(error) + }) } const findAllOccurrences = (arr: any, target: any) => {