RemoteController.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?php
  2. namespace app\api\controller\remote;
  3. use app\api\controller\ZskkDefaultController;
  4. use app\api\validate\remote\RemoteValidate;
  5. use app\api\servies\remote\RemoteService;
  6. use app\common\library\uploadToCloud;
  7. use think\Exception;
  8. use think\facade\Config;
  9. class RemoteController extends ZskkDefaultController
  10. {
  11. protected $needToken = true;
  12. protected $logName = "RemoteController";
  13. /**
  14. * 远程申请列表中个人信息
  15. */
  16. public function info(RemoteService $service){
  17. try{
  18. $doctor = $service->getUser($this->getToken());
  19. // 获取今日已写报告数量
  20. $today_report = $service->get_today_report($doctor['id']);
  21. // 获取当前医生所有保存过得报告
  22. $all_report = $service->get_all_report($doctor['id']);
  23. // 获取所影响医院数量
  24. $institution_num = $service->get_institution_num($doctor['id']);
  25. // 获取患者数量
  26. $patient_num = $service->get_patient_num($doctor['id']);
  27. $info = array();
  28. $info['today_report'] = $today_report;
  29. $info['all_report'] = ($all_report == 0) ? 1 : $all_report;
  30. $info['institution_num'] = $institution_num;
  31. $info['patient_num'] = $patient_num;
  32. return$this->success($info);
  33. }catch(Exception $e){
  34. $this->throwError($e->getMessage(),0001);
  35. }
  36. }
  37. /**
  38. * 邀请方医院
  39. */
  40. public function local_institution(RemoteService $service)
  41. {
  42. try{
  43. $doctor = $service->getUser($this->getToken());
  44. $info = $service->get_local_ins($doctor['institution_id']);
  45. return$this->success($info);
  46. }catch(Exception $e){
  47. $this->throwError($e->getMessage(),0001);
  48. }
  49. }
  50. /**
  51. * 远程申请列表
  52. */
  53. /*public function applicationList(RemoteService $service)
  54. {
  55. $params = $this->getParams();
  56. RemoteValidate::check($params);
  57. $doctor = $service->getUser($this->getToken());
  58. // 获取搜索条件
  59. $where = $service->getWhere($params);
  60. $limit = $service->getLimit($params);
  61. $twhere = $service->getTimeWhere($params);
  62. $list = $service->fetch_sql($doctor['id'],$doctor['institution_id'],$where,$limit,$twhere);
  63. $count = $service->fetch_count_sql($doctor['id'],$doctor['institution_id'],$where,$twhere);
  64. $info = array('total'=>$count[0]['count(1)'],'list'=>$list);
  65. return $this->success($info);
  66. /*$order['FIELD(TrainClass.status ,3,1,2,4)'] = '';
  67. $order变量为数组,就不会走ViewModel中的checkOrder方法了*/
  68. /*}*/
  69. public function todayApplicationList(RemoteService $service)
  70. {
  71. try{
  72. ini_set('memory_limit','-1');
  73. $params = $this->getParams();
  74. RemoteValidate::checkToday($params);
  75. $doctor = $service->getUser($this->getToken());
  76. $where = $service->getwhere($params);
  77. $info = $service->getTodayInfo($doctor,$where,$params);
  78. return$this->success($info);
  79. }catch(Exception $e){
  80. $this->throwError($e->getMessage(),0001);
  81. }
  82. }
  83. public function all(RemoteService $service)
  84. {
  85. try{
  86. $params = $this->getParams();
  87. RemoteValidate::checkAll($params);
  88. $doctor = $service->getUser($this->getToken());
  89. $where = $service->getwhere($params);
  90. $info = $service->getAllInfo($params,$doctor,$where);
  91. return$this->success($info);
  92. }catch(Exception $e){
  93. $this->throwError($e->getMessage(),0001);
  94. }
  95. }
  96. public function getApplicationInfo(RemoteService $service)
  97. {
  98. try{
  99. $params = $this->getParams();
  100. RemoteValidate::checkId($params);
  101. $doctor = $service->getUser($this->getToken());
  102. $info = $service->getOne($params,$doctor);
  103. return$this->success($info);
  104. }catch(Exception $e){
  105. $this->throwError($e->getMessage(),0001);
  106. }
  107. }
  108. public function detail(RemoteService $service)
  109. {
  110. $params = $this->getParams();
  111. RemoteValidate::checkId($params);
  112. $doctor = $service->getUser($this->getToken());
  113. $info = $service->getRemote($params['id'],$doctor['id']);
  114. return $this->success($info);
  115. }
  116. //分配医生操作
  117. public function distribute(RemoteService $service)
  118. {
  119. $params = $this->getParams();
  120. RemoteValidate::checkDistribute($params);
  121. $doctor = $service->getUser($this->getToken());
  122. $info = $service->distribute($doctor,$params);
  123. return $this->success($info);
  124. }
  125. //分配医生列表
  126. public function doctorList(RemoteService $service)
  127. {
  128. $doctor = $service->getUser($this->getToken());
  129. $info = $service->getDoctorList($doctor['institution_id']);
  130. return $this->success($info);
  131. }
  132. //获取当前医生下所有未删除的视频
  133. public function getVideoList(RemoteService $service)
  134. {
  135. $doctor = $service->getUser($this->getToken());
  136. $list = $service->getVideoList($doctor);
  137. return $this->success($list);
  138. }
  139. //获取当前医生所有的检查类的远程诊断
  140. public function getExamList(RemoteService $service)
  141. {
  142. $params = $this->getParams();
  143. $doctor = $service->getUser($this->getToken());
  144. $list = $service->getExamList($doctor,$params);
  145. return $this->success($list);
  146. }
  147. public function videoUpload()
  148. {
  149. // try{
  150. // 获取表单上传文件 例如上传了001.jpg
  151. $file = request()->file('video');
  152. // 移动到框架应用根目录/public/uploads/ 目录下
  153. if($file) {
  154. $fildInfo = $file->getInfo();
  155. $name = $fildInfo['name'];
  156. $search = '/.php$/';
  157. if(preg_match($search,$name)) {
  158. // php文件批量不允许通过
  159. return '';
  160. }
  161. $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
  162. if ($info) {
  163. $type = Config::get('upload');
  164. if($type == 1)
  165. {
  166. $url = '/' . 'uploads' . '/' . $info->getSaveName();
  167. $success = ['url'=>$url,'type'=>$type,'tokenUrl'=>$url];
  168. return $this->success($success);
  169. }
  170. $key = 'video' . '/' . $info->getFilename();
  171. $source_file = './' . 'uploads' . '/' . $info->getSaveName();
  172. $upload = new uploadToCloud();
  173. $s = $upload->upload($key,$source_file,'2','2','2','2');
  174. if(($s['@metadata']['statusCode'] ?? '') == '200')
  175. {
  176. gc_collect_cycles();
  177. unset($info);
  178. unlink($source_file);
  179. $success = ['url'=>$key,'type'=>'3','tokenUrl'=>$upload->makeCloudUrl($key,'inline')];
  180. return $this->success($success);
  181. }else{
  182. return '上传云失败';
  183. }
  184. } else {
  185. // 上传失败获取错误信息
  186. echo $file->getError();
  187. }
  188. }else{
  189. $this->throwError('没有找到上传的文件','3010');
  190. }
  191. // }catch(Exception $e){
  192. // $this->throwError($e->getMessage(),0001);
  193. // }
  194. }
  195. public function rejectStatus(RemoteService $service)
  196. {
  197. $params = $this->getParams();
  198. $list = $service->rejectStatus($params['id']);
  199. return $this->success($list);
  200. }
  201. }