浏览代码

设备跟踪左侧菜单

qiuenguang 1 年之前
父节点
当前提交
4d0c750d10
共有 1 个文件被更改,包括 51 次插入51 次删除
  1. 51 51
      application/api/controller/Facility.php

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

@@ -31,66 +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['设备名称'];
-                $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['时间']);
+            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);
     }