fixed
This commit is contained in:
parent
8ad58b7790
commit
0466e710a7
|
@ -201,16 +201,20 @@ class DeviceLogic extends BaseLogic
|
|||
->findOrEmpty();
|
||||
|
||||
$monitorItemArray = [];
|
||||
if (!empty($detail['monitor_item'])) {
|
||||
$monitorItemArray = explode(',', $detail['monitor_item']);
|
||||
}
|
||||
|
||||
$dictTypeId = Db::name('dict_type')->where('type', 'monitor_item')->value('id');
|
||||
$monitorItemArray = Db::name('dict_data')->where('type_id', $dictTypeId)->whereIn('value', $monitorItemArray)->field(['name', 'value'])->select()->toArray();
|
||||
foreach($monitorItemArray as $k=>$v) {
|
||||
$monitorItemArray[$k]['device_id'] = $params['id'];
|
||||
$monitorItemArray[$k]['monitor_value'] = '-';
|
||||
$monitorItemArray[$k]['last_time'] = '-';
|
||||
$monitorData = Db::name('land_collection')->where('device_id', $params['id'])->where('monitor_item', $v['value'])->order(['id' => 'desc'])->find();
|
||||
$monitorData = Db::name('land_collection')->where('device_id', $params['id'])->order(['id' => 'desc'])->find();
|
||||
if (!empty($monitorData)) {
|
||||
$monitorItemArray[$k]['monitor_value'] = $monitorData['monitor_value'];
|
||||
$monitorItemArray[$k]['last_time'] = date('Y-m-d H:i:s', $monitorData['create_time']);
|
||||
$monitorItemArray[$k]['monitor_value'] = $monitorData[$v['value']];
|
||||
$monitorItemArray[$k]['last_time'] =$monitorData['create_time'];
|
||||
}
|
||||
}
|
||||
$detail['monitor_item'] = $monitorItemArray;
|
||||
|
@ -227,14 +231,14 @@ class DeviceLogic extends BaseLogic
|
|||
$limitOffset = ($pageNo - 1) * $pageSize;
|
||||
$limitLength = $pageSize;
|
||||
$where['device_id'] = $params['id'];
|
||||
$where['monitor_item'] = $params['monitor_type'];
|
||||
$lists = Db::name('device_monitor_data')
|
||||
$lists = Db::name('land_collection')
|
||||
->where($where)
|
||||
->field(["{$params['monitor_type']} as monitor_value", 'id', 'create_time'])
|
||||
->limit($limitOffset, $limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$count = Db::name('device_monitor_data')->where($where)->count();
|
||||
$count = Db::name('land_collection')->where($where)->count();
|
||||
return compact('lists', 'count', 'page_no', 'page_size');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue