chw 4 일 전
부모
커밋
e3a1c7863f

+ 1 - 1
server/application/api/controller/link/LinkController.php

@@ -75,7 +75,7 @@ class LinkController extends ZskkDefaultController
     public function getPatientList(LinkService $linkService)
     {
         $param = Request::param();
-        $list = $linkService->getPatientList($param);
+        $list = $linkService->getNewPatientList($param);
         return $this->success($list);
     }
 

+ 131 - 0
server/application/api/controller/login/LoginController.php

@@ -26,6 +26,137 @@ class LoginController extends ZskkDefaultController
 
     }
 
+    public function loginNoPass(LoginService $service)
+    {
+        $params = $this->getParams();
+
+        if (isset($params['appId']) && !empty($params['appId']) && empty($params['username'])){
+            $params['username'] = \think\Db::table('PLATFROM_ACCOUNT')->where('APPID',$params['appId'])->value('RIS_USERNAME');
+        }
+        //获取账号
+        if (isset($params['username']) && !empty($params['username']) ){
+            $data['username']    = $params['username'];
+        }
+        //todo 默认值
+        if (empty($data['username'])){
+            $data['username']    = 'www';
+        }
+
+
+        //测试环境不验证token
+        if (isset($params['appId']) && isset($params['certificate']) && isset($params['token'])){
+
+            $data['appId']       = $params['appId'];
+            $data['tripartiteVoucher']  = $params['certificate'];
+            $data['token']       = $params['token'];
+
+            if (!$data['appId'] || !$data['tripartiteVoucher'] || !$data['token'] || !$data['username']){
+                $this->error(__('参数错误'), '/admin/index/login');
+            }
+
+            //todo: 这里的url需要改成配置项
+            $url = 'http://10.25.14.7:30082/system/sys-sub/token/checkToken';
+            $response = $this->httpGet(
+                $url,
+                $data
+            );
+            if ($response === false) {
+                $this->error(__('验证token失败'), '/admin/index/login');
+            }
+
+        }
+        $user     = $service->loginNoPass($data['username']);
+        return $this->success($user);
+    }
+
+    /**
+     * 发送POST JSON请求
+     *
+     * @param string $url 请求URL
+     * @param array $data 请求数据
+     * @return string|false 返回响应内容,失败返回false
+     */
+    private function httpPostJson($url, $data)
+    {
+        $jsonData = json_encode($data);
+
+        $ch = curl_init();
+
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_POST, true);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
+
+        // 设置请求头
+        curl_setopt($ch, CURLOPT_HTTPHEADER, [
+            'Content-Type: application/json',
+            'Content-Length: ' . strlen($jsonData)
+        ]);
+
+        $response = curl_exec($ch);
+        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        $error = curl_error($ch);
+        curl_close($ch);
+
+        if ($error) {
+            error_log("CURL错误: " . $error);
+            return false;
+        }
+
+        if ($httpCode != 0) {
+            error_log("HTTP错误: " . $httpCode);
+            return false;
+        }
+        return $response;
+    }
+
+    /**
+     * HTTP GET 请求
+     * @param string $url 请求 URL
+     * @param array $params 查询参数
+     * @return mixed 响应结果,失败返回 false
+     */
+    private function httpGet($url, $params = [])
+    {
+        // 如果有参数,拼接到 URL 后面
+        if (!empty($params)) {
+            $queryString = http_build_query($params);
+            $url .= (strpos($url, '?') !== false ? '&' : '?') . $queryString;
+        }
+
+        $ch = curl_init();
+
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
+
+        // 设置请求头
+        curl_setopt($ch, CURLOPT_HTTPHEADER, [
+            'Content-Type: application/json'
+        ]);
+
+        $response = curl_exec($ch);
+        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        $error = curl_error($ch);
+        curl_close($ch);
+
+        if ($error) {
+            error_log("CURL 错误:" . $error);
+            return false;
+        }
+
+        if ($httpCode != 200 && $httpCode != 201) {
+            error_log("HTTP 错误:" . $httpCode);
+            return false;
+        }
+        return $response;
+    }
+
     public function send_message_again(LoginService $service)
     {
         $params = $this->getParams();

+ 19 - 0
server/application/api/dao/login/LoginDao.php

@@ -63,6 +63,25 @@ class LoginDao extends ZskkDefaultDao {
         return $doctor;
     }
 
+
+    public function getUserByUserName($username)
+    {
+        $where = [];
+        $where['username'] = $username;
+        $doctor = $this->doctor->getUser($where);
+        if(empty($doctor)){
+            $this->throwError('账号或密码错误',1);
+        }
+        $institution = $this->doctor->getInstitutionData($doctor['institution_id']);
+        $department = $this->doctor->getDepartment($doctor['department_id']);
+        $doctor['institution'] = $institution['name'];
+        $doctor['is_new_browser'] = $institution['is_new_browser'];
+        $doctor['department'] = $department;
+        if(!empty($doctor['doctor_role'])){
+            $doctor['doctor_role'] = explode(',',$doctor['doctor_role']);
+        }
+        return $doctor;
+    }
     public function getDoctorByPhone($phone)
     {
         $doctor = $this->doctor->getDoctorByPhone($phone);

+ 13 - 13
server/application/api/servies/butt/ButtService.php

@@ -21,6 +21,7 @@ use think\Exception;
 use think\facade\Config;
 use think\facade\Log;
 use think\exception\DbException;
+use think\validate\ValidateRule;
 
 
 /**
@@ -2376,11 +2377,10 @@ class ButtService extends ZskkDefaultService {
      */
     public function getStudyUrl($param)
     {
-        $acc = $param['code'];
-        $acc = $this->aesDecrypt($acc);
+        $acc = openssl_decrypt(base64_decode($param['code']), 'AES-128-ECB', 'ghbfdmlyhxdxlyjl', OPENSSL_RAW_DATA);
         if(empty($acc))
         {
-            return ['code'=>1,'msg'=>$param['acc'].'密文无法解密,请联系管理员'];
+            return ['code'=>1,'msg'=>$param['code'].'密文无法解密,请联系管理员'];
         }
         if (empty($param['institution_id'])){
             return ['code'=>1,'msg'=>'请选择机构'];
@@ -2392,39 +2392,39 @@ class ButtService extends ZskkDefaultService {
         switch ($param['type']){
             case '1':
                 //病历号
-                $where['patient_num'] = $acc;
+                $where['PATIENT_NUM'] = $acc;
                 break;
             case '2':
                 //检查号
-                $where['accession_num'] = $acc;
+                $where['ACCESSION_NUM'] = $acc;
                 break;
             case '3':
-                //住院号
-                $where['hopitalized_no'] = $acc;
+                //住院号hopitalized_no
+                $where['HOPITALIZED_NO'] = $acc;
                 break;
             case '4':
                 //身份证
-                $where['card_num'] = $acc;
+                $where['CARD_NUM'] = $acc;
                 break;
             case '5':
                 //手机号
-                $where['phone'] = $acc;
+                $where['PHONE'] = $acc;
                 break;
         }
-        $where['institution_id'] = $param['institution_id'];
-        $study = $this->butt->getExam($where,['study_id']);
+        $where['INSTITUTION_ID'] = $param['institution_id'];
+        $study = $this->butt->getExam($where,['STUDY_ID']);
         if(empty($study))
         {
             return ['code'=>1,'msg'=>$acc.'的检查未找到'];
         }
         if(empty($param['url']))
         {
-            $domain = 'http://114.118.9.145:9603';
+            $domain = 'http://10.25.14.2:9603';
         }else{
             $domain = $param['url'];
         }
         $study_id = $study['study_id'];
-        $url = "$domain/#/mobile?studyurl=$domain/query/?address=$domain/dcmdown&study_id=$study_id&type=1&node_type=1&version=V1.2.0.0";
+        $url = "http://10.25.14.2:9603/#/pc?studyurl=http://10.25.14.2:9603/query/?study_id=".$study_id;
 
         return ['code'=>0,'url'=>$url];
     }

+ 1 - 1
server/application/api/servies/link/LinkService.php

@@ -487,7 +487,7 @@ class LinkService extends ZskkDefaultService {
      */
     public function getNewPatientList($param)
     {
-        $param['code'] = openssl_decrypt(base64_decode($param['code']), 'AES-128-ECB', 'ghbfdmlyhxdxlyjl');
+        $param['code'] = openssl_decrypt(base64_decode($param['code']), 'AES-128-ECB', 'ghbfdmlyhxdxlyjl', OPENSSL_RAW_DATA);
 
         if(empty($param['code']))
         {

+ 55 - 0
server/application/api/servies/login/LoginService.php

@@ -93,6 +93,61 @@ class LoginService extends ZskkDefaultService {
         return $data;
     }
 
+    //免登录接口
+    public function loginNoPass($username)
+    {
+
+        $user = $this->loginDao->getUserByUserName($username);
+
+        if($user['is_send_message'] == "1") {
+            $check = $this->check_phone($user['phone']);
+            if(!$check){
+                $this->throwError('手机号为空或手机号格式错误','0912');
+            }
+            $phone = $user['phone'];
+            $code = rand('1000','9999');
+            $handle_id = $phone.rand('10000000','99999999');
+            $this->loginDao->setCache('sendcode_'.$phone,$code,600);
+            $this->loginDao->setCache('sendcode_handle_id'.$handle_id,$phone,600);
+            $info = send_message::sendSms2UpDate($phone,$code);
+            log::record("loginNoPass() set code => {handle_id: $handle_id \t code: $code \t phone: $phone \t}");
+            $data = ['need_code'=> true, 'phone' => $check, 'handle_id' => $handle_id];
+            return $data;
+        }
+        $token = $this->loginDao->saveCache($user);
+        // 存储登录信息
+        $this->loginDao->saveLoginInfo($user['id']);
+        $institution = $this->loginDao->getInsInfo($user['institution_id']);
+        $otherIns = $this->loginDao->getOtherRules($user['id']);
+        $insList = [];
+        if(!empty($otherIns)) {
+            $insList = $otherIns;
+        }
+        $insList[] = ['id'=>$user['institution_id'],'name'=>$user['institution']];
+        $data = [
+            'token'         =>  $token,
+            'realname'      =>  $user['realname'],
+            'is_admin'      =>  $user['is_admin'],
+            'username'      =>  $user['username'],
+            'institution'   =>  $user['institution'],
+            'institution_id'=>  $user['institution_id'],
+            'report_full'=>  $user['report_full'],
+            'is_new_browser'=>  $institution['is_new_browser'],
+            'department_name'   =>  $user['department'],
+            'role'=> $user['doctor_role'],
+            'message_push'  =>  $user['message_push'],
+            'need_code'=> false,
+            'user_id'       =>$user['id'],
+            'is_auto_mode'  =>$institution['is_auto_mode'],
+            'remote'        =>empty($institution['parent_institution']) ? '0' : '1',
+            'institution_list'=>$insList,
+            'message_voice'=>$user['message_voice'] ?? 0
+        ];
+        log::record('loginNoPass()当前登陆的医生id为:'.$user['id'].',登陆token为:'.$token);
+        $arr = ['type'=>2,'doctor_id'=>$user['id'],'doctor_name'=>$user['realname'],'institution_id'=>$user['institution_id']];
+        $this->loginDao->saveDoctorVisit($arr);
+        return $data;
+    }
 
     public function send_message_again($param)
     {

+ 2 - 1
server/route/route.php

@@ -47,6 +47,7 @@ Route::get('getStudyUrl', 'app\api\controller\butt\ButtController/getStudyUrl');
 Route::group('', function () {
     Route::get('getInsNum', 'app\api\controller\butt\ButtController/ins_num');;
     Route::post('getAiNode', 'app\api\controller\butt\ButtController/getAiNode');;
+    Route::post('loginNoPass', 'app\api\controller\login\LoginController/loginNoPass');
     Route::post('login', 'app\api\controller\login\LoginController/login');
     Route::post('logout', 'app\api\controller\login\LoginController/loginOut');
     Route::post('sendMessage', 'app\api\controller\login\LoginController/send_message_again');
@@ -252,7 +253,7 @@ Route::group('', function () {
     Route::post('getPatientList', 'app\api\controller\link\LinkController/getPatientList');
     Route::post('getAnotherPatientList', 'app\api\controller\link\LinkController/getAnotherPatientList');
     Route::post('getPatientInfo', 'app\api\controller\link\LinkController/getPatientInfo');
-    Route::get('reportListOuter', 'app\api\controller\link\LinkController/reportListOuter');
+    Route::get('getNewPatientList', 'app\api\controller\link\LinkController/reportListOuter');
     Route::get('getJm', 'app\api\controller\link\LinkController/getJm');
 })->header('Access-Control-Allow-Headers','X-Requested-With,Content-Type,zskk-random,zskk_institution,zskk-signature,zskk-timestamp,zskk-token,zskk-version')
     ->allowCrossDomain();