作者 lyh
@@ -102,7 +102,7 @@ class HtmlCollect extends Command @@ -102,7 +102,7 @@ class HtmlCollect extends Command
102 $source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']); 102 $source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
103 103
104 if ($source_list) { 104 if ($source_list) {
105 - $html = $this->upload_source($html, $source_list, $project_id); 105 + $html = $this->upload_source($html, $source_list, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
106 } 106 }
107 } catch (\Exception $e) { 107 } catch (\Exception $e) {
108 $collect_info->status = CollectTask::STATUS_FAIL; 108 $collect_info->status = CollectTask::STATUS_FAIL;
@@ -321,7 +321,7 @@ class HtmlCollect extends Command @@ -321,7 +321,7 @@ class HtmlCollect extends Command
321 } 321 }
322 322
323 //下载并替换资源 323 //下载并替换资源
324 - protected function upload_source($html, $source, $project_id) 324 + protected function upload_source($html, $source, $project_id, $domain, $web_url_domain, $home_url)
325 { 325 {
326 foreach ($source as $vs) { 326 foreach ($source as $vs) {
327 327
@@ -337,21 +337,17 @@ class HtmlCollect extends Command @@ -337,21 +337,17 @@ class HtmlCollect extends Command
337 ]); 337 ]);
338 $html = str_replace($vs['url'], getImageUrl($new_source), $html); 338 $html = str_replace($vs['url'], getImageUrl($new_source), $html);
339 339
340 - if (substr($new_source, -3, 3) == 'css' || substr($new_source, -2, 2) == 'js') {  
341 - $source_html = curl_c($vs['url_complete'], false);  
342 if (substr($new_source, -3, 3) == 'css') { 340 if (substr($new_source, -3, 3) == 'css') {
343 - preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $source_html, $result_source);  
344 - } else {  
345 - preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $source_html, $result_source);  
346 - }  
347 - $source_list = $result_source[1] ?? []; 341 + // 下载css文件中的资源
  342 + $css_html = curl_c($vs['url_complete'], false);
  343 + preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source);
  344 + $css_source = $result_css_source[1] ?? [];
348 345
349 $url_arr = explode('/', $vs['url_complete']); 346 $url_arr = explode('/', $vs['url_complete']);
350 $target_arr = explode('/', $new_source); 347 $target_arr = explode('/', $new_source);
351 - foreach ($source_list as $vcs) { 348 + foreach ($css_source as $vcs) {
352 $vcs = str_replace('"', '', $vcs); 349 $vcs = str_replace('"', '', $vcs);
353 $vcs_arr = parse_url($vcs); 350 $vcs_arr = parse_url($vcs);
354 -  
355 if (isset($vcs_arr['domain'])) { 351 if (isset($vcs_arr['domain'])) {
356 //不是相对路径,不下载 352 //不是相对路径,不下载
357 continue; 353 continue;
@@ -391,6 +387,34 @@ class HtmlCollect extends Command @@ -391,6 +387,34 @@ class HtmlCollect extends Command
391 ]); 387 ]);
392 } 388 }
393 } 389 }
  390 + } elseif (substr($new_source, -2, 2) == 'js') {
  391 + $js_html = curl_c(getImageUrl($new_source), false);
  392 + preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);
  393 + $js_source = $result_js_source[1] ?? [];
  394 + foreach ($js_source as $vjs) {
  395 + $vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);
  396 + if (!$vjs_result) {
  397 + continue;
  398 + }
  399 +
  400 + if ($vjs_result['download']) {
  401 + $new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);
  402 + if ($new_vjs) {
  403 + CollectSource::insert([
  404 + 'project_id' => $project_id,
  405 + 'origin' => $vjs_result['url'],
  406 + 'target' => $new_vjs,
  407 + 'created_at' => date('Y-m-d H:i:s'),
  408 + 'updated_at' => date('Y-m-d H:i:s'),
  409 + ]);
  410 + $js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html);
  411 + }
  412 + } else {
  413 + $js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);
  414 + }
  415 + }
  416 +
  417 + CosService::uploadRemote($project_id, 'source', $new_source, $new_source, $js_html);
394 } 418 }
395 } 419 }
396 } else { 420 } else {
@@ -544,6 +544,20 @@ class ProjectController extends BaseController @@ -544,6 +544,20 @@ class ProjectController extends BaseController
544 $this->map['entry_position'] = ['in',$this->map['entry_position']]; 544 $this->map['entry_position'] = ['in',$this->map['entry_position']];
545 } 545 }
546 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']); 546 $lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
  547 +
  548 + //zgj 售后技术排序调整 start
  549 + if(isset($this->map['entry_position'][1]) && in_array(45,$this->map['entry_position'][1])){
  550 + $ar_sort = ['王娇'=>1,'银蝶'=>2,'胡哲'=>3,'郭婷婷'=>4,'徐庆'=>5,'邓锦康'=>6,'兰波'=>7];
  551 + foreach ($lists as $k=>$v){
  552 + $lists[$k]['sort'] = 0;
  553 + if(in_array($v['name'],array_keys($ar_sort))){
  554 + $lists[$k]['sort'] = $ar_sort[$v['name']];
  555 + }
  556 + }
  557 + $sort_arr = array_column($lists, 'sort');
  558 + array_multisort($sort_arr,SORT_DESC,$lists);
  559 + }
  560 + //售后技术排序调整 end
547 $this->response('success',Code::SUCCESS,$lists); 561 $this->response('success',Code::SUCCESS,$lists);
548 } 562 }
549 563
@@ -69,11 +69,12 @@ class CosService @@ -69,11 +69,12 @@ class CosService
69 * @param $image_type 69 * @param $image_type
70 * @param $file_url 70 * @param $file_url
71 * @param $key 71 * @param $key
  72 + * @param $body_str
72 * @return string 73 * @return string
73 * @author Akun 74 * @author Akun
74 * @date 2023/09/21 9:39 75 * @date 2023/09/21 9:39
75 */ 76 */
76 - public static function uploadRemote($project_id,$image_type,$file_url,$key='') 77 + public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='')
77 { 78 {
78 if(!$key){ 79 if(!$key){
79 $url_arr = parse_url($file_url); 80 $url_arr = parse_url($file_url);
@@ -96,7 +97,7 @@ class CosService @@ -96,7 +97,7 @@ class CosService
96 ]); 97 ]);
97 98
98 try { 99 try {
99 - $body = curl_c($file_url,false); 100 + $body = $body_str ?:curl_c($file_url,false);
100 }catch (\Exception $e){ 101 }catch (\Exception $e){
101 return ''; 102 return '';
102 } 103 }