You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.4 KiB
101 lines
3.4 KiB
<?php
|
|
namespace app\api\controller\library;
|
|
|
|
use app\api\controller\Controller;
|
|
use app\common\dm\Dm;
|
|
|
|
class Pass extends Controller
|
|
{
|
|
|
|
protected $url = 'http://balib.cn:8999';
|
|
|
|
/**
|
|
* 图书管数据接口
|
|
* @return array
|
|
* 返回数据:today.incount=今天进 month.incount=本月进 year.incount=今年进 day30.incount=近30天近 outcount=出
|
|
* 不传参数就是所有摄像头,传cameraid就是按传的摄像头ID
|
|
* cameraid = 宝安图书馆9,7,6,4,2,1,67,3 1990分馆134、 135
|
|
*/
|
|
public function allFlowTrends()
|
|
{
|
|
$dm = new Dm();
|
|
$res = $dm->find('bt_library',['group_id' => 'lib001']);
|
|
|
|
$data = [
|
|
'day30' => [
|
|
'incount' => isset($res['day30_incount']) ? $res['day30_incount'] : 0,
|
|
'outcount' => isset($res['day30_outcount']) ? $res['day30_outcount'] : 0
|
|
],
|
|
'month' => [
|
|
'incount' => isset($res['month_incount']) ? $res['month_incount'] : 0,
|
|
'outcount' => isset($res['month_outcount']) ? $res['month_outcount'] : 0
|
|
],
|
|
'today' => [
|
|
'incount' => isset($res['today_incount']) ? $res['today_incount'] : 0,
|
|
'outcount' => isset($res['today_outcount']) ? $res['today_outcount'] : 0
|
|
],
|
|
'year' => [
|
|
'incount' => isset($res['year_incount']) ? $res['year_incount'] : 0,
|
|
'outcount' => isset($res['year_outcount']) ? $res['year_outcount'] : 0
|
|
],
|
|
];
|
|
|
|
return $this->renderSuccess(compact('data'));
|
|
}
|
|
|
|
/**
|
|
* 借阅,办证
|
|
* 分馆年借还,今日借、还,今日办证
|
|
* @return array
|
|
*/
|
|
public function getLibraryService()
|
|
{
|
|
|
|
$library = $this->request->param('library') ?: '044007';
|
|
$url = $this->url . "/SSBusiness/monitor/getLibraryService?library={$library}";
|
|
|
|
$result = curlPost($url);
|
|
$data = json_decode($result,true);
|
|
|
|
return $this->renderSuccess(compact('data'));
|
|
}
|
|
|
|
/**
|
|
* 创建数据接口
|
|
* @return array
|
|
*/
|
|
public function create()
|
|
{
|
|
|
|
$data_json = $this->request->param('data');
|
|
$data = json_decode(html_entity_decode($data_json),true);
|
|
|
|
$dm = new Dm();
|
|
foreach ($data as $val) {
|
|
|
|
$query = $dm->find('bt_library',['group_id' => $val['group_id']]);
|
|
|
|
$opData = [
|
|
'day30_incount' => $val['day30_incount'],
|
|
'day30_outcount' => $val['day30_outcount'],
|
|
'today_incount' => $val['today_incount'],
|
|
'today_outcount' => $val['today_outcount'],
|
|
'month_incount' => $val['month_incount'],
|
|
'month_outcount' => $val['month_outcount'],
|
|
'year_incount' => $val['year_incount'],
|
|
'year_outcount' => $val['year_outcount'],
|
|
];
|
|
if ($query) {
|
|
$opData['update_time'] = date("Y-m-d H:i:s",time());
|
|
$dm->update('bt_library',$opData,['id' => $query['id']]);
|
|
} else {
|
|
$opData['group_id'] = $val['group_id'];
|
|
$opData['group_name'] = base64_decode($val['group_name']);
|
|
$opData['create_time'] = date("Y-m-d H:i:s",time());
|
|
$dm->insert('bt_library',$opData);
|
|
}
|
|
}
|
|
return $this->renderSuccess();
|
|
}
|
|
|
|
}
|