12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\manage\controller;
- use think\Controller;
- use think\Db;
- use think\Session;
- use think\Config;
- use think\Cookie;
- use think\Request;
- use app\common\library\SysLogs;
- use app\common\library\UUIDs;
- /**
- *
- */
- class Studiesnums extends Base {
- public function index(){
- return $this->fetch();
- }
- public function datas(){
- $request = Request::instance();
- $params = $request->param();
- if(isset($params['search']) && !empty($params['search'])){
- $search = str_replace('-', '', $params['search']);
- $where = $search;
- }else{
- $where = date('Ymd',strtotime('-1 day'));
- }
- $date = array();
- $date['studydate'] = $where;
- $time['date'] = $where;
- $info = DB::table('every_studies')->where($time)->select();
- if($info){
- $count = DB::table('every_studies')->where($time)->count();
- $data["total"] = $count;
- $data["rows"] = $info;
- echo json_encode($data);
- }else{
- $institution = DB::table('institution')->where('is_test',0)->field('id,name as institution_name')->select();
- $count = DB::table('institution')->count();
- $every = array();
- foreach ($institution as $k => $v) {
- $institution[$k]['count'] = DB::table('studies')->where($date)->where('institution_id',$v['id'])->group('institution_id')->count();
- $every[$k]['id'] = UUIDs::uuid16();
- $every[$k]['date'] = $where;
- $every[$k]['institution_id'] = $v['id'];
- $every[$k]['institution_name'] = $v['institution_name'];
- $every[$k]['count'] = $institution[$k]['count'];
- }
- DB::table('every_studies')->insertAll($every);
- $data["total"] = $count;
- $data["rows"] = $institution;
- echo json_encode($data);
- }
- }
- }
|