作者 lyh

GX生成白帽报表脚本

@@ -39,7 +39,31 @@ class UpdateProjectTdk extends Command @@ -39,7 +39,31 @@ class UpdateProjectTdk extends Command
39 } 39 }
40 $info = $noticeLogModel->read(['id'=>$task_id]); 40 $info = $noticeLogModel->read(['id'=>$task_id]);
41 if($info === false){ 41 if($info === false){
  42 + $project_id = $info['data']['project_id'] ?? 0;
  43 + if(empty($project_id)){
  44 + echo date('Y-m-d H:i:s').'未获取到项目id.'.PHP_EOL;
  45 + $noticeLogModel->edit(['status'=>$noticeLogModel::STATUS_FAIL],['id'=>$task_id]);
  46 + continue;
  47 + }
  48 + $url = $info['data']['url'] ?? '';
  49 + if(empty($url)){
  50 + echo date('Y-m-d H:i:s').'未获取到项目更新文件.项目id为:'.$project_id.PHP_EOL;
  51 + //未获取到文件,跳过
  52 + $noticeLogModel->edit(['status'=>$noticeLogModel::STATUS_SUCCESS],['id'=>$task_id]);
  53 + continue;
  54 + }
  55 + if (!file_exists($url)) {
  56 + return '文件不存在';
  57 + }
42 58
  59 + // 载入 Excel
  60 + $spreadsheet = IOFactory::load($url);
  61 + $sheet = $spreadsheet->getActiveSheet();
  62 + $rows = $sheet->toArray();
  63 + dd($rows);
  64 + // 假设第一行是表头
  65 + $header = $rows[0];
  66 + $dataRows = array_slice($rows, 1);
43 } 67 }
44 } 68 }
45 return true; 69 return true;