123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- namespace app\admin\controller\statistics;
- use app\admin\model\remote\Order;
- use app\common\controller\Backend;
- use think\Db;
- use think\Env;
- /**
- *
- *
- * @icon fa fa-circle-o
- */
- class Remote extends Backend
- {
- protected $noNeedRight = ['getPositive'];
- /**
- * Remote模型对象
- * @var \app\admin\model\remote\Remote
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new Order();
- }
- 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($this->searchFields,false);
- $join = [
- ['remote_order o', 'a.id = o.application_id', 'LEFT'],
- ['report r', 'a.id = r.remote_application_id','LEFT'],
- ];
- $field = [
- 'a.name','local_institution_id','local_institution_id','local_institution_name','remote_institution_id',
- 'remote_institution_name','a.exam_class','a.exam_id','req_doctor_name','req_date_time','report_status',
- 'a.is_urgent','o.status as order_status','a.exam_project',
- 'r.report_doctor_name', 'r.review_doctor_name', 'r.review_datetime', 'o.order_money', 'o.pay_way'
- ];
- $more = [
- 'r.type' => '2',
- 'a.status' => '0',
- ];
- // 过滤机构
- $my_ins_id = $this->auth->getMyInsId();
- if($my_ins_id === false){
- $total = model('Remote','model\remote')
- ->alias('a')
- ->join($join)
- ->where($where)
- ->where('report_status>3')
- ->where($more)
- ->order($sort, $order)
- ->count();
- $list = model('Remote','model\remote')
- ->alias('a')
- ->join($join)
- ->where($where)
- ->where('report_status>3')
- ->where($more)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->field($field)
- ->select();
- } else {
- $total = model('Remote','model\remote')
- ->alias('a')
- ->join($join)
- ->where($where)
- ->where('report_status>3')
- ->where($more)
- ->where(function ($query) use ($my_ins_id){
- $query->whereIn('local_institution_id', $my_ins_id);
- $query->whereIn('remote_institution_id', $my_ins_id,'or');
- })
- ->order($sort, $order)
- ->count();
- $list = model('Remote','model\remote')
- ->alias('a')
- ->join($join)
- ->where($where)
- ->where('report_status>3')
- ->where($more)
- ->where(function ($query) use ($my_ins_id){
- $query->whereIn('local_institution_id', $my_ins_id);
- $query->whereIn('remote_institution_id', $my_ins_id,'or');
- })
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->field($field)
- ->select();
- }
- $list = collection($list)->toArray();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- public function getPositive()
- {
- list($where) = $this->buildparams($this->searchFields, true);
- $record = model('Remote','model\remote')::alias('a')
- ->join([
- ['report r', 'a.id = r.remote_application_id','LEFT'],
- ])
- ->where($where)
- ->where(function ($query){
- $query->where('r.report_result',"1")
- ->whereOr('r.report_result',"2");
- })
- ->column('r.report_result');
- $num = 0;
- $positive = 0;
- foreach ($record as $val){
- $positive += $val === '2' ? 1 : 0;
- }
- if($positive != 0){
- $num = round(($positive / count($record)) * 100, 2);
- }
- $this->success('','',[
- 'centage' => $num,
- 'positive' => $positive
- ]);
- }
- }
|