Device.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\App;
  6. use think\Db;
  7. class Device extends Base
  8. {
  9. public function __construct(App $app = null) {
  10. parent::__construct($app);
  11. $this->model = new \app\common\model\Device();
  12. }
  13. public function sweepCode(){
  14. $code = input('code','','trim');
  15. $taskId = input('taskId/d',0);
  16. $deviceId = input('deviceId/d',0);
  17. $ret = $this->model->sweepCode($code,$this->userId,$this->orgId,$taskId,$deviceId);
  18. if($ret){
  19. HelpHander::success($ret);
  20. }else{
  21. HelpHander::error($this->model->getError());
  22. }
  23. }
  24. public function deviceInfo(){
  25. $id=input('deviceId');
  26. $ret=$this->model->deviceInfo($id,$this->orgId);
  27. if($ret){
  28. HelpHander::success($ret);
  29. }else{
  30. HelpHander::error($this->model->getError());
  31. }
  32. }
  33. //任务列表下所有地点
  34. public function taskAddrAll(){
  35. $taskId = input('taskId/d',0);
  36. $ret = $this->model->taskAddrAll($taskId);
  37. HelpHander::success($ret);
  38. }
  39. //我的历史记录
  40. public function myTaskRecord(){
  41. $page = input('page/d',1);
  42. $size = input('size/d',10);
  43. $type = input('type/d');
  44. $status = input('status','');
  45. if($status == 0){
  46. $status = 2;
  47. }elseif ($status == 1){
  48. $status = 3;
  49. }
  50. $ret = $this->model->myTaskRecord($type,$page,$size,$this->userId,$this->orgId,$status);
  51. HelpHander::success($ret);
  52. }
  53. // 延期申请
  54. public function delay(){
  55. $taskId = input('taskId/d',0);
  56. $endTime = input('endTime','','trim');
  57. $reason = input('reason','','trim');
  58. model('DeviceTask')->delayTask($taskId,$endTime,$reason,$this->userId,$this->orgId);
  59. HelpHander::success([],'操作成功');
  60. }
  61. // 延期申请列表
  62. public function delayLists(){
  63. $page = input('page/d',1);
  64. $size = input('size/d',10);
  65. $res = model('DeviceTask')->delayLists($page,$size,$this->userId,$this->orgId);
  66. HelpHander::success($res,'操作成功');
  67. }
  68. // 延期申请取消
  69. public function cancelDelay(){
  70. $id = input('id/d',0);
  71. model('DeviceTask')->cancelDelay($id,$this->userId);
  72. HelpHander::success([],'操作成功');
  73. }
  74. public function taskList(){
  75. $page = input('page',1);
  76. $size = input('size',10);
  77. $date = input('date','');
  78. if($date!=''){
  79. $map[] = ['create_yyyymmdd','=',date('Ymd',strtotime($date))];
  80. }
  81. $map[] = ['a.org_id','=',$this->orgId];
  82. $map[] = ['a.del','=',0];
  83. $map[] = ['a.status','=',0];
  84. $lists = Db::name('device_task')
  85. ->alias('a')
  86. ->join('device_task_user b','a.id=b.task_id')
  87. ->field('a.id,a.start_time,a.end_time,a.title')
  88. ->where($map)
  89. ->where('b.user_id',$this->userId)
  90. ->page($page,$size)
  91. ->order('a.id desc')
  92. ->select();
  93. HelpHander::success($lists);
  94. }
  95. }