作者 lyh
... ... @@ -59,22 +59,30 @@ class UpdateController extends BaseController
'type.required' => '采集类型不能为空',
]);
$update_info = UpdateLog::where('project_id', $this->param['project_id'])->first();
if (!$update_info) {
$this->fail('当前项目非升级项目,无法采集');
$collect_un = UpdateLog::where('project_id', $this->param['project_id'])->where('collect_status', 0)->get();
if ($collect_un->count() > 0) {
$this->fail('项目正在采集中');
}
$project = ProjectServer::useProject($this->param['project_id']);
if ($project) {
try {
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
} catch (\Exception $e) {
errorLog('重新采集升级项目数据', $this->param, $e);
$this->fail('采集任务添加失败');
}
if(!$project){
$this->fail('项目不存在');
}
if ($project->is_upgrade != 1) {
$this->fail('非升级无法进行采集操作');
}
try {
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
} catch (\Exception $e) {
errorLog('重新采集升级项目数据', $this->param, $e);
$this->fail('采集任务添加失败');
}
//关闭数据库
DB::disconnect('custom_mysql');
... ...