This commit is contained in:
zhouhuang 2024-11-25 15:05:49 +08:00
commit a47ca1a29b
7 changed files with 197 additions and 135 deletions

View File

@ -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();

View File

@ -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',

View File

@ -17,12 +17,17 @@
/>
<div style="width: 20px"></div>
<div style="width: fit-content; min-width: 60px">{{ t('airBlower.airBlowerNumber') }}</div>
<el-select v-model="airBlowerNumberValue" :placeholder="t('alarm.select') + t('airBlower.airBlowerNumber')" class="alarmSelect">
<el-select
v-model="airBlowerNumberValue"
:placeholder="t('alarm.select') + t('airBlower.airBlowerNumber')"
class="alarmSelect"
clearable
>
<el-option v-for="v in airBlowerList" :key="v.value" :label="v.label" :value="v.value"></el-option>
</el-select>
<div style="width: 20px"></div>
<div style="width: fit-content; min-width: 30px">{{ t('alarm.type') }}</div>
<el-select v-model="alarmTypeValue" :placeholder="t('alarm.select') + t('alarm.type')" class="alarmSelect">
<el-select v-model="alarmTypeValue" :placeholder="t('alarm.select') + t('alarm.type')" class="alarmSelect" clearable>
<el-option v-for="v in alarmTypes" :key="v.value" :label="v.label" :value="v.value"></el-option>
</el-select>
<div style="width: 20px"></div>
@ -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) => {

View File

@ -22,7 +22,7 @@
<div class="small-title">全场实时有功</div>
<div class="small-value">
<span class="content-number">{{realData.attributeMap.windfarmactivepower}}</span>
<span>MW</span>
<span>kW</span>
</div>
</div>
</div>
@ -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<keyof typeof state.charts>
chartKeys.forEach((key) => {
state.charts[key].dispose()
})*/
})
</script>

View File

@ -10,7 +10,7 @@
</div>
</div>
<div class="topRight">
<el-button type="primary" @click="statAnalysisOperate()">{{ t('statAnalysis.search') }}</el-button>
<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>
</el-header>
@ -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,16 +270,48 @@ 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) => {
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) {
const resData = res.data[statAnalysisDeviceId.value.split(':')[2]]
if (resData) {
const iGenPower = resData['iGenPower']['values']
const iWindSpeed = resData['iWindSpeed']['values']
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]
})
@ -313,14 +323,31 @@ const historyDataReq = (data: any) => {
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: '理论值',
smooth: true,
animation: false,
}
option.series.push(series)
option.legend.data.push('理论值')
}
chart.value.setOption(option)
}
} else {
ElMessage.warning('查询失败')
}
})
.catch((error) => {
isLoading.value = false
ElMessage.warning(error)
})
}

View File

@ -30,7 +30,7 @@
</div>
</div>
<div class="topRight">
<el-button type="primary" @click="statAnalysisOperate()">{{ t('statAnalysis.search') }}</el-button>
<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>
</el-header>
@ -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,16 +427,17 @@ 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)
})
}
@ -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')

View File

@ -22,7 +22,7 @@
</div>
</div>
<div class="topRight">
<el-button type="primary" @click="statAnalysisOperate()">{{ t('statAnalysis.search') }}</el-button>
<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>
</el-header>
@ -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,12 +323,21 @@ 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) => {
historyReq(data)
.then((res) => {
isLoading.value = false
if (res.code == 200) {
const resData = res.data
const deviceIdKeys = Object.keys(resData)
@ -342,12 +351,17 @@ const historyDataReq = (data: any) => {
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[dataIndex] = calculateStats(yData)
calculate.value[dataIndex] = calculateStats(yData)
option.tooltip = {
show: true,
trigger: 'axis',
@ -367,9 +381,15 @@ const historyDataReq = (data: any) => {
})
}
} else {
isLoading.value = false
ElMessage.warning('查询失败')
}
})
.catch((error) => {
isLoading.value = false
console.error(error)
ElMessage.warning(error)
})
}
const findAllOccurrences = (arr: any, target: any) => {