导入检查车架号有效且相同数据更新

master
zhaocheng 2 years ago
parent 2cd9b85e5e
commit 9ce4011b64
  1. 64
      extend/service/CarInfoHandle.php

@ -555,40 +555,44 @@ class CarInfoHandle
$register_date = date('Y-m-d', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($register_date)); $register_date = date('Y-m-d', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($register_date));
else else
$register_date = date('Y-m-d', strtotime(trim(trim($register_date, '"')))); $register_date = date('Y-m-d', strtotime(trim(trim($register_date, '"'))));
$row_array[] = [ $frame_no = trim(trim($worksheet->getCellByColumnAndRow(6, $row)->getValue(), '"'));
'duty_no' => trim(trim($worksheet->getCellByColumnAndRow(1, $row)->getValue(), '"')), $row_array = [
'register_date' => $register_date, 'duty_no' => trim(trim($worksheet->getCellByColumnAndRow(1, $row)->getValue(), '"')),
'car_man' => trim(trim($worksheet->getCellByColumnAndRow(3, $row)->getValue(), '"')), 'register_date' => $register_date,
'car_number' => trim(trim($worksheet->getCellByColumnAndRow(4, $row)->getValue(), '"')), 'car_man' => trim(trim($worksheet->getCellByColumnAndRow(3, $row)->getValue(), '"')),
'car_phone' => trim(trim($worksheet->getCellByColumnAndRow(5, $row)->getValue(), '"')), 'car_number' => trim(trim($worksheet->getCellByColumnAndRow(4, $row)->getValue(), '"')),
'car_frame_no' => trim(trim($worksheet->getCellByColumnAndRow(6, $row)->getValue(), '"')), 'car_phone' => trim(trim($worksheet->getCellByColumnAndRow(5, $row)->getValue(), '"')),
'car_no' => str_replace('-', '', trim(trim($worksheet->getCellByColumnAndRow(7, $row)->getValue(), '"'))), 'car_frame_no' => $frame_no,
'engine_no' => trim(trim($worksheet->getCellByColumnAndRow(8, $row)->getValue(), '"')), 'car_no' => str_replace('-', '', trim(trim($worksheet->getCellByColumnAndRow(7, $row)->getValue(), '"'))),
'factory_model' => trim(trim($worksheet->getCellByColumnAndRow(9, $row)->getValue(), '"')), 'engine_no' => trim(trim($worksheet->getCellByColumnAndRow(8, $row)->getValue(), '"')),
'purchase_price' => trim(trim($worksheet->getCellByColumnAndRow(10, $row)->getValue(), '"')), 'factory_model' => trim(trim($worksheet->getCellByColumnAndRow(9, $row)->getValue(), '"')),
'insurer2_date' => trim(trim($worksheet->getCellByColumnAndRow(11, $row)->getValue(), '"')), 'purchase_price' => trim(trim($worksheet->getCellByColumnAndRow(10, $row)->getValue(), '"')),
'insurer1_date' => trim(trim($worksheet->getCellByColumnAndRow(12, $row)->getValue(), '"')), 'insurer2_date' => trim(trim($worksheet->getCellByColumnAndRow(11, $row)->getValue(), '"')),
'link_man_1' => trim(trim($worksheet->getCellByColumnAndRow(13, $row)->getValue(), '"')), 'insurer1_date' => trim(trim($worksheet->getCellByColumnAndRow(12, $row)->getValue(), '"')),
'link_phone_1' => trim(trim($worksheet->getCellByColumnAndRow(14, $row)->getValue(), '"')), 'link_man_1' => trim(trim($worksheet->getCellByColumnAndRow(13, $row)->getValue(), '"')),
'link_man_2' => trim(trim($worksheet->getCellByColumnAndRow(15, $row)->getValue(), '"')), 'link_phone_1' => trim(trim($worksheet->getCellByColumnAndRow(14, $row)->getValue(), '"')),
'link_phone_2' => trim(trim($worksheet->getCellByColumnAndRow(16, $row)->getValue(), '"')), 'link_man_2' => trim(trim($worksheet->getCellByColumnAndRow(15, $row)->getValue(), '"')),
'tag' => trim(trim($worksheet->getCellByColumnAndRow(17, $row)->getValue(), '"')), 'link_phone_2' => trim(trim($worksheet->getCellByColumnAndRow(16, $row)->getValue(), '"')),
'source' => $id, 'tag' => trim(trim($worksheet->getCellByColumnAndRow(17, $row)->getValue(), '"')),
'create_timestamp' => $now, 'source' => $id,
'update_timestamp' => $now 'create_timestamp' => $now,
'update_timestamp' => $now
]; ];
if (count($row_array) > 1000) { // 有效车架号且存在更新并清除状态
Db::name('car_info_t')->insertAll($row_array); if (strlen($frame_no) == 17 && ($id = Db::name('car_info_t')->where('car_frame_no', $frame_no)->value('id'))) {
cache('shell_process_' . $id, round(($row - 1) / $highestRow * 100, 3), 300); $row_array['is_export_bhx'] = 0;
echo '当前进度:' . round(round(($row - 1) / $highestRow * 100, 3)) . PHP_EOL; $row_array['is_update_bhx'] = 0;
$row_array = []; $row_array['is_export_bmc'] = 0;
$row_array['is_export_failed'] = 0;
$row_array['is_export_none_bmc'] = 0;
$row_array['is_export_failed_bmc'] = 0;
Db::name('car_info_t')->where('id', $id)->insert($row_array);
} else {
Db::name('car_info_t')->insert($row_array);
} }
}
if (count($row_array) > 0) {
Db::name('car_info_t')->insertAll($row_array);
cache('shell_process_' . $id, round(($row - 1) / $highestRow * 100, 3), 300); cache('shell_process_' . $id, round(($row - 1) / $highestRow * 100, 3), 300);
echo '当前进度:' . round(round(($row - 1) / $highestRow * 100, 3)) . PHP_EOL; echo '当前进度:' . round(round(($row - 1) / $highestRow * 100, 3)) . PHP_EOL;
$row_array = [];
} }
Db::execute('ALTER TABLE car_info_t ENABLE KEYS;'); Db::execute('ALTER TABLE car_info_t ENABLE KEYS;');
$t2 = microtime(true); $t2 = microtime(true);

Loading…
Cancel
Save