Complete.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 Complete extends Backend
  11. {
  12. /**
  13. * Complete模型对象
  14. * @var \app\admin\model\manage\statics\Complete
  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\Complete;
  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("card_num is null
  51. or phone is null
  52. or studydate is null
  53. or reportdate is null
  54. or reviewdate is null")
  55. ->where($more)
  56. ->order($sort, $order)
  57. ->count();
  58. $list = $this->model
  59. ->where($where)
  60. ->where("card_num is null
  61. or phone is null
  62. or studydate is null
  63. or reportdate is null
  64. or reviewdate is null")
  65. ->where($more)
  66. ->order($sort, $order)
  67. ->limit($offset, $limit)
  68. ->select();
  69. $list = collection($list)->toArray();
  70. $result = array("total" => $total, "rows" => $list);
  71. return json($result);
  72. }
  73. return $this->view->fetch();
  74. }
  75. public function picture()
  76. {
  77. $type = $_GET['type'];
  78. $childInsIds = $this->auth->getMyInsId();
  79. if($childInsIds == false){
  80. $more = false;
  81. } else {
  82. $more = ['institution_id' => ['in', $childInsIds]];
  83. }
  84. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  85. $list = $this->model
  86. ->where($more)
  87. ->where($where)
  88. ->where("card_num is null
  89. or phone is null
  90. or studydate is null
  91. or reportdate is null
  92. or reviewdate is null")
  93. ->field('count(*) c,institution_id')
  94. ->group('institution_id')
  95. ->select();
  96. $ins = Db::table('institution')->column('id,name');
  97. $insCount = [];
  98. $insName = [];
  99. foreach ($list as $k=>$v)
  100. {
  101. $insName[] = $ins[$v['institution_id']];
  102. $insCount[] = $v['c'];
  103. }
  104. $departList = $this->model
  105. ->where($more)
  106. ->where($where)
  107. ->where("card_num is null
  108. or phone is null
  109. or studydate is null
  110. or reportdate is null
  111. or reviewdate is null")
  112. ->field('count(*) c,department_name')
  113. ->group('department_name')
  114. ->select();
  115. $departName = [];
  116. $departCount = [];
  117. foreach ($departList as $k=>$v)
  118. {
  119. $departCount[] = $v['c'];
  120. $departName[] = empty($v['department_name']) ? '其他' : $v['department_name'];
  121. }
  122. $dateList = $this->model
  123. ->where($more)
  124. ->where($where)
  125. ->where("card_num is null
  126. or phone is null
  127. or studydate is null
  128. or reportdate is null
  129. or reviewdate is null")
  130. ->field('count(*) c,reviewday')
  131. ->group('reviewday')
  132. ->select();
  133. $dateName = [];
  134. $dateCount = [];
  135. foreach ($dateList as $k=>$v)
  136. {
  137. $dateCount[] = $v['c'];
  138. $dateName[] = $v['reviewday'];
  139. }
  140. $this->view->assign('type',$type);
  141. $this->view->assign('insCount',json_encode($insCount));
  142. $this->view->assign('insName',json_encode($insName,JSON_UNESCAPED_UNICODE ));
  143. $this->view->assign('departCount',json_encode($departCount));
  144. $this->view->assign('departName',json_encode($departName,JSON_UNESCAPED_UNICODE ));
  145. $this->view->assign('dateCount',json_encode($dateCount));
  146. $this->view->assign('dateName',json_encode($dateName));
  147. return $this->view->fetch();
  148. }
  149. }