123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <?php
- namespace app\api\controller\remote;
- use app\api\controller\ZskkDefaultController;
- use app\api\validate\remote\RemoteValidate;
- use app\api\servies\remote\RemoteService;
- use app\common\library\uploadToCloud;
- use think\Exception;
- use think\facade\Config;
- class RemoteController extends ZskkDefaultController
- {
- protected $needToken = true;
- protected $logName = "RemoteController";
- /**
- * 远程申请列表中个人信息
- */
- public function info(RemoteService $service){
- try{
- $doctor = $service->getUser($this->getToken());
- // 获取今日已写报告数量
- $today_report = $service->get_today_report($doctor['id']);
- // 获取当前医生所有保存过得报告
- $all_report = $service->get_all_report($doctor['id']);
- // 获取所影响医院数量
- $institution_num = $service->get_institution_num($doctor['id']);
- // 获取患者数量
- $patient_num = $service->get_patient_num($doctor['id']);
- $info = array();
- $info['today_report'] = $today_report;
- $info['all_report'] = ($all_report == 0) ? 1 : $all_report;
- $info['institution_num'] = $institution_num;
- $info['patient_num'] = $patient_num;
- return$this->success($info);
- }catch(Exception $e){
- $this->throwError($e->getMessage(),0001);
- }
- }
- /**
- * 邀请方医院
- */
- public function local_institution(RemoteService $service)
- {
- try{
- $doctor = $service->getUser($this->getToken());
- $info = $service->get_local_ins($doctor['institution_id']);
- return$this->success($info);
- }catch(Exception $e){
- $this->throwError($e->getMessage(),0001);
- }
- }
- /**
- * 远程申请列表
- */
- /*public function applicationList(RemoteService $service)
- {
- $params = $this->getParams();
- RemoteValidate::check($params);
- $doctor = $service->getUser($this->getToken());
- // 获取搜索条件
- $where = $service->getWhere($params);
- $limit = $service->getLimit($params);
- $twhere = $service->getTimeWhere($params);
- $list = $service->fetch_sql($doctor['id'],$doctor['institution_id'],$where,$limit,$twhere);
- $count = $service->fetch_count_sql($doctor['id'],$doctor['institution_id'],$where,$twhere);
- $info = array('total'=>$count[0]['count(1)'],'list'=>$list);
- return $this->success($info);
- /*$order['FIELD(TrainClass.status ,3,1,2,4)'] = '';
- $order变量为数组,就不会走ViewModel中的checkOrder方法了*/
- /*}*/
- public function todayApplicationList(RemoteService $service)
- {
- try{
- ini_set('memory_limit','-1');
- $params = $this->getParams();
- RemoteValidate::checkToday($params);
- $doctor = $service->getUser($this->getToken());
- $where = $service->getwhere($params);
- $info = $service->getTodayInfo($doctor,$where,$params);
- return$this->success($info);
- }catch(Exception $e){
- $this->throwError($e->getMessage(),0001);
- }
- }
- public function all(RemoteService $service)
- {
- try{
- $params = $this->getParams();
- RemoteValidate::checkAll($params);
- $doctor = $service->getUser($this->getToken());
- $where = $service->getwhere($params);
- $info = $service->getAllInfo($params,$doctor,$where);
- return$this->success($info);
- }catch(Exception $e){
- $this->throwError($e->getMessage(),0001);
- }
- }
- public function getApplicationInfo(RemoteService $service)
- {
- try{
- $params = $this->getParams();
- RemoteValidate::checkId($params);
- $doctor = $service->getUser($this->getToken());
- $info = $service->getOne($params,$doctor);
- return$this->success($info);
- }catch(Exception $e){
- $this->throwError($e->getMessage(),0001);
- }
- }
- public function detail(RemoteService $service)
- {
- $params = $this->getParams();
- RemoteValidate::checkId($params);
- $doctor = $service->getUser($this->getToken());
- $info = $service->getRemote($params['id'],$doctor['id']);
- return $this->success($info);
- }
- //分配医生操作
- public function distribute(RemoteService $service)
- {
- $params = $this->getParams();
- RemoteValidate::checkDistribute($params);
- $doctor = $service->getUser($this->getToken());
- $info = $service->distribute($doctor,$params);
- return $this->success($info);
- }
- //分配医生列表
- public function doctorList(RemoteService $service)
- {
- $doctor = $service->getUser($this->getToken());
- $info = $service->getDoctorList($doctor['institution_id']);
- return $this->success($info);
- }
- //获取当前医生下所有未删除的视频
- public function getVideoList(RemoteService $service)
- {
- $doctor = $service->getUser($this->getToken());
- $list = $service->getVideoList($doctor);
- return $this->success($list);
- }
- //获取当前医生所有的检查类的远程诊断
- public function getExamList(RemoteService $service)
- {
- $params = $this->getParams();
- $doctor = $service->getUser($this->getToken());
- $list = $service->getExamList($doctor,$params);
- return $this->success($list);
- }
- public function videoUpload()
- {
- // try{
- // 获取表单上传文件 例如上传了001.jpg
- $file = request()->file('video');
- // 移动到框架应用根目录/public/uploads/ 目录下
- if($file) {
- $fildInfo = $file->getInfo();
- $name = $fildInfo['name'];
- $search = '/.php$/';
- if(preg_match($search,$name)) {
- // php文件批量不允许通过
- return '';
- }
- $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
- if ($info) {
- $type = Config::get('upload');
- if($type == 1)
- {
- $url = '/' . 'uploads' . '/' . $info->getSaveName();
- $success = ['url'=>$url,'type'=>$type,'tokenUrl'=>$url];
- return $this->success($success);
- }
- $key = 'video' . '/' . $info->getFilename();
- $source_file = './' . 'uploads' . '/' . $info->getSaveName();
- $upload = new uploadToCloud();
- $s = $upload->upload($key,$source_file,'2','2','2','2');
- if(($s['@metadata']['statusCode'] ?? '') == '200')
- {
- gc_collect_cycles();
- unset($info);
- unlink($source_file);
- $success = ['url'=>$key,'type'=>'3','tokenUrl'=>$upload->makeCloudUrl($key,'inline')];
- return $this->success($success);
- }else{
- return '上传云失败';
- }
- } else {
- // 上传失败获取错误信息
- echo $file->getError();
- }
- }else{
- $this->throwError('没有找到上传的文件','3010');
- }
- // }catch(Exception $e){
- // $this->throwError($e->getMessage(),0001);
- // }
- }
- public function rejectStatus(RemoteService $service)
- {
- $params = $this->getParams();
- $list = $service->rejectStatus($params['id']);
- return $this->success($list);
- }
- }
|