|
...
|
...
|
@@ -10,10 +10,15 @@ namespace App\Console\Commands\Test; |
|
|
|
use App\Models\Blog\Blog;
|
|
|
|
use App\Models\Devops\ServerConfig;
|
|
|
|
use App\Models\File\Image;
|
|
|
|
use App\Models\Manage\BelongingGroup;
|
|
|
|
use App\Models\Manage\Dept;
|
|
|
|
use App\Models\Manage\EntryPosition;
|
|
|
|
use App\Models\Manage\ManageHr;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class Demo extends Command
|
|
|
|
{
|
|
...
|
...
|
@@ -41,11 +46,185 @@ class Demo extends Command |
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
|
|
|
|
{
|
|
|
|
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
|
|
|
if ($data)
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
|
|
|
|
'Expect:',
|
|
|
|
'Content-type: application/json',
|
|
|
|
'Accept: application/json',
|
|
|
|
], $header)
|
|
|
|
);
|
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
|
|
|
$response = curl_exec($ch);
|
|
|
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
curl_close($ch);
|
|
|
|
return [$code, $response];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
dd(isset($data['a']['b']));
|
|
|
|
$url = 'https://demo.globalso.site/';
|
|
|
|
$action = 'api/updateHtmlNotify/';
|
|
|
|
$data = [
|
|
|
|
'project_id' => 1,
|
|
|
|
'type' => 1,
|
|
|
|
'route' => 1
|
|
|
|
];;
|
|
|
|
$method = 'GET';
|
|
|
|
$result = $this->curlRequest($url . $action, $data, $method);
|
|
|
|
dd($result);
|
|
|
|
|
|
|
|
$context = stream_context_create([
|
|
|
|
'ssl' => [
|
|
|
|
'capture_peer_cert' => true,
|
|
|
|
'capture_peer_cert_chain' => false,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
|
|
|
|
|
|
|
|
if(!$stream) {
|
|
|
|
die("Failed to connect: $errno - $errstr");
|
|
|
|
}
|
|
|
|
|
|
|
|
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
|
|
|
|
|
|
|
|
if(!$remote_cert) {
|
|
|
|
die("Failed to retrieve certificate");
|
|
|
|
}
|
|
|
|
|
|
|
|
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
|
|
|
|
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
|
|
|
|
|
|
|
|
fclose($stream);
|
|
|
|
|
|
|
|
echo "Certificate Valid From: $valid_from<br>";
|
|
|
|
echo "Certificate Valid To: $valid_to<br>";
|
|
|
|
|
|
|
|
dd('end');
|
|
|
|
$dept_array = [
|
|
|
|
'品牌部',
|
|
|
|
'综合部',
|
|
|
|
'渠道部',
|
|
|
|
'广告推广部',
|
|
|
|
'AICC运营部',
|
|
|
|
'黑格运营部',
|
|
|
|
'直营运营部',
|
|
|
|
'直营销售部',
|
|
|
|
'深圳跨境部',
|
|
|
|
'外贸部',
|
|
|
|
'研发部',
|
|
|
|
'技术部',
|
|
|
|
'售后部',
|
|
|
|
];
|
|
|
|
foreach ($dept_array as $v) {
|
|
|
|
$dept = Dept::where(['title' => $v])->first();
|
|
|
|
if (FALSE == empty($dept))
|
|
|
|
continue;
|
|
|
|
$dept = new Dept();
|
|
|
|
$dept->title = $v;
|
|
|
|
$dept->save();
|
|
|
|
}
|
|
|
|
// dd('dept end');
|
|
|
|
$dept_map = Dept::pluck('title', 'id')->toArray();
|
|
|
|
$belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
|
|
|
|
// dd($belonging_map);
|
|
|
|
|
|
|
|
$filename = storage_path('logs/oa_hr.txt');
|
|
|
|
$string = file_get_contents($filename);
|
|
|
|
$data = explode("\r\n", $string);
|
|
|
|
$data = array_filter($data);
|
|
|
|
$dept = '';
|
|
|
|
foreach ($data as $k=>$v) {
|
|
|
|
// var_dump($v) . PHP_EOL;
|
|
|
|
if ($k == 1)
|
|
|
|
continue;
|
|
|
|
$tmp = explode("\t", $v);
|
|
|
|
if (count($tmp) == 3) {
|
|
|
|
$dept = $tmp[0] ? : $dept;
|
|
|
|
$position = $tmp[1];
|
|
|
|
$name = $tmp[2];
|
|
|
|
} else if (count($tmp) == 2) {
|
|
|
|
$position = $tmp[0];
|
|
|
|
$name = $tmp[1];
|
|
|
|
} else {
|
|
|
|
Log::info($v . PHP_EOL);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
$dept_id = array_search($dept, $dept_map);
|
|
|
|
$belonging_id = 17;
|
|
|
|
if (FALSE !== strpos($dept,'技术部')) {
|
|
|
|
$belonging_string = str_replace('技术部', '', $dept);
|
|
|
|
if ($belonging_string) {
|
|
|
|
$belonging_string = $belonging_string . '组';
|
|
|
|
$belonging_id = array_search($belonging_string, $belonging_map);
|
|
|
|
}
|
|
|
|
|
|
|
|
$dept_tmp = '技术部';
|
|
|
|
$dept_id = array_search($dept_tmp, $dept_map);
|
|
|
|
}
|
|
|
|
if (FALSE !== strpos($dept,'售后')) {
|
|
|
|
$belonging_string = str_replace('售后', '', $dept);
|
|
|
|
if ($belonging_string)
|
|
|
|
$belonging_id = array_search($belonging_string, $belonging_map);
|
|
|
|
$dept_tmp = '售后部';
|
|
|
|
$dept_id = array_search($dept_tmp, $dept_map);
|
|
|
|
}
|
|
|
|
|
|
|
|
$position_log = EntryPosition::where(['name' => $position])->first();
|
|
|
|
if (empty($position_log)) {
|
|
|
|
$position_log = new EntryPosition();
|
|
|
|
$position_log->name = $position;
|
|
|
|
$position_log->save();
|
|
|
|
}
|
|
|
|
$position_id = $position_log->id;
|
|
|
|
|
|
|
|
$hr = ManageHr::where(['name' => $name])->first();
|
|
|
|
if (empty($hr)) {
|
|
|
|
Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$hr->belong_group = $belonging_id;
|
|
|
|
$hr->dept_id = $dept_id;
|
|
|
|
$hr->entry_position = $position_id;
|
|
|
|
$hr->save();
|
|
|
|
echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
|
|
|
|
|
|
|
|
}
|
|
|
|
dd('end');
|
|
|
|
exit;
|
|
|
|
|
|
|
|
if (($handle = fopen($filename, 'r')) !== false) {
|
|
|
|
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
|
|
|
|
// 处理每行数据
|
|
|
|
Log::info(var_export($data, true));
|
|
|
|
}
|
|
|
|
fclose($handle);
|
|
|
|
}
|
|
|
|
exit;
|
|
|
|
|
|
|
|
$group = BelongingGroup::get();
|
|
|
|
dd($group->toArray());
|
|
|
|
$domain = parse_url('https//:dev.golbalso.site/');
|
|
|
|
dd($domain);
|
|
|
|
echo time() . PHP_EOL;
|
...
|
...
|
|