123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <?php
- namespace App\Console\Commands;
- use App\Repositories\Enums\Base\AdminTypeEnum;
- use App\Repositories\Enums\BikeManage\BindingOperateTypeEnum;
- use App\Repositories\Enums\BikeManage\BindingStatusEnum;
- use App\Repositories\Enums\Car\BillDisburseEnum;
- use App\Repositories\Enums\Car\OrderDrivingStatusEnum;
- use App\Repositories\Enums\Car\OrderPayTypeEnum;
- use App\Repositories\Enums\Check\StatusEnum;
- use App\Repositories\Enums\ModelStatusEnum;
- use App\Repositories\Models\Base\Admin;
- use App\Repositories\Models\Base\Department;
- use App\Repositories\Models\Base\User;
- use App\Repositories\Models\BikeManage\Bike;
- use App\Repositories\Models\BikeManage\Binding;
- use App\Repositories\Models\Car\Bill;
- use App\Repositories\Models\Car\Order;
- use App\Repositories\Models\Car\OrderLog;
- use Carbon\Carbon;
- use GuzzleHttp\Client;
- use GuzzleHttp\Cookie\CookieJar;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Hash;
- use Illuminate\Support\Str;
- /**
- * Class PresenterCommand
- * @package Prettus\Repository\Generators\Commands
- * @author Anderson Andrade <contato@andersonandra.de>
- */
- 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;
- }
- }
|