0
0

Index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace app\api\controller\screen;
  3. use app\hander\HelpHander;
  4. use think\Controller;
  5. use think\Db;
  6. /**
  7. * 大屏接口
  8. */
  9. class Index extends Controller
  10. {
  11. protected $sid = 0;
  12. protected $orgId = 0;
  13. protected function initialize()
  14. {
  15. parent::initialize();
  16. $token = input('token','','trim');
  17. $str = think_decrypt($token);
  18. // $str = '23|3';
  19. // $str = '26|3';
  20. $data = $str?explode('|',$str):[];
  21. if(count($data) != 2){
  22. HelpHander::error('参数错误');
  23. }
  24. $this->sid = $data[0];
  25. $this->orgId = $data[1];
  26. }
  27. // 大屏详情
  28. public function info(){
  29. $ret = model('Screen')->getInfo($this->sid,$this->orgId);
  30. if(!$ret){
  31. HelpHander::error('大屏不存在');
  32. }
  33. HelpHander::success($ret);
  34. }
  35. // 获取大屏紧急联系人或图片
  36. public function getOrgInfo(){
  37. $data = [
  38. 'name' => model('Config')->getConfig('org_emergency_name',$this->orgId),
  39. 'phone' => model('Config')->getConfig('org_emergency_phone',$this->orgId),
  40. 'img' => model('Config')->getConfig('org_screen_img',$this->orgId)
  41. ];
  42. HelpHander::success($data);
  43. }
  44. // 日常工作任务记录
  45. public function dailyTaskRecord(){
  46. $map[] = ['org_id','=',$this->orgId];
  47. $map[] = ['task_id','>',0];
  48. $lists = Db::name('daily_record')
  49. ->where($map)
  50. ->field('user_id,task_id,daily_id')
  51. ->limit(20)
  52. ->order('id desc')
  53. ->select();
  54. $data = [];
  55. foreach ($lists as $k=>$v){
  56. $uname = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  57. $task = Db::name('daily_task')->where('id',$v['task_id'])->value('title');
  58. $daily = Db::name('daily')->where('id',$v['daily_id'])->value('title');
  59. $data[] = [$daily,$task,$uname];
  60. }
  61. HelpHander::success($data);
  62. }
  63. public function questionnaireInfoList(){
  64. $map[] = ['del','=',0];
  65. $map[] = ['org_id','=',$this->orgId];
  66. $map= empty($map) ? true: $map;
  67. $lists1 = db('questionnaire')
  68. ->where($map)
  69. ->select();
  70. $total1 = $total2 = 0;
  71. foreach($lists1 as $k=>$v){
  72. $records = Db::name('questionnaire_record')
  73. ->where('questionnaire_id',$v['id'])
  74. ->count();
  75. $total1 +=$v['view'];
  76. $total2 +=$records;
  77. }
  78. //数据查询
  79. $lists = db('questionnaire')
  80. ->where($map)
  81. ->limit(20)
  82. ->order('id desc')
  83. ->select();
  84. $dd = [];
  85. foreach ($lists as $k=>$v){
  86. $records = Db::name('questionnaire_record')
  87. ->where('questionnaire_id',$v['id'])
  88. ->count();
  89. $dd[] = [$v['title'],$v['view'],$records,date('Y-m-d H:i',strtotime($v['create_time']))];
  90. }
  91. $data = [
  92. 'info'=>[
  93. 'total'=>count($lists1),
  94. 'total1'=>$total1,
  95. 'total2'=>$total2,
  96. ],
  97. 'list'=>$dd
  98. ];
  99. HelpHander::success($data);
  100. }
  101. }