Kaynağa Gözat

决策支持月度机台运行统计页面数据

qiuenguang 1 yıl önce
ebeveyn
işleme
27fdae2233
1 değiştirilmiş dosya ile 111 ekleme ve 0 silme
  1. 111 0
      application/api/controller/Decision.php

+ 111 - 0
application/api/controller/Decision.php

@@ -149,4 +149,115 @@ class Decision extends Api
         }
         $this->success('成功',$list);
     }
+
+    /**
+     * 月度机台运行工时汇总
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function MachineOperation()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['mouth']) || empty($param['sist'])){
+            $this->error('参数错误');
+        }
+        $mouth = date('Y-m',strtotime($param['mouth']));
+        $list = \db('设备_基本资料')
+            ->alias('a')
+            ->join('设备_产量计酬 b','a.设备编号 = b.sczl_jtbh')
+            ->field([
+                'a.设备编号' => '设备编号',
+                'rtrim(a.设备名称)' => '设备名称',
+                'SUM(b.sczl_cl)' => '产量',
+                'SUM(b.sczl_设备运行工时)' => '设备运行工时',
+                'SUM(b.sczl_保养工时)' => '保养工时',
+                'SUM(b.sczl_打样总工时)' => '打样总工时',
+                'SUM(b.sczl_打样工时)' => '打样补产工时',
+                'SUM(b.sczl_装版总工时)' => '装板总工时',
+                'SUM(b.sczl_装版工时)' => '装板补产工时',
+                'SUM(b.sczl_异常停机工时)' => '异常停机工时'
+            ])
+            ->where('a.设备编组',$param['sist'])
+            ->whereTime('b.sczl_rq',$mouth)
+            ->group('a.设备编号')
+            ->order('a.设备编号')
+            ->select();
+        $total = \db('设备_基本资料')
+            ->alias('a')
+            ->join('设备_产量计酬 b','a.设备编号 = b.sczl_jtbh')
+            ->field([
+                'SUM(b.sczl_设备运行工时)' => '设备运行工时',
+                'SUM(b.sczl_保养工时)' => '保养工时',
+                'SUM(b.sczl_打样总工时)' => '打样总工时',
+                'SUM(b.sczl_打样工时)' => '打样补产工时',
+                'SUM(b.sczl_装版总工时)' => '装板总工时',
+                'SUM(b.sczl_装版工时)' => '装板补产工时',
+                'SUM(b.sczl_异常停机工时)' => '异常停机工时'
+            ])
+            ->where('a.设备编组',$param['sist'])
+            ->whereTime('b.sczl_rq',$mouth)
+            ->find();
+        $list['total'] = $total;
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 设备运行工时机台生产工单数据详情
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function MachineOperationProductDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['mouth']) || empty($param['machine'])){
+            $this->error('参数错误');
+        }
+        $mouth = date('Y-m',strtotime($param['mouth']));
+        $list = \db('设备_产量计酬')
+            ->alias('a')
+            ->join('设备_基本资料 b','a.sczl_jtbh = b.设备编号')
+            ->join('工单_印件资料 c','a.sczl_gdbh = c.Yj_Gdbh AND a.sczl_yjno = c.yj_Yjno')
+            ->join('工单_工艺资料 d','a.sczl_gdbh = d.Gy0_gdbh AND a.sczl_yjno = d.Gy0_yjno AND a.sczl_gxh = d.Gy0_gxh')
+            ->field([
+                'a.sczl_jtbh' => '设备编号',
+                'rtrim(b.设备名称)' => '设备名称',
+                'DATE(a.sczl_rq)' => '日期',
+                'a.sczl_gdbh' => '工单编号',
+                'a.sczl_yjno' => '印件号',
+                'a.sczl_gxh' => '工序号',
+                'c.yj_yjmc' => '印件名称',
+                'd.Gy0_gxmc' => '工序名称',
+                'SUM(a.sczl_cl)' => '产量',
+                'SUM(a.sczl_设备运行工时)' => '设备运行工时',
+                'SUM(a.sczl_保养工时)' => '保养工时',
+                'SUM(a.sczl_打样总工时)' => '打样总工时',
+                'SUM(a.sczl_打样工时)' => '打样补产工时',
+                'SUM(a.sczl_装版总工时)' => '装板总工时',
+                'SUM(a.sczl_装版工时)' => '装板补产工时',
+                'SUM(a.sczl_异常停机工时)' => '异常停机工时',
+                'a.sczl_ms' => '墨色数'
+            ])
+            ->whereTime('a.sczl_rq',$mouth)
+            ->where('a.sczl_jtbh',$param['machine'])
+            ->group('a.sczl_rq,a.sczl_gdbh')
+            ->order('a.sczl_rq')
+            ->select();
+        if (!empty($list)){
+            foreach ($list as $key=>$value){
+                $list[$key]['工序名称'] = $value['印件号'].'-'.$value['工序号'].'-'.$value['工序名称'];
+                unset($list[$key]['印件号'],$list[$key]['工序号']);
+            }
+        }
+        $this->success('成功',$list);
+    }
 }