Standard.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace app\admin\controller\manage\statics;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. *
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Standard extends Backend
  11. {
  12. /**
  13. * Standard模型对象
  14. * @var \app\admin\model\manage\statics\Standard
  15. */
  16. protected $model = null;
  17. protected $noNeedRight=['picture'];
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = new \app\admin\model\manage\statics\Standard;
  22. }
  23. /**
  24. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  25. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  26. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  27. */
  28. /**
  29. * 查看
  30. */
  31. public function index()
  32. {
  33. //设置过滤方法
  34. $this->request->filter(['strip_tags']);
  35. if ($this->request->isAjax()) {
  36. //如果发送的来源是Selectpage,则转发到Selectpage
  37. if ($this->request->request('keyField')) {
  38. return $this->selectpage();
  39. }
  40. // 过滤机构
  41. $childInsIds = $this->auth->getMyInsId();
  42. if($childInsIds == false){
  43. $more = false;
  44. } else {
  45. $more = ['institution_id' => ['in', $childInsIds]];
  46. }
  47. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  48. $total = $this->model
  49. ->where($where)
  50. ->where("report_doctor_id = review_doctor_id")
  51. ->where($more)
  52. ->order($sort, $order)
  53. ->count();
  54. $list = $this->model
  55. ->where($where)
  56. ->where("report_doctor_id = review_doctor_id")
  57. ->where($more)
  58. ->order($sort, $order)
  59. ->limit($offset, $limit)
  60. ->select();
  61. $list = collection($list)->toArray();
  62. $result = array("total" => $total, "rows" => $list);
  63. return json($result);
  64. }
  65. return $this->view->fetch();
  66. }
  67. public function picture()
  68. {
  69. $type = $_GET['type'];
  70. $childInsIds = $this->auth->getMyInsId();
  71. if($childInsIds == false){
  72. $more = false;
  73. } else {
  74. $more = ['institution_id' => ['in', $childInsIds]];
  75. }
  76. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  77. $list = $this->model
  78. ->where($more)
  79. ->where($where)
  80. ->where("report_doctor_id = review_doctor_id")
  81. ->field('count(*) c,institution_id')
  82. ->group('institution_id')
  83. ->select();
  84. $ins = Db::table('institution')->column('id,name');
  85. $insCount = [];
  86. $insName = [];
  87. foreach ($list as $k=>$v)
  88. {
  89. $insName[] = $ins[$v['institution_id']];
  90. $insCount[] = $v['c'];
  91. }
  92. $departList = $this->model
  93. ->where($more)
  94. ->where($where)
  95. ->where("report_doctor_id = review_doctor_id")
  96. ->field('count(*) c,department_name')
  97. ->group('department_name')
  98. ->select();
  99. $departName = [];
  100. $departCount = [];
  101. foreach ($departList as $k=>$v)
  102. {
  103. $departCount[] = $v['c'];
  104. $departName[] = empty($v['department_name']) ? '其他' : $v['department_name'];
  105. }
  106. $dateList = $this->model
  107. ->where($more)
  108. ->where($where)
  109. ->where("report_doctor_id = review_doctor_id")
  110. ->field('count(*) c,reviewday')
  111. ->group('reviewday')
  112. ->select();
  113. $dateName = [];
  114. $dateCount = [];
  115. foreach ($dateList as $k=>$v)
  116. {
  117. $dateCount[] = $v['c'];
  118. $dateName[] = $v['reviewday'];
  119. }
  120. $this->view->assign('type',$type);
  121. $this->view->assign('insCount',json_encode($insCount));
  122. $this->view->assign('insName',json_encode($insName,JSON_UNESCAPED_UNICODE ));
  123. $this->view->assign('departCount',json_encode($departCount));
  124. $this->view->assign('departName',json_encode($departName,JSON_UNESCAPED_UNICODE ));
  125. $this->view->assign('dateCount',json_encode($dateCount));
  126. $this->view->assign('dateName',json_encode($dateName));
  127. return $this->view->fetch();
  128. }
  129. }