123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- <?php
- namespace app\api\controller\screen;
- use app\api\controller\screen\Index;
- use app\hander\HelpHander;
- use think\Db;
- class Daily extends Index
- {
- public function taskCount(){
- $count = Db::name('daily_task')
- ->where('org_id',$this->orgId)
- ->where('del',0)
- ->count();
- $task = Db::name('daily_task')
- ->where('org_id',$this->orgId)
- ->where('status',2)
- ->where('del',0)
- ->count();
- $recordIds = Db::name('comment')
- ->where('org_id',$this->orgId)
- ->where('type',0)
- ->where('score','<',3)
- ->column('from_id');
- $taskIds = Db::name('daily_record')
- ->where('org_id',$this->orgId)
- ->whereIn('id',$recordIds)
- ->group('task_id')
- ->column('task_id');
- $taskCount = Db::name('daily_task')
- ->where('org_id',$this->orgId)
- ->whereIn('id',$taskIds)
- ->where('del',0)
- ->where('status',2)
- ->count();
- //合格数
- $nums2 = $count - $taskCount;
- $total = $total2 = 0;
- if($count > 0){
- $total = round($task/$count*100,0);
- $total2 = round($nums2/$count*100,0);
- }
- $data = [
- 'list'=>['count'=>$total,'nums'=>$task],
- 'list2'=>['count'=>$total2,'nums'=>$nums2],
- ];
- HelpHander::success($data);
- }
- //近7日检查情况概览
- public function checkNums(){
- $dlist = [
- date('Ymd',strtotime('-6 days')),
- date('Ymd',strtotime('-5 days')),
- date('Ymd',strtotime('-4 days')),
- date('Ymd',strtotime('-3 days')),
- date('Ymd',strtotime('-2 days')),
- date('Ymd',strtotime('-1 days')),
- date('Ymd'),
- ];
- $date = $list =$list2 = [];
- foreach ($dlist as $k=>$v){
- $date[] = date('m-d',strtotime($v));
- $tt = date('Ymd',strtotime($v));
- $count = Db::name('comment')
- ->where('org_id',$this->orgId)
- ->where('create_yyyymmdd',$tt)
- ->where('type',0)
- ->count();
- $count2 = Db::name('comment')
- ->where('org_id',$this->orgId)
- ->where('create_yyyymmdd',$tt)
- ->where('type',0)
- ->avg('score');
- $list[$k]= $count;
- $list2[$k] = $count2;
- }
- $data = [
- 'title'=>$date,
- 'list'=>[
- 'list1'=>$list,
- 'list2'=>$list2,
- ]
- ];
- HelpHander::success($data);
- }
- //员工排行榜
- public function userRanking(){
- $user = Db::name('daily_record')
- ->alias('dr')
- ->field('u.real_name,dr.user_id')
- ->join('user u','u.id=dr.user_id')
- ->where('dr.org_id',$this->orgId)
- ->group('dr.user_id')
- ->select();
- $list = [];
- foreach ($user as $k=>$v){
- $list[$k]['count'] = Db::name('daily_record')
- ->where('user_id',$v['user_id'])
- ->where('org_id',$this->orgId)
- ->count();
- $list[$k]['user_name'] = $v['real_name'];
- }
- $newList =array_slice(list_sort_by($list,'count','desc'),0,7) ;
- $data = [];
- foreach ($newList as $k=>$v){
- if($k == 0){
- $data[$k][] = '<img src="'.config("app.app_host").'/img/top1.png" style="width: 100%;height: 100%" />';
- }
- if($k == 1){
- $data[$k][] = '<img src="'.config("app.app_host").'/img/top2.png" style="width: 100%;height: 100%" />';
- }
- if($k == 2){
- $data[$k][] = '<img src="'.config("app.app_host").'/img/top3.png" style="width: 100%;height: 100%" />';
- }
- if($k == 3){
- $data[$k][] = '<img src="'.config("app.app_host").'/img/top4.png" style="width: 100%;height: 100%" />';
- }
- if($k == 4){
- $data[$k][] = '<img src="'.config("app.app_host").'/img/top5.png" style="width: 100%;height: 100%" />';
- }
- if($k == 5){
- $data[$k][] = '<img src="'.config("app.app_host").'/img/top6.png" style="width: 100%;height: 100%" />';
- }
- if($k == 6){
- $data[$k][] = '<img src="'.config("app.app_host").'/img/top7.png" style="width: 100%;height: 100%" />';
- }
- $data[$k][] = $v['user_name'];
- $data[$k][] = $v['count'];
- }
- HelpHander::success($data);
- }
- public function dailyStatus(){
- $lists = model('WorkTypeMode')->getRolesUserApp(9,$this->orgId);
- $curday = date('Ymd');
- $users = Db::name('daily_record')
- ->alias('dr')
- ->field('dr.user_id')
- ->join('daily_task dt','dt.id=dr.task_id')
- ->where('dt.del',0)
- ->where('dr.create_yyyymmdd',$curday)
- ->where('dt.status',1)
- ->where('dr.org_id',$this->orgId)
- ->group('dr.user_id')
- ->select();
- $users = $users?$users:[];
- $userIds = [];
- foreach ($users as $k=>$v){
- $userIds[] = $v['user_id'];
- }
- $nlists = $nlists2 = [];
- foreach ($lists as $k=>$v){
- if(!in_array($v['id'],$userIds)){
- $nlists[] = $v;
- }
- }
- //待命中的
- $slist = $slist2 = [];
- foreach ($nlists as $k=>$v){
- $count = Db::name('daily_record')
- ->where('org_id',$this->orgId)
- ->where('user_id',$v['id'])
- ->where('create_yyyymmdd',$curday)
- ->count();
- $addr = Db::name('daily_record')
- ->alias('dr')
- ->join('daily d','d.id=dr.daily_id')
- ->where('dr.org_id',$this->orgId)
- ->where('dr.user_id',$v['id'])
- ->where('dr.create_yyyymmdd',$curday)
- ->value('d.title');
- $slist[$k][] = '<span style="color: #2A88F7">'.$v['real_name'].'</span>';
- $slist[$k][] = '<span style="color: #2A88F7">'.$count.'</span>';
- $slist[$k][] = '<span style="color: #2A88F7">'.$addr.'</span>';
- }
- //任务中的
- foreach ($lists as $k=>$v){
- if(in_array($v['id'],$userIds)){
- $nlists2[] = $v;
- }
- }
- foreach ($nlists2 as $k=>$v){
- $count = Db::name('daily_record')
- ->where('org_id',$this->orgId)
- ->where('user_id',$v['id'])
- ->where('create_yyyymmdd',$curday)
- ->count();
- $addr = Db::name('daily_record')
- ->alias('dr')
- ->join('daily d','d.id=dr.daily_id')
- ->where('dr.org_id',$this->orgId)
- ->where('dr.user_id',$v['id'])
- ->where('dr.create_yyyymmdd',$curday)
- ->value('d.title');
- $slist2[$k][] = '<span style="color: #2DF8F5">'.$v['real_name'].'</span>';
- $slist2[$k][] = '<span style="color: #2DF8F5">'.$count.'</span>';
- $slist2[$k][] = '<span style="color: #2DF8F5">'.$addr.'</span>';
- }
- $data = [
- 'list1'=>[
- 'list'=>$slist2,
- 'count'=>count($slist2),
- ],// 任务中
- 'list2'=>[
- 'list'=>$slist,
- 'count'=>count($slist),
- ],// 待命中
- ];
- HelpHander::success($data);
- }
- public function taskRecordOne(){
- $map[] = ['enable', '=', 1];
- $map[] = ['org_id', '=', $this->orgId];
- $map[] = ['del', '=', 0];
- $lists = Db::name('daily')->where($map)->field('id,title')->order('id desc')->select();
- $hours = model('Daily')->getTimeDaily($this->orgId);
- foreach ($lists as $k=>$v){
- $m = [];
- $m[] = ['org_id','=',$this->orgId];
- $m[] = ['daily_id','=',$v['id']];
- $m[] = ['create_time','>=',$hours['start']];
- $m[] = ['create_time','<',$hours['end']];
- $count = Db::name('daily_record')->where($m)->count();
- $lists[$k]['count'] = $count;
- }
- HelpHander::success($lists);
- }
- public function recordList(){
- $list = Db::name('daily_record')
- ->field('task_id,user_id,create_time,daily_id')
- ->where('create_yyyymmdd',date('Ymd'))
- ->where('org_id',$this->orgId)
- ->order('id desc')
- ->select();
- $data = [];
- foreach ($list as $k=>$v){
- $data[$k][] = Db::name('daily')->where('id',$v['daily_id'])->value('title');
- $data[$k][] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
- $data[$k][] = date('m-d H:i:s',strtotime($v['create_time']));
- }
- HelpHander::success($data);
- }
- }
|