tongshanglei 2 vuotta sitten
vanhempi
commit
6e7f494efe

+ 69 - 0
catch/alarm/controller/BwList.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace catchAdmin\alarm\controller;
+
+use catcher\base\CatchRequest as Request;
+use catcher\CatchResponse;
+use catcher\base\CatchController;
+use catchAdmin\alarm\model\BwList as bwListModel;
+
+class BwList extends CatchController
+{
+    protected $bwListModel;
+    
+    public function __construct(BwListModel $bwListModel)
+    {
+        $this->bwListModel = $bwListModel;
+    }
+    
+    /**
+     * 列表
+     * @time 2022年10月26日 10:32
+     * @param Request $request 
+     */
+    public function index(Request $request) : \think\Response
+    {
+        return CatchResponse::paginate($this->bwListModel->getList());
+    }
+    
+    /**
+     * 保存信息
+     * @time 2022年10月26日 10:32
+     * @param Request $request 
+     */
+    public function save(Request $request) : \think\Response
+    {
+        return CatchResponse::success($this->bwListModel->storeBy($request->post()));
+    }
+    
+    /**
+     * 读取
+     * @time 2022年10月26日 10:32
+     * @param $id 
+     */
+    public function read($id) : \think\Response
+    {
+        return CatchResponse::success($this->bwListModel->findBy($id));
+    }
+    
+    /**
+     * 更新
+     * @time 2022年10月26日 10:32
+     * @param Request $request 
+     * @param $id
+     */
+    public function update(Request $request, $id) : \think\Response
+    {
+        return CatchResponse::success($this->bwListModel->updateBy($id, $request->post()));
+    }
+    
+    /**
+     * 删除
+     * @time 2022年10月26日 10:32
+     * @param $id
+     */
+    public function delete($id) : \think\Response
+    {
+        return CatchResponse::success($this->bwListModel->deleteBy($id));
+    }
+}

+ 69 - 0
catch/alarm/controller/ControlManage.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace catchAdmin\alarm\controller;
+
+use catcher\base\CatchRequest as Request;
+use catcher\CatchResponse;
+use catcher\base\CatchController;
+use catchAdmin\alarm\model\ControlManage as controlManageModel;
+
+class ControlManage extends CatchController
+{
+    protected $controlManageModel;
+    
+    public function __construct(ControlManageModel $controlManageModel)
+    {
+        $this->controlManageModel = $controlManageModel;
+    }
+    
+    /**
+     * 列表
+     * @time 2022年10月26日 10:23
+     * @param Request $request 
+     */
+    public function index(Request $request) : \think\Response
+    {
+        return CatchResponse::paginate($this->controlManageModel->getList());
+    }
+    
+    /**
+     * 保存信息
+     * @time 2022年10月26日 10:23
+     * @param Request $request 
+     */
+    public function save(Request $request) : \think\Response
+    {
+        return CatchResponse::success($this->controlManageModel->storeBy($request->post()));
+    }
+    
+    /**
+     * 读取
+     * @time 2022年10月26日 10:23
+     * @param $id 
+     */
+    public function read($id) : \think\Response
+    {
+        return CatchResponse::success($this->controlManageModel->findBy($id));
+    }
+    
+    /**
+     * 更新
+     * @time 2022年10月26日 10:23
+     * @param Request $request 
+     * @param $id
+     */
+    public function update(Request $request, $id) : \think\Response
+    {
+        return CatchResponse::success($this->controlManageModel->updateBy($id, $request->post()));
+    }
+    
+    /**
+     * 删除
+     * @time 2022年10月26日 10:23
+     * @param $id
+     */
+    public function delete($id) : \think\Response
+    {
+        return CatchResponse::success($this->controlManageModel->deleteBy($id));
+    }
+}

+ 86 - 0
catch/alarm/controller/RfidWithBw.php

@@ -0,0 +1,86 @@
+<?php
+
+namespace catchAdmin\alarm\controller;
+
+use catcher\base\CatchRequest as Request;
+use catcher\CatchResponse;
+use catcher\base\CatchController;
+use catchAdmin\alarm\model\RfidWithBw as rfidWithBwModel;
+
+class RfidWithBw extends CatchController
+{
+    protected $rfidWithBwModel;
+    
+    public function __construct(RfidWithBwModel $rfidWithBwModel)
+    {
+        $this->rfidWithBwModel = $rfidWithBwModel;
+    }
+    
+    /**
+     * 列表
+     * @time 2022年10月26日 13:53
+     * @param Request $request 
+     */
+    public function index(Request $request) : \think\Response
+    {
+        return CatchResponse::paginate($this->rfidWithBwModel->getList());
+    }
+    
+    /**
+     * 保存信息
+     * @time 2022年10月26日 13:53
+     * @param Request $request 
+     */
+    public function save(Request $request) : \think\Response
+    {   
+        //$this->rfidWithBwModel->storeBy($request->post())
+        $data=$request->post();
+        $creator_id=$data['creator_id'];
+        $arr=[];
+        foreach($data as $key=>$val){
+
+            if($key==='creator_id'){
+                continue;
+            }
+            $val['creator_id']=$creator_id;
+            $val['created_at']=time();
+            
+            array_push($arr,$val);
+        }
+        // var_dump($arr);
+        array_unique($data, SORT_REGULAR);
+        $success = $this->rfidWithBwModel->insertAll($arr);
+        return CatchResponse::success($success);
+    }
+    
+    /**
+     * 读取
+     * @time 2022年10月26日 13:53
+     * @param $id 
+     */
+    public function read($id) : \think\Response
+    {
+        return CatchResponse::success($this->rfidWithBwModel->findBy($id));
+    }
+    
+    /**
+     * 更新
+     * @time 2022年10月26日 13:53
+     * @param Request $request 
+     * @param $id
+     */
+    public function update(Request $request, $id) : \think\Response
+    {
+        return CatchResponse::success($this->rfidWithBwModel->updateBy($id, $request->post()));
+    }
+    
+    /**
+     * 删除
+     * @time 2022年10月26日 13:53
+     * @param $id
+     */
+    public function delete($id) : \think\Response
+    {
+        return CatchResponse::success($this->rfidWithBwModel->deleteBy($id));
+    }
+}

