Bladeren bron

设备运行跟踪

qiuenguang 1 jaar geleden
bovenliggende
commit
e92c558b12
2 gewijzigde bestanden met toevoegingen van 131 en 4 verwijderingen
  1. 122 1
      application/api/controller/Facility.php
  2. 9 3
      application/api/controller/WorkOrder.php

+ 122 - 1
application/api/controller/Facility.php

@@ -49,7 +49,16 @@ class Facility extends Api
     }
 
 
-    //当日上报产量
+    /**
+     * 机台每日产量
+     * @ApiMethod (GET)
+     * @param string $machine  机台编号
+     * @param string $date 日期
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
     public function chanLiang()
     {
         if ($this->request->isGet() === false){
@@ -76,6 +85,8 @@ class Facility extends Api
         $productName = Db::table('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->column('Gd_cpmc','Gd_gdbh');
         //组员信息
         $list = Db::table('设备_产量计酬')->where($where)->field($field)->select();
+        $totalA = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
+        $totalB = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
         if (empty($list)){
             $this->error('未找到机台数据');
         }
@@ -99,6 +110,116 @@ class Facility extends Api
             }
             unset($list[$key]['工序编号'],$list[$key]['yjno'],$list[$key]['gxmc'],$list[$key]['num'],$list[$key]['sj1'],$list[$key]['sj2'],$list[$key]['bzdh']);
         }
+        $list['totalA'] = $totalA[0]['产量'];
+        $list['totalB'] = $totalB[0]['产量'];
         $this->success('成功',$list);
     }
+
+    /**
+     * 当日制程检验记录
+     * @ApiMethod (GET)
+     * @param string $machine  机台编号
+     * @param string $date   日期
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Inspect()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $machine = input('machine');
+        $date = input('date');
+        if (empty($machine) || empty($date)){
+            $this->error('参数错误');
+        }
+        $last_id = Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find();
+        $startId = $last_id['UniqId']-1000000;
+        $where = [
+            '设备编号' => $machine,
+            '开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
+            '类别' => ['in',['IPQC检验','机台检验']],
+            'UniqId' => ['>',$startId],
+        ];
+        $begin = Db::table('制程检验_记录')->where($where)->field('UniqId')->find();
+        $end = Db::table('制程检验_记录')->where($where)->order('UniqId desc')->field('UniqId')->find();
+        $where['UniqId'] = ['between',[$begin['UniqId'],$end['UniqId']+1]];
+        //检验项目筛选
+        $itemA = Db::table('制程检验_记录')->where($where)->distinct(true)->where('班组编号','A班')->column('rtrim(检验项目)');
+        $itemB = Db::table('制程检验_记录')->where($where)->distinct(true)->where('班组编号','B班')->column('rtrim(检验项目)');
+        //检验时间
+        $InspectionTime = Db::table('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
+        foreach ($InspectionTime as $k=>$v){
+            $InspectionTime[$k] = date('H:i',strtotime($v));
+        }
+        //检测记录详情
+        $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
+        $nameDetailA = Db::table('制程检验_记录')->where($where)->field($field)->where('班组编号','A班')->find();
+        $nameDetailB = Db::table('制程检验_记录')->where($where)->field($field)->where('班组编号','B班')->find();
+        $list = $data1 = $data2 = [];
+        //A班检测数据
+        foreach ($itemA as $key=>$value){
+            $SubmissionTime = Db::table('制程检验_记录')->where($where)
+                ->where('班组编号','A班')
+                ->where('检验项目',$value)
+                ->where('检验结果','合格')
+                ->field('rtrim(提交时间) as 提交时间')
+                ->select();
+            $time = [];
+            foreach ($SubmissionTime as $k=>$v){
+                $time[$k] = date('H:i',strtotime($v['提交时间']));
+            }
+            $data1[$key] = [
+                '工单编号' => $nameDetailA['工单编号'],
+                '印件号' => $nameDetailA['印件号'],
+                '工序名称' => $nameDetailA['工序名称'],
+                '检验项目' => $value,
+                'inspectresult' => implode(',',$time),
+            ];
+        }
+        //B班数据详情
+        foreach ($itemB as $key=>$value){
+            $SubmissionTime = Db::table('制程检验_记录')->where($where)
+                ->where('班组编号','B班')
+                ->where('检验项目',$value)
+                ->where('检验结果','合格')
+                ->field('rtrim(提交时间) as 提交时间')
+                ->select();
+            $time = [];
+            foreach ($SubmissionTime as $k=>$v){
+                $time[$k] = date('H:i',strtotime($v['提交时间']));
+            }
+            $data2[$key] = [
+                '工单编号' => $nameDetailB['工单编号'],
+                '印件号' => $nameDetailB['印件号'],
+                '工序名称' => $nameDetailB['工序名称'],
+                '检验项目' => $value,
+                'inspectresult' => implode(',',$time),
+            ];
+        }
+        $list = array_merge($data2,$data1);
+        $list['inspectiontime'] = $InspectionTime;
+        $this->success('成功',$list);
+    }
+
+    //生产中工单信息
+    public function Production()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $machine = input('machine');
+        if (empty($machine)){
+            $this->error('参数错误');
+        }
+        $nowTime = date('Y-m-d H:i:s',time());
+        $where = [
+            'Gy0_sbbh' => $machine,
+            'Gy0_sj1' => ['<',$nowTime],
+            'Gy0_sj2' => ['>',$nowTime],
+        ];
+//        $field = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(Gy0_yjno) as 印件编号,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Ass_gxmc) as add,'
+    }
 }

+ 9 - 3
application/api/controller/WorkOrder.php

@@ -44,10 +44,11 @@ class WorkOrder extends Api
                 $Detail = [
                     'Gd_khdh' => rtrim($key),
                     'Gd_khmc' => rtrim($value),
-                    'producting' => rtrim($productIng),
-                    'progress' => rtrim($proGress),
+                    'producting' => $productIng = 0?'':"生产中:".$productIng,
+                    'progress' => $proGress=0?'':'计划中:'.$proGress,
                 ];
-                array_push($data,$Detail);
+                $menu = $Detail['Gd_khdh'].'【'.$Detail['producting'].$Detail['progress'].'】'.'【'.$Detail['Gd_khmc'].'】';
+                array_push($data,$menu);
             }
         }
         $this->success('成功',$data);
@@ -69,6 +70,7 @@ class WorkOrder extends Api
             $this->error('请求错误');
         }
         $limit = input('limit');
+//        $page = input('page');
         $clientNumber = input('Gd_khdh');
         $startTime = input('start');
         $endTime = input('end');
@@ -78,6 +80,10 @@ class WorkOrder extends Api
         if (isset($startTime) && isset($endTime)){
             $where['接单日期'] = ['between',[$startTime,$endTime]];
         }
+//        $config = [
+//            'page_param' => $page,
+//            'per_page' => $limit
+//        ];
         $list = Db::table('工单_基本资料')
             ->where($where)
             ->order('接单日期 desc')