DeviceInformationController.class.php.bak.20200601 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/5/20 0020
  6. * Time: 下午 15:11
  7. */
  8. namespace Home\Controller;
  9. use Think\Controller;
  10. class DeviceInformationController extends ComController
  11. {
  12. public function index(){
  13. $Data=I();
  14. // print_r($Data);
  15. if(isset($Data['list'])){
  16. $GetPage=$Data['pageCurrent'];//第几页
  17. $GetSize=$Data['pageSize'];//每页条数
  18. $Page=($GetPage-1)*$GetSize;
  19. if(!empty($Data['object_name'])){
  20. $Map['object_name']=array('like','%'.$Data['object_name'].'%');
  21. }
  22. if(!empty($Data['owner_code'])){
  23. $Map['owner_code']=array('like','%'.$Data['owner_code'].'%');
  24. }
  25. if(!empty($Data['device_name'])){
  26. $Map['device_name']=array('like','%'.$Data['device_name'].'%');
  27. }
  28. if(!empty($Data['dwtype'])){
  29. $Map['dwtype']=array('like','%'.$Data['dwtype'].'%');
  30. }
  31. $Count= M("object_share")->where($Map)->count();// 查询满足要求的总记录数
  32. $List = M("object_share")->where($Map)->limit($Page,$GetSize)->order('id desc')->select();
  33. $Info = array(
  34. 'totalRow' => $Count,
  35. 'list' => $List,
  36. );
  37. echo json_encode($Info);
  38. }else{
  39. $this->display();
  40. }
  41. }
  42. public function add(){
  43. if (IS_POST) {
  44. $Data=I();
  45. if(strlen($Data['owner_code']) < 1){
  46. $this->mtReturn(300,'请填写完整的设备编号');
  47. }
  48. if(strlen($Data['device_name']) < 1){
  49. $this->mtReturn(300,'请填写完整的设备名称');
  50. }
  51. if(strlen($Data['object_name']) < 1){
  52. $this->mtReturn(300,'请填写完整的安装位置');
  53. }
  54. if(strlen($Data['dwtype']) < 1){
  55. $this->mtReturn(300,'请填写完整的监控数据类型');
  56. }
  57. if(strlen($Data['object_code']) < 1){
  58. $this->mtReturn(300,'请填写完整的监控对象编号');
  59. }
  60. if(strlen($Data['start_port']) < 1){
  61. $this->mtReturn(300,'请填写完整的数据起始端口号');
  62. }
  63. if(strlen($Data['rec_cur']) < 1){
  64. $this->mtReturn(300,'请填写完整的同步记录号');
  65. }
  66. if(strlen($Data['min_level']) < 1){
  67. $this->mtReturn(300,'请填写完整的所在楼层(最低)');
  68. }
  69. if(strlen($Data['max_level']) < 1){
  70. $this->mtReturn(300,'请填写完整的所在楼层(最高)');
  71. }
  72. $res =M('object_share')->add($Data);
  73. if($res)
  74. $this->mtReturn(200,'新增成功');
  75. else
  76. $this->mtReturn(300,'新增失败');
  77. }else{
  78. $this->assign('action','/home/DeviceInformation/add');
  79. $this->display();
  80. }
  81. }
  82. public function object_modify(){
  83. $Data=I();
  84. if(IS_POST) {
  85. if (!empty($Data['owner_code'])){
  86. $Data1['owner_code']=$Data['owner_code'];
  87. $res=M('object_share')->where('owner_code='.$Data1['owner_code'])->save($Data);
  88. }
  89. if($res)
  90. $this->mtReturn(200,'修改成功');
  91. else
  92. $this->mtReturn(300,'修改失败');
  93. }else{
  94. $bao=M('object_share')
  95. ->where('owner_code='.$Data['code'])
  96. ->select();
  97. // print_r($bao);
  98. $this->assign('list2',$bao);
  99. $this->assign('code',$Data['code']);
  100. $this->assign('action','/home/DeviceInformation/object_modify');
  101. }
  102. $this->display();
  103. }
  104. public function deldata(){
  105. $Model=M('object_share');
  106. $Data=I();
  107. $res=$Model->where('id='.$Data['id'])->delete();
  108. if($res)
  109. $this->mtReturn(200,'删除成功');
  110. else
  111. $this->mtReturn(300,'删除失败');
  112. }
  113. }