diff --git a/app/model/ExportLogT.php.bak b/app/model/ExportLogT.php.bak deleted file mode 100644 index e69de29..0000000 diff --git a/extend/service/CarInfoHandle.php b/extend/service/CarInfoHandle.php index b2775cd..a70ab88 100644 --- a/extend/service/CarInfoHandle.php +++ b/extend/service/CarInfoHandle.php @@ -260,21 +260,14 @@ class CarInfoHandle echo '总计:' . $count . PHP_EOL; $current = 0; $faild_num = 0; - $map = []; - if (isset($data['export_date1']) && $data['export_date1'] != '') { - $map[] = ['register_date', '>=', $data['export_date1']]; - } - if (isset($data['export_date2']) && $data['export_date2'] != '') { - $map[] = ['register_date', '<=', $data['export_date2']]; - } cache('shell_process_' . $id, 0, 300); - $query->chunk(1000, function ($infos) use (&$current, &$faild_num, $count, $id, $map) { + $query->chunk(1000, function ($infos) use (&$current, &$faild_num, $count, $id) { foreach ($infos as $item) { if ($current % 10 == 0) { cache('shell_process_' . $id, round($current / $count * 100, 3), 300); echo '当前进度:' . round($current / $count * 100, 3) . PHP_EOL; } - $ids = CarInfoT::where('car_phone', $item->phone)->where($map)->column('id'); + $ids = CarInfoT::where('car_phone', $item->phone)->column('id'); Db::startTrans(); try { CarInfoT::where('id', 'in', $ids) @@ -329,31 +322,32 @@ class CarInfoHandle try { foreach ($sources as $index => $source) { if (empty(trim($source['car_phone']))) { - $ids = array_column($sources, 'id'); - CarInfoT::destroy($ids); + foreach ($sources as $source_data) { + $this->repeatDataHandle($source_data, $id, 'frame'); + } RepeatFrameT::where('car_frame_no', $item->car_frame_no)->delete(); $sources = []; break; } else if ($source_a['car_phone'] == $source['car_phone']) { if ($source_a['insurer1_date'] != $source['insurer1_date'] && (trim($source_a['insurer1_date']) == '' || $source_a['insurer1_date'] < $source['insurer1_date'])) { list($source_a, $source) = [$source, $source_a]; - CarInfoT::destroy($source['id']); + $this->repeatDataHandle($source, $id, 'frame'); unset($sources[$index]); } else if ($source_a['insurer2_date'] != $source['insurer2_date'] && (trim($source_a['insurer2_date']) == '' || $source_a['insurer2_date'] < $source['insurer2_date'])) { list($source_a, $source) = [$source, $source_a]; - CarInfoT::destroy($source['id']); + $this->repeatDataHandle($source, $id, 'frame'); unset($sources[$index]); } else if ($source_a['car_no'] != $source['car_no'] && (trim($source_a['car_no']) == '' || !in_array(strlen($source_a['car_no']), [7,8]))) { list($source_a, $source) = [$source, $source_a]; - CarInfoT::destroy($source['id']); + $this->repeatDataHandle($source, $id, 'frame'); unset($sources[$index]); } if (isset($sources[$index])) { - CarInfoT::destroy($source['id']); + $this->repeatDataHandle($source, $id, 'frame'); unset($sources[$index]); } } else if (!preg_match('/^1[3-9][0-9]{9}/', $source['car_phone'])) { - CarInfoT::destroy($source['id']); + $this->repeatDataHandle($source, $id, 'frame'); unset($sources[$index]); } else { $phones = [$source['car_phone']]; @@ -375,6 +369,7 @@ class CarInfoHandle break; } CarInfoT::where('id', $source_a['id'])->update($source_a); + $this->repeatDataHandle($source, $id, 'frame'); CarInfoT::destroy($source['id']); unset($sources[$index]); } @@ -491,6 +486,14 @@ class CarInfoHandle 跳过数据列:" . implode(',', $statistical_information['total_skip_arr']); } + private function repeatDataHandle($data, $id, $type) + { + if ($type == 'frame') { + CarInfoT::destroy($data['id']); + } + + } + private function importExcel($data, $id) { $filename = public_path('public/storage') . $data['filename'];