123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- class CronAction extends Action {
-
-
- public function createEplate_index( ){
- $this->createElectronicPlate();
- }
-
-
- private function createElectronicPlate( ){
- $start = time();
- $pendingElectricPlate = Redis('jyzl_wait_create_eplate');
- $plateLocalPath = Redis('jyzl_wait_upload2oss_eplate', 'queue');
- while( (time() - $start) < 60 ){
- $licensPlate = $pendingElectricPlate->pop();
- if($licensPlate){
- echo 'pop licensPlate:'.$licensPlate.PHP_EOL;
- $field = 'LicensPlate,VehicleColor, FullName, Address, FrameNumber, MotorNumber, VehicleBrand';
- $vehicleInfo = M('jms_vehicle')->where('LicensPlate' => $licensPlate)->field($field);
- $localPath = '生成函数';
- $up2ossWait = json_encode(array('licensPlate' => $licensPlate, 'localPath' => $localPath));
- $plateLocalPath->push($up2ossWait);
- }
- sleep(1);
- }
- }
-
-
- private function uploadElectronicPlate2Oss( ){
- $config = array(
- 'OssDsn' => C('OSS_DSN'),
- 'filePathDir' => '/data/wwwroot/czapp.rltest.cn/1.0.0//uploadimage/',
- "SaveRule" => "/electronic_plate/{Y}{m}{d}/{uid}.{ext}",
- "AllowExts" => array('jpg', 'png', 'jpeg'), // 允许上传的文件后缀(留空为不限制)
- "ResizeImage" => true, // 是否自动压缩
- "MaxImageWidth" => 1024,
- "MaxImageHeight" => 1024,
- "IsCheckRgb" => true,
- "MinImgAverageRgb" => 70
- );
- $upload = new \Jms\File\Oss2($config);
-
- $start = time();
- $plateLocalPath = Redis('jyzl_wait_upload2oss_eplate');
- while( (time() - $start) < 60 ){
- $data = $plateLocalPath->pop();
- var_dump($data);
- json_decode($data,true);
- var_dump($data);
- if($data){
- //TEST
- $fileName = 'gravatar.jpg';
- //$fileName = $data['localPath'];
- $uploadRes = $upload->localFileUpload($fileName);
- if(!$uploadRes['success']){
- echo $uploadRes['message'].PHP_EOL;
- continue;
- }
- $frontImageUrl = $uploadRes['objectname'];
-
- $updateRes = M('jms_vehicle')->where(array('LicensePlate' => $data['licensPlate']))->setField('FrontElectronicPlateUrl',$frontImageUrl);
- if(!$updateRes){
- echo 'update failed'.PHP_EOL;
- continue;
- }
- if(file_exists($filename)){
- unlink($filename);
- }
- }
- sleep(1);
- }
- }
-
-
- public function uploadEplate_index( ){
- $this->uploadElectronicPlate2Oss();
- }
-
-
- public function test_function( ){
- $plate = 'BJ000100';
- $pendingElectricPlate = Redis("jyzl_wait_create_eplate","queue");
- $licensePlate = $plate;
- $pendingElectricPlate->push($licensePlate);
-
- }
-
-
- public function acrossAlarm2Kafka( ){
- // 从 topic :gps_location_data 取轨迹
-
- // 存入 topic:gps_alarm_msg_queue
- }
-
- }
|