master
zhaocheng 4 years ago
parent a9d24fad4c
commit 4a7329a704
  1. 48
      extend/service/CarInfoHandle.php

@ -361,7 +361,7 @@ class CarInfoHandle
return '处理总数:' . $count . ', 失败总数:' . $faild_num; return '处理总数:' . $count . ', 失败总数:' . $faild_num;
} }
public function carInfoUpdate($data, $id) public function carInfoUpdate($data, $id)
{ {
$filename = public_path('public/storage') . $data['filename']; $filename = public_path('public/storage') . $data['filename'];
if (empty($filename) OR !file_exists($filename)) { if (empty($filename) OR !file_exists($filename)) {
@ -394,7 +394,7 @@ class CarInfoHandle
$insurer2_date = trim($worksheet->getCellByColumnAndRow(9, $row)->getValue()); $insurer2_date = trim($worksheet->getCellByColumnAndRow(9, $row)->getValue());
$id_man = trim($worksheet->getCellByColumnAndRow(10, $row)->getValue()); $id_man = trim($worksheet->getCellByColumnAndRow(10, $row)->getValue());
$id_number = trim($worksheet->getCellByColumnAndRow(11, $row)->getValue()); $id_number = trim($worksheet->getCellByColumnAndRow(11, $row)->getValue());
if($car_frame_no == ''){ if ($car_frame_no == '') {
continue; continue;
} }
$car_info = CarInfoT::where('car_frame_no', $car_frame_no)->find(); $car_info = CarInfoT::where('car_frame_no', $car_frame_no)->find();
@ -422,7 +422,7 @@ class CarInfoHandle
$car_info->id_number = $car_info->id_number != '' && startsWith($car_info->id_number, rtrim($id_number, '*')) ? $car_info->id_number : $id_number; $car_info->id_number = $car_info->id_number != '' && startsWith($car_info->id_number, rtrim($id_number, '*')) ? $car_info->id_number : $id_number;
} }
$car_info->is_update_bhx = $id; $car_info->is_update_bhx = $id;
$car_info->is_export_failed = 0; $car_info->is_export_failed = 0;
if (!$car_info->save()) { if (!$car_info->save()) {
$statistical_information['total_error']++; $statistical_information['total_error']++;
$statistical_information['total_error_arr'][] = $row; $statistical_information['total_error_arr'][] = $row;
@ -436,20 +436,20 @@ class CarInfoHandle
cache('shell_process_' . $id, round($row / $total * 100, 3), 300); cache('shell_process_' . $id, round($row / $total * 100, 3), 300);
echo '当前进度:' . round($row / $total * 100, 3) . PHP_EOL; echo '当前进度:' . round($row / $total * 100, 3) . PHP_EOL;
} }
if($is_update_failed > 0){ if ($is_update_failed > 0) {
CarInfoT::where('is_export_failed', $is_update_failed) CarInfoT::where('is_export_failed', $is_update_failed)
->update(['is_export_failed' => 0, 'is_update_bhx' => Db::raw('is_update_bhx - 1')]); ->update(['is_export_failed' => 0, 'is_update_bhx' => Db::raw('is_update_bhx - 1')]);
}else if($car_info && $car_info->is_update_bhx <= 0) { } else if ($car_info && $car_info->is_update_bhx <= 0) {
CarInfoT::where('is_update_bhx', 0) CarInfoT::where('is_update_bhx', 0)
->where('is_export_bhx', $car_info->is_export_bhx) ->where('is_export_bhx', $car_info->is_export_bhx)
->update(['is_update_bhx' => -1]); ->update(['is_update_bhx' => -1]);
} }
return '操作成功' . "数据总计{$statistical_information['total_all']}条, return '操作成功' . "数据总计{$statistical_information['total_all']}条,
更新{$statistical_information['total_update']}, 更新{$statistical_information['total_update']},
失败{$statistical_information['total_error']}, 失败{$statistical_information['total_error']},
失败数据列:" . implode(',', $statistical_information['total_error_arr']) . ", 失败数据列:" . implode(',', $statistical_information['total_error_arr']) . ",
跳过{$statistical_information['total_skip']}, 跳过{$statistical_information['total_skip']},
跳过数据列:" . implode(',', $statistical_information['total_skip_arr']); 跳过数据列:" . implode(',', $statistical_information['total_skip_arr']);
} }
private function importExcel($data, $id) private function importExcel($data, $id)
@ -524,8 +524,11 @@ class CarInfoHandle
$this->setProcess(++$current, $count, $id); $this->setProcess(++$current, $count, $id);
} }
FileSystem::appendWriteFile($filename, $content, false); FileSystem::appendWriteFile($filename, $content, false);
$export_limit != 0 && CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]); if($export_limit != 0 && $export_type == 'success_bmc'){
$export_limit != 0 && $export_type == 'success_bmc' && CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]); CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]);
} else if($export_limit != 0) {
CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]);
}
} else { } else {
$info = $query->limit(3000)->select(); $info = $query->limit(3000)->select();
$limit = $count; $limit = $count;
@ -541,8 +544,11 @@ class CarInfoHandle
$this->setProcess(++$current, $count, $id); $this->setProcess(++$current, $count, $id);
} }
FileSystem::appendWriteFile($filename, $content, false); FileSystem::appendWriteFile($filename, $content, false);
$export_limit != 0 && CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]); if($export_limit != 0 && $export_type == 'success_bmc'){
$export_limit != 0 && $export_type == 'success_bmc' && CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]); CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]);
} else if($export_limit != 0) {
CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]);
}
$limit -= 3000; $limit -= 3000;
$end = $info->pop(); $end = $info->pop();
$lastRegisterDate = is_array($end) ? $end['register_date'] : $end->getData('register_date'); $lastRegisterDate = is_array($end) ? $end['register_date'] : $end->getData('register_date');
@ -575,8 +581,11 @@ class CarInfoHandle
} }
$this->setProcess($row, $count * 1.2, $id); $this->setProcess($row, $count * 1.2, $id);
} }
$export_limit != 0 && CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]); if($export_limit != 0 && $export_type == 'success_bmc'){
$export_limit != 0 && $export_type == 'success_bmc' && CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]); CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]);
} else if($export_limit != 0) {
CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]);
}
} else { } else {
$info = $query->limit(3000)->select(); $info = $query->limit(3000)->select();
$limit = $count; $limit = $count;
@ -590,8 +599,11 @@ class CarInfoHandle
} }
$this->setProcess($row, $count * 1.2, $id); $this->setProcess($row, $count * 1.2, $id);
} }
$export_limit != 0 && CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]); if($export_limit != 0 && $export_type == 'success_bmc'){
$export_limit != 0 && $export_type == 'success_bmc' && CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]); CarInfoT::where('id', 'in', $ids)->update(['is_export_bmc' => 0]);
} else if($export_limit != 0) {
CarInfoT::where('id', 'in', $ids)->update(['is_export_' . $export_type => $id]);
}
$limit -= 3000; $limit -= 3000;
$end = $info->pop(); $end = $info->pop();
$lastRegisterDate = is_array($end) ? $end['register_date'] : $end->getData('register_date'); $lastRegisterDate = is_array($end) ? $end['register_date'] : $end->getData('register_date');

Loading…
Cancel
Save