Browse Source

feat:fix bugs

master
zhaobing’ 1 year ago
parent
commit
8188b6bd19
  1. 24
      weapp/package/deviceBigdataGraph/statusDetail/statusDetail.js
  2. 3
      weapp/package/polling/polling.json
  3. 4
      weapp/package/polling/polling.wxml
  4. 8
      weapp/package/report/report.js
  5. 2
      weapp/package/report/report.wxml

24
weapp/package/deviceBigdataGraph/statusDetail/statusDetail.js

@ -102,6 +102,8 @@ Page({
// 创建一个对象来存储每个pointId的最大inspectionTime // 创建一个对象来存储每个pointId的最大inspectionTime
const maxInspectionTimeByPointId = {}; const maxInspectionTimeByPointId = {};
const sevenDaysAgo = moment().subtract(7, 'days'); // 获取七天前的日期 const sevenDaysAgo = moment().subtract(7, 'days'); // 获取七天前的日期
//把设备数据全部弄成未知状态
const len=complexArray.map(item=>{return {id:item.id,name:item.name,status:'unknown'}})?.length
// 过滤出近七天内的最新记录(同点位+同一天的最新记录) // 过滤出近七天内的最新记录(同点位+同一天的最新记录)
const latestRecords = patrolRecord.filter((record) => { const latestRecords = patrolRecord.filter((record) => {
const inspectionDate = moment(record.inspectionTime).format('YYYY-MM-DD'); const inspectionDate = moment(record.inspectionTime).format('YYYY-MM-DD');
@ -117,7 +119,7 @@ Page({
}); });
}); });
//调用每天的函数处理每天的正常-异常-未知的个数 //调用每天的函数处理每天的正常-异常-未知的个数
const sevenDays= that.calculateDailyDeviceStatusCounts(latestRecords) const sevenDays= that.calculateDailyDeviceStatusCounts(latestRecords,len)
// 遍历数据并更新maxInspectionTimeByPointId // 遍历数据并更新maxInspectionTimeByPointId
patrolRecord.forEach((item) => { patrolRecord.forEach((item) => {
const {pointId,inspectionTime} = item; const {pointId,inspectionTime} = item;
@ -139,7 +141,7 @@ Page({
return false; return false;
}); });
//七天内最新的数据(正常) //七天内最新的数据(正常)
const statusCounts =that.classifiedStatistics(filteredData) const statusCounts =that.classifiedStatistics(filteredData,len)
const {unknown,normal,abnormal}=statusCounts const {unknown,normal,abnormal}=statusCounts
const deviceCount=complexArray.length const deviceCount=complexArray.length
that.setData({ that.setData({
@ -159,10 +161,10 @@ Page({
}, },
//分类统计设备,异常-正常-未知个数 //分类统计设备,异常-正常-未知个数
classifiedStatistics:function(list){ classifiedStatistics:function(list,len){
let normal = 0; let normal = 0;
let abnormal = 0; let abnormal = 0;
let unknown = 0; let unknown = len;
list.forEach((item) => { list.forEach((item) => {
const inspectContent = item.alarm ? (item?.points?.inspectContent || []) : []; const inspectContent = item.alarm ? (item?.points?.inspectContent || []) : [];
if (inspectContent && inspectContent.length && Array.isArray(inspectContent)) { if (inspectContent && inspectContent.length && Array.isArray(inspectContent)) {
@ -174,17 +176,20 @@ Page({
if (state === 6) { if (state === 6) {
// 正常 // 正常
normal += 1; normal += 1;
unknown-=1
} else if (state === 5) { } else if (state === 5) {
// 未知 // 未知
unknown += 1; // unknown += 1;
} else { } else {
// 异常 // 异常
abnormal += 1; abnormal += 1;
unknown-=1
} }
} }
} else { } else {
// 正常 // 正常
normal += 1; normal += 1;
unknown-=1
} }
}); });
} }
@ -192,7 +197,7 @@ Page({
return {normal,unknown,abnormal} return {normal,unknown,abnormal}
}, },
//统计每天异常-正常-未知个数 //统计每天异常-正常-未知个数
calculateDailyDeviceStatusCounts:function(data) { calculateDailyDeviceStatusCounts:function(data,len) {
const dateRange = [] const dateRange = []
const today = moment() const today = moment()
for (let i = 6; i >= 0; i--) { for (let i = 6; i >= 0; i--) {
@ -203,7 +208,7 @@ Page({
dateRange.forEach((date) => { dateRange.forEach((date) => {
dailyCounts[date] = { dailyCounts[date] = {
normal: 0, normal: 0,
unknown: 0, unknown: len,
abnormal: 0 abnormal: 0
}; };
}); });
@ -214,14 +219,15 @@ Page({
const status = item.patrolRecordIssueHandles.length ? item.patrolRecordIssueHandles[0].state : 6; const status = item.patrolRecordIssueHandles.length ? item.patrolRecordIssueHandles[0].state : 6;
if (status === 6) { if (status === 6) {
dailyCounts[inspectionDate].normal += 1; dailyCounts[inspectionDate].normal += 1;
dailyCounts[inspectionDate].unknown -= 1;
} else if (status === 5) { } else if (status === 5) {
dailyCounts[inspectionDate].unknown += 1; // dailyCounts[inspectionDate].unknown += 1;
} else { } else {
dailyCounts[inspectionDate].abnormal += 1; dailyCounts[inspectionDate].abnormal += 1;
dailyCounts[inspectionDate].unknown -= 1;
} }
} }
}); });
return dailyCounts; return dailyCounts;
}, },
/** /**

3
weapp/package/polling/polling.json

@ -10,7 +10,8 @@
"van-dropdown-menu": "@vant/weapp/dropdown-menu/index", "van-dropdown-menu": "@vant/weapp/dropdown-menu/index",
"van-dropdown-item": "@vant/weapp/dropdown-item/index", "van-dropdown-item": "@vant/weapp/dropdown-item/index",
"van-datetime-picker": "@vant/weapp/datetime-picker/index", "van-datetime-picker": "@vant/weapp/datetime-picker/index",
"van-icon": "@vant/weapp/icon/index" "van-icon": "@vant/weapp/icon/index",
"van-button": "@vant/weapp/button/index"
} }
} }

4
weapp/package/polling/polling.wxml

@ -80,8 +80,8 @@
</view> </view>
</van-tab> </van-tab>
<van-tab title='主动上报' > <van-tab title='主动上报' >
<view> <view style="display: flex; justify-content: center; align-items: center; height: 100vh;">
<van-button type="info" round bindtap="jumpToReport"><van-icon name="plus" /></van-button> <van-button type="info" round bindtap="jumpToReport">主动上报</van-button>
</view> </view>
</van-tab> </van-tab>
</van-tabs> </van-tabs>

8
weapp/package/report/report.js

@ -84,6 +84,10 @@ Page({
structListIndex: event.detail.value, structListIndex: event.detail.value,
// isPlanState: true, // isPlanState: true,
pointList:[],//选择结构物后先置空先前的点位列表 pointList:[],//选择结构物后先置空先前的点位列表
patrolTemplate:[],
inspectContentArr:[],
patrolTemplateIndex:undefined,
pointIndex:undefined
}) })
const projectId=that.data?.structList[event.detail.value]?.id const projectId=that.data?.structList[event.detail.value]?.id
@ -402,7 +406,9 @@ Page({
//巡检模板改变 //巡检模板改变
patrolTemplateChange(e){ patrolTemplateChange(e){
const that=this const that=this
that.getPatrolTemplate(that.data.patrolTemplate[e.detail.value].id,that.data.devicesList) if(e.detail.value!=0){
that.getPatrolTemplate(that.data.patrolTemplate[e.detail.value].id,that.data.devicesList)
}
that.setData({ that.setData({
patrolTemplateIndex:e.detail.value patrolTemplateIndex:e.detail.value
}) })

2
weapp/package/report/report.wxml

@ -15,7 +15,7 @@
<van-cell> <van-cell>
<view style="display:flex"> <view style="display:flex">
<view class="fs-cell-title" style="">当前点位:</view> <view class="fs-cell-title" style="">当前点位:</view>
<picker style="width:100%;text-align:left" bindchange="pointChange" data-type='point' range="{{pointList}}" range-key="name"> <picker style="width:100%;text-align:left" bindchange="pointChange" data-type='point' value="{{0}}" range="{{pointList}}" range-key="name">
<view class="fs-cell-content" style="width:100%"> <view class="fs-cell-content" style="width:100%">
{{pointIndex||pointIndex==0?pointList[pointIndex].name:'请选择'}} {{pointIndex||pointIndex==0?pointList[pointIndex].name:'请选择'}}
<van-icon name="arrow" style="float:right;position:relative; top:4px" /> <van-icon name="arrow" style="float:right;position:relative; top:4px" />

Loading…
Cancel
Save