tongshanglei 2 년 전
부모
커밋
0e527eaa4c
1개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 11 7
      catch/yunying/controller/Vehicle.php

+ 11 - 7
catch/yunying/controller/Vehicle.php

@@ -374,10 +374,14 @@ class Vehicle extends CatchController
                 INSERT INTO DSSC3.W_DW_NON_MOTOR("ID", "RFID_ID","PLATE_NO","CAR_BRAND","CAR_TYPE") VALUES (DSSC3.SEQ_W_DW_RFID_TAGS.nextval, tagId,:col4,:col5,:col6);
             end;';
             $stmt = oci_parse($conn, $sql);
-            $start=2;
             for ($j = 2; $j <= $highestRow; $j++) {
                 $arr = array(); //每条设备信息
                 $arr['PLATE_NO'] = strtoupper(trim($sheet->getCell("A" . $j)->getFormattedValue())); 
+                if(empty($arr['PLATE_NO']) ||  strlen($str)!=13){
+                    $fail++;
+                    debug_log('importVehicleError','车牌格式不正确,车牌号为:'.$arr['PLATE_NO']);
+                    continue;
+                }
                 $brand = trim($sheet->getCell("B" . $j)->getFormattedValue());  
                 $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';
@@ -386,6 +390,11 @@ class Vehicle extends CatchController
                 $car_type=Db::table("sys_dict_data")->where('type_id', $car_type_id)->whereLike('value','%'.$type.'%')->cache(60)->value('code');
                 $arr['CAR_TYPE']=$car_type?$car_type:'4';
                 $arr['RFID_SN'] = trim($sheet->getCell("D" . $j)->getFormattedValue());  
+                if(empty($arr['RFID_SN']) ||  strlen($str)!=8){
+                    $fail++;
+                    debug_log('importVehicleError','标签格式格式不正确,标签为:'.$arr['RFID_SN']);
+                    continue;
+                }
                 $arr['INSTA_DATE'] = trim($sheet->getCell("E" . $j)->getFormattedValue());  
                 $arr['INSTALLER'] = trim($sheet->getCell("F" . $j)->getFormattedValue()); 
 
@@ -402,15 +411,10 @@ class Vehicle extends CatchController
 
                 $arr['DATA_TYPE']='vehicle_save';
                 pushDataToRedisList($arr);
+                $success++;
                 if( ($j%1000 == 0) || $j==$highestRow){
                     // 提交事务
                     $res=oci_commit($conn);
-                    if($res){
-                        $success+=$j-$start;
-                    }else{
-                        $fail+=$j-$start;
-                    }
-                    $start=$j;
                 }
                 
             }