Browse Source

设备运行跟踪左侧菜单

qiuenguang 1 year ago
parent
commit
3c44a8d67a
1 changed files with 12 additions and 8 deletions
  1. 12 8
      application/api/controller/Facility.php

+ 12 - 8
application/api/controller/Facility.php

@@ -47,19 +47,23 @@ class Facility extends Api
                 'rtrim(sczl_jtbh)' => '机台编号'
             ])
             ->where('sczl_rq','>',$date)
-            ->cache(true,86400)
+            ->cache(true,3600)
             ->order('sczl_rq desc')
             ->select();
-        if (empty($list)){
-            $this->success('未找到机台生产记录');
-        }
         foreach ($department as $value){
-            $machine = \db('设备_基本资料')->where('使用部门',$value)->where('sys_sbID','<>','')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
+            $machine = \db('设备_基本资料')
+                ->where('使用部门',$value)
+                ->where('sys_sbID','<>','')
+                ->where('使用部门',$value)
+                ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')
+                ->select();
             foreach ($machine as $k=>$v){
                 $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
-                foreach ($list as $kk=>$vv){
-                    if ($v['设备编号'] === $vv['机台编号']){
-                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
+                if (!empty($list)){
+                    foreach ($list as $kk=>$vv){
+                        if ($v['设备编号'] === $vv['机台编号']){
+                            array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
+                        }
                     }
                 }
             }