修复监控点设备数据读取异常
parent
9b64450dac
commit
abab5f7361
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
namespace App\Services\Admin;
|
namespace App\Services\Admin;
|
||||||
|
|
||||||
|
use App\Admin\Components;
|
||||||
|
use App\Filters\Admin\DeviceFilter;
|
||||||
|
use App\Iot\Linkos\HttpClient;
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
use App\Models\MonitorMode;
|
use App\Models\MonitorMode;
|
||||||
use App\Models\{MeteorologicalDailyReport, MeteorologicalReport, SoilDailyReport, SoilReport, AirLog, FarmWormPhoto, MonitorDevice, RegionMonitor, Region, FarmWormReport};
|
use App\Models\{MeteorologicalDailyReport, MeteorologicalReport, SoilDailyReport, SoilReport, AirLog, FarmWormPhoto, MonitorDevice, RegionMonitor, Region, FarmWormReport};
|
||||||
use App\Filters\Admin\DeviceFilter;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Admin\Components;
|
|
||||||
use App\Iot\Linkos\HttpClient;
|
|
||||||
/**
|
/**
|
||||||
* @method Device getModel()
|
* @method Device getModel()
|
||||||
* @method Device|\Illuminate\Database\Query\Builder query()
|
* @method Device|\Illuminate\Database\Query\Builder query()
|
||||||
|
|
@ -59,7 +59,7 @@ class DeviceService extends BaseService
|
||||||
$diffDays = 0;
|
$diffDays = 0;
|
||||||
$day = date('Y-m-d');
|
$day = date('Y-m-d');
|
||||||
$xKeys = [];
|
$xKeys = [];
|
||||||
|
|
||||||
if($startTime && $endTime){
|
if($startTime && $endTime){
|
||||||
$startDay = Carbon::parse($startTime);
|
$startDay = Carbon::parse($startTime);
|
||||||
$endDay = Carbon::parse($endTime);
|
$endDay = Carbon::parse($endTime);
|
||||||
|
|
@ -77,7 +77,7 @@ class DeviceService extends BaseService
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//调整截至到当前小时
|
//调整截至到当前小时
|
||||||
|
|
||||||
$th = $startDay->format('H');
|
$th = $startDay->format('H');
|
||||||
$eh = $endDay->format('H');;
|
$eh = $endDay->format('H');;
|
||||||
if($day == date('Y-m-d')){
|
if($day == date('Y-m-d')){
|
||||||
|
|
@ -170,7 +170,7 @@ class DeviceService extends BaseService
|
||||||
$yData = ['北风','东北风','东风','东南风','南风','西南风','西风','西北风'];
|
$yData = ['北风','东北风','东风','东南风','南风','西南风','西风','西北风'];
|
||||||
$_chartCard = amisMake()->Card()->body(
|
$_chartCard = amisMake()->Card()->body(
|
||||||
amisMake()->Chart()->config(
|
amisMake()->Chart()->config(
|
||||||
Components::make()->chartScatterConfig($field['name'], $xKeys,
|
Components::make()->chartScatterConfig($field['name'], $xKeys,
|
||||||
[
|
[
|
||||||
'name'=> $field['name'],
|
'name'=> $field['name'],
|
||||||
'type' => 'scatter',
|
'type' => 'scatter',
|
||||||
|
|
@ -220,7 +220,7 @@ class DeviceService extends BaseService
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($k%$columnNum != 0){
|
if($k%$columnNum != 0){
|
||||||
$_chartCard->className('m-r');
|
$_chartCard->className('m-r');
|
||||||
}
|
}
|
||||||
|
|
@ -278,14 +278,14 @@ class DeviceService extends BaseService
|
||||||
}else{
|
}else{
|
||||||
$_fields = explode(',', $device->pivot->fields);
|
$_fields = explode(',', $device->pivot->fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($diffDays) {
|
if($diffDays) {
|
||||||
$modelQuery = $dayliyReportQuery->whereBetween('reported_at', [$startTime, $endTime]);
|
$modelQuery = (clone $dayliyReportQuery)->whereBetween('reported_at', [$startTime, $endTime]);
|
||||||
}else{
|
}else{
|
||||||
$modelQuery = $reportQuery->whereDate('reported_at', $day);
|
$modelQuery = (clone $reportQuery)->whereDate('reported_at', $day);
|
||||||
}
|
}
|
||||||
if($modelQuery){
|
if($modelQuery){
|
||||||
$datalist = $modelQuery->where('device_id', $device->id)->get()->keyBy('reported_at')->toArray();
|
$datalist = (clone $modelQuery)->where('device_id', $device->id)->get()->keyBy('reported_at')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
//组装数据;
|
//组装数据;
|
||||||
|
|
@ -339,7 +339,7 @@ class DeviceService extends BaseService
|
||||||
if($config && $config['open_is_enable'] ){
|
if($config && $config['open_is_enable'] ){
|
||||||
$rule = $config['open_config'];
|
$rule = $config['open_config'];
|
||||||
$res = $this->verifyRule($rule, $log);
|
$res = $this->verifyRule($rule, $log);
|
||||||
|
|
||||||
if($res['status'] && !$airState){//如果判定成功,且设备当前是关闭状态
|
if($res['status'] && !$airState){//如果判定成功,且设备当前是关闭状态
|
||||||
$msg = '';
|
$msg = '';
|
||||||
$column = $res['keys'][0];
|
$column = $res['keys'][0];
|
||||||
|
|
@ -348,7 +348,7 @@ class DeviceService extends BaseService
|
||||||
foreach($_columns as $cc){
|
foreach($_columns as $cc){
|
||||||
$msg.= $fieldNameMap[$cc].'达到'.$log->$cc.$fieldUnitMap[$cc].'值,且';
|
$msg.= $fieldNameMap[$cc].'达到'.$log->$cc.$fieldUnitMap[$cc].'值,且';
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg = mb_substr($msg, 0, -2);
|
$msg = mb_substr($msg, 0, -2);
|
||||||
}else{
|
}else{
|
||||||
$msg = $fieldNameMap[$column].'达到'.$log->$column.$fieldUnitMap[$column].'值';
|
$msg = $fieldNameMap[$column].'达到'.$log->$column.$fieldUnitMap[$column].'值';
|
||||||
|
|
@ -369,7 +369,7 @@ class DeviceService extends BaseService
|
||||||
foreach($_columns as $cc){
|
foreach($_columns as $cc){
|
||||||
$msg.= $fieldNameMap[$cc].'达到'.$log->$cc.$fieldUnitMap[$cc].'值,且';
|
$msg.= $fieldNameMap[$cc].'达到'.$log->$cc.$fieldUnitMap[$cc].'值,且';
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg = mb_substr($msg, 0, -2);
|
$msg = mb_substr($msg, 0, -2);
|
||||||
}else{
|
}else{
|
||||||
$msg = $fieldNameMap[$column].'达到'.$log->$column.$fieldUnitMap[$column].'值';
|
$msg = $fieldNameMap[$column].'达到'.$log->$column.$fieldUnitMap[$column].'值';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue