From 98e2e8f96250badb04d003123e03bc80e0174f5c Mon Sep 17 00:00:00 2001 From: zhaocheng <578322713@qq.com> Date: Tue, 30 Aug 2022 18:47:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=BD=A6=E6=9E=B6=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=90=8E=E4=BF=9D=E5=AD=98=E6=BA=90=E4=BF=A1=E6=81=AF?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/ExportLogT.php.bak | 0 extend/service/CarInfoHandle.php | 35 +++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) delete mode 100644 app/model/ExportLogT.php.bak 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'];