+ 46 - 0
catch/alarm/database/migrations/20221026102401_control_manage.php

@@ -0,0 +1,46 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class ControlManage extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        $table = $this->table('control_manage', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '布控管理' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('type', 'string', ['limit' => 16,'null' => true,'signed' => true,'comment' => '布控类型',])
+			->addColumn('start_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => false,'comment' => '布控开始时间',])
+			->addColumn('end_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => false,'comment' => '布控结束时间',])
+			->addColumn('plate_no', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '车牌',])
+			->addColumn('rfid_sn', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '车辆标签',])
+			->addColumn('station_ids', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '区域基站',])
+			->addColumn('area_type', 'string', ['limit' => 8,'null' => true,'signed' => true,'comment' => '区域类型',])
+			->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
+			->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
+			->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
+			->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
+            ->create();
+    }
+}

+ 44 - 0
catch/alarm/database/migrations/20221026103228_bw_list.php

@@ -0,0 +1,44 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class BwList extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        $table = $this->table('bw_list', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '黑白名单' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('name', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '名称',])
+			->addColumn('type', 'boolean', ['null' => true,'signed' => true,'comment' => '名单类型(0-黑名单,1-白名单)',])
+			->addColumn('rfid_type', 'string', ['limit' => 8,'null' => true,'signed' => true,'comment' => '标签类型',])
+			->addColumn('state', 'boolean', ['null' => true,'signed' => true,'comment' => '启用停用(0-停用,1-启用)',])
+			->addColumn('remark', 'string', ['limit' => 128,'null' => true,'default' => '','signed' => true,'comment' => '备注',])
+			->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
+			->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
+			->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
+			->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
+            ->create();
+    }
+}

+ 42 - 0
catch/alarm/database/migrations/20221026135412_rfid_with_bw.php

@@ -0,0 +1,42 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class RfidWithBw extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        $table = $this->table('rfid_with_bw', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '黑白名单标签' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('bw_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '黑白名单id',])
+			->addColumn('rfid', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '标签',])
+			->addColumn('rfid_type', 'string', ['limit' => 8,'null' => true,'signed' => true,'comment' => '标签类型',])
+			->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
+			->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
+			->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
+			->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
+            ->create();
+    }
+}

+ 71 - 0
catch/alarm/model/BwList.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace catchAdmin\alarm\model;
+
+use catcher\base\CatchModel as Model;
+use catchAdmin\permissions\model\DataRangScopeTrait;
+use catchAdmin\system\model\SysDictData;
+class BwList extends Model
+{
+    use DataRangScopeTrait;
+    // 表名
+    public $name = 'bw_list';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 名称
+        'name',
+        // 名单类型(0-黑名单,1-白名单)
+        'type',
+        // 标签类型
+        'rfid_type',
+        // 启用停用(0-停用,1-启用)
+        'state',
+        // 备注
+        'remark',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+    /**
+     * 列表
+     */
+    public function getList()
+    {
+        $res=$this->dataRange()
+            ->catchSearch()
+            ->append(['type_text','rfid_type_text'])
+            ->order($this->aliasField('id'), 'desc')
+            ->paginate();
+        return $res;
+    }
+    //根据姓名搜索
+    public function searchNameAttr($query, $value, $data)
+    {
+        return $query->where('name', 'like', '%' . $value . '%');
+    }
+    
+    public function searchStateAttr($query, $value, $data)
+    {
+        return $query->where('state',  $value );
+    }
+
+    
+    public function getTypeAttr($value){
+       
+        return (string)$value;
+    }
+    public function getTypeTextAttr($value){
+        return $value ?'白名单': '黑名单';
+    }
+    public function getRfidTypeTextAttr($value){
+        $rfid_type = $this->getData('rfid_type');
+        return (new SysDictData())->getValueByCode('RFID_TYPE_OPTION', $rfid_type) ?: '';
+    }
+
+}

