|
@ -39,9 +39,10 @@ Page({ |
|
|
show: true, |
|
|
show: true, |
|
|
currentPatrolCount: 0, //当月巡检次数
|
|
|
currentPatrolCount: 0, //当月巡检次数
|
|
|
currentRepairCount: 0, //当月维修次数
|
|
|
currentRepairCount: 0, //当月维修次数
|
|
|
level1Count: 0, //轻微
|
|
|
// level1Count: 0, //轻微
|
|
|
level2Count: 0, //中度
|
|
|
// level2Count: 0, //中度
|
|
|
level3Count: 0, //严重
|
|
|
// level3Count: 0, //严重
|
|
|
|
|
|
// dataList:[],//饼图数据
|
|
|
selectedDate: new Date(), // 设置默认选中的日期为当前日期
|
|
|
selectedDate: new Date(), // 设置默认选中的日期为当前日期
|
|
|
formatter(day) { |
|
|
formatter(day) { |
|
|
|
|
|
|
|
@ -139,25 +140,70 @@ Page({ |
|
|
const ETime = moment().endOf('month').format('YYYY-MM-DD') |
|
|
const ETime = moment().endOf('month').format('YYYY-MM-DD') |
|
|
//子系统关键字
|
|
|
//子系统关键字
|
|
|
let keywords = options.key |
|
|
let keywords = options.key |
|
|
|
|
|
const maxInspectionTimeByPointId = {}; |
|
|
// keywords = '管廊'
|
|
|
// keywords = '管廊'
|
|
|
const query = { |
|
|
const query = { STime, ETime, keywords } |
|
|
STime, |
|
|
|
|
|
ETime, |
|
|
|
|
|
keywords |
|
|
|
|
|
} |
|
|
|
|
|
Request.get(getSubSystemPatrolAbout(query)).then(res => { |
|
|
Request.get(getSubSystemPatrolAbout(query)).then(res => { |
|
|
|
|
|
|
|
|
if (res) { |
|
|
if (res) { |
|
|
|
|
|
// 遍历数据并更新maxInspectionTimeByPointId
|
|
|
|
|
|
res.forEach((item) => { |
|
|
|
|
|
const { pointId, inspectionTime } = item; |
|
|
|
|
|
if (pointId in maxInspectionTimeByPointId) { |
|
|
|
|
|
if (inspectionTime > maxInspectionTimeByPointId[pointId]) { |
|
|
|
|
|
maxInspectionTimeByPointId[pointId] = inspectionTime; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
maxInspectionTimeByPointId[pointId] = inspectionTime; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
// 过滤数据以获取相同pointId中inspectionTime最大的记录
|
|
|
|
|
|
const filteredData = res.filter((item) => { |
|
|
|
|
|
const { pointId, inspectionTime } = item; |
|
|
|
|
|
return inspectionTime === maxInspectionTimeByPointId[pointId]; |
|
|
|
|
|
}); |
|
|
//巡查内容
|
|
|
//巡查内容
|
|
|
// const list=res?.filter(item=>item?.points?.user.id===userInfo.id)||[]
|
|
|
// const list=res?.filter(item=>item?.points?.user.id===userInfo.id)||[]
|
|
|
|
|
|
// 创建一个对象来存储按设备分类的最低level统计
|
|
|
|
|
|
const deviceLevelStatistics = {}; |
|
|
|
|
|
// 初始化一个包含所有level的对象
|
|
|
|
|
|
const levelValues = {轻微: 0,中度: 1,严重: 2}; |
|
|
|
|
|
// 遍历巡检记录
|
|
|
|
|
|
filteredData.forEach((record) => { |
|
|
|
|
|
const points = record.points; |
|
|
|
|
|
if (points && points.inspectContent && Array.isArray(points.inspectContent)) { |
|
|
|
|
|
points.inspectContent.forEach((content) => { |
|
|
|
|
|
const device = content.deviceId; |
|
|
|
|
|
content.checkItems.forEach(checkItem => { |
|
|
|
|
|
const level = checkItem.level; |
|
|
|
|
|
if (!deviceLevelStatistics[device]) { |
|
|
|
|
|
// 如果设备不存在于统计对象中,初始化
|
|
|
|
|
|
deviceLevelStatistics[device] = { |
|
|
|
|
|
deviceName: content.deviceName, // 可能需要设备名称
|
|
|
|
|
|
level: level |
|
|
|
|
|
}; |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果设备已存在于统计对象中,比较level并更新为最低的level
|
|
|
|
|
|
deviceLevelStatistics[device].level = levelValues[level] < levelValues[deviceLevelStatistics[device].level] ? level : deviceLevelStatistics[device].level; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
const levelCounts = {轻微: 0,中度: 0, 严重: 0}; |
|
|
|
|
|
for (const deviceId in deviceLevelStatistics) { |
|
|
|
|
|
if (deviceLevelStatistics.hasOwnProperty(deviceId)) { |
|
|
|
|
|
const deviceInfo = deviceLevelStatistics[deviceId]; |
|
|
|
|
|
const level = deviceInfo.level; |
|
|
|
|
|
// 增加相应等级的设备数量
|
|
|
|
|
|
levelCounts[level]++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
const data1=Object.entries(levelCounts).map(([name, value]) => ({ name, value })); |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
currentRepairCount: res?.filter(i => i.patrolRecordIssueHandles.length > 0).length || 0, |
|
|
currentRepairCount: res?.filter(i => i.patrolRecordIssueHandles.length > 0).length || 0, |
|
|
currentPatrolCount: res.length, |
|
|
currentPatrolCount: res.length, |
|
|
level1Count: that.filterLevelCount(res,'轻微')||0, |
|
|
|
|
|
level2Count: that.filterLevelCount(res,'中度')||0, |
|
|
|
|
|
level3Count: that.filterLevelCount(res,'严重')||0, |
|
|
|
|
|
formatter: function (e) { |
|
|
formatter: function (e) { |
|
|
res?.map(i=>{ |
|
|
filteredData?.map(i => { |
|
|
if (moment(i.inspectionTime).format('YYYY-MM-DD') == moment(e.date).format('YYYY-MM-DD')) { |
|
|
if (moment(i.inspectionTime).format('YYYY-MM-DD') == moment(e.date).format('YYYY-MM-DD')) { |
|
|
if (i.patrolRecordIssueHandles.length == 0) { |
|
|
if (i.patrolRecordIssueHandles.length == 0) { |
|
|
e.bottomInfo = '.'; e.className = 'greenClass' |
|
|
e.bottomInfo = '.'; e.className = 'greenClass' |
|
@ -176,6 +222,9 @@ Page({ |
|
|
bottom: 10, |
|
|
bottom: 10, |
|
|
left: 'center', |
|
|
left: 'center', |
|
|
}, |
|
|
}, |
|
|
|
|
|
tooltip: { |
|
|
|
|
|
trigger: 'item' |
|
|
|
|
|
}, |
|
|
series: [{ |
|
|
series: [{ |
|
|
label: { |
|
|
label: { |
|
|
normal: { |
|
|
normal: { |
|
@ -185,9 +234,7 @@ Page({ |
|
|
type: 'pie', |
|
|
type: 'pie', |
|
|
center: ['50%', '50%'], |
|
|
center: ['50%', '50%'], |
|
|
radius: ['20%', '40%'], |
|
|
radius: ['20%', '40%'], |
|
|
data:[ {name:'轻微',value:that.data.level1Count}, |
|
|
data:data1 |
|
|
{name:'中度',value:that.data.level2Count}, |
|
|
|
|
|
{name:'重度',value:that.data.level3Count}] |
|
|
|
|
|
}] |
|
|
}] |
|
|
}; |
|
|
}; |
|
|
that.initECharts(option); |
|
|
that.initECharts(option); |
|
|