Index.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 = '1|3';
  19. $data = $str?explode('|',$str):[];
  20. if(count($data) != 2){
  21. HelpHander::error('参数错误');
  22. }
  23. $this->sid = $data[0];
  24. $this->orgId = $data[1];
  25. }
  26. // 大屏详情
  27. public function info(){
  28. $ret = model('Screen')->getInfo($this->sid,$this->orgId);
  29. if(!$ret){
  30. HelpHander::error('大屏不存在');
  31. }
  32. HelpHander::success($ret);
  33. }
  34. // 获取大屏紧急联系人或图片
  35. public function getOrgInfo(){
  36. $data = [
  37. 'name' => model('Config')->getConfig('org_emergency_name',$this->orgId),
  38. 'phone' => model('Config')->getConfig('org_emergency_phone',$this->orgId),
  39. 'img' => model('Config')->getConfig('org_screen_img',$this->orgId)
  40. ];
  41. HelpHander::success($data);
  42. }
  43. // 日常工作任务记录
  44. public function dailyTaskRecord(){
  45. $map[] = ['org_id','=',$this->orgId];
  46. $map[] = ['task_id','>',0];
  47. $lists = Db::name('daily_record')
  48. ->where($map)
  49. ->field('user_id,task_id,daily_id')
  50. ->limit(20)
  51. ->order('id desc')
  52. ->select();
  53. $data = [];
  54. foreach ($lists as $k=>$v){
  55. $uname = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  56. $task = Db::name('daily_task')->where('id',$v['task_id'])->value('title');
  57. $daily = Db::name('daily')->where('id',$v['daily_id'])->value('title');
  58. $data[] = [$daily,$task,$uname];
  59. }
  60. HelpHander::success($data);
  61. }
  62. public function getMonitor(){
  63. $list = model('Monitor')->getMonitors($this->orgId,10);
  64. $data = [
  65. 'info'=>isset($list[0])?$list[0]:null,
  66. 'info1'=>isset($list[1])?$list[1]:null,
  67. 'info2'=>isset($list[2])?$list[2]:null,
  68. 'info3'=>isset($list[3])?$list[3]:null,
  69. 'info4'=>isset($list[4])?$list[4]:null,
  70. 'info5'=>isset($list[5])?$list[5]:null,
  71. 'info6'=>isset($list[6])?$list[6]:null,
  72. 'info7'=>isset($list[7])?$list[7]:null,
  73. 'info8'=>isset($list[8])?$list[8]:null,
  74. 'info9'=>isset($list[9])?$list[9]:null,
  75. ];
  76. HelpHander::success($data);
  77. }
  78. }