update socket
This commit is contained in:
@@ -154,7 +154,7 @@ class VehicleController extends Controller {
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
//
|
||||
// public function actionImport() {
|
||||
// $file_type = \PHPExcel_IOFactory::identify("data/data.xlsx");
|
||||
// $objReader = \PHPExcel_IOFactory::createReader($file_type);
|
||||
@@ -165,12 +165,12 @@ class VehicleController extends Controller {
|
||||
// if ($k > 1) {
|
||||
// $model = new Vehicle();
|
||||
// $kq[] = $model->create([
|
||||
// 'plate' => $this->formatPlate($row["B"]),
|
||||
// 'plate' => $this->format($row["B"]),
|
||||
// 'type' => $row["C"],
|
||||
// 'company' => $row["D"],
|
||||
// 'vehicle_type' => $row["E"],
|
||||
// 'driver' => $row["F"],
|
||||
// 'telephone' => $this->formatPlate($row["G"]),
|
||||
// 'telephone' => $this->format($row["G"]),
|
||||
// 'indentity_card' => strval($row["H"])
|
||||
// ]);
|
||||
// }
|
||||
@@ -180,11 +180,77 @@ class VehicleController extends Controller {
|
||||
// echo "</pre>";
|
||||
// exit();
|
||||
// }
|
||||
//
|
||||
|
||||
public function format($plate) {
|
||||
$p1 = str_replace("-", "", $plate);
|
||||
$p2 = str_replace(".", "", $p1);
|
||||
return str_replace(" ", "", $p2);
|
||||
$p3 = str_replace("\n", "", $p2);
|
||||
return str_replace(" ", "", $p3);
|
||||
}
|
||||
//
|
||||
// public function actionExport() {
|
||||
// set_time_limit(3600);
|
||||
// $vehicles = Vehicle::find()->orderBy(['plate' => SORT_ASC])->all();
|
||||
// $connection = Yii::$app->getDb();
|
||||
// foreach ($vehicles as $k => $v) {
|
||||
// $command = $connection->createCommand("SELECT * FROM `vehicle` WHERE `plate`<>'{$v->plate}' AND levenshtein('%{$v->plate}', `plate`) BETWEEN 0 AND 1");
|
||||
// $result = $command->queryAll();
|
||||
// $temp = [];
|
||||
// foreach ($result as $key => $value) {
|
||||
// $temp[] = $value['plate'];
|
||||
// }
|
||||
// $v->levenshtein_plate_2 = json_encode($temp);
|
||||
// $v->save();
|
||||
// }
|
||||
// exit();
|
||||
//
|
||||
// $objPHPExcel = new \PHPExcel();
|
||||
// $count = 1;
|
||||
// $objPHPExcel->setActiveSheetIndex(0);
|
||||
// $toExcelFile[] = [
|
||||
// "STT",
|
||||
// "Biển số",
|
||||
// "Gần giống",
|
||||
// "Công ty",
|
||||
// "Lái xe"
|
||||
// ];
|
||||
// foreach ($vehicles as $k => $v) {
|
||||
// $ExportData[] = $count++;
|
||||
// $ExportData[] = $v->plate;
|
||||
// $connection = Yii::$app->getDb();
|
||||
// $command = $connection->createCommand("SELECT * FROM `vehicle` WHERE levenshtein(':plate_query', `plate`) BETWEEN 0 AND 2 AND `plate`<>':plate_query'", [':plate_query' => $v->plate]);
|
||||
// $result = $command->queryAll();
|
||||
// $ExportData[] = count($result);
|
||||
// $ExportData[] = $v->company;
|
||||
// $ExportData[] = $v->driver;
|
||||
// $toExcelFile[] = $ExportData;
|
||||
// unset($ExportData);
|
||||
// }
|
||||
// $activeSheet = $objPHPExcel->getActiveSheet();
|
||||
// $rowCount = 1;
|
||||
// for ($i = 0; $i < count($toExcelFile); $i++) {
|
||||
// $column = 'A';
|
||||
// $row = $toExcelFile[$i];
|
||||
// for ($j = 0; $j < count($row); $j++) {
|
||||
// if (!isset($row[$j]))
|
||||
// $value = NULL;
|
||||
// elseif ($row[$j] != "")
|
||||
// $value = strip_tags($row[$j]);
|
||||
// else
|
||||
// $value = "";
|
||||
// $activeSheet->setCellValue($column . $rowCount, $value);
|
||||
// $column = chr(ord($column) + 1);
|
||||
// }
|
||||
// $rowCount++;
|
||||
// }
|
||||
//
|
||||
// $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
// ob_end_clean();
|
||||
// header('Content-type: application/vnd.ms-excel');
|
||||
// header('Content-Disposition: attachment; filename="bao-cao.xlsx"');
|
||||
// header('Cache-Control: max-age=0');
|
||||
// $objWriter->save('php://output');
|
||||
// exit();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user