tongshanglei 2 years ago
parent
commit
9ee8e85af0

+ 9 - 1
catch/alarm/controller/ControlManage.php

@@ -62,7 +62,15 @@ class ControlManage extends CatchController
      */
     public function update(Request $request, $id) : \think\Response
     {
-        return CatchResponse::success($this->controlManageModel->updateBy($id, $request->post()));
+        $params=$request->post();
+        $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'];
+        }
+
+        return CatchResponse::success($this->controlManageModel->updateBy($id, $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_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' => '备注',])
             

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

@@ -26,6 +26,7 @@ class ControlManage extends Model
         'control_obj',
         // 区域类型
         'area_type',
+        'bw_type',
         'bw_ids',
         'revoke_time',
         'revoke_res',
@@ -47,7 +48,7 @@ class ControlManage extends Model
     {
         $res=$this->dataRange()
             ->catchSearch()
-            ->append(['type_text','rfid_type_text','state_text','timeRange'])
+            ->append(['type_text','rfid_type_text','state_text','timeRange','stations'])
             ->order($this->aliasField('id'), 'desc')
             ->paginate();
         return $res;
@@ -67,6 +68,10 @@ class ControlManage extends Model
         $state = $this->getData('state');
         return (new SysDictData())->getValueByCode('ControlStateEnum', $state) ?: '';
     }
+    public function getStationsAttr($value){
+        $obj = $this->getData('control_obj');
+        return $obj;
+    }
 
     public function getTypeTextAttr($value){
         $type = $this->getData('type');

+ 65 - 7
catch/device/controller/Station.php

@@ -80,18 +80,11 @@ class Station extends CatchController
      */
     public function getAllList(Request $request) 
     {
-
-        
- 
         $cond=[
             '_string'=>'a.DEVICE_CODE = r.DEVICE_CODE',
         ];
-            
-
         $cond['page']=1;
         $cond['limit']=3000;
-
-           
         $conn = null;
         $tableName='(SELECT * FROM DSSC2.ADM_DEV  ORDER BY ID DESC) a,DSSC2.ADM_DEV_RFID_CHN r';
         $field='a.ID,a.IS_ONLINE,a.LOGIN_NAME,a.DEVICE_CODE,a.DEVICE_NAME,a.OWNER_CODE,to_char(a.UPDATE_DATE,\'yyyy-mm-dd hh24:mi:ss\') UPDATE_DATE,r.GPS_X,r.GPS_Y';
@@ -111,6 +104,7 @@ class Station extends CatchController
         $end=$cond['page']*$cond['limit'];
         $whereStr=buildQueryCond2($cond);
         $sql='SELECT * FROM ( SELECT '.$field.',ROWNUM RN FROM '.$tableName.' WHERE ROWNUM <='.$end.' '.$whereStr.'  ) WHERE RN >'. $start;
+        // $sql='SELECT '.$field.' FROM '.$tableName.' WHERE  '.$whereStr;
         // var_dump($sql);
         // 查询并渲染
         $stid = oci_parse($conn, $sql);
@@ -138,6 +132,70 @@ class Station extends CatchController
           
        
     }
+    /**
+     * 所有列表给智能交通使用
+     * @time 2022年01月20日 10:09
+     * @param Request $request 
+     */
+    public function getAllListForTrans(Request $request) 
+    {
+        // $param=$request->param();
+        // $cond['page']=isset($param['page'])?$param['page']:1;
+        // $cond['limit']=isset($param['limit'])?$param['limit']:100;
+        $cond['page']=1;
+        $cond['limit']=30000;
+        $conn = null;
+        $tableName='(SELECT * FROM DSSC2.ADM_DEV  ORDER BY ID DESC) a';
+        $field='a.ID,a.LOGIN_NAME,a.DEVICE_CODE,a.DEVICE_NAME,a.OWNER_CODE';
+        $host=    Env::get('oracle.hostname',  '127.0.0.1');
+        $port=    Env::get('oracle.hostport',  '1521');
+        $instance_name=    Env::get('oracle.instance',  'ORCL');
+        $username=    Env::get('oracle.username',  'root');
+        $password=    Env::get('oracle.password',  'root');
+
+        // $count=queryOracleCount('DSSC2.ADM_DEV',$cond);
+        // $conn = oci_connect('用户名', '密码', '远程数据库名(eg.//192.168.1.133/orcl)');
+        $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);
+        }
+        $start=($cond['page']-1)*$cond['limit'];
+        $end=$cond['page']*$cond['limit'];
+        $whereStr=buildQueryCond2($cond);
+        $sql='SELECT * FROM ( SELECT '.$field.',ROWNUM RN FROM '.$tableName.' WHERE ROWNUM <='.$end.' '.$whereStr.'  ) WHERE RN >'. $start;
+        // var_dump($sql);
+        // 查询并渲染
+        $stid = oci_parse($conn, $sql);
+        $r = oci_execute($stid);
+        $rows=[];
+        while($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
+            $item=['key'=>$row['LOGIN_NAME'],'label'=>$row['DEVICE_NAME']];
+            $rows[]=$item;
+            
+            
+        }
+        oci_free_statement($stid);
+        // $response=[
+        //     'code'=>10000,
+        //     'message'=>'查询成功',
+        //     'count'=>$count,
+        //     'data'=>$rows,
+        //     'current'=>isset($param['page'])?(int)$param['page']:1,
+        //     'limit'=>isset($param['limit'])?(int)$param['limit']:100,
+        // ];
+        // return $response;
+        $response=[
+            'code'=>10000,
+            'message'=>'查询成功',
+            'data'=>$rows,
+        ];
+        return $response;
+            
+          
+       
+    }
      /**
      * 保存信息
      * @time 2022年01月20日 10:55

+ 1 - 0
catch/device/route.php

@@ -15,6 +15,7 @@ $router->group(function () use ($router) {
 	$router->resource('device', '\catchAdmin\device\controller\Device');
 	// station路由
 	$router->get('station/getdeviceListByStation','\catchAdmin\device\controller\Station@getdeviceListByStation');
+	$router->get('station/getAllListForTrans','\catchAdmin\device\controller\Station@getAllListForTrans');
 	$router->get('station/getAllList','\catchAdmin\device\controller\Station@getAllList');
 	//导入基站
 	$router->post('station/importStation', '\catchAdmin\device\controller\Station@importStation');

+ 5 - 2
catch/transport/controller/StuckPoint.php

@@ -33,7 +33,10 @@ class StuckPoint extends CatchController
      */
     public function save(Request $request) : \think\Response
     {
-        return CatchResponse::success($this->stuckPointModel->storeBy($request->post()));
+        $params=$request->post();
+        // var_dump($params);
+        $params['macs']=implode(',',$params['macs']);
+        return CatchResponse::success($this->stuckPointModel->storeBy($params));
     }
     
     /**
@@ -64,6 +67,6 @@ class StuckPoint extends CatchController
      */
     public function delete($id) : \think\Response
     {
-        return CatchResponse::success($this->stuckPointModel->deleteBy($id));
+        return CatchResponse::success($this->stuckPointModel->deleteBy($id,true));
     }
 }