123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/5/20 0020
- * Time: 下午 15:11
- */
- namespace Home\Controller;
- use Think\Controller;
- class DeviceInformationController extends ComController
- {
- public function index(){
- $Data=I();
- // print_r($Data);
- if(isset($Data['list'])){
- $GetPage=$Data['pageCurrent'];//第几页
- $GetSize=$Data['pageSize'];//每页条数
- $Page=($GetPage-1)*$GetSize;
- if(!empty($Data['object_name'])){
- $Map['object_name']=array('like','%'.$Data['object_name'].'%');
- }
- if(!empty($Data['owner_code'])){
- $Map['owner_code']=array('like','%'.$Data['owner_code'].'%');
- }
- if(!empty($Data['device_name'])){
- $Map['device_name']=array('like','%'.$Data['device_name'].'%');
- }
- if(!empty($Data['dwtype'])){
- $Map['dwtype']=array('like','%'.$Data['dwtype'].'%');
- }
- $Count= M("object_share")->where($Map)->count();// 查询满足要求的总记录数
- $List = M("object_share")->where($Map)->limit($Page,$GetSize)->order('id desc')->select();
- $Info = array(
- 'totalRow' => $Count,
- 'list' => $List,
- );
- echo json_encode($Info);
- }else{
- $this->display();
- }
- }
- public function add(){
- if (IS_POST) {
- $Data=I();
- if(strlen($Data['owner_code']) < 1){
- $this->mtReturn(300,'请填写完整的设备编号');
- }
- if(strlen($Data['device_name']) < 1){
- $this->mtReturn(300,'请填写完整的设备名称');
- }
- if(strlen($Data['object_name']) < 1){
- $this->mtReturn(300,'请填写完整的安装位置');
- }
- if(strlen($Data['dwtype']) < 1){
- $this->mtReturn(300,'请填写完整的监控数据类型');
- }
- if(strlen($Data['object_code']) < 1){
- $this->mtReturn(300,'请填写完整的监控对象编号');
- }
- if(strlen($Data['start_port']) < 1){
- $this->mtReturn(300,'请填写完整的数据起始端口号');
- }
- if(strlen($Data['rec_cur']) < 1){
- $this->mtReturn(300,'请填写完整的同步记录号');
- }
- if(strlen($Data['min_level']) < 1){
- $this->mtReturn(300,'请填写完整的所在楼层(最低)');
- }
- if(strlen($Data['max_level']) < 1){
- $this->mtReturn(300,'请填写完整的所在楼层(最高)');
- }
- $res =M('object_share')->add($Data);
- if($res)
- $this->mtReturn(200,'新增成功');
- else
- $this->mtReturn(300,'新增失败');
- }else{
- $this->assign('action','/home/DeviceInformation/add');
- $this->display();
- }
- }
- public function object_modify(){
- $Data=I();
- if(IS_POST) {
- if (!empty($Data['owner_code'])){
- $Data1['owner_code']=$Data['owner_code'];
- $res=M('object_share')->where('owner_code='.$Data1['owner_code'])->save($Data);
- }
- if($res)
- $this->mtReturn(200,'修改成功');
- else
- $this->mtReturn(300,'修改失败');
- }else{
- $bao=M('object_share')
- ->where('owner_code='.$Data['code'])
- ->select();
- // print_r($bao);
- $this->assign('list2',$bao);
- $this->assign('code',$Data['code']);
- $this->assign('action','/home/DeviceInformation/object_modify');
- }
- $this->display();
- }
- public function deldata(){
- $Model=M('object_share');
- $Data=I();
- $res=$Model->where('id='.$Data['id'])->delete();
- if($res)
- $this->mtReturn(200,'删除成功');
- else
- $this->mtReturn(300,'删除失败');
- }
- }
|