|
|
@ -290,9 +290,10 @@ class CarInfoHandle |
|
|
|
$count = $query->count(); |
|
|
|
$count = $query->count(); |
|
|
|
echo '总计:' . $count . PHP_EOL; |
|
|
|
echo '总计:' . $count . PHP_EOL; |
|
|
|
$current = 0; |
|
|
|
$current = 0; |
|
|
|
|
|
|
|
$delete_num = 0; |
|
|
|
$faild_num = 0; |
|
|
|
$faild_num = 0; |
|
|
|
cache('shell_process_' . $id, 0, 300); |
|
|
|
cache('shell_process_' . $id, 0, 300); |
|
|
|
$query->chunk(1000, function ($infos) use (&$current, &$faild_num, $count, $id) { |
|
|
|
$query->chunk(1000, function ($infos) use (&$current, &$delete_num, &$faild_num, $count, $id) { |
|
|
|
foreach ($infos as $item) { |
|
|
|
foreach ($infos as $item) { |
|
|
|
if ($current % 10 == 0) { |
|
|
|
if ($current % 10 == 0) { |
|
|
|
cache('shell_process_' . $id, round($current / $count * 100, 3), 300); |
|
|
|
cache('shell_process_' . $id, round($current / $count * 100, 3), 300); |
|
|
@ -315,15 +316,14 @@ class CarInfoHandle |
|
|
|
if (empty($source_a)) { |
|
|
|
if (empty($source_a)) { |
|
|
|
$source_a = $sources[0]; |
|
|
|
$source_a = $sources[0]; |
|
|
|
array_shift($sources); |
|
|
|
array_shift($sources); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Db::startTrans(); |
|
|
|
Db::startTrans(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
foreach ($sources as $index => $source) { |
|
|
|
foreach ($sources as $index => $source) { |
|
|
|
if (empty(trim($source['car_phone']))) { |
|
|
|
if (empty(trim($source['car_phone']))) { |
|
|
|
foreach ($sources as $source_data) { |
|
|
|
foreach ($sources as $source_data) { |
|
|
|
$this->repeatDataHandle($source_data, $id, 'frame'); |
|
|
|
$this->repeatDataHandle($source_data, $id, 'frame'); |
|
|
|
|
|
|
|
$delete_num ++; |
|
|
|
} |
|
|
|
} |
|
|
|
RepeatFrameT::where('car_frame_no', $item->car_frame_no)->delete(); |
|
|
|
RepeatFrameT::where('car_frame_no', $item->car_frame_no)->delete(); |
|
|
|
$sources = []; |
|
|
|
$sources = []; |
|
|
@ -332,22 +332,27 @@ class CarInfoHandle |
|
|
|
if ($source_a['insurer1_date'] != $source['insurer1_date'] && (trim($source_a['insurer1_date']) == '' || $source_a['insurer1_date'] < $source['insurer1_date'])) { |
|
|
|
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]; |
|
|
|
list($source_a, $source) = [$source, $source_a]; |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
|
|
|
|
$delete_num ++; |
|
|
|
unset($sources[$index]); |
|
|
|
unset($sources[$index]); |
|
|
|
} else if ($source_a['insurer2_date'] != $source['insurer2_date'] && (trim($source_a['insurer2_date']) == '' || $source_a['insurer2_date'] < $source['insurer2_date'])) { |
|
|
|
} 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]; |
|
|
|
list($source_a, $source) = [$source, $source_a]; |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
|
|
|
|
$delete_num ++; |
|
|
|
unset($sources[$index]); |
|
|
|
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]))) { |
|
|
|
} 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]; |
|
|
|
list($source_a, $source) = [$source, $source_a]; |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
|
|
|
|
$delete_num ++; |
|
|
|
unset($sources[$index]); |
|
|
|
unset($sources[$index]); |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($sources[$index])) { |
|
|
|
if (isset($sources[$index])) { |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
|
|
|
|
$delete_num ++; |
|
|
|
unset($sources[$index]); |
|
|
|
unset($sources[$index]); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (!preg_match('/^1[3-9][0-9]{9}/', $source['car_phone'])) { |
|
|
|
} else if (!preg_match('/^1[3-9][0-9]{9}/', $source['car_phone'])) { |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
|
|
|
|
$delete_num ++; |
|
|
|
unset($sources[$index]); |
|
|
|
unset($sources[$index]); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$phones = [$source['car_phone']]; |
|
|
|
$phones = [$source['car_phone']]; |
|
|
@ -370,6 +375,7 @@ class CarInfoHandle |
|
|
|
} |
|
|
|
} |
|
|
|
CarInfoT::where('id', $source_a['id'])->update($source_a); |
|
|
|
CarInfoT::where('id', $source_a['id'])->update($source_a); |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
$this->repeatDataHandle($source, $id, 'frame'); |
|
|
|
|
|
|
|
$delete_num ++; |
|
|
|
CarInfoT::destroy($source['id']); |
|
|
|
CarInfoT::destroy($source['id']); |
|
|
|
unset($sources[$index]); |
|
|
|
unset($sources[$index]); |
|
|
|
} |
|
|
|
} |
|
|
@ -385,7 +391,7 @@ class CarInfoHandle |
|
|
|
$current++; |
|
|
|
$current++; |
|
|
|
} |
|
|
|
} |
|
|
|
}, 'car_frame_no'); |
|
|
|
}, 'car_frame_no'); |
|
|
|
return '处理总数:' . $count . ', 失败总数:' . $faild_num; |
|
|
|
return '处理总数:' . $count . ', 删除总数:' . $delete_num . ', 失败总数:' . $faild_num; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function carInfoUpdate($data, $id) |
|
|
|
public function carInfoUpdate($data, $id) |
|
|
|