瀏覽代碼

客户端入口方法,适配接口

ligao 5 月之前
父節點
當前提交
b78892ced5
共有 1 個文件被更改,包括 61 次插入254 次删除
  1. 61 254
      application/index/controller/Index.php

+ 61 - 254
application/index/controller/Index.php

@@ -65,26 +65,28 @@ class Index extends \think\Controller
 		]);
     }
     
-    //客户端
-    public function chatBox2(){
+        
+          //客户端
+    public function chatBox(){
+        $ragId =  request() -> param('ragId');
         $mobileType = 'unknow';
         $data['publicKey'] = commonPublicKey();
         $url = commonOpenURLLocal()."/apis/searchRag";
         $ragList = curlPost($url,$data);
- 
-        if($ragList != null){
-            $ragList = json_decode($ragList);
-            $ragList = $ragList->rags;
-            $ragList = stdClassObjToArray($ragList);
+        $ragList = json_decode($ragList);
+        $ragList = stdClassObjToArray($ragList);
+        if($ragList["code"] != 0){
+            $ragList = $ragList['rags'];
         }
- 
+        $ragList = json_encode($ragList);
         $urlagent = commonOpenURLLocal()."/Apis/searchagents";
         $agentList = curlPost($urlagent,$data);
-        if($agentList != null){
         $agentList = json_decode($agentList);
-        $agentList = $agentList->agents;
         $agentList = stdClassObjToArray($agentList);
+        if($agentList ["code"] != 0){
+            $agentList = $agentList['agents'];
         }
+        $agentList = json_encode($agentList);
         // dump($ragList);
         // exit;   
         //判断用户设备是否是移动端
@@ -116,10 +118,10 @@ class Index extends \think\Controller
 	    $jsapiTicket = getOfficialJsapiTicket();
 		$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";
 	    $signature = sha1($string);
-	    
-	    
-	  
-        return view('chatBox1440', [
+        // dump($userData[0]["strate"]);
+        // exit;
+      
+        return view('chatBox', [
 			'device' => $device,
 			'mobileType' => $mobileType,
 			'commonURL' => $commonURL,
@@ -135,129 +137,8 @@ class Index extends \think\Controller
 			'timestamp' => $timestamp,
 			'nonceStr' => $nonceStr,
 			'signature' => $signature,
-		]);
-    }
-    
-        
-          //客户端
-    public function chatBox(){
-        $ragId =  request() -> param('ragId');
-        $mobileType = 'unknow';
-        $data['publicKey'] = commonPublicKey();
-        $url = commonOpenURLLocal()."/apis/searchRag";
-        $ragList = curlPost($url,$data);
- 
-        if($ragList != null){
-            $ragList = json_decode($ragList);
-            $ragList = $ragList->rags;
-            $ragList = stdClassObjToArray($ragList);
-        }
- 
-        $urlagent = commonOpenURLLocal()."/Apis/searchagents";
-        $agentList = curlPost($urlagent,$data);
-        if($agentList != null){
-        $agentList = json_decode($agentList);
-        $agentList = $agentList->agents;
-        $agentList = stdClassObjToArray($agentList);
-        }
-        
-        
-        // dump($ragList);
-        // exit;   
-        //判断用户设备是否是移动端
-        if(isMobile() == true){
-            $device = 'phone';
-            $mobileType = mobileType();
-        }
-        else{
-            $device = 'pc';
-        }
-        //获取公共路径
-        $commonURL = commonURL();
-        //获取当前时间
-        $now = date('Y-m-d H:i:s',time());
-        //获取提问示例
-        $question = db('Question') -> order('id DESC') -> select();
-        // dump($question);
-        // exit;
-        //获取一个标记当前用户的传参
-        $user =  request() -> param('user');
-        if(!$user){
-            $user = rand(10000,99999);    
-        }
-        //构建微信分享参数
-        $appId = commonAPPID();
-		$timestamp = time();
-	    $nonceStr = nonceStr(16);
-	    $url = commonURL().'/index/chatBox?user='.$user;
-	    $jsapiTicket = getOfficialJsapiTicket();
-		$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";
-	    $signature = sha1($string);
-	    $mapUser['user'] = array('eq',$user);
-        $userData = db('client') -> where($mapUser) -> select();
-        // dump($userData[0]["strate"]);
-        // exit;
-        if($userData == null){
-            return view('chatBox', [
-    			'device' => $device,
-    			'mobileType' => $mobileType,
-    			'commonURL' => $commonURL,
-    			'now' => $now,
-    			'question' => $question,
-    			'commonOpenURLSSE' => commonOpenURLSSE(),
-    			'commonOpenURLLocalSSE' => commonOpenURLLocalSSE(),
-    			'commonWebsocket' => commonWebsocket(),
-    			'user' => $user,
-    			'ragList' => $ragList,
-    			'agentList' => $agentList,
-    			'appId' => $appId,
-    			'timestamp' => $timestamp,
-    			'nonceStr' => $nonceStr,
-    			'signature' => $signature,
-    			'ragId' => $ragId,
-    		]);
-     
-        }
-        if($userData[0]["strate"] == 1){
-             return view('chatBox', [
-    			'device' => $device,
-    			'mobileType' => $mobileType,
-    			'commonURL' => $commonURL,
-    			'now' => $now,
-    			'question' => $question,
-    			'commonOpenURLSSE' => commonOpenURLSSE(),
-    			'commonOpenURLLocalSSE' => commonOpenURLLocalSSE(),
-    			'commonWebsocket' => commonWebsocket(),
-    			'user' => $user,
-    			'ragList' => $ragList,
-    			'agentList' => $agentList,
-    			'appId' => $appId,
-    			'timestamp' => $timestamp,
-    			'nonceStr' => $nonceStr,
-    			'signature' => $signature,
-    			'ragId' => $ragId,
-    		]);
-        }
-        else{
-            return view('chatBox', [
-    			'device' => $device,
-    			'mobileType' => $mobileType,
-    			'commonURL' => $commonURL,
-    			'now' => $now,
-    			'question' => $question,
-    			'commonOpenURLSSE' => commonOpenURLSSE(),
-    			'commonOpenURLLocalSSE' => commonOpenURLLocalSSE(),
-    			'commonWebsocket' => commonWebsocket(),
-    			'user' => $user,
-    			'ragList' => $ragList,
-    			'agentList' => $agentList,
-    			'appId' => $appId,
-    			'timestamp' => $timestamp,
-    			'nonceStr' => $nonceStr,
-    			'signature' => $signature,
-    			'ragId' => $ragId,
-    		]);
-        }
+			'ragId' => $ragId,
+    	]);
 	   // return $url;
    
     }
@@ -315,71 +196,25 @@ class Index extends \think\Controller
 	    $jsapiTicket = getOfficialJsapiTicket();
 		$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";
 	    $signature = sha1($string);
-	    $mapUser['user'] = array('eq',$user);
-        $userData = db('client') -> where($mapUser) -> select();
-        // dump($userData[0]["strate"]);
-        // exit;
-        if($userData == null){
-            return view('chatBox1', [
-    			'device' => $device,
-    			'mobileType' => $mobileType,
-    			'commonURL' => $commonURL,
-    			'now' => $now,
-    			'question' => $question,
-    			'commonOpenURLSSE' => commonOpenURLSSE(),
-    			'commonOpenURLLocalSSE' => commonOpenURLLocalSSE(),
-    			'commonWebsocket' => commonWebsocket(),
-    			'user' => $user,
-    			'ragList' => $ragList,
-    			'agentList' => $agentList,
-    			'appId' => $appId,
-    			'timestamp' => $timestamp,
-    			'nonceStr' => $nonceStr,
-    			'signature' => $signature,
-    			'ragId' => $ragId,
-    		]);
-     
-        }
-        if($userData[0]["strate"] == 1){
-             return view('chatBox1', [
-    			'device' => $device,
-    			'mobileType' => $mobileType,
-    			'commonURL' => $commonURL,
-    			'now' => $now,
-    			'question' => $question,
-    			'commonOpenURLSSE' => commonOpenURLSSE(),
-    			'commonOpenURLLocalSSE' => commonOpenURLLocalSSE(),
-    			'commonWebsocket' => commonWebsocket(),
-    			'user' => $user,
-    			'ragList' => $ragList,
-    			'agentList' => $agentList,
-    			'appId' => $appId,
-    			'timestamp' => $timestamp,
-    			'nonceStr' => $nonceStr,
-    			'signature' => $signature,
-    			'ragId' => $ragId,
-    		]);
-        }
-        else{
-            return view('chatBox1', [
-    			'device' => $device,
-    			'mobileType' => $mobileType,
-    			'commonURL' => $commonURL,
-    			'now' => $now,
-    			'question' => $question,
-    			'commonOpenURLSSE' => commonOpenURLSSE(),
-    			'commonOpenURLLocalSSE' => commonOpenURLLocalSSE(),
-    			'commonWebsocket' => commonWebsocket(),
-    			'user' => $user,
-    			'ragList' => $ragList,
-    			'agentList' => $agentList,
-    			'appId' => $appId,
-    			'timestamp' => $timestamp,
-    			'nonceStr' => $nonceStr,
-    			'signature' => $signature,
-    			'ragId' => $ragId,
-    		]);
-        }
+	  
+        return view('chatBox1', [
+			'device' => $device,
+			'mobileType' => $mobileType,
+			'commonURL' => $commonURL,
+			'now' => $now,
+			'question' => $question,
+			'commonOpenURLSSE' => commonOpenURLSSE(),
+			'commonOpenURLLocalSSE' => commonOpenURLLocalSSE(),
+			'commonWebsocket' => commonWebsocket(),
+			'user' => $user,
+			'ragList' => $ragList,
+			'agentList' => $agentList,
+			'appId' => $appId,
+			'timestamp' => $timestamp,
+			'nonceStr' => $nonceStr,
+			'signature' => $signature,
+			'ragId' => $ragId,
+		]);
 	   // return $url;
    
     }
@@ -1104,7 +939,7 @@ class Index extends \think\Controller
     }
     
     
-    public function roleindexold(){
+    public function roleindex(){
         $data['askInfoId'] = request() -> param('askInfoId');
      
         // $data['askInfoId'] = '53ef8235ca3e5d60708baae51be72db8';
@@ -1133,61 +968,33 @@ class Index extends \think\Controller
      
         return "ss";
     }
-    
-    //存储模型返回的数据到tokenrole
-    public function roleindex(){
-        $data['token'] = request() -> param('token');
-        $data['reply'] = request() -> param('reply');;
-        $maprulecontent['token'] = array('eq', $data['token']);
-       // 判断reply里是否存在ending,如果不存在,在字符串的最后加上ending
-        if(strpos($data['reply'], 'ending') === false){
-            $data['reply'] = $data['reply'] . 'ending';
-        }
-         // 判断reply里是否存在【规则关键字】,如果不存在,在ending前加上\n【规则关键字】:全文。
-        if(strpos($data['reply'], '【规则关键字】') === false){
-            $endingPos = strpos($data['reply'], 'ending');
-            if($endingPos !== false){
-                // 在ending前插入\n【规则关键字】:全文。
-                $data['reply'] = substr($data['reply'], 0, $endingPos) . "\n【规则关键字】:全文。" . substr($data['reply'], $endingPos);
-            }
-        }
-        if(strstr($data['reply'], '病例校验通过')){
-            $datarole['aireply'] = $data['reply'];
-            $datarole['reply'] = "【质控结果】   病例校验通过。";
-            db('tokenrole')->where($maprulecontent)->update($datarole);
-        }
-        else{
-            $datarole['aireply'] = $data['reply'];
-            $datarole['reply'] = $data['reply'];
-            db('tokenrole')->where($maprulecontent)->update($datarole);
-        }
-    }
-     //存储模型返回的数据到tokenrole
     public function roleindex1(){
-        $data['token'] = request() -> param('token');
-        $data['reply'] = request() -> param('reply');;
-        $maprulecontent['token'] = array('eq', $data['token']);
-       // 判断reply里是否存在ending,如果不存在,在字符串的最后加上ending
-        if(strpos($data['reply'], 'ending') === false){
-            $data['reply'] = $data['reply'] . 'ending';
-        }
-         // 判断reply里是否存在【规则关键字】,如果不存在,在ending前加上\n【规则关键字】:全文。
-        if(strpos($data['reply'], '【规则关键字】') === false){
-            $endingPos = strpos($data['reply'], 'ending');
-            if($endingPos !== false){
-                // 在ending前插入\n【规则关键字】:全文。
-                $data['reply'] = substr($data['reply'], 0, $endingPos) . "\n【规则关键字】:全文。" . substr($data['reply'], $endingPos);
-            }
-        }
-        if(strstr($data['reply'], '病例校验通过')){
-            $datarole['aireply'] = $data['reply'];
+        $data['askInfoId'] = request() -> param('askInfoId');
+     
+        // $data['askInfoId'] = '53ef8235ca3e5d60708baae51be72db8';
+
+        $maprulecontent['token'] = array('eq', $data['askInfoId']);
+        $tokenrole = db('tokenrole2')->where($maprulecontent)->select();
+        $urlrole = commonOpenURLLocal().'/apis/role';
+        $rulename = curlPost($urlrole,$data);
+        $rulename = json_decode($rulename);
+        $rulename = stdClassObjToArray($rulename);
+      
+      
+        if(strstr($rulename['reply'], '病例校验通过')){
+ 
+            
+            $datarole['aireply'] = $rulename['reply'];
             $datarole['reply'] = "【质控结果】   病例校验通过。";
-            db('tokenrole')->where($maprulecontent)->update($datarole);
+            db('tokenrole2')->where($maprulecontent)->update($datarole);
         }
         else{
-            $datarole['aireply'] = $data['reply'];
-            $datarole['reply'] = $data['reply'];
-            db('tokenrole')->where($maprulecontent)->update($datarole);
+            
+            $datarole['aireply'] = $rulename['reply'];
+            $datarole['reply'] = $rulename['reply'];
+            db('tokenrole2')->where($maprulecontent)->update($datarole);
         }
+     
+        return "ss";
     }
 }