作者 潘浩文
1 个管道 的构建 通过 耗费 0 秒

后台设备模块开发

@@ -139,10 +139,10 @@ class AdminLightController extends AdminBaseController @@ -139,10 +139,10 @@ class AdminLightController extends AdminBaseController
139 array_push($arr, [$r,$c]); 139 array_push($arr, [$r,$c]);
140 } 140 }
141 } 141 }
142 - $is_set = Db::name('light')->where(['area_id'=>$id,'id'=>['neq',$this->request->param('lightId')]])->field('row,column')->select()->toArray();  
143 - if (!empty($lightId)) {  
144 - $is_set = Db::name('light')->where(['area_id'=> $id,'id'=>['neq',$lightId]])->field('row,column')->select()->toArray(); 142 + if (empty($lightId)){
  143 + $lightId=$this->request->param('lightId');
145 } 144 }
  145 + $is_set = Db::name('light')->where(['area_id'=> $id,'id'=>['neq',$lightId]])->field('row,column')->select()->toArray();
146 foreach ($arr as $k=>$v){ 146 foreach ($arr as $k=>$v){
147 foreach ($is_set as $k1=>$v1){ 147 foreach ($is_set as $k1=>$v1){
148 if (array_values($v)==array_values($v1)){ 148 if (array_values($v)==array_values($v1)){
@@ -201,31 +201,13 @@ class AdminLightOrderController extends AdminBaseController @@ -201,31 +201,13 @@ class AdminLightOrderController extends AdminBaseController
201 if (empty($id)) { 201 if (empty($id)) {
202 $id = $this->request->param('id'); 202 $id = $this->request->param('id');
203 } 203 }
204 - $data = Db::name('temple_area')->where('id', $id)->find();  
205 - $arr = [];  
206 - for ($r = 1; $r <= $data['rows']; $r++) {  
207 - for ($c = 1; $c <= $data['columns']; $c++) {  
208 - array_push($arr, [$r,$c]);  
209 - } 204 + if (empty($lightId)){
  205 + $lightId=$this->request->param('lightId');
210 } 206 }
211 - $is_set = Db::name('light_order')  
212 - ->alias('lo')  
213 - ->join('light l', 'lo.light_id=l.id')  
214 - ->where(['l.area_id' => $id, 'lo.status' => 1, 'lo.end_time' => ['>', time()]])->field('l.row,l.column')->select()->toArray();  
215 - if (!empty($lightId)) {  
216 - $is_set = Db::name('light_order') 207 + $data = Db::name('light_order')
217 ->alias('lo') 208 ->alias('lo')
218 ->join('light l', 'lo.light_id=l.id') 209 ->join('light l', 'lo.light_id=l.id')
219 ->where(['l.area_id' => $id, 'lo.status' => 1, 'lo.end_time' => ['>', time()], 'l.id' => ['neq', $lightId]])->field('l.row,l.column')->select()->toArray(); 210 ->where(['l.area_id' => $id, 'lo.status' => 1, 'lo.end_time' => ['>', time()], 'l.id' => ['neq', $lightId]])->field('l.row,l.column')->select()->toArray();
220 - }  
221 - foreach ($arr as $k=>$v){  
222 - foreach ($is_set as $k1=>$v1){  
223 - if (array_values($v)==array_values($v1)){  
224 - unset($arr[$k]);  
225 -// $arr = array_values($arr);  
226 - }  
227 - }  
228 - }  
229 - return json_encode($arr); 211 + return json_encode($data);
230 } 212 }
231 } 213 }