*/ class LoadlogsCommand extends Command { /** * The name of command. * * @var string */ protected $name = 'load:logs'; /** * The description of command. * * @var string */ protected $description = 'test'; /** * The type of class being generated. * * @var string */ protected $type = 'permission'; private $cookieJar = null; private $client = null; /** * Execute the command. * * @return void * @see fire() */ public function handle() { $this->client = new Client(); $cookie_str = 'HWWAFSESID=50dfc7357adc6e0919; HWWAFSESTIME=1710222167359; MOD_AUTH_CAS=ST-iap:1018617332602740:ST:7c922f18-b70a-4bbb-b6a3-9fb10dc9b97f:20240312134247'; $cookie_arr = str2arr($cookie_str, '; '); $cookie = []; foreach ($cookie_arr as $v) { list($key, $val) = str2arr($v, '='); $cookie[$key] = $val; } $this->cookieJar = CookieJar::fromArray($cookie, 'hactcm.campusphere.net'); $categories = $this->loadCategory(); foreach ($categories as $category) { $da = $this->loadLogsData([ 'dateType' => 5, 'dateStart' => '2024-02-01', 'dateEnd' => '2024-03-12', 'deptWid' => '73230', 'formWid' => $category['wid'], 'idOrName' => '', 'ownDeptWid' => '-1', 'pageNumber' => 1, 'pageSize' => 8, 'searchFillContent' => '', 'searchStuContent' => '', 'sortColumn' => '', 'sortOrder' => '', 'teacherUserWids' => [], ]); dd($da); } $this->line('ok'); } public static function parseResult($result) { $result = js2php($result); if (!is_array($result)) return []; return $result['datas']['rows']; } public function loadCategory() { $response = $this->client->request('POST', 'https://hactcm.campusphere.net/wec-counselor-worklog-apps/worklog/template/listActiveTemplate', [ 'cookies' => $this->cookieJar, 'headers' => [ 'Content-Type' => 'application/json' ], 'json' => [ 'status' => 1, ] ]); // 获取响应体 $result = $response->getBody()->getContents(); return self::parseResult($result); } public function loadLogsData($param) { $page = 1; $pre_page = 10; $total_page = 1; $data = []; $filed = []; do { $param['pageNumber'] = $page; $param['pageSize'] = $pre_page; $response = $this->client->request('POST', 'https://hactcm.campusphere.net/wec-counselor-worklog-apps/worklogSummary/queryWorkLogsInSummary', [ 'cookies' => $this->cookieJar, 'headers' => [ 'Content-Type' => 'application/json' ], 'json' => $param ]); // 获取响应体 $result = $response->getBody()->getContents(); $result = js2php($result); if (is_array($result) && !$result['code']) { $datas = $result['datas']; $total_page = $datas['totalSize']; if (!count($filed)) { foreach ($datas['summaryCols'] as $col) { $filed[$col['colName']] = $col['colTitle']; } } foreach ($datas['rows'] as $row) { $rowData = []; foreach ($row as $item) { $rowData[$item['colName']] = $item['value']; } $data[] = $rowData; } } $page++; } while ($page <= $total_page); return $data; } }