|
|
@ -71,6 +71,65 @@ Page({ |
|
|
|
that.ecComponent = that.selectComponent('#mychart-dom-pie'); |
|
|
|
that.ecDeviceComponent = that.selectComponent('#mychart-device-pie'); |
|
|
|
const date1 = new Date('1970-01-01 00:00:00'); |
|
|
|
Request.get(getDevices()).then(res => { |
|
|
|
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) => { |
|
|
|
const type = item.type; |
|
|
|
// 如果 typeGroups 中没有这个类型的数组,就初始化一个空数组
|
|
|
|
if (!typeGroups[type]) { |
|
|
|
typeGroups[type] = []; |
|
|
|
} |
|
|
|
// 将对象添加到相应类型的数组中
|
|
|
|
typeGroups[type].push(item); |
|
|
|
}); |
|
|
|
// 格式转换成指定格式
|
|
|
|
const result = Object.keys(typeGroups).map((type) => ({ |
|
|
|
name: type, |
|
|
|
value: typeGroups[type].length, |
|
|
|
})); |
|
|
|
var option = { |
|
|
|
tooltip: { |
|
|
|
trigger: 'item' |
|
|
|
}, |
|
|
|
backgroundColor: "#ffffff", |
|
|
|
legend: { |
|
|
|
bottom: 10, |
|
|
|
left: 'center', |
|
|
|
}, |
|
|
|
series: [{ |
|
|
|
label: { |
|
|
|
normal: { |
|
|
|
fontSize: 14 |
|
|
|
} |
|
|
|
}, |
|
|
|
type: 'pie', |
|
|
|
center: ['50%', '50%'], |
|
|
|
radius: ['20%', '40%'], |
|
|
|
data: result |
|
|
|
|
|
|
|
}] |
|
|
|
}; |
|
|
|
setTimeout(() => { |
|
|
|
that.initECharts(option); |
|
|
|
}, 1000) |
|
|
|
} else { |
|
|
|
wx.hideLoading() |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
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')).then(res => { |
|
|
|
if (res) { |
|
|
|
let normal = 0; |
|
|
@ -94,6 +153,8 @@ Page({ |
|
|
|
const {pointId,inspectionTime} = item; |
|
|
|
return inspectionTime === maxInspectionTimeByPointId[pointId]; |
|
|
|
}); |
|
|
|
//获取设备信息
|
|
|
|
const devices=that.data.deviceList.map(item=>{return {id:item.id,name:item.name,status:'unknown'}}) |
|
|
|
filteredData.forEach((item) => { |
|
|
|
const inspectContent =item.alarm?(item?.points?.inspectContent || []):[]; |
|
|
|
if (inspectContent && inspectContent.length&&Array.isArray(inspectContent)) { |
|
|
@ -104,11 +165,14 @@ Page({ |
|
|
|
const state = item.patrolRecordIssueHandles[0].state; |
|
|
|
if (state === 6) { |
|
|
|
// 正常
|
|
|
|
statusCount['正常'] += 1; |
|
|
|
normal += 1; |
|
|
|
} else if (state === 5) { |
|
|
|
statusCount['未知'] += 1; |
|
|
|
// 未知
|
|
|
|
unknown += 1; |
|
|
|
}else { |
|
|
|
statusCount['异常'] += 1; |
|
|
|
// 异常
|
|
|
|
abnormal += 1; |
|
|
|
} |
|
|
@ -120,6 +184,23 @@ Page({ |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
//更新devices
|
|
|
|
devices.forEach(device => { |
|
|
|
if (normal > 0) { |
|
|
|
device.status = 'normal'; |
|
|
|
normal -= 1; |
|
|
|
} else if (abnormal > 0) { |
|
|
|
device.status = 'abnormal'; |
|
|
|
abnormal -= 1; |
|
|
|
} else if (unknown > 0) { |
|
|
|
device.status = 'unknown'; |
|
|
|
unknown -= 1; |
|
|
|
} |
|
|
|
}); |
|
|
|
//重新给三个状态的值赋值
|
|
|
|
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 |
|
|
|
that.setData({dataList:res}) |
|
|
|
var optionDevice = { |
|
|
|
tooltip: { |
|
|
@ -173,65 +254,7 @@ Page({ |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
Request.get(getDevices()).then(res => { |
|
|
|
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) => { |
|
|
|
const type = item.type; |
|
|
|
// 如果 typeGroups 中没有这个类型的数组,就初始化一个空数组
|
|
|
|
if (!typeGroups[type]) { |
|
|
|
typeGroups[type] = []; |
|
|
|
} |
|
|
|
// 将对象添加到相应类型的数组中
|
|
|
|
typeGroups[type].push(item); |
|
|
|
}); |
|
|
|
// 格式转换成指定格式
|
|
|
|
const result = Object.keys(typeGroups).map((type) => ({ |
|
|
|
name: type, |
|
|
|
value: typeGroups[type].length, |
|
|
|
})); |
|
|
|
var option = { |
|
|
|
tooltip: { |
|
|
|
trigger: 'item' |
|
|
|
}, |
|
|
|
backgroundColor: "#ffffff", |
|
|
|
legend: { |
|
|
|
bottom: 10, |
|
|
|
left: 'center', |
|
|
|
}, |
|
|
|
series: [{ |
|
|
|
label: { |
|
|
|
normal: { |
|
|
|
fontSize: 14 |
|
|
|
} |
|
|
|
}, |
|
|
|
type: 'pie', |
|
|
|
center: ['50%', '50%'], |
|
|
|
radius: ['20%', '40%'], |
|
|
|
data: result |
|
|
|
|
|
|
|
}] |
|
|
|
}; |
|
|
|
setTimeout(() => { |
|
|
|
that.initECharts(option); |
|
|
|
}, 1000) |
|
|
|
} else { |
|
|
|
wx.hideLoading() |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|