update
This commit is contained in:
parent
3643b2b7d7
commit
2c48c37228
|
@ -15,6 +15,7 @@
|
||||||
namespace app\adminapi\logic\animal_info;
|
namespace app\adminapi\logic\animal_info;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\logic\RemoteRequestLogic;
|
||||||
use app\common\model\animal_info\AnimalInfo;
|
use app\common\model\animal_info\AnimalInfo;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
@ -134,10 +135,19 @@ class AnimalInfoLogic extends BaseLogic
|
||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
|
$data = AnimalInfo::with(['fenceHouseAttr'])->findOrEmpty($params['id'])->toArray();
|
||||||
if (isset($params['sn'])) {
|
if (isset($params['sn'])) {
|
||||||
return AnimalInfo::with(['fenceHouseAttr'])->where('sn', $params['sn'])->findOrEmpty()->toArray();
|
$data = AnimalInfo::with(['fenceHouseAttr'])->where('sn', $params['sn'])->findOrEmpty()->toArray();
|
||||||
}
|
}
|
||||||
return AnimalInfo::with(['fenceHouseAttr'])->findOrEmpty($params['id'])->toArray();
|
// 查动物体温
|
||||||
|
$res = RemoteRequestLogic::requestAnimalTemperature($data['sn']);
|
||||||
|
if (!empty($res['values'])) {
|
||||||
|
$temperature = $res['values'][1];
|
||||||
|
} else {
|
||||||
|
$temperature = 0;
|
||||||
|
}
|
||||||
|
$data['temperature'] = $temperature;
|
||||||
|
return $data;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -264,4 +264,15 @@ class RemoteRequestLogic extends BaseLogic
|
||||||
$monitor = json_decode($response->getContent(), true);
|
$monitor = json_decode($response->getContent(), true);
|
||||||
return $monitor['data']['values'];
|
return $monitor['data']['values'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function requestAnimalTemperature($rfid='')
|
||||||
|
{
|
||||||
|
$response = HttpClient::create()->request('GET', env('PROJECT.MQTT_PROJECT_URL'). 'api/xumu/warning/past_seven_days', [
|
||||||
|
'query' => [
|
||||||
|
'rfid' => $rfid
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$monitor = json_decode($response->getContent(), true);
|
||||||
|
return $monitor['data'];
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue