Bladeren bron

设备跟踪左侧菜单

qiuenguang 1 jaar geleden
bovenliggende
commit
e5fb09d80e
1 gewijzigde bestanden met toevoegingen van 51 en 49 verwijderingen
  1. 51 49
      application/api/controller/Facility.php

+ 51 - 49
application/api/controller/Facility.php

@@ -31,64 +31,66 @@ class Facility extends Api
             $this->error('请求错误');
         }
         $data = [];
-        $department = \db('设备_基本资料')->distinct(true)->column('使用部门');
-        $date = date('Y-m-d 00:00:00',time()-3888000);
-        if (empty($department)){
-            $this->success('未获取到机台数据');
-        }
-        foreach ($department as $value){
-            if (rtrim($value) !== '研发中心'){
-                $machine = \db('设备_基本资料')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
-                foreach ($machine as $kk=>$vv){
-                    if ($vv['设备编号'] !== 'ZH01#'){
-                        $date = \db('设备_产量计酬')
-                            ->where('sczl_jtbh',$vv['设备编号'])
-//                            ->where('sczl_rq','> time',$date)
-                            ->distinct(true)
-                            ->cache(true)
-                            ->limit(40)
-                            ->order('UniqId desc')
-                            ->column('sczl_rq');
-                        $data[rtrim($value)][$vv['设备编号'].'【'.$vv['设备名称'].'】'] = $date;
-                    }
-                }
-            }
-        }
-        $this->success('成功',$data);
+//        $department = \db('设备_基本资料')->distinct(true)->column('使用部门');
 //        $date = date('Y-m-d 00:00:00',time()-3888000);
-//        $department = \db('设备_基本资料')
-//            ->distinct(true)
-//            ->where('使用部门','<>','研发中心')
-//            ->where('设备编组','<>','')
-//            ->order('设备编组')
-//            ->column('rtrim(使用部门) as 使用部门');
 //        if (empty($department)){
-//            $this->success('为获取到机台数据');
-//        }
-//        $list = \db('设备_产量计酬')
-//            ->field([
-//                'DISTINCT(sczl_rq)' => '时间',
-//                'rtrim(sczl_jtbh)' => '机台编号'
-//            ])
-//            ->where('sczl_rq','>',$date)
-//            ->cache(true,86400)
-//            ->order('sczl_rq desc')
-//            ->select();
-//        if (empty($list)){
-//            $this->success('未找到机台生产记录');
+//            $this->success('未获取到机台数据');
 //        }
 //        foreach ($department as $value){
-//            $machine = \db('设备_基本资料')->where('使用部门',$value)->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
-//            foreach ($machine as $k=>$v){
-//                $data[rtrim($value)][$k]['机台'] = $v['设备编号'].'-->'.$v['设备名称'];
-//                foreach ($list as $kk=>$vv){
-//                    if ($v['设备编号'] === $vv['机台编号']){
-//                        array_push($data[rtrim($value)][$k],date('Y-m-d',strtotime($vv['时间'])));
+//            if (rtrim($value) !== '研发中心'){
+//                $machine = \db('设备_基本资料')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
+//                foreach ($machine as $kk=>$vv){
+//                    if ($vv['设备编号'] !== 'ZH01#'){
+//                        $date = \db('设备_产量计酬')
+//                            ->where('sczl_jtbh',$vv['设备编号'])
+////                            ->where('sczl_rq','> time',$date)
+//                            ->distinct(true)
+//                            ->cache(true)
+//                            ->limit(40)
+//                            ->order('UniqId desc')
+//                            ->column('sczl_rq');
+//                        $data[rtrim($value)][$vv['设备编号'].'【'.$vv['设备名称'].'】'] = $date;
 //                    }
 //                }
 //            }
 //        }
 //        $this->success('成功',$data);
+        $date = date('Y-m-d 00:00:00',time()-3888000);
+        $department = \db('设备_基本资料')
+            ->distinct(true)
+            ->where('使用部门','<>','研发中心')
+            ->where('设备编组','<>','')
+            ->order('设备编组')
+            ->column('rtrim(使用部门) as 使用部门');
+        if (empty($department)){
+            $this->success('为获取到机台数据');
+        }
+        $list = \db('设备_产量计酬')
+            ->field([
+                'DISTINCT(sczl_rq)' => '时间',
+                'rtrim(sczl_jtbh)' => '机台编号'
+            ])
+            ->where('sczl_rq','>',$date)
+            ->cache(true,86400)
+            ->order('sczl_rq desc')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到机台生产记录');
+        }
+        foreach ($department as $value){
+            $machine = \db('设备_基本资料')->where('使用部门',$value)->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
+            foreach ($machine as $k=>$v){
+//                $data[rtrim($value)][$k] = $v['设备编号'].'-->'.$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['时间'])));
+                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],$vv['时间']);
+                    }
+                }
+            }
+        }
+        $this->success('成功',$data);
     }