|
|
@ -54,7 +54,7 @@ Page({ |
|
|
|
const res = JSON.stringify(this.data.deviceList) |
|
|
|
const patrolRecord=JSON.stringify(this.data.dataList) |
|
|
|
wx.navigateTo({ |
|
|
|
url: `/package/deviceBigdataGraph/statusDetail/statusDetail?arrayData=${encodeURIComponent(res)}&patrolRecord=${encodeURIComponent(patrolRecord)}`, |
|
|
|
url: `/package/deviceBigdataGraph/statusDetail/statusDetail?arrayData=${encodeURIComponent(res)}`, |
|
|
|
}) |
|
|
|
}, |
|
|
|
navigatorToLifeWarning(e) { |
|
|
@ -72,29 +72,34 @@ Page({ |
|
|
|
that.ecDeviceComponent = that.selectComponent('#mychart-device-pie'); |
|
|
|
const date1 = new Date('1970-01-01 00:00:00'); |
|
|
|
Request.get(getDevices()).then(res => { |
|
|
|
const currentDate = moment(); |
|
|
|
|
|
|
|
let guaranteedRate = 0; |
|
|
|
let warrantyPeriod = 0; |
|
|
|
if (res && res.length) { |
|
|
|
//总的
|
|
|
|
const count = res.length |
|
|
|
//过期的
|
|
|
|
const guaranteedRate = res.filter(item => moment(item.dateGuarantee).isBefore(moment()))?.length || 0 |
|
|
|
//没过期的
|
|
|
|
const warrantyPeriod = res.filter(item => moment(item.dateGuarantee).isAfter(moment()))?.length || 0 |
|
|
|
that.setData({ |
|
|
|
guaranteedRate: Math.round((guaranteedRate / count) * 100), |
|
|
|
warrantyPeriod: Math.round((warrantyPeriod / count) * 100), |
|
|
|
count: res.length, |
|
|
|
deviceList:res |
|
|
|
}) |
|
|
|
const typeGroups = {}; |
|
|
|
res.forEach((item) => { |
|
|
|
res.forEach(item => { |
|
|
|
const itemDate = moment(item.dateGuarantee); |
|
|
|
if (itemDate.isBefore(currentDate)) { |
|
|
|
guaranteedRate++; |
|
|
|
} else { |
|
|
|
warrantyPeriod++; |
|
|
|
} |
|
|
|
// 处理类型分组逻辑
|
|
|
|
const type = item.type; |
|
|
|
// 如果 typeGroups 中没有这个类型的数组,就初始化一个空数组
|
|
|
|
if (!typeGroups[type]) { |
|
|
|
typeGroups[type] = []; |
|
|
|
} |
|
|
|
// 将对象添加到相应类型的数组中
|
|
|
|
typeGroups[type].push(item); |
|
|
|
typeGroups[type].push(item) |
|
|
|
}); |
|
|
|
that.setData({ |
|
|
|
guaranteedRate: Math.round((guaranteedRate / count) * 100), |
|
|
|
warrantyPeriod: Math.round((warrantyPeriod / count) * 100), |
|
|
|
count: res.length, |
|
|
|
deviceList:res |
|
|
|
}) |
|
|
|
// 格式转换成指定格式
|
|
|
|
const result = Object.keys(typeGroups).map((type) => ({ |
|
|
|
name: type, |
|
|
@ -105,18 +110,27 @@ Page({ |
|
|
|
trigger: 'item' |
|
|
|
}, |
|
|
|
backgroundColor: "#ffffff", |
|
|
|
// grid: {
|
|
|
|
// left: 10,
|
|
|
|
// // right: 10,
|
|
|
|
// // bottom: 10,
|
|
|
|
// top: 10,
|
|
|
|
// // containLabel: true,
|
|
|
|
// },
|
|
|
|
legend: { |
|
|
|
bottom: 10, |
|
|
|
left: 'center', |
|
|
|
bottom: 0, |
|
|
|
// left: 'right',
|
|
|
|
}, |
|
|
|
|
|
|
|
series: [{ |
|
|
|
label: { |
|
|
|
normal: { |
|
|
|
fontSize: 14 |
|
|
|
} |
|
|
|
show:false, |
|
|
|
// normal: {
|
|
|
|
// fontSize: 14
|
|
|
|
// }
|
|
|
|
}, |
|
|
|
type: 'pie', |
|
|
|
center: ['50%', '50%'], |
|
|
|
center:['50%','30%'], |
|
|
|
radius: ['20%', '40%'], |
|
|
|
data: result |
|
|
|
|
|
|
@ -130,7 +144,7 @@ Page({ |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
Request.get(getPatrolRecord('all', moment(date1).format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null',{home:false})).then(res => { |
|
|
|
Request.get(getPatrolRecord('all', moment(date1).format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null',{home:true})).then(res => { |
|
|
|
if (res) { |
|
|
|
let normal = 0; |
|
|
|
let abnormal = 0; |
|
|
@ -155,7 +169,7 @@ Page({ |
|
|
|
}); |
|
|
|
//获取设备信息
|
|
|
|
const devices=that.data.deviceList.map(item=>{return {id:item.id,name:item.name,status:'unknown'}}) |
|
|
|
filteredData.forEach((item) => { |
|
|
|
filteredData?.forEach((item) => { |
|
|
|
const inspectContent =item.alarm?(item?.points?.inspectContent || []):[]; |
|
|
|
if (inspectContent && inspectContent.length&&Array.isArray(inspectContent)&&inspectContent.some(o=>o.deviceId)) { |
|
|
|
inspectContent.forEach((p) => { |
|
|
@ -184,7 +198,7 @@ Page({ |
|
|
|
} |
|
|
|
}); |
|
|
|
//更新devices
|
|
|
|
devices.forEach(device => { |
|
|
|
devices?.forEach(device => { |
|
|
|
if (normal > 0) { |
|
|
|
device.status = 'normal'; |
|
|
|
normal -= 1; |
|
|
@ -197,9 +211,19 @@ Page({ |
|
|
|
} |
|
|
|
}); |
|
|
|
//重新给三个状态的值赋值
|
|
|
|
normal=devices.filter(device => device.status === 'normal').length||0 |
|
|
|
abnormal=devices.filter(device => device.status === 'abnormal').length||0 |
|
|
|
unknown=devices.filter(device => device.status === 'unknown').length||0 |
|
|
|
devices.forEach(device => { |
|
|
|
switch (device.status) { |
|
|
|
case 'normal': |
|
|
|
normal += 1; |
|
|
|
break; |
|
|
|
case 'abnormal': |
|
|
|
abnormal += 1; |
|
|
|
break; |
|
|
|
case 'unknown': |
|
|
|
unknown += 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
}); |
|
|
|
that.setData({dataList:res}) |
|
|
|
var optionDevice = { |
|
|
|
tooltip: { |
|
|
|