Parcourir la source

最新版本首版

hanzhengyi il y a 2 ans
Parent
commit
2422bcce5d
100 fichiers modifiés avec 4978 ajouts et 2769 suppressions
  1. 4 0
      .gitignore
  2. 8 1
      .htaccess
  3. 42 0
      .travis.yml
  4. 32 0
      LICENSE.txt
  5. 129 1
      README.md
  6. 0 155
      admin/controller/Manage.php.bak.20201202
  7. 0 164
      admin/controller/Manage.php.bak.20201202fasongjiange
  8. 0 315
      admin/controller/Manage.php.bak.20201204shangxiaxianweiruku
  9. 0 332
      admin/controller/Manage.php.bak.20201223
  10. 0 552
      admin/controller/Manage.php.bak.2021-03-17
  11. 0 491
      admin/controller/Manage.php.bak.20210317
  12. 0 757
      admin/controller/Manage.php.bak.20210325
  13. 1 0
      application/.htaccess
  14. 0 0
      application/admin/common.php
  15. 0 0
      application/admin/common.php.bak
  16. 0 0
      application/admin/common.php.bak.2020-12-11
  17. 0 0
      application/admin/common.php.bak.20201202
  18. 0 0
      application/admin/common.php.bak.20201204
  19. 0 0
      application/admin/common.php.bak.2021-04-29
  20. 0 0
      application/admin/common.php.bak.2021-12-29
  21. 0 0
      application/admin/common.php.bak.20210316
  22. 0 0
      application/admin/common4.php.bak
  23. 0 0
      application/admin/common5.php.bak
  24. 0 0
      application/admin/common6.php.bak
  25. 0 0
      application/admin/common7.php.bak
  26. 0 0
      application/admin/controller/Batchhandle.php
  27. 0 0
      application/admin/controller/Batchhandle.php.bak.2021-08-31
  28. 504 0
      application/admin/controller/Dataacceptance.php
  29. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-04-29
  30. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-06-02
  31. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-11-04
  32. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-11-05
  33. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-11-05-1
  34. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-11-11
  35. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-11-30
  36. 0 0
      application/admin/controller/Dataacceptance.php.bak.2021-12-01
  37. 0 0
      application/admin/controller/Dataacceptance.php.bak.2022-07-07
  38. 0 0
      application/admin/controller/Device.php
  39. 0 0
      application/admin/controller/Device.php.bak
  40. 0 0
      application/admin/controller/Device.php.bak.2020-12-14
  41. 0 0
      application/admin/controller/Device.php.bak.2021-12-29
  42. 0 0
      application/admin/controller/Device5.php.bak
  43. 0 0
      application/admin/controller/Device6.php.bak
  44. 0 0
      application/admin/controller/Device7.php.bak
  45. 0 0
      application/admin/controller/Index.php
  46. 0 0
      application/admin/controller/Log.php
  47. 0 0
      application/admin/controller/Login.php
  48. 2200 0
      application/admin/controller/Manage.php
  49. 0 0
      application/admin/controller/Manage.php.bak.20210419
  50. 0 0
      application/admin/controller/Manage.php.bak.20210625
  51. 0 0
      application/admin/controller/Manage.php.bak.20210720
  52. 0 0
      application/admin/controller/Manage.php.bak.20210808
  53. 0 0
      application/admin/controller/Manage.php.bak.20210824
  54. 0 0
      application/admin/controller/Manage.php.bak.20211028
  55. 0 0
      application/admin/controller/Manage.php.bak.20220106
  56. 0 0
      application/admin/controller/Manage.php.bak.20220111
  57. 0 0
      application/admin/controller/Manage.php.bak.20220227
  58. 1898 0
      application/admin/controller/Manage.php.bak.20221229
  59. 0 0
      application/admin/controller/Messagepush.php
  60. 148 0
      application/admin/controller/Onenet.php
  61. 0 0
      application/admin/controller/Onenet.php.bak.20220301
  62. 12 1
      application/admin/controller/Order.php
  63. 0 0
      application/admin/controller/Order.php.bak
  64. 0 0
      application/admin/controller/Order.php.bak.20201209
  65. 0 0
      application/admin/controller/Order.php.bak.20201215
  66. 0 0
      application/admin/controller/Order.php.bak.20201216
  67. 0 0
      application/admin/controller/Order.php.bak.20210122
  68. 0 0
      application/admin/controller/Order.php.bak.20210127
  69. 0 0
      application/admin/controller/Order.php.bak.20210316
  70. 0 0
      application/admin/controller/Order.php.bak.20210414
  71. 0 0
      application/admin/controller/Order.php.bak.20210608
  72. 0 0
      application/admin/controller/Order.php.bak.20211028
  73. 0 0
      application/admin/controller/Order.php.bak.20211029
  74. 0 0
      application/admin/controller/Order.php.bak.20211104
  75. 0 0
      application/admin/controller/Order.php.bak.20211202
  76. 0 0
      application/admin/controller/Order.php.bak1
  77. 0 0
      application/admin/controller/Order.php.bak2
  78. 0 0
      application/admin/controller/Order.php.bak3
  79. 0 0
      application/admin/controller/Order.php.bak4
  80. 0 0
      application/admin/controller/Order.php.yuanshi
  81. 0 0
      application/admin/controller/Owner.php
  82. 0 0
      application/admin/controller/Send.php
  83. 0 0
      application/admin/controller/common.php
  84. 0 0
      application/admin/phpMQTT/phpMQTT.php
  85. 0 0
      application/admin/phpMQTT/publish.php
  86. 0 0
      application/admin/phpMQTT/subscribe.php
  87. 0 0
      application/admin/view/batchhandle/add.html
  88. 0 0
      application/admin/view/batchhandle/index.html
  89. 0 0
      application/admin/view/company/add.html
  90. 0 0
      application/admin/view/company/edit.html
  91. 0 0
      application/admin/view/company/index.html
  92. 0 0
      application/admin/view/device/add.html
  93. 0 0
      application/admin/view/device/add.html.bak.2021-12-29
  94. 0 0
      application/admin/view/device/edit.html
  95. 0 0
      application/admin/view/device/edit.html.bak
  96. 0 0
      application/admin/view/device/edit.html.bak-2021-12-27
  97. 0 0
      application/admin/view/device/edit.html.bak.2020-12-14
  98. 0 0
      application/admin/view/device/edit2.html.bak
  99. 0 0
      application/admin/view/device/edit3.html.bak
  100. 0 0
      application/admin/view/device/history.html

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.idea
+composer.lock
+*.log
+thinkphp

+ 8 - 1
.htaccess

@@ -1 +1,8 @@
-deny from all
+<IfModule mod_rewrite.c>
+  Options +FollowSymlinks -Multiviews
+  RewriteEngine On
+
+  RewriteCond %{REQUEST_FILENAME} !-d
+  RewriteCond %{REQUEST_FILENAME} !-f
+  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
+</IfModule>

+ 42 - 0
.travis.yml

@@ -0,0 +1,42 @@
+sudo: false
+
+language: php
+
+branches:
+  only:
+    - stable
+
+cache:
+  directories:
+    - $HOME/.composer/cache
+
+before_install:
+  - composer self-update
+
+install:
+  - composer install --no-dev --no-interaction --ignore-platform-reqs
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
+  - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
+  - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
+
+script:
+  - php think unit
+
+deploy:
+  provider: releases
+  api_key:
+    secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
+  file:
+    - ThinkPHP_Core.zip
+    - ThinkPHP_Full.zip
+  skip_cleanup: true
+  on:
+    tags: true

+ 32 - 0
LICENSE.txt

@@ -0,0 +1,32 @@
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
+All rights reserved。
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+Apache Licence是著名的非盈利开源组织Apache采用的协议。
+该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
+允许代码修改,再作为开源或商业软件发布。需要满足
+的条件: 
+1. 需要给代码的用户一份Apache Licence ;
+2. 如果你修改了代码,需要在被修改的文件中说明;
+3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
+带有原来代码中的协议,商标,专利声明和其他原来作者规
+定需要包含的说明;
+4. 如果再发布的产品中包含一个Notice文件,则在Notice文
+件中需要带有本协议内容。你可以在Notice中增加自己的
+许可,但不可以表现为对Apache Licence构成更改。 
+具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.

+ 129 - 1
README.md

