tongshanglei 2 anos atrás
pai
commit
2a0d4eadc5

+ 44 - 18
app/common.php

@@ -6,7 +6,7 @@ use Aliyun\OTS\Consts\OperationTypeConst;
 use Aliyun\OTS\Consts\PrimaryKeyTypeConst;
 use Aliyun\OTS\Consts\RowExistenceExpectationConst;
 use Aliyun\OTS\OTSClient;
-use PDO;
+
     /**
      * 查询Gps股轨迹 表格存储
      */
@@ -1330,21 +1330,31 @@ use PDO;
         $username=    Env::get('oracle.username',  'root');
         $password=    Env::get('oracle.password',  'root');
            
-        $conn = new PDO("oci:dbname=//".$host.":".$port."/".$instance_name,$username,$password);// PDO方式
-        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-       
+        // $conn = new PDO("oci:dbname=//".$host.":".$port."/".$instance_name,$username,$password);// PDO方式
+        // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+        $conn = oci_connect($username, $password, $host.':'.$port.'/'. $instance_name,'AL32UTF8');
 
+        if (!$conn) {
+            $e = oci_error();
+            trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
+        }
         $sql='SELECT *  FROM  '.$tableName.' WHERE ';
         foreach($cond as $key=>$val){
             $sql .=$key.' '.$val[0].' '.$val[1];
         }
-        
-        $res= $conn -> query($sql)->fetch(PDO::FETCH_ASSOC);
-        if ($conn){
-            $conn = null;
+        // var_dump($sql);
+        // 查询并渲染
+        $stid = oci_parse($conn, $sql);
+        $r = oci_execute($stid);
+        $rows=[];
+        while($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
+            $rows[]=$row;
         }
-        // $response=[];
-        return $res;
+        
+        oci_free_statement($stid);
+        return $rows[0];
+        
     }
     /**
      * 查询oracle数据库 count
@@ -1359,20 +1369,36 @@ use PDO;
         $username=    Env::get('oracle.username',  'root');
         $password=    Env::get('oracle.password',  'root');
         
-        $conn = new PDO("oci:dbname=//".$host.":".$port."/".$instance_name,$username,$password);// PDO方式
-        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+        // $conn = new PDO("oci:dbname=//".$host.":".$port."/".$instance_name,$username,$password);// PDO方式
+        // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         // var_dump($cond);
        
+        // $whereStr=buildQueryCond($cond);
+        // $countQuery='SELECT count(*) as count FROM  '.$tableName.' '.$whereStr;
+        // // var_dump($countQuery);
+        // // return 1111;
+        // $countRes= $conn -> query($countQuery)->fetch(PDO::FETCH_ASSOC);
+
+        $conn = oci_connect($username, $password, $host.':'.$port.'/'. $instance_name,'AL32UTF8');
+
+        if (!$conn) {
+            $e = oci_error();
+            trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
+        }
         $whereStr=buildQueryCond($cond);
         $countQuery='SELECT count(*) as count FROM  '.$tableName.' '.$whereStr;
-        // var_dump($countQuery);
-        // return 1111;
-        $countRes= $conn -> query($countQuery)->fetch(PDO::FETCH_ASSOC);
+        // var_dump($sql);
+        // 查询并渲染
+        $stid = oci_parse($conn, $countQuery);
+        $r = oci_execute($stid);
+        $rows=[];
+        while($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
 
-        if ($conn){
-            $conn = null;
+            $rows[]=$row;
         }
-        return (int)$countRes['COUNT'];
+        // var_dump($rows);
+        oci_free_statement($stid);
+        return (int)$rows[0]['COUNT'];
     }
     
     function buildQueryCond($cond){

+ 1 - 1
catch/alarm/controller/BwList.php

@@ -64,6 +64,6 @@ class BwList extends CatchController
      */
     public function delete($id) : \think\Response
     {
-        return CatchResponse::success($this->bwListModel->deleteBy($id));
+        return CatchResponse::success($this->bwListModel->deleteBy($id,true));
     }
 }

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

@@ -37,6 +37,9 @@ class ControlManage extends CatchController
         $params['start_time']=strtotime($params['timeRange'][0]);
         $params['end_time']=strtotime($params['timeRange'][1]);
         $params['state']=1;
+        if($params['type']=='2'){
+            $params['control_obj']=$params['stations'];
+        }
         // var_dump($params);
         return CatchResponse::success($this->controlManageModel->storeBy($params));
     }

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

@@ -40,6 +40,7 @@ class ControlManage extends Migrator
 			->addColumn('phone', 'string', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => false,'comment' => '联系电话',])
 			->addColumn('control_obj', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '布控对象',])
             ->addColumn('area_type', 'string', ['limit' => 8,'null' => true,'signed' => true,'comment' => '区域类型',])