+ 37 - 0
catch/alarm/model/ControlManage.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace catchAdmin\alarm\model;
+
+use catcher\base\CatchModel as Model;
+
+class ControlManage extends Model
+{
+    // 表名
+    public $name = 'control_manage';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 布控类型
+        'type',
+        // 布控开始时间
+        'start_time',
+        // 布控结束时间
+        'end_time',
+        // 车牌
+        'plate_no',
+        // 车辆标签
+        'rfid_sn',
+        // 区域基站
+        'station_ids',
+        // 区域类型
+        'area_type',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+}

+ 41 - 0
catch/alarm/model/RfidWithBw.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace catchAdmin\alarm\model;
+
+use catcher\base\CatchModel as Model;
+
+class RfidWithBw extends Model
+{
+    // 表名
+    public $name = 'rfid_with_bw';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 黑白名单id
+        'bw_id',
+        // 标签
+        'rfid',
+        'rfid_type',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+    public function getList()
+    {
+        $res=$this->catchSearch()
+            
+            ->order($this->aliasField('id'), 'desc')
+            ->paginate();
+        return $res;
+    }
+    //根据姓名搜索
+    public function searchBwIdAttr($query, $value, $data)
+    {
+        return $query->where('bw_id',  $value);
+    }
+}

+ 7 - 2
catch/alarm/route.php

@@ -21,12 +21,17 @@ $router->group(function () use ($router){
 	$router->post('AlarmRecords/getAlarmRecordsbyId','\catchAdmin\alarm\controller\AlarmRecords@getAlarmRecordsbyId');
 	//微信获取告警详情
 	$router->post('AlarmRecords/getAlarmDetail','\catchAdmin\alarm\controller\AlarmRecords@getAlarmDetail');
-	//解除警报
-	
 	
+	// controlManage路由
+	$router->resource('controlManage', '\catchAdmin\alarm\controller\ControlManage');
+	// bwList路由
+	$router->resource('bwList', '\catchAdmin\alarm\controller\BwList');
+	// rfidWithBw路由
+	$router->resource('rfidWithBw', '\catchAdmin\alarm\controller\RfidWithBw');
 })->middleware('auth');
 
 $router->group('alarmReport', function () use ($router){
 	$router->get('getDetail/:id', '\catchAdmin\alarm\controller\AlarmReport@detail');
 	$router->get('totalGrowth', '\catchAdmin\alarm\controller\AlarmReport@totalGrowth');
+	
 })->middleware('auth');

+ 29 - 0
catch/yunying/controller/Vehicle.php

@@ -70,6 +70,35 @@ class Vehicle extends CatchController
         ];
         return $response;
     }
+    public function getRfidTagsList(Request $request) {
+        $param=$request->param();
+        //联表条件o.rfid_id = s.id and o.owner_id = r.id 
+        $cond=[];
+        if($param['RFID_SN']){
+            $cond['s.RFID_SN']=['like',$param['RFID_SN']];
+        }
+        $count=queryOracleCount('DSSC3.W_DW_RFID_TAGS s',$cond);
+        $cond['page']=isset($param['page'])?$param['page']:1;
+        $cond['limit']=isset($param['limit'])?$param['limit']:10;
+        // $rows=queryOracleSelect('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_NON_MOTOR_OWNER r,DSSC3.W_DW_RFID_TAGS s',$cond,'o.PLATE_NO,s.RFID_SN,r. NAME,r.ID_CARD_NUMBER,r.MOBILE_NUMBER,r.HOME_ADDRESS');
+        $rows=queryOracleSelect('DSSC3.W_DW_RFID_TAGS s',$cond,'s.ID,s.RFID_SN,s.RFID_TYPE');
+        foreach($rows as &$val){
+            // $val['CAR_BRAND_TEXT']=(new SysDictData())->getValueByCode('CAR_BRAND_OPTION',$val['CAR_BRAND']);
+            $val['RFID_TYPE_TEXT']=(new SysDictData())->getValueByCode('RFID_TYPE_OPTION',$val['RFID_TYPE']);
+            if( isset($param['bw_id']) && $param['bw_id'] ){
+                $val['isAdd']=Db::table('rfid_with_bw')->where('bw_id',$param['bw_id'])->where('rfid',$val['RFID_SN'])->count();
+            }
+        }
+        $response=[
+            'code'=>10000,
+            'message'=>'查询成功',
+            'count'=>$count,
+            'data'=>$rows,
+            'current'=>isset($param['page'])?(int)$param['page']:1,
+            'limit'=>isset($param['limit'])?(int)$param['limit']:10,
+        ];
+        return $response;
+    }
     // public function index(Request $request) 
     // {
     //     ini_set('memory_limit','3072M');

+ 1 - 0
catch/yunying/route.php

@@ -12,6 +12,7 @@
 // you should use `$router`
 $router->group(function () use ($router){
 	// vehicle路由
+	$router->get('vehicle/getRfidTagsList', '\catchAdmin\yunying\controller\Vehicle@getRfidTagsList');
 	$router->post('vehicle/importVehicle', '\catchAdmin\yunying\controller\Vehicle@importVehicle');
 	$router->resource('vehicle', '\catchAdmin\yunying\controller\Vehicle');