Explorar o código

修复:无效数据丢掉

git %!s(int64=5) %!d(string=hai) anos
pai
achega
953b3e575a
Modificáronse 1 ficheiros con 24 adicións e 54 borrados
  1. 24 54
      Home/Lib/Action/CronAction.class.php

+ 24 - 54
Home/Lib/Action/CronAction.class.php

@@ -76,8 +76,6 @@ class CronAction extends Action {
 				continue;
 			}
 		
-			//$data = json_decode($data, true);
-			//$fileName = 'gravatar.jpg';//TEST
 			$fileName = $data['localPath'];
 			$licensPlate = $data['licensePlate'];
 			if(!$licensPlate || !$fileName){
@@ -85,13 +83,6 @@ class CronAction extends Action {
 				echo 'fileName:'.$fileName.PHP_EOL;
 				echo 'licensPlate:'.$licensPlate.PHP_EOL;
 				echo '---------------delimiter----------------'.PHP_EOL;
-				
-				$result = $plateLocalPath->add($data);
-				if(!$result){
-					echo 'plateLocalPath->add() failed,$licensPlate = '. $data['licensPlate'] .PHP_EOL;
-					continue;
-				}
-				sleep(1);
 				continue;
 			}
 			//上传至oss
@@ -110,24 +101,21 @@ class CronAction extends Action {
 			
 			$frontImageUrl = $uploadRes['objectname'];
 			if(!$frontImageUrl){
-				echo 'cant get img_oss_url';
+				echo 'cant get img_oss_url'.PHP_EOL;
 				continue;
-			}else{
-				echo 'return oss-url:'.$frontImageUrl.PHP_EOL;
 			}
-			
+			echo 'return oss-url:'.$frontImageUrl.PHP_EOL;
 		
 			$updateRes = M('jms_vehicle')->where(array('LicensePlate' => $licensPlate))->setField('FrontElectronicPlateUrl',$frontImageUrl);
 			if(!$updateRes){
 				echo 'save electricPlate in mysql failed'.PHP_EOL;
 				continue;
-			}else{
-				echo 'save electricPlate in mysql success'.PHP_EOL;
 			}
+			echo 'save electricPlate in mysql success'.PHP_EOL;
 			
 			//删除本地图片
 			$filePath = $filename;
-			if(file_exists(!$filePath)){
+			if(!file_exists($filePath)){
 				$flag = unlink($filePath);
 				if(!$flag){
 					echo 'delete localImg failed'.PHP_EOL;
@@ -135,44 +123,9 @@ class CronAction extends Action {
 					echo 'delete localImg success'.PHP_EOL;
 				}
 			}
-			sleep(1);
+			usleep(100000);
 		}
 		
-		
-		/*
-			$licensPlate = $pendingElectricPlate->pop();
-			if(!$licensPlate){
-				echo 'no message!'.PHP_EOL;
-				sleep(1);
-				continue;
-			}
-			echo 'pop licensPlate:'.$licensPlate.PHP_EOL;
-			$field = 'LicensePlate,VehicleColor, FullName, Address, FrameNumber, MotorNumber, VehicleBrand, RegistrationTime';
-			$vehicleInfo = M('jms_vehicle')->where(array('LicensePlate' => $licensPlate))->field($field)->find();
-			if(!$vehicleInfo){
-				echo 'vehicleInfo not existed,$licensPlate = '.$licensPlate .PHP_EOL;
-				continue;
-			}
-			//生成电子车牌到本地
-			$localPath = $this->createLocalElectronicPlate($vehicleInfo);
-			if(!$localPath){
-				echo 'createLocalElectronicPlate failed,$licensPlate = '.$licensPlate .PHP_EOL;
-				//生成失败的重新放回队列
-				$result = $pendingElectricPlate->add($licensPlate);
-				if(!$result){
-					echo 'pendingElectricPlate->add() failed,$licensPlate = '.$licensPlate .PHP_EOL;
-					continue;
-				}
-			}
-			//生成的本地电子车牌,加入到待上传oss队列
-			$up2ossWait = json_encode(array('LicensePlate' => $licensPlate, 'localPath' => $localPath));
-			$reslut = $plateLocalPath->add($up2ossWait);//push方法没有返回值,用add代替
-			if(!$result){
-				echo 'plateLocalPath->add() failed,$licensPlate = '.$licensPlate .PHP_EOL;
-				continue;
-			}
-			usleep(100000);
-		*/
 	}
 	
  
@@ -337,6 +290,7 @@ class CronAction extends Action {
 	
  
 	public  function mockProduce(  ){
+		/* // jyzl gps
 		$msg_data = array(
 			'DeviceId' => FFFFFF123122,
 			'State' => 1,
@@ -347,8 +301,24 @@ class CronAction extends Action {
 			'LBS' => 'LBS',
 			'Direction' => 's',
 		);
-		$msg_data = json_encode($msg_data, JSON_UNESCAPED_UNICODE);
-		kafkaProducer('gps_location_data',$msg_data);
+		kafkaProducer('gps_location_data',$msg_data);*/
+		
+		// fly 轨迹数据
+		$msg_data = array(
+			'StationCode' => '860588041560932',
+			'StationType' => 0,
+			"CityId" => "1018",
+			"StationName" => "测试基站2",
+			"Longitude" => "114.251604",
+			"Latitude" => "22.725217",
+			"Address" => "建设大厦",
+			"AddTime" => "2019-05-16 22:40:01",
+			"VehicleNumber" => "8000000009",
+			"VehicleStatus" =>  "1",
+		   "SignalCount" => 88,
+			"OnlineTime" => "2019-05-16 22:40:01"
+		);
+		kafkaProducer('fly_vroute_data',$msg_data);
 	}