123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\api\controller\screen;
- use app\hander\HelpHander;
- use think\Controller;
- use think\Db;
- /**
- * 大屏接口
- */
- class Index extends Controller
- {
- protected $sid = 0;
- protected $orgId = 0;
- protected function initialize()
- {
- parent::initialize();
- $token = input('token','','trim');
- $str = think_decrypt($token);
- // $str = '23|3';
- // $str = '26|3';
- $data = $str?explode('|',$str):[];
- if(count($data) != 2){
- HelpHander::error('参数错误');
- }
- $this->sid = $data[0];
- $this->orgId = $data[1];
- }
- // 大屏详情
- public function info(){
- $ret = model('Screen')->getInfo($this->sid,$this->orgId);
- if(!$ret){
- HelpHander::error('大屏不存在');
- }
- HelpHander::success($ret);
- }
- // 获取大屏紧急联系人或图片
- public function getOrgInfo(){
- $data = [
- 'name' => model('Config')->getConfig('org_emergency_name',$this->orgId),
- 'phone' => model('Config')->getConfig('org_emergency_phone',$this->orgId),
- 'img' => model('Config')->getConfig('org_screen_img',$this->orgId)
- ];
- HelpHander::success($data);
- }
- // 日常工作任务记录
- public function dailyTaskRecord(){
- $map[] = ['org_id','=',$this->orgId];
- $map[] = ['task_id','>',0];
- $lists = Db::name('daily_record')
- ->where($map)
- ->field('user_id,task_id,daily_id')
- ->limit(20)
- ->order('id desc')
- ->select();
- $data = [];
- foreach ($lists as $k=>$v){
- $uname = Db::name('user')->where('id',$v['user_id'])->value('real_name');
- $task = Db::name('daily_task')->where('id',$v['task_id'])->value('title');
- $daily = Db::name('daily')->where('id',$v['daily_id'])->value('title');
- $data[] = [$daily,$task,$uname];
- }
- HelpHander::success($data);
- }
- public function questionnaireInfoList(){
- $map[] = ['del','=',0];
- $map[] = ['org_id','=',$this->orgId];
- $map= empty($map) ? true: $map;
- $lists1 = db('questionnaire')
- ->where($map)
- ->select();
- $total1 = $total2 = 0;
- foreach($lists1 as $k=>$v){
- $records = Db::name('questionnaire_record')
- ->where('questionnaire_id',$v['id'])
- ->count();
- $total1 +=$v['view'];
- $total2 +=$records;
- }
- //数据查询
- $lists = db('questionnaire')
- ->where($map)
- ->limit(20)
- ->order('id desc')
- ->select();
- $dd = [];
- foreach ($lists as $k=>$v){
- $records = Db::name('questionnaire_record')
- ->where('questionnaire_id',$v['id'])
- ->count();
- $dd[] = [$v['title'],$v['view'],$records,date('Y-m-d H:i',strtotime($v['create_time']))];
- }
- $data = [
- 'info'=>[
- 'total'=>count($lists1),
- 'total1'=>$total1,
- 'total2'=>$total2,
- ],
- 'list'=>$dd
- ];
- HelpHander::success($data);
- }
- }
|