diff --git a/extend/service/CarInfoHandle.php b/extend/service/CarInfoHandle.php index 68a2a4c..920ab87 100644 --- a/extend/service/CarInfoHandle.php +++ b/extend/service/CarInfoHandle.php @@ -47,8 +47,11 @@ class CarInfoHandle }); $values = array_slice($arr, 0, $keys_len); $values[$keys_len - 1] = $id; - return array_combine($keys, $values); + $data = array_combine($keys, $values); + $data['register_date'] = date('Y-m-d', strtotime($data['register_date'])); + return $data; }); + Db::name('car_info_t')->insertAll($insert_data); cache('shell_process_' . $id, round(($i + 2000) / $lines * 100, 3), 300); echo '当前进度:' . round(round(($i + 2000) / $lines * 100, 3)) . PHP_EOL; @@ -475,7 +478,7 @@ class CarInfoHandle for ($row = 2; $row <= $highestRow; $row++) { $row_array[] = [ 'duty_no' => $worksheet->getCellByColumnAndRow(1, $row)->getValue(), - 'register_date' => $worksheet->getCellByColumnAndRow(2, $row)->getValue(), + 'register_date' => date('Y-m-d', strtotime($worksheet->getCellByColumnAndRow(2, $row)->getValue())), 'car_man' => $worksheet->getCellByColumnAndRow(3, $row)->getValue(), 'car_number' => $worksheet->getCellByColumnAndRow(4, $row)->getValue(), 'car_phone' => $worksheet->getCellByColumnAndRow(5, $row)->getValue(), @@ -487,10 +490,12 @@ class CarInfoHandle 'create_timestamp' => $now, 'update_timestamp' => $now ]; + + if ($row >= 1000) { Db::name('car_info_t')->insertAll($row_array); - cache('shell_process_' . $id, round(($i + 2000) / $lines * 100, 3), 300); - echo '当前进度:' . round(round(($i + 2000) / $lines * 100, 3)) . PHP_EOL; + cache('shell_process_' . $id, round(($row - 1) / $highestRow * 100, 3), 300); + echo '当前进度:' . round(round(($row - 1) / $highestRow * 100, 3)) . PHP_EOL; $row_array = []; } }