+            ->addColumn('bw_ids', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '名单ID',])
 			->addColumn('remark', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '备注',])
             
 			->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])

+ 4 - 1
catch/alarm/model/BwList.php

@@ -49,7 +49,10 @@ class BwList extends Model
     {
         return $query->where('name', 'like', '%' . $value . '%');
     }
-    
+    public function searchTypeAttr($query, $value, $data)
+    {
+        return $query->where('type',  $value );
+    }
     public function searchStateAttr($query, $value, $data)
     {
         return $query->where('state',  $value );

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

@@ -26,6 +26,7 @@ class ControlManage extends Model
         'control_obj',
         // 区域类型
         'area_type',
+        'bw_ids',
         'revoke_time',
         'revoke_res',
         'phone',

+ 1 - 1
catch/device/controller/Station.php

@@ -89,7 +89,7 @@ class Station extends CatchController
             
 
         $cond['page']=1;
-        $cond['limit']=1000;
+        $cond['limit']=3000;
 
            
         $conn = null;

+ 23 - 0
catch/transport/TransportService.php

@@ -0,0 +1,23 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+namespace catchAdmin\transport;
+
+use catcher\ModuleService;
+
+class TransportService extends ModuleService
+{
+    public function loadRouteFrom()
+    {
+        // TODO: Implement loadRouteFrom() method.
+        return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
+    }
+}

+ 69 - 0
catch/transport/controller/StuckPoint.php

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

+ 69 - 0
catch/transport/controller/StuckSection.php

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

+ 41 - 0
catch/transport/database/migrations/20221101161628_stuck_point.php

@@ -0,0 +1,41 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class StuckPoint 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('stuck_point', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '卡点' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('name', 'string', ['limit' => 128,'null' => true,'default' => '','signed' => true,'comment' => '名称',])
+			->addColumn('macs', 'string', ['limit' => 255,'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();
+    }
+}

+ 46 - 0
catch/transport/database/migrations/20221101162701_stuck_section.php

@@ -0,0 +1,46 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class StuckSection 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('stuck_section', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '卡点区间' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
+        $table->addColumn('name', 'string', ['limit' => 128,'null' => true,'signed' => true,'comment' => '名称',])
+			->addColumn('pre_spot', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '前置卡点',])
+			->addColumn('pos_spot', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '后置卡点',])
+			->addColumn('distance', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '区间长度',])
+			->addColumn('max_speed', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '最大限速(km/h)',])
+			->addColumn('retrograde_stat', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '启用逆行状态',])
+			->addColumn('over_speed_stat', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'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();
+    }
+}

+ 27 - 0
catch/transport/model/StuckPoint.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace catchAdmin\transport\model;
+
+use catcher\base\CatchModel as Model;
+
+class StuckPoint extends Model
+{
+    // 表名
+    public $name = 'stuck_point';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 名称
+        'name',
+        // 卡点基站
+        'macs',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+}

+ 37 - 0
catch/transport/model/StuckSection.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace catchAdmin\transport\model;
+
+use catcher\base\CatchModel as Model;
+
+class StuckSection extends Model
+{
+    // 表名
+    public $name = 'stuck_section';
+    // 数据库字段映射
+    public $field = array(
+        'id',
+        // 名称
+        'name',
+        // 前置卡点
+        'pre_spot',
+        // 后置卡点
+        'pos_spot',
+        // 区间长度
+        'distance',
+        // 最大限速(km/h)
+        'max_speed',
+        // 启用逆行状态
+        'retrograde_stat',
+        // 启用超速状态
+        'over_speed_stat',
+        // 创建人ID
+        'creator_id',
+        // 创建时间
+        'created_at',
+        // 更新时间
+        'updated_at',
+        // 软删除
+        'deleted_at',
+    );
+}

+ 15 - 0
catch/transport/module.json

@@ -0,0 +1,15 @@
+{
+    "name": "transport",
+    "alias": "transport",
+    "description": "智能交通",
+    "version": "1.0.0",
+    "keywords": ["transport"],
+    "order": 0,
+    "services": [
+        "\\catchAdmin\\transport\\TransportService"
+    ],
+    "aliases": {},
+    "files": [],
+    "requires": [],
+    "enable": true
+}

+ 18 - 0
catch/transport/route.php

@@ -0,0 +1,18 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+// you should use `$router`
+$router->group(function () use ($router){
+	// stuckPoint路由
+	$router->resource('stuckPoint', '\catchAdmin\transport\controller\StuckPoint');
+	// stuckSection路由
+	$router->resource('stuckSection', '\catchAdmin\transport\controller\StuckSection');
+})->middleware('auth');