作者 lyh

GX生成白帽报表脚本

... ... @@ -39,7 +39,31 @@ class UpdateProjectTdk extends Command
}
$info = $noticeLogModel->read(['id'=>$task_id]);
if($info === false){
$project_id = $info['data']['project_id'] ?? 0;
if(empty($project_id)){
echo date('Y-m-d H:i:s').'未获取到项目id.'.PHP_EOL;
$noticeLogModel->edit(['status'=>$noticeLogModel::STATUS_FAIL],['id'=>$task_id]);
continue;
}
$url = $info['data']['url'] ?? '';
if(empty($url)){
echo date('Y-m-d H:i:s').'未获取到项目更新文件.项目id为:'.$project_id.PHP_EOL;
//未获取到文件,跳过
$noticeLogModel->edit(['status'=>$noticeLogModel::STATUS_SUCCESS],['id'=>$task_id]);
continue;
}
if (!file_exists($url)) {
return '文件不存在';
}
// 载入 Excel
$spreadsheet = IOFactory::load($url);
$sheet = $spreadsheet->getActiveSheet();
$rows = $sheet->toArray();
dd($rows);
// 假设第一行是表头
$header = $rows[0];
$dataRows = array_slice($rows, 1);
}
}
return true;
... ...