@@ -1 +1,129 @@
-本项目包含:永天科技NBIOT管理平台、NB水表液位采集程序、4G拓扑索尔水表液位采集程序,主要具备与电信OC平台交互,NB设备注册、数据跟踪、命令下发等功能;拓扑索尔、朝晖、宇洁容情等NB水表与液位、消火栓,拓普索尔4G水表数据采集、解析、存库、转发功能
+ThinkPHP 5.0
+===============
+
+[![Total Downloads](https://poser.pugx.org/topthink/think/downloads)](https://packagist.org/packages/topthink/think)
+[![Latest Stable Version](https://poser.pugx.org/topthink/think/v/stable)](https://packagist.org/packages/topthink/think)
+[![Latest Unstable Version](https://poser.pugx.org/topthink/think/v/unstable)](https://packagist.org/packages/topthink/think)
+[![License](https://poser.pugx.org/topthink/think/license)](https://packagist.org/packages/topthink/think)
+
+ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PHP版本要求提升到5.4,对已有的CBD模式做了更深的强化,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是ThinkPHP突破原有框架思路的颠覆之作,其主要特性包括:
+
+ + 基于命名空间和众多PHP新特性
+ + 核心功能组件化
+ + 强化路由功能
+ + 更灵活的控制器
+ + 重构的模型和数据库类
+ + 配置文件可分离
+ + 重写的自动验证和完成
+ + 简化扩展机制
+ + API支持完善
+ + 改进的Log类
+ + 命令行访问支持
+ + REST支持
+ + 引导文件支持
+ + 方便的自动生成定义
+ + 真正惰性加载
+ + 分布式环境支持
+ + 更多的社交类库
+
+> ThinkPHP5的运行环境要求PHP5.4以上。
+
+详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5)
+
+## 目录结构
+
+初始的目录结构如下:
+
+~~~
+www  WEB部署目录(或者子目录)
+├─application           应用目录
+│  ├─common             公共模块目录(可以更改)
+│  ├─module_name        模块目录
+│  │  ├─config.php      模块配置文件
+│  │  ├─common.php      模块函数文件
+│  │  ├─controller      控制器目录
+│  │  ├─model           模型目录
+│  │  ├─view            视图目录
+│  │  └─ ...            更多类库目录
+│  │
+│  ├─command.php        命令行工具配置文件
+│  ├─common.php         公共函数文件
+│  ├─config.php         公共配置文件
+│  ├─route.php          路由配置文件
+│  ├─tags.php           应用行为扩展定义文件
+│  └─database.php       数据库配置文件
+│
+├─public                WEB目录(对外访问目录)
+│  ├─index.php          入口文件
+│  ├─router.php         快速测试文件
+│  └─.htaccess          用于apache的重写
+│
+├─thinkphp              框架系统目录
+│  ├─lang               语言文件目录
+│  ├─library            框架类库目录
+│  │  ├─think           Think类库包目录
+│  │  └─traits          系统Trait目录
+│  │
+│  ├─tpl                系统模板目录
+│  ├─base.php           基础定义文件
+│  ├─console.php        控制台入口文件
+│  ├─convention.php     框架惯例配置文件
+│  ├─helper.php         助手函数文件
+│  ├─phpunit.xml        phpunit配置文件
+│  └─start.php          框架入口文件
+│
+├─extend                扩展类库目录
+├─runtime               应用的运行时目录(可写,可定制)
+├─vendor                第三方类库目录(Composer依赖库)
+├─build.php             自动生成定义文件(参考)
+├─composer.json         composer 定义文件
+├─LICENSE.txt           授权说明文件
+├─README.md             README 文件
+├─think                 命令行入口文件
+~~~
+
+> router.php用于php自带webserver支持,可用于快速测试
+> 切换到public目录后,启动命令:php -S localhost:8888  router.php
+> 上面的目录结构和名称是可以改变的,这取决于你的入口文件和配置参数。
+
+## 命名规范
+
+`ThinkPHP5`遵循PSR-2命名规范和PSR-4自动加载规范,并且注意如下规范:
+
+### 目录和文件
+
+*   目录不强制规范,驼峰和小写+下划线模式均支持;
+*   类库、函数文件统一以`.php`为后缀;
+*   类的文件名均以命名空间定义,并且命名空间的路径和类库文件所在路径一致;
+*   类名和类文件名保持一致,统一采用驼峰法命名(首字母大写);
+
+### 函数和类、属性命名
+*   类的命名采用驼峰法,并且首字母大写,例如 `User`、`UserType`,默认不需要添加后缀,例如`UserController`应该直接命名为`User`;
+*   函数的命名使用小写字母和下划线(小写字母开头)的方式,例如 `get_client_ip`;
+*   方法的命名使用驼峰法,并且首字母小写,例如 `getUserName`;
+*   属性的命名使用驼峰法,并且首字母小写,例如 `tableName`、`instance`;
+*   以双下划线“__”打头的函数或方法作为魔法方法,例如 `__call` 和 `__autoload`;
+
+### 常量和配置
+*   常量以大写字母和下划线命名,例如 `APP_PATH`和 `THINK_PATH`;
+*   配置参数以小写字母和下划线命名,例如 `url_route_on` 和`url_convert`;
+
+### 数据表和字段
+*   数据表和字段采用小写加下划线方式命名,并注意字段名不要以下划线开头,例如 `think_user` 表和 `user_name`字段,不建议使用驼峰和中文作为数据表字段命名。
+
+## 参与开发
+请参阅 [ThinkPHP5 核心框架包](https://github.com/top-think/framework)。
+
+## 版权信息
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+
+本项目包含的第三方源码和二进制文件之版权信息另行标注。
+
+版权所有Copyright © 2006-2017 by ThinkPHP (http://thinkphp.cn)
+
+All rights reserved。
+
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+更多细节参阅 [LICENSE.txt](LICENSE.txt)

+ 0 - 155
admin/controller/Manage.php.bak.20201202

@@ -1,155 +0,0 @@
-<?php
-namespace app\admin\controller;
-use think\Controller;
-use think\Session;
-use think\Db;
-use think\Request;
-class Manage extends Controller
-{  
- 	private $host="https://device.api.ct10649.com:8743/";
-    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
-    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
- 	
- 	public function index(){
- 		$data_list =Db::table('managelog')->paginate();
-        $pages = $data_list->render();        
-        $this->assign('data_list', $data_list);
-        $this->assign('pages', $pages); 
-
-
-        	//所有的服务类型
-        $SetType=[
-        	1=>"读取模块信息",
-        	2=>"读取参数",
-        	3=>"设置IOT平台IP地址",
-        	4=>"设置参数",
-        	5=>"复位模块",
-        	6=>"配置下行波特率",
-        	7=>"读取下行波特率配置",
-        	8=>"设置DTU自动采集指令",
-        	9=>"读取DTU自动采集指令",
-        	10=>"设置APN",
-        	11=>"读取APN设置",
-        	12=>"AT指令",
-
-   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]*/
-        ];
-
-        $this->assign('SetType',$SetType);
-        
-        return $this->fetch();
-
-
- 	}
- 	//下发命令
- 	public function add(){
-
- 		if ($this->request->isPost()) {
- 				 $data=$_POST;
- 		       //调用电信接口
-                $token=json_decode(gettoken(),true);
-
-            
-
-                $sendata=[
-                    "appId"=>$this->appId,
-                    "deviceId"=>$data['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                    "command"=>[
-                    		"serviceId"=>"SomkNotifiction",
-                    		"method"=>"REPORT",
-                    		
-                    	],
-                    "callbackUrl"=>"http://www.jd-ioe.com:80/ytapi/admin/Manage/status",
-                 ];
-                $header=[
-                    "Content-Type:application/json", 
-                    "app_key:".$this->appId,
-                    "Authorization:Bearer ".$token["accessToken"]      
-                    ];            
-                $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-                 var_dump($rescurl); 
-                if($rescurl[0]==201){//成功
-                    $res1=json_decode($rescurl[1],true);
-                    var_dump($res1); 
-                }else{//失败
-                  //  $res2=json_decode($res1[1],true);
-                    return $this->error($rescurl[1]);
-                } 
-
-              //将请求的结果存入managelog中
-              
-             	$list=array();
-                $list['commandId']=$res1['commandId'];
-                $list['deviceId']=$res1['deviceId']; 
-                $list['status']=$res1['status']; 
-                $list['command']= json_encode($res1['command'],320) ;
-                $list['IMEI']=$data['IMEI']; 
-                $list['HexStr']="";     
-                $list['settype']="";      
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
- 				if($res) {
-                    return $this->success('添加成功','index');
-                }else{
-                    return $this->error("添加失败,请稍后再试");
-                }
-
-          
-         }
-
-        if($this->request->isGet()){
-        	$deviceId=input('deviceId');
-        	$IMEI=input('IMEI');
-
-
-        	//所有的服务类型
-        	$SetType=[
-        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]
-        	];
-
-        	$this->assign('SetType',$SetType);
-        	$this->assign('deviceId',$deviceId);
-       		$this->assign('IMEI', $IMEI); 
-        	return $this->fetch();
-        }
-
- 		    
- 	}
-
-  	public function status(){
- 		$data=input('');
-
- 		
-        	if(is_array($data)){
-                	$getdata= json_encode($data,320);
-                	$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=1;
-         
-                }else{
-                	$getdata=$data;
-              		$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=2;
-
-                }
-             
-             	$list=array();
-                $list['deviceId']=$getdata['deviceId'];
-                $list['commandId']=$getdata['commandId']; 
-                $list['resultCode']=$getdata['result']['resultCode']; 
-                $list['result']= json_encode($getdata['result'],320) ;
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-
- 		echo    111;
-
- 	}
-
- 	public function delete(){
- 			echo   111;
- 	}
- 
-}

+ 0 - 164
admin/controller/Manage.php.bak.20201202fasongjiange

@@ -1,164 +0,0 @@
-<?php
-namespace app\admin\controller;
-use think\Controller;
-use think\Session;
-use think\Db;
-use think\Request;
-use think\Log;
-class Manage extends Controller
-{  
- 	private $host="https://device.api.ct10649.com:8743/";
-    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
-    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
- 	
- 	public function index(){
- 		$data_list =Db::table('managelog')->paginate();
-        $pages = $data_list->render();        
-        $this->assign('data_list', $data_list);
-        $this->assign('pages', $pages); 
-
-
-        	//所有的服务类型
-        $SetType=[
-        	1=>"读取模块信息",
-        	2=>"读取参数",
-        	3=>"设置IOT平台IP地址",
-        	4=>"设置参数",
-        	5=>"复位模块",
-        	6=>"配置下行波特率",
-        	7=>"读取下行波特率配置",
-        	8=>"设置DTU自动采集指令",
-        	9=>"读取DTU自动采集指令",
-        	10=>"设置APN",
-        	11=>"读取APN设置",
-        	12=>"AT指令",
-
-   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]*/
-        ];
-
-        $this->assign('SetType',$SetType);
-        
-        return $this->fetch();
-
-
- 	}
- 	//下发命令
- 	public function add(){
-
- 		if ($this->request->isPost()) {
-            $data=input('');
-            $list = array();
-            if (is_array($data)) {
-                $list['data'] = json_encode($data, 320);
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 1;
-            } else {
-                $list['data'] = $data;
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 2;
-            }
- 		       //调用电信接口
-                $token=json_decode(gettoken(),true);
-            $paras = array();
-            $paras['value'] = "7470736c04001701383634303136303534383331393632300204000002580023696f74";
-            $sendata=[
-                "appId"=>$this->appId,
-                "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                "command"=>[
-                        "serviceId"=>"topsailSensorData",
-                        "method"=>"SET_DEVICE_LEVEL",
-                        "paras"=>$paras
-                    ],
-                "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-             ];
-            $header=[
-                "Content-Type:application/json",
-                "app_key:".$this->appId,
-                "Authorization:Bearer ".$token["accessToken"]
-                ];
-            $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-             var_dump($rescurl);
-            Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-            if($rescurl[0]==201){//成功
-                $res1=json_decode($rescurl[1],true);
-                var_dump($res1);
-            }else{//失败
-              //  $res2=json_decode($res1[1],true);
-                return $this->error($rescurl[1]);
-            }
-
-          //将请求的结果存入managelog中
-
-            $list=array();
-            $list['commandId']=$res1['commandId'];
-            $list['deviceId']=$res1['deviceId'];
-            $list['status']=$res1['status'];
-            $list['command']= json_encode($res1['command'],320) ;
-            $list['IMEI']=$getdata['IMEI'];
-            $list['HexStr']="";
-            $list['settype']="";
-            $list['addtime']= date('Y-m-d H:i:s');
-            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
-            if($res) {
-                return $this->success('添加成功','index');
-            }else{
-                return $this->error("添加失败,请稍后再试");
-            }
-         }
-
-        if($this->request->isGet()){
-        	$deviceId=input('deviceId');
-        	$IMEI=input('IMEI');
-
-
-        	//所有的服务类型
-        	$SetType=[
-        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]
-        	];
-
-        	$this->assign('SetType',$SetType);
-        	$this->assign('deviceId',$deviceId);
-       		$this->assign('IMEI', $IMEI); 
-        	return $this->fetch();
-        }
-
- 		    
- 	}
-
-  	public function status(){
- 		$data=input('');
-
- 		
-        	if(is_array($data)){
-                	$getdata= json_encode($data,320);
-                	$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=1;
-         
-                }else{
-                	$getdata=$data;
-              		$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=2;
-
-                }
-             
-             	$list=array();
-                $list['deviceId']=$getdata['deviceId'];
-                $list['commandId']=$getdata['commandId']; 
-                $list['resultCode']=$getdata['result']['resultCode']; 
-                $list['result']= json_encode($getdata['result'],320) ;
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-
- 		echo    111;
-
- 	}
-
- 	public function delete(){
- 			echo   111;
- 	}
- 
-}

+ 0 - 315
admin/controller/Manage.php.bak.20201204shangxiaxianweiruku

@@ -1,315 +0,0 @@
-<?php
-namespace app\admin\controller;
-use think\Controller;
-use think\Session;
-use think\Db;
-use think\Request;
-use think\Log;
-class Manage extends Controller
-{  
- 	private $host="https://device.api.ct10649.com:8743/";
-    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
-    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
-
- 	public function index(){
- 		$data_list =Db::table('managelog')->paginate();
-        $pages = $data_list->render();        
-        $this->assign('data_list', $data_list);
-        $this->assign('pages', $pages); 
-
-
-        	//所有的服务类型
-        $SetType=[
-        	1=>"读取模块信息",
-        	2=>"读取参数",
-        	3=>"设置IOT平台IP地址",
-        	4=>"设置参数",
-        	5=>"复位模块",
-        	6=>"配置下行波特率",
-        	7=>"读取下行波特率配置",
-        	8=>"设置DTU自动采集指令",
-        	9=>"读取DTU自动采集指令",
-        	10=>"设置APN",
-        	11=>"读取APN设置",
-        	12=>"AT指令",
-
-   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]*/
-        ];
-
-        $this->assign('SetType',$SetType);
-        
-        return $this->fetch();
-
-
- 	}
- 	//下发命令
- 	public function add(){
-
- 		if ($this->request->isPost()) {
-            $data=input('');
-            $list = array();
-            if (is_array($data)) {
-                $list['data'] = json_encode($data, 320);
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 1;
-            } else {
-                $list['data'] = $data;
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 2;
-            }
-            $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
-            Log::record('rawData:' .$json_string );
-            $paras = array();
-            if(!empty($getdata["dataType"])){
-                if($getdata['dataType']=="setting"){
-                    $sql6="select * from sp_owner where id ={$getdata['sensorId']}";
-                    $longHuOwner = add($sql6);
-                    $deviceCode = '';
-                    $deviceArr = str_split($longHuOwner[0]['owner_code'],1);
-                    for ($i=0;$i<count($deviceArr);$i++){
-                        $deviceCode.='3'.$deviceArr[$i];
-                    }
-                    $deviceCode = $deviceCode.'30';
-                    $sendingInterval = "";//发送间隔
-                    if (!empty($getdata['sendTime'])) {
-                        if($getdata['sendTime']<1800){
-                            $sendingInterval = "020400000708";
-                        }else{
-                            $liuSendTime1 = dechex($getdata['sendTime']);
-                            $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                            $sendingInterval = "0204".$liuSendTime;
-                        }
-                    }
-                    $lowThreshold = "";//告警下限
-                    if (!empty($getdata['lowThreshold'])) {
-                        $shiLowThreshold = $getdata['lowThreshold']*1000;
-                        $liuLowThreshold1 = dechex($shiLowThreshold);
-                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                        $lowThreshold = "0602".$liuLowThreshold;
-                    }
-                    $highThreshold = "";//告警上限
-                    if (!empty($getdata['highThreshold'])) {
-                        $shiHighThreshold = $getdata['highThreshold']*1000;
-                        $liuHighThreshold1 = dechex($shiHighThreshold);
-                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                        $highThreshold = "0702".$liuHighThreshold;
-                    }
-                    if($longHuOwner[0]['dwtype']==2){
-                        $dwType = "01";
-                    }elseif ($longHuOwner[0]['dwtype']==5){
-                        $dwType = "02";
-                    }
-                    $shiLength = strlen($dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                    $liuLength = dechex($shiLength);
-                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                    //调用电信接口
-                    $token=json_decode(gettoken(),true);
-                    $a = "7470736c04".$length.$dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold;
-                    $s = pack('H*',$a);
-                    $t = crc166($s);
-                    $t = unpack("H*", $s.$t);
-                    $paras['value'] = $t[1]."696f74";
-                    //            $t = crc16($paras['value'],0X1021,0Xffff,0X0000,false,false);
-                    $device = Db::name('device')->where('device_id', trim($longHuOwner[0]['owner_code']))->find();
-                    $sendata=[
-                        "appId"=>$this->appId,
-                        "deviceId"=>$device['iot_id'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                        "command"=>[
-                            "serviceId"=>"topsailSensorData",
-                            "method"=>"SET_DEVICE_LEVEL",
-                            "paras"=>$paras
-                        ],
-                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                    ];
-                    $header=[
-                        "Content-Type:application/json",
-                        "app_key:".$this->appId,
-                        "Authorization:Bearer ".$token["accessToken"]
-                    ];
-                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-//                var_dump($rescurl);
-                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                    if($rescurl[0]==201){//成功
-                        $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                    }else{//失败
-                        //  $res2=json_decode($res1[1],true);
-//                    return $this->error($rescurl[1]);
-                        Log::record('nbmanageerror:' .json_encode($this->error($rescurl[1])));
-                        $returnInformation['code'] = 60001;
-                        $returnInformation['msg'] = "操作失败,请联系管理员";
-                        return json_encode($returnInformation);
-                    }
-                }else if($getdata['dataType']=="bendi"){
-                    $deviceCode = '';
-                    $deviceArr = str_split($getdata['IMEI'],1);
-                    for ($i=0;$i<count($deviceArr);$i++){
-                        $deviceCode.='3'.$deviceArr[$i];
-                    }
-                    $deviceCode = $deviceCode.'30';
-                    //调用电信接口
-                    $collectionInterval = "";//发送间隔
-                    if (!empty($getdata['collectionTime'])) {
-                        $liuCollectionTime1 = dechex($getdata['collectionTime']);
-                        $liuCollectionTime = str_pad($liuCollectionTime1,8,0,STR_PAD_LEFT);
-                        $collectionInterval = "0104".$liuCollectionTime;
-                    }
-                    $sendingInterval = "";//发送间隔
-                    if (!empty($getdata['sendTime'])) {
-                        $liuSendTime1 = dechex($getdata['sendTime']);
-                        $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                        $sendingInterval = "0204".$liuSendTime;
-                    }
-                    $lowThreshold = "";//告警下限
-                    if (!empty($getdata['alarmLowerLimit'])) {
-                        $shiLowThreshold = $getdata['alarmLowerLimit']*1000;
-                        $liuLowThreshold1 = dechex($shiLowThreshold);
-                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                        $lowThreshold = "0602".$liuLowThreshold;
-                    }
-                    $highThreshold = "";//告警上限
-                    if (!empty($getdata['alarmUpperLimit'])) {
-                        $shiHighThreshold = $getdata['alarmUpperLimit']*1000;
-                        $liuHighThreshold1 = dechex($shiHighThreshold);
-                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                        $highThreshold = "0702".$liuHighThreshold;
-                    }
-                    if($getdata['deviceType']==2){
-                        $dwType = "01";
-                    }elseif ($getdata['deviceType']==5){
-                        $dwType = "02";
-                    }
-                    $shiLength = strlen($dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                    $liuLength = dechex($shiLength);
-                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                    //调用电信接口
-                    $token=json_decode(gettoken(),true);
-                    $a = "7470736c04".$length.$dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold;
-                    $s = pack('H*',$a);
-                    $t = crc166($s);
-                    $t = unpack("H*", $s.$t);
-                    $paras['value'] = $t[1]."696f74";
-                    $sendata=[
-                        "appId"=>$this->appId,
-                        "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                        "command"=>[
-                            "serviceId"=>"topsailSensorData",
-                            "method"=>"SET_DEVICE_LEVEL",
-                            "paras"=>$paras
-                        ],
-                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                    ];
-                    $header=[
-                        "Content-Type:application/json",
-                        "app_key:".$this->appId,
-                        "Authorization:Bearer ".$token["accessToken"]
-                    ];
-                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-                    var_dump($rescurl);
-                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                    if($rescurl[0]==201){//成功
-                        $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                    }else{//失败
-                        //  $res2=json_decode($res1[1],true);
-                        return $this->error($rescurl[1]);
-                    }
-                }else{
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,请联系管理员";
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                return json_encode($returnInformation);
-            }
-          //将请求的结果存入managelog中
-
-            $list=array();
-            $list['commandId']=$res1['commandId'];
-            $list['deviceId']=$res1['deviceId'];
-            $list['status']=$res1['status'];
-            $list['command']= json_encode($res1['command'],320) ;
-            if($getdata['dataType']=="setting"){
-                $list['IMEI']=$longHuOwner[0]['owner_code'];
-            }else{
-                $list['IMEI']=$getdata['IMEI'];
-            }
-            $list['HexStr']="";
-            $list['settype']="";
-            $list['addtime']= date('Y-m-d H:i:s');
-            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
-            if($res) {
-                $returnInformation['code'] = 200;
-                $returnInformation['msg'] = "操作成功";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->success('添加成功','index');
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->error("添加失败,请稍后再试");
-                }
-            }
-         }
-
-        if($this->request->isGet()){
-        	$deviceId=input('deviceId');
-        	$IMEI=input('IMEI');
-
-
-        	//所有的服务类型
-        	$SetType=[
-        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]
-        	];
-
-        	$this->assign('SetType',$SetType);
-        	$this->assign('deviceId',$deviceId);
-       		$this->assign('IMEI', $IMEI); 
-        	return $this->fetch();
-        }
- 	}
-
-  	public function status(){
- 		$data=input('');
-
- 		
-        	if(is_array($data)){
-                	$getdata= json_encode($data,320);
-                	$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=1;
-         
-                }else{
-                	$getdata=$data;
-              		$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=2;
-
-                }
-             
-             	$list=array();
-                $list['deviceId']=$getdata['deviceId'];
-                $list['commandId']=$getdata['commandId']; 
-                $list['resultCode']=$getdata['result']['resultCode']; 
-                $list['result']= json_encode($getdata['result'],320) ;
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-
- 		echo    111;
-
- 	}
-
- 	public function delete(){
- 			echo   111;
- 	}
-
-}

+ 0 - 332
admin/controller/Manage.php.bak.20201223

@@ -1,332 +0,0 @@
-<?php
-namespace app\admin\controller;
-use think\Controller;
-use think\Session;
-use think\Db;
-use think\Request;
-use think\Log;
-class Manage extends Controller
-{  
- 	private $host="https://device.api.ct10649.com:8743/";
-    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
-    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
-
- 	public function index(){
- 		$data_list =Db::table('managelog')->paginate();
-        $pages = $data_list->render();        
-        $this->assign('data_list', $data_list);
-        $this->assign('pages', $pages); 
-
-
-        	//所有的服务类型
-        $SetType=[
-        	1=>"读取模块信息",
-        	2=>"读取参数",
-        	3=>"设置IOT平台IP地址",
-        	4=>"设置参数",
-        	5=>"复位模块",
-        	6=>"配置下行波特率",
-        	7=>"读取下行波特率配置",
-        	8=>"设置DTU自动采集指令",
-        	9=>"读取DTU自动采集指令",
-        	10=>"设置APN",
-        	11=>"读取APN设置",
-        	12=>"AT指令",
-
-   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]*/
-        ];
-
-        $this->assign('SetType',$SetType);
-        
-        return $this->fetch();
-
-
- 	}
- 	//下发命令
- 	public function add(){
-
- 		if ($this->request->isPost()) {
-            $data=input('');
-            $list = array();
-            if (is_array($data)) {
-                $list['data'] = json_encode($data, 320);
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 1;
-            } else {
-                $list['data'] = $data;
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 2;
-            }
-            $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
-            Log::record('rawData:' .$json_string );
-            $paras = array();
-            $upData = array();
-            if(!empty($getdata["dataType"])){
-                if($getdata['dataType']=="setting"){
-                    $sql6="select * from sp_owner where id ={$getdata['sensorId']}";
-                    $longHuOwner = add($sql6);
-                    $deviceCode = '';
-                    $deviceArr = str_split($longHuOwner[0]['owner_code'],1);
-                    for ($i=0;$i<count($deviceArr);$i++){
-                        $deviceCode.='3'.$deviceArr[$i];
-                    }
-                    $deviceCode = $deviceCode.'30';
-                    $sendingInterval = "";//发送间隔
-                    if (!empty($getdata['sendTime'])) {
-                        if($getdata['sendTime']<1800){
-                            $sendingInterval = "020400000708";
-                            $upData['send_time'] = 1800;
-                        }else{
-                            $liuSendTime1 = dechex($getdata['sendTime']);
-                            $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                            $sendingInterval = "0204".$liuSendTime;
-                            $upData['send_time'] = $getdata['sendTime'];
-                        }
-                    }
-                    $lowThreshold = "";//告警下限
-                    if (!empty($getdata['lowThreshold'])) {
-                        $shiLowThreshold = $getdata['lowThreshold']*1000;
-                        $liuLowThreshold1 = dechex($shiLowThreshold);
-                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                        $lowThreshold = "0602".$liuLowThreshold;
-                        $upData['low_threshold'] = $getdata['lowThreshold'];
-                    }
-                    $highThreshold = "";//告警上限
-                    if (!empty($getdata['highThreshold'])) {
-                        $shiHighThreshold = $getdata['highThreshold']*1000;
-                        $liuHighThreshold1 = dechex($shiHighThreshold);
-                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                        $highThreshold = "0702".$liuHighThreshold;
-                        $upData['high_threshold'] = $getdata['highThreshold'];
-                    }
-                    if($longHuOwner[0]['dwtype']==2){
-                        $dwType = "01";
-                    }elseif ($longHuOwner[0]['dwtype']==5){
-                        $dwType = "02";
-                    }
-                    $shiLength = strlen($dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                    $liuLength = dechex($shiLength);
-                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                    //调用电信接口
-                    $token=json_decode(gettoken(),true);
-                    $a = "7470736c04".$length.$dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold;
-                    $s = pack('H*',$a);
-                    $t = crc166($s);
-                    $t = unpack("H*", $s.$t);
-                    $paras['value'] = $t[1]."696f74";
-                    //            $t = crc16($paras['value'],0X1021,0Xffff,0X0000,false,false);
-                    $device = Db::name('device')->where('device_id', trim($longHuOwner[0]['owner_code']))->find();
-                    $sendata=[
-                        "appId"=>$this->appId,
-                        "deviceId"=>$device['iot_id'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                        "command"=>[
-                            "serviceId"=>"topsailSensorData",
-                            "method"=>"SET_DEVICE_LEVEL",
-                            "paras"=>$paras
-                        ],
-                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                    ];
-                    $header=[
-                        "Content-Type:application/json",
-                        "app_key:".$this->appId,
-                        "Authorization:Bearer ".$token["accessToken"]
-                    ];
-                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-//                var_dump($rescurl);
-                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                    if($rescurl[0]==201){//成功
-                        $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                    }else{//失败
-                        //  $res2=json_decode($res1[1],true);
-//                    return $this->error($rescurl[1]);
-                        Log::record('nbmanageerror:' .json_encode($this->error($rescurl[1])));
-                        $returnInformation['code'] = 60001;
-                        $returnInformation['msg'] = "操作失败,请联系管理员";
-                        return json_encode($returnInformation);
-                    }
-                }else if($getdata['dataType']=="bendi"){
-                    $deviceCode = '';
-                    $deviceArr = str_split($getdata['IMEI'],1);
-                    for ($i=0;$i<count($deviceArr);$i++){
-                        $deviceCode.='3'.$deviceArr[$i];
-                    }
-                    $deviceCode = $deviceCode.'30';
-                    //调用电信接口
-                    $collectionInterval = "";//发送间隔
-                    if (!empty($getdata['collectionTime'])) {
-                        $liuCollectionTime1 = dechex($getdata['collectionTime']);
-                        $liuCollectionTime = str_pad($liuCollectionTime1,8,0,STR_PAD_LEFT);
-                        $collectionInterval = "0104".$liuCollectionTime;
-                    }
-                    $sendingInterval = "";//发送间隔
-                    if (!empty($getdata['sendTime'])) {
-                        $liuSendTime1 = dechex($getdata['sendTime']);
-                        $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                        $sendingInterval = "0204".$liuSendTime;
-                    }
-                    $lowThreshold = "";//告警下限
-                    if (!empty($getdata['alarmLowerLimit'])) {
-                        $shiLowThreshold = $getdata['alarmLowerLimit']*1000;
-                        $liuLowThreshold1 = dechex($shiLowThreshold);
-                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                        $lowThreshold = "0602".$liuLowThreshold;
-                    }
-                    $highThreshold = "";//告警上限
-                    if (!empty($getdata['alarmUpperLimit'])) {
-                        $shiHighThreshold = $getdata['alarmUpperLimit']*1000;
-                        $liuHighThreshold1 = dechex($shiHighThreshold);
-                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                        $highThreshold = "0702".$liuHighThreshold;
-                    }
-                    if($getdata['deviceType']==2){
-                        $dwType = "01";
-                    }elseif ($getdata['deviceType']==5){
-                        $dwType = "02";
-                    }
-                    $shiLength = strlen($dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                    $liuLength = dechex($shiLength);
-                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                    //调用电信接口
-                    $token=json_decode(gettoken(),true);
-                    $a = "7470736c04".$length.$dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold;
-                    $s = pack('H*',$a);
-                    $t = crc166($s);
-                    $t = unpack("H*", $s.$t);
-                    $paras['value'] = $t[1]."696f74";
-                    $sendata=[
-                        "appId"=>$this->appId,
-                        "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                        "command"=>[
-                            "serviceId"=>"topsailSensorData",
-                            "method"=>"SET_DEVICE_LEVEL",
-                            "paras"=>$paras
-                        ],
-                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                    ];
-                    $header=[
-                        "Content-Type:application/json",
-                        "app_key:".$this->appId,
-                        "Authorization:Bearer ".$token["accessToken"]
-                    ];
-                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-                    var_dump($rescurl);
-                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                    if($rescurl[0]==201){//成功
-                        $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                    }else{//失败
-                        //  $res2=json_decode($res1[1],true);
-                        return $this->error($rescurl[1]);
-                    }
-                }else{
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,请联系管理员";
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                return json_encode($returnInformation);
-            }
-          //将请求的结果存入managelog中
-
-            $list=array();
-            $list['commandId']=$res1['commandId'];
-            $list['deviceId']=$res1['deviceId'];
-            $list['status']=$res1['status'];
-            $list['command']= json_encode($res1['command'],320) ;
-            if($getdata['dataType']=="setting"){
-                $list['IMEI']=$longHuOwner[0]['owner_code'];
-            }else{
-                $list['IMEI']=$getdata['IMEI'];
-            }
-            $list['HexStr']=json_encode($upData,320) ;;
-            $list['settype']="";
-            $list['addtime']= date('Y-m-d H:i:s');
-            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
-            if($res) {
-                $returnInformation['code'] = 200;
-                $returnInformation['msg'] = "操作成功";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->success('添加成功','index');
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->error("添加失败,请稍后再试");
-                }
-            }
-         }
-
-        if($this->request->isGet()){
-        	$deviceId=input('deviceId');
-        	$IMEI=input('IMEI');
-
-
-        	//所有的服务类型
-        	$SetType=[
-        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]
-        	];
-
-        	$this->assign('SetType',$SetType);
-        	$this->assign('deviceId',$deviceId);
-       		$this->assign('IMEI', $IMEI); 
-        	return $this->fetch();
-        }
- 	}
-
-  	public function status(){
- 		$data=input('');
-
- 		
-        	if(is_array($data)){
-                	$getdata= json_encode($data,320);
-                	$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=1;
-         
-                }else{
-                	$getdata=$data;
-              		$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=2;
-
-                }
-             	$list=array();
-                $list['deviceId']=$getdata['deviceId'];
-                $list['commandId']=$getdata['commandId']; 
-                $list['resultCode']=$getdata['result']['resultCode']; 
-                $list['result']= json_encode($getdata['result'],320) ;
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
-            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
-            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
-            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
-            $upData = json_decode($managelog['HexStr'],true);
-            if (!empty($deviceConfigure['device_code'])) {
-                sleep(1);
-                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
-            }else{
-                sleep(1);
-                $upData['device_code'] = $device['device_id'];
-                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-            }
-        }
- 		echo    111;
-
- 	}
-
- 	public function delete(){
- 			echo   111;
- 	}
-
-}

+ 0 - 552
admin/controller/Manage.php.bak.2021-03-17

@@ -1,552 +0,0 @@
-<?php
-namespace app\admin\controller;
-use think\Controller;
-use think\Session;
-use think\Db;
-use think\Request;
-use think\Log;
-class Manage extends Controller
-{  
- 	private $host="https://device.api.ct10649.com:8743/";
-    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
-    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
-
- 	public function index(){
- 		$data_list =Db::table('managelog')->paginate();
-        $pages = $data_list->render();        
-        $this->assign('data_list', $data_list);
-        $this->assign('pages', $pages); 
-
-
-        	//所有的服务类型
-        $SetType=[
-        	1=>"读取模块信息",
-        	2=>"读取参数",
-        	3=>"设置IOT平台IP地址",
-        	4=>"设置参数",
-        	5=>"复位模块",
-        	6=>"配置下行波特率",
-        	7=>"读取下行波特率配置",
-        	8=>"设置DTU自动采集指令",
-        	9=>"读取DTU自动采集指令",
-        	10=>"设置APN",
-        	11=>"读取APN设置",
-        	12=>"AT指令",
-
-   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]*/
-        ];
-
-        $this->assign('SetType',$SetType);
-        
-        return $this->fetch();
-
-
- 	}
- 	//下发命令
- 	public function add(){
-
- 		if ($this->request->isPost()) {
-            $data=input('');
-            $list = array();
-            if (is_array($data)) {
-                $list['data'] = json_encode($data, 320);
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 1;
-            } else {
-                $list['data'] = $data;
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 2;
-            }
-            $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
-            Log::record('rawData:' .$json_string );
-            $paras = array();
-            $upData = array();
-            if(!empty($getdata["dataType"])){
-                if($getdata['dataType']=="setting"){
-                    $sql6="select * from sp_owner where id ={$getdata['sensorId']}";
-                    $longHuOwner = add($sql6);
-                    if ($longHuOwner[0]['s_interval']==7){
-                        $imei='&imei='.$longHuOwner[0]['owner_code'];
-                        if($longHuOwner[0]['dwtype']==2){
-                            $deviceType=1;
-                        }elseif ($longHuOwner[0]['dwtype']==5){
-                            $deviceType=2;
-                        }
-                        $sendata['imei']=$longHuOwner[0]['owner_code'];
-                        $sendata['deviceType']=$deviceType;
-                        $sendingGap = '';
-                        if (!empty($getdata["sendTime"])){
-                            if($getdata['sendTime']<1800) {
-                                $sendingGap = '&sendingGap=1800';
-                                $upData['send_time'] = 1800;
-                                $sendata['sendingGap']=1800;
-                            }else{
-                                $sendingGap = '&sendingGap='.$getdata["sendTime"];
-                                $upData['send_time'] = $getdata["sendTime"];
-                                $sendata['sendingGap']=$getdata["sendTime"];
-                            }
-                        }
-                        $unipathThresholdLimit = '';
-                        if (!empty($getdata["lowThreshold"])){
-                            $sendata['unipathThresholdLimit'] = $getdata["lowThreshold"]*1000;
-                            $upData['low_threshold'] = $getdata['lowThreshold'];
-                        }
-                        $unipathThresholdUpper = '';
-                        if (!empty($getdata["highThreshold"])){
-                            $sendata['unipathThresholdUpper'] = $getdata["highThreshold"]*1000;
-                            $upData['high_threshold'] = $getdata['highThreshold'];
-                        }
-
-                        $header=[
-                            "Content-Type:application/json"
-                        ];
-                        $rescurl=$this->s_curl("https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052",json_encode($sendata),$header);
-//                        $rep_url = "https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052".$imei.$deviceType.$sendingGap.$unipathThresholdLimit.$unipathThresholdUpper;
-//                        $res = $this->s_curl($rep_url,'');
-                        Log::record('longhulorasend' . ':' . json_encode($sendata));
-                        Log::record('longhuloraresult' . ':' . $rescurl);
-//                        if (is_array($rescurl)) {
-//
-//                        }else{}
-                        $resArr = json_decode($rescurl,true);
-                        if ($resArr['code']==0){
-                            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->find();
-                            if (!empty($deviceConfigure['device_code'])) {
-                                sleep(1);
-                                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->update($upData);
-                            }else{
-                                sleep(1);
-                                $upData['device_code'] = $longHuOwner[0]['owner_code'];
-                                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-                            }
-                        }
-                        return $rescurl;
-                    }else{
-                        $deviceCode = '';
-                        $deviceArr = str_split($longHuOwner[0]['owner_code'],1);
-                        for ($i=0;$i<count($deviceArr);$i++){
-                            $deviceCode.='3'.$deviceArr[$i];
-                        }
-                        $deviceCode = $deviceCode.'30';
-                        $sendingInterval = "";//发送间隔
-                        if (!empty($getdata['sendTime'])) {
-                            if($getdata['sendTime']<1800){
-                                $sendingInterval = "020400000708";
-                                $upData['send_time'] = 1800;
-                            }else{
-                                $liuSendTime1 = dechex($getdata['sendTime']);
-                                $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                                $sendingInterval = "0204".$liuSendTime;
-                                $upData['send_time'] = $getdata['sendTime'];
-                            }
-                        }
-                        $lowThreshold = "";//告警下限
-                        if (!empty($getdata['lowThreshold'])) {
-                            $shiLowThreshold = $getdata['lowThreshold']*1000;
-                            $liuLowThreshold1 = dechex($shiLowThreshold);
-                            $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                            $lowThreshold = "0602".$liuLowThreshold;
-                            $upData['low_threshold'] = $getdata['lowThreshold'];
-                        }
-                        $highThreshold = "";//告警上限
-                        if (!empty($getdata['highThreshold'])) {
-                            $shiHighThreshold = $getdata['highThreshold']*1000;
-                            $liuHighThreshold1 = dechex($shiHighThreshold);
-                            $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                            $highThreshold = "0702".$liuHighThreshold;
-                            $upData['high_threshold'] = $getdata['highThreshold'];
-                        }
-                        if($longHuOwner[0]['dwtype']==2){
-                            $dwType = "01";
-                        }elseif ($longHuOwner[0]['dwtype']==5){
-                            $dwType = "02";
-                        }
-                        $shiLength = strlen($dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                        $liuLength = dechex($shiLength);
-                        $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                        //调用电信接口
-                        $token=json_decode(gettoken(),true);
-                        $a = "7470736c04".$length.$dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold;
-                        $s = pack('H*',$a);
-                        $t = crc166($s);
-                        $t = unpack("H*", $s.$t);
-                        $paras['value'] = $t[1]."696f74";
-                        //            $t = crc16($paras['value'],0X1021,0Xffff,0X0000,false,false);
-                        $device = Db::name('device')->where('device_id', trim($longHuOwner[0]['owner_code']))->find();
-                        $sendata=[
-                            "appId"=>$this->appId,
-                            "deviceId"=>$device['iot_id'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                            "command"=>[
-                                "serviceId"=>"topsailSensorData",
-                                "method"=>"SET_DEVICE_LEVEL",
-                                "paras"=>$paras
-                            ],
-                            "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                        ];
-                        $header=[
-                            "Content-Type:application/json",
-                            "app_key:".$this->appId,
-                            "Authorization:Bearer ".$token["accessToken"]
-                        ];
-                        $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-//                var_dump($rescurl);
-                        Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                        if($rescurl[0]==201){//成功
-                            $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                        }else{//失败
-                            //  $res2=json_decode($res1[1],true);
-//                    return $this->error($rescurl[1]);
-                            Log::record('nbmanageerror:' .json_encode($this->error($rescurl[1])));
-                            $returnInformation['code'] = 60001;
-                            $returnInformation['msg'] = "操作失败,请联系管理员";
-                            return json_encode($returnInformation);
-                        }
-                    }
-                }else if($getdata['dataType']=="bendi"){
-                    $deviceCode = '';
-                    $deviceArr = str_split($getdata['IMEI'],1);
-                    for ($i=0;$i<count($deviceArr);$i++){
-                        $deviceCode.='3'.$deviceArr[$i];
-                    }
-                    $deviceCode = $deviceCode.'30';
-                    //调用电信接口
-                    $collectionInterval = "";//发送间隔
-                    if (!empty($getdata['collectionTime'])) {
-                        $liuCollectionTime1 = dechex($getdata['collectionTime']);
-                        $liuCollectionTime = str_pad($liuCollectionTime1,8,0,STR_PAD_LEFT);
-                        $collectionInterval = "0104".$liuCollectionTime;
-                    }
-                    $sendingInterval = "";//发送间隔
-                    if (!empty($getdata['sendTime'])) {
-                        $liuSendTime1 = dechex($getdata['sendTime']);
-                        $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                        $sendingInterval = "0204".$liuSendTime;
-                    }
-                    $lowThreshold = "";//告警下限
-                    if (!empty($getdata['alarmLowerLimit'])) {
-                        $shiLowThreshold = $getdata['alarmLowerLimit']*1000;
-                        $liuLowThreshold1 = dechex($shiLowThreshold);
-                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                        $lowThreshold = "0602".$liuLowThreshold;
-                    }
-                    $highThreshold = "";//告警上限
-                    if (!empty($getdata['alarmUpperLimit'])) {
-                        $shiHighThreshold = $getdata['alarmUpperLimit']*1000;
-                        $liuHighThreshold1 = dechex($shiHighThreshold);
-                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                        $highThreshold = "0702".$liuHighThreshold;
-                    }
-                    if($getdata['deviceType']==2){
-                        $dwType = "01";
-                    }elseif ($getdata['deviceType']==5){
-                        $dwType = "02";
-                    }
-                    $shiLength = strlen($dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                    $liuLength = dechex($shiLength);
-                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                    //调用电信接口
-                    $token=json_decode(gettoken(),true);
-                    $a = "7470736c04".$length.$dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold;
-                    $s = pack('H*',$a);
-                    $t = crc166($s);
-                    $t = unpack("H*", $s.$t);
-                    $paras['value'] = $t[1]."696f74";
-                    $sendata=[
-                        "appId"=>$this->appId,
-                        "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                        "command"=>[
-                            "serviceId"=>"topsailSensorData",
-                            "method"=>"SET_DEVICE_LEVEL",
-                            "paras"=>$paras
-                        ],
-                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                    ];
-                    $header=[
-                        "Content-Type:application/json",
-                        "app_key:".$this->appId,
-                        "Authorization:Bearer ".$token["accessToken"]
-                    ];
-                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-                    var_dump($rescurl);
-                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                    if($rescurl[0]==201){//成功
-                        $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                    }else{//失败
-                        //  $res2=json_decode($res1[1],true);
-                        return $this->error($rescurl[1]);
-                    }
-                }else{
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,请联系管理员";
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                return json_encode($returnInformation);
-            }
-          //将请求的结果存入managelog中
-
-            $list=array();
-            $list['commandId']=$res1['commandId'];
-            $list['deviceId']=$res1['deviceId'];
-            $list['status']=$res1['status'];
-            $list['command']= json_encode($res1['command'],320) ;
-            if($getdata['dataType']=="setting"){
-                $list['IMEI']=$longHuOwner[0]['owner_code'];
-            }else{
-                $list['IMEI']=$getdata['IMEI'];
-            }
-            $list['HexStr']=json_encode($upData,320) ;;
-            $list['settype']="";
-            $list['addtime']= date('Y-m-d H:i:s');
-            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
-            if($res) {
-                $returnInformation['code'] = 200;
-                $returnInformation['msg'] = "操作成功";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->success('添加成功','index');
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->error("添加失败,请稍后再试");
-                }
-            }
-         }
-
-        if($this->request->isGet()){
-        	$deviceId=input('deviceId');
-        	$IMEI=input('IMEI');
-
-
-        	//所有的服务类型
-        	$SetType=[
-        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]
-        	];
-
-        	$this->assign('SetType',$SetType);
-        	$this->assign('deviceId',$deviceId);
-       		$this->assign('IMEI', $IMEI); 
-        	return $this->fetch();
-        }
- 	}
-
-  	public function status(){
- 		$data=input('');
-
- 		
-        	if(is_array($data)){
-                	$getdata= json_encode($data,320);
-                	$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=1;
-         
-                }else{
-                	$getdata=$data;
-              		$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=2;
-
-                }
-             	$list=array();
-                $list['deviceId']=$getdata['deviceId'];
-                $list['commandId']=$getdata['commandId']; 
-                $list['resultCode']=$getdata['result']['resultCode']; 
-                $list['result']= json_encode($getdata['result'],320) ;
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
-            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
-            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
-            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
-            $upData = json_decode($managelog['HexStr'],true);
-            if (!empty($deviceConfigure['device_code'])) {
-                sleep(1);
-                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
-            }else{
-                sleep(1);
-                $upData['device_code'] = $device['device_id'];
-                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-            }
-        }
- 		echo    111;
-
- 	}
-
- 	public function delete(){
- 			echo   111;
- 	}
-
-    public function manualPush(){
-        $data=input('');
-        if(is_array($data)){
-            $getdata= json_encode($data,320);
-            $getdata=json_decode($getdata,true);//转成数组
-            $list['type']=1;
-
-        }else{
-            $getdata=$data;
-            $getdata=json_decode($getdata,true);//转成数组
-            $list['type']=2;
-
-        }
-        if ($getdata['deviceType']==2){
-            $sql6="select * from sp_sj2017 where device_code ='{$getdata["deviceCode"]}'";
-            $longHuOwner = add($sql6);
-            Log::record('yangpuxiaoyuan12' . ':' . $longHuOwner[0]["id"]);
-            foreach ($longHuOwner as $row) {
-                $waterData["SubType"] = 2;
-                $waterData["DeviceId"] = $getdata["deviceCode"];
-                $waterData["InsertId"] = $row["id"];
-                $waterData["Confirmed"] = false;
-                $data6 = json_encode($waterData);
-                $rep_url = "http://47.98.201.187:55335/report";
-                $res = $this->ypxycurl($rep_url, $data6);
-                Log::record('yangpuxiaoyuan' . ':' . $res);
-                sleep(1);
-            }
-        }
-//        $list=array();
-//        $list['deviceId']=$getdata['deviceId'];
-//        $list['commandId']=$getdata['commandId'];
-//        $list['resultCode']=$getdata['result']['resultCode'];
-//        $list['result']= json_encode($getdata['result'],320) ;
-//        $list['addtime']= date('Y-m-d H:i:s');
-//        $res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-//        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
-//            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
-//            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
-//            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
-//            $upData = json_decode($managelog['HexStr'],true);
-//            if (!empty($deviceConfigure['device_code'])) {
-//                sleep(1);
-//                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
-//            }else{
-//                sleep(1);
-//                $upData['device_code'] = $device['device_id'];
-//                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-//            }
-//        }
-        echo    111;
-
-    }
-
-    public function alarmHandling(){
-        $data=input('');
-        if(is_array($data)){
-            $getDataJson= json_encode($data,320);
-            $getdata=json_decode($getDataJson,true);//转成数组
-            $list['type']=1;
-
-        }else{
-            $getDataJson=$data;
-            $getdata=json_decode($getDataJson,true);//转成数组
-            $list['type']=2;
-
-        }
-        Log::record('yangpuerqi' . ':' .$getDataJson);
-        if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
-            if ($getdata["userName"]=="ypsgec" && $getdata["userPassword"]=="ypsgec123"){
-                if (empty($getdata['recordId'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少记录Id";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['deviceCode'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少设备编号";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['deviceType'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少设备类型";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['confirmAll'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少是否批量处理类型";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['misinformation'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少是否误报字段";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['handlerName'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少处理人姓名";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['handlerPhone'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少处理人联系方式";
-                    return json_encode($returnInformation);
-                }else{
-                    $returnInformation['code'] = 0;
-                    $returnInformation['msg'] = "操作成功";
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60002;
-                $returnInformation['msg'] = "操作失败,用户名或密码错误";
-                return json_encode($returnInformation);
-            }
-        }else{
-            $returnInformation['code'] = 60002;
-            $returnInformation['msg'] = "操作失败,用户名或密码为空";
-            return json_encode($returnInformation);
-        }
-    }
-
-    public function s_curl($url,$data='',$header="",$method="POST"){
-        $ch = curl_init() ;
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
-
-        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
-        /*   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');*/
-        //  curl_setopt($ch, CURLOPT_VERBOSE, 1); //debugģʽ
-        curl_setopt($ch, CURLOPT_SSLCERT, "./server.crt"); //client.crt����
-        curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "IoM@1234"); //client֤������
-        curl_setopt($ch, CURLOPT_SSLKEY, "./server.key");
-        if($method=="POST"||$method=="PUT"||$method=="DELETE"){
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-        }
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-        $info = curl_exec($ch);
-        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-        if (curl_errno($ch)) {
-            $infores =  curl_error($ch);
-        }else{
-            $infores = $info;
-        }
-        curl_close($ch);
-        return $infores;
-    }
-
-    public function ypxycurl($url,$data=''){
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
-        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
-        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-        $info = curl_exec($ch);
-        if (curl_errno($ch)) {
-            $info = 'ERROR: ' . curl_error($ch);
-        }
-        curl_close($ch);
-        return $info;
-    }
-}

+ 0 - 491
admin/controller/Manage.php.bak.20210317

@@ -1,491 +0,0 @@
-<?php
-namespace app\admin\controller;
-use think\Controller;
-use think\Session;
-use think\Db;
-use think\Request;
-use think\Log;
-class Manage extends Controller
-{  
- 	private $host="https://device.api.ct10649.com:8743/";
-    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
-    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
-
- 	public function index(){
- 		$data_list =Db::table('managelog')->paginate();
-        $pages = $data_list->render();        
-        $this->assign('data_list', $data_list);
-        $this->assign('pages', $pages); 
-
-
-        	//所有的服务类型
-        $SetType=[
-        	1=>"读取模块信息",
-        	2=>"读取参数",
-        	3=>"设置IOT平台IP地址",
-        	4=>"设置参数",
-        	5=>"复位模块",
-        	6=>"配置下行波特率",
-        	7=>"读取下行波特率配置",
-        	8=>"设置DTU自动采集指令",
-        	9=>"读取DTU自动采集指令",
-        	10=>"设置APN",
-        	11=>"读取APN设置",
-        	12=>"AT指令",
-
-   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]*/
-        ];
-
-        $this->assign('SetType',$SetType);
-        
-        return $this->fetch();
-
-
- 	}
- 	//下发命令
- 	public function add(){
-
- 		if ($this->request->isPost()) {
-            $data=input('');
-            $list = array();
-            if (is_array($data)) {
-                $list['data'] = json_encode($data, 320);
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 1;
-            } else {
-                $list['data'] = $data;
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 2;
-            }
-            $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
-            Log::record('rawData:' .$json_string );
-            $paras = array();
-            $upData = array();
-            if(!empty($getdata["dataType"])){
-                if($getdata['dataType']=="setting"){
-                    $sql6="select * from sp_owner where id ={$getdata['sensorId']}";
-                    $longHuOwner = add($sql6);
-                    if ($longHuOwner[0]['s_interval']==7){
-                        $imei='&imei='.$longHuOwner[0]['owner_code'];
-                        if($longHuOwner[0]['dwtype']==2){
-                            $deviceType=1;
-                        }elseif ($longHuOwner[0]['dwtype']==5){
-                            $deviceType=2;
-                        }
-                        $sendata['imei']=$longHuOwner[0]['owner_code'];
-                        $sendata['deviceType']=$deviceType;
-                        $sendingGap = '';
-                        if (!empty($getdata["sendTime"])){
-                            if($getdata['sendTime']<1800) {
-                                $sendingGap = '&sendingGap=1800';
-                                $upData['send_time'] = 1800;
-                                $sendata['sendingGap']=1800;
-                            }else{
-                                $sendingGap = '&sendingGap='.$getdata["sendTime"];
-                                $upData['send_time'] = $getdata["sendTime"];
-                                $sendata['sendingGap']=$getdata["sendTime"];
-                            }
-                        }
-                        $unipathThresholdLimit = '';
-                        if (!empty($getdata["lowThreshold"])){
-                            $sendata['unipathThresholdLimit'] = $getdata["lowThreshold"]*1000;
-                            $upData['low_threshold'] = $getdata['lowThreshold'];
-                        }
-                        $unipathThresholdUpper = '';
-                        if (!empty($getdata["highThreshold"])){
-                            $sendata['unipathThresholdUpper'] = $getdata["highThreshold"]*1000;
-                            $upData['high_threshold'] = $getdata['highThreshold'];
-                        }
-
-                        $header=[
-                            "Content-Type:application/json"
-                        ];
-                        $rescurl=$this->s_curl("https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052",json_encode($sendata),$header);
-//                        $rep_url = "https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052".$imei.$deviceType.$sendingGap.$unipathThresholdLimit.$unipathThresholdUpper;
-//                        $res = $this->s_curl($rep_url,'');
-                        Log::record('longhulorasend' . ':' . json_encode($sendata));
-                        Log::record('longhuloraresult' . ':' . $rescurl);
-//                        if (is_array($rescurl)) {
-//
-//                        }else{}
-                        $resArr = json_decode($rescurl,true);
-                        if ($resArr['code']==0){
-                            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->find();
-                            if (!empty($deviceConfigure['device_code'])) {
-                                sleep(1);
-                                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->update($upData);
-                            }else{
-                                sleep(1);
-                                $upData['device_code'] = $longHuOwner[0]['owner_code'];
-                                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-                            }
-                        }
-                        return $rescurl;
-                    }else{
-                        $deviceCode = '';
-                        $deviceArr = str_split($longHuOwner[0]['owner_code'],1);
-                        for ($i=0;$i<count($deviceArr);$i++){
-                            $deviceCode.='3'.$deviceArr[$i];
-                        }
-                        $deviceCode = $deviceCode.'30';
-                        $sendingInterval = "";//发送间隔
-                        if (!empty($getdata['sendTime'])) {
-                            if($getdata['sendTime']<1800){
-                                $sendingInterval = "020400000708";
-                                $upData['send_time'] = 1800;
-                            }else{
-                                $liuSendTime1 = dechex($getdata['sendTime']);
-                                $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                                $sendingInterval = "0204".$liuSendTime;
-                                $upData['send_time'] = $getdata['sendTime'];
-                            }
-                        }
-                        $lowThreshold = "";//告警下限
-                        if (!empty($getdata['lowThreshold'])) {
-                            $shiLowThreshold = $getdata['lowThreshold']*1000;
-                            $liuLowThreshold1 = dechex($shiLowThreshold);
-                            $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                            $lowThreshold = "0602".$liuLowThreshold;
-                            $upData['low_threshold'] = $getdata['lowThreshold'];
-                        }
-                        $highThreshold = "";//告警上限
-                        if (!empty($getdata['highThreshold'])) {
-                            $shiHighThreshold = $getdata['highThreshold']*1000;
-                            $liuHighThreshold1 = dechex($shiHighThreshold);
-                            $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                            $highThreshold = "0702".$liuHighThreshold;
-                            $upData['high_threshold'] = $getdata['highThreshold'];
-                        }
-                        if($longHuOwner[0]['dwtype']==2){
-                            $dwType = "01";
-                        }elseif ($longHuOwner[0]['dwtype']==5){
-                            $dwType = "02";
-                        }
-                        $shiLength = strlen($dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                        $liuLength = dechex($shiLength);
-                        $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                        //调用电信接口
-                        $token=json_decode(gettoken(),true);
-                        $a = "7470736c04".$length.$dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold;
-                        $s = pack('H*',$a);
-                        $t = crc166($s);
-                        $t = unpack("H*", $s.$t);
-                        $paras['value'] = $t[1]."696f74";
-                        //            $t = crc16($paras['value'],0X1021,0Xffff,0X0000,false,false);
-                        $device = Db::name('device')->where('device_id', trim($longHuOwner[0]['owner_code']))->find();
-                        $sendata=[
-                            "appId"=>$this->appId,
-                            "deviceId"=>$device['iot_id'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                            "command"=>[
-                                "serviceId"=>"topsailSensorData",
-                                "method"=>"SET_DEVICE_LEVEL",
-                                "paras"=>$paras
-                            ],
-                            "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                        ];
-                        $header=[
-                            "Content-Type:application/json",
-                            "app_key:".$this->appId,
-                            "Authorization:Bearer ".$token["accessToken"]
-                        ];
-                        $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-//                var_dump($rescurl);
-                        Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                        if($rescurl[0]==201){//成功
-                            $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                        }else{//失败
-                            //  $res2=json_decode($res1[1],true);
-//                    return $this->error($rescurl[1]);
-                            Log::record('nbmanageerror:' .json_encode($this->error($rescurl[1])));
-                            $returnInformation['code'] = 60001;
-                            $returnInformation['msg'] = "操作失败,请联系管理员";
-                            return json_encode($returnInformation);
-                        }
-                    }
-                }else if($getdata['dataType']=="bendi"){
-                    $deviceCode = '';
-                    $deviceArr = str_split($getdata['IMEI'],1);
-                    for ($i=0;$i<count($deviceArr);$i++){
-                        $deviceCode.='3'.$deviceArr[$i];
-                    }
-                    $deviceCode = $deviceCode.'30';
-                    //调用电信接口
-                    $collectionInterval = "";//发送间隔
-                    if (!empty($getdata['collectionTime'])) {
-                        $liuCollectionTime1 = dechex($getdata['collectionTime']);
-                        $liuCollectionTime = str_pad($liuCollectionTime1,8,0,STR_PAD_LEFT);
-                        $collectionInterval = "0104".$liuCollectionTime;
-                    }
-                    $sendingInterval = "";//发送间隔
-                    if (!empty($getdata['sendTime'])) {
-                        $liuSendTime1 = dechex($getdata['sendTime']);
-                        $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                        $sendingInterval = "0204".$liuSendTime;
-                    }
-                    $lowThreshold = "";//告警下限
-                    if (!empty($getdata['alarmLowerLimit'])) {
-                        $shiLowThreshold = $getdata['alarmLowerLimit']*1000;
-                        $liuLowThreshold1 = dechex($shiLowThreshold);
-                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                        $lowThreshold = "0602".$liuLowThreshold;
-                    }
-                    $highThreshold = "";//告警上限
-                    if (!empty($getdata['alarmUpperLimit'])) {
-                        $shiHighThreshold = $getdata['alarmUpperLimit']*1000;
-                        $liuHighThreshold1 = dechex($shiHighThreshold);
-                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                        $highThreshold = "0702".$liuHighThreshold;
-                    }
-                    if($getdata['deviceType']==2){
-                        $dwType = "01";
-                    }elseif ($getdata['deviceType']==5){
-                        $dwType = "02";
-                    }
-                    $shiLength = strlen($dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                    $liuLength = dechex($shiLength);
-                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                    //调用电信接口
-                    $token=json_decode(gettoken(),true);
-                    $a = "7470736c04".$length.$dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold;
-                    $s = pack('H*',$a);
-                    $t = crc166($s);
-                    $t = unpack("H*", $s.$t);
-                    $paras['value'] = $t[1]."696f74";
-                    $sendata=[
-                        "appId"=>$this->appId,
-                        "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                        "command"=>[
-                            "serviceId"=>"topsailSensorData",
-                            "method"=>"SET_DEVICE_LEVEL",
-                            "paras"=>$paras
-                        ],
-                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                    ];
-                    $header=[
-                        "Content-Type:application/json",
-                        "app_key:".$this->appId,
-                        "Authorization:Bearer ".$token["accessToken"]
-                    ];
-                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-                    var_dump($rescurl);
-                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                    if($rescurl[0]==201){//成功
-                        $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                    }else{//失败
-                        //  $res2=json_decode($res1[1],true);
-                        return $this->error($rescurl[1]);
-                    }
-                }else{
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,请联系管理员";
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                return json_encode($returnInformation);
-            }
-          //将请求的结果存入managelog中
-
-            $list=array();
-            $list['commandId']=$res1['commandId'];
-            $list['deviceId']=$res1['deviceId'];
-            $list['status']=$res1['status'];
-            $list['command']= json_encode($res1['command'],320) ;
-            if($getdata['dataType']=="setting"){
-                $list['IMEI']=$longHuOwner[0]['owner_code'];
-            }else{
-                $list['IMEI']=$getdata['IMEI'];
-            }
-            $list['HexStr']=json_encode($upData,320) ;;
-            $list['settype']="";
-            $list['addtime']= date('Y-m-d H:i:s');
-            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
-            if($res) {
-                $returnInformation['code'] = 200;
-                $returnInformation['msg'] = "操作成功";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->success('添加成功','index');
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->error("添加失败,请稍后再试");
-                }
-            }
-         }
-
-        if($this->request->isGet()){
-        	$deviceId=input('deviceId');
-        	$IMEI=input('IMEI');
-
-
-        	//所有的服务类型
-        	$SetType=[
-        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]
-        	];
-
-        	$this->assign('SetType',$SetType);
-        	$this->assign('deviceId',$deviceId);
-       		$this->assign('IMEI', $IMEI); 
-        	return $this->fetch();
-        }
- 	}
-
-  	public function status(){
- 		$data=input('');
-
- 		
-        	if(is_array($data)){
-                	$getdata= json_encode($data,320);
-                	$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=1;
-         
-                }else{
-                	$getdata=$data;
-              		$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=2;
-
-                }
-             	$list=array();
-                $list['deviceId']=$getdata['deviceId'];
-                $list['commandId']=$getdata['commandId']; 
-                $list['resultCode']=$getdata['result']['resultCode']; 
-                $list['result']= json_encode($getdata['result'],320) ;
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
-            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
-            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
-            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
-            $upData = json_decode($managelog['HexStr'],true);
-            if (!empty($deviceConfigure['device_code'])) {
-                sleep(1);
-                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
-            }else{
-                sleep(1);
-                $upData['device_code'] = $device['device_id'];
-                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-            }
-        }
- 		echo    111;
-
- 	}
-
- 	public function delete(){
- 			echo   111;
- 	}
-
-    public function manualPush(){
-        $data=input('');
-        if(is_array($data)){
-            $getdata= json_encode($data,320);
-            $getdata=json_decode($getdata,true);//转成数组
-            $list['type']=1;
-
-        }else{
-            $getdata=$data;
-            $getdata=json_decode($getdata,true);//转成数组
-            $list['type']=2;
-
-        }
-        if ($getdata['deviceType']==2){
-            $sql6="select * from sp_sj2017 where device_code ='{$getdata["deviceCode"]}'";
-            $longHuOwner = add($sql6);
-            Log::record('yangpuxiaoyuan12' . ':' . $longHuOwner[0]["id"]);
-            foreach ($longHuOwner as $row) {
-                $waterData["SubType"] = 2;
-                $waterData["DeviceId"] = $getdata["deviceCode"];
-                $waterData["InsertId"] = $row["id"];
-                $waterData["Confirmed"] = false;
-                $data6 = json_encode($waterData);
-                $rep_url = "http://47.98.201.187:55335/report";
-                $res = $this->ypxycurl($rep_url, $data6);
-                Log::record('yangpuxiaoyuan' . ':' . $res);
-                sleep(1);
-            }
-        }
-//        $list=array();
-//        $list['deviceId']=$getdata['deviceId'];
-//        $list['commandId']=$getdata['commandId'];
-//        $list['resultCode']=$getdata['result']['resultCode'];
-//        $list['result']= json_encode($getdata['result'],320) ;
-//        $list['addtime']= date('Y-m-d H:i:s');
-//        $res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-//        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
-//            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
-//            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
-//            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
-//            $upData = json_decode($managelog['HexStr'],true);
-//            if (!empty($deviceConfigure['device_code'])) {
-//                sleep(1);
-//                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
-//            }else{
-//                sleep(1);
-//                $upData['device_code'] = $device['device_id'];
-//                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-//            }
-//        }
-        echo    111;
-
-    }
-
-    public function s_curl($url,$data='',$header="",$method="POST"){
-        $ch = curl_init() ;
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
-
-        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
-        /*   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');*/
-        //  curl_setopt($ch, CURLOPT_VERBOSE, 1); //debugģʽ
-        curl_setopt($ch, CURLOPT_SSLCERT, "./server.crt"); //client.crt����
-        curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "IoM@1234"); //client֤������
-        curl_setopt($ch, CURLOPT_SSLKEY, "./server.key");
-        if($method=="POST"||$method=="PUT"||$method=="DELETE"){
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-        }
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-        $info = curl_exec($ch);
-        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-        if (curl_errno($ch)) {
-            $infores =  curl_error($ch);
-        }else{
-            $infores = $info;
-        }
-        curl_close($ch);
-        return $infores;
-    }
-
-    public function ypxycurl($url,$data=''){
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
-        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
-        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-        $info = curl_exec($ch);
-        if (curl_errno($ch)) {
-            $info = 'ERROR: ' . curl_error($ch);
-        }
-        curl_close($ch);
-        return $info;
-    }
-}

+ 0 - 757
admin/controller/Manage.php.bak.20210325

@@ -1,757 +0,0 @@
-<?php
-namespace app\admin\controller;
-use think\Controller;
-use think\Session;
-use think\Db;
-use think\Request;
-use think\Log;
-class Manage extends Controller
-{  
- 	private $host="https://device.api.ct10649.com:8743/";
-    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
-    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
-
- 	public function index(){
- 		$data_list =Db::table('managelog')->paginate();
-        $pages = $data_list->render();        
-        $this->assign('data_list', $data_list);
-        $this->assign('pages', $pages); 
-
-
-        	//所有的服务类型
-        $SetType=[
-        	1=>"读取模块信息",
-        	2=>"读取参数",
-        	3=>"设置IOT平台IP地址",
-        	4=>"设置参数",
-        	5=>"复位模块",
-        	6=>"配置下行波特率",
-        	7=>"读取下行波特率配置",
-        	8=>"设置DTU自动采集指令",
-        	9=>"读取DTU自动采集指令",
-        	10=>"设置APN",
-        	11=>"读取APN设置",
-        	12=>"AT指令",
-
-   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]*/
-        ];
-
-        $this->assign('SetType',$SetType);
-        
-        return $this->fetch();
-
-
- 	}
- 	//下发命令
- 	public function add(){
-
- 		if ($this->request->isPost()) {
-            $data=input('');
-            $list = array();
-            if (is_array($data)) {
-                $list['data'] = json_encode($data, 320);
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 1;
-            } else {
-                $list['data'] = $data;
-                $getdata = json_decode($list['data'], true);//转成数组
-                $list['type'] = 2;
-            }
-            $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
-            Log::record('rawData:' .$json_string );
-            $paras = array();
-            $upData = array();
-            if(!empty($getdata["dataType"])){
-                if($getdata['dataType']=="setting"){
-                    $sql6="select * from sp_owner where id ={$getdata['sensorId']}";
-                    $longHuOwner = add($sql6);
-                    if ($longHuOwner[0]['s_interval']==7){
-                        $imei='&imei='.$longHuOwner[0]['owner_code'];
-                        if($longHuOwner[0]['dwtype']==2){
-                            $deviceType=1;
-                        }elseif ($longHuOwner[0]['dwtype']==5){
-                            $deviceType=2;
-                        }
-                        $sendata['imei']=$longHuOwner[0]['owner_code'];
-                        $sendata['deviceType']=$deviceType;
-                        $sendingGap = '';
-                        if (!empty($getdata["sendTime"])){
-                            if($getdata['sendTime']<1800) {
-                                $sendingGap = '&sendingGap=1800';
-                                $upData['send_time'] = 1800;
-                                $sendata['sendingGap']=1800;
-                            }else{
-                                $sendingGap = '&sendingGap='.$getdata["sendTime"];
-                                $upData['send_time'] = $getdata["sendTime"];
-                                $sendata['sendingGap']=$getdata["sendTime"];
-                            }
-                        }
-                        $unipathThresholdLimit = '';
-                        if (!empty($getdata["lowThreshold"])){
-                            $sendata['unipathThresholdLimit'] = $getdata["lowThreshold"]*1000;
-                            $upData['low_threshold'] = $getdata['lowThreshold'];
-                        }
-                        $unipathThresholdUpper = '';
-                        if (!empty($getdata["highThreshold"])){
-                            $sendata['unipathThresholdUpper'] = $getdata["highThreshold"]*1000;
-                            $upData['high_threshold'] = $getdata['highThreshold'];
-                        }
-
-                        $header=[
-                            "Content-Type:application/json"
-                        ];
-                        $rescurl=$this->s_curl("https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052",json_encode($sendata),$header);
-//                        $rep_url = "https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052".$imei.$deviceType.$sendingGap.$unipathThresholdLimit.$unipathThresholdUpper;
-//                        $res = $this->s_curl($rep_url,'');
-                        Log::record('longhulorasend' . ':' . json_encode($sendata));
-                        Log::record('longhuloraresult' . ':' . $rescurl);
-//                        if (is_array($rescurl)) {
-//
-//                        }else{}
-                        $resArr = json_decode($rescurl,true);
-                        if ($resArr['code']==0){
-                            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->find();
-                            if (!empty($deviceConfigure['device_code'])) {
-                                sleep(1);
-                                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->update($upData);
-                            }else{
-                                sleep(1);
-                                $upData['device_code'] = $longHuOwner[0]['owner_code'];
-                                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-                            }
-                        }
-                        return $rescurl;
-                    }else{
-                        $deviceCode = '';
-                        $deviceArr = str_split($longHuOwner[0]['owner_code'],1);
-                        for ($i=0;$i<count($deviceArr);$i++){
-                            $deviceCode.='3'.$deviceArr[$i];
-                        }
-                        $deviceCode = $deviceCode.'30';
-                        $sendingInterval = "";//发送间隔
-                        if (!empty($getdata['sendTime'])) {
-                            if($getdata['sendTime']<1800){
-                                $sendingInterval = "020400000708";
-                                $upData['send_time'] = 1800;
-                            }else{
-                                $liuSendTime1 = dechex($getdata['sendTime']);
-                                $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                                $sendingInterval = "0204".$liuSendTime;
-                                $upData['send_time'] = $getdata['sendTime'];
-                            }
-                        }
-                        $lowThreshold = "";//告警下限
-                        if (!empty($getdata['lowThreshold'])) {
-                            $shiLowThreshold = $getdata['lowThreshold']*1000;
-                            $liuLowThreshold1 = dechex($shiLowThreshold);
-                            $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                            $lowThreshold = "0602".$liuLowThreshold;
-                            $upData['low_threshold'] = $getdata['lowThreshold'];
-                        }
-                        $highThreshold = "";//告警上限
-                        if (!empty($getdata['highThreshold'])) {
-                            $shiHighThreshold = $getdata['highThreshold']*1000;
-                            $liuHighThreshold1 = dechex($shiHighThreshold);
-                            $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                            $highThreshold = "0702".$liuHighThreshold;
-                            $upData['high_threshold'] = $getdata['highThreshold'];
-                        }
-                        if($longHuOwner[0]['dwtype']==2){
-                            $dwType = "01";
-                        }elseif ($longHuOwner[0]['dwtype']==5){
-                            $dwType = "02";
-                        }
-                        $shiLength = strlen($dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                        $liuLength = dechex($shiLength);
-                        $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                        //调用电信接口
-                        $token=json_decode(gettoken(),true);
-                        $a = "7470736c04".$length.$dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold;
-                        $s = pack('H*',$a);
-                        $t = crc166($s);
-                        $t = unpack("H*", $s.$t);
-                        $paras['value'] = $t[1]."696f74";
-                        //            $t = crc16($paras['value'],0X1021,0Xffff,0X0000,false,false);
-                        $device = Db::name('device')->where('device_id', trim($longHuOwner[0]['owner_code']))->find();
-                        $sendata=[
-                            "appId"=>$this->appId,
-                            "deviceId"=>$device['iot_id'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                            "command"=>[
-                                "serviceId"=>"topsailSensorData",
-                                "method"=>"SET_DEVICE_LEVEL",
-                                "paras"=>$paras
-                            ],
-                            "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                        ];
-                        $header=[
-                            "Content-Type:application/json",
-                            "app_key:".$this->appId,
-                            "Authorization:Bearer ".$token["accessToken"]
-                        ];
-                        $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-//                var_dump($rescurl);
-                        Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                        if($rescurl[0]==201){//成功
-                            $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                        }else{//失败
-                            //  $res2=json_decode($res1[1],true);
-//                    return $this->error($rescurl[1]);
-                            Log::record('nbmanageerror:' .json_encode($this->error($rescurl[1])));
-                            $returnInformation['code'] = 60001;
-                            $returnInformation['msg'] = "操作失败,请联系管理员";
-                            return json_encode($returnInformation);
-                        }
-                    }
-                }else if($getdata['dataType']=="bendi"){
-                    $deviceCode = '';
-                    $deviceArr = str_split($getdata['IMEI'],1);
-                    for ($i=0;$i<count($deviceArr);$i++){
-                        $deviceCode.='3'.$deviceArr[$i];
-                    }
-                    $deviceCode = $deviceCode.'30';
-                    //调用电信接口
-                    $collectionInterval = "";//发送间隔
-                    if (!empty($getdata['collectionTime'])) {
-                        $liuCollectionTime1 = dechex($getdata['collectionTime']);
-                        $liuCollectionTime = str_pad($liuCollectionTime1,8,0,STR_PAD_LEFT);
-                        $collectionInterval = "0104".$liuCollectionTime;
-                    }
-                    $sendingInterval = "";//发送间隔
-                    if (!empty($getdata['sendTime'])) {
-                        $liuSendTime1 = dechex($getdata['sendTime']);
-                        $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
-                        $sendingInterval = "0204".$liuSendTime;
-                    }
-                    $lowThreshold = "";//告警下限
-                    if (!empty($getdata['alarmLowerLimit'])) {
-                        $shiLowThreshold = $getdata['alarmLowerLimit']*1000;
-                        $liuLowThreshold1 = dechex($shiLowThreshold);
-                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
-                        $lowThreshold = "0602".$liuLowThreshold;
-                    }
-                    $highThreshold = "";//告警上限
-                    if (!empty($getdata['alarmUpperLimit'])) {
-                        $shiHighThreshold = $getdata['alarmUpperLimit']*1000;
-                        $liuHighThreshold1 = dechex($shiHighThreshold);
-                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
-                        $highThreshold = "0702".$liuHighThreshold;
-                    }
-                    if($getdata['deviceType']==2){
-                        $dwType = "01";
-                    }elseif ($getdata['deviceType']==5){
-                        $dwType = "02";
-                    }
-                    $shiLength = strlen($dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold)/2;
-                    $liuLength = dechex($shiLength);
-                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
-                    //调用电信接口
-                    $token=json_decode(gettoken(),true);
-                    $a = "7470736c04".$length.$dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold;
-                    $s = pack('H*',$a);
-                    $t = crc166($s);
-                    $t = unpack("H*", $s.$t);
-                    $paras['value'] = $t[1]."696f74";
-                    $sendata=[
-                        "appId"=>$this->appId,
-                        "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
-                        "command"=>[
-                            "serviceId"=>"topsailSensorData",
-                            "method"=>"SET_DEVICE_LEVEL",
-                            "paras"=>$paras
-                        ],
-                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
-                    ];
-                    $header=[
-                        "Content-Type:application/json",
-                        "app_key:".$this->appId,
-                        "Authorization:Bearer ".$token["accessToken"]
-                    ];
-                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
-                    var_dump($rescurl);
-                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
-                    if($rescurl[0]==201){//成功
-                        $res1=json_decode($rescurl[1],true);
-//                    var_dump($res1);
-                    }else{//失败
-                        //  $res2=json_decode($res1[1],true);
-                        return $this->error($rescurl[1]);
-                    }
-                }else{
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,请联系管理员";
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                return json_encode($returnInformation);
-            }
-          //将请求的结果存入managelog中
-
-            $list=array();
-            $list['commandId']=$res1['commandId'];
-            $list['deviceId']=$res1['deviceId'];
-            $list['status']=$res1['status'];
-            $list['command']= json_encode($res1['command'],320) ;
-            if($getdata['dataType']=="setting"){
-                $list['IMEI']=$longHuOwner[0]['owner_code'];
-            }else{
-                $list['IMEI']=$getdata['IMEI'];
-            }
-            $list['HexStr']=json_encode($upData,320) ;;
-            $list['settype']="";
-            $list['addtime']= date('Y-m-d H:i:s');
-            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
-            if($res) {
-                $returnInformation['code'] = 200;
-                $returnInformation['msg'] = "操作成功";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->success('添加成功','index');
-                }
-            }else{
-                $returnInformation['code'] = 60001;
-                $returnInformation['msg'] = "操作失败,请联系管理员";
-                if($getdata['dataType']=="setting"){
-                    return json_encode($returnInformation);
-                }else{
-                    return $this->error("添加失败,请稍后再试");
-                }
-            }
-         }
-
-        if($this->request->isGet()){
-        	$deviceId=input('deviceId');
-        	$IMEI=input('IMEI');
-
-
-        	//所有的服务类型
-        	$SetType=[
-        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
-        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
-        		[12,"AT指令"]
-        	];
-
-        	$this->assign('SetType',$SetType);
-        	$this->assign('deviceId',$deviceId);
-       		$this->assign('IMEI', $IMEI); 
-        	return $this->fetch();
-        }
- 	}
-
-  	public function status(){
- 		$data=input('');
-
- 		
-        	if(is_array($data)){
-                	$getdata= json_encode($data,320);
-                	$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=1;
-         
-                }else{
-                	$getdata=$data;
-              		$getdata=json_decode($getdata,true);//转成数组
-                	$list['type']=2;
-
-                }
-             	$list=array();
-                $list['deviceId']=$getdata['deviceId'];
-                $list['commandId']=$getdata['commandId']; 
-                $list['resultCode']=$getdata['result']['resultCode']; 
-                $list['result']= json_encode($getdata['result'],320) ;
-                $list['addtime']= date('Y-m-d H:i:s');
- 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
-            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
-            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
-            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
-            $upData = json_decode($managelog['HexStr'],true);
-            if (!empty($deviceConfigure['device_code'])) {
-                sleep(1);
-                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
-            }else{
-                sleep(1);
-                $upData['device_code'] = $device['device_id'];
-                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-            }
-        }
- 		echo    111;
-
- 	}
-
- 	public function delete(){
- 			echo   111;
- 	}
-
-    public function manualPush(){
-        $data=input('');
-        if(is_array($data)){
-            $getdata= json_encode($data,320);
-            $getdata=json_decode($getdata,true);//转成数组
-            $list['type']=1;
-
-        }else{
-            $getdata=$data;
-            $getdata=json_decode($getdata,true);//转成数组
-            $list['type']=2;
-
-        }
-        if ($getdata['deviceType']==2){
-            $sql6="select * from sp_sj2017 where device_code ='{$getdata["deviceCode"]}'";
-            $longHuOwner = add($sql6);
-            Log::record('yangpuxiaoyuan12' . ':' . $longHuOwner[0]["id"]);
-            foreach ($longHuOwner as $row) {
-                $waterData["SubType"] = 2;
-                $waterData["DeviceId"] = $getdata["deviceCode"];
-                $waterData["InsertId"] = $row["id"];
-                $waterData["Confirmed"] = false;
-                $data6 = json_encode($waterData);
-                $rep_url = "http://47.98.201.187:55335/report";
-                $res = $this->ypxycurl($rep_url, $data6);
-                Log::record('yangpuxiaoyuan' . ':' . $res);
-                sleep(1);
-            }
-        }
-//        $list=array();
-//        $list['deviceId']=$getdata['deviceId'];
-//        $list['commandId']=$getdata['commandId'];
-//        $list['resultCode']=$getdata['result']['resultCode'];
-//        $list['result']= json_encode($getdata['result'],320) ;
-//        $list['addtime']= date('Y-m-d H:i:s');
-//        $res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
-//        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
-//            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
-//            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
-//            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
-//            $upData = json_decode($managelog['HexStr'],true);
-//            if (!empty($deviceConfigure['device_code'])) {
-//                sleep(1);
-//                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
-//            }else{
-//                sleep(1);
-//                $upData['device_code'] = $device['device_id'];
-//                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
-//            }
-//        }
-        echo    111;
-
-    }
-
-//    public function alarmHandling(){
-//        $data=input('');
-//        if(is_array($data)){
-//            $getDataJson= json_encode($data,320);
-//            $getdata=json_decode($getDataJson,true);//转成数组
-////            $list['type']=1;
-//
-//        }else{
-//            $getDataJson=$data;
-//            $getdata=json_decode($getDataJson,true);//转成数组
-////            $list['type']=2;
-//
-//        }
-//        Log::record('yangpuerqi' . ':' .$getDataJson);
-//        if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
-//            if ($getdata["userName"]=="ypsgec" && $getdata["userPassword"]=="ypsgec123"){
-//                if (empty($getdata['recordId'])){
-//                    $returnInformation['code'] = 60001;
-//                    $returnInformation['msg'] = "操作失败,缺少记录Id";
-//                    return json_encode($returnInformation);
-//                }elseif (empty($getdata['deviceCode'])){
-//                    $returnInformation['code'] = 60001;
-//                    $returnInformation['msg'] = "操作失败,缺少设备编号";
-//                    return json_encode($returnInformation);
-//                }elseif (empty($getdata['deviceType'])){
-//                    $returnInformation['code'] = 60001;
-//                    $returnInformation['msg'] = "操作失败,缺少设备类型";
-//                    return json_encode($returnInformation);
-//                }elseif (is_int($getdata['confirmAll'])==true&&$getdata['confirmAll']!=0&&$getdata['confirmAll']!=1){
-//                    $returnInformation['code'] = 60001;
-//                    $returnInformation['msg'] = "操作失败,缺少是否批量处理类型";
-//                    return json_encode($returnInformation);
-//                }elseif ($getdata['misinformation']!=0&&$getdata['misinformation']!=1){
-//                    $returnInformation['code'] = 60001;
-//                    $returnInformation['msg'] = "操作失败,缺少是否误报字段";
-//                    return json_encode($returnInformation);
-//                }elseif (empty($getdata['handlerName'])){
-//                    $returnInformation['code'] = 60001;
-//                    $returnInformation['msg'] = "操作失败,缺少处理人姓名";
-//                    return json_encode($returnInformation);
-//                }elseif (empty($getdata['handlerPhone'])){
-//                    $returnInformation['code'] = 60001;
-//                    $returnInformation['msg'] = "操作失败,缺少处理人联系方式";
-//                    return json_encode($returnInformation);
-//                }else{
-//                    $returnInformation['code'] = 0;
-//                    $returnInformation['msg'] = "操作成功";
-//                    return json_encode($returnInformation);
-//                }
-//
-//
-//
-//
-//
-//
-//
-//            }else{
-//                $returnInformation['code'] = 60002;
-//                $returnInformation['msg'] = "操作失败,用户名或密码错误";
-//                return json_encode($returnInformation);
-//            }
-//        }else{
-//            $returnInformation['code'] = 60002;
-//            $returnInformation['msg'] = "操作失败,用户名或密码为空";
-//            return json_encode($returnInformation);
-//        }
-//    }
-
-    public function deviceList(){
-        $data=input('');
-        if(is_array($data)){
-            $getDataJson= json_encode($data,320);
-            $getdata=json_decode($getDataJson,true);//转成数组
-        }else{
-            $getDataJson=$data;
-            $getdata=json_decode($getDataJson,true);//转成数组
-        }
-        $clientIp=$this->ip();
-        Log::record('yangpuerqi_deviceList' . ':' .'<<<'.$clientIp.'>>>'.$getDataJson);
-        $allowIp = ['222.69.153.207','120.253.238.34','114.86.176.11'];
-        if (!in_array($clientIp, $allowIp)){
-            $returnInformation['code'] = 60001;
-            $returnInformation['msg'] = "操作失败,IP地址不在白名单中";
-            $returnInformation['data']=null;
-            return json_encode($returnInformation);
-        }else{
-            if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
-                if ($getdata["userName"]=="sgec68" && $getdata["userPassword"]=="sgec68123"){
-                    if(!empty($getdata['commandType'])){
-                        if($getdata['commandType']=="FRONTPAGE"){
-                            $sql="select device_code as deviceCode,device_name as deviceName,CONVERT(type, UNSIGNED INTEGER) as deviceType,type_name as deviceTypeName,unitinfo as deviceAddress,CONVERT(louyu, UNSIGNED INTEGER) as deviceFloor,company_name as companyName,company_code as companyCode,contacts,contacts_phone as contactsPhone,address as detailedAddress,street,posistion,time as dataTime,'在线' as status from sp_v_yp_device where company_code='10246'";
-                            $res=add($sql);
-                            if (!empty($res)){
-                                $returnInformation['code'] = 0;
-                                $returnInformation['msg'] = "操作成功";
-                                $returnInformation['data']=$res;
-                                return json_encode($returnInformation);
-                            }else{
-                                $returnInformation['code'] = 60001;
-                                $returnInformation['msg'] = "操作失败";
-                                $returnInformation['data']=null;
-                                return json_encode($returnInformation);
-                            }
-                        }else{
-                            $returnInformation['code'] = 60001;
-                            $returnInformation['msg'] = "操作失败,参数错误";
-                            $returnInformation['data']=null;
-                            return json_encode($returnInformation);
-                        }
-                    }else{
-                        $returnInformation['code'] = 60001;
-                        $returnInformation['msg'] = "操作失败,参数为空";
-                        $returnInformation['data']=null;
-                        return json_encode($returnInformation);
-                    }
-                }else{
-                    $returnInformation['code'] = 60002;
-                    $returnInformation['msg'] = "操作失败,用户名或密码错误";
-                    $returnInformation['data']=null;
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60002;
-                $returnInformation['msg'] = "操作失败,用户名或密码为空";
-                $returnInformation['data']=null;
-                return json_encode($returnInformation);
-            }
-        }
-    }
-
-    public function alarmHandling(){
-        $data=input('');
-        if(is_array($data)){
-            $getDataJson= json_encode($data,320);
-            $getdata=json_decode($getDataJson,true);//转成数组
-//            $list['type']=1;
-
-        }else{
-            $getDataJson=$data;
-            $getdata=json_decode($getDataJson,true);//转成数组
-//            $list['type']=2;
-
-        }
-        Log::record('yangpuerqi_alarmHandling' . ':' .$getDataJson);
-        if ($getdata['confirmAll']==""){
-            $getdata['confirmAll']=0;
-        }
-
-        if ($getdata['misinformation']==""){
-            $getdata['misinformation']=0;
-        }
-
-
-        if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
-            if ($getdata["userName"]=="ypsgec" && $getdata["userPassword"]=="ypsgec123"){
-                if (empty($getdata['recordId'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少记录Id";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['deviceCode'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少设备编号";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['deviceType'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少设备类型";
-                    return json_encode($returnInformation);
-                }elseif ($getdata['confirmAll']!=0&&$getdata['confirmAll']!=1){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少是否批量处理类型";
-                    return json_encode($returnInformation);
-                }elseif ($getdata['misinformation']!=0&&$getdata['misinformation']!=1){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少是否误报字段";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['handlerName'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少处理人姓名";
-                    return json_encode($returnInformation);
-                }elseif (empty($getdata['handlerPhone'])){
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,缺少处理人联系方式";
-                    return json_encode($returnInformation);
-                }
-//                else{
-//                    $returnInformation['code'] = 0;
-//                    $returnInformation['msg'] = "操作成功";
-//                    return json_encode($returnInformation);
-//                }
-
-
-//                echo 'aaaaaaa';
-//                exit();
-                switch ($getdata['deviceType']) {
-                    case '1':
-                        $tab="sp_hj2017";
-                        break;
-                    case '2':
-                        $tab="sp_sj2017";
-                        break;
-                    case '6':
-                        $tab="sp_rtu2017";
-                        break;
-                    case '7':
-                        $tab="sp_ef2017";
-                        break;
-//                    case '16':
-//                        $tab="sp_video2017";
-//                        break;
-                    default:
-                        $returnInformation['code'] = 60001;
-                        $returnInformation['msg'] = "操作失败,缺少设备类型";
-                        return json_encode($returnInformation);
-                        break;
-                }
-
-                $time = date('Y-m-d h:i:s', time());
-
-                if ($getdata['confirmAll']==0){
-                    $where = " where id=".$getdata['recordId']." and device_code='".$getdata['deviceCode']."' and clzt='0'";
-                }else{
-                    $where = " where device_code='".$getdata['deviceCode']."' and clzt='0'";
-                }
-                $sql="UPDATE ".$tab." SET clsj='".$time."',clr='".$getdata['handlerName']."',clnr='".$getdata['processingContent']."',clwb='".$getdata['misinformation']."',cldh='".$getdata['handlerPhone']."',clzt=1 ".$where;
-//                echo $sql;
-//               print_r($sql);
-//               exit();
-                $res=addDataInfo($sql);
-                if ($res){
-                    $returnInformation['code'] = 0;
-                    $returnInformation['msg'] = "操作成功";
-                    return json_encode($returnInformation);
-                }else{
-                    $returnInformation['code'] = 60001;
-                    $returnInformation['msg'] = "操作失败,参数错误";
-                    return json_encode($returnInformation);
-                }
-            }else{
-                $returnInformation['code'] = 60002;
-                $returnInformation['msg'] = "操作失败,用户名或密码错误";
-                return json_encode($returnInformation);
-            }
-        }else{
-            $returnInformation['code'] = 60002;
-            $returnInformation['msg'] = "操作失败,用户名或密码为空";
-            return json_encode($returnInformation);
-        }
-    }
-
-
-    public function ip() {
-        //strcasecmp 比较两个字符,不区分大小写。返回0,>0,<0。
-        if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
-            $ip = getenv('HTTP_CLIENT_IP');
-        } else if (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
-            $ip = getenv('HTTP_X_FORWARDED_FOR');
-        } else if (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
-            $ip = getenv('REMOTE_ADDR');
-        } else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
-            $ip = $_SERVER['REMOTE_ADDR'];
-        }
-        $res =  preg_match ( '/[\d\.]{7,15}/', $ip, $matches ) ? $matches [0] : '';
-        return $res;
-        //dump(phpinfo());//所有PHP配置信息
-    }
-
-    public function s_curl($url,$data='',$header="",$method="POST"){
-        $ch = curl_init() ;
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
-
-        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
-        /*   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');*/
-        //  curl_setopt($ch, CURLOPT_VERBOSE, 1); //debugģʽ
-        curl_setopt($ch, CURLOPT_SSLCERT, "./server.crt"); //client.crt����
-        curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "IoM@1234"); //client֤������
-        curl_setopt($ch, CURLOPT_SSLKEY, "./server.key");
-        if($method=="POST"||$method=="PUT"||$method=="DELETE"){
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-        }
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-        $info = curl_exec($ch);
-        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-        if (curl_errno($ch)) {
-            $infores =  curl_error($ch);
-        }else{
-            $infores = $info;
-        }
-        curl_close($ch);
-        return $infores;
-    }
-
-    public function ypxycurl($url,$data=''){
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
-        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
-        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-        $info = curl_exec($ch);
-        if (curl_errno($ch)) {
-            $info = 'ERROR: ' . curl_error($ch);
-        }
-        curl_close($ch);
-        return $info;
-    }
-}

+ 1 - 0
application/.htaccess

@@ -0,0 +1 @@
+deny from all

+ 0 - 0
admin/common.php → application/admin/common.php


+ 0 - 0
admin/common.php.bak → application/admin/common.php.bak


+ 0 - 0
admin/common.php.bak.2020-12-11 → application/admin/common.php.bak.2020-12-11


+ 0 - 0
admin/common.php.bak.20201202 → application/admin/common.php.bak.20201202


+ 0 - 0
admin/common.php.bak.20201204 → application/admin/common.php.bak.20201204


+ 0 - 0
admin/common.php.bak.2021-04-29 → application/admin/common.php.bak.2021-04-29


+ 0 - 0
admin/common.php.bak.2021-12-29 → application/admin/common.php.bak.2021-12-29


+ 0 - 0
admin/common.php.bak.20210316 → application/admin/common.php.bak.20210316


+ 0 - 0
admin/common4.php.bak → application/admin/common4.php.bak


+ 0 - 0
admin/common5.php.bak → application/admin/common5.php.bak


+ 0 - 0
admin/common6.php.bak → application/admin/common6.php.bak


+ 0 - 0
admin/common7.php.bak → application/admin/common7.php.bak


+ 0 - 0
admin/controller/Batchhandle.php → application/admin/controller/Batchhandle.php


+ 0 - 0
admin/controller/Batchhandle.php.bak.2021-08-31 → application/admin/controller/Batchhandle.php.bak.2021-08-31


+ 504 - 0
application/admin/controller/Dataacceptance.php

@@ -0,0 +1,504 @@
+<?php
+
+namespace app\admin\controller;
+
+use think\Controller;
+use think\Session;
+use think\Db;
+use think\Request;
+use think\Log;
+
+class Dataacceptance extends Controller
+{
+    public function getData()
+    {
+        $Data = input('');
+        if (is_array($Data)) {
+            $getDataJson = json_encode($Data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $Data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
+        Log::record('yangpu4GRawData:' . $json_string);
+
+
+        $bin_data = $getdata['msg']['value']['bin_data'];
+        if (empty($bin_data)) {
+            $returnInformation['code'] = false;
+            $returnInformation['msg'] = "数据格式错误";
+            return json_encode($returnInformation);
+        }
+        Log::record('yangpu4GData' . ':' . $bin_data);
+        //数据类型
+        $type = substr($bin_data, 8, 2);
+        //数据长度
+        $length = substr($bin_data, 10, 4);
+        //设备类型
+        $device_type = substr($bin_data, 14, 2);
+        //设备编号截取拼接
+        $devide_id1 = ((int)substr($bin_data, 16, 2)) - 30;
+        $devide_id2 = ((int)substr($bin_data, 18, 2)) - 30;
+        $devide_id3 = ((int)substr($bin_data, 20, 2)) - 30;
+        $devide_id4 = ((int)substr($bin_data, 22, 2)) - 30;
+        $devide_id5 = ((int)substr($bin_data, 24, 2)) - 30;
+        $devide_id6 = ((int)substr($bin_data, 26, 2)) - 30;
+        $devide_id7 = ((int)substr($bin_data, 28, 2)) - 30;
+        $devide_id8 = ((int)substr($bin_data, 30, 2)) - 30;
+        $devide_id9 = ((int)substr($bin_data, 32, 2)) - 30;
+        $devide_id10 = ((int)substr($bin_data, 34, 2)) - 30;
+        $devide_id11 = ((int)substr($bin_data, 36, 2)) - 30;
+        $devide_id12 = ((int)substr($bin_data, 38, 2)) - 30;
+        $devide_id13 = ((int)substr($bin_data, 40, 2)) - 30;
+        $devide_id14 = ((int)substr($bin_data, 42, 2)) - 30;
+        $devide_id15 = ((int)substr($bin_data, 44, 2)) - 30;
+        $device_code = $devide_id1 . $devide_id2 . $devide_id3 . $devide_id4 . $devide_id5 . $devide_id6 . $devide_id7 . $devide_id8 . $devide_id9 . $devide_id10 . $devide_id11 . $devide_id12 . $devide_id13 . $devide_id14 . $devide_id15;
+        //发送时间截取拼接
+        $send_time1 = substr($bin_data, 48, 2);
+        $send_time2 = substr($bin_data, 50, 2);
+        $send_time3 = substr($bin_data, 52, 2);
+        $send_time4 = substr($bin_data, 54, 2);
+        $send_time5 = substr($bin_data, 56, 2);
+        $send_time6 = substr($bin_data, 58, 2);
+        $time = '20' . $send_time1 . '-' . $send_time2 . '-' . $send_time3 . ' ' . $send_time4 . ':' . $send_time5 . ':' . $send_time6;
+
+//        print_r($time);
+
+        //电池电量
+        $battery_level = hexdec(substr($bin_data, 60, 2));
+        //信号强度
+        $signal_strength = substr($bin_data, 62, 2);
+        if ((int)$signal_strength <= 6 && (int)$signal_strength != 0) {
+            $signal_level = 1;
+        } else if ((int)$signal_strength <= 12) {
+            $signal_level = 2;
+        } else if ((int)$signal_strength <= 18) {
+            $signal_level = 3;
+        } else if ((int)$signal_strength <= 24) {
+            $signal_level = 4;
+        } else if ((int)$signal_strength <= 31) {
+            $signal_level = 5;
+        } else {
+            $signal_level = 0;
+        }
+
+        //设备采集数据解析
+        $device_type_10 = hexdec($device_type);
+        if ($device_type_10 != 1 && $device_type_10 != 2 && $device_type_10 != 3 && $device_type_10 != 4) {//&& $device_type_10 != 7 && $device_type_10 != 8 && $device_type_10 != 9
+            $returnInformation['code'] = false;
+            $returnInformation['msg'] = "该类型未定义";
+            return json_encode($returnInformation);
+        }
+        $sample_data = substr($bin_data, 64, 8);
+        $sample_data_unit1 = substr($bin_data, 64, 2);
+        $sample_data_unit2 = substr($bin_data, 66, 2);
+        $sample_data_unit3 = substr($bin_data, 68, 2);
+        $sample_data_unit4 = substr($bin_data, 70, 2);
+
+        $sample_data_unit1_high = substr($sample_data_unit1, 0, 1);
+        $sample_data_unit1_low = substr($sample_data_unit1, 1, 1);
+
+        $sample_data_unit2_high = substr($sample_data_unit2, 0, 1);
+        $sample_data_unit2_low = substr($sample_data_unit2, 1, 1);
+
+        $sample_data_unit3_high = substr($sample_data_unit3, 0, 1);
+        $sample_data_unit3_low = substr($sample_data_unit3, 1, 1);
+
+        $sample_data_unit4_high = substr($sample_data_unit4, 0, 1);
+        $sample_data_unit4_low = substr($sample_data_unit4, 1, 1);
+
+        $value = $sample_data_unit2_low . $sample_data_unit3_high . $sample_data_unit3_low . $sample_data_unit4_high . $sample_data_unit4_low;
+        switch ($sample_data_unit2_high) {
+            case '1':
+                $alarm_value = (int)$value * 0.1;
+                break;
+            case '2':
+                $alarm_value = (int)$value * 0.01;
+                break;
+            case '3':
+                $alarm_value = (int)$value * 0.001;
+                break;
+            case '4':
+                $alarm_value = (int)$value * 0.0001;
+                break;
+        }
+
+
+        if ($sample_data_unit1_low == 1) {
+            $alarm_type = 'WP' . $sample_data_unit1_high;
+            $alarm_value = $alarm_value;
+        } else if ($sample_data_unit1_low == 2) {
+            $alarm_type = 'WP' . $sample_data_unit1_high;
+            $alarm_value = $alarm_value * 0.1;
+
+        } else if ($sample_data_unit1_low == 3) {
+            $alarm_type = 'WP' . $sample_data_unit1_high;
+            $alarm_value = $alarm_value * 1000;
+
+        } else if ($sample_data_unit1_low == 4) {
+            $alarm_type = 'LL' . $sample_data_unit1_high;
+            $alarm_value = $alarm_value;
+        } else {
+            $returnInformation['code'] = false;
+            $returnInformation['msg'] = "单位未定义";
+            return json_encode($returnInformation);
+        }
+
+
+        switch ($alarm_type) {
+            case 'LL0':
+            case 'WP0':
+                $alarm_data = '正常';
+                break;
+            case 'WP1':
+                $alarm_data = '低压';
+                break;
+            case 'WP2':
+                $alarm_data = '高压';
+                break;
+            case 'LL3':
+            case 'WP3':
+                $alarm_data = '故障';
+                break;
+            case 'LL4':
+            case 'WP4':
+                $alarm_data = '波动告警';
+                break;
+            case 'LL5':
+            case 'WP5':
+                $alarm_data = '碰撞告警';
+                break;
+            case 'LL6':
+            case 'WP6':
+                $alarm_data = '倾斜告警';
+                break;
+            case 'LL7':
+            case 'WP7':
+                $alarm_data = '水流告警';
+                break;
+            case 'LL8':
+            case 'WP8':
+                $alarm_data = '进水告警';
+                break;
+            case 'LL9':
+            case 'WP9':
+                $alarm_data = '低电量告警';
+                break;
+            case 'LL1':
+                $alarm_data = '低水位';
+                break;
+            case 'LL2':
+                $alarm_data = '高水位';
+                break;
+            default:
+                $returnInformation['code'] = false;
+                $returnInformation['msg'] = "未知告警";
+                return json_encode($returnInformation);
+                break;
+        }
+
+        $res_owner = add("select owner_code,dwtype,company,owner_name from sp_owner where owner_code='" . $device_code . "'");
+        if (empty($res_owner)) {
+            $returnInformation['code'] = false;
+            $returnInformation['msg'] = "该设备未注册";
+            return json_encode($returnInformation);
+        }
+
+        ////闵行MQTT
+        $where_one['device_code'] = $device_code;
+        $where_one['push_status'] = 0;
+        $device = Db::name('yt_t_mhwater')->where($where_one)->find();
+        if (!empty($device)) {
+            $json_data_one = $this->mh_array_turn_json(1, $device, $signal_level * 20, $battery_level, strtotime($time), '', $alarm_type);
+            if (!empty($json_data_one)) {
+                $this->message_push_mh("mh/water/info", $json_data_one, 0);
+            }
+        }
+
+        $sql = "INSERT INTO sp_d" . $device_code . " (id,device_code,port,time,status,address,ncmd,data1,data2,data3,data4,data5) VALUES ('','" . $device_code . "','4G','" . $time . "','','','','" . $alarm_type . "','" . $battery_level . "','" . $signal_level . "','" . $alarm_value . "','PHP')";
+        Log::record('yangpu4GRawSql:' . $sql);
+        $R = addDataInfo($sql);
+
+        $json_data_qone = $this->mqqt_data_recombination("INFO", $device_code, $res_owner[0]['owner_name'], $battery_level, $signal_level, $alarm_value,$res_owner[0]['dwtype']);
+        if (!empty($json_data_qone)){
+            $topicYp_one = '/usky/ytDP0002/'.$res_owner[0]['company'].'/'.$device_code.'/info';
+            $this->message_push_mh($topicYp_one, $json_data_qone, 0);
+        }
+
+
+
+        //addDataInfoInsert
+        if ($alarm_data == '低压' || $alarm_data == '高压' | $alarm_data == '低水位' | $alarm_data == '高水位' | $alarm_data == '故障' | $alarm_data == '波动告警') {
+            $sql1 = "INSERT INTO sp_sj2017 (id,port,device_code,time,status,address,ncmd,data1,data2,data3,data4,data5,cllxr,clsj,clr,clnr,clwb,cldh,clzt,cllx,video) 
+                    VALUES ('','tp_water_pressure','" . $device_code . "','" . $time . "','','拓普索尔4G','','" . $alarm_type . "','" . $battery_level . "','" . $signal_level . "','" . $alarm_value . "','拓普索尔','','0','','','','','0','','')";
+            Log::record('yangpu4GAlarmSql:' . $sql1);
+            $Res = addDataInfoInsert($sql1);
+            $json_data_qtwo = $this->mqqt_data_recombination("ALARM", $device_code, $res_owner[0]['owner_name'], $battery_level, $signal_level, $alarm_value,$res_owner[0]['dwtype']);
+            if (!empty($json_data_qtwo)){
+                $topicYp_two = '/usky/ytDP0002/'.$res_owner[0]['company'].'/'.$device_code.'/alarm';
+                $this->message_push_mh($topicYp_two, $json_data_qtwo, 0);
+            }
+
+            //闵行MQTT
+//            if ($alarm_type=='WP1'||$alarm_type=='WP2'||$alarm_type=='LL9'||$alarm_type=='WP9'){
+//                if (!empty($device)){
+//                    $json_data_two=$this->mh_array_turn_json(2,$device,$signal_level*20,$battery_level,strtotime($time),'',$alarm_type);
+//                    if (!empty($json_data_two)){
+//                        $this->message_push_mh("mh/water/alert",$json_data_two,0);
+//                    }
+//                    $json_data_three=$this->date_array_turn_json($Res,$device,strtotime($time),$alarm_data,0,'','');
+//                    if (!empty($json_data_three)){
+//                        $this->message_push_mh("mh/water/statistics",$json_data_three,0);
+//
+//                    }
+//                    $json_data_four=$this->date_array_turn_json($Res,$device,strtotime($time),$alarm_data,1,'','');
+//                    if (!empty($json_data_four)){
+//                        $this->message_push_mh("mh/water/statistics",$json_data_four,0);
+//                    }
+//                }
+//            }
+
+
+//            print_r('id'.$Res);
+            $phone_data = add("select phone from sp_owner_phone where owner_code='" . $res_owner[0]['company'] . "' group by phone");
+            $openids = $this->array_column1($phone_data, "phone");
+
+
+            $wx_data['IMEI'] = $device_code;
+            $wx_data['phone'] = $openids;
+            $wx_data['evt'] = $alarm_type;
+            $wx_data['time'] = $time;
+            $wx_data['insert_id'] = $Res;
+            $wx_data['bz'] = '';
+            $wx_data['user_from'] = 'water_form';
+            $wx_data['Status'] = $alarm_type;
+
+            if ($res_owner[0]['dwtype'] == 2) {
+                $url = "https://iot.usky.cn/jdxf/wxapp2.php/Home/Waterwarn/message_water";
+            } else {
+                $url = "https://iot.usky.cn/jdxf/wxapp2.php/Home/Yeweiwarn/message_water";
+            }
+
+            Log::record('yangpu4GWxUrl' . ':' . $url);
+            Log::record('yangpu4GWxData' . ':' . json_encode($wx_data, JSON_FORCE_OBJECT));
+            $res = $this->curl($url, $wx_data);
+            print_r($res);
+
+        }
+
+        $returnInformation['code'] = true;
+        $returnInformation['msg'] = "成功";
+        return json_encode($returnInformation);
+    }
+
+    public function array_column1($rows, $column_key, $index_key = null)
+    {
+        $data = array();
+        if (empty($index_key)) {
+            foreach ($rows as $row) {
+                $data[] = $row[$column_key];
+            }
+            $data = implode(",", $data);
+        } else {
+            foreach ($rows as $row) {
+                $data[$row[$index_key]] = $row[$column_key];
+            }
+        }
+        return $data;
+    }
+
+    public function curl($url, $data = '')
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $info = curl_exec($ch);
+        if (curl_errno($ch)) {
+            $info = 'ERROR: ' . curl_error($ch);
+        }
+        curl_close($ch);
+        return $info;
+    }
+
+    /**
+     * @param $type 1心跳 2报警
+     * @param $DeviceCode 设备编号
+     * @param $signalLevel 信号
+     * @param $volt 电量
+     * @param $createdTime 时间 时间戳
+     * @param $param 暂留
+     * @param $alarm_type 告警编码
+     * @return false|string|null
+     */
+    public function mh_array_turn_json($type, $device, $signalLevel, $volt, $createdTime, $param, $alarm_type)
+    {
+//        $param = [];
+        $param = ["platform_cy" => $device['platform_cy'], "scenetype_cy" => $device['scenetype_cy']];
+        if ($type == 1) {
+            if (!empty($device)) {
+                $arr = [
+                    "deviceCode" => $device['mh_device_code'],
+                    "signalLevel" => $signalLevel,
+                    "volt" => $volt,
+                    "lon" => (double)$device['longitude'],
+                    "lat" => (double)$device['latitude'],
+                    "createdTime" => $createdTime,
+                    "param" => $param
+                ];
+                $json_data = json_encode($arr);
+
+            } else {
+                $json_data = null;
+            }
+        } else {
+            if (!empty($device)) {
+                $eventCode1 = "02";
+                $eventName1 = "预警事件";
+                switch ($alarm_type) {
+                    case 'WP1':
+                    case 'WP2':
+                        $eventCode2 = '02008';
+                        $eventName2 = '水压报警';
+                        break;
+                    case 'LL9':
+                    case 'WP9':
+                        $eventCode2 = '02002';
+                        $eventName2 = '电量不足';
+                        break;
+                    default:
+                        $eventCode2 = '02000';
+                        $eventName2 = '其他';
+                        break;
+                }
+                $arr = [
+                    "deviceCode" => $device['mh_device_code'],
+                    "lon" => (double)$device['longitude'],
+                    "lat" => (double)$device['latitude'],
+                    "createdTime" => $createdTime,
+                    "addr" => "上海市",
+                    "eventCode1" => $eventCode1,
+                    "eventName1" => $eventName1,
+                    "eventCode2" => $eventCode2,
+                    "eventName2" => $eventName2,
+                    "description" => "备注信息",
+                    "param" => $param
+                ];
+                $json_data = json_encode($arr);
+            } else {
+                $json_data = null;
+            }
+        }
+        return $json_data;
+    }
+
+
+    public function date_array_turn_json($insert_id, $device, $createdTime, $ajDescribe, $ajFlag, $enclosure, $image)
+    {
+        if (!empty($device)) {
+            $arr = [
+                "id" => $insert_id,
+                "deviceCode" => $device['mh_device_code'],
+                "createTime" => date("Y-m-d H:i:s", $createdTime),
+                "ajType" => $device['aj_type'],
+                "street" => $device['street'],
+                "address" => $device['company_address'] . ',' . $device['device_address'],
+                "grid" => $device['grid'],
+                "ajDescribe" => $ajDescribe,
+                "dutyGroup" => $device['company_name'],
+                "ajFlag" => $ajFlag,
+                "endTime" => date("Y-m-d H:i:s", $createdTime + 86400),
+                "enclosure" => $enclosure,
+                "image" => $image
+            ];
+            $json_data = json_encode($arr);
+        } else {
+            $json_data = null;
+        }
+        return $json_data;
+    }
+
+    public function message_push_mh($topic, $msg, $qos)
+    {
+        vendor('phpMQTT.phpMQTT');
+        $server = '47.98.201.73';     // 服务器IP
+        $port = 1883;            // 服务器端口
+        $username = 'usky';              // 用户名
+        $password = 'usky';              // 密码
+        $client_id = 'pub_' . uniqid();
+        $mqtt = new \phpMQTT($server, $port, $client_id);
+        if ($mqtt->connect(true, NULL, $username, $password)) {
+            $mqtt->publish($topic, $msg, $qos);
+            usleep(100000);
+            $mqtt->close();
+            Log::record('MH—4G-MQTT-Push success!(' . $topic . ')[' . date('Y-m-d H:i:s') . ']:' . json_encode($msg));
+        } else {
+            Log::record('MH—4G-MQTT-Time out!(' . $topic . ')[' . date('Y-m-d H:i:s') . ']:' . json_encode($msg));
+        }
+    }
+
+
+    public function mqqt_data_recombination($type, $device_code, $device_name, $electric_quantity, $signal, $water_gage,$dwtype)
+    {
+        if ($type == 'INFO') {
+            $status_valie = "0";
+        } else {
+            $status_valie = "1";
+        }
+
+        if ($dwtype==2){
+            $property = "水压";
+        }else{
+            $property = "水位";
+        }
+
+        $array = [
+            "devId" => $device_code,
+            "connType" => "G",
+            "deviceName" => $device_name,
+            "devs" => [
+                [
+                    "dp" => [
+                        [
+                            "property" => "电量",
+                            "serial" => "201",
+                            "value" => '' . $electric_quantity
+                        ],
+                        [
+                            "property" => "信号",
+                            "serial" => "202",
+                            "value" => '' . $signal
+                        ],
+                        [
+                            "property" => $property,
+                            "serial" => "203",
+                            "value" => '' . $water_gage
+                        ],
+                        [
+                            "property" => "状态",
+                            "serial" => "204",
+                            "value" => $status_valie
+                        ]
+                    ],
+                    "deviceName" => $device_name,
+                    "timeStamp" => "".time(),
+                    "deviceModel" => "",
+                    "deviceType" => "".$dwtype,
+                    "devId" => $device_code
+                ]
+            ],
+            "type" => $type,
+            "timeStamp" => "".time()
+        ];
+
+        $json_data = json_encode($array);
+        return $json_data;
+    }
+}

+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-04-29 → application/admin/controller/Dataacceptance.php.bak.2021-04-29


+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-06-02 → application/admin/controller/Dataacceptance.php.bak.2021-06-02


+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-11-04 → application/admin/controller/Dataacceptance.php.bak.2021-11-04


+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-11-05 → application/admin/controller/Dataacceptance.php.bak.2021-11-05


+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-11-05-1 → application/admin/controller/Dataacceptance.php.bak.2021-11-05-1


+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-11-11 → application/admin/controller/Dataacceptance.php.bak.2021-11-11


+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-11-30 → application/admin/controller/Dataacceptance.php.bak.2021-11-30


+ 0 - 0
admin/controller/Dataacceptance.php.bak.2021-12-01 → application/admin/controller/Dataacceptance.php.bak.2021-12-01


+ 0 - 0
admin/controller/Dataacceptance.php → application/admin/controller/Dataacceptance.php.bak.2022-07-07


+ 0 - 0
admin/controller/Device.php → application/admin/controller/Device.php


+ 0 - 0
admin/controller/Device.php.bak → application/admin/controller/Device.php.bak


+ 0 - 0
admin/controller/Device.php.bak.2020-12-14 → application/admin/controller/Device.php.bak.2020-12-14


+ 0 - 0
admin/controller/Device.php.bak.2021-12-29 → application/admin/controller/Device.php.bak.2021-12-29


+ 0 - 0
admin/controller/Device5.php.bak → application/admin/controller/Device5.php.bak


+ 0 - 0
admin/controller/Device6.php.bak → application/admin/controller/Device6.php.bak


+ 0 - 0
admin/controller/Device7.php.bak → application/admin/controller/Device7.php.bak


+ 0 - 0
admin/controller/Index.php → application/admin/controller/Index.php


+ 0 - 0
admin/controller/Log.php → application/admin/controller/Log.php


+ 0 - 0
admin/controller/Login.php → application/admin/controller/Login.php


+ 2200 - 0
application/admin/controller/Manage.php

@@ -0,0 +1,2200 @@
+<?php
+namespace app\admin\controller;
+use think\Controller;
+use think\Session;
+use think\Db;
+use think\Request;
+use think\Log;
+class Manage extends Controller
+{  
+ 	private $host="https://device.api.ct10649.com:8743/";
+    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
+    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
+
+ 	public function index(){
+ 		$data_list =Db::table('managelog')->paginate();
+        $pages = $data_list->render();        
+        $this->assign('data_list', $data_list);
+        $this->assign('pages', $pages); 
+
+
+        	//所有的服务类型
+        $SetType=[
+        	1=>"读取模块信息",
+        	2=>"读取参数",
+        	3=>"设置IOT平台IP地址",
+        	4=>"设置参数",
+        	5=>"复位模块",
+        	6=>"配置下行波特率",
+        	7=>"读取下行波特率配置",
+        	8=>"设置DTU自动采集指令",
+        	9=>"读取DTU自动采集指令",
+        	10=>"设置APN",
+        	11=>"读取APN设置",
+        	12=>"AT指令",
+
+   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
+        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
+        		[12,"AT指令"]*/
+        ];
+
+        $this->assign('SetType',$SetType);
+        
+        return $this->fetch();
+
+
+ 	}
+ 	//下发命令
+ 	public function add(){
+
+ 		if ($this->request->isPost()) {
+            $data=input('');
+            $list = array();
+            if (is_array($data)) {
+                $list['data'] = json_encode($data, 320);
+                $getdata = json_decode($list['data'], true);//转成数组
+                $list['type'] = 1;
+            } else {
+                $list['data'] = $data;
+                $getdata = json_decode($list['data'], true);//转成数组
+                $list['type'] = 2;
+            }
+            $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
+            Log::record('rawData:' .$list['data'] );
+            $paras = array();
+            $upData = array();
+            if(!empty($getdata["dataType"])){
+                if($getdata['dataType']=="setting"){
+                    $sql6="select * from sp_owner where id ={$getdata['sensorId']}";
+                    $longHuOwner = add($sql6);
+                    if ($longHuOwner[0]['s_interval']==7){
+                        $imei='&imei='.$longHuOwner[0]['owner_code'];
+                        if($longHuOwner[0]['dwtype']==2){
+                            $deviceType=1;
+                        }elseif ($longHuOwner[0]['dwtype']==5){
+                            $deviceType=2;
+                        }
+                        $sendata['imei']=$longHuOwner[0]['owner_code'];
+                        $sendata['deviceType']=$deviceType;
+                        $sendingGap = '';
+                        if (!empty($getdata["sendTime"])){
+                            if($getdata['sendTime']<1800) {
+                                $sendingGap = '&sendingGap=1800';
+                                $upData['send_time'] = 1800;
+                                $sendata['sendingGap']=1800;
+                            }else{
+                                $sendingGap = '&sendingGap='.$getdata["sendTime"];
+                                $upData['send_time'] = $getdata["sendTime"];
+                                $sendata['sendingGap']=$getdata["sendTime"];
+                            }
+                        }
+                        $unipathThresholdLimit = '';
+                        if (!empty($getdata["lowThreshold"])){
+                            $sendata['unipathThresholdLimit'] = $getdata["lowThreshold"]*1000;
+                            $upData['low_threshold'] = $getdata['lowThreshold'];
+                        }
+                        $unipathThresholdUpper = '';
+                        if (!empty($getdata["highThreshold"])){
+                            $sendata['unipathThresholdUpper'] = $getdata["highThreshold"]*1000;
+                            $upData['high_threshold'] = $getdata['highThreshold'];
+                        }
+
+                        $header=[
+                            "Content-Type:application/json"
+                        ];
+                        $rescurl=$this->s_curl("https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052",json_encode($sendata),$header);
+//                        $rep_url = "https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052".$imei.$deviceType.$sendingGap.$unipathThresholdLimit.$unipathThresholdUpper;
+//                        $res = $this->s_curl($rep_url,'');
+                        Log::record('longhulorasend' . ':' . json_encode($sendata));
+                        Log::record('longhuloraresult' . ':' . $rescurl);
+//                        if (is_array($rescurl)) {
+//
+//                        }else{}
+                        $resArr = json_decode($rescurl,true);
+                        if ($resArr['code']==0){
+                            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->find();
+                            if (!empty($deviceConfigure['device_code'])) {
+                                sleep(1);
+                                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->update($upData);
+                            }else{
+                                sleep(1);
+                                $upData['device_code'] = $longHuOwner[0]['owner_code'];
+                                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
+                            }
+                        }
+                        return $rescurl;
+                    }else{
+                        $deviceCode = '';
+                        $deviceArr = str_split($longHuOwner[0]['owner_code'],1);
+                        for ($i=0;$i<count($deviceArr);$i++){
+                            $deviceCode.='3'.$deviceArr[$i];
+                        }
+                        $deviceCode = $deviceCode.'30';
+                        $sendingInterval = "";//发送间隔
+                        if (!empty($getdata['sendTime'])) {
+                            if($getdata['sendTime']<1800){
+                                $sendingInterval = "020400000708";
+                                $upData['send_time'] = 1800;
+                            }else{
+                                $liuSendTime1 = dechex($getdata['sendTime']);
+                                $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
+                                $sendingInterval = "0204".$liuSendTime;
+                                $upData['send_time'] = $getdata['sendTime'];
+                            }
+                        }
+                        $lowThreshold = "";//告警下限
+                        if (!empty($getdata['lowThreshold'])) {
+                            $shiLowThreshold = $getdata['lowThreshold']*1000;
+                            $liuLowThreshold1 = dechex($shiLowThreshold);
+                            $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
+                            $lowThreshold = "0602".$liuLowThreshold;
+                            $upData['low_threshold'] = $getdata['lowThreshold'];
+                        }
+                        $highThreshold = "";//告警上限
+                        if (!empty($getdata['highThreshold'])) {
+                            $shiHighThreshold = $getdata['highThreshold']*1000;
+                            $liuHighThreshold1 = dechex($shiHighThreshold);
+                            $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
+                            $highThreshold = "0702".$liuHighThreshold;
+                            $upData['high_threshold'] = $getdata['highThreshold'];
+                        }
+                        if($longHuOwner[0]['dwtype']==2){
+                            $dwType = "01";
+                        }elseif ($longHuOwner[0]['dwtype']==5){
+                            $dwType = "02";
+                        }
+                        $shiLength = strlen($dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold)/2;
+                        $liuLength = dechex($shiLength);
+                        $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
+                        //调用电信接口
+                        $token=json_decode(gettoken(),true);
+                        $a = "7470736c04".$length.$dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold;
+                        $s = pack('H*',$a);
+                        $t = crc166($s);
+                        $t = unpack("H*", $s.$t);
+                        $paras['value'] = $t[1]."696f74";
+                        //            $t = crc16($paras['value'],0X1021,0Xffff,0X0000,false,false);
+                        $device = Db::name('device')->where('device_id', trim($longHuOwner[0]['owner_code']))->find();
+                        $sendata=[
+                            "appId"=>$this->appId,
+                            "deviceId"=>$device['iot_id'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
+                            "command"=>[
+                                "serviceId"=>"topsailSensorData",
+                                "method"=>"SET_DEVICE_LEVEL",
+                                "paras"=>$paras
+                            ],
+                            "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
+                        ];
+                        $header=[
+                            "Content-Type:application/json",
+                            "app_key:".$this->appId,
+                            "Authorization:Bearer ".$token["accessToken"]
+                        ];
+                        $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
+//                var_dump($rescurl);
+                        Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
+                        if($rescurl[0]==201){//成功
+                            $res1=json_decode($rescurl[1],true);
+//                    var_dump($res1);
+                        }else{//失败
+                            //  $res2=json_decode($res1[1],true);
+//                    return $this->error($rescurl[1]);
+                            Log::record('nbmanageerror:' .json_encode($this->error($rescurl[1])));
+                            $returnInformation['code'] = 60001;
+                            $returnInformation['msg'] = "操作失败,请联系管理员";
+                            return json_encode($returnInformation);
+                        }
+                    }
+                }else if($getdata['dataType']=="bendi"){
+                    $deviceCode = '';
+                    $deviceArr = str_split($getdata['IMEI'],1);
+                    for ($i=0;$i<count($deviceArr);$i++){
+                        $deviceCode.='3'.$deviceArr[$i];
+                    }
+                    $deviceCode = $deviceCode.'30';
+                    //调用电信接口
+                    $collectionInterval = "";//发送间隔
+                    if (!empty($getdata['collectionTime'])) {
+                        $liuCollectionTime1 = dechex($getdata['collectionTime']);
+                        $liuCollectionTime = str_pad($liuCollectionTime1,8,0,STR_PAD_LEFT);
+                        $collectionInterval = "0104".$liuCollectionTime;
+                    }
+                    $sendingInterval = "";//发送间隔
+                    if (!empty($getdata['sendTime'])) {
+                        $liuSendTime1 = dechex($getdata['sendTime']);
+                        $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
+                        $sendingInterval = "0204".$liuSendTime;
+                    }
+                    $lowThreshold = "";//告警下限
+                    if (!empty($getdata['alarmLowerLimit'])) {
+                        $shiLowThreshold = $getdata['alarmLowerLimit']*1000;
+                        $liuLowThreshold1 = dechex($shiLowThreshold);
+                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
+                        $lowThreshold = "0602".$liuLowThreshold;
+                    }
+                    $highThreshold = "";//告警上限
+                    if (!empty($getdata['alarmUpperLimit'])) {
+                        $shiHighThreshold = $getdata['alarmUpperLimit']*1000;
+                        $liuHighThreshold1 = dechex($shiHighThreshold);
+                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
+                        $highThreshold = "0702".$liuHighThreshold;
+                    }
+                    if($getdata['deviceType']==2){
+                        $dwType = "01";
+                    }elseif ($getdata['deviceType']==5){
+                        $dwType = "02";
+                    }
+                    $shiLength = strlen($dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold)/2;
+                    $liuLength = dechex($shiLength);
+                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
+                    //调用电信接口
+                    $token=json_decode(gettoken(),true);
+                    $a = "7470736c04".$length.$dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold;
+                    $s = pack('H*',$a);
+                    $t = crc166($s);
+                    $t = unpack("H*", $s.$t);
+                    $paras['value'] = $t[1]."696f74";
+                    $sendata=[
+                        "appId"=>$this->appId,
+                        "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
+                        "command"=>[
+                            "serviceId"=>"topsailSensorData",
+                            "method"=>"SET_DEVICE_LEVEL",
+                            "paras"=>$paras
+                        ],
+                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
+                    ];
+                    $header=[
+                        "Content-Type:application/json",
+                        "app_key:".$this->appId,
+                        "Authorization:Bearer ".$token["accessToken"]
+                    ];
+                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
+                    var_dump($rescurl);
+                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
+                    if($rescurl[0]==201){//成功
+                        $res1=json_decode($rescurl[1],true);
+//                    var_dump($res1);
+                    }else{//失败
+                        //  $res2=json_decode($res1[1],true);
+                        return $this->error($rescurl[1]);
+                    }
+                }else{
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,请联系管理员";
+                    return json_encode($returnInformation);
+                }
+            }else{
+                $returnInformation['code'] = 60001;
+                $returnInformation['msg'] = "操作失败,请联系管理员";
+                return json_encode($returnInformation);
+            }
+          //将请求的结果存入managelog中
+
+            $list=array();
+            $list['commandId']=$res1['commandId'];
+            $list['deviceId']=$res1['deviceId'];
+            $list['status']=$res1['status'];
+            $list['command']= json_encode($res1['command'],320) ;
+            if($getdata['dataType']=="setting"){
+                $list['IMEI']=$longHuOwner[0]['owner_code'];
+            }else{
+                $list['IMEI']=$getdata['IMEI'];
+            }
+            $list['HexStr']=json_encode($upData,320) ;;
+            $list['settype']="";
+            $list['addtime']= date('Y-m-d H:i:s');
+            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
+            if($res) {
+                $returnInformation['code'] = 200;
+                $returnInformation['msg'] = "操作成功";
+                if($getdata['dataType']=="setting"){
+                    return json_encode($returnInformation);
+                }else{
+                    return $this->success('添加成功','index');
+                }
+            }else{
+                $returnInformation['code'] = 60001;
+                $returnInformation['msg'] = "操作失败,请联系管理员";
+                if($getdata['dataType']=="setting"){
+                    return json_encode($returnInformation);
+                }else{
+                    return $this->error("添加失败,请稍后再试");
+                }
+            }
+         }
+
+        if($this->request->isGet()){
+        	$deviceId=input('deviceId');
+        	$IMEI=input('IMEI');
+
+
+        	//所有的服务类型
+        	$SetType=[
+        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
+        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
+        		[12,"AT指令"]
+        	];
+
+        	$this->assign('SetType',$SetType);
+        	$this->assign('deviceId',$deviceId);
+       		$this->assign('IMEI', $IMEI); 
+        	return $this->fetch();
+        }
+ 	}
+
+  	public function status(){
+ 		$data=input('');
+
+ 		
+        	if(is_array($data)){
+                	$getdata= json_encode($data,320);
+                	$getdata=json_decode($getdata,true);//转成数组
+                	$list['type']=1;
+         
+                }else{
+                	$getdata=$data;
+              		$getdata=json_decode($getdata,true);//转成数组
+                	$list['type']=2;
+
+                }
+             	$list=array();
+                $list['deviceId']=$getdata['deviceId'];
+                $list['commandId']=$getdata['commandId']; 
+                $list['resultCode']=$getdata['result']['resultCode']; 
+                $list['result']= json_encode($getdata['result'],320) ;
+                $list['addtime']= date('Y-m-d H:i:s');
+ 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
+        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
+            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
+            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
+            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
+            $upData = json_decode($managelog['HexStr'],true);
+            if (!empty($deviceConfigure['device_code'])) {
+                sleep(1);
+                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
+            }else{
+                sleep(1);
+                $upData['device_code'] = $device['device_id'];
+                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
+            }
+        }
+ 		echo    111;
+
+ 	}
+
+ 	public function delete(){
+ 			echo   111;
+ 	}
+
+    public function manualPush(){
+        $data=input('');
+        if(is_array($data)){
+            $getdata= json_encode($data,320);
+            $getdata=json_decode($getdata,true);//转成数组
+            $list['type']=1;
+
+        }else{
+            $getdata=$data;
+            $getdata=json_decode($getdata,true);//转成数组
+            $list['type']=2;
+
+        }
+        if ($getdata['deviceType']==2){
+            $sql6="select * from sp_sj2017 where device_code ='{$getdata["deviceCode"]}'";
+            $longHuOwner = add($sql6);
+            Log::record('yangpuxiaoyuan12' . ':' . $longHuOwner[0]["id"]);
+            foreach ($longHuOwner as $row) {
+                $waterData["SubType"] = 2;
+                $waterData["DeviceId"] = $getdata["deviceCode"];
+                $waterData["InsertId"] = $row["id"];
+                $waterData["Confirmed"] = false;
+                $data6 = json_encode($waterData);
+                $rep_url = "http://47.98.201.187:55335/report";
+                $res = $this->ypxycurl($rep_url, $data6);
+                Log::record('yangpuxiaoyuan' . ':' . $res);
+                sleep(1);
+            }
+        }
+        echo    111;
+
+    }
+
+    public function deviceList(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $clientIp=$this->ip();
+        Log::record('yangpuerqi_deviceList' . ':' .'<<<'.$clientIp.'>>>'.$getDataJson);
+        $allowIp = ['222.69.148.83','120.253.238.34','114.86.176.11','120.253.238.37','218.242.51.14'];
+//        if (!in_array($clientIp, $allowIp)){
+//            $returnInformation['code'] = 60001;
+//            $returnInformation['msg'] = "操作失败,IP地址不在白名单中";
+//            $returnInformation['data']=null;
+//            return json_encode($returnInformation);
+//        }else{
+            if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
+                if ($getdata["userName"]=="sgec68" && $getdata["userPassword"]=="sgec68123"){
+                    if(!empty($getdata['commandType'])){
+                        if($getdata['commandType']=="FRONTPAGE"){
+                            $sql="select device_code as deviceCode,device_name as deviceName,CONVERT(type, UNSIGNED INTEGER) as deviceType,type_name as deviceTypeName,unitinfo as deviceAddress,CONVERT(louyu, UNSIGNED INTEGER) as deviceFloor,company_name as companyName,company_code as companyCode,contacts,contacts_phone as contactsPhone,address as detailedAddress,street,posistion,time as dataTime,'在线' as status from sp_v_yp_device";
+                            $res=add($sql);
+                            if (!empty($res)){
+                                $returnInformation['code'] = 0;
+                                $returnInformation['msg'] = "操作成功";
+                                $returnInformation['data']=$res;
+                                return json_encode($returnInformation);
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                        }else{
+                            $returnInformation['code'] = 60001;
+                            $returnInformation['msg'] = "操作失败,参数错误";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                    }else{
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,参数为空";
+                        $returnInformation['data']=null;
+                        return json_encode($returnInformation);
+                    }
+                }else{
+                    $returnInformation['code'] = 60002;
+                    $returnInformation['msg'] = "操作失败,用户名或密码错误";
+                    $returnInformation['data']=null;
+                    return json_encode($returnInformation);
+                }
+            }else{
+                $returnInformation['code'] = 60002;
+                $returnInformation['msg'] = "操作失败,用户名或密码为空";
+                $returnInformation['data']=null;
+                return json_encode($returnInformation);
+            }
+//        }
+    }
+
+    //杨浦城运中心设备基础信息注册
+    public function deviceInfoRegister()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $data1 = Db::query("select sensorId,sensorType,sensorName,CONCAT(companyName,address) AS address,wsLng,wsLat,dataCode,applyId,cityId,areaId,regionId,projectCode from yp_ywtg_configure where id >{$getdata["id"]}");
+//        $rep_url = "http://220.196.241.22:8000/api-projectdatamanage/equipmentsync/sync";
+//        $header=[
+//            "Content-Type:application/json",
+//            "Authenticator:eyJhbGciOiJIUzI1NiJ9.eyJyZWFsTmFtZSI6Iumfqeato-S5iSIsInJvbGVJZHMiOiIxMSIsIm9yZ0NvZGUiOiJYIiwibG9naW5OYW1lIjoiaGFuenkiLCJwbGF0Zm9ybUlkIjpudWxsLCJleHAiOjE2Mzc2NjQ1MDMsInVzZXJJZCI6MTAwNiwib3JnSWQiOjF9.H_xzdQ9jdcndOCsYU9z3cZ-oBk4FtdxJk9wxC0AaZvE"
+//        ];
+//        $res = $this->ywManagementCurl($rep_url,$header,json_encode($data1));
+        return json_encode($data1);
+    }
+
+    public function alarmHandling(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=1;
+
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=2;
+
+        }
+        Log::record('yangpuerqi_alarmHandling' . ':' .$getDataJson);
+        if ($getdata['confirmAll']==""){
+            $getdata['confirmAll']=0;
+        }
+
+        if ($getdata['misinformation']==""){
+            $getdata['misinformation']=0;
+        }
+
+
+        if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
+            if ($getdata["userName"]=="ypsgec" && $getdata["userPassword"]=="ypsgec123"){
+                if (empty($getdata['recordId'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少记录Id";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['deviceCode'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少设备编号";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['deviceType'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少设备类型";
+                    return json_encode($returnInformation);
+                }elseif ($getdata['confirmAll']!=0&&$getdata['confirmAll']!=1){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少是否批量处理类型";
+                    return json_encode($returnInformation);
+                }elseif ($getdata['misinformation']!=0&&$getdata['misinformation']!=1){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少是否误报字段";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['handlerName'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少处理人姓名";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['handlerPhone'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少处理人联系方式";
+                    return json_encode($returnInformation);
+                }
+//                else{
+//                    $returnInformation['code'] = 0;
+//                    $returnInformation['msg'] = "操作成功";
+//                    return json_encode($returnInformation);
+//                }
+
+
+//                echo 'aaaaaaa';
+//                exit();
+                switch ($getdata['deviceType']) {
+                    case '1':
+                        $tab="sp_hj2017";
+                        break;
+                    case '2':
+                        $tab="sp_sj2017";
+                        break;
+                    case '6':
+                        $tab="sp_rtu2017";
+                        break;
+                    case '7':
+                        $tab="sp_ef2017";
+                        break;
+//                    case '16':
+//                        $tab="sp_video2017";
+//                        break;
+                    default:
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,缺少设备类型";
+                        return json_encode($returnInformation);
+                        break;
+                }
+
+                $time = date('Y-m-d h:i:s', time());
+
+                if ($getdata['confirmAll']==0){
+                    $where = " where id=".$getdata['recordId']." and device_code='".$getdata['deviceCode']."' and clzt='0'";
+                }else{
+                    $where = " where device_code='".$getdata['deviceCode']."' and clzt='0'";
+                }
+                $sql="UPDATE ".$tab." SET clsj='".$time."',clr='".$getdata['handlerName']."',clnr='".$getdata['processingContent']."',clwb='".$getdata['misinformation']."',cldh='".$getdata['handlerPhone']."',clzt=1 ".$where;
+//                echo $sql;
+//               print_r($sql);
+//               exit();
+                $res=addDataInfo($sql);
+                if ($res){
+                    $returnInformation['code'] = 0;
+                    $returnInformation['msg'] = "操作成功";
+                    return json_encode($returnInformation);
+                }else{
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,参数错误";
+                    return json_encode($returnInformation);
+                }
+            }else{
+                $returnInformation['code'] = 60002;
+                $returnInformation['msg'] = "操作失败,用户名或密码错误";
+                return json_encode($returnInformation);
+            }
+        }else{
+            $returnInformation['code'] = 60002;
+            $returnInformation['msg'] = "操作失败,用户名或密码为空";
+            return json_encode($returnInformation);
+        }
+    }
+
+    public function ip() {
+        //strcasecmp 比较两个字符,不区分大小写。返回0,>0,<0。
+        if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
+            $ip = getenv('HTTP_CLIENT_IP');
+        } else if (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
+            $ip = getenv('HTTP_X_FORWARDED_FOR');
+        } else if (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
+            $ip = getenv('REMOTE_ADDR');
+        } else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
+            $ip = $_SERVER['REMOTE_ADDR'];
+        }
+        $res =  preg_match ( '/[\d\.]{7,15}/', $ip, $matches ) ? $matches [0] : '';
+        return $res;
+        //dump(phpinfo());//所有PHP配置信息
+    }
+
+    public function http_post_advertise1($url,$data){        //封装curl方法
+        $header  = array(
+            'appKey:'.'850404889644236801',
+            'Content-Type:'.'application/json'
+        );
+        $ch = curl_init();     //初始化
+        curl_setopt($ch, CURLOPT_URL, $url);      //请求地址
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_POST, true);
+//https协议需要以下两行,否则请求不成功
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+//post方法所需要的参数
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
+        $result = curl_exec($ch);
+        curl_close($ch);
+        return $result;        //返回所获取的方法
+    }
+
+    public function ytapi_query($sql){
+        $link = mysqli_connect('47.98.201.187', 'root', 'Yt2018IoT', 'jdxf', 3306);
+        mysqli_query($link,"set character set 'utf8'");
+        $res1 = mysqli_query($link,$sql);
+        if($res1==FALSE){
+            return $list=null;
+        }
+        $list=array();
+        while ($row = $res1->fetch_assoc()) {
+            $list[]=$row;
+        }
+        mysqli_free_result($res1);
+        mysqli_close($link);
+        return $list;
+    }
+
+    public function dianQiCeShiUrl(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=1;
+
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=2;
+
+        }
+        $number=$getdata['number'];
+        $start_number=$getdata['start_number'];
+        $arr=$this->ytapi_query("select * from a_fire_brigade limit ".$start_number.",".$number);
+//$arr=ytapi_query("select * from a_yc_point_register limit 200,10");
+        $array=[];
+        foreach ($arr as $key=>$value){
+            $array[$key]['descript']=$arr[$key]['descript'];
+            $array[$key]['deviceName']=$arr[$key]['device_name'];
+//    $array[$key]['deviceNo']=$arr[$key]['device_code'].str_replace(',','',$arr[$key]['port']);
+            $array[$key]['deviceNo']=$arr[$key]['device_code'].str_replace(',','',$arr[$key]['port']).$arr[$key]['data'];
+            $array[$key]['deviceType']=$arr[$key]['device_type'];
+            $array[$key]['deviceTypeName']=$arr[$key]['device_type_name'];
+            $array[$key]['openProjectId']=$arr[$key]['open_project_id'];
+        }
+
+        $url1='http://iot.shxf-119.com/access/device/point/register';//新正式路径
+        foreach ($array as $key=>$value){
+//            sleep(2);
+            $data1=[];
+            $data1  = $array[$key];
+            Log::record('fireBrigadeAfferent:' .json_encode($data1));
+            $output= $this->http_post_advertise1($url1,json_encode($data1));
+            echo $output."\n";
+            Log::record('fireBrigadeOutput:' .$output);
+        }
+    }
+
+    public function mt_rand_float($min, $max){
+        return $min +  abs($max-$min) * mt_rand(0,mt_getrandmax())/mt_getrandmax();
+ 	}
+
+    public function randomDate() {
+        $begin = strtotime("now");
+        $end = strtotime("-1 Month");
+        $timestamp = rand($begin, $end);
+        return date("Y-m-d H:i:s", $timestamp);
+    }
+
+    public function ceShiUrl(){
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        Log::record('zhanyejunceshi:' .$getDataJson);
+        return $getDataJson;
+//        $data1 = array();
+//        $data2 = array();
+//        $data4 = array();
+//        $data5 = array();
+//        $data6 = array();
+//        $data7 = array();
+//        $data8 = array();
+//        $data9 = array();
+//        $data10 = array();
+//        $data11 = array();
+//        $data12 = array();
+//        $data15 = array();
+//        $data16 = array();
+//        $data18 = array();
+//        $data19 = array();
+//        for ($i=0;$i<=14;$i++){
+//            $data1['standard_deviation']=round($this->mt_rand_float(1,5),2);
+//            $data1['variance']=round($data1['standard_deviation']*$data1['standard_deviation'],2);
+//            $data1['average_value']=round($this->mt_rand_float(220,227),2);
+//            $j=$i+1;
+//            if($j>=10){
+//                $data1['data_time']="2021-03-".$j;
+//            }
+//            $data2[$i]=$data1;
+//            $data4['standard_deviation']=round($this->mt_rand_float(3,8),2);
+//            $data4['variance']=round($data4['standard_deviation']*$data4['standard_deviation'],2);
+//            $data4['average_value']=round($this->mt_rand_float(7,15),2);
+//            if($j>=10){
+//                $data4['data_time']="2021-03-".$j;
+//            }
+//            $data5[$i]=$data4;
+//            $data6['standard_deviation']=round($this->mt_rand_float(0,2),2);
+//            $data6['variance']=round($data6['standard_deviation']*$data6['standard_deviation'],2);
+//            $data6['average_value']=round($this->mt_rand_float(17,25),2);
+//            if($j>=10){
+//                $data6['data_time']="2021-03-".$j;
+//            }
+//            $data7[$i]=$data6;
+//            $data8['standard_deviation']=round($this->mt_rand_float(30,70),2);
+//            $data8['variance']=round($data8['standard_deviation']*$data8['standard_deviation'],2);
+//            $data8['average_value']=round($this->mt_rand_float(30,60),2);
+//            if($j>=10){
+//                $data8['data_time']="2021-03-".$j;
+//            }
+//            $data9[$i]=$data8;
+//            $data11['electric_current']=round($this->mt_rand_float(8,18),2);
+//            $data11['voltage']=round($this->mt_rand_float(220,225),2);
+//            $data11['data_time']=$this->randomDate();
+//            $data12[$i]=$data11;
+//            $data15['electric_current']=round($this->mt_rand_float(20,100),2);
+//            $data15['voltage']=round($this->mt_rand_float(220,225),2);
+//            $data15['data_time']=$this->randomDate();
+//            $data16[$i]=$data15;
+//            $data18['ambient_temperature']=round($this->mt_rand_float(20,25),2);
+//            $data18['Cable_temperature']=round($this->mt_rand_float(10,20),2);
+//            $data18['generation_temperature']=round($data18['ambient_temperature']-$data18['Cable_temperature'],2);
+//            $data18['data_time']=$this->randomDate();
+//            $data19[$i]=$data18;
+//        }
+//        $data10['conclusion1']="因数据量未达到暂无法分析";
+//        $data3['voltage']=$data2;
+//        $data3['electric_current']=$data5;
+//        $data3['temperature']=$data7;
+//        $data3['leakage_current']=$data9;
+//        $data3['conclusion']=$data10;
+//        $data14['abnormal_equipment']=$data12;
+//        $data14['leakage_alarm']=$data16;
+//        $data14['conclusion']=$data10;
+//        $data20['visualization']=$data19;
+//        $data20['conclusion']=$data10;
+//        $data13['dispersion_rate']=$data3;
+//        $data13['electrical_aging']=$data14;
+//        $data13['thermal_aging']=$data20;
+////        $data1['alarm_number']=$this->mt_rand_float(100,500);
+////        $sensorList['productId'] = round($this->mt_rand_float(3,5),2);
+//        $data17 = json_encode($data13);
+//        return $data17;
+    }
+
+    //水系统电气火灾算法测试API
+    public function algorithmApi(){
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        if(!empty($getdata["dataType"])){
+            if($getdata["dataType"]==1||$getdata["dataType"]==2){
+                if($getdata["dataType"]==1){
+                    if (!empty($getdata["apiType"])){
+                        if ($getdata["apiType"]==4){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select dispersion_rate from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['dispersion_rate'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+
+                        }elseif ($getdata["apiType"]==5){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select leakage_investigation from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['leakage_investigation'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==6){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select device_association from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['device_association'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==7){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_fluctuation from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_fluctuation'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==2){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_statistics from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_statistics'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==3){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    if($getdata["timeType"]==1) {
+                                        $sql6 = "select data4,data1,`time`as dataTime from sp_d864016058809717 where `time` between '2021-07-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==2){
+                                        $sql6 = "select data4,data1,`time`as dataTime from sp_d864016058809717 where `time` between '2021-07-13 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==3){
+                                        $sql6 = "select data4,data1,`time`as dataTime from sp_d864016058809717 where `time` between '2021-06-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }
+                    }else{
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,api类型不能为空";
+                        return json_encode($returnInformation);
+                    }
+                }else{
+                    if (!empty($getdata["apiType"])){
+                        if ($getdata["apiType"]==4){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select dispersion_rate from sp_ef_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['dispersion_rate'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+
+                        }elseif ($getdata["apiType"]==5){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select electrical_aging from sp_ef_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['electrical_aging'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==6){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select thermal_aging from sp_ef_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['thermal_aging'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==7){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_fluctuation from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_fluctuation'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==2){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_statistics from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_statistics'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==3){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    if($getdata["timeType"]==1) {
+                                        $sql6 = "select point_data,point_code,data_time from sp_e00003215010144 where data_time between '2021-07-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==2){
+                                        $sql6 = "select point_data,point_code,data_time from sp_e00003215010144 where data_time between '2021-07-13 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==3){
+                                        $sql6 = "select point_data,point_code,data_time from sp_e00003215010144 where data_time between '2021-06-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }
+                    }else{
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,api类型不能为空";
+                        return json_encode($returnInformation);
+                    }
+                }
+            }else{
+                $returnInformation['code'] = 60001;
+                $returnInformation['msg'] = "操作失败,数据范围超出限制";
+                return json_encode($returnInformation);
+            }
+        }else{
+            $returnInformation['code'] = 60001;
+            $returnInformation['msg'] = "操作失败,数据类型不能为空";
+            return json_encode($returnInformation);
+        }
+    }
+
+    public function ceshiApi()
+    {
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $data1 = array();
+        $data2 = array();
+        $data3 = array();
+        $data4 = array();
+        if ($getdata['status']=="getnewslist"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['zhaiyao']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+                $data2['click']=1;
+                $data2['img_url']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fs10.sinaimg.cn%2Forignal%2F4a8a8049ga9eae999a909&refer=http%3A%2F%2Fs10.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=f95e7303fda34bef3751916ee036b4a9";
+                $data3[$i]=$data2;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getnew"){
+            $data1['status']=0;
+            $data2['id']=1;
+            $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+            $data2['add_time']="2021-08-05 16:48:17";
+            $data2['content']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+            $data2['click']=2;
+            $data3[0]=$data2;
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getimages"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['zhaiyao']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+                $data2['img_url']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn08%2F336%2Fw501h635%2F20180630%2F9d76-hespqrx2645109.jpg&refer=http%3A%2F%2Fn.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=384680be0388ea4c8bd06dfed25d9da3";
+                $data3[$i]=$data2;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getimgcategory"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试".$i;
+                $data3[$i]=$data2;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getthumimages"){
+            $data1['status']=0;
+            for ($i=0;$i<3;$i++){
+                $data2['src']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.article.pchome.net%2F00%2F40%2F91%2F79%2Fpic_lib%2Fs960x639%2Fcountry_field_landscape_photo_EA52058s960x639.jpg&refer=http%3A%2F%2Fimg.article.pchome.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=0fe6c4c3d1a111f5e848695687261303";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getimageInfo"){
+            $data1['status']=0;
+            for ($i=0;$i<1;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['click']=3;
+                $data2['content']="解释的机会就是进口关税打开撒酒疯还是";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getcomments"){
+            $data1['status']=0;
+            for ($i=0;$i<1;$i++){
+                $data2['user_name']="djsjf";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['content']="快速减肥健身看江户时代";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="postcomment"){
+            $data1['status']=0;
+            $data1['message']="啊附加符号方式";
+            return json_encode($data1);
+        }elseif($getdata['status']=="getgoods"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['zhaiyao']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+                $data2['click']=0;
+                $data2['img_url']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_360_360%2F5b%2F71%2F3b%2F5b713b0d8f5fb4e4f8759c417b42eefb.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=699aab395bae994606f72becd4cbb90d";
+                $data2['sell_price']=214;
+                $data2['market_price']=3446;
+                $data2['stock_quantity']=3446;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getdesc"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['content']="<p>的实际开工的开始</p><p align='center'></p>";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }
+    }
+
+    //杨浦一网通管各类设备数量
+    public function deviceNumber(){
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $data6 = array();
+        if ($getdata['userName']=="ypywtg"){
+            $sql="SELECT COUNT(*) AS waterNumber FROM sp_owner WHERE dwtype = 2 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res=add($sql);
+            $sql1="SELECT COUNT(*) AS levelNumber FROM sp_owner WHERE dwtype = 5 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res1=add($sql1);
+            $sql2="SELECT COUNT(*) AS smokeSensationNumber FROM sp_owner WHERE dwtype = 3 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res2=add($sql2);
+            $sql3="SELECT COUNT(*) AS rtuNumber FROM sp_owner WHERE dwtype = 6 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res3=add($sql3);
+            $sql4="SELECT COUNT(*) AS videoNumber FROM sp_owner WHERE dwtype = 16 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res4=add($sql4);
+            $sql5="SELECT COUNT(*) AS electricalFireNumber FROM sp_owner WHERE dwtype = 7 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res5=add($sql5);
+            $sensorList['waterNumber'] =$res[0]['waterNumber'];
+            $sensorList['levelNumber'] =$res1[0]['levelNumber'];
+            $sensorList['smokeSensationNumber'] =$res2[0]['smokeSensationNumber'];
+            $sensorList['rtuNumber'] =$res3[0]['rtuNumber'];
+            $sensorList['videoNumber'] =$res4[0]['videoNumber'];
+            $sensorList['electricalFireNumber'] =$res5[0]['electricalFireNumber'];
+            $data6 = json_encode($sensorList);
+        }
+        return $data6;
+    }
+
+    //伍继电力程序校验机制api
+    public function wooGiApi(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $clientIp=$this->ip();
+        Log::record('wooGiApi_deviceList' . ':' .'<<<'.$clientIp.'>>>'.$getDataJson);
+        $allowIp = ['101.133.214.75','124.71.174.104','124.71.175.91','124.70.160.158','222.69.148.83','114.95.161.247'];
+//        if (!in_array($clientIp, $allowIp)){
+//            $returnInformation['code'] = 60001;
+//            $returnInformation['msg'] = "操作失败,IP地址不在白名单中";
+//            $returnInformation['data']=null;
+//            return json_encode($returnInformation);
+//        }else{
+            $redis = new \Redis();
+            $redis->connect('127.0.0.1', 6379);
+            $result = $redis->auth("usky2021");
+            $redis->select(1);
+            if ($result == 1) {
+                $check =$redis->exists($clientIp);
+                if ($check){
+                    // +1
+                    $redis->incr($clientIp);
+                    $count =$redis->get($clientIp);
+                    // 限制每小时1次
+                    if($count > 500){
+                        $returnInformation['code'] = 60003;
+                        $returnInformation['msg'] = "操作失败,当前ip请求频率过高";
+                        $returnInformation['data']=null;
+                        return json_encode($returnInformation);
+                    }else{
+                        if (!empty($getdata['publicKey'])){
+                            $publicKey = $getdata['publicKey'];
+                            $timeStamp = time();
+                            if (!empty($getdata['requestType'])){
+                                if($getdata['requestType']==1){
+                                    $publicKey1 = md5("usky".$getdata['timeStamp']."9bcbc5d723cb9bae394d3a097deb6695");
+                                    $publicKey2 = md5("usky".$timeStamp."9bcbc5d723cb9bae394d3a097deb6695");
+                                }else if ($getdata['requestType']==2){
+                                    $publicKey1 = md5("usky".$getdata['timeStamp']."b9848b4fe4647e380fd1367a4f34ced9");
+                                    $publicKey2 = md5("usky".$timeStamp."b9848b4fe4647e380fd1367a4f34ced9");
+                                }else if ($getdata['requestType']==3){
+                                    $publicKey1 = md5("usky".$getdata['timeStamp']."056ac8fae059c9c9e700b734922edfc8");
+                                    $publicKey2 = md5("usky".$timeStamp."056ac8fae059c9c9e700b734922edfc8");
+                                }else{
+                                    $returnInformation['code'] = 60004;
+                                    $returnInformation['msg'] = "操作失败,requestType不在范围内";
+                                    $returnInformation['data']=null;
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60004;
+                                $returnInformation['msg'] = "操作失败,requestType不能为空";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                            if ($publicKey==$publicKey1){
+                                $sensorList['publicKey'] =$publicKey2;
+                                $sensorList['timeStamp'] =$timeStamp;
+                                $returnInformation['code'] = 200;
+                                $returnInformation['msg'] = "操作成功";
+                                $returnInformation['data']=$sensorList;
+                                return json_encode($returnInformation);
+                            }else{
+                                $returnInformation['code'] = 60002;
+                                $returnInformation['msg'] = "操作失败,publicKey错误";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                        }else{
+                            $returnInformation['code'] = 60004;
+                            $returnInformation['msg'] = "操作失败,publicKey不能为空";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                    }
+                } else {
+                    $redis->set($clientIp, 1,3300);//初始值1
+                    if (!empty($getdata['publicKey'])){
+                        $publicKey = $getdata['publicKey'];
+                        $timeStamp = time();
+                        if (!empty($getdata['requestType'])){
+                            if($getdata['requestType']==1){
+                                $publicKey1 = md5("usky".$getdata['timeStamp']."9bcbc5d723cb9bae394d3a097deb6695");
+                                $publicKey2 = md5("usky".$timeStamp."9bcbc5d723cb9bae394d3a097deb6695");
+                            }else if ($getdata['requestType']==2){
+                                $publicKey1 = md5("usky".$getdata['timeStamp']."b9848b4fe4647e380fd1367a4f34ced9");
+                                $publicKey2 = md5("usky".$timeStamp."b9848b4fe4647e380fd1367a4f34ced9");
+                            }else if ($getdata['requestType']==3){
+                                $publicKey1 = md5("usky".$getdata['timeStamp']."056ac8fae059c9c9e700b734922edfc8");
+                                $publicKey2 = md5("usky".$timeStamp."056ac8fae059c9c9e700b734922edfc8");
+                            }else{
+                                $returnInformation['code'] = 60004;
+                                $returnInformation['msg'] = "操作失败,requestType不在范围内";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                        }else{
+                            $returnInformation['code'] = 60004;
+                            $returnInformation['msg'] = "操作失败,requestType不能为空";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                        if ($publicKey==$publicKey1){
+                            $sensorList['publicKey'] =$publicKey2;
+                            $sensorList['timeStamp'] =$timeStamp;
+                            $returnInformation['code'] = 200;
+                            $returnInformation['msg'] = "操作成功";
+                            $returnInformation['data']=$sensorList;
+                            return json_encode($returnInformation);
+                        }else{
+                            $returnInformation['code'] = 60002;
+                            $returnInformation['msg'] = "操作失败,publicKey错误";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                    }else{
+                        $returnInformation['code'] = 60004;
+                        $returnInformation['msg'] = "操作失败,publicKey不能为空";
+                        $returnInformation['data']=null;
+                        return json_encode($returnInformation);
+                    }
+                }
+            }
+//        }
+    }
+
+    //伍继电力java程序校验机制api
+    public function wooGiJavaApi(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $clientIp=$this->ip();
+        Log::record('wooGiJavaApi_deviceList' . ':' .'<<<'.$clientIp.'>>>'.$getDataJson);
+        $code = 1;
+        if ($code==1){
+            return 1;
+        }else{
+            return 0;
+        }
+    }
+
+    //杨浦学校设备注册api
+    public function ypSchoolApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $sql6="select * from sp_yangpuxy_share where company_code ='{$getdata["deviceCode"]}' and rec_cur=1586416046";
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $cs['deviceId'] = $ypSchoolOwner[$key]['object_code'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['object_name'].$ypSchoolOwner[$key]['device_name'];
+                if ($ypSchoolOwner[$key]['owner_dwtype']==2){
+                    $cs['deviceType'] = "1";
+                    $cs['deviceTypeName'] = "水泵水压检测器";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==128){
+                    $cs['deviceType'] = "4";
+                    $cs['deviceTypeName'] = "井盖探测器";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==3){
+                    $cs['deviceType'] = "3";
+                    $cs['deviceTypeName'] = "烟感检测";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==7){
+                    $cs['deviceType'] = "5";
+                    $cs['deviceTypeName'] = "高低压配电房检测器";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==130){
+                    $cs['deviceType'] = "2";
+                    $cs['deviceTypeName'] = "消防栓";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==1){
+                    $cs['deviceType'] = "3";
+                    $cs['deviceTypeName'] = "烟感检测";
+                }
+                $cs['companyCode'] = $ypSchoolOwner[$key]['company_code'];
+                $cs['companyName'] = $ypSchoolOwner[$key]['company_name'];
+                $data6 = json_encode($cs);
+                $rep_url = "http://ypaqpt.edu.sh.cn/schoolSafe-yp/deviceAdd";
+                $res = $this->ypxycurl($rep_url, $data6);
+                Log::record('yangpuxiaoyuandevice1' . ':' . $data6);
+                Log::record('yangpuxiaoyuandevice2' . ':' . $res);
+                print_r('结果'.$res);
+                print_r($data6);
+                sleep(0.5);
+            }
+        }
+    }
+
+    //消防总队平台主机点位设备注册api
+    public function xfzdAddApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $header=[
+            "Content-Type:application/json",
+            "appKey:850404889644236801"
+        ];
+        $sql6="select * from sp_corps_share_ceshi where open_project_id ='{$getdata["companyCode"]}' and `data` ={$getdata["hostCode"]} limit ".$getdata["startNum"].",".$getdata["endNum"];
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $cs['descript'] = $ypSchoolOwner[$key]['descript'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['device_name'];
+//                if ($ypSchoolOwner[$key]['dwtype']==6){
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'].str_replace(',','',$ypSchoolOwner[$key]['port']).$ypSchoolOwner[$key]['data'];
+//                }else{
+//                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'];
+//                }
+                $cs['deviceType'] = $ypSchoolOwner[$key]['device_type'];
+                $cs['deviceTypeName'] = $ypSchoolOwner[$key]['device_type_name'];
+                $cs['openProjectId'] = $ypSchoolOwner[$key]['open_project_id'];
+                $cs['floor'] = $ypSchoolOwner[$key]['device_floor'];
+                $data6 = json_encode($cs);
+                $rep_url = "http://iot.shxf-119.com/access/device/point/register";
+                $res = $this->ywManagementCurl($rep_url,$header,$data6);
+                Log::record('xiaofangzongduidevice1' . ':' . $data6);
+                Log::record('xiaofangzongduidevice2' . ':' . $res);
+                print_r('结果'.$res);
+                print_r($data6);
+                sleep(0.5);
+            }
+        }
+    }
+
+    //消防总队平台主机点位设备注册api
+    public function xfzdDeviceAddApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $header=[
+            "Content-Type:application/json",
+            "appKey:850404889644236801"
+        ];
+        $sql6="select * from sp_corps_share where open_project_id ='{$getdata["companyCode"]}' limit ".$getdata["startNum"].",".$getdata["endNum"];
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $cs['descript'] = $ypSchoolOwner[$key]['descript'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['device_name'];
+                if ($ypSchoolOwner[$key]['dwtype']==6){
+                $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'].$ypSchoolOwner[$key]['port'];
+                }else{
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'];
+                }
+                $cs['deviceType'] = $ypSchoolOwner[$key]['device_type'];
+                $cs['deviceTypeName'] = $ypSchoolOwner[$key]['device_type_name'];
+                $cs['openProjectId'] = $ypSchoolOwner[$key]['open_project_id'];
+                $cs['floor'] = $ypSchoolOwner[$key]['device_floor'];
+                $data6 = json_encode($cs);
+                $rep_url = "http://iot.shxf-119.com/access/device/point/register";
+                $res = $this->ywManagementCurl($rep_url,$header,$data6);
+                Log::record('xiaofangzongduidevice1' . ':' . $data6);
+                Log::record('xiaofangzongduidevice2' . ':' . $res);
+                print_r('结果'.$res);
+                print_r($data6);
+                sleep(0.5);
+            }
+        }
+    }
+
+    //消防总队平台设备数据推送api
+    public function xfzdDeviceInfoAddApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $header=[
+            "Content-Type:application/json",
+            "appKey:850404889644236801"
+        ];
+        $rep_url1 = "http://iot.shxf-119.com/access/devlog/transmission/devicestatus";//用传
+        $rep_url2 = "http://iot.shxf-119.com/access/devlog/sprinkler/endpressure";//喷淋末端压力
+        $rep_url3 = "http://iot.shxf-119.com/access/devlog/sprinkler/pipepressunusual";//喷淋主管压力
+        $rep_url4 = "http://iot.shxf-119.com/access/devlog/sprinkler/spraypump";//喷淋泵状态
+        $rep_url5 = "http://iot.shxf-119.com/access/devlog/hydrant/endpressure";//消火栓末端压力
+        $rep_url6 = "http://iot.shxf-119.com/access/devlog/hydrant/pipepress";//消火栓主管压力
+        $rep_url7 = "http://iot.shxf-119.com/access/devlog/hydrant/tanklevel";//水箱液位
+        $rep_url8 = "http://iot.shxf-119.com/access/devlog/hydrant/pumpstatus";//消防泵状态
+        $sql6="select * from sp_corps_share where open_project_id ='{$getdata["companyCode"]}'";
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $sql7="select * from sp_owner_status where device_id ='{$ypSchoolOwner[$key]['device_code']}'";
+                $companyOwner = add($sql7);
+                $cs['descript'] = $ypSchoolOwner[$key]['descript'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['device_name'];
+                if ($ypSchoolOwner[$key]['dwtype']==6){
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'].$ypSchoolOwner[$key]['port'];
+                }else{
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'];
+                }
+                $cs['deviceType'] = $ypSchoolOwner[$key]['device_type'];
+                $cs['deviceTypeName'] = $ypSchoolOwner[$key]['device_type_name'];
+                $cs['openProjectId'] = $ypSchoolOwner[$key]['open_project_id'];
+                $cs['floor'] = $ypSchoolOwner[$key]['device_floor'];
+                if ($ypSchoolOwner[$key]['dwtype']==1){
+                    foreach ($companyOwner as $key1=>$value1){
+                        if ($companyOwner[$key1]['point_code']==1){
+                            if(strstr($companyOwner[$key1]['content'],'监测连线故障') !== false) {
+                                $cs['connectStatus'] = "1";
+                            }else{
+                                $cs['connectStatus'] = "0";
+                            }
+                            $cs['workStatus'] = "0";
+                            $cs['mainPower'] = "0";
+                            $cs['logTime'] = date('Y-m-d H:i:s');
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url1,$header,$data6);
+                            print_r('结果'.$res);
+                        }
+                    }
+                }elseif ($ypSchoolOwner[$key]['dwtype']==2){
+                    foreach ($companyOwner as $key1=>$value1){
+                        if ($companyOwner[$key1]['point_code']==4){
+                            $cs['logTime'] = date('Y-m-d H:i:s');
+                            $cs['pressure'] = $companyOwner[$key1]['point_data'];
+                        }elseif ($companyOwner[$key1]['point_code']==1){
+                            if(strstr($companyOwner[$key1]['content'],'正常') !== false) {
+                                $cs['alarmStatus'] = "0";
+                            }elseif (strstr($companyOwner[$key1]['content'],'低压') !== false){
+                                $cs['alarmStatus'] = "1";
+                            }elseif (strstr($companyOwner[$key1]['content'],'高压') !== false){
+                                $cs['alarmStatus'] = "2";
+                            }else{
+                                $cs['alarmStatus'] = "0";
+                            }
+                        }
+                    }
+                    if($ypSchoolOwner[$key]['device_type']==304){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url2,$header,$data6);
+                        print_r('结果'.$res);
+                    }elseif ($ypSchoolOwner[$key]['device_type']==301){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url3,$header,$data6);
+                        print_r('结果'.$res);
+                    }elseif ($ypSchoolOwner[$key]['device_type']==305){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url5,$header,$data6);
+                        print_r('结果'.$res);
+                    }elseif ($ypSchoolOwner[$key]['device_type']==302){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url6,$header,$data6);
+                        print_r('结果'.$res);
+                    }
+                }elseif ($ypSchoolOwner[$key]['dwtype']==5){
+                    foreach ($companyOwner as $key1=>$value1){
+                        if ($companyOwner[$key1]['point_code']==4){
+                            $cs['logTime'] = date('Y-m-d H:i:s');
+                            $cs['level'] = $companyOwner[$key1]['point_data'];
+                        }elseif ($companyOwner[$key1]['point_code']==1){
+                            if(strstr($companyOwner[$key1]['content'],'正常') !== false) {
+                                $cs['alarmStatus'] = "0";
+                            }elseif (strstr($companyOwner[$key1]['content'],'低液位') !== false){
+                                $cs['alarmStatus'] = "1";
+                            }elseif (strstr($companyOwner[$key1]['content'],'高液位') !== false){
+                                $cs['alarmStatus'] = "2";
+                            }else{
+                                $cs['alarmStatus'] = "0";
+                            }
+                        }
+                    }
+                    if($ypSchoolOwner[$key]['device_type']==402){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url7,$header,$data6);
+                        print_r('结果'.$res);
+                    }else{
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url7,$header,$data6);
+                        print_r('结果'.$res);
+                    }
+                }elseif ($ypSchoolOwner[$key]['dwtype']==6){
+                    if($ypSchoolOwner[$key]['device_type']==258 || $ypSchoolOwner[$key]['device_type']==256 || $ypSchoolOwner[$key]['device_type']==452){
+                        $cs['logTime'] = date('Y-m-d H:i:s');
+                        $companyOwner1 = $ypSchoolOwner[$key]['data'];
+                        foreach ($companyOwner1 as $key1=>$value1){
+                            if ($companyOwner1[$key1]['port']==-1){
+                                if(strstr($companyOwner1[$key1]['name'],'powerStatus') !== false) {
+                                    $cs['powerState'] = "0";
+                                }elseif (strstr($companyOwner1[$key1]['name'],'runStatus') !== false){
+                                    $cs['manualAutomaticState'] = "0";
+                                }elseif (strstr($companyOwner1[$key1]['name'],'startStatus') !== false){
+                                    $cs['startStopStatus'] = "0";
+                                }elseif (strstr($companyOwner1[$key1]['name'],'faultStatus') !== false){
+                                    $cs['faultStatus'] = "0";
+                                }
+                            }
+                        }
+                        foreach ($companyOwner as $key3=>$value3){
+                            foreach ($companyOwner1 as $key2=>$value2){
+                                if ($companyOwner1[$key2]['port']==$companyOwner[$key3]['point_code'] && $companyOwner[$key3]['point_code']!=0){
+                                    if(strstr($companyOwner[$key3]['content'],'正常') !== false || strstr($companyOwner[$key3]['content'],'自动') !== false || strstr($companyOwner[$key3]['content'],'停止') !== false) {
+                                        if(strstr($companyOwner1[$key2]['name'],'powerStatus') !== false) {
+                                            $cs['powerState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'runStatus') !== false){
+                                            $cs['manualAutomaticState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'startStatus') !== false){
+                                            $cs['startStopStatus'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'faultStatus') !== false){
+                                            $cs['faultStatus'] = "0";
+                                        }
+                                    }elseif (strstr($companyOwner[$key3]['content'],'关闭') !== false || strstr($companyOwner[$key3]['content'],'手动') !== false || strstr($companyOwner[$key3]['content'],'运行') !== false || strstr($companyOwner[$key3]['content'],'故障') !== false){
+                                        if(strstr($companyOwner1[$key2]['name'],'powerStatus') !== false) {
+                                            $cs['powerState'] = "1";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'runStatus') !== false){
+                                            $cs['manualAutomaticState'] = "1";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'startStatus') !== false){
+                                            $cs['startStopStatus'] = "1";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'faultStatus') !== false){
+                                            $cs['faultStatus'] = "1";
+                                        }
+                                    }else{
+                                        if(strstr($companyOwner1[$key2]['name'],'powerStatus') !== false) {
+                                            $cs['powerState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'runStatus') !== false){
+                                            $cs['manualAutomaticState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'startStatus') !== false){
+                                            $cs['startStopStatus'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'faultStatus') !== false){
+                                            $cs['faultStatus'] = "0";
+                                        }
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                        if ($ypSchoolOwner[$key]['device_type']==258){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url8,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==256){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url4,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==452){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url4,$header,$data6);
+                            print_r('结果'.$res);
+                        }
+                    }else{
+                        $cs['logTime'] = date('Y-m-d H:i:s');
+                        $companyOwner1 = $ypSchoolOwner[$key]['data'];
+                        foreach ($companyOwner as $key2=>$value2) {
+                            foreach ($companyOwner1 as $key3 => $value3) {
+                                if (strstr($companyOwner1[$key3]['name'],'value') !== false){
+                                    if ($companyOwner1[$key3]['port']==$companyOwner[$key2]['point_code'] && $companyOwner[$key2]['point_code']!=0){
+                                        $cs['pressure'] = $companyOwner[$key2]['point_data'];
+                                        if(strstr($companyOwner[$key2]['content'],'正常') !== false) {
+                                            $cs['alarmStatus'] = "0";
+                                        }elseif (strstr($companyOwner[$key2]['content'],'低压') !== false){
+                                            $cs['alarmStatus'] = "1";
+                                        }elseif (strstr($companyOwner[$key2]['content'],'高压') !== false){
+                                            $cs['alarmStatus'] = "2";
+                                        }else{
+                                            $cs['alarmStatus'] = "0";
+                                        }
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+                        if($ypSchoolOwner[$key]['device_type']==304){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url2,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==301){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url3,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==305){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url5,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==302){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url6,$header,$data6);
+                            print_r('结果'.$res);
+                        }
+                    }
+                }
+            }
+        }
+    }
+    //消防物联网api
+    public function mhMobileLogin()
+    {
+        // 制定允许其他域名访问
+        header('Access-Control-Allow-Origin:*');
+        // 响应类型
+        header('Access-Control-Allow-Methods:*');
+        //请求头
+        header('Access-Control-Allow-Headers:*');
+        // 响应头设置
+        header('Access-Control-Allow-Credentials:false');
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $sendata['V_LOGINNAME'] = "afzzh";
+        $sendata['V_PASSWORD'] = "f67832d9943f7a68b80c05c411a6485e";
+        $sendata['V_COMMAND'] = "FRONTPAGE";
+        $sendata['COMMSTATUS'] = "NO";
+        if($getdata['api_type']==1){
+            $header=[
+                "Content-Type:application/json",
+            ];
+            $rescurl=curl("https://fire.usky.cn:8443/YtIoT/cgi-bin/WebAction.cgi",json_encode($sendata),$header);
+        }
+        return $rescurl[1];
+    }
+
+
+    //积木测试api
+    public function mhCompanyData()
+    {
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $allowKey = ['31cdd6a7766d24820156e5304a3f7107'];
+//        if (!in_array($clientIp, $allowIp)){
+        if (!empty($getdata['app_key']) && in_array($getdata['app_key'], $allowKey)){
+            if (!empty($getdata['app_key'])){
+
+            }
+        }else{
+            $sensorList=[];
+            $returnInformation['code'] = 10001;
+            $returnInformation['msg'] = "app_key参数错误";
+            $returnInformation['data']=$sensorList;
+            return json_encode($returnInformation);
+        }
+    }
+
+    //积木测试api
+    public function IOTData()
+    {
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $sql6="select COUNT(*) AS deviceNumber from sp_owner";
+        $device = add($sql6);
+        $sensorList['deviceNumber'] =$device[0]['deviceNumber'];
+        $sql7="SELECT COUNT(*) AS onDeviceNumber FROM Online_v_state WHERE `差值(小时)` < 24";
+        $onDevice = $this->temSelect($sql7);
+        $sensorList['onDeviceNumber'] =$onDevice[0]['onDeviceNumber'];
+        $sql8="select COUNT(*) AS pointNumber from sp_corps_share_ceshi";
+        $point1 = add($sql8);
+        $sql9="select COUNT(*) AS pointNumber from sp_corps_share_yf";
+        $point2 = add($sql9);
+        $sensorList['pointNumber'] =$point1[0]['pointNumber']+$point2[0]['pointNumber'];
+        $sql10="select COUNT(*) AS companyNumber from sp_owner_company";
+        $company = add($sql10);
+        $sensorList['companyNumber'] =$company[0]['companyNumber'];
+        $sql11="select COUNT(*) AS corpsDeviceNumber FROM sp_corps_share GROUP BY device_code";
+        $corpsDevice = add($sql11);
+        $sensorList['corpsDeviceNumber'] =count($corpsDevice);
+        $sql12="SELECT COUNT(*) AS corpsOffWaterDeviceNumber FROM Online_v_state WHERE `类型` = '水系统' AND `差值(小时)` > 48 AND `单位编号` in ('10357',
+'10356',
+'10354',
+'10352',
+'10349',
+'10350',
+'10347',
+'10346',
+'10334',
+'10188',
+'10343',
+'10348',
+'10331',
+'10320',
+'10320',
+'10164',
+'10071',
+'10345',
+'10144',
+'10064',
+'10336',
+'10131',
+'10205',
+'10340',
+'10339',
+'10225',
+'10323',
+'10320',
+'10134',
+'10235',
+'10337',
+'10226',
+'10214',
+'10160',
+'10076',
+'10079',
+'10078',
+'10215',
+'10324',
+'10324',
+'10154',
+'10106',
+'10121',
+'10067',
+'10310',
+'10325',
+'10323',
+'10322',
+'10320',
+'10128',
+'10314',
+'10315',
+'10312',
+'10222',
+'10077',
+'10146',
+'10151',
+'10232',
+'10150',
+'10116',
+'10114',
+'10122',
+'10166',
+'10353',
+'10358',
+'10359',
+'10361',
+'10360',
+'10140',
+'10362',
+'10206',
+'10355')";
+        $corpsOffWaterDevice = $this->temSelect($sql12);
+        $sensorList['corpsOffWaterDeviceNumber'] =$corpsOffWaterDevice[0]['corpsOffWaterDeviceNumber'];
+        $sql13="SELECT COUNT(*) AS corpsOffLevelDeviceNumber FROM Online_v_state WHERE `类型` = '液位' AND `差值(小时)` > 48 AND `单位编号` in ('10357',
+'10356',
+'10354',
+'10352',
+'10349',
+'10350',
+'10347',
+'10346',
+'10334',
+'10188',
+'10343',
+'10348',
+'10331',
+'10320',
+'10320',
+'10164',
+'10071',
+'10345',
+'10144',
+'10064',
+'10336',
+'10131',
+'10205',
+'10340',
+'10339',
+'10225',
+'10323',
+'10320',
+'10134',
+'10235',
+'10337',
+'10226',
+'10214',
+'10160',
+'10076',
+'10079',
+'10078',
+'10215',
+'10324',
+'10324',
+'10154',
+'10106',
+'10121',
+'10067',
+'10310',
+'10325',
+'10323',
+'10322',
+'10320',
+'10128',
+'10314',
+'10315',
+'10312',
+'10222',
+'10077',
+'10146',
+'10151',
+'10232',
+'10150',
+'10116',
+'10114',
+'10122',
+'10166',
+'10353',
+'10358',
+'10359',
+'10361',
+'10360',
+'10140',
+'10362',
+'10206',
+'10355')";
+        $corpsOffLevelDevice = $this->temSelect($sql13);
+        $sensorList['corpsOffLevelDeviceNumber'] =$corpsOffLevelDevice[0]['corpsOffLevelDeviceNumber'];
+        $sql14="SELECT COUNT(*) AS corpsOffRtuDeviceNumber FROM Online_v_state WHERE `类型` = 'rtu' AND `差值(小时)` > 48 AND `单位编号` in ('10357',
+'10356',
+'10354',
+'10352',
+'10349',
+'10350',
+'10347',
+'10346',
+'10334',
+'10188',
+'10343',
+'10348',
+'10331',
+'10320',
+'10320',
+'10164',
+'10071',
+'10345',
+'10144',
+'10064',
+'10336',
+'10131',
+'10205',
+'10340',
+'10339',
+'10225',
+'10323',
+'10320',
+'10134',
+'10235',
+'10337',
+'10226',
+'10214',
+'10160',
+'10076',
+'10079',
+'10078',
+'10215',
+'10324',
+'10324',
+'10154',
+'10106',
+'10121',
+'10067',
+'10310',
+'10325',
+'10323',
+'10322',
+'10320',
+'10128',
+'10314',
+'10315',
+'10312',
+'10222',
+'10077',
+'10146',
+'10151',
+'10232',
+'10150',
+'10116',
+'10114',
+'10122',
+'10166',
+'10353',
+'10358',
+'10359',
+'10361',
+'10360',
+'10140',
+'10362',
+'10206',
+'10355')";
+        $corpsOffRtuDevice = $this->temSelect($sql14);
+        $sensorList['corpsOffRtuDeviceNumber'] =$corpsOffRtuDevice[0]['corpsOffRtuDeviceNumber'];
+        return json_encode($sensorList);
+    }
+
+    public function s_curl($url,$data='',$header="",$method="POST"){
+        $ch = curl_init() ;
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
+
+        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+        /*   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');*/
+        //  curl_setopt($ch, CURLOPT_VERBOSE, 1); //debugģʽ
+        curl_setopt($ch, CURLOPT_SSLCERT, "./server.crt"); //client.crt����
+        curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "IoM@1234"); //client֤������
+        curl_setopt($ch, CURLOPT_SSLKEY, "./server.key");
+        if($method=="POST"||$method=="PUT"||$method=="DELETE"){
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        }
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        $info = curl_exec($ch);
+        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        if (curl_errno($ch)) {
+            $infores =  curl_error($ch);
+        }else{
+            $infores = $info;
+        }
+        curl_close($ch);
+        return $infores;
+    }
+
+    public function ypxycurl($url,$data=''){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $info = curl_exec($ch);
+        if (curl_errno($ch)) {
+            $info = 'ERROR: ' . curl_error($ch);
+        }
+        curl_close($ch);
+        return $info;
+    }
+
+    public function ywManagementCurl($url,$header,$data=''){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+//        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $info = curl_exec($ch);
+        if (curl_errno($ch)) {
+            $info = 'ERROR: ' . curl_error($ch);
+        }
+        curl_close($ch);
+        return $info;
+    }
+
+    public function temSelect($sql)
+    {
+        $link = mysqli_connect('47.98.201.187', 'root', 'Yt2018IoT', 'Temporary data', 3306);
+        mysqli_query($link,"set character set 'utf8'");
+        $res1 = mysqli_query($link,$sql);
+//    Log::record('res'.':'.$res1);
+        $list=array();
+        while ($row = $res1->fetch_assoc()) {
+            $list[]=$row;
+            //print_r($row);
+        }
+        mysqli_free_result($res1);
+        mysqli_close($link);
+        return $list;
+
+    }
+}

+ 0 - 0
admin/controller/Manage.php.bak.20210419 → application/admin/controller/Manage.php.bak.20210419


+ 0 - 0
admin/controller/Manage.php.bak.20210625 → application/admin/controller/Manage.php.bak.20210625


+ 0 - 0
admin/controller/Manage.php.bak.20210720 → application/admin/controller/Manage.php.bak.20210720


+ 0 - 0
admin/controller/Manage.php.bak.20210808 → application/admin/controller/Manage.php.bak.20210808


+ 0 - 0
admin/controller/Manage.php.bak.20210824 → application/admin/controller/Manage.php.bak.20210824


+ 0 - 0
admin/controller/Manage.php.bak.20211028 → application/admin/controller/Manage.php.bak.20211028


+ 0 - 0
admin/controller/Manage.php.bak.20220106 → application/admin/controller/Manage.php.bak.20220106


+ 0 - 0
admin/controller/Manage.php.bak.20220111 → application/admin/controller/Manage.php.bak.20220111


+ 0 - 0
admin/controller/Manage.php → application/admin/controller/Manage.php.bak.20220227


+ 1898 - 0
application/admin/controller/Manage.php.bak.20221229

@@ -0,0 +1,1898 @@
+<?php
+namespace app\admin\controller;
+use think\Controller;
+use think\Session;
+use think\Db;
+use think\Request;
+use think\Log;
+class Manage extends Controller
+{  
+ 	private $host="https://device.api.ct10649.com:8743/";
+    private $appId="wvdOfp7JVe0ULwnFKwBF0edfbcAa";
+    private $secret="Bihoe_rY9vebXMw6sFfpQy0jiRca";
+
+ 	public function index(){
+ 		$data_list =Db::table('managelog')->paginate();
+        $pages = $data_list->render();        
+        $this->assign('data_list', $data_list);
+        $this->assign('pages', $pages); 
+
+
+        	//所有的服务类型
+        $SetType=[
+        	1=>"读取模块信息",
+        	2=>"读取参数",
+        	3=>"设置IOT平台IP地址",
+        	4=>"设置参数",
+        	5=>"复位模块",
+        	6=>"配置下行波特率",
+        	7=>"读取下行波特率配置",
+        	8=>"设置DTU自动采集指令",
+        	9=>"读取DTU自动采集指令",
+        	10=>"设置APN",
+        	11=>"读取APN设置",
+        	12=>"AT指令",
+
+   /*     		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
+        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
+        		[12,"AT指令"]*/
+        ];
+
+        $this->assign('SetType',$SetType);
+        
+        return $this->fetch();
+
+
+ 	}
+ 	//下发命令
+ 	public function add(){
+
+ 		if ($this->request->isPost()) {
+            $data=input('');
+            $list = array();
+            if (is_array($data)) {
+                $list['data'] = json_encode($data, 320);
+                $getdata = json_decode($list['data'], true);//转成数组
+                $list['type'] = 1;
+            } else {
+                $list['data'] = $data;
+                $getdata = json_decode($list['data'], true);//转成数组
+                $list['type'] = 2;
+            }
+            $json_string = json_encode($getdata, JSON_FORCE_OBJECT);
+            Log::record('rawData:' .$list['data'] );
+            $paras = array();
+            $upData = array();
+            if(!empty($getdata["dataType"])){
+                if($getdata['dataType']=="setting"){
+                    $sql6="select * from sp_owner where id ={$getdata['sensorId']}";
+                    $longHuOwner = add($sql6);
+                    if ($longHuOwner[0]['s_interval']==7){
+                        $imei='&imei='.$longHuOwner[0]['owner_code'];
+                        if($longHuOwner[0]['dwtype']==2){
+                            $deviceType=1;
+                        }elseif ($longHuOwner[0]['dwtype']==5){
+                            $deviceType=2;
+                        }
+                        $sendata['imei']=$longHuOwner[0]['owner_code'];
+                        $sendata['deviceType']=$deviceType;
+                        $sendingGap = '';
+                        if (!empty($getdata["sendTime"])){
+                            if($getdata['sendTime']<1800) {
+                                $sendingGap = '&sendingGap=1800';
+                                $upData['send_time'] = 1800;
+                                $sendata['sendingGap']=1800;
+                            }else{
+                                $sendingGap = '&sendingGap='.$getdata["sendTime"];
+                                $upData['send_time'] = $getdata["sendTime"];
+                                $sendata['sendingGap']=$getdata["sendTime"];
+                            }
+                        }
+                        $unipathThresholdLimit = '';
+                        if (!empty($getdata["lowThreshold"])){
+                            $sendata['unipathThresholdLimit'] = $getdata["lowThreshold"]*1000;
+                            $upData['low_threshold'] = $getdata['lowThreshold'];
+                        }
+                        $unipathThresholdUpper = '';
+                        if (!empty($getdata["highThreshold"])){
+                            $sendata['unipathThresholdUpper'] = $getdata["highThreshold"]*1000;
+                            $upData['high_threshold'] = $getdata['highThreshold'];
+                        }
+
+                        $header=[
+                            "Content-Type:application/json"
+                        ];
+                        $rescurl=$this->s_curl("https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052",json_encode($sendata),$header);
+//                        $rep_url = "https://api.topsailiot.com/dmp/deviceConfig?appkey=3a3e533818a9604dfec0388b2d817dbc2f9f7b05dd4b153c403897cd93a9c04d0edfe3d86ebd3ad0&userid=TS2020120110122980052".$imei.$deviceType.$sendingGap.$unipathThresholdLimit.$unipathThresholdUpper;
+//                        $res = $this->s_curl($rep_url,'');
+                        Log::record('longhulorasend' . ':' . json_encode($sendata));
+                        Log::record('longhuloraresult' . ':' . $rescurl);
+//                        if (is_array($rescurl)) {
+//
+//                        }else{}
+                        $resArr = json_decode($rescurl,true);
+                        if ($resArr['code']==0){
+                            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->find();
+                            if (!empty($deviceConfigure['device_code'])) {
+                                sleep(1);
+                                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($longHuOwner[0]['owner_code']))->update($upData);
+                            }else{
+                                sleep(1);
+                                $upData['device_code'] = $longHuOwner[0]['owner_code'];
+                                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
+                            }
+                        }
+                        return $rescurl;
+                    }else{
+                        $deviceCode = '';
+                        $deviceArr = str_split($longHuOwner[0]['owner_code'],1);
+                        for ($i=0;$i<count($deviceArr);$i++){
+                            $deviceCode.='3'.$deviceArr[$i];
+                        }
+                        $deviceCode = $deviceCode.'30';
+                        $sendingInterval = "";//发送间隔
+                        if (!empty($getdata['sendTime'])) {
+                            if($getdata['sendTime']<1800){
+                                $sendingInterval = "020400000708";
+                                $upData['send_time'] = 1800;
+                            }else{
+                                $liuSendTime1 = dechex($getdata['sendTime']);
+                                $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
+                                $sendingInterval = "0204".$liuSendTime;
+                                $upData['send_time'] = $getdata['sendTime'];
+                            }
+                        }
+                        $lowThreshold = "";//告警下限
+                        if (!empty($getdata['lowThreshold'])) {
+                            $shiLowThreshold = $getdata['lowThreshold']*1000;
+                            $liuLowThreshold1 = dechex($shiLowThreshold);
+                            $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
+                            $lowThreshold = "0602".$liuLowThreshold;
+                            $upData['low_threshold'] = $getdata['lowThreshold'];
+                        }
+                        $highThreshold = "";//告警上限
+                        if (!empty($getdata['highThreshold'])) {
+                            $shiHighThreshold = $getdata['highThreshold']*1000;
+                            $liuHighThreshold1 = dechex($shiHighThreshold);
+                            $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
+                            $highThreshold = "0702".$liuHighThreshold;
+                            $upData['high_threshold'] = $getdata['highThreshold'];
+                        }
+                        if($longHuOwner[0]['dwtype']==2){
+                            $dwType = "01";
+                        }elseif ($longHuOwner[0]['dwtype']==5){
+                            $dwType = "02";
+                        }
+                        $shiLength = strlen($dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold)/2;
+                        $liuLength = dechex($shiLength);
+                        $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
+                        //调用电信接口
+                        $token=json_decode(gettoken(),true);
+                        $a = "7470736c04".$length.$dwType.$deviceCode.$sendingInterval.$lowThreshold.$highThreshold;
+                        $s = pack('H*',$a);
+                        $t = crc166($s);
+                        $t = unpack("H*", $s.$t);
+                        $paras['value'] = $t[1]."696f74";
+                        //            $t = crc16($paras['value'],0X1021,0Xffff,0X0000,false,false);
+                        $device = Db::name('device')->where('device_id', trim($longHuOwner[0]['owner_code']))->find();
+                        $sendata=[
+                            "appId"=>$this->appId,
+                            "deviceId"=>$device['iot_id'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
+                            "command"=>[
+                                "serviceId"=>"topsailSensorData",
+                                "method"=>"SET_DEVICE_LEVEL",
+                                "paras"=>$paras
+                            ],
+                            "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
+                        ];
+                        $header=[
+                            "Content-Type:application/json",
+                            "app_key:".$this->appId,
+                            "Authorization:Bearer ".$token["accessToken"]
+                        ];
+                        $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
+//                var_dump($rescurl);
+                        Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
+                        if($rescurl[0]==201){//成功
+                            $res1=json_decode($rescurl[1],true);
+//                    var_dump($res1);
+                        }else{//失败
+                            //  $res2=json_decode($res1[1],true);
+//                    return $this->error($rescurl[1]);
+                            Log::record('nbmanageerror:' .json_encode($this->error($rescurl[1])));
+                            $returnInformation['code'] = 60001;
+                            $returnInformation['msg'] = "操作失败,请联系管理员";
+                            return json_encode($returnInformation);
+                        }
+                    }
+                }else if($getdata['dataType']=="bendi"){
+                    $deviceCode = '';
+                    $deviceArr = str_split($getdata['IMEI'],1);
+                    for ($i=0;$i<count($deviceArr);$i++){
+                        $deviceCode.='3'.$deviceArr[$i];
+                    }
+                    $deviceCode = $deviceCode.'30';
+                    //调用电信接口
+                    $collectionInterval = "";//发送间隔
+                    if (!empty($getdata['collectionTime'])) {
+                        $liuCollectionTime1 = dechex($getdata['collectionTime']);
+                        $liuCollectionTime = str_pad($liuCollectionTime1,8,0,STR_PAD_LEFT);
+                        $collectionInterval = "0104".$liuCollectionTime;
+                    }
+                    $sendingInterval = "";//发送间隔
+                    if (!empty($getdata['sendTime'])) {
+                        $liuSendTime1 = dechex($getdata['sendTime']);
+                        $liuSendTime = str_pad($liuSendTime1,8,0,STR_PAD_LEFT);
+                        $sendingInterval = "0204".$liuSendTime;
+                    }
+                    $lowThreshold = "";//告警下限
+                    if (!empty($getdata['alarmLowerLimit'])) {
+                        $shiLowThreshold = $getdata['alarmLowerLimit']*1000;
+                        $liuLowThreshold1 = dechex($shiLowThreshold);
+                        $liuLowThreshold = str_pad($liuLowThreshold1,4,0,STR_PAD_LEFT);
+                        $lowThreshold = "0602".$liuLowThreshold;
+                    }
+                    $highThreshold = "";//告警上限
+                    if (!empty($getdata['alarmUpperLimit'])) {
+                        $shiHighThreshold = $getdata['alarmUpperLimit']*1000;
+                        $liuHighThreshold1 = dechex($shiHighThreshold);
+                        $liuHighThreshold = str_pad($liuHighThreshold1,4,0,STR_PAD_LEFT);
+                        $highThreshold = "0702".$liuHighThreshold;
+                    }
+                    if($getdata['deviceType']==2){
+                        $dwType = "01";
+                    }elseif ($getdata['deviceType']==5){
+                        $dwType = "02";
+                    }
+                    $shiLength = strlen($dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold)/2;
+                    $liuLength = dechex($shiLength);
+                    $length = str_pad($liuLength,4,0,STR_PAD_LEFT);
+                    //调用电信接口
+                    $token=json_decode(gettoken(),true);
+                    $a = "7470736c04".$length.$dwType.$deviceCode.$collectionInterval.$sendingInterval.$lowThreshold.$highThreshold;
+                    $s = pack('H*',$a);
+                    $t = crc166($s);
+                    $t = unpack("H*", $s.$t);
+                    $paras['value'] = $t[1]."696f74";
+                    $sendata=[
+                        "appId"=>$this->appId,
+                        "deviceId"=>$getdata['deviceId'],//  c448d5e3-2ec5-4e42-99d7-0ad27668614f  137effbe-4980-4719-a768-0ae301fc5000
+                        "command"=>[
+                            "serviceId"=>"topsailSensorData",
+                            "method"=>"SET_DEVICE_LEVEL",
+                            "paras"=>$paras
+                        ],
+                        "callbackUrl"=>"http://iot.usky.cn:80/ytapi/admin/Manage/status",
+                    ];
+                    $header=[
+                        "Content-Type:application/json",
+                        "app_key:".$this->appId,
+                        "Authorization:Bearer ".$token["accessToken"]
+                    ];
+                    $rescurl=curl($this->host."iocm/app/cmd/v1.4.0/deviceCommands",json_encode($sendata),$header);
+                    var_dump($rescurl);
+                    Log::record('nbmanage1:' .$rescurl[0].$sendata['command']['paras']['value'] );
+                    if($rescurl[0]==201){//成功
+                        $res1=json_decode($rescurl[1],true);
+//                    var_dump($res1);
+                    }else{//失败
+                        //  $res2=json_decode($res1[1],true);
+                        return $this->error($rescurl[1]);
+                    }
+                }else{
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,请联系管理员";
+                    return json_encode($returnInformation);
+                }
+            }else{
+                $returnInformation['code'] = 60001;
+                $returnInformation['msg'] = "操作失败,请联系管理员";
+                return json_encode($returnInformation);
+            }
+          //将请求的结果存入managelog中
+
+            $list=array();
+            $list['commandId']=$res1['commandId'];
+            $list['deviceId']=$res1['deviceId'];
+            $list['status']=$res1['status'];
+            $list['command']= json_encode($res1['command'],320) ;
+            if($getdata['dataType']=="setting"){
+                $list['IMEI']=$longHuOwner[0]['owner_code'];
+            }else{
+                $list['IMEI']=$getdata['IMEI'];
+            }
+            $list['HexStr']=json_encode($upData,320) ;;
+            $list['settype']="";
+            $list['addtime']= date('Y-m-d H:i:s');
+            $res = Db::name('managelog')->insertGetId($list);//将推送的数据存入总表
+            if($res) {
+                $returnInformation['code'] = 200;
+                $returnInformation['msg'] = "操作成功";
+                if($getdata['dataType']=="setting"){
+                    return json_encode($returnInformation);
+                }else{
+                    return $this->success('添加成功','index');
+                }
+            }else{
+                $returnInformation['code'] = 60001;
+                $returnInformation['msg'] = "操作失败,请联系管理员";
+                if($getdata['dataType']=="setting"){
+                    return json_encode($returnInformation);
+                }else{
+                    return $this->error("添加失败,请稍后再试");
+                }
+            }
+         }
+
+        if($this->request->isGet()){
+        	$deviceId=input('deviceId');
+        	$IMEI=input('IMEI');
+
+
+        	//所有的服务类型
+        	$SetType=[
+        		[1,"读取模块信息"],[2,"读取参数"],[3,"设置IOT平台IP地址"],[4,"设置参数"],[5,"复位模块"],[6,"配置下行波特率"],
+        		[7,"读取下行波特率配置"],[8,"设置DTU自动采集指令"],[9,"读取DTU自动采集指令"],[10,"设置APN"],[11,"读取APN设置"],
+        		[12,"AT指令"]
+        	];
+
+        	$this->assign('SetType',$SetType);
+        	$this->assign('deviceId',$deviceId);
+       		$this->assign('IMEI', $IMEI); 
+        	return $this->fetch();
+        }
+ 	}
+
+  	public function status(){
+ 		$data=input('');
+
+ 		
+        	if(is_array($data)){
+                	$getdata= json_encode($data,320);
+                	$getdata=json_decode($getdata,true);//转成数组
+                	$list['type']=1;
+         
+                }else{
+                	$getdata=$data;
+              		$getdata=json_decode($getdata,true);//转成数组
+                	$list['type']=2;
+
+                }
+             	$list=array();
+                $list['deviceId']=$getdata['deviceId'];
+                $list['commandId']=$getdata['commandId']; 
+                $list['resultCode']=$getdata['result']['resultCode']; 
+                $list['result']= json_encode($getdata['result'],320) ;
+                $list['addtime']= date('Y-m-d H:i:s');
+ 				$res = Db::name('managedata')->insertGetId($list);//将推送的数据存入总表
+        if($getdata['result']['resultCode']=='SENT'||$getdata['result']['resultCode']=='TIMEOUT'||$getdata['result']['resultCode']=='DELIVERED'||$getdata['result']['resultCode']=='SUCCESSFUL'){
+            $device = Db::name('device')->where('iot_id', trim($getdata['deviceId']))->find();
+            $deviceConfigure = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->find();
+            $managelog = Db::name('managelog')->where('commandId', trim($getdata['commandId']))->find();
+            $upData = json_decode($managelog['HexStr'],true);
+            if (!empty($deviceConfigure['device_code'])) {
+                sleep(1);
+                $upDataRes = Db::name('deviceConfigure')->where('device_code', trim($device['device_id']))->update($upData);
+            }else{
+                sleep(1);
+                $upData['device_code'] = $device['device_id'];
+                $insertRes = Db::name('deviceConfigure')->insertGetId($upData);
+            }
+        }
+ 		echo    111;
+
+ 	}
+
+ 	public function delete(){
+ 			echo   111;
+ 	}
+
+    public function manualPush(){
+        $data=input('');
+        if(is_array($data)){
+            $getdata= json_encode($data,320);
+            $getdata=json_decode($getdata,true);//转成数组
+            $list['type']=1;
+
+        }else{
+            $getdata=$data;
+            $getdata=json_decode($getdata,true);//转成数组
+            $list['type']=2;
+
+        }
+        if ($getdata['deviceType']==2){
+            $sql6="select * from sp_sj2017 where device_code ='{$getdata["deviceCode"]}'";
+            $longHuOwner = add($sql6);
+            Log::record('yangpuxiaoyuan12' . ':' . $longHuOwner[0]["id"]);
+            foreach ($longHuOwner as $row) {
+                $waterData["SubType"] = 2;
+                $waterData["DeviceId"] = $getdata["deviceCode"];
+                $waterData["InsertId"] = $row["id"];
+                $waterData["Confirmed"] = false;
+                $data6 = json_encode($waterData);
+                $rep_url = "http://47.98.201.187:55335/report";
+                $res = $this->ypxycurl($rep_url, $data6);
+                Log::record('yangpuxiaoyuan' . ':' . $res);
+                sleep(1);
+            }
+        }
+        echo    111;
+
+    }
+
+    public function deviceList(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $clientIp=$this->ip();
+        Log::record('yangpuerqi_deviceList' . ':' .'<<<'.$clientIp.'>>>'.$getDataJson);
+        $allowIp = ['222.69.148.83','120.253.238.34','114.86.176.11','120.253.238.37','218.242.51.14'];
+//        if (!in_array($clientIp, $allowIp)){
+//            $returnInformation['code'] = 60001;
+//            $returnInformation['msg'] = "操作失败,IP地址不在白名单中";
+//            $returnInformation['data']=null;
+//            return json_encode($returnInformation);
+//        }else{
+            if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
+                if ($getdata["userName"]=="sgec68" && $getdata["userPassword"]=="sgec68123"){
+                    if(!empty($getdata['commandType'])){
+                        if($getdata['commandType']=="FRONTPAGE"){
+                            $sql="select device_code as deviceCode,device_name as deviceName,CONVERT(type, UNSIGNED INTEGER) as deviceType,type_name as deviceTypeName,unitinfo as deviceAddress,CONVERT(louyu, UNSIGNED INTEGER) as deviceFloor,company_name as companyName,company_code as companyCode,contacts,contacts_phone as contactsPhone,address as detailedAddress,street,posistion,time as dataTime,'在线' as status from sp_v_yp_device";
+                            $res=add($sql);
+                            if (!empty($res)){
+                                $returnInformation['code'] = 0;
+                                $returnInformation['msg'] = "操作成功";
+                                $returnInformation['data']=$res;
+                                return json_encode($returnInformation);
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                        }else{
+                            $returnInformation['code'] = 60001;
+                            $returnInformation['msg'] = "操作失败,参数错误";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                    }else{
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,参数为空";
+                        $returnInformation['data']=null;
+                        return json_encode($returnInformation);
+                    }
+                }else{
+                    $returnInformation['code'] = 60002;
+                    $returnInformation['msg'] = "操作失败,用户名或密码错误";
+                    $returnInformation['data']=null;
+                    return json_encode($returnInformation);
+                }
+            }else{
+                $returnInformation['code'] = 60002;
+                $returnInformation['msg'] = "操作失败,用户名或密码为空";
+                $returnInformation['data']=null;
+                return json_encode($returnInformation);
+            }
+//        }
+    }
+
+    //杨浦城运中心设备基础信息注册
+    public function deviceInfoRegister()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $data1 = Db::query("select sensorId,sensorType,sensorName,CONCAT(companyName,address) AS address,wsLng,wsLat,dataCode,applyId,cityId,areaId,regionId,projectCode from yp_ywtg_configure where id >{$getdata["id"]}");
+//        $rep_url = "http://220.196.241.22:8000/api-projectdatamanage/equipmentsync/sync";
+//        $header=[
+//            "Content-Type:application/json",
+//            "Authenticator:eyJhbGciOiJIUzI1NiJ9.eyJyZWFsTmFtZSI6Iumfqeato-S5iSIsInJvbGVJZHMiOiIxMSIsIm9yZ0NvZGUiOiJYIiwibG9naW5OYW1lIjoiaGFuenkiLCJwbGF0Zm9ybUlkIjpudWxsLCJleHAiOjE2Mzc2NjQ1MDMsInVzZXJJZCI6MTAwNiwib3JnSWQiOjF9.H_xzdQ9jdcndOCsYU9z3cZ-oBk4FtdxJk9wxC0AaZvE"
+//        ];
+//        $res = $this->ywManagementCurl($rep_url,$header,json_encode($data1));
+        return json_encode($data1);
+    }
+
+    public function alarmHandling(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=1;
+
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=2;
+
+        }
+        Log::record('yangpuerqi_alarmHandling' . ':' .$getDataJson);
+        if ($getdata['confirmAll']==""){
+            $getdata['confirmAll']=0;
+        }
+
+        if ($getdata['misinformation']==""){
+            $getdata['misinformation']=0;
+        }
+
+
+        if (!empty($getdata['userName']) && !empty($getdata['userPassword'])){
+            if ($getdata["userName"]=="ypsgec" && $getdata["userPassword"]=="ypsgec123"){
+                if (empty($getdata['recordId'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少记录Id";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['deviceCode'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少设备编号";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['deviceType'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少设备类型";
+                    return json_encode($returnInformation);
+                }elseif ($getdata['confirmAll']!=0&&$getdata['confirmAll']!=1){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少是否批量处理类型";
+                    return json_encode($returnInformation);
+                }elseif ($getdata['misinformation']!=0&&$getdata['misinformation']!=1){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少是否误报字段";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['handlerName'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少处理人姓名";
+                    return json_encode($returnInformation);
+                }elseif (empty($getdata['handlerPhone'])){
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,缺少处理人联系方式";
+                    return json_encode($returnInformation);
+                }
+//                else{
+//                    $returnInformation['code'] = 0;
+//                    $returnInformation['msg'] = "操作成功";
+//                    return json_encode($returnInformation);
+//                }
+
+
+//                echo 'aaaaaaa';
+//                exit();
+                switch ($getdata['deviceType']) {
+                    case '1':
+                        $tab="sp_hj2017";
+                        break;
+                    case '2':
+                        $tab="sp_sj2017";
+                        break;
+                    case '6':
+                        $tab="sp_rtu2017";
+                        break;
+                    case '7':
+                        $tab="sp_ef2017";
+                        break;
+//                    case '16':
+//                        $tab="sp_video2017";
+//                        break;
+                    default:
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,缺少设备类型";
+                        return json_encode($returnInformation);
+                        break;
+                }
+
+                $time = date('Y-m-d h:i:s', time());
+
+                if ($getdata['confirmAll']==0){
+                    $where = " where id=".$getdata['recordId']." and device_code='".$getdata['deviceCode']."' and clzt='0'";
+                }else{
+                    $where = " where device_code='".$getdata['deviceCode']."' and clzt='0'";
+                }
+                $sql="UPDATE ".$tab." SET clsj='".$time."',clr='".$getdata['handlerName']."',clnr='".$getdata['processingContent']."',clwb='".$getdata['misinformation']."',cldh='".$getdata['handlerPhone']."',clzt=1 ".$where;
+//                echo $sql;
+//               print_r($sql);
+//               exit();
+                $res=addDataInfo($sql);
+                if ($res){
+                    $returnInformation['code'] = 0;
+                    $returnInformation['msg'] = "操作成功";
+                    return json_encode($returnInformation);
+                }else{
+                    $returnInformation['code'] = 60001;
+                    $returnInformation['msg'] = "操作失败,参数错误";
+                    return json_encode($returnInformation);
+                }
+            }else{
+                $returnInformation['code'] = 60002;
+                $returnInformation['msg'] = "操作失败,用户名或密码错误";
+                return json_encode($returnInformation);
+            }
+        }else{
+            $returnInformation['code'] = 60002;
+            $returnInformation['msg'] = "操作失败,用户名或密码为空";
+            return json_encode($returnInformation);
+        }
+    }
+
+    public function ip() {
+        //strcasecmp 比较两个字符,不区分大小写。返回0,>0,<0。
+        if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
+            $ip = getenv('HTTP_CLIENT_IP');
+        } else if (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
+            $ip = getenv('HTTP_X_FORWARDED_FOR');
+        } else if (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
+            $ip = getenv('REMOTE_ADDR');
+        } else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
+            $ip = $_SERVER['REMOTE_ADDR'];
+        }
+        $res =  preg_match ( '/[\d\.]{7,15}/', $ip, $matches ) ? $matches [0] : '';
+        return $res;
+        //dump(phpinfo());//所有PHP配置信息
+    }
+
+    public function http_post_advertise1($url,$data){        //封装curl方法
+        $header  = array(
+            'appKey:'.'850404889644236801',
+            'Content-Type:'.'application/json'
+        );
+        $ch = curl_init();     //初始化
+        curl_setopt($ch, CURLOPT_URL, $url);      //请求地址
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_POST, true);
+//https协议需要以下两行,否则请求不成功
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+//post方法所需要的参数
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
+        $result = curl_exec($ch);
+        curl_close($ch);
+        return $result;        //返回所获取的方法
+    }
+
+    public function ytapi_query($sql){
+        $link = mysqli_connect('47.98.201.187', 'root', 'Yt2018IoT', 'jdxf', 3306);
+        mysqli_query($link,"set character set 'utf8'");
+        $res1 = mysqli_query($link,$sql);
+        if($res1==FALSE){
+            return $list=null;
+        }
+        $list=array();
+        while ($row = $res1->fetch_assoc()) {
+            $list[]=$row;
+        }
+        mysqli_free_result($res1);
+        mysqli_close($link);
+        return $list;
+    }
+
+    public function dianQiCeShiUrl(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=1;
+
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+//            $list['type']=2;
+
+        }
+        $number=$getdata['number'];
+        $start_number=$getdata['start_number'];
+        $arr=$this->ytapi_query("select * from a_fire_brigade limit ".$start_number.",".$number);
+//$arr=ytapi_query("select * from a_yc_point_register limit 200,10");
+        $array=[];
+        foreach ($arr as $key=>$value){
+            $array[$key]['descript']=$arr[$key]['descript'];
+            $array[$key]['deviceName']=$arr[$key]['device_name'];
+//    $array[$key]['deviceNo']=$arr[$key]['device_code'].str_replace(',','',$arr[$key]['port']);
+            $array[$key]['deviceNo']=$arr[$key]['device_code'].str_replace(',','',$arr[$key]['port']).$arr[$key]['data'];
+            $array[$key]['deviceType']=$arr[$key]['device_type'];
+            $array[$key]['deviceTypeName']=$arr[$key]['device_type_name'];
+            $array[$key]['openProjectId']=$arr[$key]['open_project_id'];
+        }
+
+        $url1='http://iot.shxf-119.com/access/device/point/register';//新正式路径
+        foreach ($array as $key=>$value){
+//            sleep(2);
+            $data1=[];
+            $data1  = $array[$key];
+            Log::record('fireBrigadeAfferent:' .json_encode($data1));
+            $output= $this->http_post_advertise1($url1,json_encode($data1));
+            echo $output."\n";
+            Log::record('fireBrigadeOutput:' .$output);
+        }
+    }
+
+    public function mt_rand_float($min, $max){
+        return $min +  abs($max-$min) * mt_rand(0,mt_getrandmax())/mt_getrandmax();
+ 	}
+
+    public function randomDate() {
+        $begin = strtotime("now");
+        $end = strtotime("-1 Month");
+        $timestamp = rand($begin, $end);
+        return date("Y-m-d H:i:s", $timestamp);
+    }
+
+    public function ceShiUrl(){
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        Log::record('zhanyejunceshi:' .$getDataJson);
+        return $getDataJson;
+//        $data1 = array();
+//        $data2 = array();
+//        $data4 = array();
+//        $data5 = array();
+//        $data6 = array();
+//        $data7 = array();
+//        $data8 = array();
+//        $data9 = array();
+//        $data10 = array();
+//        $data11 = array();
+//        $data12 = array();
+//        $data15 = array();
+//        $data16 = array();
+//        $data18 = array();
+//        $data19 = array();
+//        for ($i=0;$i<=14;$i++){
+//            $data1['standard_deviation']=round($this->mt_rand_float(1,5),2);
+//            $data1['variance']=round($data1['standard_deviation']*$data1['standard_deviation'],2);
+//            $data1['average_value']=round($this->mt_rand_float(220,227),2);
+//            $j=$i+1;
+//            if($j>=10){
+//                $data1['data_time']="2021-03-".$j;
+//            }
+//            $data2[$i]=$data1;
+//            $data4['standard_deviation']=round($this->mt_rand_float(3,8),2);
+//            $data4['variance']=round($data4['standard_deviation']*$data4['standard_deviation'],2);
+//            $data4['average_value']=round($this->mt_rand_float(7,15),2);
+//            if($j>=10){
+//                $data4['data_time']="2021-03-".$j;
+//            }
+//            $data5[$i]=$data4;
+//            $data6['standard_deviation']=round($this->mt_rand_float(0,2),2);
+//            $data6['variance']=round($data6['standard_deviation']*$data6['standard_deviation'],2);
+//            $data6['average_value']=round($this->mt_rand_float(17,25),2);
+//            if($j>=10){
+//                $data6['data_time']="2021-03-".$j;
+//            }
+//            $data7[$i]=$data6;
+//            $data8['standard_deviation']=round($this->mt_rand_float(30,70),2);
+//            $data8['variance']=round($data8['standard_deviation']*$data8['standard_deviation'],2);
+//            $data8['average_value']=round($this->mt_rand_float(30,60),2);
+//            if($j>=10){
+//                $data8['data_time']="2021-03-".$j;
+//            }
+//            $data9[$i]=$data8;
+//            $data11['electric_current']=round($this->mt_rand_float(8,18),2);
+//            $data11['voltage']=round($this->mt_rand_float(220,225),2);
+//            $data11['data_time']=$this->randomDate();
+//            $data12[$i]=$data11;
+//            $data15['electric_current']=round($this->mt_rand_float(20,100),2);
+//            $data15['voltage']=round($this->mt_rand_float(220,225),2);
+//            $data15['data_time']=$this->randomDate();
+//            $data16[$i]=$data15;
+//            $data18['ambient_temperature']=round($this->mt_rand_float(20,25),2);
+//            $data18['Cable_temperature']=round($this->mt_rand_float(10,20),2);
+//            $data18['generation_temperature']=round($data18['ambient_temperature']-$data18['Cable_temperature'],2);
+//            $data18['data_time']=$this->randomDate();
+//            $data19[$i]=$data18;
+//        }
+//        $data10['conclusion1']="因数据量未达到暂无法分析";
+//        $data3['voltage']=$data2;
+//        $data3['electric_current']=$data5;
+//        $data3['temperature']=$data7;
+//        $data3['leakage_current']=$data9;
+//        $data3['conclusion']=$data10;
+//        $data14['abnormal_equipment']=$data12;
+//        $data14['leakage_alarm']=$data16;
+//        $data14['conclusion']=$data10;
+//        $data20['visualization']=$data19;
+//        $data20['conclusion']=$data10;
+//        $data13['dispersion_rate']=$data3;
+//        $data13['electrical_aging']=$data14;
+//        $data13['thermal_aging']=$data20;
+////        $data1['alarm_number']=$this->mt_rand_float(100,500);
+////        $sensorList['productId'] = round($this->mt_rand_float(3,5),2);
+//        $data17 = json_encode($data13);
+//        return $data17;
+    }
+
+    //水系统电气火灾算法测试API
+    public function algorithmApi(){
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        if(!empty($getdata["dataType"])){
+            if($getdata["dataType"]==1||$getdata["dataType"]==2){
+                if($getdata["dataType"]==1){
+                    if (!empty($getdata["apiType"])){
+                        if ($getdata["apiType"]==4){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select dispersion_rate from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['dispersion_rate'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+
+                        }elseif ($getdata["apiType"]==5){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select leakage_investigation from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['leakage_investigation'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==6){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select device_association from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['device_association'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==7){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_fluctuation from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_fluctuation'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==2){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_statistics from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_statistics'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==3){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    if($getdata["timeType"]==1) {
+                                        $sql6 = "select data4,data1,`time`as dataTime from sp_d864016058809717 where `time` between '2021-07-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==2){
+                                        $sql6 = "select data4,data1,`time`as dataTime from sp_d864016058809717 where `time` between '2021-07-13 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==3){
+                                        $sql6 = "select data4,data1,`time`as dataTime from sp_d864016058809717 where `time` between '2021-06-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }
+                    }else{
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,api类型不能为空";
+                        return json_encode($returnInformation);
+                    }
+                }else{
+                    if (!empty($getdata["apiType"])){
+                        if ($getdata["apiType"]==4){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select dispersion_rate from sp_ef_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['dispersion_rate'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+
+                        }elseif ($getdata["apiType"]==5){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select electrical_aging from sp_ef_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['electrical_aging'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==6){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select thermal_aging from sp_ef_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['thermal_aging'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==7){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_fluctuation from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_fluctuation'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==2){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    $sql6="select data_statistics from sp_water_analysis where company_code ='{$getdata["companyCode"]}' and data_type ={$getdata["timeType"]}";
+                                    $longHuOwner = add($sql6);
+                                    $returnInformation['code'] = 200;
+                                    $returnInformation['msg'] = "success";
+                                    $returnInformation['data']=$longHuOwner[0]['data_statistics'];
+                                    return stripslashes(json_encode($returnInformation));
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }elseif ($getdata["apiType"]==3){
+                            if(!empty($getdata["timeType"])){
+                                if (!empty($getdata["companyCode"])){
+                                    if($getdata["timeType"]==1) {
+                                        $sql6 = "select point_data,point_code,data_time from sp_e00003215010144 where data_time between '2021-07-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==2){
+                                        $sql6 = "select point_data,point_code,data_time from sp_e00003215010144 where data_time between '2021-07-13 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }elseif ($getdata["timeType"]==3){
+                                        $sql6 = "select point_data,point_code,data_time from sp_e00003215010144 where data_time between '2021-06-20 00:00:00' and '2021-07-20 15:00:00'";
+                                        $longHuOwner = add($sql6);
+                                        $returnInformation['code'] = 200;
+                                        $returnInformation['msg'] = "success";
+                                        $returnInformation['data'] = $longHuOwner;
+                                        return stripslashes(json_encode($returnInformation));
+                                    }
+                                }else{
+                                    $returnInformation['code'] = 60001;
+                                    $returnInformation['msg'] = "操作失败,单位编号不能为空";
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60001;
+                                $returnInformation['msg'] = "操作失败,时间类型不能为空";
+                                return json_encode($returnInformation);
+                            }
+                        }
+                    }else{
+                        $returnInformation['code'] = 60001;
+                        $returnInformation['msg'] = "操作失败,api类型不能为空";
+                        return json_encode($returnInformation);
+                    }
+                }
+            }else{
+                $returnInformation['code'] = 60001;
+                $returnInformation['msg'] = "操作失败,数据范围超出限制";
+                return json_encode($returnInformation);
+            }
+        }else{
+            $returnInformation['code'] = 60001;
+            $returnInformation['msg'] = "操作失败,数据类型不能为空";
+            return json_encode($returnInformation);
+        }
+    }
+
+    public function ceshiApi()
+    {
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $data1 = array();
+        $data2 = array();
+        $data3 = array();
+        $data4 = array();
+        if ($getdata['status']=="getnewslist"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['zhaiyao']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+                $data2['click']=1;
+                $data2['img_url']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fs10.sinaimg.cn%2Forignal%2F4a8a8049ga9eae999a909&refer=http%3A%2F%2Fs10.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=f95e7303fda34bef3751916ee036b4a9";
+                $data3[$i]=$data2;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getnew"){
+            $data1['status']=0;
+            $data2['id']=1;
+            $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+            $data2['add_time']="2021-08-05 16:48:17";
+            $data2['content']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+            $data2['click']=2;
+            $data3[0]=$data2;
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getimages"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['zhaiyao']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+                $data2['img_url']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn08%2F336%2Fw501h635%2F20180630%2F9d76-hespqrx2645109.jpg&refer=http%3A%2F%2Fn.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=384680be0388ea4c8bd06dfed25d9da3";
+                $data3[$i]=$data2;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getimgcategory"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试".$i;
+                $data3[$i]=$data2;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getthumimages"){
+            $data1['status']=0;
+            for ($i=0;$i<3;$i++){
+                $data2['src']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.article.pchome.net%2F00%2F40%2F91%2F79%2Fpic_lib%2Fs960x639%2Fcountry_field_landscape_photo_EA52058s960x639.jpg&refer=http%3A%2F%2Fimg.article.pchome.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=0fe6c4c3d1a111f5e848695687261303";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getimageInfo"){
+            $data1['status']=0;
+            for ($i=0;$i<1;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['click']=3;
+                $data2['content']="解释的机会就是进口关税打开撒酒疯还是";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getcomments"){
+            $data1['status']=0;
+            for ($i=0;$i<1;$i++){
+                $data2['user_name']="djsjf";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['content']="快速减肥健身看江户时代";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="postcomment"){
+            $data1['status']=0;
+            $data1['message']="啊附加符号方式";
+            return json_encode($data1);
+        }elseif($getdata['status']=="getgoods"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['id']=$i+1;
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['add_time']="2021-08-05 16:48:17";
+                $data2['zhaiyao']="的就是但是绝大多数公开大量上市价格第四季度睡个好觉了";
+                $data2['click']=0;
+                $data2['img_url']="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_360_360%2F5b%2F71%2F3b%2F5b713b0d8f5fb4e4f8759c417b42eefb.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631010162&t=699aab395bae994606f72becd4cbb90d";
+                $data2['sell_price']=214;
+                $data2['market_price']=3446;
+                $data2['stock_quantity']=3446;
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }elseif($getdata['status']=="getdesc"){
+            $data1['status']=0;
+            for ($i=0;$i<2;$i++){
+                $data2['title']="测试高房价结果回复的合法化觉得很简单的事";
+                $data2['content']="<p>的实际开工的开始</p><p align='center'></p>";
+            }
+            $data1['message']=$data3;
+            return json_encode($data1);
+        }
+    }
+
+    //杨浦一网通管各类设备数量
+    public function deviceNumber(){
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $data6 = array();
+        if ($getdata['userName']=="ypywtg"){
+            $sql="SELECT COUNT(*) AS waterNumber FROM sp_owner WHERE dwtype = 2 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res=add($sql);
+            $sql1="SELECT COUNT(*) AS levelNumber FROM sp_owner WHERE dwtype = 5 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res1=add($sql1);
+            $sql2="SELECT COUNT(*) AS smokeSensationNumber FROM sp_owner WHERE dwtype = 3 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res2=add($sql2);
+            $sql3="SELECT COUNT(*) AS rtuNumber FROM sp_owner WHERE dwtype = 6 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res3=add($sql3);
+            $sql4="SELECT COUNT(*) AS videoNumber FROM sp_owner WHERE dwtype = 16 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res4=add($sql4);
+            $sql5="SELECT COUNT(*) AS electricalFireNumber FROM sp_owner WHERE dwtype = 7 AND company in ('10309', '10308', '10307', '10306', '10305', '10304', '10303', '10302', '10301', '10300', '10299', '10298', '10297', '10296', '10295', '10294', '10293', '10292', '10291', '10290', '10289', '10288', '10287', '10286', '10285', '10284', '10283', '10282', '10281', '10280', '10279', '10278', '10277', '10276', '10275', '10274', '10273', '10272', '10271', '10270', '10269', '10268', '10267', '10266', '10265', '10264', '10263', '10262', '10261', '10260', '10259', '10258', '10257', '10256', '10255', '10254', '10253', '10252', '10251', '10250', '10249', '10248', '10246', '10245', '10244', '10243', '10242', '10241', '10240', '10239', '10238', '10237', '10236', '10234');";
+            $res5=add($sql5);
+            $sensorList['waterNumber'] =$res[0]['waterNumber'];
+            $sensorList['levelNumber'] =$res1[0]['levelNumber'];
+            $sensorList['smokeSensationNumber'] =$res2[0]['smokeSensationNumber'];
+            $sensorList['rtuNumber'] =$res3[0]['rtuNumber'];
+            $sensorList['videoNumber'] =$res4[0]['videoNumber'];
+            $sensorList['electricalFireNumber'] =$res5[0]['electricalFireNumber'];
+            $data6 = json_encode($sensorList);
+        }
+        return $data6;
+    }
+
+    //伍继电力程序校验机制api
+    public function wooGiApi(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $clientIp=$this->ip();
+        Log::record('wooGiApi_deviceList' . ':' .'<<<'.$clientIp.'>>>'.$getDataJson);
+        $allowIp = ['101.133.214.75','124.71.174.104','124.71.175.91','124.70.160.158','222.69.148.83','114.95.161.247'];
+//        if (!in_array($clientIp, $allowIp)){
+//            $returnInformation['code'] = 60001;
+//            $returnInformation['msg'] = "操作失败,IP地址不在白名单中";
+//            $returnInformation['data']=null;
+//            return json_encode($returnInformation);
+//        }else{
+            $redis = new \Redis();
+            $redis->connect('127.0.0.1', 6379);
+            $result = $redis->auth("usky2021");
+            $redis->select(1);
+            if ($result == 1) {
+                $check =$redis->exists($clientIp);
+                if ($check){
+                    // +1
+                    $redis->incr($clientIp);
+                    $count =$redis->get($clientIp);
+                    // 限制每小时1次
+                    if($count > 500){
+                        $returnInformation['code'] = 60003;
+                        $returnInformation['msg'] = "操作失败,当前ip请求频率过高";
+                        $returnInformation['data']=null;
+                        return json_encode($returnInformation);
+                    }else{
+                        if (!empty($getdata['publicKey'])){
+                            $publicKey = $getdata['publicKey'];
+                            $timeStamp = time();
+                            if (!empty($getdata['requestType'])){
+                                if($getdata['requestType']==1){
+                                    $publicKey1 = md5("usky".$getdata['timeStamp']."9bcbc5d723cb9bae394d3a097deb6695");
+                                    $publicKey2 = md5("usky".$timeStamp."9bcbc5d723cb9bae394d3a097deb6695");
+                                }else if ($getdata['requestType']==2){
+                                    $publicKey1 = md5("usky".$getdata['timeStamp']."b9848b4fe4647e380fd1367a4f34ced9");
+                                    $publicKey2 = md5("usky".$timeStamp."b9848b4fe4647e380fd1367a4f34ced9");
+                                }else if ($getdata['requestType']==3){
+                                    $publicKey1 = md5("usky".$getdata['timeStamp']."056ac8fae059c9c9e700b734922edfc8");
+                                    $publicKey2 = md5("usky".$timeStamp."056ac8fae059c9c9e700b734922edfc8");
+                                }else{
+                                    $returnInformation['code'] = 60004;
+                                    $returnInformation['msg'] = "操作失败,requestType不在范围内";
+                                    $returnInformation['data']=null;
+                                    return json_encode($returnInformation);
+                                }
+                            }else{
+                                $returnInformation['code'] = 60004;
+                                $returnInformation['msg'] = "操作失败,requestType不能为空";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                            if ($publicKey==$publicKey1){
+                                $sensorList['publicKey'] =$publicKey2;
+                                $sensorList['timeStamp'] =$timeStamp;
+                                $returnInformation['code'] = 200;
+                                $returnInformation['msg'] = "操作成功";
+                                $returnInformation['data']=$sensorList;
+                                return json_encode($returnInformation);
+                            }else{
+                                $returnInformation['code'] = 60002;
+                                $returnInformation['msg'] = "操作失败,publicKey错误";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                        }else{
+                            $returnInformation['code'] = 60004;
+                            $returnInformation['msg'] = "操作失败,publicKey不能为空";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                    }
+                } else {
+                    $redis->set($clientIp, 1,3300);//初始值1
+                    if (!empty($getdata['publicKey'])){
+                        $publicKey = $getdata['publicKey'];
+                        $timeStamp = time();
+                        if (!empty($getdata['requestType'])){
+                            if($getdata['requestType']==1){
+                                $publicKey1 = md5("usky".$getdata['timeStamp']."9bcbc5d723cb9bae394d3a097deb6695");
+                                $publicKey2 = md5("usky".$timeStamp."9bcbc5d723cb9bae394d3a097deb6695");
+                            }else if ($getdata['requestType']==2){
+                                $publicKey1 = md5("usky".$getdata['timeStamp']."b9848b4fe4647e380fd1367a4f34ced9");
+                                $publicKey2 = md5("usky".$timeStamp."b9848b4fe4647e380fd1367a4f34ced9");
+                            }else if ($getdata['requestType']==3){
+                                $publicKey1 = md5("usky".$getdata['timeStamp']."056ac8fae059c9c9e700b734922edfc8");
+                                $publicKey2 = md5("usky".$timeStamp."056ac8fae059c9c9e700b734922edfc8");
+                            }else{
+                                $returnInformation['code'] = 60004;
+                                $returnInformation['msg'] = "操作失败,requestType不在范围内";
+                                $returnInformation['data']=null;
+                                return json_encode($returnInformation);
+                            }
+                        }else{
+                            $returnInformation['code'] = 60004;
+                            $returnInformation['msg'] = "操作失败,requestType不能为空";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                        if ($publicKey==$publicKey1){
+                            $sensorList['publicKey'] =$publicKey2;
+                            $sensorList['timeStamp'] =$timeStamp;
+                            $returnInformation['code'] = 200;
+                            $returnInformation['msg'] = "操作成功";
+                            $returnInformation['data']=$sensorList;
+                            return json_encode($returnInformation);
+                        }else{
+                            $returnInformation['code'] = 60002;
+                            $returnInformation['msg'] = "操作失败,publicKey错误";
+                            $returnInformation['data']=null;
+                            return json_encode($returnInformation);
+                        }
+                    }else{
+                        $returnInformation['code'] = 60004;
+                        $returnInformation['msg'] = "操作失败,publicKey不能为空";
+                        $returnInformation['data']=null;
+                        return json_encode($returnInformation);
+                    }
+                }
+            }
+//        }
+    }
+
+    //伍继电力java程序校验机制api
+    public function wooGiJavaApi(){
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $clientIp=$this->ip();
+        Log::record('wooGiJavaApi_deviceList' . ':' .'<<<'.$clientIp.'>>>'.$getDataJson);
+        $code = 1;
+        if ($code==1){
+            return 1;
+        }else{
+            return 0;
+        }
+    }
+
+    //杨浦学校设备注册api
+    public function ypSchoolApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $sql6="select * from sp_yangpuxy_share where company_code ='{$getdata["deviceCode"]}' and rec_cur=1586416046";
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $cs['deviceId'] = $ypSchoolOwner[$key]['object_code'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['object_name'].$ypSchoolOwner[$key]['device_name'];
+                if ($ypSchoolOwner[$key]['owner_dwtype']==2){
+                    $cs['deviceType'] = "1";
+                    $cs['deviceTypeName'] = "水泵水压检测器";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==128){
+                    $cs['deviceType'] = "4";
+                    $cs['deviceTypeName'] = "井盖探测器";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==3){
+                    $cs['deviceType'] = "3";
+                    $cs['deviceTypeName'] = "烟感检测";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==7){
+                    $cs['deviceType'] = "5";
+                    $cs['deviceTypeName'] = "高低压配电房检测器";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==130){
+                    $cs['deviceType'] = "2";
+                    $cs['deviceTypeName'] = "消防栓";
+                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==1){
+                    $cs['deviceType'] = "3";
+                    $cs['deviceTypeName'] = "烟感检测";
+                }
+                $cs['companyCode'] = $ypSchoolOwner[$key]['company_code'];
+                $cs['companyName'] = $ypSchoolOwner[$key]['company_name'];
+                $data6 = json_encode($cs);
+                $rep_url = "http://ypaqpt.edu.sh.cn/schoolSafe-yp/deviceAdd";
+                $res = $this->ypxycurl($rep_url, $data6);
+                Log::record('yangpuxiaoyuandevice1' . ':' . $data6);
+                Log::record('yangpuxiaoyuandevice2' . ':' . $res);
+                print_r('结果'.$res);
+                print_r($data6);
+                sleep(0.5);
+            }
+        }
+    }
+
+    //消防总队平台主机点位设备注册api
+    public function xfzdAddApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $header=[
+            "Content-Type:application/json",
+            "appKey:850404889644236801"
+        ];
+        $sql6="select * from sp_corps_share_ceshi where open_project_id ='{$getdata["companyCode"]}' and `data` ={$getdata["hostCode"]} limit ".$getdata["startNum"].",".$getdata["endNum"];
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $cs['descript'] = $ypSchoolOwner[$key]['descript'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['device_name'];
+//                if ($ypSchoolOwner[$key]['dwtype']==6){
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'].str_replace(',','',$ypSchoolOwner[$key]['port']).$ypSchoolOwner[$key]['data'];
+//                }else{
+//                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'];
+//                }
+                $cs['deviceType'] = $ypSchoolOwner[$key]['device_type'];
+                $cs['deviceTypeName'] = $ypSchoolOwner[$key]['device_type_name'];
+                $cs['openProjectId'] = $ypSchoolOwner[$key]['open_project_id'];
+                $cs['floor'] = $ypSchoolOwner[$key]['device_floor'];
+                $data6 = json_encode($cs);
+                $rep_url = "http://iot.shxf-119.com/access/device/point/register";
+                $res = $this->ywManagementCurl($rep_url,$header,$data6);
+                Log::record('xiaofangzongduidevice1' . ':' . $data6);
+                Log::record('xiaofangzongduidevice2' . ':' . $res);
+                print_r('结果'.$res);
+                print_r($data6);
+                sleep(0.5);
+            }
+        }
+    }
+
+    //消防总队平台主机点位设备注册api
+    public function xfzdDeviceAddApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $header=[
+            "Content-Type:application/json",
+            "appKey:850404889644236801"
+        ];
+        $sql6="select * from sp_corps_share where open_project_id ='{$getdata["companyCode"]}' limit ".$getdata["startNum"].",".$getdata["endNum"];
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $cs['descript'] = $ypSchoolOwner[$key]['descript'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['device_name'];
+                if ($ypSchoolOwner[$key]['dwtype']==6){
+                $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'].$ypSchoolOwner[$key]['port'];
+                }else{
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'];
+                }
+                $cs['deviceType'] = $ypSchoolOwner[$key]['device_type'];
+                $cs['deviceTypeName'] = $ypSchoolOwner[$key]['device_type_name'];
+                $cs['openProjectId'] = $ypSchoolOwner[$key]['open_project_id'];
+                $cs['floor'] = $ypSchoolOwner[$key]['device_floor'];
+                $data6 = json_encode($cs);
+                $rep_url = "http://iot.shxf-119.com/access/device/point/register";
+                $res = $this->ywManagementCurl($rep_url,$header,$data6);
+                Log::record('xiaofangzongduidevice1' . ':' . $data6);
+                Log::record('xiaofangzongduidevice2' . ':' . $res);
+                print_r('结果'.$res);
+                print_r($data6);
+                sleep(0.5);
+            }
+        }
+    }
+
+    //消防总队平台设备数据推送api
+    public function xfzdDeviceInfoAddApi()
+    {
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $header=[
+            "Content-Type:application/json",
+            "appKey:850404889644236801"
+        ];
+        $rep_url1 = "http://iot.shxf-119.com/access/devlog/transmission/devicestatus";//用传
+        $rep_url2 = "http://iot.shxf-119.com/access/devlog/sprinkler/endpressure";//喷淋末端压力
+        $rep_url3 = "http://iot.shxf-119.com/access/devlog/sprinkler/pipepressunusual";//喷淋主管压力
+        $rep_url4 = "http://iot.shxf-119.com/access/devlog/sprinkler/spraypump";//喷淋泵状态
+        $rep_url5 = "http://iot.shxf-119.com/access/devlog/hydrant/endpressure";//消火栓末端压力
+        $rep_url6 = "http://iot.shxf-119.com/access/devlog/hydrant/pipepress";//消火栓主管压力
+        $rep_url7 = "http://iot.shxf-119.com/access/devlog/hydrant/tanklevel";//水箱液位
+        $rep_url8 = "http://iot.shxf-119.com/access/devlog/hydrant/pumpstatus";//消防泵状态
+        $sql6="select * from sp_corps_share where open_project_id ='{$getdata["companyCode"]}'";
+        $ypSchoolOwner = add($sql6);
+        if (!empty($ypSchoolOwner)){
+            foreach ($ypSchoolOwner as $key=>$value){
+                $sql7="select * from sp_owner_status where device_id ='{$ypSchoolOwner[$key]['device_code']}'";
+                $companyOwner = add($sql7);
+                $cs['descript'] = $ypSchoolOwner[$key]['descript'];
+                $cs['deviceName'] = $ypSchoolOwner[$key]['device_name'];
+                if ($ypSchoolOwner[$key]['dwtype']==6){
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'].$ypSchoolOwner[$key]['port'];
+                }else{
+                    $cs['deviceNo'] = $ypSchoolOwner[$key]['device_code'];
+                }
+                $cs['deviceType'] = $ypSchoolOwner[$key]['device_type'];
+                $cs['deviceTypeName'] = $ypSchoolOwner[$key]['device_type_name'];
+                $cs['openProjectId'] = $ypSchoolOwner[$key]['open_project_id'];
+                $cs['floor'] = $ypSchoolOwner[$key]['device_floor'];
+                if ($ypSchoolOwner[$key]['dwtype']==1){
+                    foreach ($companyOwner as $key1=>$value1){
+                        if ($companyOwner[$key1]['point_code']==1){
+                            if(strstr($companyOwner[$key1]['content'],'监测连线故障') !== false) {
+                                $cs['connectStatus'] = "1";
+                            }else{
+                                $cs['connectStatus'] = "0";
+                            }
+                            $cs['workStatus'] = "0";
+                            $cs['mainPower'] = "0";
+                            $cs['logTime'] = date('Y-m-d H:i:s');
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url1,$header,$data6);
+                            print_r('结果'.$res);
+                        }
+                    }
+                }elseif ($ypSchoolOwner[$key]['dwtype']==2){
+                    foreach ($companyOwner as $key1=>$value1){
+                        if ($companyOwner[$key1]['point_code']==4){
+                            $cs['logTime'] = date('Y-m-d H:i:s');
+                            $cs['pressure'] = $companyOwner[$key1]['point_data'];
+                        }elseif ($companyOwner[$key1]['point_code']==1){
+                            if(strstr($companyOwner[$key1]['content'],'正常') !== false) {
+                                $cs['alarmStatus'] = "0";
+                            }elseif (strstr($companyOwner[$key1]['content'],'低压') !== false){
+                                $cs['alarmStatus'] = "1";
+                            }elseif (strstr($companyOwner[$key1]['content'],'高压') !== false){
+                                $cs['alarmStatus'] = "2";
+                            }else{
+                                $cs['alarmStatus'] = "0";
+                            }
+                        }
+                    }
+                    if($ypSchoolOwner[$key]['device_type']==304){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url2,$header,$data6);
+                        print_r('结果'.$res);
+                    }elseif ($ypSchoolOwner[$key]['device_type']==301){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url3,$header,$data6);
+                        print_r('结果'.$res);
+                    }elseif ($ypSchoolOwner[$key]['device_type']==305){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url5,$header,$data6);
+                        print_r('结果'.$res);
+                    }elseif ($ypSchoolOwner[$key]['device_type']==302){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url6,$header,$data6);
+                        print_r('结果'.$res);
+                    }
+                }elseif ($ypSchoolOwner[$key]['dwtype']==5){
+                    foreach ($companyOwner as $key1=>$value1){
+                        if ($companyOwner[$key1]['point_code']==4){
+                            $cs['logTime'] = date('Y-m-d H:i:s');
+                            $cs['level'] = $companyOwner[$key1]['point_data'];
+                        }elseif ($companyOwner[$key1]['point_code']==1){
+                            if(strstr($companyOwner[$key1]['content'],'正常') !== false) {
+                                $cs['alarmStatus'] = "0";
+                            }elseif (strstr($companyOwner[$key1]['content'],'低液位') !== false){
+                                $cs['alarmStatus'] = "1";
+                            }elseif (strstr($companyOwner[$key1]['content'],'高液位') !== false){
+                                $cs['alarmStatus'] = "2";
+                            }else{
+                                $cs['alarmStatus'] = "0";
+                            }
+                        }
+                    }
+                    if($ypSchoolOwner[$key]['device_type']==402){
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url7,$header,$data6);
+                        print_r('结果'.$res);
+                    }else{
+                        $data6 = json_encode($cs);
+                        $res = $this->ywManagementCurl($rep_url7,$header,$data6);
+                        print_r('结果'.$res);
+                    }
+                }elseif ($ypSchoolOwner[$key]['dwtype']==6){
+                    if($ypSchoolOwner[$key]['device_type']==258 || $ypSchoolOwner[$key]['device_type']==256 || $ypSchoolOwner[$key]['device_type']==452){
+                        $cs['logTime'] = date('Y-m-d H:i:s');
+                        $companyOwner1 = $ypSchoolOwner[$key]['data'];
+                        foreach ($companyOwner1 as $key1=>$value1){
+                            if ($companyOwner1[$key1]['port']==-1){
+                                if(strstr($companyOwner1[$key1]['name'],'powerStatus') !== false) {
+                                    $cs['powerState'] = "0";
+                                }elseif (strstr($companyOwner1[$key1]['name'],'runStatus') !== false){
+                                    $cs['manualAutomaticState'] = "0";
+                                }elseif (strstr($companyOwner1[$key1]['name'],'startStatus') !== false){
+                                    $cs['startStopStatus'] = "0";
+                                }elseif (strstr($companyOwner1[$key1]['name'],'faultStatus') !== false){
+                                    $cs['faultStatus'] = "0";
+                                }
+                            }
+                        }
+                        foreach ($companyOwner as $key3=>$value3){
+                            foreach ($companyOwner1 as $key2=>$value2){
+                                if ($companyOwner1[$key2]['port']==$companyOwner[$key3]['point_code'] && $companyOwner[$key3]['point_code']!=0){
+                                    if(strstr($companyOwner[$key3]['content'],'正常') !== false || strstr($companyOwner[$key3]['content'],'自动') !== false || strstr($companyOwner[$key3]['content'],'停止') !== false) {
+                                        if(strstr($companyOwner1[$key2]['name'],'powerStatus') !== false) {
+                                            $cs['powerState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'runStatus') !== false){
+                                            $cs['manualAutomaticState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'startStatus') !== false){
+                                            $cs['startStopStatus'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'faultStatus') !== false){
+                                            $cs['faultStatus'] = "0";
+                                        }
+                                    }elseif (strstr($companyOwner[$key3]['content'],'关闭') !== false || strstr($companyOwner[$key3]['content'],'手动') !== false || strstr($companyOwner[$key3]['content'],'运行') !== false || strstr($companyOwner[$key3]['content'],'故障') !== false){
+                                        if(strstr($companyOwner1[$key2]['name'],'powerStatus') !== false) {
+                                            $cs['powerState'] = "1";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'runStatus') !== false){
+                                            $cs['manualAutomaticState'] = "1";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'startStatus') !== false){
+                                            $cs['startStopStatus'] = "1";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'faultStatus') !== false){
+                                            $cs['faultStatus'] = "1";
+                                        }
+                                    }else{
+                                        if(strstr($companyOwner1[$key2]['name'],'powerStatus') !== false) {
+                                            $cs['powerState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'runStatus') !== false){
+                                            $cs['manualAutomaticState'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'startStatus') !== false){
+                                            $cs['startStopStatus'] = "0";
+                                        }elseif (strstr($companyOwner1[$key2]['name'],'faultStatus') !== false){
+                                            $cs['faultStatus'] = "0";
+                                        }
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                        if ($ypSchoolOwner[$key]['device_type']==258){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url8,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==256){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url4,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==452){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url4,$header,$data6);
+                            print_r('结果'.$res);
+                        }
+                    }else{
+                        $cs['logTime'] = date('Y-m-d H:i:s');
+                        $companyOwner1 = $ypSchoolOwner[$key]['data'];
+                        foreach ($companyOwner as $key2=>$value2) {
+                            foreach ($companyOwner1 as $key3 => $value3) {
+                                if (strstr($companyOwner1[$key3]['name'],'value') !== false){
+                                    if ($companyOwner1[$key3]['port']==$companyOwner[$key2]['point_code'] && $companyOwner[$key2]['point_code']!=0){
+                                        $cs['pressure'] = $companyOwner[$key2]['point_data'];
+                                        if(strstr($companyOwner[$key2]['content'],'正常') !== false) {
+                                            $cs['alarmStatus'] = "0";
+                                        }elseif (strstr($companyOwner[$key2]['content'],'低压') !== false){
+                                            $cs['alarmStatus'] = "1";
+                                        }elseif (strstr($companyOwner[$key2]['content'],'高压') !== false){
+                                            $cs['alarmStatus'] = "2";
+                                        }else{
+                                            $cs['alarmStatus'] = "0";
+                                        }
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+                        if($ypSchoolOwner[$key]['device_type']==304){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url2,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==301){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url3,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==305){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url5,$header,$data6);
+                            print_r('结果'.$res);
+                        }elseif ($ypSchoolOwner[$key]['device_type']==302){
+                            $data6 = json_encode($cs);
+                            $res = $this->ywManagementCurl($rep_url6,$header,$data6);
+                            print_r('结果'.$res);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    //积木测试api
+    public function mhCompanyData()
+    {
+        $data=input('');
+        if(is_array($data)){
+            $getDataJson= json_encode($data,320);
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }else{
+            $getDataJson=$data;
+            $getdata=json_decode($getDataJson,true);//转成数组
+        }
+        $allowKey = ['31cdd6a7766d24820156e5304a3f7107'];
+//        if (!in_array($clientIp, $allowIp)){
+        if (!empty($getdata['app_key']) && in_array($getdata['app_key'], $allowKey)){
+            if (!empty($getdata['app_key'])){
+
+            }
+        }else{
+            $sensorList=[];
+            $returnInformation['code'] = 10001;
+            $returnInformation['msg'] = "app_key参数错误";
+            $returnInformation['data']=$sensorList;
+            return json_encode($returnInformation);
+        }
+    }
+
+    public function s_curl($url,$data='',$header="",$method="POST"){
+        $ch = curl_init() ;
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
+
+        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+        /*   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');*/
+        //  curl_setopt($ch, CURLOPT_VERBOSE, 1); //debugģʽ
+        curl_setopt($ch, CURLOPT_SSLCERT, "./server.crt"); //client.crt����
+        curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "IoM@1234"); //client֤������
+        curl_setopt($ch, CURLOPT_SSLKEY, "./server.key");
+        if($method=="POST"||$method=="PUT"||$method=="DELETE"){
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        }
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        $info = curl_exec($ch);
+        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        if (curl_errno($ch)) {
+            $infores =  curl_error($ch);
+        }else{
+            $infores = $info;
+        }
+        curl_close($ch);
+        return $infores;
+    }
+
+    public function ypxycurl($url,$data=''){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $info = curl_exec($ch);
+        if (curl_errno($ch)) {
+            $info = 'ERROR: ' . curl_error($ch);
+        }
+        curl_close($ch);
+        return $info;
+    }
+
+    public function ywManagementCurl($url,$header,$data=''){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+//        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $info = curl_exec($ch);
+        if (curl_errno($ch)) {
+            $info = 'ERROR: ' . curl_error($ch);
+        }
+        curl_close($ch);
+        return $info;
+    }
+}

+ 0 - 0
admin/controller/Messagepush.php → application/admin/controller/Messagepush.php


+ 148 - 0
application/admin/controller/Onenet.php

@@ -0,0 +1,148 @@
+<?php
+namespace app\admin\controller;
+use think\Controller;
+use think\Session;
+use think\Db;
+use think\Request;
+use think\Log;
+class Onenet extends Controller
+{  
+ 
+ 	
+ 	public function index(){
+
+ 	}
+ 	//下发命令
+ 	public function add(){
+ 
+ 		    
+ 	}
+
+  	public function status(){
+
+
+ 	}
+
+ 	public function delete(){
+ 			
+ 	}
+
+    public function OneNetCeShi(){
+//        if ($this->request->isPost()) {
+        $data = input('');
+
+        /*            $rand=rand(0,2);
+               $header=["Content-Type:application/json"];
+
+               //将数据分配给不同的服务
+               $httpserver=["http://47.98.153.212:1101","http://47.98.153.212:1102","http://47.98.153.212:1103"];
+               $server=$httpserver[$rand];
+
+               //将数据随机转发到别的平台做处理
+                $res=curltest($server,$data,$header);
+         */
+        $list = array();
+        if (is_array($data)) {
+            $list['data'] = json_encode($data, 320);
+            $getdata = json_decode($list['data'], true);//转成数组
+        } else {
+            $list['data'] = $data;
+            $getdata = json_decode($list['data'], true);//转成数组
+
+        }
+        //  $list['data']=11;
+//            $list['response'] = "111";
+//
+//            $list['notifyType'] = $getdata["notifyType"];
+//            $list['deviceId'] = $getdata["deviceId"];
+//            $list['addtime'] = date('Y-m-d H:i:s');
+        $res = Db::name('one_net_data')->insertGetId($list);//将推送的数据存入总表
+        $returnInformation['code'] = 200;
+        $returnInformation['msg'] = "操作成功";
+        Log::record('onenet:' .$getdata['msg'] );
+        return $getdata['msg'];
+//        }
+    }
+
+    //山东党校api
+    public function sdSchoolApi()
+    {
+        header("Access-Control-Allow-Origin:*");
+// 响应类型
+        header('Access-Control-Allow-Methods:POST');
+// 响应头设置
+        header('Access-Control-Allow-Headers:x-requested-with, content-type');
+        $data = input('');
+        if (is_array($data)) {
+            $getDataJson = json_encode($data, 320);
+            $getdata = json_decode($getDataJson, true);//转成数组
+        } else {
+            $getDataJson = $data;
+            $getdata = json_decode($getDataJson, true);//转成数组
+        }
+        $cs['V_LOGINNAME'] = "sddx";
+        $cs['V_PASSWORD'] = "sddx123";
+        $cs['COMPANY_CODE'] = "10321";
+        $cs['COMMSTATUS'] = "NO";
+        $data6 = json_encode($cs);
+        $data = "queryJson=".$data6;
+        $rep_url = "https://fire.usky.cn:8443/YtIoT/iot/frontpage/getCurrentObjectListByCompanyId";
+        $res = $this->ypxycurl($rep_url, $data);
+//        if (!empty($ypSchoolOwner)){
+//            foreach ($ypSchoolOwner as $key=>$value){
+//                $cs['deviceId'] = $ypSchoolOwner[$key]['object_code'];
+//                $cs['deviceName'] = $ypSchoolOwner[$key]['object_name'].$ypSchoolOwner[$key]['device_name'];
+//                if ($ypSchoolOwner[$key]['owner_dwtype']==2){
+//                    $cs['deviceType'] = "1";
+//                    $cs['deviceTypeName'] = "水泵水压检测器";
+//                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==128){
+//                    $cs['deviceType'] = "4";
+//                    $cs['deviceTypeName'] = "井盖探测器";
+//                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==3){
+//                    $cs['deviceType'] = "3";
+//                    $cs['deviceTypeName'] = "烟感检测";
+//                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==7){
+//                    $cs['deviceType'] = "5";
+//                    $cs['deviceTypeName'] = "高低压配电房检测器";
+//                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==130){
+//                    $cs['deviceType'] = "2";
+//                    $cs['deviceTypeName'] = "消防栓";
+//                }elseif ($ypSchoolOwner[$key]['owner_dwtype']==1){
+//                    $cs['deviceType'] = "3";
+//                    $cs['deviceTypeName'] = "烟感检测";
+//                }
+//                $cs['companyCode'] = $ypSchoolOwner[$key]['company_code'];
+//                $cs['companyName'] = $ypSchoolOwner[$key]['company_name'];
+//                $data6 = json_encode($cs);
+//                $rep_url = "http://ypaqpt.edu.sh.cn/schoolSafe-yp/deviceAdd";
+//                $res = $this->ypxycurl($rep_url, $data6);
+//                Log::record('yangpuxiaoyuandevice1' . ':' . $data6);
+//                Log::record('yangpuxiaoyuandevice2' . ':' . $res);
+//                print_r('结果'.$res);
+//                print_r($data6);
+//                sleep(0.5);
+//            }
+//        }
+        return $res;
+    }
+
+    public function ypxycurl($url,$data=''){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HEADER, FALSE);//不抓取头部信息。只返回数据
+        curl_setopt($ch, CURLOPT_TIMEOUT,1000);//超时设置
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//1表示不返回bool值
+        curl_setopt($ch, CURLOPT_POST, TRUE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));//重点
+        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
+        $info = curl_exec($ch);
+        if (curl_errno($ch)) {
+            $info = 'ERROR: ' . curl_error($ch);
+        }
+        curl_close($ch);
+        return $info;
+    }
+ 
+}

+ 0 - 0
admin/controller/Onenet.php → application/admin/controller/Onenet.php.bak.20220301


+ 12 - 1
admin/controller/Order.php → application/admin/controller/Order.php

@@ -690,6 +690,13 @@ class Order extends Controller
                                 $rep_url = "http://47.98.201.73:55125/report";
                                 $res = $this->curl($rep_url,$rep2);
                                 Log::record('TuoPuSuoEr-TSM-04P'.':'.$res);
+                                $waterData["SubType"] = 2;
+                                $waterData["DeviceId"] = $data666['IMEI'];
+                                $waterData["InsertId"] = $insert_id66[0]['id'];
+                                $waterData["Confirmed"] = false;
+                                $data6 = json_encode($waterData);
+                                $rep_url = "http://47.98.201.187:55335/report";
+                                $res = $this->curl($rep_url, $data6);
 
 //                            $url_wx_push2        = "http://www.jd-ioe.com/jdxf/wxapp2.php/Home/Waterwarn/bj";
                                 foreach($op as $key => $o){
@@ -1457,7 +1464,11 @@ class Order extends Controller
                 Log::record('xingyuehui' . ':' . $getdata["device_code"]);
                 $sql6="select * from sp_owner where owner_code ='{$getdata["device_code"]}'";
                 $longHuCompany = add($sql6);
-                $sensorList['sensorId'] = (int)$longHuCompany[0]['id'].(int)$getdata["port"];
+                if($getdata["device_type"]=="water"){
+                    $sensorList['sensorId'] = (int)$longHuCompany[0]['id'];
+                }else{
+                    $sensorList['sensorId'] = (int)$longHuCompany[0]['id'].(int)$getdata["port"];
+                }
                 $sensorList['status'] = 0;
                 $sensorList['desc'] = $longHuCompany[0]['unitinfo'].'-'.$getdata["port_name"].'-压力正常';
                 $data4['deviceType'] = 'XiaoFangShuiYa';

+ 0 - 0
admin/controller/Order.php.bak → application/admin/controller/Order.php.bak


+ 0 - 0
admin/controller/Order.php.bak.20201209 → application/admin/controller/Order.php.bak.20201209


+ 0 - 0
admin/controller/Order.php.bak.20201215 → application/admin/controller/Order.php.bak.20201215


+ 0 - 0
admin/controller/Order.php.bak.20201216 → application/admin/controller/Order.php.bak.20201216


+ 0 - 0
admin/controller/Order.php.bak.20210122 → application/admin/controller/Order.php.bak.20210122


+ 0 - 0
admin/controller/Order.php.bak.20210127 → application/admin/controller/Order.php.bak.20210127


+ 0 - 0
admin/controller/Order.php.bak.20210316 → application/admin/controller/Order.php.bak.20210316


+ 0 - 0
admin/controller/Order.php.bak.20210414 → application/admin/controller/Order.php.bak.20210414


+ 0 - 0
admin/controller/Order.php.bak.20210608 → application/admin/controller/Order.php.bak.20210608


+ 0 - 0
admin/controller/Order.php.bak.20211028 → application/admin/controller/Order.php.bak.20211028


+ 0 - 0
admin/controller/Order.php.bak.20211029 → application/admin/controller/Order.php.bak.20211029


+ 0 - 0
admin/controller/Order.php.bak.20211104 → application/admin/controller/Order.php.bak.20211104


+ 0 - 0
admin/controller/Order.php.bak.20211202 → application/admin/controller/Order.php.bak.20211202


+ 0 - 0
admin/controller/Order.php.bak1 → application/admin/controller/Order.php.bak1


+ 0 - 0
admin/controller/Order.php.bak2 → application/admin/controller/Order.php.bak2


+ 0 - 0
admin/controller/Order.php.bak3 → application/admin/controller/Order.php.bak3


+ 0 - 0
admin/controller/Order.php.bak4 → application/admin/controller/Order.php.bak4


+ 0 - 0
admin/controller/Order.php.yuanshi → application/admin/controller/Order.php.yuanshi


+ 0 - 0
admin/controller/Owner.php → application/admin/controller/Owner.php


+ 0 - 0
admin/controller/Send.php → application/admin/controller/Send.php


+ 0 - 0
admin/controller/common.php → application/admin/controller/common.php


+ 0 - 0
admin/phpMQTT/phpMQTT.php → application/admin/phpMQTT/phpMQTT.php


+ 0 - 0
admin/phpMQTT/publish.php → application/admin/phpMQTT/publish.php


+ 0 - 0
admin/phpMQTT/subscribe.php → application/admin/phpMQTT/subscribe.php


+ 0 - 0
admin/view/batchhandle/add.html → application/admin/view/batchhandle/add.html


+ 0 - 0
admin/view/batchhandle/index.html → application/admin/view/batchhandle/index.html


+ 0 - 0
admin/view/company/add.html → application/admin/view/company/add.html


+ 0 - 0
admin/view/company/edit.html → application/admin/view/company/edit.html


+ 0 - 0
admin/view/company/index.html → application/admin/view/company/index.html


+ 0 - 0
admin/view/device/add.html → application/admin/view/device/add.html


+ 0 - 0
admin/view/device/add.html.bak.2021-12-29 → application/admin/view/device/add.html.bak.2021-12-29


+ 0 - 0
admin/view/device/edit.html → application/admin/view/device/edit.html


+ 0 - 0
admin/view/device/edit.html.bak → application/admin/view/device/edit.html.bak


+ 0 - 0
admin/view/device/edit.html.bak-2021-12-27 → application/admin/view/device/edit.html.bak-2021-12-27


+ 0 - 0
admin/view/device/edit.html.bak.2020-12-14 → application/admin/view/device/edit.html.bak.2020-12-14


+ 0 - 0
admin/view/device/edit2.html.bak → application/admin/view/device/edit2.html.bak


+ 0 - 0
admin/view/device/edit3.html.bak → application/admin/view/device/edit3.html.bak


+ 0 - 0
admin/view/device/history.html → application/admin/view/device/history.html


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff