更新数据调试2

master
zcstatham 1 year ago
parent 9ce4011b64
commit bdb7d4c764
  1. 9
      extend/service/CarInfoHandle.php

@ -548,6 +548,7 @@ class CarInfoHandle
$highestRow = $worksheet->getHighestRow(); // e.g. 10
echo '总计:' . $highestRow . PHP_EOL;
$now = date('Y-m-d H:i:s');
$update_keys = ['register_date', 'car_no', 'car_frame_no', 'engine_no', 'factory_model', 'car_year', 'displacement', 'car_man', 'car_number', 'car_phone', 'purchase_price', 'id_man', 'id_number', 'id_phone', 'insured_man', 'insured_number', 'insured_phone', 'company', 'insurer1_date', 'insurer2_date'];
Db::execute('ALTER TABLE car_info_t DISABLE KEYS;');
for ($row = 2; $row <= $highestRow; $row++) {
$register_date = $worksheet->getCellByColumnAndRow(2, $row)->getValue();
@ -579,14 +580,18 @@ class CarInfoHandle
'update_timestamp' => $now
];
// 有效车架号且存在更新并清除状态
if (strlen($frame_no) == 17 && ($id = Db::name('car_info_t')->where('car_frame_no', $frame_no)->value('id'))) {
if (strlen($frame_no) == 17 && ($old = Db::name('car_info_t')->where('car_frame_no', $frame_no)->value('id'))) {
foreach ($update_keys as $key) {
if (empty($row_array[$key]))
$row_array[$key] = $old[$key];
}
$row_array['is_export_bhx'] = 0;
$row_array['is_update_bhx'] = 0;
$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);
Db::name('car_info_t')->where('id', $id)->save($row_array);
} else {
Db::name('car_info_t')->insert($row_array);
}

Loading…
Cancel
Save