ss 4 ヶ月 前
コミット
8e72a69b26

+ 1 - 1
application/api/controller/screen/Index.php

@@ -19,7 +19,7 @@ class Index extends Controller
         $token = input('token','','trim');
 
         $str = think_decrypt($token);
-        //$str = '4|100';
+      //  $str = '11|3';
         $data = $str?explode('|',$str):[];
 
         if(count($data) != 2){

+ 35 - 30
application/api/controller/screen/Patrol.php

@@ -69,6 +69,7 @@ class Patrol extends Index
             ->where('pt.status',1)
             ->order('pr.id desc')
             ->find();
+        $addrList =[];
         if(isset($record) && !empty($record)){
             $record['addr'] = Db::name('address')->where('id',$record['patrol_addr_id'])->value('title');
 
@@ -76,39 +77,43 @@ class Patrol extends Index
 
             $record['task'] = Db::name('patrol_task')->where('id',$record['patrol_task_id'])->value('title');
 
-        }
-
-        $addrList = Db::name('patrol_task_addr')
-            ->alias('pta')
-            ->field('a.id,a.title')
-            ->join('patrol_addr_form paf','paf.id=pta.patrol_form_id')
-            ->join('address a','a.id=paf.patrol_addr_id')
-            ->where('pta.patrol_task_id',$record['patrol_task_id'])
-            ->where('a.del',0)
-            ->select();
 
-        foreach ($addrList as $k=>$v){
-            $addrList[$k]['nums'] = Db::name('patrol_record')
-                ->where('org_id',$this->orgId)
-                ->where('patrol_addr_id',$v['id'])
-                ->count();
-            $active = 0;
-            if($v['id'] == $record['patrol_addr_id']){
-                $active = 1;
-            }
-            $addrList[$k]['active'] = $active;
-            $times = Db::name('patrol_record')
-                ->field('create_time')
-                ->where('org_id',$this->orgId)
-                ->where('patrol_addr_id',$v['id'])
+            $addrList = Db::name('patrol_task_addr')
+                ->alias('pta')
+                ->field('a.id,a.title')
+                ->join('patrol_addr_form paf','paf.id=pta.patrol_form_id')
+                ->join('address a','a.id=paf.patrol_addr_id')
+                ->where('pta.patrol_task_id',$record['patrol_task_id'])
+                ->where('a.del',0)
                 ->select();
-            $eDate = '无';
-            foreach ($times as $kk=>$vv){
-                $date = isset($times[1]['create_time'])&&!empty($times[1]['create_time'])?$times[1]['create_time']:'';
-                $eDate = !empty($date)?date('H:i',strtotime($date)):'无';
+            if($addrList){
+                foreach ($addrList as $k=>$v){
+                    $addrList[$k]['nums'] = Db::name('patrol_record')
+                        ->where('org_id',$this->orgId)
+                        ->where('patrol_addr_id',$v['id'])
+                        ->count();
+                    $active = 0;
+                    if($v['id'] == $record['patrol_addr_id']){
+                        $active = 1;
+                    }
+                    $addrList[$k]['active'] = $active;
+                    $times = Db::name('patrol_record')
+                        ->field('create_time')
+                        ->where('org_id',$this->orgId)
+                        ->where('patrol_addr_id',$v['id'])
+                        ->select();
+                    $eDate = '无';
+                    foreach ($times as $kk=>$vv){
+                        $date = isset($times[1]['create_time'])&&!empty($times[1]['create_time'])?$times[1]['create_time']:'';
+                        $eDate = !empty($date)?date('H:i',strtotime($date)):'无';
+                    }
+                    $addrList[$k]['time'] = $eDate;
+                }
             }
-            $addrList[$k]['time'] = $eDate;
-         }
+
+        }
+
+
         $data = [
             'record' => $record,
             'addrList' => $addrList,