Studiesnums.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\manage\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use think\Session;
  6. use think\Config;
  7. use think\Cookie;
  8. use think\Request;
  9. use app\common\library\SysLogs;
  10. use app\common\library\UUIDs;
  11. /**
  12. *
  13. */
  14. class Studiesnums extends Base {
  15. public function index(){
  16. return $this->fetch();
  17. }
  18. public function datas(){
  19. $request = Request::instance();
  20. $params = $request->param();
  21. if(isset($params['search']) && !empty($params['search'])){
  22. $search = str_replace('-', '', $params['search']);
  23. $where = $search;
  24. }else{
  25. $where = date('Ymd',strtotime('-1 day'));
  26. }
  27. $date = array();
  28. $date['studydate'] = $where;
  29. $time['date'] = $where;
  30. $info = DB::table('every_studies')->where($time)->select();
  31. if($info){
  32. $count = DB::table('every_studies')->where($time)->count();
  33. $data["total"] = $count;
  34. $data["rows"] = $info;
  35. echo json_encode($data);
  36. }else{
  37. $institution = DB::table('institution')->where('is_test',0)->field('id,name as institution_name')->select();
  38. $count = DB::table('institution')->count();
  39. $every = array();
  40. foreach ($institution as $k => $v) {
  41. $institution[$k]['count'] = DB::table('studies')->where($date)->where('institution_id',$v['id'])->group('institution_id')->count();
  42. $every[$k]['id'] = UUIDs::uuid16();
  43. $every[$k]['date'] = $where;
  44. $every[$k]['institution_id'] = $v['id'];
  45. $every[$k]['institution_name'] = $v['institution_name'];
  46. $every[$k]['count'] = $institution[$k]['count'];
  47. }
  48. DB::table('every_studies')->insertAll($every);
  49. $data["total"] = $count;
  50. $data["rows"] = $institution;
  51. echo json_encode($data);
  52. }
  53. }
  54. }