123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\admin\controller\statistics;
- use app\common\controller\Backend;
- use think\Db;
- /**
- *
- *
- * @icon fa fa-circle-o
- */
- class Finance extends Backend
- {
-
- /**
- * Finance模型对象
- * @var \app\admin\model\statistics\Finance
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\statistics\Finance;
- }
-
- /**
- * 默认生成的控制器所继承的父类中有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();
- $filter = $this->request->get("filter", '');
- $op = $this->request->get("op", '', 'trim');
- $filter = (array)json_decode($filter, true);
- if(empty($filter))
- {
- $result = array("total" => [], "rows" => 0);
- return json($result);
- }
- $time = [];
- if($filter['time'] ?? null)
- {
- $time = explode(' - ',$filter['time']);
- }else{
- $this->error('请选择要查询的时间段');
- }
- $institution = ['25000004','11000006','04500002','04500003','13400003','03300001','06300006','06300010'];
- if($filter['institution_id'] ?? null)
- {
- if(in_array($filter['institution_id'],$institution))
- {
- $institution = [$filter['institution_id']];
- }else{
- $this->error('无效的医院');
- }
- }
- $pay = [];
- if($filter['pay_status'] ?? null)
- {
- $pay = ['pay_status'=>$filter['pay_status']];
- }
- $name = Db::table('institution')->where('id','in',$institution)->column('id,name');
- // 25000004 济南复大肿瘤医院 CT+MR拍片量
- $data = [];
- foreach ($institution as $v)
- {
- $ins = $name[$v] ?? '';
- $info = Db::table('exams')
- ->whereTime('createdAt',[$time[0],$time[1]])
- ->where($pay)
- ->where('institution_id',$v)
- ->where('exam_class','in',['CT','MR','DX','DR'])
- ->group("exam_class,pay_status")
- ->field("count(id) as count,exam_class,pay_status,'".$ins."' as name,$v as institution_id,'' as time")
- ->select();
- foreach ($info as $k=>$value)
- {
- // $remote as remote
- $remote = '';
- $remote = Db::table('remote_application')
- ->whereTime('createdAt',[$time[0],$time[1]])
- ->where('local_institution_id',$v)
- ->where('exam_class',$value['exam_class'])
- ->where('report_status','in',['7','8','9','10'])
- ->count();
- $value['remote'] = $remote;
- $data[] = $value;
- }
- }
- $count = count($data);
- $result = array("rows" => $data, "total" => $count);
- return $result;
- // 11000006 沈阳市浑南区高坎社区卫生服务中心 拍片量
- // 04500002 阳泉煤业集团总医院 拍片量已收费
- // 04500003 阳泉煤业集团第三医院 CT+DR(DX)+MR+已收费拍片量
- // 13400003 通化市人民医院 CT+MR拍片量
- // 03300001 柳林县人民医院 CT+DR(DX)+MR拍片量
- }
- return $this->view->fetch();
- }
- }
|