作者 郭文星

1231

@@ -29,8 +29,9 @@ class Index extends Api @@ -29,8 +29,9 @@ class Index extends Api
29 protected $noNeedRight = ['*']; 29 protected $noNeedRight = ['*'];
30 protected $token = ""; 30 protected $token = "";
31 protected $cameraurl = "https://camera.ynzhsk.cn"; 31 protected $cameraurl = "https://camera.ynzhsk.cn";
32 - protected $govregurl = "http://124.71.107.128:9040";  
33 - 32 + protected $uimsApiurl="https://tyuims.tenyes.cn/";
  33 + protected $swApiurl="http://121.37.218.20:9011/";
  34 + protected $sxjApiurl="http://124.71.107.128:9040/";
34 //前置方法 35 //前置方法
35 public function _initialize() 36 public function _initialize()
36 { 37 {
@@ -49,41 +50,11 @@ class Index extends Api @@ -49,41 +50,11 @@ class Index extends Api
49 return $this->error("返回失败"); 50 return $this->error("返回失败");
50 } 51 }
51 } 52 }
52 - //获取token  
53 - public function tokenLogin($appKey,$appSecret){  
54 - $appKey= $this->request->param('appKey',"");  
55 - $appSecret= $this->request->param('appSecret',"");  
56 - $appKey="waterPro_54989312";  
57 - $appSecret="bef381707451606b34c1f9b4b18bd5d7";  
58 - $url="https://tyuims.tenyes.cn/api/access_token";  
59 - $postdata=[  
60 - "appKey"=>$appKey,  
61 - "appSecret"=>$appSecret,  
62 - ];  
63 - $res =HttpHelper::post($url,$postdata);  
64 - $jsondata=json_decode($res,true);  
65 - if($jsondata['code']==200){  
66 - $loginurl="https://tyuims.tenyes.cn/api/login/token";  
67 - $logindata=[  
68 - "token"=>$jsondata['data']  
69 - ];  
70 - $res =HttpHelper::post($loginurl,$logindata);  
71 - $jsonlogin=json_decode($res,true);  
72 - if($jsonlogin['code']==200){  
73 - return $this->success($jsonlogin['msg'],$jsonlogin['data']);  
74 - }else{  
75 - return $this->error("请求失败");  
76 - }  
77 -  
78 - }else{  
79 - return $this->error("请求失败");  
80 - }  
81 - }  
82 -  
83 //获取水厂列表 53 //获取水厂列表
84 public function getwaterworks(){ 54 public function getwaterworks(){
85 - $token=$this->token;  
86 - $url="http://124.71.107.128:9040/data_api/v1/getWaterworksListData"; 55 + $user=new User();
  56 + $token=$user->sxjApitoken();
  57 + $url=$this->sxjApiurl."data_api/v1/getWaterworksListData";
87 $res =HttpHelper::postheader($url,"","",$token); 58 $res =HttpHelper::postheader($url,"","",$token);
88 $res=json_decode($res,true); 59 $res=json_decode($res,true);
89 return $this->success($res['message'],$res['data']); 60 return $this->success($res['message'],$res['data']);
@@ -92,8 +63,9 @@ class Index extends Api @@ -92,8 +63,9 @@ class Index extends Api
92 //获取水厂列表 63 //获取水厂列表
93 public function getWaterworksDetailData(){ 64 public function getWaterworksDetailData(){
94 $id= $this->request->param('id',""); 65 $id= $this->request->param('id',"");
95 - $token=$this->token;  
96 - $url="http://124.71.107.128:9040/data_api/v1/getWaterworksDetailData"; 66 + $user=new User();
  67 + $token=$user->sxjApitoken();
  68 + $url=$this->sxjApiurl."data_api/v1/getWaterworksDetailData";
97 $data=['id'=>$id]; 69 $data=['id'=>$id];
98 $res =HttpHelper::postheader($url,$data,"",$token); 70 $res =HttpHelper::postheader($url,$data,"",$token);
99 $res=json_decode($res,true); 71 $res=json_decode($res,true);
@@ -109,8 +81,9 @@ class Index extends Api @@ -109,8 +81,9 @@ class Index extends Api
109 81
110 //获得净水设备列表 82 //获得净水设备列表
111 public function getWaterworksEquipmentListData(){ 83 public function getWaterworksEquipmentListData(){
112 - $token=$this->token;  
113 - $url="http://124.71.107.128:9040/data_api/v1/getWaterworksEquipmentListData"; 84 + $user=new User();
  85 + $token=$user->sxjApitoken();
  86 + $url=$this->sxjApiurl."data_api/v1/getWaterworksEquipmentListData";
114 $res =HttpHelper::postheader($url,"","",$token); 87 $res =HttpHelper::postheader($url,"","",$token);
115 $res=json_decode($res,true); 88 $res=json_decode($res,true);
116 return $this->success($res['message'],$res['data']); 89 return $this->success($res['message'],$res['data']);
@@ -119,9 +92,9 @@ class Index extends Api @@ -119,9 +92,9 @@ class Index extends Api
119 //获得净水设备列表 92 //获得净水设备列表
120 public function getWaterworksEquipmentDetailData(){ 93 public function getWaterworksEquipmentDetailData(){
121 $id= $this->request->param('id',""); 94 $id= $this->request->param('id',"");
122 - $token=$this->token;  
123 - $url="http://124.71.107.128:9040/data_api/v1/getWaterworksEquipmentDetailData";  
124 - //$token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IjE5OTY5MTA2NzEwIiwicGFzc3dvcmQiOiJhMGUxNWM0NDRmOGNiY2NiNTAwM2U1MDk5OGI2OGZhNyIsImV4cCI6MTczMTY2ODA5MSwiaXNzIjoidWltcyJ9.W3RBwrFdidL9ERykKC_gHtjp911xrkNvUKglSes1w7c"; 95 + $user=new User();
  96 + $token=$user->sxjApitoken();
  97 + $url=$this->sxjApiurl."data_api/v1/getWaterworksEquipmentDetailData";
125 $data=['id'=>$id]; 98 $data=['id'=>$id];
126 $res =HttpHelper::postheader($url,$data,"",$token); 99 $res =HttpHelper::postheader($url,$data,"",$token);
127 $res=json_decode($res,true); 100 $res=json_decode($res,true);
@@ -130,8 +103,9 @@ class Index extends Api @@ -130,8 +103,9 @@ class Index extends Api
130 103
131 //-获得净水设备数据列表 104 //-获得净水设备数据列表
132 public function getWaterworksEquipmentDataListData(){ 105 public function getWaterworksEquipmentDataListData(){
133 - $token=$this->token;  
134 - $url="http://124.71.107.128:9040/data_api/v1/getWaterworksEquipmentDataListData"; 106 + $user=new User();
  107 + $token=$user->sxjApitoken();
  108 + $url=$this->sxjApiurl."data_api/v1/getWaterworksEquipmentDataListData";
135 $res =HttpHelper::postheader($url,"","",$token); 109 $res =HttpHelper::postheader($url,"","",$token);
136 $res=json_decode($res,true); 110 $res=json_decode($res,true);
137 return $this->success($res['message'],$res['data']); 111 return $this->success($res['message'],$res['data']);
@@ -141,8 +115,9 @@ class Index extends Api @@ -141,8 +115,9 @@ class Index extends Api
141 //-获得设备数据详情 115 //-获得设备数据详情
142 public function getWaterworksEquipmentDataDetailData(){ 116 public function getWaterworksEquipmentDataDetailData(){
143 $id= $this->request->param('id',""); 117 $id= $this->request->param('id',"");
144 - $token=$this->token;  
145 - $url="http://124.71.107.128:9040/data_api/v1/getWaterworksEquipmentDataDetailData"; 118 + $user=new User();
  119 + $token=$user->sxjApitoken();
  120 + $url=$this->sxjApiurl."data_api/v1/getWaterworksEquipmentDataDetailData";
146 $data=['id'=>$id]; 121 $data=['id'=>$id];
147 $res =HttpHelper::postheader($url,$data,"",$token); 122 $res =HttpHelper::postheader($url,$data,"",$token);
148 $res=json_decode($res,true); 123 $res=json_decode($res,true);
@@ -162,16 +137,18 @@ class Index extends Api @@ -162,16 +137,18 @@ class Index extends Api
162 } 137 }
163 //-获得设备数据详情 138 //-获得设备数据详情
164 public function getAllSupplyStatistics(){ 139 public function getAllSupplyStatistics(){
165 - $token=$this->token;  
166 - $url="http://124.71.107.128:9040/data_all/v1/getAllSupplyStatistics"; 140 + $user=new User();
  141 + $token=$user->sxjApitoken();
  142 + $url=$this->sxjApiurl."data_all/v1/getAllSupplyStatistics";
167 $res =HttpHelper::postheader($url,"","",$token); 143 $res =HttpHelper::postheader($url,"","",$token);
168 $res=json_decode($res,true); 144 $res=json_decode($res,true);
169 return $this->success($res['message'],$res['data']); 145 return $this->success($res['message'],$res['data']);
170 } 146 }
171 //-获得设备数据详情 147 //-获得设备数据详情
172 public function getPayAndOwe(){ 148 public function getPayAndOwe(){
173 - $token=$this->token;  
174 - $url="http://124.71.107.128:9040//data_all/v1/getPayAndOwe"; 149 + $user=new User();
  150 + $token=$user->sxjApitoken();
  151 + $url=$this->sxjApiurl."data_all/v1/getPayAndOwe";
175 $res =HttpHelper::postheader($url,"","",$token); 152 $res =HttpHelper::postheader($url,"","",$token);
176 $res=json_decode($res,true); 153 $res=json_decode($res,true);
177 return $this->success($res['message'],$res['data']); 154 return $this->success($res['message'],$res['data']);
@@ -179,9 +156,9 @@ class Index extends Api @@ -179,9 +156,9 @@ class Index extends Api
179 156
180 //-获得水表列表 157 //-获得水表列表
181 public function getInstrumentListData(){ 158 public function getInstrumentListData(){
182 - $token=$this->token;  
183 - $url="http://121.37.218.20:9011/data_api/v1/insListAll";  
184 - //$token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IjE5OTY5MTA2NzEwIiwicGFzc3dvcmQiOiJhMGUxNWM0NDRmOGNiY2NiNTAwM2U1MDk5OGI2OGZhNyIsImV4cCI6MTczMTY2ODA5MSwiaXNzIjoidWltcyJ9.W3RBwrFdidL9ERykKC_gHtjp911xrkNvUKglSes1w7c"; 159 + $user=new User();
  160 + $token=$user->swApitoken();
  161 + $url=$this->swApiurl."data_api/v1/insListAll";
185 $data=["cat"=>0]; 162 $data=["cat"=>0];
186 $res =HttpHelper::getheader($url,$data,"",$token); 163 $res =HttpHelper::getheader($url,$data,"",$token);
187 $res=json_decode($res,true); 164 $res=json_decode($res,true);
@@ -190,9 +167,9 @@ class Index extends Api @@ -190,9 +167,9 @@ class Index extends Api
190 //-获得水表列表 167 //-获得水表列表
191 public function getInstrumentDetailData(){ 168 public function getInstrumentDetailData(){
192 $id= $this->request->param('id',""); 169 $id= $this->request->param('id',"");
193 - $token=$this->token;  
194 - $url="http://121.37.218.20:9011/data_api/v1/getInstrumentDetailData";  
195 - //$token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IjE5OTY5MTA2NzEwIiwicGFzc3dvcmQiOiJhMGUxNWM0NDRmOGNiY2NiNTAwM2U1MDk5OGI2OGZhNyIsImV4cCI6MTczMTY2ODA5MSwiaXNzIjoidWltcyJ9.W3RBwrFdidL9ERykKC_gHtjp911xrkNvUKglSes1w7c"; 170 + $user=new User();
  171 + $token=$user->swApitoken();
  172 + $url=$this->swApiurl."data_api/v1/getInstrumentDetailData";
196 $data=['id'=>$id]; 173 $data=['id'=>$id];
197 $res =HttpHelper::postheader($url,$data,"",$token); 174 $res =HttpHelper::postheader($url,$data,"",$token);
198 $res=json_decode($res,true); 175 $res=json_decode($res,true);
@@ -202,9 +179,9 @@ class Index extends Api @@ -202,9 +179,9 @@ class Index extends Api
202 //-获得水表列表 179 //-获得水表列表
203 public function eqpDataWaterCenInfo(){ 180 public function eqpDataWaterCenInfo(){
204 $id= $this->request->param('id',""); 181 $id= $this->request->param('id',"");
205 - $token=$this->token;  
206 - $url="http://124.71.107.128:9040/screen_eqp_data/v1/eqpDataWaterCenInfo";  
207 - //$token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IjE5OTY5MTA2NzEwIiwicGFzc3dvcmQiOiJhMGUxNWM0NDRmOGNiY2NiNTAwM2U1MDk5OGI2OGZhNyIsImV4cCI6MTczMTY2ODA5MSwiaXNzIjoidWltcyJ9.W3RBwrFdidL9ERykKC_gHtjp911xrkNvUKglSes1w7c"; 182 + $user=new User();
  183 + $token=$user->sxjApitoken();
  184 + $url=$this->sxjApiurl."screen_eqp_data/v1/eqpDataWaterCenInfo";
208 $data=['wid'=>$id]; 185 $data=['wid'=>$id];
209 $res =HttpHelper::postheader($url,$data,"",$token); 186 $res =HttpHelper::postheader($url,$data,"",$token);
210 $res=json_decode($res,true); 187 $res=json_decode($res,true);
@@ -212,9 +189,9 @@ class Index extends Api @@ -212,9 +189,9 @@ class Index extends Api
212 } 189 }
213 //-获得水表列表 190 //-获得水表列表
214 public function getDataWaterCenInfo($id){ 191 public function getDataWaterCenInfo($id){
215 - $token=$this->token;  
216 - $url="http://124.71.107.128:9040/screen_eqp_data/v1/eqpDataWaterCenInfo";  
217 - //$token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IjE5OTY5MTA2NzEwIiwicGFzc3dvcmQiOiJhMGUxNWM0NDRmOGNiY2NiNTAwM2U1MDk5OGI2OGZhNyIsImV4cCI6MTczMTY2ODA5MSwiaXNzIjoidWltcyJ9.W3RBwrFdidL9ERykKC_gHtjp911xrkNvUKglSes1w7c"; 192 + $user=new User();
  193 + $token=$user->sxjApitoken();
  194 + $url=$this->sxjApiurl."screen_eqp_data/v1/eqpDataWaterCenInfo";
218 $data=['wid'=>$id]; 195 $data=['wid'=>$id];
219 $res =HttpHelper::postheader($url,$data,"",$token); 196 $res =HttpHelper::postheader($url,$data,"",$token);
220 $res=json_decode($res,true); 197 $res=json_decode($res,true);
@@ -223,8 +200,9 @@ class Index extends Api @@ -223,8 +200,9 @@ class Index extends Api
223 200
224 //-获得水表列表 201 //-获得水表列表
225 public function getInstrumentcount(){ 202 public function getInstrumentcount(){
226 - $token=$this->token;  
227 - $url="http://121.37.218.20:9011/data_api/v1/getInstrumentListData"; 203 + $user=new User();
  204 + $token=$user->swApitoken();
  205 + $url=$this->swApiurl."data_api/v1/getInstrumentListData";
228 $res =HttpHelper::postheader($url,"","",$token); 206 $res =HttpHelper::postheader($url,"","",$token);
229 $res=json_decode($res,true); 207 $res=json_decode($res,true);
230 if($res['code']){ 208 if($res['code']){
@@ -26,10 +26,12 @@ class User extends Api @@ -26,10 +26,12 @@ class User extends Api
26 protected $noNeedLogin = ['*']; 26 protected $noNeedLogin = ['*'];
27 // 无需鉴权的接口,*表示全部 27 // 无需鉴权的接口,*表示全部
28 protected $noNeedRight = ['*']; 28 protected $noNeedRight = ['*'];
29 - protected $url="https://tyuims.tenyes.cn/"; 29 + protected $uimsApiurl="https://tyuims.tenyes.cn/";
  30 + protected $swApiurl="http://121.37.218.20:9011/";
  31 + protected $sxjApiurl="http://124.71.107.128:9040/";
30 32
31 - //获取token  
32 - public function tokenLogin(){ 33 + //统一用户系统配置:获得token,登录验证,手机号一键登录
  34 + public function uimsApitoken(){
33 $appKey ="waterPro_54989312"; 35 $appKey ="waterPro_54989312";
34 $appSecret ="bef381707451606b34c1f9b4b18bd5d7"; 36 $appSecret ="bef381707451606b34c1f9b4b18bd5d7";
35 $url="/api/access_token"; 37 $url="/api/access_token";
@@ -37,7 +39,42 @@ class User extends Api @@ -37,7 +39,42 @@ class User extends Api
37 "appKey"=>$appKey, 39 "appKey"=>$appKey,
38 "appSecret"=>$appSecret, 40 "appSecret"=>$appSecret,
39 ]; 41 ];
40 - $res =HttpHelper::post($this->url.$url,$postdata); 42 + $res =HttpHelper::post($this->uimsApiurl.$url,$postdata);
  43 + $jsondata=json_decode($res,true);
  44 + if($jsondata['code']==200){
  45 + return $jsondata['data'];
  46 + }else{
  47 + return $this->error("请求失败".$jsondata['msg'],$jsondata['data']);
  48 + }
  49 + }
  50 + //项目运营管理API:水表,水费账单
  51 + public function swApitoken(){
  52 + $appKey ="sw_70304512";
  53 + $appSecret ="186eb7122814b28af73724198afe6cfa";
  54 + $url="/api/access_token";
  55 + $postdata=[
  56 + "appKey"=>$appKey,
  57 + "appSecret"=>$appSecret,
  58 + ];
  59 + $res =HttpHelper::post($this->swApiurl.$url,$postdata);
  60 + $jsondata=json_decode($res,true);
  61 + if($jsondata['code']==200){
  62 + return $jsondata['data'];
  63 + }else{
  64 + return $this->error("请求失败".$jsondata['msg'],$jsondata['data']);
  65 + }
  66 + }
  67 +
  68 + //行政监管API:水厂,水厂设备数据
  69 + public function sxjApitoken(){
  70 + $appKey ="tyorderauto_69272576";
  71 + $appSecret ="1238cb88883413febbbabf17203b341d";
  72 + $url="/api/access_token";
  73 + $postdata=[
  74 + "appKey"=>$appKey,
  75 + "appSecret"=>$appSecret,
  76 + ];
  77 + $res =HttpHelper::post($this->sxjApiurl.$url,$postdata);
41 $jsondata=json_decode($res,true); 78 $jsondata=json_decode($res,true);
42 if($jsondata['code']==200){ 79 if($jsondata['code']==200){
43 return $jsondata['data']; 80 return $jsondata['data'];