You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8369 lines
319 KiB
8369 lines
319 KiB
5 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by PhpStorm.
|
||
|
* User: zengchaoxin
|
||
|
* Date: 16/5/20
|
||
|
* Time: 下午2:16
|
||
|
*/
|
||
|
namespace console\controllers;
|
||
|
|
||
|
use common\libs\MyLib;
|
||
|
use common\models\AppointmentHistoryT;
|
||
|
use common\models\AppointmentT;
|
||
|
use common\models\Brand2T;
|
||
|
use common\models\BrandT;
|
||
|
use common\models\CaiwuT;
|
||
|
use common\models\Car2T;
|
||
|
use common\models\CarBT;
|
||
|
use common\models\CarCT;
|
||
|
use common\models\CarDT;
|
||
|
use common\models\CarET;
|
||
|
use common\models\CarFT;
|
||
|
use common\models\CarF4T;
|
||
|
use common\models\CarGiftT;
|
||
|
use common\models\CarInvalidT;
|
||
|
use common\models\CarLogT;
|
||
|
use common\models\CarOldT;
|
||
|
use common\models\CarT;
|
||
|
use common\models\CarTypeT;
|
||
|
use common\models\CarUseT;
|
||
|
use common\models\CityT;
|
||
|
use common\models\CarCount;
|
||
|
use common\models\Displacement2T;
|
||
|
use common\models\DisplacementT;
|
||
|
use common\models\DistrictT;
|
||
|
use common\models\EmsT;
|
||
|
use common\models\FactoryT;
|
||
|
use common\models\GiftT;
|
||
|
use common\models\GroupT;
|
||
|
use common\models\ImportLogT;
|
||
|
use common\models\InvalidT;
|
||
|
use common\models\LinkmanT;
|
||
|
use common\models\ModelT;
|
||
|
use common\models\Order2T;
|
||
|
use common\models\OrderCaiwuT;
|
||
|
use common\models\OrderGiftT;
|
||
|
use common\models\OrderT;
|
||
|
use common\models\PayOrderUserT;
|
||
|
use common\models\PayT;
|
||
|
use common\models\PayTypeT;
|
||
|
use common\models\PeerPhoneT;
|
||
|
use common\models\PiccCarT;
|
||
|
use common\models\PriceT;
|
||
|
use common\models\Series2T;
|
||
|
use common\models\SeriesT;
|
||
|
use common\models\TmpCarT;
|
||
|
use common\models\TestX;
|
||
|
use common\models\UserT;
|
||
|
use common\models\YearT;
|
||
|
use Yii;
|
||
|
use yii\console\Controller;
|
||
|
use yii\web\User;
|
||
|
|
||
|
class TestController extends Controller
|
||
|
{
|
||
|
|
||
|
protected $mname='300xubao.xlsx';
|
||
|
//查找库里的数据-总共有多少续保的
|
||
|
public function actionCounts(){
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$yearnam='order-ku';
|
||
|
$filename = $file_path.$yearnam.'.xlsx';
|
||
|
$base_filename=$yearnam.'.xlsx';
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $indexs = 1;
|
||
|
// $insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,'车牌号');
|
||
|
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
|
||
|
$car_no = trim(sprintf("%s",$item[0]));
|
||
|
$id_man = sprintf("%s",$item[1]);
|
||
|
if($car_no==''){
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
echo $car_no."...";
|
||
|
echo $id_man."...";
|
||
|
|
||
|
|
||
|
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
|
||
|
if($car_info) {
|
||
|
|
||
|
$carcounts= CarCount::findOne(['car_no'=>$car_no]);
|
||
|
if($carcounts){
|
||
|
$carcounts->num=$carcounts->num+1;
|
||
|
if(!$carcounts->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
}else{
|
||
|
$car_count = new CarCount();
|
||
|
$car_count->car_no = $car_no;
|
||
|
$car_count->id_man = $id_man;
|
||
|
$car_count->num = 1;
|
||
|
$car_count->location = $car_info->location;
|
||
|
if(!$car_count->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('yilou2.xlsx');
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
//开始从2017年之前的数据和2017.3 月份之后的保单数据 进行导入c库
|
||
|
public function actionCountCku(){
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$yearnam='order-ku';
|
||
|
$filename = $file_path.$yearnam.'.xlsx';
|
||
|
$base_filename=$yearnam.'.xlsx';
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $indexs = 1;
|
||
|
// $insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,'车牌号');
|
||
|
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
|
||
|
$car_no = trim(sprintf("%s",$item[0]));
|
||
|
|
||
|
if($car_no==''){
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
echo $car_no."...";
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
|
||
|
|
||
|
if($car_info) {
|
||
|
if($car_info->location==2){
|
||
|
CarBT::deleteAll(['id'=>$car_info->id]);
|
||
|
}elseif($car_info->location==5){
|
||
|
CarInvalidT::deleteAll(['id'=>$car_info->id]);
|
||
|
}elseif($car_info->location==7){
|
||
|
CarFT::deleteAll(['id'=>$car_info->id]);
|
||
|
}
|
||
|
$kname=$car_info->getLocation();
|
||
|
$car_info->xubao_num=$car_info->xubao_num+1;
|
||
|
//在d库和e库
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);//3
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);//4
|
||
|
$car_e_info = CarET::findOne(['id'=>$car_info->id]);//6
|
||
|
if($car_c_info || $car_d_info || $car_e_info ){
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$car_info->location=3;
|
||
|
|
||
|
// echo $kname;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
$c_info = new CarCT();
|
||
|
$c_info->id = $car_info->id;
|
||
|
$c_info->user_id = 0;
|
||
|
$c_info->save();
|
||
|
$this->addLog($car_info->id,'从'.$kname.'分配到C库',1);
|
||
|
$insert_total++;
|
||
|
;
|
||
|
}
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('yilou2.xlsx');
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//处理xx
|
||
|
public function actionFan()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$yearnam=$this->mname;
|
||
|
$filename = $file_path.$yearnam;
|
||
|
$base_filename=$yearnam;
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $indexs = 1;
|
||
|
// $insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,'车牌号');
|
||
|
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$register_date = sprintf("%s",$item[2]);
|
||
|
$engine_no = sprintf("%s",$item[3]);
|
||
|
$car_frame_no = sprintf("%s",$item[4]);
|
||
|
$company = sprintf("%s",$item[5]);
|
||
|
$insurer1_date = sprintf("%s",$item[6]);
|
||
|
$insurer2_date = sprintf("%s",$item[6]);
|
||
|
$car_no= trim($car_no);
|
||
|
|
||
|
if($car_no == '') {
|
||
|
// echo "\r\n";
|
||
|
$car_no = '京xxxxxx';
|
||
|
// continue;
|
||
|
}
|
||
|
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
|
||
|
// $tmp_date = explode('-',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
// echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
//排除京牌xxx
|
||
|
// CarT::find()->where('car_no= $car_no')
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
|
||
|
if($car_info) {
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_e_info = CarET::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_e_info|| $car_w_info ){
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->phone = '';
|
||
|
$car_info->factory_model = '';
|
||
|
$car_info->register_date =$register_date ;
|
||
|
// $car_info->from_src = 'oldxubao';
|
||
|
$car_info->biaozhu = 2019417;
|
||
|
// echo 'insert...'.$car_info->id.'...';
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
// continue;
|
||
|
// $indexs++;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,$car_no);
|
||
|
// $insert_total++;
|
||
|
}else{
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
// $car_info->from_src ='oldxubao';
|
||
|
$car_info->biaozhu = 2019417;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
|
||
|
// $car_info->company = $company;
|
||
|
// $car_info->insurer1_date = $insurer1_date;
|
||
|
// $car_info->insurer2_date = $insurer2_date;
|
||
|
// $car_info->id_man = $id_man;
|
||
|
// $car_info->id_number = $id_number;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('yilou2.xlsx');
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
|
||
|
}
|
||
|
//10-30 批量导入数据
|
||
|
public function actionCarinfos1030()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$yearnam=$this->mname;
|
||
|
|
||
|
$filename = $file_path.$yearnam;
|
||
|
$base_filename=$yearnam;
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $indexs = 1;
|
||
|
// $insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,'车牌号');
|
||
|
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
$engine_no = sprintf("%s",$item[3]);
|
||
|
$car_frame_no = sprintf("%s",$item[4]);
|
||
|
$register_date = sprintf("%s",$item[5]);
|
||
|
$company = sprintf("%s",$item[6]);
|
||
|
$insurer1_date = sprintf("%s",$item[7]);
|
||
|
$insurer2_date = sprintf("%s",$item[8]);
|
||
|
$id_man = sprintf("%s",$item[9]);
|
||
|
$id_number = sprintf("%s",$item[10]);
|
||
|
$car_no= trim($car_no);
|
||
|
|
||
|
if($car_no == '') {
|
||
|
// echo "\r\n";
|
||
|
$car_no = '京xxxxxx';
|
||
|
// continue;
|
||
|
}
|
||
|
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
echo $register_date.'...';
|
||
|
// $tmp_date = explode('-',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
// echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
//排除京牌xxx
|
||
|
// CarT::find()->where('car_no= $car_no')
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
|
||
|
if($car_info) {
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_e_info = CarET::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_e_info|| $car_w_info ){
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
// echo 'insert...'.$car_info->id.'...';
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
// continue;
|
||
|
// $indexs++;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,$car_no);
|
||
|
// $insert_total++;
|
||
|
}else{
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('yilou2.xlsx');
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
public function actionCarinfos10301()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$yearnam=$this->mname;
|
||
|
$filename = $file_path.$yearnam;
|
||
|
$base_filename=$yearnam;
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $indexs = 1;
|
||
|
// $insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,'车牌号');
|
||
|
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
$engine_no = sprintf("%s",$item[3]);
|
||
|
$car_frame_no = sprintf("%s",$item[4]);
|
||
|
$register_date = sprintf("%s",$item[5]);
|
||
|
$company = sprintf("%s",$item[6]);
|
||
|
$insurer1_date = sprintf("%s",$item[7]);
|
||
|
$insurer2_date = sprintf("%s",$item[8]);
|
||
|
$id_man = sprintf("%s",$item[9]);
|
||
|
$id_number = sprintf("%s",$item[10]);
|
||
|
$car_no= trim($car_no);
|
||
|
|
||
|
if($car_no == '') {
|
||
|
// echo "\r\n";
|
||
|
$car_no = '京xxxxxx';
|
||
|
// continue;
|
||
|
}
|
||
|
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
echo $register_date.'...';
|
||
|
// $tmp_date = explode('-',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
// echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
//排除京牌xxx
|
||
|
// CarT::find()->where('car_no= $car_no')
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
|
||
|
if($car_info) {
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_e_info = CarET::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_e_info|| $car_w_info ){
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
|
||
|
// echo 'insert...'.$car_info->id.'...';
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
// continue;
|
||
|
// $indexs++;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$indexs,$car_no);
|
||
|
// $insert_total++;
|
||
|
}else{
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
// $car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
|
||
|
// $car_info->id_man = $id_man;
|
||
|
// $car_info->id_number = $id_number;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('yilou2.xlsx');
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
|
||
|
}
|
||
|
public function actionChuli44()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$yearname='wash12.xlsx';
|
||
|
$filename = $file_path.$yearname;
|
||
|
$basename=$yearname;
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $index = 1;
|
||
|
$insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车架号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'发动机号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'品牌车型');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车主');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'证件号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'联系方式');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'保险到期日');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'标准初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'车牌号不匹配');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
echo $i.'/'.$rowCount."...";
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
$car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
|
||
|
// if($car_info){
|
||
|
// $resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
// $resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
// $insert_total++;
|
||
|
// }
|
||
|
if($car_info){
|
||
|
|
||
|
if($car_info->phone!=''&& $phone!=$car_info->phone){
|
||
|
$car_info->phone1 =(string) $phone;
|
||
|
}else{
|
||
|
$car_info->phone=$phone;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_e_info = CarET::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
if($car_c_info || $car_d_info || $car_e_info|| $car_w_info ){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->save();
|
||
|
$insert_total++;
|
||
|
}
|
||
|
|
||
|
if(!$car_info){
|
||
|
$car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
if($car_infos){
|
||
|
if($car_infos->phone!=''&& $phone!=$car_infos->phone){
|
||
|
$car_infos->phone1 =(string) $phone;
|
||
|
}else{
|
||
|
$car_infos->phone=$phone;
|
||
|
}
|
||
|
$car_infos->save();
|
||
|
$insert_total++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// $index++;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_frame_no);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$engine_no);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$factory_model);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_man);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car_man_number);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$phone);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$register_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt?$resgt:'');
|
||
|
// if(!$car_info){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
// }
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('simple6.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = $basename;
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
//批量导入新车辆数据
|
||
|
public function actionCarinfos()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
|
||
|
$base_filename=$this->mname;
|
||
|
$filename = $file_path.$base_filename;
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
$engine_no = sprintf("%s",$item[3]);
|
||
|
$car_frame_no = sprintf("%s",$item[4]);
|
||
|
$register_date = sprintf("%s",$item[5]);
|
||
|
$company = sprintf("%s",$item[6]);
|
||
|
$insurer1_date = sprintf("%s",$item[7]);
|
||
|
$insurer2_date = sprintf("%s",$item[7]);
|
||
|
$id_man = sprintf("%s",$item[9]);
|
||
|
$id_number = sprintf("%s",$item[10]);
|
||
|
$car_no= trim($car_no);
|
||
|
|
||
|
if($car_no == '') {
|
||
|
// echo "\r\n";
|
||
|
$car_no = '京xxxxxx';
|
||
|
// continue;
|
||
|
}
|
||
|
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
echo $register_date.'...';
|
||
|
// $tmp_date = explode('-',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
// echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
//排除京牌xxx
|
||
|
// CarT::find()->where('car_no= $car_no')
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// $car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
// $car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
//
|
||
|
// if($car_c_info || $car_d_info || $car_w_info ){
|
||
|
// continue;
|
||
|
// }
|
||
|
if(isset($car_info)) {
|
||
|
|
||
|
if($car_info->car_no!='京xxxxxx'){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
|
||
|
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo 'insert...'.$car_info->id.'...';
|
||
|
}
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
public function actionCarinfos1()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'car_t_2-1.xlsx';
|
||
|
$base_filename='car_t_2-1.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
// if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_frame_no = sprintf("%s",$item[1]);
|
||
|
$engine_no = sprintf("%s",$item[2]);
|
||
|
$factory_model = sprintf("%s",$item[3]);
|
||
|
$car_man= sprintf("%s",$item[4]);
|
||
|
$car_man_number= sprintf("%s",$item[5]);
|
||
|
$phone = sprintf("%s",$item[6]);
|
||
|
$insurer1_date = sprintf("%s",$item[7]);
|
||
|
$insurer2_date = sprintf("%s",$item[7]);
|
||
|
|
||
|
$car_no= trim($car_no);
|
||
|
|
||
|
|
||
|
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
|
||
|
// $tmp_date = explode('-',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
// echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
//排除京牌xxx
|
||
|
// CarT::find()->where('car_no= $car_no')
|
||
|
$car_info = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
if(isset($car_info)) {
|
||
|
|
||
|
continue;
|
||
|
|
||
|
} else {
|
||
|
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->car_man_number = $car_man_number;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo 'insert...'.$car_info->id.'...';
|
||
|
}
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
//查找保单的数据导出excel
|
||
|
public function actionOrderOutput()
|
||
|
{
|
||
|
|
||
|
$query = OrderT::find()
|
||
|
->where('status_id=10');
|
||
|
|
||
|
|
||
|
$objectPHPExcel = new \PHPExcel();
|
||
|
$index = 1;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'被保险人');
|
||
|
|
||
|
foreach($query->each() as $item) {
|
||
|
$index++;
|
||
|
// $cars = $item->car;
|
||
|
echo $item->car_no;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$item->car_no);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$item->car_id);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$item->id_man);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$cars?$cars->location:'');
|
||
|
|
||
|
}
|
||
|
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
|
||
|
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
$objWriter->save('order-ku.xlsx');
|
||
|
|
||
|
}
|
||
|
//查找2015
|
||
|
public function actionCarinfos2015()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'teshu.xlsx';
|
||
|
$base_filename='teshu.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
$engine_no = sprintf("%s",$item[3]);
|
||
|
$car_frame_no = sprintf("%s",$item[4]);
|
||
|
$register_date = sprintf("%s",$item[5]);
|
||
|
$company = sprintf("%s",$item[6]);
|
||
|
$insurer1_date = sprintf("%s",$item[7]);
|
||
|
$insurer2_date = sprintf("%s",$item[7]);
|
||
|
$id_man = sprintf("%s",$item[9]);
|
||
|
$id_number = sprintf("%s",$item[10]);
|
||
|
|
||
|
|
||
|
// if($car_no == '') {
|
||
|
//// echo "\r\n";
|
||
|
// $car_no = '京xxxxxx';
|
||
|
//// continue;
|
||
|
// }
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
echo $register_date.'...';
|
||
|
// $tmp_date = explode('-',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
// echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
//排除京牌xxx
|
||
|
$year= (int)substr($register_date,0,4);
|
||
|
// echo $year;
|
||
|
// die;
|
||
|
if($year==2015){
|
||
|
$insert_total++;
|
||
|
}
|
||
|
// CarT::find()->where('car_no= $car_no')
|
||
|
// $car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
// if(isset($car_info)) {
|
||
|
//
|
||
|
// if($car_info->car_no!='京xxxxxx'){
|
||
|
// continue;
|
||
|
// }
|
||
|
// $car_info = new CarT();
|
||
|
// $car_info->user_id = 0;
|
||
|
// $car_info->car_use_id = 0;
|
||
|
// $car_info->car_type_id = 0;
|
||
|
// $car_info->car_no = $car_no;
|
||
|
// $car_info->car_man = $car_man;
|
||
|
// $car_info->factory_model = $factory_model;
|
||
|
// $car_info->engine_no = $engine_no;
|
||
|
// $car_info->car_frame_no = $car_frame_no;
|
||
|
// $car_info->register_date = $register_date;
|
||
|
// $car_info->company = $company;
|
||
|
// $car_info->insurer1_date = $insurer1_date;
|
||
|
// $car_info->insurer2_date = $insurer2_date;
|
||
|
// $car_info->id_man = $id_man;
|
||
|
// $car_info->id_number = $id_number;
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
// $car_info->times = 1;
|
||
|
// $car_info->invalid_flag = 0;
|
||
|
// $car_info->invalid_id = 0;
|
||
|
// if(!$car_info->save()) {
|
||
|
// var_dump($car_info->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
//
|
||
|
// } else {
|
||
|
//
|
||
|
//
|
||
|
// $car_info = new CarT();
|
||
|
// $car_info->user_id = 0;
|
||
|
// $car_info->car_use_id = 0;
|
||
|
// $car_info->car_type_id = 0;
|
||
|
// $car_info->car_no = $car_no;
|
||
|
// $car_info->car_man = $car_man;
|
||
|
// $car_info->factory_model = $factory_model;
|
||
|
// $car_info->engine_no = $engine_no;
|
||
|
// $car_info->car_frame_no = $car_frame_no;
|
||
|
// $car_info->register_date = $register_date;
|
||
|
// $car_info->company = $company;
|
||
|
// $car_info->insurer1_date = $insurer1_date;
|
||
|
// $car_info->insurer2_date = $insurer2_date;
|
||
|
// $car_info->id_man = $id_man;
|
||
|
// $car_info->id_number = $id_number;
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
// $car_info->times = 1;
|
||
|
// $car_info->invalid_flag = 0;
|
||
|
// $car_info->invalid_id = 0;
|
||
|
// if(!$car_info->save()) {
|
||
|
// var_dump($car_info->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// echo 'insert...'.$car_info->id.'...';
|
||
|
// }
|
||
|
echo "ok";
|
||
|
// $insert_total++;
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$total1=$total-1;
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->dif2015 = 2;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
public function actionChuli2015()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'teshu.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
|
||
|
$objectPHPExcel = new \PHPExcel();
|
||
|
$index = 1;
|
||
|
$insert_total = 0;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车主');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'品牌车型');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'发动机号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车架号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'注册日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'上年承保公司');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'商业险到期日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'交强险到期日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'被保险人姓名');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'被保险人证件号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('L'.$index,'京牌');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('M'.$index,'非京牌');
|
||
|
|
||
|
for ($i = 2; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$register_date = $cell->getFormattedValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$company = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer1_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$insurer2_date = $cell->getFormattedValue();//$data[$i][8];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(9, $i);
|
||
|
$id_man = $cell->getFormattedValue();//$data[$i][8];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(10, $i);
|
||
|
$id_number = $cell->getFormattedValue();//$data[$i][8];
|
||
|
|
||
|
$year= (int)substr($register_date,0,4);
|
||
|
if($year!=2015){
|
||
|
continue;
|
||
|
}
|
||
|
$insert_total++;
|
||
|
// $car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
// if($car_info){
|
||
|
// $resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
// $year= (int)substr($car_info->register_date,0,4);
|
||
|
// if($year!=2018){
|
||
|
// continue;
|
||
|
// }
|
||
|
// $resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
// $insert_total++;
|
||
|
//
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// if(!$car_info){
|
||
|
// $car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
//
|
||
|
// if($car_infos){
|
||
|
// $resgt=$car_infos->register_date?$car_infos->register_date:'';
|
||
|
// $year= (int)substr($car_infos->register_date,0,4);
|
||
|
// if($year!=2018){
|
||
|
// continue;
|
||
|
// }
|
||
|
//
|
||
|
// $resgt1=$car_infos->car_no;
|
||
|
// $insert_total++;
|
||
|
// }else{
|
||
|
// continue;
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$index++;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_man);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$factory_model);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$engine_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_frame_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$register_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$company);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer1_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$insurer2_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$id_man);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$id_number);
|
||
|
// if(!$car_info){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
// }
|
||
|
// $zi=mb_substr($cars, 0, 1, 'utf-8');
|
||
|
// if($zi=='京'){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('L'.$index,1);
|
||
|
// }else{
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('M'.$index,1);
|
||
|
// }
|
||
|
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
$objWriter->save('out2015-12.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'out2015.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
//处理同行电话号码
|
||
|
public function actionPhones()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$car_items = CarT::find()
|
||
|
->select('phone,count(phone) as total')
|
||
|
->groupBy('phone')
|
||
|
->orderBy('total DESC')
|
||
|
->asArray()
|
||
|
->all();
|
||
|
|
||
|
$total = count($car_items);
|
||
|
// $total = $car_items->count();
|
||
|
// echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($car_items as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $item['phone'].'...';
|
||
|
echo $item['total'].'...';
|
||
|
if($item['total'] >= 5) {
|
||
|
$peer_info = PeerPhoneT::findOne(['phone'=>$item['phone']]);
|
||
|
if(!$peer_info) {
|
||
|
$peer_info = new PeerPhoneT();
|
||
|
$peer_info->phone = $item['phone'];
|
||
|
$peer_info->save();
|
||
|
echo 'ok';
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
} else {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
public function actionChuli()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'find-a.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
$objectPHPExcel = new \PHPExcel();
|
||
|
$index = 1;
|
||
|
$insert_total = 0;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车架号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'发动机号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'品牌车型');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车主');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'证件号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'联系方式');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'保险到期日');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'初登日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'标准初登日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'车牌号不匹配');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
$car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
if($car_info){
|
||
|
$resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
$resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
$insert_total++;
|
||
|
}
|
||
|
|
||
|
if(!$car_info){
|
||
|
$car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
if($car_infos){
|
||
|
$resgt=$car_infos->register_date;
|
||
|
$resgt1=$car_infos->car_no;
|
||
|
$insert_total++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$index++;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_frame_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$engine_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$factory_model);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_man);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car_man_number);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$phone);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$register_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt?$resgt:'');
|
||
|
if(!$car_info){
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
}
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
$objWriter->save('simple6.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'simple6.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
public function actionChuli1()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'find-a.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
$objectPHPExcel = new \PHPExcel();
|
||
|
$index = 1;
|
||
|
$insert_total = 0;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车架号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'发动机号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'品牌车型');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车主');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'证件号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'联系方式');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'保险到期日');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'初登日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'标准初登日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'车牌号不匹配');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('L'.$index,'京牌');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('M'.$index,'非京牌');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
$car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
if($car_info){
|
||
|
$resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
$year= (int)substr($car_info->register_date,0,4);
|
||
|
if($year!=2018){
|
||
|
continue;
|
||
|
}
|
||
|
$resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
if(!$car_info){
|
||
|
$car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
if($car_infos){
|
||
|
$resgt=$car_infos->register_date?$car_infos->register_date:'';
|
||
|
$year= (int)substr($car_infos->register_date,0,4);
|
||
|
if($year!=2018){
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$resgt1=$car_infos->car_no;
|
||
|
$insert_total++;
|
||
|
}else{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$index++;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_frame_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$engine_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$factory_model);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_man);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car_man_number);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$phone);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$register_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt?$resgt:'');
|
||
|
if(!$car_info){
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
}
|
||
|
$zi=mb_substr($cars, 0, 1, 'utf-8');
|
||
|
if($zi=='京'){
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('L'.$index,1);
|
||
|
}else{
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('M'.$index,1);
|
||
|
}
|
||
|
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
$objWriter->save('simple10.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'simple10.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
public function actionChuli2()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'text-68.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
$objectPHPExcel = new \PHPExcel();
|
||
|
$index = 1;
|
||
|
$insert_total = 0;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车架号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'发动机号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'品牌车型');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车主');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'证件号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'联系方式');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'保险到期日');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'标准初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'车牌号不匹配');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
// $car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
// if($car_info){
|
||
|
// $resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
// $resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
//// $insert_total++;
|
||
|
// continue;
|
||
|
// }
|
||
|
//
|
||
|
// if(!$car_info){
|
||
|
//
|
||
|
// }
|
||
|
$car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
if($car_infos){
|
||
|
$resgt=$car_infos->register_date;
|
||
|
$resgt1=$car_infos->car_no;
|
||
|
$insert_total++;
|
||
|
}else{
|
||
|
continue;
|
||
|
|
||
|
}
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$index++;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_frame_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$engine_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$factory_model);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_man);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car_man_number);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$phone);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$register_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt?$resgt:'');
|
||
|
// if(!$car_info){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
// }
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
$objWriter->save('test-669.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'test-669.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
public function actionChuli22()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'text-68.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
$objectPHPExcel = new \PHPExcel();
|
||
|
$index = 1;
|
||
|
|
||
|
$insert_total = 0;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车架号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'发动机号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'品牌车型');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车主');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'证件号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'联系方式');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'保险到期日');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'标准初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'车牌号不匹配');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
$car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
if($car_info){
|
||
|
// $resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
// $resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
// $insert_total++;
|
||
|
continue;
|
||
|
}
|
||
|
//
|
||
|
if(!$car_info){
|
||
|
$car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
if($car_infos){
|
||
|
// $resgt=$car_infos->register_date;
|
||
|
// $resgt1=$car_infos->car_no;
|
||
|
continue;
|
||
|
}else{
|
||
|
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$index++;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_frame_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$engine_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$factory_model);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_man);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car_man_number);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$phone);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer_date);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$register_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt?$resgt:'');
|
||
|
// if(!$car_info){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
// }
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
$objWriter->save('test-670.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'test-670.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
public function actionChuli3()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'find-a.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $index = 1;
|
||
|
$insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车架号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'发动机号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'品牌车型');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车主');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'证件号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'联系方式');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'保险到期日');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'标准初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'车牌号不匹配');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
$car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
// if($car_info){
|
||
|
// $resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
// $resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
// $insert_total++;
|
||
|
// }
|
||
|
|
||
|
if(!$car_info){
|
||
|
$car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
if($car_infos){
|
||
|
|
||
|
$car_infos->car_no=$cars;
|
||
|
|
||
|
if($phone!=$car_infos->phone){
|
||
|
$car_infos->phone1 =(string) $phone;
|
||
|
}
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_infos->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_infos->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_infos->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_w_info ){
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$car_infos->save();
|
||
|
$insert_total++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// $index++;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_frame_no);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$engine_no);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$factory_model);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_man);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car_man_number);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$phone);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$register_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt?$resgt:'');
|
||
|
// if(!$car_info){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
// }
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('simple6.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'simple12.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
public function actionChuli4()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'find-a.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
// $objectPHPExcel = new \PHPExcel();
|
||
|
// $index = 1;
|
||
|
$insert_total = 0;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车架号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'发动机号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'品牌车型');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车主');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'证件号');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'联系方式');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'保险到期日');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'标准初登日期');
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'车牌号不匹配');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
$car_info = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
// if($car_info){
|
||
|
// $resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
// $resgt1=$car_info->car_no?$car_info->car_no:'';
|
||
|
// $insert_total++;
|
||
|
// }
|
||
|
if($car_info){
|
||
|
if($car_info->phone!=''){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->phone=$phone;
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
if($car_c_info || $car_d_info || $car_w_info ){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->save();
|
||
|
$insert_total++;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// $index++;
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_frame_no);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$engine_no);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$factory_model);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_man);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$car_man_number);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$phone);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$insurer_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$register_date);
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt?$resgt:'');
|
||
|
// if(!$car_info){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
// }
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
// $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
// $objWriter->save('simple6.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'find-a.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
|
||
|
public function actionChuli5()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'text-68.xlsx';
|
||
|
// $company = $request->post('company', '');
|
||
|
//
|
||
|
// $web_path = Yii::$app->getBasePath() . '/../frontend/web';
|
||
|
//
|
||
|
// $urlfile = $web_path . $request->post('urlfile');
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
//读取Excel 2007
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||
|
if (!$PHPReader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$PHPExcel = $PHPReader->load($filename);
|
||
|
$currentSheet = $PHPExcel->getSheet(0);
|
||
|
|
||
|
$rowCount = $currentSheet->getHighestRow();
|
||
|
//$data = $currentSheet->toArray('', true, true);
|
||
|
//创建新的xlsx表
|
||
|
$objectPHPExcel = new \PHPExcel();
|
||
|
$index = 1;
|
||
|
$insert_total = 0;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'车牌号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'车主');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'品牌车型');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'发动机号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'车架号');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'注册日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'上年承保公司');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'商业险到期日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'交强险到期日期');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'被保险人姓名');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,'被保险人证件号');
|
||
|
|
||
|
for ($i = 1; $i <= $rowCount; $i++) {
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(0, $i);
|
||
|
$cars= $cell->getValue();
|
||
|
// var_dump($cars);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(1, $i);
|
||
|
$car_frame_no = $cell->getValue();//$data[$i][1];
|
||
|
// var_dump($car_frame_no);
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(2, $i);
|
||
|
$engine_no = $cell->getValue();//$data[$i][2];
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(3, $i);
|
||
|
$factory_model = $cell->getValue();//$data[$i][3];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(4, $i);
|
||
|
$car_man = $cell->getValue();//$data[$i][4];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(5, $i);
|
||
|
$car_man_number = $cell->getValue();//$data[$i][5];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(6, $i);
|
||
|
$phone = $cell->getValue();//$data[$i][6];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(7, $i);
|
||
|
$insurer_date = $cell->getFormattedValue();
|
||
|
// var_dump($insurer_date);
|
||
|
|
||
|
|
||
|
// $insurer_date = \PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());//$data[$i][7];
|
||
|
$cell = $currentSheet->getCellByColumnAndRow(8, $i);
|
||
|
$resgt='';
|
||
|
$resgt1='';
|
||
|
$resgt2='';
|
||
|
$resgt3='';
|
||
|
$resgt4='';
|
||
|
$resgt5='';
|
||
|
$register_date = $cell->getValue();//$data[$i][8];
|
||
|
$car_info = CarT::findOne(['car_no'=>$cars]);
|
||
|
if($car_info){
|
||
|
$resgt=$car_info->register_date?$car_info->register_date:'';
|
||
|
$year= (int)substr($car_info->register_date,0,4);
|
||
|
if($year<=2015){
|
||
|
continue;
|
||
|
}
|
||
|
$resgt1=$car_info->company?$car_info->company:'';
|
||
|
$resgt2=$car_info->id_man?$car_info->id_man:'';
|
||
|
$resgt3=$car_info->id_number?$car_info->id_number:'';
|
||
|
$resgt4=$car_info->insurer1_date?$car_info->insurer1_date:'';
|
||
|
$resgt5=$car_info->insurer2_date?$car_info->insurer2_date:'';
|
||
|
$insert_total++;
|
||
|
// continue;
|
||
|
}
|
||
|
//
|
||
|
if(!$car_info){
|
||
|
$car_infos = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
|
||
|
if($car_infos){
|
||
|
$resgt=$car_infos->register_date;
|
||
|
// $resgt1=$car_infos->car_no;
|
||
|
$year= (int)substr($car_infos->register_date,0,4);
|
||
|
if($year<=2015){
|
||
|
continue;
|
||
|
}
|
||
|
$resgt1=$car_infos->company?$car_infos->company:'';
|
||
|
$resgt2=$car_infos->id_man?$car_infos->id_man:'';
|
||
|
$resgt3=$car_infos->id_number?$car_infos->id_number:'';
|
||
|
$resgt4=$car_infos->insurer1_date?$car_infos->insurer1_date:'';
|
||
|
$resgt5=$car_infos->insurer2_date?$car_infos->insurer2_date:'';
|
||
|
$insert_total++;
|
||
|
}else{
|
||
|
continue;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$index++;
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$cars);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$car_man);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$factory_model);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$engine_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$car_frame_no);
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$resgt?$resgt:'');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$resgt1?$resgt1:'');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$resgt4?$resgt4:'');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$resgt5?$resgt5:'');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$resgt2?$resgt2:'');
|
||
|
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt3?$resgt3:'');
|
||
|
|
||
|
;
|
||
|
// if(!$car_info){
|
||
|
// $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$index,$resgt1?$resgt1:'');
|
||
|
// }
|
||
|
// die;
|
||
|
|
||
|
|
||
|
// if($insurer_no == 'PDAA201811010000089441') {
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
// exit;
|
||
|
// }
|
||
|
// $row = CaiwuT::findOne(['car_no' => $car_no, 'insurer_no' => $insurer_no]);
|
||
|
// die;
|
||
|
// $row = CaiwuT::findOne(['insurer_no' => $insurer_no]);
|
||
|
// var_dump($row);
|
||
|
// die;
|
||
|
// if ($row) {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
|
||
|
// echo $insurer_no.'='.$policy_man.'='.$total_real.'='.$total_rate.'=';
|
||
|
// echo $pay_total.'='.$insurer_total.'='.date('Y-m-d',$insurer_date).'='.$car_no."\r\n";
|
||
|
|
||
|
// $row->r_total = $insurer_total;
|
||
|
// $row->r_date = $insurer_date;
|
||
|
// $row->company = $company;
|
||
|
// $row->total_dis = round((($row->total_clear * $row->total_rate / 100) - $insurer_total), 2);
|
||
|
// if (!$row->save()) {
|
||
|
// var_dump($row->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
// } else {
|
||
|
// CaiwuErrorT::deleteAll(['insurer_no' => $insurer_no]);
|
||
|
// $tmp_row = new CaiwuErrorT();
|
||
|
// $tmp_row->car_no = $car_no;
|
||
|
// $tmp_row->insurer_no = $insurer_no;
|
||
|
// $tmp_row->policy_man = $policy_man;
|
||
|
// $tmp_row->total_real = $total_real;
|
||
|
// $tmp_row->total_rate = $total_rate;
|
||
|
// $tmp_row->pay_total = $pay_total;
|
||
|
// $tmp_row->finish_total = $insurer_total;
|
||
|
// $tmp_row->pay_date = $insurer_date;
|
||
|
// $tmp_row->company = $company;
|
||
|
// $tmp_row->save();
|
||
|
// }
|
||
|
}
|
||
|
// die;
|
||
|
// header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
||
|
// die;
|
||
|
// header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"');
|
||
|
// header('Cache-Control: max-age=0');
|
||
|
$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel2007');
|
||
|
$objWriter->save('test-671-d2015.xlsx');
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
$log = new ImportLogT();
|
||
|
$datacount=$rowCount;
|
||
|
$log->filename = 'test-671-d2015.xlsx';
|
||
|
$log->total = $datacount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$datacount) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
// return $result;
|
||
|
}
|
||
|
//移去同行电话号码相关的车辆信息
|
||
|
public function actionRemoveCarByPhone()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$peer_items = PeerPhoneT::find()->all();
|
||
|
|
||
|
$total = count($peer_items);
|
||
|
// $total = $car_items->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($peer_items as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $item['phone'].'...';
|
||
|
if(trim($item['phone']) == '') break;
|
||
|
$car_items = CarT::find()
|
||
|
->where(['phone'=>$item['phone']])
|
||
|
->all();
|
||
|
foreach($car_items as $car_item) {
|
||
|
echo "\r\n";
|
||
|
echo $car_item->id.'...'.$car_item->car_no.'...'.$car_item->location.'...';
|
||
|
$order_count = $car_item->getOrders()->where('status_id>0')->count();
|
||
|
if($order_count == 0) {
|
||
|
$data = $car_item->toArray();
|
||
|
$car_old_item = new CarOldT();
|
||
|
$car_old_item->updateAttributes($data);
|
||
|
$car_old_item->save();
|
||
|
|
||
|
// 删除预约记录
|
||
|
AppointmentT::deleteAll(['car_id'=>$car_item->id]);
|
||
|
// 删除对应分库记录
|
||
|
CarBT::deleteAll(['id'=>$car_item->id]);
|
||
|
CarCT::deleteAll(['id'=>$car_item->id]);
|
||
|
CarDT::deleteAll(['id'=>$car_item->id]);
|
||
|
CarET::deleteAll(['id'=>$car_item->id]);
|
||
|
// 删除订单
|
||
|
OrderT::deleteAll(['car_id'=>$car_item->id]);
|
||
|
// 删除车辆信息
|
||
|
$car_item->delete();
|
||
|
echo "ok";
|
||
|
}
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//移动其他符合无效数据的车辆信息
|
||
|
public function actionRemoveCarByOther()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$car_query = CarT::find();
|
||
|
|
||
|
$total = $car_query->count();
|
||
|
// $total = $car_items->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($car_query->each() as $car_item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $car_item->id.'...'.$car_item->car_no.'...'.$car_item->location.'...';
|
||
|
$delete_flag = false;
|
||
|
// 公安局
|
||
|
$str_pos = strpos($car_item->car_man,'公安');
|
||
|
if($str_pos !== FALSE) {
|
||
|
$delete_flag = true;
|
||
|
}
|
||
|
// 座机
|
||
|
if(substr($car_item->phone,0,1) != '1') $delete_flag = true;
|
||
|
// 号码为空
|
||
|
if(trim($car_item->phone) == '') $delete_flag = true;
|
||
|
// 京AD
|
||
|
$str_pos = strpos($car_item->car_no,'京AD');
|
||
|
if($str_pos !== FALSE) $delete_flag = true;
|
||
|
// 京B
|
||
|
$str_pos = strpos($car_item->car_no,'京B');
|
||
|
if($str_pos !== FALSE) $delete_flag = true;
|
||
|
// 租赁
|
||
|
$str_pos = strpos($car_item->car_man,'租赁');
|
||
|
if($str_pos !== FALSE) $delete_flag = true;
|
||
|
|
||
|
if($delete_flag) {
|
||
|
$order_count = $car_item->getOrders()->where('status_id>0')->count();
|
||
|
if($order_count == 0) {
|
||
|
$data = $car_item->toArray();
|
||
|
$car_old_item = new CarOldT();
|
||
|
$car_old_item->updateAttributes($data);
|
||
|
$car_old_item->save();
|
||
|
|
||
|
// 删除预约记录
|
||
|
AppointmentT::deleteAll(['car_id'=>$car_item->id]);
|
||
|
// 删除对应分库记录
|
||
|
CarBT::deleteAll(['id'=>$car_item->id]);
|
||
|
CarCT::deleteAll(['id'=>$car_item->id]);
|
||
|
CarDT::deleteAll(['id'=>$car_item->id]);
|
||
|
CarET::deleteAll(['id'=>$car_item->id]);
|
||
|
// 删除订单
|
||
|
OrderT::deleteAll(['car_id'=>$car_item->id]);
|
||
|
// 删除车辆信息
|
||
|
$car_item->delete();
|
||
|
echo "ok";
|
||
|
}
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//从C库回收到A库
|
||
|
public function actionCA() {
|
||
|
$query = CarCT::find()
|
||
|
->where('user_id=0');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $car_c_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = CarT::findOne(['id'=>$car_c_info->id]);
|
||
|
$car_info->location = 1;
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
$car_c_info->delete();
|
||
|
|
||
|
echo "ok";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//从B库回收到A库
|
||
|
public function actionBA() {
|
||
|
$query = CarBT::find()
|
||
|
->where('user_id=0');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $car_b_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = CarT::findOne(['id'=>$car_b_info->id]);
|
||
|
if($car_info->insurer1_date=='1970-01-01'){
|
||
|
$car_info->location = 1;
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
$car_b_info->delete();
|
||
|
}
|
||
|
|
||
|
|
||
|
echo "ok";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//从C库清除分配
|
||
|
public function actionAClear() {
|
||
|
$query = CarT::find()
|
||
|
->where('user_id>0 and location=1');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $car_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info->location = 1;
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
CarBT::deleteAll('id='.$car_info->id);
|
||
|
CarCT::deleteAll('id='.$car_info->id);
|
||
|
CarDT::deleteAll('id='.$car_info->id);
|
||
|
|
||
|
AppointmentT::deleteAll('car_id='.$car_info->id);
|
||
|
OrderT::deleteAll('car_id='.$car_info->id.' and status_id=1');
|
||
|
|
||
|
echo "ok";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//从D库回收到C库
|
||
|
public function actionDC() {
|
||
|
$query = CarDT::find();
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $car_d_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = CarT::findOne(['id'=>$car_d_info->id]);
|
||
|
$car_info->location = 3;
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
$car_d_info->delete();
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$car_c_info) {
|
||
|
$car_c_info = new CarCT();
|
||
|
$car_c_info->id = $car_info->id;
|
||
|
$car_c_info->user_id = 0;
|
||
|
$car_c_info->save();
|
||
|
}
|
||
|
|
||
|
echo "ok";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//从无效库回收到A库
|
||
|
public function actionInvalideA() {
|
||
|
$query = CarT::find()
|
||
|
->where('invalid_flag=1');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $car_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info->location = 1;
|
||
|
$car_info->invalid_flag = 0; //是否无效
|
||
|
$car_info->invalid_id = 0;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
echo "ok";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//从A库分配到C库
|
||
|
public function actionAC()
|
||
|
{
|
||
|
$query = OrderT::find()
|
||
|
->where('status_id=10');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $order_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = $order_info->car;
|
||
|
if($car_info) {
|
||
|
$car_info->insurer1_date = $order_info->insurer1_begin_date;
|
||
|
$car_info->insurer2_date = $order_info->insurer2_begin_date;
|
||
|
$car_info->location = 3;
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
$c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$c_info) {
|
||
|
$c_info = new CarCT();
|
||
|
$c_info->id = $car_info->id;
|
||
|
$c_info->user_id = 0;
|
||
|
$c_info->save();
|
||
|
}
|
||
|
}
|
||
|
echo "ok";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//处理无效车辆表
|
||
|
public function actionInvalide() {
|
||
|
for($i = 40; $i < 45; $i++) {
|
||
|
$sql = "select * from car_t where invalidate=1 limit ".($i * 10000).",10000";
|
||
|
$items = Yii::$app->db2->createCommand($sql)->queryAll();
|
||
|
|
||
|
$index = 0;
|
||
|
$total = count($items);
|
||
|
foreach($items as $item) {
|
||
|
$index++;
|
||
|
echo $i.'/'.$index.'/'.$total.'=='.$item['car_no'].'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = CarT::findOne(['id'=>$item['id']]);
|
||
|
if($car_info) {
|
||
|
AppointmentT::deleteAll('car_id='.$car_info->id.' and user_id='.$car_info->user_id);
|
||
|
|
||
|
if($car_info->location > 1) {
|
||
|
CarBT::deleteAll('id='.$car_info->id);
|
||
|
CarCT::deleteAll('id='.$car_info->id);
|
||
|
CarDT::deleteAll('id='.$car_info->id);
|
||
|
}
|
||
|
if($car_info->user_id > 0) {
|
||
|
//删除预约
|
||
|
AppointmentT::deleteAll('car_id='.$car_info->id);
|
||
|
//删除保单
|
||
|
OrderT::deleteAll('car_id='.$car_info->id.' and user_id='.$car_info->user_id.' and status_id=1');
|
||
|
}
|
||
|
$car_info->location = 1;
|
||
|
$car_info->invalid_flag = 1;
|
||
|
$car_info->invalid_id = 19;
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
}
|
||
|
echo "ok";
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//同步礼品表
|
||
|
public function actionGift()
|
||
|
{
|
||
|
$sql = "select * from gift_t";
|
||
|
$items = Yii::$app->db2->createCommand($sql)->queryAll();
|
||
|
GiftT::deleteAll();
|
||
|
|
||
|
$index = 0;
|
||
|
foreach($items as $item) {
|
||
|
$index++;
|
||
|
echo $index.'=='.$item['name'].'...';
|
||
|
$row = new GiftT();
|
||
|
$row->id = $item['id'];
|
||
|
$row->name = $item['name'];
|
||
|
$row->type_id = 0;
|
||
|
$row->price = $item['price'];
|
||
|
$row->total = $item['total'];
|
||
|
$row->remark = $item['description'];
|
||
|
$row->created_at = $item['created_at'];
|
||
|
$row->updated_at = $item['updated_at'];
|
||
|
$row->save();
|
||
|
echo "ok\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//分配
|
||
|
public function actionAssign()
|
||
|
{
|
||
|
$user_items = UserT::find()
|
||
|
->all();
|
||
|
$user_index = 0;
|
||
|
$user_total = count($user_items);
|
||
|
foreach($user_items as $user_info)
|
||
|
{
|
||
|
$user_index++;
|
||
|
//去掉无效和首拨
|
||
|
$sql = "SELECT `car_assign_t`.* FROM `car_assign_t` INNER JOIN `car_t` ON car_t.assign_id=car_assign_t.id or car_t.assign2_id=car_assign_t.id WHERE ((op_status=0 and sale_id=".$user_info->id." and car_assign_t.invalidate=0) AND (is_first=0))";
|
||
|
|
||
|
$items = Yii::$app->db2->createCommand($sql)->queryAll();
|
||
|
// AppointmentT::deleteAll();
|
||
|
// OrderT::deleteAll();
|
||
|
$index = 0;
|
||
|
$total = count($items);
|
||
|
// echo $total;exit;
|
||
|
foreach($items as $item) {
|
||
|
$index++;
|
||
|
echo $user_index.'/'.$user_total.'...';
|
||
|
echo $index.'/'.$total.'==';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = CarT::findOne(['id'=>$item['car_id']]);
|
||
|
if(!$car_info) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
// if($car_info->user_id > 0) {
|
||
|
// echo "\r\n";
|
||
|
// continue;
|
||
|
// }
|
||
|
echo $car_info->car_no.'...';
|
||
|
// $user_info = UserT::findOne(['id'=>$item['sale_id']]);
|
||
|
// if(!$user_info) {
|
||
|
// echo "\r\n";
|
||
|
// continue;
|
||
|
// }
|
||
|
echo $user_info->username.'...';
|
||
|
echo $user_info->name.'...';
|
||
|
$car_info->user_id = $user_info->id;
|
||
|
$car_info->save();
|
||
|
|
||
|
$row = AppointmentT::find()
|
||
|
->where('car_id='.$car_info->id.' and user_id='.$user_info->id)
|
||
|
->one();
|
||
|
if(!$row) {
|
||
|
$row = new AppointmentT();
|
||
|
$row->car_id = $car_info->id;
|
||
|
$row->user_id = $user_info->id;
|
||
|
$row->pdate = $item['call_date'];
|
||
|
$row->ptime = $item['call_time'];
|
||
|
$row->remark = $item['remark'];
|
||
|
$row->is_first = $item['is_first'];
|
||
|
$row->created_at = $item['created_at'];
|
||
|
$row->updated_at = $item['updated_at'];
|
||
|
$row->save();
|
||
|
}
|
||
|
|
||
|
//生成保单
|
||
|
$order_row = OrderT::find()
|
||
|
->where('car_id='.$car_info->id.' and user_id='.$user_info->id)
|
||
|
->one();
|
||
|
if(!$order_row) {
|
||
|
$order_row = new OrderT();
|
||
|
$order_row->car_id = $car_info->id;
|
||
|
$order_row->car_no = $car_info->car_no;
|
||
|
$order_row->engine_no = $car_info->engine_no;
|
||
|
$order_row->car_frame_no = $car_info->car_frame_no;
|
||
|
$order_row->car_man = $car_info->car_man;
|
||
|
$order_row->user_id = $user_info->id;
|
||
|
$order_row->status_id = 1;
|
||
|
$order_row->id_man = $car_info->car_man;
|
||
|
$order_row->link_man = $car_info->car_man;
|
||
|
$order_row->save();
|
||
|
}
|
||
|
|
||
|
// $row2 = new AppointmentHistoryT();
|
||
|
// $row2->car_id = $car_info->id;
|
||
|
// $row2->user_id = $user_info->id;
|
||
|
// $row2->pdate = $item['call_date'];
|
||
|
// $row2->ptime = $item['call_time'];
|
||
|
// $row2->remark = $item['remark'];
|
||
|
// $row2->created_at = $item['created_at'];
|
||
|
// $row2->updated_at = $item['updated_at'];
|
||
|
// $row2->save();
|
||
|
|
||
|
if($car_info->location == 1 || $car_info->location == 2) {
|
||
|
$car_info->location = 2;
|
||
|
$car_info->save();
|
||
|
|
||
|
$b_info = CarBT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$b_info) {
|
||
|
$b_info = new CarBT();
|
||
|
$b_info->id = $car_info->id;
|
||
|
}
|
||
|
$b_info->user_id = $car_info->user_id;
|
||
|
$b_info->save();
|
||
|
echo "b";
|
||
|
}
|
||
|
if($car_info->location == 3 || $car_info->location == 4) {
|
||
|
$car_info->location = 4;
|
||
|
$car_info->save();
|
||
|
|
||
|
$d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$d_info) {
|
||
|
$d_info = new CarDT();
|
||
|
$d_info->id = $car_info->id;
|
||
|
}
|
||
|
$d_info->user_id = $car_info->user_id;
|
||
|
$d_info->save();
|
||
|
|
||
|
$c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
if($c_info)
|
||
|
$c_info->delete();
|
||
|
echo "c";
|
||
|
}
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//处理续报问题
|
||
|
public function actionIsFinish()
|
||
|
{
|
||
|
$user_items = UserT::find()
|
||
|
->where('username like "10%"')
|
||
|
->all();
|
||
|
$user_total = count($user_items);
|
||
|
$user_index = 0;
|
||
|
foreach($user_items as $user_info) {
|
||
|
$user_index++;
|
||
|
$car_items = CarT::find()
|
||
|
->where('user_id='.$user_info->id)
|
||
|
->all();
|
||
|
$total = count($car_items);
|
||
|
$index = 0;
|
||
|
foreach($car_items as $car_info) {
|
||
|
$index++;
|
||
|
echo $user_index.'/'.$user_total.'...';
|
||
|
echo $index.'/'.$total."...";
|
||
|
if($car_info->location != 2) {
|
||
|
echo $car_info->id."...";
|
||
|
echo $car_info->car_no."...";
|
||
|
echo $car_info->location."...";
|
||
|
if($car_info->location == 4) {
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info->location = 3;
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->save();
|
||
|
|
||
|
$car_c_info = new CarCT();
|
||
|
$car_c_info->id = $car_info->id;
|
||
|
$car_c_info->user_id = 0;
|
||
|
$car_c_info->save();
|
||
|
|
||
|
CarDT::deleteAll('id='.$car_info->id);
|
||
|
AppointmentT::deleteAll('car_id='.$car_info->id.' and user_id=18');
|
||
|
|
||
|
echo "ok";
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//清除多余的保单
|
||
|
public function actionClearOrders()
|
||
|
{
|
||
|
$car_items = CarCT::find()
|
||
|
->all();
|
||
|
$car_index = 0;
|
||
|
$car_total = count($car_items);
|
||
|
foreach($car_items as $car_info) {
|
||
|
$car_index++;
|
||
|
|
||
|
$user_items = UserT::find()
|
||
|
->where('username like "20%"')
|
||
|
->all();
|
||
|
$user_index = 0;
|
||
|
$user_total = count($user_items);
|
||
|
foreach($user_items as $user_info) {
|
||
|
$user_index++;
|
||
|
echo $car_index.'/'.$car_total.'...';
|
||
|
echo $user_index.'/'.$user_total.'...';
|
||
|
OrderT::deleteAll('car_id='.$car_info->id.' and user_id='.$user_info->id.' and status_id=1');
|
||
|
echo "ok\r\n";
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//清除指定用户的全部预约
|
||
|
public function actionAppointment()
|
||
|
{
|
||
|
$sql = "select * from appointment_t where created_at>='2017-01-01 00:00:00'";
|
||
|
$items = Yii::$app->db2->createCommand($sql)
|
||
|
->queryAll();
|
||
|
AppointmentHistoryT::deleteAll();
|
||
|
$index = 0;
|
||
|
$total = count($items);
|
||
|
foreach($items as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'==';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = CarT::findOne(['id'=>$item['car_id']]);
|
||
|
if(!$car_info) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $car_info->car_no.'...';
|
||
|
$sql = "select * from car_assign_t where id=".$item['assign_id'];
|
||
|
$tmp_row = Yii::$app->db2->createCommand($sql)->queryOne();
|
||
|
$user_info = UserT::findOne(['id'=>$tmp_row['sale_id']]);
|
||
|
if(!$user_info) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $user_info->name.'...';
|
||
|
|
||
|
$row = new AppointmentHistoryT();
|
||
|
$row->car_id = $car_info->id;
|
||
|
$row->user_id = $user_info->id;
|
||
|
$row->pdate = $item['call_date'];
|
||
|
$row->ptime = $item['call_time'];
|
||
|
$row->remark = $item['remark'];
|
||
|
$row->created_at = $item['created_at'];
|
||
|
$row->updated_at = $item['updated_at'];
|
||
|
$row->save();
|
||
|
echo 'ok'."\r\n";
|
||
|
$tran->commit();
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//同步保单
|
||
|
public function actionInsurer()
|
||
|
{
|
||
|
$sql = "select * from car_assign_t where op_status=8";
|
||
|
$items = Yii::$app->db2->createCommand($sql)->queryAll();
|
||
|
// OrderT::deleteAll();
|
||
|
// PriceT::deleteAll();
|
||
|
$index = 0;
|
||
|
$total = count($items);
|
||
|
foreach($items as $tmp_row) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'==';
|
||
|
$tran = OrderT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = CarT::findOne(['id'=>$tmp_row['car_id']]);
|
||
|
echo $car_info->car_no.'...';
|
||
|
$sql = "select * from assign_order_t where assign_id=".$tmp_row['id'];
|
||
|
$item = Yii::$app->db2->createCommand($sql)->queryOne();
|
||
|
$user_info = UserT::findOne(['id'=>$tmp_row['sale_id']]);
|
||
|
if(!$user_info) {
|
||
|
$user_info = new UserT();
|
||
|
$user_info->id = 0;
|
||
|
$user_info->name = '已离职';
|
||
|
}
|
||
|
echo $user_info->name.'...';
|
||
|
|
||
|
//座位数
|
||
|
$car_info->seats = $item['seats'];
|
||
|
$car_info->insurer1_date = $item['insurer_no2_date'];
|
||
|
$car_info->insurer2_date = $item['insurer_no1_date'];
|
||
|
$car_info->save();
|
||
|
|
||
|
//保单
|
||
|
$order_info = OrderT::find()
|
||
|
->where('car_id='.$car_info->id.' and user_id='.$user_info->id)
|
||
|
->one();
|
||
|
if(!$order_info) {
|
||
|
$order_info = new OrderT();
|
||
|
$order_info->car_id = $car_info->id;
|
||
|
$order_info->user_id = $user_info->id;
|
||
|
}
|
||
|
|
||
|
$order_info->car_no = $item['car_no'];
|
||
|
$order_info->engine_no = $car_info->engine_no;
|
||
|
$order_info->car_frame_no = $car_info->car_frame_no;
|
||
|
$order_info->car_man = $item['car_man'];
|
||
|
$order_info->company_id = $item['insurer_company_id'];
|
||
|
if($order_info->company_id == 5)
|
||
|
$order_info->company_id = 1;
|
||
|
$order_info->pay_no = $item['pay_no'];
|
||
|
$order_info->status_id = 10;
|
||
|
$order_info->submit_date = $item['upload_date'];
|
||
|
$order_info->id_man = $item['insurer_name'];
|
||
|
$order_info->id_number = $item['id_num'];
|
||
|
$order_info->link_man = $item['link_man'];
|
||
|
$order_info->link_phone = $item['link_tel'];
|
||
|
$order_info->insurer1_begin_date = $item['insurer_no2_date'];
|
||
|
$order_info->insurer2_begin_date = $item['insurer_no1_date'];
|
||
|
$order_info->send_date = $item['send_date'];
|
||
|
$city_info = CityT::findOne(['name'=>$item['city_id']]);
|
||
|
if($city_info) {
|
||
|
$order_info->city1_id = $city_info->id;
|
||
|
$order_info->city2_id = $city_info->id;
|
||
|
}
|
||
|
$county_info = DistrictT::findOne(['name'=>$item['county_id']]);
|
||
|
if($county_info) {
|
||
|
$order_info->district1_id = $county_info->id;
|
||
|
$order_info->district2_id = $county_info->id;
|
||
|
}
|
||
|
$order_info->send_address1 = $item['send_address'];
|
||
|
$order_info->send_address2 = $item['send_address2'];
|
||
|
$pay_row = PayTypeT::findOne(['name'=>$item['pay_type']]);
|
||
|
$order_info->pay_type_id = $pay_row?$pay_row->id:0;
|
||
|
$order_info->remark = $item['send_remark'];
|
||
|
$order_info->lock_id = 0;
|
||
|
$order_info->insurer1_no = $item['insurer_no2'];
|
||
|
$order_info->insurer2_no = $item['insurer_no1'];
|
||
|
$order_info->print_date = $item['print_date'];
|
||
|
|
||
|
//报价
|
||
|
$sql = "select * from assign_quotation_t where assign_id=".$item['assign_id'];
|
||
|
$price_item = Yii::$app->db2->createCommand($sql)->queryOne();
|
||
|
$order_info->total1 = $price_item['total3'];
|
||
|
$order_info->total1_clear = $price_item['total13'];
|
||
|
$order_info->total1_rate = $price_item['total23'];
|
||
|
$order_info->total1_real = $price_item['total7'];
|
||
|
$order_info->total1_percent = $price_item['percent'];
|
||
|
$order_info->total1_dis = $price_item['total9'];
|
||
|
$order_info->total2 = $price_item['total4'];
|
||
|
$order_info->total2_clear = $price_item['total14'];
|
||
|
$order_info->total2_rate = $price_item['total24'];
|
||
|
$order_info->total3 = $price_item['total5'];
|
||
|
|
||
|
$order_info->total_all = $price_item['total6'];
|
||
|
$order_info->total_real = $price_item['total8'];
|
||
|
$order_info->price_remark = $price_item['price_remark'];
|
||
|
|
||
|
$order_info->created_at = $item['created_at'];
|
||
|
$order_info->updated_at = $item['updated_at'];
|
||
|
$order_info->save();
|
||
|
|
||
|
//报价明细
|
||
|
PriceT::deleteAll('order_id='.$order_info->id);
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 1;
|
||
|
$price_row['val'] = $price_item['a_val1'];
|
||
|
$price_row['is_nopay'] = $price_item['a_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 2;
|
||
|
switch($price_item['b_val1']) {
|
||
|
case 1: $price_row['val'] = '5';break;
|
||
|
case 2: $price_row['val'] = '10';break;
|
||
|
case 3: $price_row['val'] = '15';break;
|
||
|
case 4: $price_row['val'] = '20';break;
|
||
|
case 5: $price_row['val'] = '30';break;
|
||
|
case 6: $price_row['val'] = '50';break;
|
||
|
case 7: $price_row['val'] = '100';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = $price_item['b_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 3;
|
||
|
switch($price_item['g_val1']) {
|
||
|
case 1: $price_row['val'] = '是';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = $price_item['g_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 4;
|
||
|
switch($price_item['d1_val1']) {
|
||
|
case 1: $price_row['val'] = '1';break;
|
||
|
case 2: $price_row['val'] = '2';break;
|
||
|
case 3: $price_row['val'] = '3';break;
|
||
|
case 4: $price_row['val'] = '4';break;
|
||
|
case 5: $price_row['val'] = '5';break;
|
||
|
case 6: $price_row['val'] = '10';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = $price_item['d1_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 5;
|
||
|
switch($price_item['d2_val1']) {
|
||
|
case 1: $price_row['val'] = '1';break;
|
||
|
case 2: $price_row['val'] = '2';break;
|
||
|
case 3: $price_row['val'] = '3';break;
|
||
|
case 4: $price_row['val'] = '4';break;
|
||
|
case 5: $price_row['val'] = '5';break;
|
||
|
case 6: $price_row['val'] = '10';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = $price_item['d2_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
//玻璃
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 6;
|
||
|
switch($price_item['f_val1']) {
|
||
|
case 1: $price_row['val'] = '国产';break;
|
||
|
case 2: $price_row['val'] = '进口';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = 0;
|
||
|
$price_row->save();
|
||
|
|
||
|
//划痕
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 7;
|
||
|
switch($price_item['l_val1']) {
|
||
|
case 1: $price_row['val'] = '2000';break;
|
||
|
case 2: $price_row['val'] = '5000';break;
|
||
|
case 3: $price_row['val'] = '10000';break;
|
||
|
case 4: $price_row['val'] = '20000';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = $price_item['l_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
//涉水
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 8;
|
||
|
switch($price_item['x1_val1']) {
|
||
|
case 1: $price_row['val'] = '是';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = $price_item['x1_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
//自燃
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 9;
|
||
|
switch($price_item['z_val1']) {
|
||
|
case 1: $price_row['val'] = '是';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = $price_item['z_val0'];
|
||
|
$price_row->save();
|
||
|
|
||
|
//交强险
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 10;
|
||
|
switch($price_item['bz_val1']) {
|
||
|
case 1: $price_row['val'] = '是';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = 0;
|
||
|
$price_row->save();
|
||
|
|
||
|
//车船税
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 11;
|
||
|
switch($price_item['cc_val1']) {
|
||
|
case 1: $price_row['val'] = '是';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = 0;
|
||
|
$price_row->save();
|
||
|
|
||
|
//无法找到第三方特约险
|
||
|
$price_row = new PriceT();
|
||
|
$price_row['order_id'] = $order_info->id;
|
||
|
$price_row['type_id'] = 12;
|
||
|
switch($price_item['w_val1']) {
|
||
|
case 1: $price_row['val'] = '是';break;
|
||
|
default: $price_row['val'] = '否';
|
||
|
}
|
||
|
$price_row['is_nopay'] = 0;
|
||
|
$price_row->save();
|
||
|
|
||
|
//处理礼品
|
||
|
CarGiftT::deleteAll('order_id='.$order_info->id);
|
||
|
$sql = "select * from assign_gift_t where assign_id=".$tmp_row['id'];
|
||
|
$gift_items = Yii::$app->db2->createCommand($sql)->queryAll();
|
||
|
foreach($gift_items as $gift_item) {
|
||
|
$gift_row = new CarGiftT();
|
||
|
$gift_row->car_id = $order_info->car_id;
|
||
|
$gift_row->order_id = $order_info->id;
|
||
|
$gift_row->user_id = 0;
|
||
|
$gift_row->strategy_id = 0;
|
||
|
$gift_row->gift_id = $gift_item['gift_id'];
|
||
|
$gift_row->submit_time = $gift_item['send_time'];
|
||
|
$gift_row->status = 1;
|
||
|
$gift_row->type = 1;
|
||
|
$gift_row->save();
|
||
|
}
|
||
|
echo "ok\r\n";
|
||
|
$tran->commit();
|
||
|
}catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
echo "\r\n";
|
||
|
throw $e;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量导入续保数据到临时库
|
||
|
public function actionContinueCar()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'car.xls';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$register_date = sprintf("%s",$item[4]);
|
||
|
|
||
|
echo $car_no."...";
|
||
|
echo $register_date."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = TmpCarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
$car_info->count += 1;
|
||
|
$car_info->save();
|
||
|
} else {
|
||
|
$car_info = new TmpCarT();
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->count = 1;
|
||
|
$car_info->save();
|
||
|
}
|
||
|
echo "ok\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量更新车辆信息
|
||
|
public function actionImportExcel()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'phone.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[4]);
|
||
|
$engine_no = sprintf("%s",$item[5]);
|
||
|
$car_frame_no = sprintf("%s",$item[6]);
|
||
|
$register_date = sprintf("%s",$item[7]);
|
||
|
$insurer1_date = sprintf("%s",$item[9]);
|
||
|
$insurer2_date = sprintf("%s",$item[10]);
|
||
|
$id_man = sprintf("%s",$item[11]);
|
||
|
$id_number = sprintf("%s",$item[12]);
|
||
|
$company = $item[8];
|
||
|
|
||
|
// if($insurer1_date != '')
|
||
|
// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
// if($insurer2_date != '')
|
||
|
// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
echo $car_no."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->save();
|
||
|
|
||
|
// if($company == '人保') {
|
||
|
// $car_info->location = 3;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$car_c_info) {
|
||
|
// $car_c_info = new CarCT();
|
||
|
// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->user_id = 0;
|
||
|
// $car_c_info->save();
|
||
|
// }
|
||
|
// }
|
||
|
echo "ok";
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//移动数据到C库
|
||
|
public function actionToC()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$query = CarT::find()
|
||
|
->where('location=3');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...'.$item->car_no.'...';
|
||
|
$c_info = new CarCT();
|
||
|
$c_info->id = $item->id;
|
||
|
$c_info->user_id = 0;
|
||
|
$c_info->save();
|
||
|
echo 'ok'."\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量导入车辆数据
|
||
|
public function actionCarinfo()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'car.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
$car_man = sprintf("%s",$item[0]);
|
||
|
$phone = sprintf("%s",$item[1]);
|
||
|
$car_no = sprintf("%s",$item[3]);
|
||
|
$factory_model = sprintf("%s",$item[4]);
|
||
|
$car_frame_no = sprintf("%s",$item[5]);
|
||
|
$engine_no = sprintf("%s",$item[6]);
|
||
|
$register_date = sprintf("%s",$item[7]);
|
||
|
|
||
|
if($car_no == '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
echo $register_date.'...';
|
||
|
$tmp_date = explode('-',$register_date);
|
||
|
$register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
if($car_info->engine_no != '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo 'update...';
|
||
|
} else {
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo 'insert...'.$car_info->id.'...';
|
||
|
}
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量导入DD续保数据
|
||
|
public function actionDd()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'DD.xls';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
// if($j == 2) continue;
|
||
|
// if($j == 3) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
// var_dump($item);
|
||
|
// exit;
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[3]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$id_man = sprintf("%s",$item[1]);
|
||
|
$engine_no = sprintf("%s",$item[6]);
|
||
|
$car_frame_no = sprintf("%s",$item[5]);
|
||
|
$factory_model = '';//sprintf("%s",$item[2]);
|
||
|
$insurer1_begin_date = sprintf("%s",$item[8]);
|
||
|
$insurer2_begin_date = sprintf("%s",$item[8]);
|
||
|
$register_date = sprintf("%s",$item[7]);
|
||
|
$total1 = (float)sprintf("%s",$item[10]);
|
||
|
$total2 = (float)sprintf("%s",$item[11]);
|
||
|
$total3 = (float)sprintf("%s",$item[12]);
|
||
|
$total_real = (float)sprintf("%s",$item[18]);
|
||
|
$insurer1_no = '';//sprintf("%s",$item[10]);
|
||
|
$insurer2_no = '';//sprintf("%s",$item[11]);
|
||
|
$id_number = sprintf("%s",$item[4]);
|
||
|
$phone = sprintf("%s",$item[2]);
|
||
|
$print_date = sprintf("%s",$item[0]);
|
||
|
$username = 'DD';//sprintf("%s",$item[14]);
|
||
|
$company = '人保';//sprintf("%s",$item[9]);
|
||
|
|
||
|
if($total1 < 0) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
if($insurer1_begin_date == '' && $insurer2_begin_date == '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
echo $insurer1_begin_date."...";
|
||
|
$tmp_date = explode('-',$insurer1_begin_date);
|
||
|
$new_date = date('Y-m-d',strtotime($insurer1_begin_date));
|
||
|
if($new_date == '1970-01-01' && count($tmp_date) > 2) {
|
||
|
$insurer1_begin_date = '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1];
|
||
|
// echo '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1]."...";
|
||
|
} else {
|
||
|
$insurer1_begin_date = $new_date;
|
||
|
}
|
||
|
echo $insurer1_begin_date."...";
|
||
|
echo $insurer2_begin_date."...";
|
||
|
$tmp_date = explode('-',$insurer2_begin_date);
|
||
|
$new_date = date('Y-m-d',strtotime($insurer2_begin_date));
|
||
|
if($new_date == '1970-01-01' && count($tmp_date) > 2) {
|
||
|
// echo '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1]."...";
|
||
|
$insurer2_begin_date = '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1];
|
||
|
} else {
|
||
|
$insurer2_begin_date = $new_date;
|
||
|
}
|
||
|
echo $insurer2_begin_date."...";
|
||
|
echo $register_date."...";
|
||
|
$new_date = date('Y-m-d',strtotime($register_date));
|
||
|
$tmp_date = explode('-',$register_date);
|
||
|
if($new_date == '1970-01-01' && count($tmp_date) > 2) {
|
||
|
// echo '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1]."...";
|
||
|
$register_date = '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1];
|
||
|
} else {
|
||
|
$register_date = $new_date;
|
||
|
}
|
||
|
echo $register_date."...";
|
||
|
|
||
|
// echo $total1."...";
|
||
|
// echo $total2."...";
|
||
|
// echo $total3."...";
|
||
|
// echo $total_real."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
echo $print_date."...";
|
||
|
$new_date = date('Y-m-d',strtotime($print_date));
|
||
|
$tmp_date = explode('-',$print_date);
|
||
|
// echo '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1]."...";
|
||
|
if($new_date == '1970-01-01' && count($tmp_date) > 2)
|
||
|
$print_date = '20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1];
|
||
|
else
|
||
|
$print_date = $new_date;
|
||
|
echo $print_date."...";
|
||
|
// echo $username."\r\n";
|
||
|
// exit;
|
||
|
$index += 1;
|
||
|
// echo "\r\n";
|
||
|
// if($index > 10) exit;
|
||
|
// continue;
|
||
|
// $tran = CarT::getDb()->beginTransaction();
|
||
|
// try {
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
if($car_info->engine_no != '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $engine_no."...";
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
echo $car_frame_no.'...';
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->old_user = $username;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
// $car_info->total1 = $total1;
|
||
|
// $car_info->total2 = $total2;
|
||
|
// $car_info->total3 = $total3;
|
||
|
// $car_info->total_real = $total_real;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_begin_date."+1 year")).'-1 day'));
|
||
|
if($insurer1_date > $car_info->insurer1_date)
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_begin_date."+1 year")).'-1 day'));
|
||
|
if($insurer2_date > $car_info->insurer2_date)
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
// $car_info->insurer1_no = $insurer1_no;
|
||
|
// $car_info->insurer2_no = $insurer2_no;
|
||
|
$car_info->print_date = $print_date;
|
||
|
// if($car_info->location == 1)
|
||
|
// $car_info->location = 3;
|
||
|
// $car_info->location = 5;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times += 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo 'update...';
|
||
|
} else {
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->old_user = $username;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->id_number = $id_number;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
// $car_info->total1 = $total1;
|
||
|
// $car_info->total2 = $total2;
|
||
|
// $car_info->total3 = $total3;
|
||
|
// $car_info->total_real = $total_real;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_begin_date."+1 year")).'-1 day'));
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_begin_date."+1 year")).'-1 day'));
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
// $car_info->insurer1_no = $insurer1_no;
|
||
|
// $car_info->insurer2_no = $insurer2_no;
|
||
|
$car_info->print_date = $print_date;
|
||
|
$car_info->location = 3;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$car_c_info) {
|
||
|
$car_c_info = new CarCT();
|
||
|
$car_c_info->id = $car_info->id;
|
||
|
$car_c_info->user_id = 0;
|
||
|
if(!$car_c_info->save()) {
|
||
|
var_dump($car_c_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
echo 'insert...'.$car_info->id.'...';
|
||
|
}
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$car_c_info) {
|
||
|
// $car_c_info = new CarCT();
|
||
|
// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->user_id = 0;
|
||
|
// $car_c_info->save();
|
||
|
// }
|
||
|
echo "ok";
|
||
|
|
||
|
// $tran->commit();
|
||
|
// } catch (\Exception $e) {
|
||
|
// $tran->rollBack();
|
||
|
// throw $e;
|
||
|
// }
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//查找车辆数据
|
||
|
public function actionFindCar()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'abc.xls';
|
||
|
$out_filename = $file_path.'phone.csv';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
$line = '';
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if($car_info) {
|
||
|
echo $j.'/'.$total.'...';
|
||
|
echo $car_info->car_no."...";
|
||
|
echo "\r\n";
|
||
|
$line .= $car_info->car_no."\t";
|
||
|
$line .= $car_info->car_man."\t";
|
||
|
$line .= $car_info->phone."\t";
|
||
|
$line .= $car_info->factory_model."\t";
|
||
|
$line .= $car_info->engine_no."\t";
|
||
|
$line .= $car_info->car_frame_no."\t";
|
||
|
$line .= $car_info->register_date."\t";
|
||
|
$line .= $car_info->company."\t";
|
||
|
$line .= $car_info->insurer1_date."\t";
|
||
|
$line .= $car_info->insurer2_date."\t";
|
||
|
$line .= $car_info->id_man."\t";
|
||
|
$line .= $car_info->id_number."\t";
|
||
|
$line .= "\r\n";
|
||
|
}
|
||
|
}
|
||
|
file_put_contents($out_filename,$line);
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//清除A库重复数据
|
||
|
public function actionDupCar()
|
||
|
{
|
||
|
$query = CarCT::find();
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $c_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_c_info = CarT::findOne(['id'=>$c_info->id]);
|
||
|
$car_c_info->user_id = 0;
|
||
|
$car_c_info->save();
|
||
|
AppointmentT::deleteAll('car_id='.$car_c_info->id);
|
||
|
OrderT::deleteAll('car_id='.$car_c_info->id.' and status_id=1');
|
||
|
|
||
|
$car_info = CarT::find()
|
||
|
->where('car_no="'.$car_c_info->car_no.'" and location=1')
|
||
|
->one();
|
||
|
if($car_info) {
|
||
|
AppointmentT::deleteAll('car_id='.$car_info->id);
|
||
|
OrderT::deleteAll('car_id='.$car_info->id.' and status_id=1');
|
||
|
$car_info->delete();
|
||
|
echo "ok";
|
||
|
}
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//清除续保数据
|
||
|
public function actionDupUser()
|
||
|
{
|
||
|
$query = UserT::find()
|
||
|
->where('username like "30%"');
|
||
|
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $user_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $user_info->username.'...';
|
||
|
$tran = AppointmentT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
AppointmentT::deleteAll('user_id='.$user_info->id);
|
||
|
OrderT::deleteAll('user_id='.$user_info->id.' and status_id=1');
|
||
|
echo "ok";
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//今天出单的移到C库
|
||
|
public function actionNewC()
|
||
|
{
|
||
|
$query = OrderT::find()
|
||
|
->where('status_id>5 and print_date="2017-03-02"');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $order_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = $order_info->car;
|
||
|
if($car_info) {
|
||
|
// echo $order_info->id."\r\n";
|
||
|
// echo $order_info->insurer1_begin_date."\r\n";
|
||
|
// echo date('Y-m-d',strtotime(date('Y-m-d',strtotime($order_info->insurer1_begin_date."+1 year")).'-1 day'));
|
||
|
// exit;
|
||
|
$insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($order_info->insurer1_end_date."+1 year")).'-1 day'));
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($order_info->insurer2_end_date."+1 year")).'-1 day'));
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->print_date = $order_info->print_date;
|
||
|
$car_info->location = 3;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->user_id = 0;
|
||
|
if($car_info->times == 0)
|
||
|
$car_info->times = 1;
|
||
|
$car_info->save();
|
||
|
|
||
|
$c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$c_info) {
|
||
|
$c_info = new CarCT();
|
||
|
$c_info->id = $car_info->id;
|
||
|
$c_info->user_id = 0;
|
||
|
$c_info->save();
|
||
|
|
||
|
echo "ok";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//处理不存在的车辆业务信息
|
||
|
public function actionProcessCar()
|
||
|
{
|
||
|
$query = OrderT::find()
|
||
|
->where('status_id>1');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $order_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = $order_info->car;
|
||
|
if(!$car_info) {
|
||
|
AppointmentT::deleteAll('car_id='.$order_info->car_id);
|
||
|
AppointmentHistoryT::deleteAll('car_id='.$order_info->car_id);
|
||
|
CarBT::deleteAll('id='.$order_info->car_id);
|
||
|
CarCT::deleteAll('id='.$order_info->car_id);
|
||
|
CarDT::deleteAll('id='.$order_info->car_id);
|
||
|
$order_info->delete();
|
||
|
}
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//处理无法删除预约信息
|
||
|
public function actionPAppointment()
|
||
|
{
|
||
|
$query = AppointmentT::find()
|
||
|
->where('is_first=0');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $app_info) {
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tmp_item = AppointmentT::find()
|
||
|
->where('car_id='.$app_info->car_id)
|
||
|
->orderBy('pdate DESC,created_at DESC')
|
||
|
->all();
|
||
|
$count = 0;
|
||
|
foreach($tmp_item as $item) {
|
||
|
$count++;
|
||
|
if($count == 1) continue;
|
||
|
$item->delete();
|
||
|
}
|
||
|
echo 'ok';
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//处理无效数据库
|
||
|
public function actionPInvalidLib()
|
||
|
{
|
||
|
$query = CarT::find()
|
||
|
->where('location=5');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $car_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $car_info->car_no.'...';
|
||
|
|
||
|
$invalid_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$invalid_info) {
|
||
|
$car_invalid_t = new CarInvalidT();
|
||
|
$car_invalid_t->id = $car_info->id;
|
||
|
$car_invalid_t->user_id = 1;
|
||
|
$car_invalid_t->invalid_id = 6;
|
||
|
if(!$car_invalid_t->save()) {
|
||
|
var_dump($car_invalid_t->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo "ok";
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//删除所有京B开头的车辆信息
|
||
|
public function actionDeleteCar()
|
||
|
{
|
||
|
$query = CarT::find()
|
||
|
->where('car_no like "京B%"');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(1000) as $car_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $car_info->car_no;
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
CarBT::deleteAll('id='.$car_info->id);
|
||
|
CarCT::deleteAll('id='.$car_info->id);
|
||
|
CarDT::deleteAll('id='.$car_info->id);
|
||
|
CarInvalidT::deleteAll('id='.$car_info->id);
|
||
|
AppointmentHistoryT::deleteAll('car_id='.$car_info->id);
|
||
|
AppointmentT::deleteAll('car_id='.$car_info->id);
|
||
|
OrderT::deleteAll('car_id='.$car_info->id);
|
||
|
CarLogT::deleteAll('car_id='.$car_info->id);
|
||
|
EmsT::deleteAll('car_id='.$car_info->id);
|
||
|
CarGiftT::deleteAll('car_id='.$car_info->id);
|
||
|
$car_info->delete();
|
||
|
|
||
|
echo "ok";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量导入抓取的出险车辆数据
|
||
|
public function actionImportPicc()
|
||
|
{
|
||
|
$query = PiccCarT::find()
|
||
|
->where('id>140000')
|
||
|
->orderBy('id ASC');
|
||
|
// ->where('insurer_end_time>="2016-01-01" and insurer_end_time<="2016-12-31"');
|
||
|
// echo $query->createCommand()->rawSql."\r\n";
|
||
|
$total = $query->count();
|
||
|
echo $total."\r\n";
|
||
|
// exit;
|
||
|
$index = 0;
|
||
|
foreach($query->each(100) as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $item->car_no.'...';
|
||
|
if(mb_substr($item->car_no,0,2) == '京B') {
|
||
|
echo "\r\n";
|
||
|
// exit;
|
||
|
continue;
|
||
|
}
|
||
|
$car_info = CarT::find()
|
||
|
->where('engine_no="'.$item->engine_no.'" and car_frame_no="'.$item->car_frame_no.'"')
|
||
|
->one();
|
||
|
if(!$car_info) {
|
||
|
$car_info = new CarT();
|
||
|
$car_info->location = 1;
|
||
|
$car_info->user_id = 0;
|
||
|
echo "new".'...';
|
||
|
$car_info->engine_no = $item->engine_no;
|
||
|
$car_info->car_frame_no = $item->car_frame_no;
|
||
|
}
|
||
|
$car_info->car_no = $item->car_no;
|
||
|
$car_info->id_man = $item->policy_man;
|
||
|
$car_info->car_model = $item->car_model;
|
||
|
$car_info->factory_model = $item->car_model;
|
||
|
$insurer_date = substr($item->insurer_end_time,0,10);
|
||
|
if($insurer_date > $car_info->insurer1_date) {
|
||
|
$car_info->insurer1_date = $insurer_date;
|
||
|
$car_info->insurer2_date = $insurer_date;
|
||
|
}
|
||
|
$car_info->car_man = $item->car_man;
|
||
|
$car_type = CarTypeT::findOne(['name'=>$item->car_type]);
|
||
|
if(!$car_type) {
|
||
|
$car_type = new CarTypeT();
|
||
|
$car_type->name = $item->car_type;
|
||
|
$car_type->save();
|
||
|
}
|
||
|
$car_info->car_type_id = $car_type->id;
|
||
|
$car_info->register_date = $item->register_date;
|
||
|
$use_type = CarUseT::findOne(['name'=>$item->use_type]);
|
||
|
if(!$use_type) {
|
||
|
$use_type = new CarUseT();
|
||
|
$use_type->name = $item->use_type;
|
||
|
$use_type->save();
|
||
|
}
|
||
|
$car_info->car_use_id = $use_type->id;
|
||
|
$car_info->seats = $item->seats;
|
||
|
$car_info->company = '人保';
|
||
|
if($item->policy_man_phone != '')
|
||
|
$car_info->phone = $item->policy_man_phone;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
}
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量同步预约数据
|
||
|
public function actionHistoryAppointment()
|
||
|
{
|
||
|
$query = AppointmentT::find();
|
||
|
$total = $query->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($query->each() as $item) {
|
||
|
$car_id = $item->car_id;
|
||
|
$tmp_item = AppointmentHistoryT::find()
|
||
|
->where('car_id='.$car_id)
|
||
|
->orderBy('pdate DESC,ptime DESC')
|
||
|
->one();
|
||
|
if($tmp_item && $item->user_id != $tmp_item->user_id) {
|
||
|
if(!$item->user) continue;
|
||
|
if(!$tmp_item->user) continue;
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $item->car->car_no.'...';
|
||
|
echo $item->pdate.' '.$item->ptime.'...';
|
||
|
// echo $item->remark;
|
||
|
echo $item->user->getShowName().'...';
|
||
|
echo $tmp_item->pdate.' '.$item->ptime.'...';
|
||
|
echo $tmp_item->user->getShowName().'...';
|
||
|
// echo $tmp_item->remark;
|
||
|
echo "\r\n";
|
||
|
//
|
||
|
$item->delete();
|
||
|
$car_info = $tmp_item->car;
|
||
|
|
||
|
$app_info = new AppointmentT();
|
||
|
$app_info->car_id = $tmp_item->car_id;
|
||
|
$app_info->user_id = $tmp_item->user_id;
|
||
|
$app_info->pdate = $tmp_item->pdate;
|
||
|
$app_info->ptime = $tmp_item->ptime;
|
||
|
$app_info->remark = $tmp_item->remark;
|
||
|
$app_info->save();
|
||
|
|
||
|
if($car_info->location == 2) {
|
||
|
$b_info = CarBT::findOne(['id'=>$tmp_item->car_id]);
|
||
|
$b_info->user_id = $tmp_item->user_id;
|
||
|
$b_info->save();
|
||
|
}
|
||
|
if($car_info->location == 3) {
|
||
|
$c_info = CarCT::findOne(['id'=>$tmp_item->car_id]);
|
||
|
$c_info->user_id = $tmp_item->user_id;
|
||
|
$c_info->save();
|
||
|
}
|
||
|
if($car_info->location == 4) {
|
||
|
$d_info = CarDT::findOne(['id'=>$tmp_item->car_id]);
|
||
|
$d_info->user_id = $tmp_item->user_id;
|
||
|
$d_info->save();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//恢复被修改的车辆信息
|
||
|
public function actionRepairCar()
|
||
|
{
|
||
|
$query = Car2T::find();
|
||
|
$total = $query->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($query->each() as $car2_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$car_info = CarT::findOne(['id'=>$car2_info->id]);
|
||
|
if($car_info) {
|
||
|
echo $car2_info->car_no.'...';
|
||
|
$car_info->id_man = $car2_info->id_man;
|
||
|
$car_info->car_model = $car2_info->car_model;
|
||
|
$car_info->factory_model = $car2_info->factory_model;
|
||
|
if($car2_info->insurer1_date != '' && $car2_info->insurer1_date != '1970-01-01')
|
||
|
$car_info->insurer1_date = $car2_info->insurer1_date;
|
||
|
if($car2_info->insurer2_date != '' && $car2_info->insurer2_date != '1970-01-01')
|
||
|
$car_info->insurer2_date = $car2_info->insurer2_date;
|
||
|
$car_info->car_man = $car2_info->car_man;
|
||
|
$car_info->engine_no = $car2_info->engine_no;
|
||
|
$car_info->car_frame_no = $car2_info->car_frame_no;
|
||
|
$car_info->register_date = $car2_info->register_date;
|
||
|
$car_info->seats = $car2_info->seats;
|
||
|
$car_info->company = $car2_info->company;
|
||
|
$car_info->phone = $car2_info->phone;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
}
|
||
|
echo "ok";
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionBLib()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$car_query = CarT::find()
|
||
|
->where('location=2');
|
||
|
|
||
|
$total = $car_query->count();
|
||
|
// $total = $car_items->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
$i = 0;
|
||
|
foreach($car_query->each() as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$b_car = $item->lib;
|
||
|
if(!$b_car) {
|
||
|
$i++;
|
||
|
echo $item['car_no'].'...';
|
||
|
echo 'ok';
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
echo "i=".$i."\r\n";
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionInvalidLib()
|
||
|
{
|
||
|
$query = CarT::find()->where('location=5');
|
||
|
$total = $query->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($query->each() as $item) {
|
||
|
$index++;
|
||
|
$invalid_info = CarInvalidT::findOne(['id'=>$item->id]);
|
||
|
if(!$invalid_info) {
|
||
|
$invalid_info = new CarInvalidT();
|
||
|
$invalid_info->id = $item->id;
|
||
|
$invalid_info->user_id = 1;
|
||
|
$invalid_info->save();
|
||
|
echo "ok";
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionCLib()
|
||
|
{
|
||
|
$query = CarCT::find();
|
||
|
$total = $query->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($query->each() as $item) {
|
||
|
$index++;
|
||
|
$car_info = CarT::findOne(['id'=>$item->id]);
|
||
|
if($car_info) {
|
||
|
if($car_info->location != 3) {
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $car_info->car_no."...";
|
||
|
echo $car_info->location.'...';
|
||
|
echo $item->user_id.'...';
|
||
|
echo "\r\n";
|
||
|
$item->delete();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionDLib()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$orders = OrderT::find()
|
||
|
->where('status_id>5')
|
||
|
->orderBy('created_at asc');
|
||
|
|
||
|
echo $orders->count();
|
||
|
echo "\r\n";
|
||
|
$index = 0;
|
||
|
foreach($orders->each() as $order) {
|
||
|
$car = $order->car;
|
||
|
if($car->insurer1_date == '' && $car->insurer2_date) {
|
||
|
$index++;
|
||
|
echo $index.'...';
|
||
|
echo $order->id."...";
|
||
|
echo $car->car_no."...";
|
||
|
echo 'b1:'.$order->insurer1_begin_date."...";
|
||
|
echo 'e1:'.$order->insurer1_end_date."...";
|
||
|
echo 'b2:'.$order->insurer2_begin_date."...";
|
||
|
echo 'e2:'.$order->insurer2_end_date."...";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量更新车辆信息
|
||
|
public function actionImportExcel2()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'car.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
// if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",str_replace('A','',$item[0]).$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[3]);
|
||
|
$car_man = sprintf("%s",$item[4]);
|
||
|
$register_date = sprintf("%s",$item[5]);
|
||
|
$phone = sprintf("%s",$item[6]);
|
||
|
$engine_no = sprintf("%s",$item[8]);
|
||
|
$car_frame_no = sprintf("%s",$item[9]);
|
||
|
$id_number = sprintf("%s",$item[11]);
|
||
|
$id_man = sprintf("%s",$item[4]);
|
||
|
$register_date = substr($register_date,0,10);
|
||
|
|
||
|
// $insurer1_date = sprintf("%s",$item[9]);
|
||
|
// $insurer2_date = sprintf("%s",$item[10]);
|
||
|
// $company = $item[8];
|
||
|
|
||
|
// if($insurer1_date != '')
|
||
|
// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
// if($insurer2_date != '')
|
||
|
// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
echo $car_no."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['engine_no'=>$engine_no,'car_frame_no'=>$car_frame_no]);
|
||
|
if(isset($car_info)) {
|
||
|
if($car_info->car_no != $car_no)
|
||
|
$car_info->car_no = $car_no;
|
||
|
if($car_info->register_date < $register_date)
|
||
|
$car_info->register_date = $register_date;
|
||
|
if($phone != $car_info->phone) {
|
||
|
$car_info->phone = $phone;
|
||
|
}
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
}
|
||
|
echo "ok1";
|
||
|
} else {
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->id_number = $id_number;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->car_model = $factory_model;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
}
|
||
|
echo "ok2";
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
//恢复误回收的数据
|
||
|
public function actionBackCar()
|
||
|
{
|
||
|
$items = CarDT::find()
|
||
|
->where('user_id=50')
|
||
|
->all();
|
||
|
$total = count($items);
|
||
|
$index = 0;
|
||
|
foreach($items as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $item->id.'...';
|
||
|
echo $item->car->car_no.'...';
|
||
|
$app_history_info = AppointmentHistoryT::find()
|
||
|
->where('car_id='.$item->id)
|
||
|
->orderBy('pdate desc')
|
||
|
->one();
|
||
|
if(isset($app_history_info) && $app_history_info->user_id == $item->user_id) {
|
||
|
echo $app_history_info->pdate."...";
|
||
|
|
||
|
$app_info = AppointmentT::find()
|
||
|
->where('car_id='.$item->id)
|
||
|
->one();
|
||
|
if($app_info) {
|
||
|
if($app_info->user_id != $item->user_id)
|
||
|
echo $app_info->user_id."...";
|
||
|
} else {
|
||
|
$row = new AppointmentT();
|
||
|
$row->pdate = $app_history_info->pdate;
|
||
|
$row->ptime = $app_history_info->ptime;
|
||
|
$row->user_id = $app_history_info->user_id;
|
||
|
$row->car_id = $app_history_info->car_id;
|
||
|
$row->remark = $app_history_info->remark;
|
||
|
$row->created_at = $app_history_info->created_at;
|
||
|
$row->updated_at = $app_history_info->updated_at;
|
||
|
$row->save();
|
||
|
echo 'none...';
|
||
|
}
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
//恢复误删除的保单
|
||
|
public function actionOldOrder()
|
||
|
{
|
||
|
$query = Order2T::find()
|
||
|
->where('status_id > 2');
|
||
|
$total = $query->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($query->each() as $order2_info) {
|
||
|
$index++;
|
||
|
$order_info = OrderT::findOne(['id'=>$order2_info->id]);
|
||
|
if(!$order_info) {
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $order2_info->id.'...';
|
||
|
echo $order2_info->status_id.'...';
|
||
|
echo $order2_info->created_at.'...';
|
||
|
echo "\r\n";
|
||
|
$order_info = new OrderT();
|
||
|
$order_info->id = $order2_info->id;
|
||
|
$order_info->car_id = $order2_info->car_id;
|
||
|
$order_info->car_no = $order2_info->car_no;
|
||
|
$order_info->engine_no = $order2_info->engine_no;
|
||
|
$order_info->car_frame_no = $order2_info->car_frame_no;
|
||
|
$order_info->car_man = $order2_info->car_man;
|
||
|
$order_info->user_id = $order2_info->user_id;
|
||
|
$order_info->gift_other = $order2_info->gift_other;
|
||
|
$order_info->company_id = $order2_info->company_id;
|
||
|
$order_info->status_id = $order2_info->status_id;
|
||
|
$order_info->submit_date = $order2_info->submit_date;
|
||
|
$order_info->id_man = $order2_info->id_man;
|
||
|
$order_info->id_number = $order2_info->id_number;
|
||
|
$order_info->link_man = $order2_info->link_man;
|
||
|
$order_info->link_phone = $order2_info->link_phone;
|
||
|
$order_info->insurer1_begin_date = $order2_info->insurer1_begin_date;
|
||
|
$order_info->insurer1_end_date = $order2_info->insurer1_end_date;
|
||
|
$order_info->insurer2_begin_date = $order2_info->insurer2_begin_date;
|
||
|
$order_info->insurer2_end_date = $order2_info->insurer2_end_date;
|
||
|
$order_info->send_date = $order2_info->send_date;
|
||
|
$order_info->direction1_id = $order2_info->direction1_id;
|
||
|
$order_info->range1_id = $order2_info->range1_id;
|
||
|
$order_info->city1_id = $order2_info->city1_id;
|
||
|
$order_info->district1_id = $order2_info->district1_id;
|
||
|
$order_info->send_address1 = $order2_info->send_address1;
|
||
|
$order_info->direction2_id = $order2_info->direction2_id;
|
||
|
$order_info->range2_id = $order2_info->range2_id;
|
||
|
$order_info->city2_id = $order2_info->city2_id;
|
||
|
$order_info->district2_id = $order2_info->district2_id;
|
||
|
$order_info->send_address2 = $order2_info->send_address2;
|
||
|
$order_info->pay_type_id = $order2_info->pay_type_id;
|
||
|
$order_info->pay_no = $order2_info->pay_no;
|
||
|
$order_info->remark = $order2_info->remark;
|
||
|
$order_info->total1 = $order2_info->total1;
|
||
|
$order_info->total1_clear = $order2_info->total1_clear;
|
||
|
$order_info->total1_real = $order2_info->total1_real;
|
||
|
$order_info->total1_dis = $order2_info->total1_dis;
|
||
|
$order_info->total1_percent = $order2_info->total1_percent;
|
||
|
$order_info->total1_rate = $order2_info->total1_rate;
|
||
|
$order_info->total2 = $order2_info->total2;
|
||
|
$order_info->total2_clear = $order2_info->total2_clear;
|
||
|
$order_info->total2_rate = $order2_info->total2_rate;
|
||
|
$order_info->total3 = $order2_info->total3;
|
||
|
$order_info->total_all = $order2_info->total_all;
|
||
|
$order_info->total_real = $order2_info->total_real;
|
||
|
$order_info->price_remark = $order2_info->price_remark;
|
||
|
$order_info->lock_id = $order2_info->lock_id;
|
||
|
$order_info->insurer1_no = $order2_info->insurer1_no;
|
||
|
$order_info->insurer2_no = $order2_info->insurer2_no;
|
||
|
$order_info->identifying_code = $order2_info->identifying_code;
|
||
|
$order_info->money_man = $order2_info->money_man;
|
||
|
$order_info->money_no = $order2_info->money_no;
|
||
|
$order_info->money_bank = $order2_info->money_bank;
|
||
|
$order_info->email = $order2_info->email;
|
||
|
$order_info->return_status_id = $order2_info->return_status_id;
|
||
|
$order_info->return_time = $order2_info->return_time;
|
||
|
$order_info->return_remark = $order2_info->return_remark;
|
||
|
$order_info->print_date = $order2_info->print_date;
|
||
|
$order_info->piao_header = $order2_info->piao_header;
|
||
|
$order_info->first_send = $order2_info->first_send;
|
||
|
$order_info->send_times = $order2_info->send_times;
|
||
|
$order_info->success_id = $order2_info->success_id;
|
||
|
$order_info->sms_code = $order2_info->sms_code;
|
||
|
$order_info->send_return_type = $order2_info->send_return_type;
|
||
|
$order_info->check_gift = $order2_info->check_gift;
|
||
|
$order_info->created_at = $order2_info->created_at;
|
||
|
$order_info->updated_at = $order2_info->updated_at;
|
||
|
if(!$order_info->save()) {
|
||
|
var_dump($order_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionPrice()
|
||
|
{
|
||
|
$query = OrderT::find()
|
||
|
->where('status_id>5')
|
||
|
->andWhere('submit_date>="2017-03-01"')
|
||
|
->andWhere('submit_date<="2017-03-31"')
|
||
|
->orderBy('id ASC');
|
||
|
$total = $query->count();
|
||
|
echo $total."\r\n";
|
||
|
$data = array();
|
||
|
$data['冀'] = 0;
|
||
|
$data['奔驰'] = 0;
|
||
|
$data['宝马'] = 0;
|
||
|
$data['奥迪'] = 0;
|
||
|
$data['陆虎'] = 0;
|
||
|
$data['保时捷'] = 0;
|
||
|
$data['凯迪拉克'] = 0;
|
||
|
$data['沃尔沃'] = 0;
|
||
|
$data['大众'] = 0;
|
||
|
$data['别克'] = 0;
|
||
|
$data['东风日产'] = 0;
|
||
|
$data['福特'] = 0;
|
||
|
$data['丰田'] = 0;
|
||
|
$data['本田'] = 0;
|
||
|
$data['其他'] = 0;
|
||
|
$index = 0;
|
||
|
$total_price = 0;
|
||
|
$total_car = 0;
|
||
|
foreach($query->each() as $order_info) {
|
||
|
$index++;
|
||
|
// echo $index.'/'.$total.'...';
|
||
|
$car_info = $order_info->car;
|
||
|
$pos = strpos($car_info->car_no,'冀');
|
||
|
if($pos !== FALSE) {
|
||
|
$data['冀'] += $order_info->total1_clear;
|
||
|
$total_price += $order_info->total1_clear;
|
||
|
$total_car++;
|
||
|
continue;
|
||
|
}
|
||
|
// $pos = strpos($car_info->factory_model,'奔驰');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['奔驰'] += $order_info->total1;
|
||
|
// $total_price += $order_info->total1;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'宝马');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['宝马'] += $order_info->total1;
|
||
|
// $total_price += $order_info->total1;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'奥迪');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['奥迪'] += $order_info->total1;
|
||
|
// $total_price += $order_info->total1;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'陆虎');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['陆虎'] += $order_info->total1;
|
||
|
// $total_price += $order_info->total1;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'保时捷');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['保时捷'] += $order_info->total1;
|
||
|
// $total_price += $order_info->total1;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'凯迪拉克');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['凯迪拉克'] += $order_info->total1;
|
||
|
// $total_price += $order_info->total1;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'沃尔沃');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['沃尔沃'] += $order_info->total1;
|
||
|
// $total_price += $order_info->total1;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'大众');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['大众'] += $order_info->total1_clear;
|
||
|
// $total_price += $order_info->total1_clear;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'别克');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['别克'] += $order_info->total1_clear;
|
||
|
// $total_price += $order_info->total1_clear;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'东风日产');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['东风日产'] += $order_info->total1_clear;
|
||
|
// $total_price += $order_info->total1_clear;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'福特');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['福特'] += $order_info->total1_clear;
|
||
|
// $total_price += $order_info->total1_clear;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'丰田');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['丰田'] += $order_info->total1_clear;
|
||
|
// $total_price += $order_info->total1_clear;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
// $pos = strpos($car_info->factory_model,'本田');
|
||
|
// if($pos !== FALSE) {
|
||
|
// $data['本田'] += $order_info->total1_clear;
|
||
|
// $total_price += $order_info->total1_clear;
|
||
|
// $total_car++;
|
||
|
// continue;
|
||
|
// }
|
||
|
$data['其他'] += $order_info->total1_clear;
|
||
|
$total_price += $order_info->total1_clear;
|
||
|
// $total_car++;
|
||
|
// echo "ok";
|
||
|
// echo "\r\n";
|
||
|
}
|
||
|
echo '冀='.number_format($data['冀'],2)."\r\n";
|
||
|
// echo '奔驰='.number_format($data['奔驰'],2)."\r\n";
|
||
|
// echo '宝马='.number_format($data['宝马'],2)."\r\n";
|
||
|
// echo '奥迪='.number_format($data['奥迪'],2)."\r\n";
|
||
|
// echo '陆虎='.number_format($data['陆虎'],2)."\r\n";
|
||
|
// echo '保时捷='.number_format($data['保时捷'],2)."\r\n";
|
||
|
// echo '凯迪拉克='.number_format($data['凯迪拉克'],2)."\r\n";
|
||
|
// echo '沃尔沃='.number_format($data['沃尔沃'],2)."\r\n";
|
||
|
// echo '大众='.number_format($data['大众'],2)."\r\n";
|
||
|
// echo '别克='.number_format($data['别克'],2)."\r\n";
|
||
|
// echo '东风日产='.number_format($data['东风日产'],2)."\r\n";
|
||
|
// echo '福特='.number_format($data['福特'],2)."\r\n";
|
||
|
// echo '丰田='.number_format($data['丰田'],2)."\r\n";
|
||
|
// echo '本田='.number_format($data['本田'],2)."\r\n";
|
||
|
echo '其他='.number_format($data['其他'],2)."\r\n";
|
||
|
echo '车辆数量='.number_format($total_car)."\r\n";
|
||
|
echo '总价格='.number_format($total_price,2)."\r\n";
|
||
|
// echo '平均保价='.number_format($total_price/$total_car,2)."\r\n";
|
||
|
// echo '利润='.number_format($total_price * 0.23,2)."\r\n";
|
||
|
// echo '点位利润='.number_format($total_price * 0.01,2)."\r\n";
|
||
|
// echo '固定利润='.number_format($total_car * 100,2)."\r\n";
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionCaiwu()
|
||
|
{
|
||
|
$query = OrderT::find()
|
||
|
->where('status_id>5');
|
||
|
$total = $query->count();
|
||
|
$index = 0;
|
||
|
foreach($query->each(100) as $order_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $order_info->car_no.'...';
|
||
|
$tran = CaiwuT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
//财务处理
|
||
|
// CaiwuT::deleteAll(['order_id'=>$order_info->id]);
|
||
|
|
||
|
//商业
|
||
|
if($order_info->insurer1_no != '' && $order_info->total1_clear > 0) {
|
||
|
$row = CaiwuT::findOne(['insurer_no'=>$order_info->insurer1_no]);
|
||
|
if(!$row) {
|
||
|
$row = new CaiwuT();
|
||
|
$row->insurer_no = $order_info->insurer1_no;
|
||
|
$row->car_no = $order_info->car_no;
|
||
|
$row->factory_model = $order_info->car->factory_model;
|
||
|
$row->id_man = $order_info->id_man;
|
||
|
$row->total = sprintf("%.2f",$order_info->total1);
|
||
|
$row->total_clear = sprintf("%.2f",$order_info->total1_clear);
|
||
|
$row->total_clear_real = sprintf("%.2f",($order_info->total1_clear * $order_info->total1_rate/100));
|
||
|
$row->total_tax = sprintf("%.2f",$order_info->total1 - $order_info->total1_clear);
|
||
|
$row->total_tax_real = sprintf("%.2f",(($order_info->total1-$order_info->total1_clear) * $order_info->total1_rate/100));
|
||
|
$row->total_rate = $order_info->total1_rate > 0 ? $order_info->total1_rate : 0;
|
||
|
$row->user_id = $order_info->user_id;
|
||
|
$row->status = 0;
|
||
|
$row->order_id = $order_info->id;
|
||
|
if(!$row->save()) {
|
||
|
var_dump($row->errors);
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//交强
|
||
|
if($order_info->insurer2_no != '' && $order_info->total2_clear > 0) {
|
||
|
$row = CaiwuT::findOne(['insurer_no'=>$order_info->insurer2_no]);
|
||
|
if(!$row) {
|
||
|
$row = new CaiwuT();
|
||
|
$row->insurer_no = $order_info->insurer2_no;
|
||
|
$row->car_no = $order_info->car_no;
|
||
|
$row->factory_model = $order_info->car->factory_model;
|
||
|
$row->id_man = $order_info->id_man;
|
||
|
$row->total = sprintf("%.2f",$order_info->total2);
|
||
|
$row->total_clear = sprintf("%.2f",$order_info->total2_clear);
|
||
|
$row->total_tax = sprintf("%.2f",($order_info->total2 - $order_info->total2_clear));
|
||
|
$row->total_clear_real = sprintf("%.2f",($order_info->total2_clear * $order_info->total2_rate/100));
|
||
|
$row->total_tax_real = sprintf("%.2f",(($order_info->total2-$order_info->total2_clear) * $order_info->total2_rate/100));
|
||
|
$row->total_rate = $order_info->total2_rate > 0 ? $order_info->total2_rate : '';
|
||
|
$row->user_id = $order_info->user_id;
|
||
|
$row->status = 0;
|
||
|
$row->order_id = $order_info->id;
|
||
|
$row->save();
|
||
|
}
|
||
|
}
|
||
|
$tran->commit();
|
||
|
echo 'ok';
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function actionOpUser()
|
||
|
{
|
||
|
$d_query = CarDT::find()
|
||
|
->where('user_id>0');
|
||
|
|
||
|
$total = $d_query->count();
|
||
|
$index = 0;
|
||
|
foreach($d_query->each() as $d_info) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
if(!$d_info->user) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
$car_info = $d_info->car;
|
||
|
if(!$car_info) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->op_user3 = $d_info->user->getShowName();
|
||
|
$car_info->save();
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
echo "OK";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
//批量导入车辆数据2017
|
||
|
public function actionCarinfo2017()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/files/';
|
||
|
$filename = $file_path.'car2017.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_frame_no = sprintf("%s",$item[1]);
|
||
|
$engine_no = sprintf("%s",$item[2]);
|
||
|
$factory_model = sprintf("%s",$item[3]);
|
||
|
$register_date = sprintf("%s",$item[4]);
|
||
|
$car_man = sprintf("%s",$item[5]);
|
||
|
$phone = sprintf("%s",$item[6]);
|
||
|
|
||
|
if($car_no == '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
// echo $register_date.'...';
|
||
|
$register_date = date('Y-m-d',strtotime($register_date));
|
||
|
// $tmp_date = explode('/',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
echo $register_date.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
// if($car_info->engine_no != '') {
|
||
|
// echo "\r\n";
|
||
|
// continue;
|
||
|
// }
|
||
|
// $car_info->engine_no = $engine_no;
|
||
|
// $car_info->car_frame_no = $car_frame_no;
|
||
|
//
|
||
|
// if(!$car_info->save()) {
|
||
|
// var_dump($car_info->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
echo 'update...';
|
||
|
} else {
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
$insert_total++;
|
||
|
echo 'insert...';
|
||
|
echo $car_info->id.'...';
|
||
|
}
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
}
|
||
|
//批量导入车辆数据20171109
|
||
|
public function actionCarinfo20171109()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'car20171109.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo '总行数:'.$total."\r\n";
|
||
|
// exit;
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_frame_no = sprintf("%s",$item[1]);
|
||
|
$engine_no = sprintf("%s",$item[2]);
|
||
|
$factory_model = sprintf("%s",$item[3]);
|
||
|
$register_date = sprintf("%s",$item[4]);
|
||
|
$car_man = sprintf("%s",$item[5]);
|
||
|
$phone = sprintf("%s",$item[6]);
|
||
|
if($phone == '#N/A') $phone = '';
|
||
|
$company = sprintf("%s",$item[8]);
|
||
|
if($company == '#N/A') $company = '';
|
||
|
$insurer_date = sprintf("%s",$item[9]);
|
||
|
if($insurer_date == '#N/A') $insurer_date = '';
|
||
|
$insurer_man = sprintf("%s",$item[10]);
|
||
|
if($insurer_man == '#N/A') $insurer_man = '';
|
||
|
$insurer_id = sprintf("%s",$item[11]);
|
||
|
if($insurer_id == '#N/A') $insurer_id = '';
|
||
|
|
||
|
if($car_no == '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $car_no."...";
|
||
|
echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
echo $register_date.'...';
|
||
|
$register_date = date('Y-m-d',strtotime($register_date));
|
||
|
// $tmp_date = explode('/',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
echo $register_date.'...';
|
||
|
echo $company.'...';
|
||
|
echo $insurer_date.'...';
|
||
|
echo $insurer_man.'...';
|
||
|
echo $insurer_id.'...';
|
||
|
// echo $new_date.'...';
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
// if($car_info->engine_no != '') {
|
||
|
// echo "\r\n";
|
||
|
// continue;
|
||
|
// }
|
||
|
// $car_info->engine_no = $engine_no;
|
||
|
// $car_info->car_frame_no = $car_frame_no;
|
||
|
//
|
||
|
// if(!$car_info->save()) {
|
||
|
// var_dump($car_info->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
echo 'update...';
|
||
|
} else {
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->location = 1;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer_date;
|
||
|
$car_info->insurer2_date = $insurer_date;
|
||
|
$car_info->id_man = $insurer_man;
|
||
|
$car_info->id_number = $insurer_id;
|
||
|
if(!$car_info->save()) {
|
||
|
var_dump($car_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
$insert_total++;
|
||
|
echo 'insert...'.$car_info->id.'...';
|
||
|
}
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
}
|
||
|
//批量导入人保车辆数据201805
|
||
|
public function actionCarinfo201706()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'car201706.xlsx';
|
||
|
$base_filename = 'car201706.xlsx';
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$rowCount = $sheet->getHighestRow();
|
||
|
// $data = $sheet->toArray('', true, true);
|
||
|
// $total = count($data);
|
||
|
echo '总行数:'.$rowCount."\r\n";
|
||
|
// exit;
|
||
|
$success_total = 0;
|
||
|
// $j = 0;
|
||
|
$insert_total = 0;
|
||
|
for($j = 2; $j < $rowCount; $j++) {
|
||
|
// foreach($data as $index => $item) {
|
||
|
// $j++;
|
||
|
// if($j == 1) continue;
|
||
|
echo $j.'/'.$rowCount."...";
|
||
|
flush();
|
||
|
$cell = $sheet->getCellByColumnAndRow(0, $j);
|
||
|
$car_no = trim($cell->getFormattedValue());
|
||
|
$cell = $sheet->getCellByColumnAndRow(1, $j);
|
||
|
$car_frame_no = $cell->getFormattedValue();//sprintf("%s",$item[1]);
|
||
|
$cell = $sheet->getCellByColumnAndRow(2, $j);
|
||
|
$engine_no = $cell->getFormattedValue();//sprintf("%s",$item[2]);
|
||
|
$cell = $sheet->getCellByColumnAndRow(3, $j);
|
||
|
$factory_model = $cell->getFormattedValue();//sprintf("%s",$item[3]);
|
||
|
$cell = $sheet->getCellByColumnAndRow(9, $j);
|
||
|
$register_date = trim($cell->getFormattedValue());//sprintf("%s",$item[9]);
|
||
|
// $car_man = sprintf("%s",$item[4]);
|
||
|
$cell = $sheet->getCellByColumnAndRow(5, $j);
|
||
|
$phone = trim($cell->getFormattedValue());//sprintf("%s",$item[5]);
|
||
|
// $company = sprintf("%s",$item[8]);
|
||
|
$cell = $sheet->getCellByColumnAndRow(6, $j);
|
||
|
$insurer_date = trim($cell->getFormattedValue());//sprintf("%s",trim($item[6]));
|
||
|
// $insurer_man = sprintf("%s",trim($item[7]));
|
||
|
$cell = $sheet->getCellByColumnAndRow(8, $j);
|
||
|
$insurer_id = trim($cell->getFormattedValue());//sprintf("%s",trim($item[8]));
|
||
|
// $seats = sprintf("%s",$item[10]);
|
||
|
|
||
|
if($car_no == '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $car_no."...";
|
||
|
// echo $car_man."...";
|
||
|
echo $factory_model."...";
|
||
|
echo $register_date.'...';
|
||
|
// $register_date = date('Y-m-d',strtotime($register_date));
|
||
|
// $tmp_date = explode('-',$register_date);
|
||
|
// $register_date = date('Y-m-d',strtotime('20'.$tmp_date[2].'-'.$tmp_date[0].'-'.$tmp_date[1].' 00:00:00'));
|
||
|
// echo $register_date.'...';
|
||
|
// exit;
|
||
|
// echo $company.'...';
|
||
|
echo $insurer_date.'...';
|
||
|
// $insurer_date = date('Y-m-d',strtotime("+1 year",strtotime($insurer_date)));
|
||
|
// $insurer_date = date('Y-m-d',strtotime(strtotime($insurer_date)));
|
||
|
// echo $insurer_date.'...';
|
||
|
// echo $insurer_man.'...';
|
||
|
echo $insurer_id.'...';
|
||
|
// echo $seats.'...';
|
||
|
// echo $new_date.'...';
|
||
|
echo "\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
// if($car_info->engine_no != '') {
|
||
|
// echo "\r\n";
|
||
|
// continue;
|
||
|
// }
|
||
|
// $car_info->engine_no = $engine_no;
|
||
|
// $car_info->car_frame_no = $car_frame_no;
|
||
|
// $car_info->insurer1_date = $insurer_date;
|
||
|
// $car_info->insurer2_date = $insurer_date;
|
||
|
// $car_info->id_man = $insurer_man;
|
||
|
// $car_info->id_number = $insurer_id;
|
||
|
//
|
||
|
// if(!$car_info->save()) {
|
||
|
// var_dump($car_info->errors);
|
||
|
// exit;
|
||
|
// }
|
||
|
echo 'update...';
|
||
|
} else {
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$car_info = new CarT();
|
||
|
$car_info->user_id = 0;
|
||
|
$car_info->car_use_id = 0;
|
||
|
$car_info->car_type_id = 0;
|
||
|
$car_info->car_no = $car_no;
|
||
|
// $car_info->car_man = $car_man;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->phone = $phone;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->location = 2;
|
||
|
$car_info->is_track = 0;
|
||
|
$car_info->times = 1;
|
||
|
$car_info->invalid_flag = 0;
|
||
|
$car_info->invalid_id = 0;
|
||
|
// $car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer_date;
|
||
|
$car_info->insurer2_date = $insurer_date;
|
||
|
// $car_info->id_man = $insurer_man;
|
||
|
$car_info->id_number = $insurer_id;
|
||
|
// $car_info->seats = $seats;
|
||
|
$car_info->from_src = $base_filename;
|
||
|
$car_info->save();
|
||
|
|
||
|
$b_info = CarBT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$b_info) {
|
||
|
$b_info = new CarBT();
|
||
|
$b_info->id = $car_info->id;
|
||
|
$b_info->user_id = 0;
|
||
|
$b_info->save();
|
||
|
}
|
||
|
$this->addLog($car_info->id,'从A库分配到B库',1);
|
||
|
|
||
|
$insert_total++;
|
||
|
echo 'insert...'.$car_info->id.'...';
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Throwable $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
}
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
//记录导入Log
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $rowCount;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ceil($insert_total/$total,4) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
}
|
||
|
//批量导出车辆信息
|
||
|
public function actionOutputCarinfo201805()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'car_info_201805.csv';
|
||
|
$base_filename = 'car201805.xlsx';
|
||
|
$query = CarT::find()
|
||
|
->where('from_src like "'.$base_filename.'"');
|
||
|
|
||
|
$header = '车牌号';
|
||
|
$header .= ",".'"厂牌型号"';
|
||
|
$header .= ",".'"车型"';
|
||
|
$header .= ",".'"初登日期"';
|
||
|
$header .= ",".'"商业到期日期"';
|
||
|
$header .= ",".'"交强到期日期"';
|
||
|
$header .= ",".'"被保险人"';
|
||
|
$header .= ",".'"被保险人身份证"';
|
||
|
$header .= ",".'"发动机号"';
|
||
|
$header .= ",".'"车架号"';
|
||
|
$header .= ",".'"年份"';
|
||
|
$header .= ",".'"车主"';
|
||
|
$header .= ",".'"电话"';
|
||
|
$header .= ",".'"车主身份证"';
|
||
|
$header .= ",".'"保险公司"';
|
||
|
|
||
|
$content = '';
|
||
|
$index = 0;
|
||
|
$total = $query->count();
|
||
|
foreach($query->each(100) as $item) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
if($item->car_no == '') {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
echo $item->car_no.'...';
|
||
|
if($item->phone == '') {
|
||
|
$row = LinkmanT::find()
|
||
|
->where('car_id='.$item->id)
|
||
|
->orderBy('id DESC')
|
||
|
->one();
|
||
|
if(!$row) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
$item->phone = $row->phone;
|
||
|
$item->car_man = $row->name;
|
||
|
} else {
|
||
|
$phone_total = CarT::find()
|
||
|
->where('phone="'.$item->phone.'"')
|
||
|
->count();
|
||
|
if($phone_total > 2) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
if(strlen($item->phone) < 11) {
|
||
|
echo "\r\n";
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
$content .= $item->car_no;
|
||
|
$content .= ",\"".$item->factory_model.'"';
|
||
|
$content .= ",\"".$item->car_model.'"';
|
||
|
$content .= ",\"".$item->register_date.'"';
|
||
|
$content .= ",\"".$item->insurer1_date.'"';
|
||
|
$content .= ",\"".$item->insurer2_date.'"';
|
||
|
$content .= ",\"".$item->id_man.'"';
|
||
|
$content .= ",\"".$item->id_number.'"';
|
||
|
$content .= ",\"".$item->engine_no.'"';
|
||
|
$content .= ",\"".$item->car_frame_no.'"';
|
||
|
$content .= ",\"".$item->car_year.'"';
|
||
|
$content .= ",\"".$item->car_man.'"';
|
||
|
$content .= ",\"".$item->phone.'"';
|
||
|
$content .= ",\"".$item->car_man_number.'"';
|
||
|
$content .= ",\"".$item->company.'"';
|
||
|
$content .= "\r\n";
|
||
|
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
file_put_contents($filename,$header."\r\n".$content);
|
||
|
flush();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//抓取汽车之家的牌品数据
|
||
|
public function actionGetBrand() {
|
||
|
//https://car.autohome.com.cn/price/brand-1.html
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
//获取所有品牌
|
||
|
$url = 'https://car.autohome.com.cn/AsLeftMenu/As_LeftListNew.ashx?typeId=1%20&brandId=0%20&fctId=0%20&seriesId=0';
|
||
|
$content = MyLib::Get($url);
|
||
|
$content = mb_convert_encoding($content,'utf-8','gbk');
|
||
|
$search = '/id=\'b(.*?)\'/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
$brand_ids = $find[1];
|
||
|
// print_r($find[1]);
|
||
|
// echo "\r\n";
|
||
|
// exit;
|
||
|
foreach($brand_ids as $id) {
|
||
|
$tran = Brand2T::getDb()->beginTransaction();
|
||
|
try {
|
||
|
//获取品牌详情
|
||
|
$url = 'https://car.autohome.com.cn/price/brand-'.$id.'.html';
|
||
|
echo $url."\r\n";
|
||
|
$content = MyLib::Get($url);
|
||
|
$content = mb_convert_encoding($content,'utf-8','gbk');
|
||
|
// echo $content;
|
||
|
// echo "\r\n";
|
||
|
$search = '/Object moved to <a href="(.*?)">here<\/a>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
if(count($find[1]) == 1) {
|
||
|
$url = 'https://car.autohome.com.cn'.$find[1][0];
|
||
|
echo $url."\r\n";
|
||
|
$content = MyLib::Get($url);
|
||
|
$content = mb_convert_encoding($content,'utf-8','gbk');
|
||
|
}
|
||
|
$search = '/<!--品牌下车系-->(.*?)<!--品牌下车系end-->/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
// print_r($find);
|
||
|
// echo "\r\n";
|
||
|
$content = $find[1][0];
|
||
|
//品牌
|
||
|
$search = '/<h2 class="fn-left name"><a href="\/price\/.*?">(.*?)<\/a><\/h2>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
$brand_name = $find[1][0];
|
||
|
$brand_info = Brand2T::findOne(['name'=>$brand_name]);
|
||
|
if(!$brand_info) {
|
||
|
$brand_info = new Brand2T();
|
||
|
$brand_info->name = $brand_name;
|
||
|
$brand_info->save();
|
||
|
}
|
||
|
echo $brand_name."\r\n";
|
||
|
//厂家和车系
|
||
|
$search = '/<dt><a href="\/price\/brand-.*?">(.*?)<\/a><\/dt><dd>(.*?)<\/dd>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
$factories = $find[1];
|
||
|
$series = $find[2];
|
||
|
//车系
|
||
|
foreach($factories as $index => $factory_name) {
|
||
|
$factory_info = FactoryT::findOne(['name'=>$factory_name,'brand_id'=>$brand_info->id]);
|
||
|
if(!$factory_info) {
|
||
|
$factory_info = new FactoryT();
|
||
|
$factory_info->name = $factory_name;
|
||
|
$factory_info->brand_id = $brand_info->id;
|
||
|
$factory_info->save();
|
||
|
}
|
||
|
echo " ".$factory_name."\r\n";
|
||
|
$content = $series[$index];
|
||
|
$search = '/<a href="\/price\/series-(.*?)\.html.*?" title="(.*?)">/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
foreach($find[2] as $sub_index => $series_name) {
|
||
|
if(strpos($series_name,' (停售)') !== false) {
|
||
|
$series_name = str_replace(' (停售)','',$series_name);
|
||
|
}
|
||
|
$series_info = Series2T::findOne(['name'=>$series_name,'factory_id'=>$factory_info->id]);
|
||
|
if(!$series_info) {
|
||
|
$series_info = new Series2T();
|
||
|
$series_info->name = $series_name;
|
||
|
$series_info->factory_id = $factory_info->id;
|
||
|
$series_info->brand_id = $brand_info->id;
|
||
|
$series_info->code = $find[1][$sub_index];
|
||
|
$series_info->save();
|
||
|
}
|
||
|
echo " ".$series_name;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
|
||
|
}
|
||
|
//获取新车购置价
|
||
|
public function actionGetSeries() {
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$series = Series2T::find()
|
||
|
->all();
|
||
|
$total_index = 0;
|
||
|
foreach($series as $series_info) {
|
||
|
$total_index++;
|
||
|
$urls = array();
|
||
|
$url = 'https://car.autohome.com.cn/price/series-'.$series_info->code.'.html';
|
||
|
array_push($urls,$url);
|
||
|
|
||
|
echo $series_info->name."\r\n";
|
||
|
for($i = 0; $i < count($urls); $i++) {
|
||
|
$url = $urls[$i];
|
||
|
$old_url = $url;
|
||
|
//获取在售车辆
|
||
|
$content = MyLib::Get($url);
|
||
|
echo $url."\r\n";
|
||
|
$content = mb_convert_encoding($content,'utf-8','gbk');
|
||
|
$search = '/Object moved to <a href="(.*?)">here<\/a>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
if(count($find[1]) == 1) {
|
||
|
$url = 'https://car.autohome.com.cn'.$find[1][0];
|
||
|
echo "1:".$url."\r\n";
|
||
|
if(!in_array($url,$urls))
|
||
|
$urls[] = $url;
|
||
|
continue;
|
||
|
// echo $url."\r\n";
|
||
|
// $content = MyLib::Get($url);
|
||
|
// $content = mb_convert_encoding($content,'utf-8','gbk');
|
||
|
}
|
||
|
//获取停售URL
|
||
|
$search = '/在售<\/a><\/li><li.*?><a href="(.*?)" data-toggle="tab" data-target="#brandtab-2"/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
if(isset($find[1][0])) {
|
||
|
$url = 'https://car.autohome.com.cn'.$find[1][0];
|
||
|
echo "2:".$url."\r\n";
|
||
|
if(!in_array($url,$urls)) {
|
||
|
$urls[] = $url;
|
||
|
}
|
||
|
}
|
||
|
//获取排量
|
||
|
$displacement_name = '';
|
||
|
$has_child = false;
|
||
|
$search = '/class="carsearch-btn border-r-no.*?>(.*?)<i class="icon12 icon12-close2"><\/i>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
if(isset($find[1][0])) {
|
||
|
$displacement_name = $find[1][0];
|
||
|
echo 'name1:'.$displacement_name."\r\n";
|
||
|
} else {
|
||
|
//获取排量列表
|
||
|
$search = '/<div class="carsearch-btn border-r-no.*?>(.*?)<\/div>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
if(isset($find[1][0])) {
|
||
|
$displacement_name = strip_tags($find[1][0]);
|
||
|
echo "name2:".substr($displacement_name,0,20)."\r\n";
|
||
|
if($displacement_name == '发动机') {
|
||
|
$search = '/<div class="carsearch-pop-content"><ul>(.*?)<\/ul><\/div>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
$content = $find[1][0];
|
||
|
$search = '/href="(.*?)"/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
$sub_urls = $find[1];
|
||
|
foreach($sub_urls as $sub_url) {
|
||
|
$has_child = true;
|
||
|
$url = 'https://car.autohome.com.cn'.$sub_url;
|
||
|
echo "3:".$url."\r\n";
|
||
|
if(!in_array($url,$urls)) {
|
||
|
$urls[] = $url;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if($displacement_name == '发动机' && $has_child) {
|
||
|
continue;
|
||
|
}
|
||
|
//下一页
|
||
|
$search = '/<!--分页-->(.*?)<!--end分页-->/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
if(isset($find[1][0])) {
|
||
|
$page_content = $find[1][0];
|
||
|
$search = '/href="(\/price.*?)"/mis';
|
||
|
preg_match_all($search,$page_content,$find);
|
||
|
foreach($find[1] as $url) {
|
||
|
$url = 'https://car.autohome.com.cn'.$url;
|
||
|
echo "4:".$url."\r\n";
|
||
|
if(!in_array($url,$urls)) {
|
||
|
array_push($urls,$url);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
$search = '/<a href="\/\/www.autohome.com.cn\/spec\/.*?".*?>(.*?)<\/a>.*?<div class="interval01-list-guidance">(.*?)<\/div>/mis';
|
||
|
preg_match_all($search,$content,$find);
|
||
|
foreach($find[1] as $index => $name) {
|
||
|
echo $series_info->name.'...';
|
||
|
echo $displacement_name.'...';
|
||
|
$year_name = substr($name,0,strpos($name,' '));
|
||
|
$name = trim(str_replace($year_name,'',$name));
|
||
|
$year_name = str_replace('款','',$year_name);
|
||
|
echo $year_name.'...';
|
||
|
echo $name."...";
|
||
|
$price = strip_tags($find[2][$index]);
|
||
|
// exit;
|
||
|
$displacement_id = 0;
|
||
|
if($displacement_name != '') {
|
||
|
// echo $displacement_name."\r\n";
|
||
|
// exit;
|
||
|
$displacement_info = Displacement2T::findOne(['name'=>$displacement_name,'series_id'=>$series_info->id]);
|
||
|
if(!$displacement_info) {
|
||
|
$displacement_info = new Displacement2T();
|
||
|
$displacement_info->name = $displacement_name;
|
||
|
$displacement_info->series_id = $series_info->id;
|
||
|
$displacement_info->save();
|
||
|
}
|
||
|
$displacement_id = $displacement_info->id;
|
||
|
}
|
||
|
$year_id = 0;
|
||
|
if($year_name != '') {
|
||
|
$year_info = YearT::findOne(['name'=>$year_name,'displacement_id'=>$displacement_id,'series_id'=>$series_info->id]);
|
||
|
if(!$year_info) {
|
||
|
$year_info = new YearT();
|
||
|
$year_info->name = $year_name;
|
||
|
$year_info->displacement_id = $displacement_id;
|
||
|
$year_info->series_id = $series_info->id;
|
||
|
$year_info->save();
|
||
|
}
|
||
|
$year_id = $year_info->id;
|
||
|
}
|
||
|
|
||
|
$model_info = ModelT::findOne(['name'=>$name,'year_id'=>$year_id,'displacement_id'=>$displacement_id,'series_id'=>$series_info->id]);
|
||
|
if(!$model_info) {
|
||
|
$model_info = new ModelT();
|
||
|
$model_info->name = $name;
|
||
|
$model_info->price = $price;
|
||
|
$model_info->year_id = $year_id;
|
||
|
$model_info->displacement_id = $displacement_id;
|
||
|
$model_info->series_id = $series_info->id;
|
||
|
$model_info->brand_id = $series_info->brand_id;
|
||
|
$model_info->factory_id = $series_info->factory_id;
|
||
|
if(!$model_info->save()) {
|
||
|
var_dump($model_info->errors);
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
echo $price."...";
|
||
|
echo $model_info->id;
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// if($old_url == 'https://car.autohome.com.cn/price/series-18-0-0-2.0-2-0-0-1.html#pvareaid=101405')
|
||
|
// exit;
|
||
|
// if($total_index > 10) exit;
|
||
|
}
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//导出9,10月保单信息
|
||
|
public function actionOutputOrders()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'9-10-orders.csv';
|
||
|
|
||
|
$orders = OrderT::find()
|
||
|
->where('print_date>="2017-09-01" and print_date<="2017-10-30"');
|
||
|
echo $orders->count();
|
||
|
echo "\r\n";
|
||
|
|
||
|
$index = 0;
|
||
|
$content = '';
|
||
|
foreach($orders->each() as $order) {
|
||
|
if($order->car->op_user3 != '') {
|
||
|
echo $index++."...";
|
||
|
echo $order->car_no."...";
|
||
|
echo $order->id_man."...";
|
||
|
echo $order->total1_clear."...";
|
||
|
echo $order->car->op_user3."...";
|
||
|
echo $order->car->op_user2."...";
|
||
|
echo "\r\n";
|
||
|
|
||
|
$content .= $order->car_no."\t".$order->id_man."\t".$order->total1_clear."\t".$order->car->op_user3."\t".$order->car->op_user2."\r\n";
|
||
|
}
|
||
|
}
|
||
|
file_put_contents($filename,$content);
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function addLog($car_id,$info,$type)
|
||
|
{
|
||
|
$log_info = new CarLogT();
|
||
|
$log_info->car_id = $car_id;
|
||
|
$log_info->op_time = time();
|
||
|
$log_info->op_man = 'Admin';
|
||
|
$log_info->group_name = '';
|
||
|
$log_info->type = $type;
|
||
|
$log_info->remark = $info;
|
||
|
$log_info->info = '';
|
||
|
if(!$log_info->save()) {
|
||
|
var_dump($log_info->errors);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function actionProcessD()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$cars = CarDT::find()
|
||
|
->leftJoin(CarT::tableName(),'car_t.id=car_d_t.id')
|
||
|
->where('car_t.location<>4');
|
||
|
$total = $cars->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($cars->each() as $car_d) {
|
||
|
$index++;
|
||
|
$car = $car_d->car;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $car->car_no."...";
|
||
|
echo $car->location.'...';
|
||
|
echo "\r\n";
|
||
|
$car_d->delete();
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionUpdateOrder()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$order_query = OrderT::find()
|
||
|
->where('status_id>5')
|
||
|
->andWhere('print_date>="2017-11-01"');
|
||
|
// echo $order_query->createCommand()->rawSql;
|
||
|
// exit;
|
||
|
$total = $order_query->count();
|
||
|
echo $total."\r\n";
|
||
|
|
||
|
$index = 0;
|
||
|
foreach($order_query->each() as $order_info) {
|
||
|
$index++;
|
||
|
$car_info = $order_info->car;
|
||
|
if(!$car_info) continue;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$tran = Yii::$app->db->beginTransaction();
|
||
|
try {
|
||
|
if($order_info->status_id == 9) {
|
||
|
$order_info->status_id = 10;
|
||
|
$order_info->save();
|
||
|
}
|
||
|
//生成财务分支
|
||
|
$order_caiwu = OrderCaiwuT::findOne(['order_id'=>$order_info->id]);
|
||
|
if(!$order_caiwu) {
|
||
|
$order_caiwu = new OrderCaiwuT();
|
||
|
$order_caiwu->order_id = $order_info->id;
|
||
|
$order_caiwu->status_id = 12;
|
||
|
if(!$order_caiwu->save()) {
|
||
|
echo $order_caiwu->order_id."...";
|
||
|
var_dump($order_caiwu->errors);
|
||
|
exit;
|
||
|
}
|
||
|
echo "ok";
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionProcessOrderGift()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$order_gift_query = OrderGiftT::find();
|
||
|
$total = $order_gift_query->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($order_gift_query->each() as $order_gift) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$group = $order_gift->group;
|
||
|
$gift = $order_gift->gift;
|
||
|
if($group) {
|
||
|
$order_gift->is_free = $group->is_free;
|
||
|
}
|
||
|
if($gift) {
|
||
|
$order_gift->gift_type = $gift->type;
|
||
|
}
|
||
|
$order_gift->save();
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionProcessFormulae()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$pay_query = PayT::find();
|
||
|
$total = $pay_query->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($pay_query->each() as $pay) {
|
||
|
$index++;
|
||
|
echo $index.'/'.$total.'...';
|
||
|
$user = $pay->user;
|
||
|
$pay->formulae = $user->formulae;
|
||
|
$pay->save();
|
||
|
|
||
|
echo "ok";
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionUpdateOpuser()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$orders = OrderT::find()
|
||
|
->where('print_date>="2017-11-01" and print_date<="2017-11-30"');
|
||
|
$total = $orders->count();
|
||
|
echo $total."\r\n";
|
||
|
$index = 0;
|
||
|
foreach($orders->each() as $order) {
|
||
|
$index++;
|
||
|
$user = $order->user;
|
||
|
$car = $order->car;
|
||
|
if($car && $user) {
|
||
|
if($car->op_user3 == '') {
|
||
|
if($user->getShowName() != $car->op_user1) {
|
||
|
echo $index.'/'.$total.'...';
|
||
|
echo $car->car_no."...";
|
||
|
echo $car->op_user1."...";
|
||
|
echo $user->getShowName()."...";
|
||
|
echo "\r\n";
|
||
|
$car->op_user1 = $user->getShowName();
|
||
|
$car->save();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionOrderStatus()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$order_query = OrderT::find()
|
||
|
->where('updated_at>="2018-03-01" and status_id>=5 and status_id<9');
|
||
|
$total = $order_query->count();
|
||
|
echo 'Total:'.$total."\r\n";
|
||
|
|
||
|
$index = 0;
|
||
|
foreach($order_query->each() as $order_info) {
|
||
|
$index++;
|
||
|
// echo $index.'/'.$total.'...';
|
||
|
echo $order_info->car_no."\n";
|
||
|
// $order_info->lock_id = 0;
|
||
|
// $order_info->save();
|
||
|
// echo "ok\r\n";
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionCarChange()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$car_query = CarT::find()
|
||
|
->where('from_src="car20180121002.xlsx"');
|
||
|
|
||
|
$total = $car_query->count();
|
||
|
echo 'Total:'.$total."\r\n";
|
||
|
|
||
|
$index = 0;
|
||
|
foreach($car_query->each() as $car_info) {
|
||
|
$index++;
|
||
|
// echo $index.'/'.$total.'...';
|
||
|
echo $car_info->car_no.'...';
|
||
|
echo $car_info->engine_no.'...';
|
||
|
echo $car_info->car_frame_no.'...';
|
||
|
$engine_no = $car_info->car_frame_no;
|
||
|
$car_info->car_frame_no = $car_info->engine_no;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->save();
|
||
|
// $order_info->lock_id = 0;
|
||
|
// $order_info->save();
|
||
|
echo "ok\r\n";
|
||
|
}
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
public function actionTest()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
|
||
|
$time1 = strtotime('2017-04-01 00:00:00');
|
||
|
$time2 = time();
|
||
|
$tmp = $time2 - $time1;
|
||
|
$days = $tmp/(60*60*24);
|
||
|
echo 'day='.$days."\r\n";
|
||
|
echo 'day='.ceil($days)."\r\n";
|
||
|
echo 'person='.ceil(115765/ceil($days))."\r\n";
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
|
||
|
|
||
|
//批量更新车辆信息和保险信息
|
||
|
public function actionImports()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'renshou1.xlsx';
|
||
|
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
// var_dump($file_path);
|
||
|
// die;
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo 'num:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
// if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
// die;
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
$insurer1_date = sprintf("%s",$item[3]);
|
||
|
$company = '人寿';
|
||
|
|
||
|
|
||
|
// if($insurer1_date != '')
|
||
|
// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
// if($insurer2_date != '')
|
||
|
// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
echo $car_no."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
$car_info->company = $company;
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_w_info){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->save();
|
||
|
|
||
|
// if($company == '人保') {
|
||
|
// $car_info->location = 3;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$car_c_info) {
|
||
|
// $car_c_info = new CarCT();
|
||
|
// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->user_id = 0;
|
||
|
// $car_c_info->save();
|
||
|
// }
|
||
|
// }
|
||
|
echo "ok";
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
//批量更新车辆信息和保险信息
|
||
|
public function actionImports1()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'2015-11-7-7.xlsx';
|
||
|
$base_filename = '2015-11-7-7.xlsx';
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
// $rowCount = $sheet->getHighestRow();
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
$total1 = $total-1;
|
||
|
echo 'num:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
//发动机号
|
||
|
$engine_no = sprintf("%s",$item[3]);
|
||
|
//车架号
|
||
|
$car_frame_no = sprintf("%s",$item[4]);
|
||
|
$register_date = sprintf("%s",$item[5]);
|
||
|
$company = $item[6];
|
||
|
$insurer1_date = sprintf("%s",$item[7]);
|
||
|
$insurer2_date = sprintf("%s",$item[8]);
|
||
|
$id_man = sprintf("%s",$item[9]);
|
||
|
$id_number = sprintf("%s",$item[10]);
|
||
|
|
||
|
|
||
|
|
||
|
// if($insurer1_date != '')
|
||
|
// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
// if($insurer2_date != '')
|
||
|
// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
echo $car_no."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->company = $company;
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
$car_info->insurer2_date = $insurer2_date;
|
||
|
$car_info->id_man = $id_man;
|
||
|
$car_info->id_number = $id_number;
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_w_info){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->save();
|
||
|
|
||
|
// if($company == '人保') {
|
||
|
// $car_info->location = 3;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$car_c_info) {
|
||
|
// $car_c_info = new CarCT();
|
||
|
// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->user_id = 0;
|
||
|
// $car_c_info->save();
|
||
|
// }
|
||
|
// }
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// var_dump($insert_total);
|
||
|
//记录导入Log
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
}
|
||
|
public function actionBipei()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'2016-10-1-sk.xlsx';
|
||
|
$base_filename = '2016-10-1-sk.xlsx';
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
// $rowCount = $sheet->getHighestRow();
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
$total1 = $total-1;
|
||
|
echo 'num:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//
|
||
|
|
||
|
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$register_date = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
//发动机号
|
||
|
$engine_no = sprintf("%s",$item[3]);
|
||
|
//车架号
|
||
|
$car_frame_no = sprintf("%s",$item[4]);
|
||
|
$car_man= sprintf("%s",$item[5]);
|
||
|
$car_man_number = sprintf("%s",$item[6]);
|
||
|
$phone = sprintf("%s",$item[7]);
|
||
|
$insurer1_date = sprintf("%s",$item[8]);
|
||
|
// $insurer2_date = sprintf("%s",$item[8]);
|
||
|
// $id_man = sprintf("%s",$item[9]);
|
||
|
// $id_number = sprintf("%s",$item[10]);
|
||
|
|
||
|
|
||
|
|
||
|
// if($insurer1_date != '')
|
||
|
// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
// if($insurer2_date != '')
|
||
|
// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
echo $car_frame_no."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_frame_no'=>$car_frame_no]);
|
||
|
if(isset($car_info)) {
|
||
|
|
||
|
|
||
|
|
||
|
//数据库的车牌号是空
|
||
|
if($car_info->car_no==''){
|
||
|
//表格的数据是空
|
||
|
if($car_no==''){
|
||
|
$car_info->car_no = '京xxxxxx';
|
||
|
}else{
|
||
|
$car_info->car_no=$car_no;
|
||
|
}
|
||
|
}else{
|
||
|
$car_info->car_no=$car_info->car_no;
|
||
|
}
|
||
|
// var_dump($car_info->car_no);
|
||
|
// die;
|
||
|
// $car_info->car_no = $car_no;
|
||
|
$car_info->register_date = $register_date;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
$car_info->engine_no = $engine_no;
|
||
|
$car_info->car_frame_no = $car_frame_no;
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->car_man_number = $car_man_number;
|
||
|
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
// var_dump($car_info->phone1);
|
||
|
// die;
|
||
|
if($car_info->phone==''){
|
||
|
$car_info->phone = $phone;
|
||
|
}elseif($phone!=$car_info->phone1){
|
||
|
// $car_info->phone = $phone;
|
||
|
$car_info->phone1 =(string) $phone;
|
||
|
}
|
||
|
//
|
||
|
|
||
|
|
||
|
$car_info->biaozhu = 1;
|
||
|
|
||
|
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_w_info ){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->save();
|
||
|
|
||
|
// if($company == '人保') {
|
||
|
// $car_info->location = 3;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$car_c_info) {
|
||
|
// $car_c_info = new CarCT();
|
||
|
// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->user_id = 0;
|
||
|
// $car_c_info->save();
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
|
||
|
|
||
|
}else{
|
||
|
// echo 22;
|
||
|
// die;
|
||
|
$car_infos = new CarT();
|
||
|
// var_dump($car_infos);
|
||
|
// die;
|
||
|
if($car_no==''){
|
||
|
$car_infos->car_no = '京xxxxxx';
|
||
|
}else{
|
||
|
$car_infos->car_no=$car_no;
|
||
|
}
|
||
|
|
||
|
$car_infos->user_id = 0;
|
||
|
$car_infos->car_type_id = 0;
|
||
|
$car_infos->car_use_id = 0;
|
||
|
$car_infos->register_date = $register_date;
|
||
|
$car_infos->factory_model = $factory_model;
|
||
|
$car_infos->engine_no = $engine_no;
|
||
|
$car_infos->car_frame_no = $car_frame_no;
|
||
|
$car_infos->car_man = $car_man;
|
||
|
$car_infos->car_man_number = $car_man_number;
|
||
|
$car_infos->phone = $phone;
|
||
|
$car_infos->phone1 = '';
|
||
|
$car_infos->insurer1_date = $insurer1_date;
|
||
|
$car_infos->biaozhu = 1;
|
||
|
$car_infos->save();
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// var_dump($insert_total);
|
||
|
//记录导入Log
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
}
|
||
|
//批量更新车辆信息和保险信息
|
||
|
// public function actionImportsx()
|
||
|
// {
|
||
|
// set_time_limit(0);
|
||
|
// $begin_time = time();
|
||
|
// $file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
// $filename = $file_path.'2014.04-2016.07.xlsx';
|
||
|
// $base_filename = '2014.04-2016.07.xlsx';
|
||
|
//// var_dump($filename);
|
||
|
//// die;
|
||
|
//
|
||
|
// if(file_exists($filename)) {
|
||
|
// echo 'OK'."\r\n";
|
||
|
// }
|
||
|
//// var_dump($filename);
|
||
|
//// die;
|
||
|
// $reader = new \PHPExcel_Reader_Excel2007();
|
||
|
// if(!$reader->canRead($filename)) {
|
||
|
// $reader = new \PHPExcel_Reader_Excel5();
|
||
|
// if(!$reader->canRead($filename)) {
|
||
|
// $errorMessage = "Can not read file.";
|
||
|
// echo $errorMessage;
|
||
|
// return;
|
||
|
// }
|
||
|
// }
|
||
|
// $excel = $reader->load($filename);
|
||
|
// $sheet = $excel->getSheet(0);
|
||
|
//// $rowCount = $sheet->getHighestRow();
|
||
|
// $data = $sheet->toArray('', true, true);
|
||
|
// $total = count($data);
|
||
|
// $total1 = $total-1;
|
||
|
// echo 'num:'.$total."\r\n";
|
||
|
// $j = 0;
|
||
|
// $insert_total = 0;
|
||
|
// foreach($data as $index => $item) {
|
||
|
//
|
||
|
// $j++;
|
||
|
// if($j == 1) continue;
|
||
|
// echo $j.'/'.$total."...";
|
||
|
// flush();
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
// $car_no = sprintf("%s",$item[2]);
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//// if($insurer1_date != '')
|
||
|
//// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
//// if($insurer2_date != '')
|
||
|
//// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
// echo $car_no."...";
|
||
|
//// echo $car_man."...";
|
||
|
//// echo $factory_model."...";
|
||
|
//// echo $engine_no."...";
|
||
|
//// echo $car_frame_no."...";
|
||
|
//// echo $register_date."...";
|
||
|
//// echo $insurer1_no."...";
|
||
|
//// echo $insurer2_no."...";
|
||
|
//// echo $id_man."...";
|
||
|
//// echo $id_number."\r\n";
|
||
|
//// exit;
|
||
|
// $car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
// //新建一个表
|
||
|
// if(isset($car_info)) {
|
||
|
// $register_date=$car_info->register_date;
|
||
|
// $insurer1_date= $car_info->insurer1_date;
|
||
|
// $car_nos=$car_info->car_no;
|
||
|
//// $car_c_info = TestX::findOne(['id'=>$car_info->id]);
|
||
|
//
|
||
|
//// if(!$car_c_info) {
|
||
|
// $car_c_info = new TestX();
|
||
|
//// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->car_no = $car_nos;
|
||
|
// $car_c_info->register_date =$register_date;
|
||
|
// $car_c_info->insurer1_date =$insurer1_date;
|
||
|
// $car_c_info->save();
|
||
|
//// }
|
||
|
//
|
||
|
//// $car_info->location = 1;
|
||
|
//// $car_info->is_track = 0;
|
||
|
//
|
||
|
//// $car_info->location = 1;
|
||
|
//// $car_info->is_track = 0;
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//// if($company == '人保') {
|
||
|
//// $car_info->location = 3;
|
||
|
//// $car_info->save();
|
||
|
////
|
||
|
//// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
//// if(!$car_c_info) {
|
||
|
//// $car_c_info = new TestX();
|
||
|
//// $car_c_info->id = $car_info->id;
|
||
|
//// $car_c_info->user_id = 0;
|
||
|
//// $car_c_info->save();
|
||
|
//// }
|
||
|
//// }
|
||
|
//
|
||
|
// echo "ok";
|
||
|
//
|
||
|
//
|
||
|
// }else{
|
||
|
// $register_date='';
|
||
|
// $insurer1_date= '';
|
||
|
// $car_nos=$car_no;
|
||
|
//// $car_c_info = TestX::findOne(['id'=>$car_info->id]);
|
||
|
//// if(!$car_c_info) {
|
||
|
// $car_c_info = new TestX();
|
||
|
//// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->car_no = $car_nos;
|
||
|
// $car_c_info->register_date =$register_date;
|
||
|
// $car_c_info->insurer1_date =$insurer1_date;
|
||
|
// $car_c_info->save();
|
||
|
//// }
|
||
|
// }
|
||
|
//
|
||
|
// $insert_total++;
|
||
|
//
|
||
|
//
|
||
|
// echo "\r\n";
|
||
|
// }
|
||
|
//// var_dump($insert_total);
|
||
|
// //记录导入Log
|
||
|
// $log = new ImportLogT();
|
||
|
// $log->filename = $base_filename;
|
||
|
// $log->total = $total1;
|
||
|
// $log->success = $insert_total;
|
||
|
// $log->success_rate = ($insert_total/$total1) * 100;
|
||
|
// $log->save();
|
||
|
//
|
||
|
// $end_time = time();
|
||
|
// $total_time = $end_time - $begin_time;
|
||
|
// $h = floor($total_time/3600);
|
||
|
// $m = floor(($total_time - $h * 3600)/60);
|
||
|
// $s = $total_time - $h * 3600 - $m * 60;
|
||
|
// echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
// echo "OK\r\n";
|
||
|
// echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
// }
|
||
|
public function actionImportsxAd()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'2014.04-2016.07-a-d.xlsx';
|
||
|
$base_filename = '2014.04-2016.07-a-d.xlsx';
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
// $rowCount = $sheet->getHighestRow();
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
$total1 = $total-1;
|
||
|
echo 'num:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
flush();
|
||
|
|
||
|
$car_no = sprintf("%s",$item[2]);
|
||
|
|
||
|
echo $car_no."...";
|
||
|
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
//新建一个表
|
||
|
if(isset($car_info)) {
|
||
|
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
;
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_w_info){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->location = 4;
|
||
|
$car_info->save();
|
||
|
|
||
|
$car_c_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$car_c_info) {
|
||
|
$car_c_info = new CarDT();
|
||
|
$car_c_info->id = $car_info->id;
|
||
|
$car_c_info->user_id = 0;
|
||
|
$car_c_info->save();
|
||
|
}
|
||
|
|
||
|
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
// var_dump($insert_total);
|
||
|
//记录导入Log
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
}
|
||
|
public function actionImport12()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'sh11.xlsx';
|
||
|
$base_filename = 'sh11.xlsx';
|
||
|
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
$total1 = $total-1;
|
||
|
echo 'num:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
$insert_total = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
// die;
|
||
|
flush();
|
||
|
$item[0]=str_replace('-', '', $item[0]);
|
||
|
// var_dump($item[0]);
|
||
|
// die;
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
// $car_man = sprintf("%s",$item[1]);
|
||
|
// $factory_model = sprintf("%s",$item[2]);
|
||
|
$insurer1_date = sprintf("%s",$item[1]);
|
||
|
// var_dump($insurer1_date);
|
||
|
// die;
|
||
|
$company = '平安';
|
||
|
|
||
|
|
||
|
// if($insurer1_date != '')
|
||
|
// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
// if($insurer2_date != '')
|
||
|
// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
echo $car_no."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
// $car_info->car_man = $car_man;
|
||
|
$car_info->car_no = $car_no;
|
||
|
// $car_info->factory_model = $factory_model;
|
||
|
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
$car_info->company = $company;
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_w_info){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->save();
|
||
|
|
||
|
// if($company == '人保') {
|
||
|
// $car_info->location = 3;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$car_c_info) {
|
||
|
// $car_c_info = new CarCT();
|
||
|
// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->user_id = 0;
|
||
|
// $car_c_info->save();
|
||
|
// }
|
||
|
// }
|
||
|
echo "ok";
|
||
|
$insert_total++;
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = $base_filename;
|
||
|
$log->total = $total1;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total1) * 100;
|
||
|
$log->save();
|
||
|
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
echo '总添加新车辆:'.$insert_total."\r\n";
|
||
|
|
||
|
|
||
|
}
|
||
|
public function actionImportstx()
|
||
|
{
|
||
|
set_time_limit(0);
|
||
|
$begin_time = time();
|
||
|
$file_path = \Yii::getAlias('@console').'/controllers/';
|
||
|
$filename = $file_path.'renbao.xlsx';
|
||
|
|
||
|
if(file_exists($filename)) {
|
||
|
echo 'OK'."\r\n";
|
||
|
}
|
||
|
// var_dump($filename);
|
||
|
// die;
|
||
|
$reader = new \PHPExcel_Reader_Excel2007();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$reader = new \PHPExcel_Reader_Excel5();
|
||
|
if(!$reader->canRead($filename)) {
|
||
|
$errorMessage = "Can not read file.";
|
||
|
echo $errorMessage;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
$excel = $reader->load($filename);
|
||
|
$sheet = $excel->getSheet(0);
|
||
|
$data = $sheet->toArray('', true, true);
|
||
|
$total = count($data);
|
||
|
echo 'num:'.$total."\r\n";
|
||
|
$j = 0;
|
||
|
foreach($data as $index => $item) {
|
||
|
$j++;
|
||
|
// if($j == 1) continue;
|
||
|
echo $j.'/'.$total."...";
|
||
|
// die;
|
||
|
flush();
|
||
|
$car_no = sprintf("%s",$item[0]);
|
||
|
$car_man = sprintf("%s",$item[1]);
|
||
|
$factory_model = sprintf("%s",$item[2]);
|
||
|
$insurer1_date = sprintf("%s",$item[3]);
|
||
|
$company = '人保';
|
||
|
|
||
|
|
||
|
// if($insurer1_date != '')
|
||
|
// $insurer1_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer1_date."-1 year")).'+1 day'));
|
||
|
// if($insurer2_date != '')
|
||
|
// $insurer2_date = date('Y-m-d',strtotime(date('Y-m-d',strtotime($insurer2_date."-1 year")).'+1 day'));
|
||
|
echo $car_no."...";
|
||
|
// echo $car_man."...";
|
||
|
// echo $factory_model."...";
|
||
|
// echo $engine_no."...";
|
||
|
// echo $car_frame_no."...";
|
||
|
// echo $register_date."...";
|
||
|
// echo $insurer1_no."...";
|
||
|
// echo $insurer2_no."...";
|
||
|
// echo $id_man."...";
|
||
|
// echo $id_number."\r\n";
|
||
|
// exit;
|
||
|
$car_info = CarT::findOne(['car_no'=>$car_no]);
|
||
|
if(isset($car_info)) {
|
||
|
$car_info->car_man = $car_man;
|
||
|
$car_info->car_no = $car_no;
|
||
|
$car_info->factory_model = $factory_model;
|
||
|
|
||
|
$car_info->insurer1_date = $insurer1_date;
|
||
|
|
||
|
// $car_info->location = 1;
|
||
|
// $car_info->is_track = 0;
|
||
|
$car_info->company = $company;
|
||
|
$car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
$car_d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
$car_w_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
|
||
|
if($car_c_info || $car_d_info || $car_w_info){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info->save();
|
||
|
|
||
|
// if($company == '人保') {
|
||
|
// $car_info->location = 3;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// $car_c_info = CarCT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$car_c_info) {
|
||
|
// $car_c_info = new CarCT();
|
||
|
// $car_c_info->id = $car_info->id;
|
||
|
// $car_c_info->user_id = 0;
|
||
|
// $car_c_info->save();
|
||
|
// }
|
||
|
// }
|
||
|
echo "ok";
|
||
|
}
|
||
|
echo "\r\n";
|
||
|
}
|
||
|
$end_time = time();
|
||
|
$total_time = $end_time - $begin_time;
|
||
|
$h = floor($total_time/3600);
|
||
|
$m = floor(($total_time - $h * 3600)/60);
|
||
|
$s = $total_time - $h * 3600 - $m * 60;
|
||
|
echo '花费时间: '.$h.'小时'.$m.'分钟'.$s.'秒';
|
||
|
echo "OK\r\n";
|
||
|
}
|
||
|
private function getE_WQuery()
|
||
|
{
|
||
|
$query = CarET::find()
|
||
|
->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_e_t`.`id`');
|
||
|
//开始时间
|
||
|
// $bgstr= date("y-m-d",time());
|
||
|
//$bgar=explode('-',$bgstr);
|
||
|
//list($bm, $bd) = $bgar;
|
||
|
//结束时间
|
||
|
// $endstr=date("y-m-d",strtotime("-90 day"));
|
||
|
//$edar=explode('-',$endstr);
|
||
|
//list($em, $ed) = $edar;
|
||
|
// $query = $query->andWhere('car_t.insurer1_date<="'.$bgstr.'"');
|
||
|
// $query = $query->andWhere('car_t.insurer1_date>="'.$endstr.'"');
|
||
|
//$query = $query->andWhere('month(car_t.insurer1_date)>="'.$em.'"');
|
||
|
//$query = $query->andWhere('day(car_t.insurer1_date)>="'.$ed.'"');
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
return ['query'=>$query];
|
||
|
}
|
||
|
public function actionEMovew()
|
||
|
{
|
||
|
|
||
|
$result = array();
|
||
|
$result['success'] = false;
|
||
|
$result['msg'] = '操作失败';
|
||
|
|
||
|
|
||
|
$data = $this->getE_WQuery();
|
||
|
$query = $data['query'];
|
||
|
|
||
|
// var_dump($query);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
foreach($query->each(100) as $e_info) {
|
||
|
$car_info = CarT::findOne(['id'=>$e_info->id]);
|
||
|
|
||
|
if($car_info->location == 6) {
|
||
|
// var_dump($car_info);
|
||
|
$car_info->location = 5;
|
||
|
|
||
|
// die;
|
||
|
$car_info->save();
|
||
|
|
||
|
CarET::deleteAll(['id'=>$car_info->id]);
|
||
|
|
||
|
$d_info = CarInvalidT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$d_info) {
|
||
|
$d_info = new CarInvalidT();
|
||
|
$d_info->id = $car_info->id;
|
||
|
$d_info->user_id = 0;
|
||
|
$d_info->save();
|
||
|
|
||
|
$this->addLog($car_info->id,'从E库分配到无效库库',1);
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// die;
|
||
|
$result['success'] = true;
|
||
|
$result['msg'] = '操作成功';
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
|
||
|
echo $result['msg'];
|
||
|
}
|
||
|
|
||
|
// private function getC_EQuery()
|
||
|
// {
|
||
|
//// $query = CarCT::find()->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_c_t`.`id`');
|
||
|
// $query=OrderT::find();
|
||
|
// //结束时间
|
||
|
// $endstr=date("Y-m-d",strtotime("-7 day"));
|
||
|
// //$edar=explode('-',$endstr);
|
||
|
// //list($ey, $em, $ed) = $edar;
|
||
|
// //$query = $query->andWhere('year(car_t.insurer1_date)="'.$ey.'"');
|
||
|
// //$query = $query->andWhere('month(car_t.insurer1_date)="'.$em.'"');
|
||
|
// //$query = $query->andWhere('day(car_t.insurer1_date)="'.$ed.'"');
|
||
|
//
|
||
|
//// $query = $query->andWhere('car_t.insurer1_date="'.$endstr.'"');
|
||
|
// $query = $query->andWhere('print_date="'.$endstr.'"');
|
||
|
//
|
||
|
// //echo $query->createCommand()->rawSql;
|
||
|
// return ['query'=>$query];
|
||
|
// }
|
||
|
//
|
||
|
// //数据在续保成功7天后自动转入跟踪库(C库到E库)
|
||
|
// public function actionCMovee()
|
||
|
// {
|
||
|
// $result = array();
|
||
|
// $result['success'] = false;
|
||
|
// $result['msg'] = '操作失败';
|
||
|
//
|
||
|
//
|
||
|
// $data = $this->getC_EQuery();
|
||
|
// $query = $data['query'];
|
||
|
//
|
||
|
//// var_dump($query);
|
||
|
//// die;
|
||
|
//
|
||
|
//
|
||
|
// $tran = CarT::getDb()->beginTransaction();
|
||
|
// try {
|
||
|
// foreach($query->each(100) as $o_info) {
|
||
|
// $car_info = CarT::findOne(['id'=>$o_info->car_id]);
|
||
|
// if($car_info->location == 3) {
|
||
|
//// var_dump($car_info);
|
||
|
// $car_info->location = 6;
|
||
|
// $car_info->op_user2 = '';
|
||
|
// $car_info->op_user3 = '';
|
||
|
//
|
||
|
//// die;
|
||
|
// $car_info->save();
|
||
|
// CarCT::deleteAll(['id'=>$car_info->id]);
|
||
|
//
|
||
|
// $e_info = CarET::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$e_info) {
|
||
|
// $e_info = new CarET();
|
||
|
// $e_info->id = $car_info->id;
|
||
|
// $e_info->user_id = 0;
|
||
|
// $e_info->save();
|
||
|
//
|
||
|
// $this->addLog($car_info->id,'从C库分配到E库',1);
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
//// echo $query->createCommand()->rawSql;
|
||
|
//// die;
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
//
|
||
|
// $tran->commit();
|
||
|
// } catch (\Exception $e) {
|
||
|
// $tran->rollBack();
|
||
|
// throw $e;
|
||
|
// }
|
||
|
//
|
||
|
// echo $result['msg'];
|
||
|
// }
|
||
|
//
|
||
|
// private function getE_DQuery()
|
||
|
// {
|
||
|
// $query = CarET::find()
|
||
|
// ->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_e_t`.`id`');
|
||
|
// //开始时间
|
||
|
// $bgstr= date("y-m-d",time());
|
||
|
// //$bgar=explode('-',$bgstr);
|
||
|
// //list($bm, $bd) = $bgar;
|
||
|
// //结束时间
|
||
|
// $endstr=date("y-m-d",strtotime("+90 day"));
|
||
|
// //$edar=explode('-',$endstr);
|
||
|
// //list($em, $ed) = $edar;
|
||
|
//// $query = $query->andWhere('car_t.insurer1_date<="'.$bgstr.'"');
|
||
|
// $query = $query->andWhere('car_t.insurer1_date="'.$endstr.'"');
|
||
|
// //$query = $query->andWhere('month(car_t.insurer1_date)>="'.$em.'"');
|
||
|
// //$query = $query->andWhere('day(car_t.insurer1_date)>="'.$ed.'"');
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// return ['query'=>$query];
|
||
|
// }
|
||
|
//
|
||
|
// //跟踪库中的数据在距保险到期日90天时,自动转入续保库(E库到D库)
|
||
|
// public function actionEMoved()
|
||
|
// {
|
||
|
//
|
||
|
// $result = array();
|
||
|
// $result['success'] = false;
|
||
|
// $result['msg'] = '操作失败';
|
||
|
//
|
||
|
//
|
||
|
// $data = $this->getE_DQuery();
|
||
|
// $query = $data['query'];
|
||
|
//
|
||
|
//// var_dump($query);
|
||
|
//// die;
|
||
|
//
|
||
|
//
|
||
|
// $tran = CarT::getDb()->beginTransaction();
|
||
|
// try {
|
||
|
// foreach($query->each(100) as $e_info) {
|
||
|
// $car_info = CarT::findOne(['id'=>$e_info->id]);
|
||
|
//
|
||
|
// if($car_info->location == 6) {
|
||
|
//// var_dump($car_info);
|
||
|
// $car_info->location = 4;
|
||
|
//
|
||
|
//// die;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// CarET::deleteAll(['id'=>$car_info->id]);
|
||
|
//
|
||
|
// $d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$d_info) {
|
||
|
// $d_info = new CarDT();
|
||
|
// $d_info->id = $car_info->id;
|
||
|
// $d_info->user_id = 0;
|
||
|
// $d_info->save();
|
||
|
//
|
||
|
// $this->addLog($car_info->id,'从E库分配到D库',1);
|
||
|
//
|
||
|
//
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
//// echo $query->createCommand()->rawSql;
|
||
|
//// die;
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
//
|
||
|
// $tran->commit();
|
||
|
// } catch (\Exception $e) {
|
||
|
// $tran->rollBack();
|
||
|
// throw $e;
|
||
|
// }
|
||
|
//
|
||
|
// echo $result['msg'];
|
||
|
// }
|
||
|
//
|
||
|
// private function getF_DQuery()
|
||
|
// {
|
||
|
// $query = CarFT::find()
|
||
|
// ->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_f_t`.`id`');
|
||
|
// //开始时间
|
||
|
//// $bgstr= date("y-m-d",time());
|
||
|
// //$bgar=explode('-',$bgstr);
|
||
|
// //list($bm, $bd) = $bgar;
|
||
|
// //结束时间
|
||
|
// $endstr=date("Y-m-d",strtotime("+90 day"));
|
||
|
//// var_dump($endstr);
|
||
|
//// die;
|
||
|
// //$edar=explode('-',$endstr);
|
||
|
// //list($em, $ed) = $edar;
|
||
|
//// $query = $query->andWhere('car_t.insurer1_date<="'.$bgstr.'"');
|
||
|
// $query = $query->andWhere('car_t.insurer1_date ="'.$endstr.'"');
|
||
|
// //$query = $query->andWhere('month(car_t.insurer1_date)>="'.$em.'"');
|
||
|
// //$query = $query->andWhere('day(car_t.insurer1_date)>="'.$ed.'"');
|
||
|
//// echo $query->createCommand()->rawSql;
|
||
|
// return ['query'=>$query];
|
||
|
// }
|
||
|
//
|
||
|
// //其他平台续保库在距保险到期日90天时,自动转入续保库;(F库到D库)
|
||
|
// public function actionFMoved()
|
||
|
// {
|
||
|
//
|
||
|
// $result = array();
|
||
|
// $result['success'] = false;
|
||
|
// $result['msg'] = '操作失败';
|
||
|
//
|
||
|
//
|
||
|
// $data = $this->getF_DQuery();
|
||
|
// $query = $data['query'];
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
// $tran = CarT::getDb()->beginTransaction();
|
||
|
// try {
|
||
|
// foreach($query->each(100) as $f_info) {
|
||
|
// $car_info = CarT::findOne(['id'=>$f_info->id]);
|
||
|
// var_dump($car_info);
|
||
|
//
|
||
|
// if($car_info->location == 7) {
|
||
|
//
|
||
|
// $car_info->location = 4;
|
||
|
//
|
||
|
//// die;
|
||
|
// $car_info->save();
|
||
|
//
|
||
|
// CarFT::deleteAll(['id'=>$car_info->id]);
|
||
|
//
|
||
|
// $d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
// if(!$d_info) {
|
||
|
// $d_info = new CarDT();
|
||
|
// $d_info->id = $car_info->id;
|
||
|
// $d_info->user_id = 0;
|
||
|
// $d_info->save();
|
||
|
//
|
||
|
// $this->addLog($car_info->id,'从F库分配到D库',1);
|
||
|
//
|
||
|
//
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
//// echo $query->createCommand()->rawSql;
|
||
|
//
|
||
|
// $result['success'] = true;
|
||
|
// $result['msg'] = '操作成功';
|
||
|
//
|
||
|
// $tran->commit();
|
||
|
// } catch (\Exception $e) {
|
||
|
// $tran->rollBack();
|
||
|
// throw $e;
|
||
|
// }
|
||
|
//
|
||
|
// echo $result['msg'];
|
||
|
// }
|
||
|
private function getC_EQuery()
|
||
|
{
|
||
|
// $query = CarCT::find()->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_c_t`.`id`');
|
||
|
$query=OrderT::find();
|
||
|
//结束时间
|
||
|
$endstr=date("Y-m-d",strtotime("-7 day"));
|
||
|
//$edar=explode('-',$endstr);
|
||
|
//list($ey, $em, $ed) = $edar;
|
||
|
//$query = $query->andWhere('year(car_t.insurer1_date)="'.$ey.'"');
|
||
|
//$query = $query->andWhere('month(car_t.insurer1_date)="'.$em.'"');
|
||
|
//$query = $query->andWhere('day(car_t.insurer1_date)="'.$ed.'"');
|
||
|
|
||
|
// $query = $query->andWhere('car_t.insurer1_date="'.$endstr.'"');
|
||
|
$query = $query->andWhere('print_date="'.$endstr.'"');
|
||
|
|
||
|
//echo $query->createCommand()->rawSql;
|
||
|
return ['query'=>$query];
|
||
|
}
|
||
|
|
||
|
//数据在续保成功7天后自动转入跟踪库(C库到E库)
|
||
|
public function actionCMovee()
|
||
|
{
|
||
|
$result = array();
|
||
|
$result['success'] = false;
|
||
|
$result['msg'] = '操作失败';
|
||
|
|
||
|
|
||
|
$data = $this->getC_EQuery();
|
||
|
$query = $data['query'];
|
||
|
|
||
|
// var_dump($query);
|
||
|
// die;
|
||
|
|
||
|
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$total = $query->count();
|
||
|
$insert_total = 0;
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// die;
|
||
|
foreach($query->each(100) as $o_info) {
|
||
|
if($o_info->insurance_status==2){
|
||
|
continue;
|
||
|
}
|
||
|
$car_info = CarT::findOne(['id'=>$o_info->car_id]);
|
||
|
// echo 44;
|
||
|
// var_dump($car_info);
|
||
|
// die;
|
||
|
// dd($car_info);
|
||
|
|
||
|
if($car_info->location == 3) {
|
||
|
// var_dump($car_info);
|
||
|
$car_info->location = 6;
|
||
|
// $car_info->op_user2 = '';
|
||
|
// $car_info->op_user3 = '';
|
||
|
|
||
|
// die;
|
||
|
$car_info->save();
|
||
|
CarCT::deleteAll(['id'=>$car_info->id]);
|
||
|
|
||
|
$e_info = CarET::findOne(['id'=>$car_info->id]);
|
||
|
if(!$e_info) {
|
||
|
$e_info = new CarET();
|
||
|
$e_info->id = $car_info->id;
|
||
|
$e_info->user_id = 0;
|
||
|
$e_info->save();
|
||
|
$insert_total++;
|
||
|
$this->addLog($car_info->id,'从C库分配到E库',1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// die;
|
||
|
$result['success'] = true;
|
||
|
$result['msg'] = '操作成功';
|
||
|
|
||
|
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = 'c-e';
|
||
|
$log->total = $total;
|
||
|
$log->success = $insert_total;
|
||
|
$log->success_rate = ($insert_total/$total) * 100;
|
||
|
$log->save();
|
||
|
echo $result['msg'];
|
||
|
}
|
||
|
private function getE_DQuery()
|
||
|
{
|
||
|
$query = CarET::find()
|
||
|
->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_e_t`.`id`');
|
||
|
//开始时间
|
||
|
$bgstr= date("Y-m-d",time());
|
||
|
//$bgar=explode('-',$bgstr);
|
||
|
//list($bm, $bd) = $bgar;
|
||
|
//结束时间
|
||
|
$endstr=date("Y-m-d",strtotime("+95 day"));
|
||
|
//$edar=explode('-',$endstr);
|
||
|
//list($em, $ed) = $edar;
|
||
|
// $query = $query->andWhere('car_t.insurer1_date<="'.$bgstr.'"');
|
||
|
$query = $query->andWhere('car_t.insurer1_date="'.$endstr.'"');
|
||
|
//$query = $query->andWhere('month(car_t.insurer1_date)>="'.$em.'"');
|
||
|
//$query = $query->andWhere('day(car_t.insurer1_date)>="'.$ed.'"');
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
return ['query'=>$query];
|
||
|
}
|
||
|
|
||
|
//跟踪库中的数据在距保险到期日90天时,自动转入续保库(E库到D库)
|
||
|
public function actionEMoved()
|
||
|
{
|
||
|
|
||
|
$result = array();
|
||
|
$result['success'] = false;
|
||
|
$result['msg'] = '操作失败';
|
||
|
|
||
|
|
||
|
$data = $this->getE_DQuery();
|
||
|
$query = $data['query'];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$total = $query->count();
|
||
|
// var_dump($total);
|
||
|
// die;
|
||
|
$insert_total = 0;
|
||
|
if($total){
|
||
|
foreach($query->each(100) as $e_info) {
|
||
|
$car_info = CarT::findOne(['id'=>$e_info->id]);
|
||
|
|
||
|
if($car_info->location == 6) {
|
||
|
// var_dump($car_info);
|
||
|
$car_info->location = 4;
|
||
|
|
||
|
// die;
|
||
|
$car_info->save();
|
||
|
|
||
|
CarET::deleteAll(['id'=>$car_info->id]);
|
||
|
|
||
|
$d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
// var_dump($d_info);
|
||
|
// die;
|
||
|
if(!$d_info) {
|
||
|
$d_info = new CarDT();
|
||
|
$d_info->id = $car_info->id;
|
||
|
$d_info->user_id = 0;
|
||
|
$d_info->save();
|
||
|
$insert_total++;
|
||
|
$this->addLog($car_info->id,'从E库分配到D库',1);
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// die;
|
||
|
$result['success'] = true;
|
||
|
$result['msg'] = '操作成功';
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = 'e-d';
|
||
|
|
||
|
$log->total = $total;
|
||
|
$log->success = $insert_total;
|
||
|
if($total){
|
||
|
$log->success_rate = ($insert_total/$total) * 100;
|
||
|
}else{
|
||
|
$log->success_rate = 0;
|
||
|
}
|
||
|
|
||
|
$log->save();
|
||
|
echo $result['msg'];
|
||
|
}
|
||
|
|
||
|
private function getF_DQuery()
|
||
|
{
|
||
|
$query = CarFT::find()
|
||
|
->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_f_t`.`id`');
|
||
|
//开始时间
|
||
|
// $bgstr= date("y-m-d",time());
|
||
|
//$bgar=explode('-',$bgstr);
|
||
|
//list($bm, $bd) = $bgar;
|
||
|
//结束时间
|
||
|
$endstr=date("Y-m-d",strtotime("+90 day"));
|
||
|
//$edar=explode('-',$endstr);
|
||
|
//list($em, $ed) = $edar;
|
||
|
// $query = $query->andWhere('car_t.insurer1_date<="'.$bgstr.'"');
|
||
|
$query = $query->andWhere('car_t.insurer1_date ="'.$endstr.'"');
|
||
|
//$query = $query->andWhere('month(car_t.insurer1_date)>="'.$em.'"');
|
||
|
//$query = $query->andWhere('day(car_t.insurer1_date)>="'.$ed.'"');
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
return ['query'=>$query];
|
||
|
}
|
||
|
|
||
|
//其他平台续保库在距保险到期日90天时,自动转入续保库;(F库到D库)
|
||
|
public function actionFMoved()
|
||
|
{
|
||
|
|
||
|
$result = array();
|
||
|
$result['success'] = false;
|
||
|
$result['msg'] = '操作失败';
|
||
|
|
||
|
|
||
|
$data = $this->getF_DQuery();
|
||
|
$query = $data['query'];
|
||
|
|
||
|
|
||
|
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$total = $query->count();
|
||
|
$insert_total = 0;
|
||
|
if($total){
|
||
|
foreach($query->each(100) as $f_info) {
|
||
|
$car_info = CarT::findOne(['id'=>$f_info->id]);
|
||
|
var_dump($car_info);
|
||
|
|
||
|
if($car_info->location == 7) {
|
||
|
|
||
|
$car_info->location = 4;
|
||
|
|
||
|
// die;
|
||
|
$car_info->save();
|
||
|
|
||
|
CarFT::deleteAll(['id'=>$car_info->id]);
|
||
|
|
||
|
$d_info = CarDT::findOne(['id'=>$car_info->id]);
|
||
|
if(!$d_info) {
|
||
|
$d_info = new CarDT();
|
||
|
$d_info->id = $car_info->id;
|
||
|
$d_info->user_id = 0;
|
||
|
$d_info->save();
|
||
|
$insert_total++;
|
||
|
$this->addLog($car_info->id,'从F库分配到D库',1);
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
|
||
|
$result['success'] = true;
|
||
|
$result['msg'] = '操作成功';
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = 'f-d';
|
||
|
$log->total = $total;
|
||
|
$log->success = $insert_total;
|
||
|
if($total){
|
||
|
$log->success_rate = ($insert_total/$total) * 100;
|
||
|
}else{
|
||
|
$log->success_rate = 0;
|
||
|
}
|
||
|
$log->save();
|
||
|
echo $result['msg'];
|
||
|
}
|
||
|
private function getCdifQuery()
|
||
|
{
|
||
|
$query = CarCT::find()
|
||
|
->leftJoin(CarT::tableName(),'`car_t`.`id`=`car_c_t`.`id`');
|
||
|
//开始时间
|
||
|
// $bgstr= date("y-m-d",time());
|
||
|
//$bgar=explode('-',$bgstr);
|
||
|
//list($bm, $bd) = $bgar;
|
||
|
//结束时间
|
||
|
|
||
|
//$edar=explode('-',$endstr);
|
||
|
//list($em, $ed) = $edar;
|
||
|
// $query = $query->andWhere('car_t.insurer1_date<="'.$bgstr.'"');
|
||
|
$query = $query->andWhere('car_c_t.dif !=0');
|
||
|
//$query = $query->andWhere('month(car_t.insurer1_date)>="'.$em.'"');
|
||
|
//$query = $query->andWhere('day(car_t.insurer1_date)>="'.$ed.'"');
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
return ['query'=>$query];
|
||
|
}
|
||
|
|
||
|
//C库无效的数据放到F4
|
||
|
public function actionCdifF4()
|
||
|
{
|
||
|
|
||
|
$result = array();
|
||
|
$result['success'] = false;
|
||
|
$result['msg'] = '操作失败';
|
||
|
|
||
|
|
||
|
$data = $this->getCdifQuery();
|
||
|
$query = $data['query'];
|
||
|
|
||
|
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
try {
|
||
|
$total = $query->count();
|
||
|
$insert_total = 0;
|
||
|
if($total){
|
||
|
foreach($query->each(100) as $f_info) {
|
||
|
$car_info = CarT::findOne(['id'=>$f_info->id]);
|
||
|
// var_dump($car_info);
|
||
|
// die;
|
||
|
|
||
|
if($car_info->location == 3) {
|
||
|
|
||
|
$car_info->location = 11;
|
||
|
|
||
|
// die;
|
||
|
$car_info->save();
|
||
|
|
||
|
CarCT::deleteAll(['id'=>$car_info->id]);
|
||
|
|
||
|
$d_info = CarF4T::findOne(['id'=>$car_info->id]);
|
||
|
if(!$d_info) {
|
||
|
$d_info = new CarF4T();
|
||
|
$d_info->id = $car_info->id;
|
||
|
$d_info->user_id = 0;
|
||
|
$d_info->save();
|
||
|
$insert_total++;
|
||
|
$this->addLog($car_info->id,'从C库分配到F4库',1);
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
|
||
|
$result['success'] = true;
|
||
|
$result['msg'] = '操作成功';
|
||
|
|
||
|
$tran->commit();
|
||
|
} catch (\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
$log = new ImportLogT();
|
||
|
$log->filename = 'c-f4';
|
||
|
$log->total = $total;
|
||
|
$log->success = $insert_total;
|
||
|
if($total){
|
||
|
$log->success_rate = ($insert_total/$total) * 100;
|
||
|
}else{
|
||
|
$log->success_rate = 0;
|
||
|
}
|
||
|
$log->save();
|
||
|
echo $result['msg'];
|
||
|
}
|
||
|
|
||
|
public function actionEkuYuyue()
|
||
|
{
|
||
|
// CarET::find()->where([])
|
||
|
$query = AppointmentT::find()
|
||
|
->select('`car_t`.*,`appointment_t`.*')
|
||
|
->leftJoin(CarT::tableName(),'`car_t`.`id`=`appointment_t`.`car_id`')
|
||
|
->where(['<=','car_t.insurer1_date','2019-05-05']);
|
||
|
// ->where('car_t.insurer1_date<= "2019-05-05"');
|
||
|
// aa($query);
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// $data=$query->all();
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
$i=0;
|
||
|
try {
|
||
|
// if ($data) {
|
||
|
foreach ($query->each(1000) as $e) {
|
||
|
// var_dump($e->id);
|
||
|
// die;
|
||
|
// AppointmentT::deleteAll(['car_id' => $e->id]);
|
||
|
$car_info=CarT::findOne($e->car_id);
|
||
|
if($car_info->location==6){
|
||
|
$e->delete();
|
||
|
}
|
||
|
$car_info->location = 1;
|
||
|
$car_info->save();
|
||
|
// var_dump($car_info->save());
|
||
|
// die;
|
||
|
|
||
|
$i++;
|
||
|
|
||
|
}
|
||
|
// }
|
||
|
|
||
|
$tran->commit();
|
||
|
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo $i;
|
||
|
echo 'ok';
|
||
|
// ->where();
|
||
|
}
|
||
|
public function actionBkuYuyue()
|
||
|
{
|
||
|
// CarET::find()->where([])
|
||
|
$endstr1=date("Y-m-d",strtotime("+90 day"));
|
||
|
for($k = 1999; $k <= 2019; $k++) {
|
||
|
$beginDate = $k.'-05-05';
|
||
|
$endData = $k.'-01-01';
|
||
|
$query = AppointmentT::find()
|
||
|
->select('`car_t`.*,`appointment_t`.*')
|
||
|
->leftJoin(CarT::tableName(),'`car_t`.`id`=`appointment_t`.`car_id`')
|
||
|
->where(['<=','car_t.insurer1_date',$beginDate])
|
||
|
->andWhere(['>=','car_t.insurer1_date', $endData]);
|
||
|
// ->andWhere(['>=','car_t.insurer1_date',$endstr1]);
|
||
|
// ->where('car_t.insurer1_date<= "2019-05-05"');
|
||
|
// aa($query);
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// die;
|
||
|
// $data=$query->all();
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
$i=0;
|
||
|
try {
|
||
|
// if ($data) {
|
||
|
foreach ($query->each(1000) as $e) {
|
||
|
// var_dump($e->id);
|
||
|
// die;
|
||
|
// AppointmentT::deleteAll(['car_id' => $e->id]);
|
||
|
$car_info=CarT::findOne($e->car_id);
|
||
|
if($car_info->location==2){
|
||
|
$e->delete();
|
||
|
}
|
||
|
$car_info->location = 1;
|
||
|
$car_info->save();
|
||
|
// var_dump($car_info->save());
|
||
|
// die;
|
||
|
echo $e->car_id."\r\n";
|
||
|
$i++;
|
||
|
|
||
|
}
|
||
|
// }
|
||
|
|
||
|
$tran->commit();
|
||
|
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo $i;
|
||
|
echo 'ok';
|
||
|
}
|
||
|
// ->where();
|
||
|
}
|
||
|
public function actionBkuYuyue1()
|
||
|
{
|
||
|
// CarET::find()->where([])
|
||
|
for($k = 1999; $k <= 2019; $k++) {
|
||
|
$endstr1=date("-m-d",strtotime("+90 day"));
|
||
|
$beginDate = $k.$endstr1;
|
||
|
$endData = $k.'-12-31';
|
||
|
$query = AppointmentT::find()
|
||
|
->select('`car_t`.*,`appointment_t`.*')
|
||
|
->leftJoin(CarT::tableName(),'`car_t`.`id`=`appointment_t`.`car_id`')
|
||
|
// ->where(['<=','car_t.insurer1_date','2019-05-05']);
|
||
|
->andWhere(['>=','car_t.insurer1_date',$beginDate])
|
||
|
->andWhere(['<=','car_t.insurer1_date',$endData]);
|
||
|
// ->where('car_t.insurer1_date<= "2019-05-05"');
|
||
|
// aa($query);
|
||
|
// echo $query->createCommand()->rawSql;
|
||
|
// die;
|
||
|
// $data=$query->all();
|
||
|
$tran = CarT::getDb()->beginTransaction();
|
||
|
$i=0;
|
||
|
try {
|
||
|
// if ($data) {
|
||
|
foreach ($query->each(1000) as $e) {
|
||
|
// var_dump($e->id);
|
||
|
// die;
|
||
|
// AppointmentT::deleteAll(['car_id' => $e->id]);
|
||
|
$car_info=CarT::findOne($e->car_id);
|
||
|
if($car_info->location==2){
|
||
|
$e->delete();
|
||
|
}
|
||
|
$car_info->location = 1;
|
||
|
$car_info->save();
|
||
|
// var_dump($car_info->save());
|
||
|
// die;
|
||
|
echo $e->car_id."\r\n";
|
||
|
$i++;
|
||
|
|
||
|
}
|
||
|
// }
|
||
|
|
||
|
$tran->commit();
|
||
|
|
||
|
} catch(\Exception $e) {
|
||
|
$tran->rollBack();
|
||
|
throw $e;
|
||
|
}
|
||
|
echo $i;
|
||
|
echo 'ok';
|
||
|
// ->where();
|
||
|
}
|
||
|
}
|
||
|
}
|