cqp před 1 dnem
rodič
revize
34b95afef4

+ 30 - 2
app/Http/Controllers/Api/TestController.php

@@ -2,13 +2,41 @@
 
 namespace App\Http\Controllers\Api;
 
-use App\Service\qyWechatService;
 use App\Service\TestService;
 use Illuminate\Http\Request;
-use Illuminate\Support\Str;
 
 class TestController extends BaseController
 {
+    public function testpj(Request $request){
+        list($bool, $data) = (new TestService())->testpj($request->all());
+
+        if($bool){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function testpjget(Request $request){
+        list($bool, $data) = (new TestService())->testpjget($request->all());
+
+        if($bool){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function testpjput(Request $request){
+        list($bool, $data) = (new TestService())->testpjput($request->all());
+
+        if($bool){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
     public function testdwy(Request $request){
         list($bool, $data) = (new TestService())->testdwy($request->all());
 

+ 78 - 2
app/Service/TestService.php

@@ -4,12 +4,88 @@ namespace App\Service;
 
 use App\Model\RecordTable;
 use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\Config;
-use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 
 class TestService extends Service
 {
+    public function testPjCommonRule($data){
+        if(empty($data['domain'])) return [false, '域名不能为空'];
+        $url = $data['domain'] . '/api/module-data/asst_daily_schedule/asst_daily_schedule/diy/get_current_daily_schedule';
+        $json = '{}';
+
+        list($status, $result) = $this->post_helper($url,$json, $data['header'], 30,'pj预先调用');
+        if(! $status) return [false, $result];
+
+        if(isset($result['message']) && $result['message'] == 'error.unAuthorized') return [false, $result['description'] ?? '用户未登录或失效'];
+        if(isset($result['status']) && $result['status'] == 'error') return [false, $result['message'] ?? '系统错误,请联系管理员'];
+
+        return [true, ''];
+    }
+
+    public function testpj($data){
+        if(empty($data['url']) || empty($data['post']) || empty($data['header'])) return [false,'API请求参数不能为空'];
+        list($status, $msg) = $this->testPjCommonRule($data);
+        if(! $status) return [false, $msg];
+
+        $url = $data['url'];
+//        $oldUrl = config('ip.zslf');
+//        $newUrl = config('ip.zslfip');
+//        $url = str_replace($oldUrl, $newUrl, $url);
+
+        $post = $data['post'];
+        $header = $data['header'];
+
+        $json = json_encode($post);
+        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',$json);
+        $json = str_replace('"loginBindingParameters":[]','"loginBindingParameters":{}',$json);
+
+        list($status, $result) = $this->post_helper($url,$json, $header, 40,'pj');
+        if(! $status) return [false, $result];
+
+        return [true, $result];
+    }
+
+    public function testpjget($data){
+        if(empty($data['url']) || empty($data['header'])) return [false,'API请求参数不能为空'];
+        list($status, $msg) = $this->testPjCommonRule($data);
+        if(! $status) return [false, $msg];
+
+        $url = $data['url'];
+//        $oldUrl = config('ip.zslf');
+//        $newUrl = config('ip.zslfip');
+//        $url = str_replace($oldUrl, $newUrl, $url);
+
+        $header = $data['header'];
+
+        list($status,$result) = $this->get_helper($url,$header);
+        if(! $status) return [false, $result];
+
+        return [true, $result];
+    }
+
+    public function testpjput($data){
+        if(empty($data['url']) || empty($data['post']) || empty($data['header'])) return [false,'API请求参数不能为空'];
+        list($status, $msg) = $this->testPjCommonRule($data);
+        if(! $status) return [false, $msg];
+
+        $url = $data['url'];
+//        $oldUrl = config('ip.zslf');
+//        $newUrl = config('ip.zslfip');
+//        $url = str_replace($oldUrl, $newUrl, $url);
+
+        $post = $data['post'];
+        $header = $data['header'];
+
+        $json = json_encode($post);
+        $json = str_replace('"workflowSearchBean":{}','"workflowSearchBean":[]',json_encode($post));
+        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
+
+        list($status, $result) = $this->put_helper($url,$json, $header,40);
+        if(! $status) return [false, $result];
+
+        return [true, $result];
+    }
+
     public function testdwy($data){
         if(empty($data['url']) || empty($data['post']) || empty($data['header'])) return [false,'API请求参数不能为空'];
         $url = $data['url'];

+ 6 - 0
routes/api.php

@@ -27,6 +27,12 @@ Route::any('screenPrintSepData', 'Api\JRFIDController@screenPrintSepData');
 Route::any('pdfLogo', 'Api\ThirdController@pdfLogo');
 Route::any('pdfData', 'Api\ThirdController@pdfData');
 
+//重庆普建
+Route::any('testpj','Api\TestController@testpj');
+Route::any('testpjget','Api\TestController@testpjget');
+Route::any('testpjput','Api\TestController@testpjput');
+
+//大王椰
 Route::any('testdwy','Api\TestController@testdwy');
 Route::any('testdwyget','Api\TestController@testdwyget');
 Route::any('testdwyput','Api\TestController@testdwyput');