DeviceInformationController1.class.php 4.0 KB

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