Browse Source

工单核检单显示方式以及列表展示

曹鹤洋 1 year ago
parent
commit
8a94554d44
1 changed files with 46 additions and 0 deletions
  1. 46 0
      application/api/controller/WorkOrderVerification.php

+ 46 - 0
application/api/controller/WorkOrderVerification.php

@@ -67,6 +67,45 @@ class WorkOrderVerification extends Api
         $this->success('成功',$rows);
     }
 
+    /**
+     * 获取工单核验单侧边栏通过工单编号
+     * @ApiMethod (GET)
+     */
+    public function getTabByGdbh()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $date = date('Y-m-d',strtotime("-1 year"));
+
+        $rows = db()->table('db_qczl')->alias('d')->cache(true)
+            ->field('d.qczl_gdbh, rtrim(y.Gd_cpmc) as Gd_cpmc')
+            ->join('工单_基本资料 y','y.Gd_gdbh = d.qczl_gdbh','left')
+            ->where('d.sys_rq','>=',$date)
+            ->group('d.qczl_gdbh')
+            ->order('d.qczl_gdbh desc')
+            ->limit(65)
+            ->select();
+        $arr = db()->table('db_qczl')->cache(true)
+            ->field('qczl_gdbh, rtrim(sys_id) as sys_id, COUNT(sys_id) as count')
+            ->where('qczl_gdbh','>=',$rows[count($rows)-1]['qczl_gdbh'])
+            ->group('qczl_gdbh, sys_id')
+            ->select();
+        foreach($rows as $key=>$value){
+            $rows[$key]['sys'] = [];
+            foreach($arr as $k=>$v){
+                if($value['qczl_gdbh'] == $v['qczl_gdbh']){
+                    unset($v['qczl_gdbh']);
+                    array_push($rows[$key]['sys'],$v);
+                    unset($arr[$k]);
+                }
+            }
+        }
+
+        $this->success('成功',$rows);
+    }
+
     /**
      * 获取工单核验单列表
      * @ApiMethod (GET)
@@ -92,6 +131,13 @@ class WorkOrderVerification extends Api
         }
         if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE',$req['sys_id'].'%'];
         if (isset($req['order']) && !empty($req['order'])) $where['qczl_gdbh'] = $req['order'];
+        if (isset($req['cpmc']) && !empty($req['cpmc'])){
+            //查询工单表
+            $gd = db('工单_基本资料')
+                ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
+                ->column('Gd_gdbh');
+            $where['qczl_gdbh'] = ['in', $gd];
+        }
         $rows = db()->table('db_qczl')
             ->field('qczl_gdbh, qczl_yjno, LEFT(qczl_rq, 10) as qczl_rq, qczl_num, rtrim(qczl_NumDesc) as qczl_NumDesc, qczl_fp, 
             fp_lb1, fp_lb2, fp_lb3, fp_lb4, fp_lb5, fp_lb6, fp_lb7, fp_lb8, fp_lb9, fp_lb10, fp_lb11, fp_lb12, fp_lb13, fp_lb14, fp_lb15, fp_lb16, fp_lb17,