123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- namespace app\admin\controller\exams;
- use app\common\controller\Backend;
- use think\Config;
- use think\Db;
- /**
- *
- *
- * @icon fa fa-circle-o
- */
- class Studies extends Backend
- {
- protected $noNeedLogin = ['reSync','serieslist'];
- protected $noNeedRight = ['serieslist','series'];
- /**
- * Studies模型对象
- * @var \app\admin\model\exams\Studies
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\exams\Studies;
- }
-
- /**
- * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
- * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
- * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
- */
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- // 过滤机构
- $childInsIds = $this->auth->getMyInsId();
- if($childInsIds == false){
- $more = false;
- } else {
- $more = ['s.institution_id' => ['in', $childInsIds]];
- }
- $ins = $this->request->get('institution_id','');
- if(empty($ins))
- {
- $ins_where = false;
- }else{
- $ins_where = 's.institution_id = '.$ins;
- }
- $sort == 'id' ? $sort = 's.id' : false ;
- $total = $this->model
- ->alias('s')
- ->join(['patient_infos'=>'p'],'p.id=s.patient_id','left')
- ->where($where)
- ->where($more)
- ->where($ins_where)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->alias('s')
- ->join(['patient_infos'=>'p'],'p.id=s.patient_id','left')
- ->where($where)
- ->where($more)
- ->where($ins_where)
- ->field('s.*,p.temp_patient_id,p.name')
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $list = collection($list)->toArray();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- public function reSync($ids)
- {
- $parse = Config::get('parse_url');
- $url = $parse."/fix/study";
- $data = ['id'=>$ids];
- $info = $this->curl_post($url,$data);
- $return = json_decode($info,true);
- if($return['msg'] == 'Success')
- {
- $this->success('请求成功');
- // return json(['code'=>1,'msg'=>'请求成功']);
- // }else{
- // return json(['code'=>200,'msg'=>$return['Msg']]);
- }else{
- $this->error($return['Msg'] ?? '请求失败');
- }
- }
- public function curl_post($url, $data)
- {
- $ch = curl_init ();
- curl_setopt ( $ch, CURLOPT_URL, $url );
- curl_setopt ( $ch, CURLOPT_POST, 1 );
- curl_setopt ( $ch, CURLOPT_HEADER, 0 );
- curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
- curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
- $return = curl_exec ( $ch );
- curl_close ( $ch );
- return $return;
- }
- public function curl_get($url)
- {
- // 初始化cURL会话
- $ch = curl_init();
- // 设置cURL选项
- curl_setopt($ch, CURLOPT_URL, $url); // 你要访问的URL
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 将curl_exec()获取的信息以字符串返回,而不是直接输出
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- // 执行cURL会话
- $response = curl_exec($ch);
- // 检查是否有错误发生
- if(curl_errno($ch)){
- echo 'cURL error: ' . curl_error($ch);
- }
- // 关闭cURL会话
- curl_close($ch);
- // 打印响应内容
- return $response;
- }
- public function series($ids)
- {
- $this->view->assign("id", $ids);
- $ins = Db::table('studies')->where('id',$ids)->value('institution_id');
- $this->view->assign("ins", $ins);
- return $this->view->fetch();
- }
- public function seriesList()
- {
- set_time_limit(0);
- if ($this->request->isAjax())
- {
- $id = $this->request->param('study');
- $ins = $this->request->param('ins');
- $query = Config::get('query_url');
- $url = $query."/query/series?study_id=".$id;
- $data = $this->curl_get($url);
- $data = json_decode($data,true);
- $total = count($data);
- foreach ($data as $k=>$v)
- {
- $data[$k]['ins'] = $ins;
- }
- $result = array("total" => $total, "rows" => $data);
- return json($result);
- }
- return $this->view->fetch();
- }
- public function deleteSeries($id,$study,$ins)
- {
- $query = Config::get('query_url');
- $url = $query."/delete/serie?key=ZSKK_DELETE_SERIES&serie_id=$id&study_id=$study&institution_id=$ins";
- $data = $this->curl_get($url);
- $this->success('删除成功','','',1);
- }
- }
|