导入行重复处理修复

master
zcstatham 2 years ago
parent bf4cb311de
commit d806da099e
  1. 6
      extend/service/CarInfoHandle.php

@ -38,7 +38,7 @@ class CarInfoHandle
cache('shell_process_' . $id, 0, 300); cache('shell_process_' . $id, 0, 300);
Db::execute('ALTER TABLE car_info_t DISABLE KEYS;'); Db::execute('ALTER TABLE car_info_t DISABLE KEYS;');
for ($i = 2; $i < $lines; $i += 2000) { for ($i = 2; $i < $lines; $i += 2000) {
$insert_data = FileSystem::getFileBlockData($filename, $i, $i + 2000, function ($str) use ($id) { $insert_data = FileSystem::getFileBlockData($filename, $i, $i + 1999, function ($str) use ($id) {
$keys = ['duty_no', 'register_date', 'car_man', 'car_number', 'car_phone', 'car_frame_no', 'car_no', 'engine_no', 'factory_model', 'purchase_price', 'source']; $keys = ['duty_no', 'register_date', 'car_man', 'car_number', 'car_phone', 'car_frame_no', 'car_no', 'engine_no', 'factory_model', 'purchase_price', 'source'];
$keys_len = count($keys); $keys_len = count($keys);
$arr = explode(',', $str); $arr = explode(',', $str);
@ -47,7 +47,7 @@ class CarInfoHandle
}); });
$values = array_slice($arr, 0, $keys_len); $values = array_slice($arr, 0, $keys_len);
$values[$keys_len - 1] = $id; $values[$keys_len - 1] = $id;
$data = array_combine($keys, $values); $data = array_combine($keys, $values);
$data['register_date'] = date('Y-m-d', strtotime($data['register_date'])); $data['register_date'] = date('Y-m-d', strtotime($data['register_date']));
return $data; return $data;
}); });
@ -490,8 +490,6 @@ class CarInfoHandle
'create_timestamp' => $now, 'create_timestamp' => $now,
'update_timestamp' => $now 'update_timestamp' => $now
]; ];
if ($row >= 1000) { if ($row >= 1000) {
Db::name('car_info_t')->insertAll($row_array); 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);

Loading…
Cancel
Save