tongshanglei 2 년 전
부모
커밋
674ed0ee87
4개의 변경된 파일59개의 추가작업 그리고 11개의 파일을 삭제
  1. 1 1
      app/common.php
  2. 52 9
      catch/yunying/controller/Vehicle.php
  3. 3 0
      catch/yunying/model/Vehicle.php
  4. 3 1
      public/cli.php

+ 1 - 1
app/common.php

@@ -1283,7 +1283,7 @@ use PDO;
         $end=$cond['page']*$cond['limit'];
         $whereStr=buildQueryCond2($cond);
         // $sql = 'SELECT * FROM ( SELECT '.$field.',ROWNUM RN FROM (SELECT * FROM '.$tableName.' '.$whereStr.' ORDER BY ID DESC) a WHERE ROWNUM <='.$end.' ) WHERE RN >='. $start;
-        $sql='SELECT * FROM ( SELECT '.$field.',ROWNUM RN FROM '.$tableName.' WHERE ROWNUM <='.$end.' '.$whereStr.'  ) WHERE RN >='. $start;
+        $sql='SELECT * FROM ( SELECT '.$field.',ROWNUM RN FROM '.$tableName.' WHERE ROWNUM <='.$end.' '.$whereStr.'  ) WHERE RN >'. $start;
         // var_dump($sql);
         // 查询并渲染
         $stid = oci_parse($conn, $sql);

+ 52 - 9
catch/yunying/controller/Vehicle.php

@@ -70,7 +70,44 @@ class Vehicle extends CatchController
         ];
         return $response;
     }
-    
+    // public function index(Request $request) 
+    // {
+    //     ini_set('memory_limit','3072M');
+    //     set_time_limit(0);
+    //     $cond=[
+    //         '_string'=>'o.rfid_id = s.id',
+    //     ];
+    //     // $count=queryOracleCount('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_NON_MOTOR_OWNER r,DSSC3.W_DW_RFID_TAGS s',$cond);
+    //     $count=queryOracleCount('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_RFID_TAGS s',$cond);
+    //     $to=ceil($count/10000);
+    //     var_dump($to);
+    //     for($i=1;$i<=$to;$i++){
+    //         var_dump($i);
+    //         $cond['page']=$i;
+    //         $cond['limit']=10000;
+    //         // $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_NON_MOTOR o,DSSC3.W_DW_RFID_TAGS s',$cond,'o.PLATE_NO,o.CAR_TYPE,o.CAR_BRAND,s.ID,s.RFID_SN,s.INSTALLER,to_char(s.INSTA_DATE,\'yyyy-mm-dd hh24:mi:ss\') INSTA_DATE');
+    //         // var_dump(count($rows));
+    //         $data=[];
+    //         foreach($rows as &$val){
+    //             $item=array(
+    //                 'license_plate'=>$val['PLATE_NO'],
+    //                 'car_type'=>$val['CAR_TYPE'],
+    //                 'brand_id'=>(int)$val['CAR_BRAND'],
+    //                 'rfid_sn'=>$val['RFID_SN'],
+    //                 'installer'=>$val['INSTALLER'],
+    //                 'license_time'=>$val['INSTA_DATE'],
+    //             );
+    //             array_push($data,$item);
+    //         }
+
+            
+    //         $success = Db::table('vehicles')->limit(1000)->insertAll($data);
+    //         var_dump($success);
+    //     }
+ 
+       
+    // }
 
     /**
      * 保存信息
@@ -210,24 +247,29 @@ class Vehicle extends CatchController
         //             ->where('code', $value)
         //             ->cache(true, 60)
         //             ->value('remark');
+
+        $r=$this->execSaveVehicle($param);
             $total += $highestRow - 1;
             for ($j = 2; $j <= $highestRow; $j++) {
                 $arr = array(); //每条设备信息
                 $arr['PLATE_NO'] = strtoupper(trim($sheet->getCell("A" . $j)->getFormattedValue())); 
                 $brand = trim($sheet->getCell("B" . $j)->getFormattedValue());  
-
-                // $brand_id=Db::table("sys_dict_data")->where('type_id', $type_id)->where('code', $value)->value('remark');
+                $brand_id=Db::table("sys_dict_data")->where('type_id', $brand_type_id)->whereLike('value','%'.$brand.'%')->cache(60)->value('code');
+                $arr['CAR_BRAND']=$brand_id?$brand_id:'99';
+                
                 $type = trim($sheet->getCell("C" . $j)->getFormattedValue());  
+                $car_type=Db::table("sys_dict_data")->where('type_id', $car_type_id)->whereLike('value','%'.$type.'%')->cache(60)->value('code');
+                $arr['CAR_BRAND']=$car_type?$car_type:'4';
                 $arr['RFID_SN'] = trim($sheet->getCell("D" . $j)->getFormattedValue());  
                 $arr['INSTA_DATE'] = trim($sheet->getCell("E" . $j)->getFormattedValue());  
                 $arr['INSTALLER'] = trim($sheet->getCell("F" . $j)->getFormattedValue()); 
                 var_dump($arr);
-                // $r=$this->execSaveStation($arr);
-                // if($r){
-                //     $success++;
-                // }else{
-                //     $fail++;
-                // }
+                $r=$this->execSaveStation($arr);
+                if($r){
+                    $success++;
+                }else{
+                    $fail++;
+                }
                 // var_dump($arr);
             //    array_push($data,$arr);
             }
@@ -242,4 +284,5 @@ class Vehicle extends CatchController
         // }
         // return CatchResponse::success(['error' => true, 'msg' => '导入失败']);
     }
+    
 }

+ 3 - 0
catch/yunying/model/Vehicle.php

@@ -35,6 +35,9 @@ class Vehicle extends Model
         'brand_id',
         // 车辆颜色
         'color_id',
+        'car_type',
+        'rfid_sn',
+        'installer',
         // 备注
         'remark',
         // 购车日期

+ 3 - 1
public/cli.php

@@ -15,7 +15,9 @@ namespace think;
 $path = '/'.$argv[1];
 $_GET['s'] = $_SERVER['s'] = $_SERVER['REQUEST_URI'] = $path;
 
-
+if('s='.$path !== $_SERVER["QUERY_STRING"]){
+header("Location: {$path}");
+}
 require __DIR__ . '/../vendor/autoload.php';
 
 // 执行HTTP应用并响应