|
...
|
...
|
@@ -97,6 +97,7 @@ class ProjectImport extends Command |
|
|
|
$success_count = 0; //成功导入条数
|
|
|
|
$repeat_count = 0; //过滤已存在条数
|
|
|
|
$fail_count = 0;
|
|
|
|
$fail_line = [];
|
|
|
|
if (count($line_of_text) > 1) {
|
|
|
|
|
|
|
|
//设置数据库
|
|
...
|
...
|
@@ -134,6 +135,7 @@ class ProjectImport extends Command |
|
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$fail_count += 1;
|
|
|
|
$fail_line[] = $k + 1;
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', title: ' . $v[0] . ', import fail, error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -148,7 +150,7 @@ class ProjectImport extends Command |
|
|
|
$task->success_count += $success_count;
|
|
|
|
$task->save();
|
|
|
|
|
|
|
|
$this->send_mail($task->user_id, $task->created_at, $task->type, $success_count, $fail_count, $repeat_count, '');
|
|
|
|
$this->send_mail($task->user_id, $task->created_at, $task->type, $success_count, $fail_count, $repeat_count, '', $fail_line);
|
|
|
|
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import end, total count: ' . $total_count . ', success count: ' . $success_count . PHP_EOL;
|
|
|
|
|
|
...
|
...
|
@@ -192,7 +194,7 @@ class ProjectImport extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
//发送站内通知
|
|
|
|
protected function send_mail($user_list, $time, $type, $success_count, $repeat_count, $fail_count, $reason)
|
|
|
|
protected function send_mail($user_list, $time, $type, $success_count, $repeat_count, $fail_count, $reason, $fail_line = [])
|
|
|
|
{
|
|
|
|
if ($type == ImportTask::TYPE_NEWS) {
|
|
|
|
$type_content = '新闻';
|
|
...
|
...
|
@@ -206,6 +208,7 @@ class ProjectImport extends Command |
|
|
|
$repeat_count && $content .= ',过滤已存在数据:' . $repeat_count . ' 条';
|
|
|
|
$fail_count && $content .= ',导入失败:' . $fail_count . ' 条';
|
|
|
|
$reason && $content .= ',原因:' . $reason;
|
|
|
|
$fail_line && $content .= ',失败行数:' . implode(',', $fail_line);
|
|
|
|
|
|
|
|
$mail_model = new Mail();
|
|
|
|
$mail_model->add([
|
...
|
...
|
|