Browse Source

其他计件单据 工单工序查询

曹鹤洋 1 year ago
parent
commit
0de0a1ba8e
1 changed files with 104 additions and 0 deletions
  1. 104 0
      application/api/controller/OtherCountDocument.php

+ 104 - 0
application/api/controller/OtherCountDocument.php

@@ -161,6 +161,110 @@ class OtherCountDocument extends Api
         $this->success('成功',$rows);
     }
 
+    /**
+     * 查询印件工序及产品名称
+     * @ApiMethod (GET)
+     * @param string $gdbh 工单编号
+     * @param string $gxmc 工序名称
+     */
+    public function getGxMc()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        if (isset($req['gdbh']) && !empty($req['gdbh'])){
+            $gdbh = $req['gdbh'];
+        }else{
+            $this->error('参数错误');
+        }
+        if (isset($req['keyword']) && !empty($req['keyword'])){
+            $keyword = $req['keyword'];
+        }else{
+            $keyword = '';
+        }
+
+        $rows = db()->table('工单_基本资料')->alias('g')
+            ->field('rtrim(g.Gd_cpmc) as Gd_cpmc, c.Gy0_yjno, c.Gy0_gxh, rtrim(c.Gy0_gxmc) as Gy0_gxmc, rtrim(c.Add_gxmc) as Add_gxmc')
+            ->where(['g.Gd_gdbh' => $gdbh])
+            ->where(function ($query) use ($keyword) {
+                $query->where(function ($query) use ($keyword) {
+                    $query->where('c.Gy0_yjno', 'like', '%' . $keyword . '%')
+                        ->whereOr('c.Gy0_gxh', 'like', '%' . $keyword . '%')
+                        ->whereOr('c.Add_gxmc', 'like', '%' . $keyword . '%');
+                });
+                $query->whereOr(function ($query) use ($keyword) {
+                    $query->where('c.Add_gxmc', '=', '')
+                        ->where(function ($query) use ($keyword) {
+                            $query->where('c.Gy0_yjno', 'like', '%' . $keyword . '%')
+                                ->whereOr('c.Gy0_gxh', 'like', '%' . $keyword . '%')
+                                ->whereOr('c.Gy0_gxmc', 'like', '%' . $keyword . '%');
+                        });
+                });
+            })
+            ->join(['产品_印件资料' => 'j'], 'g.Gd_cpdh=j.yj_yjdh and g.成品代号=j.yj_cpdh')
+            ->join(['工单_工艺资料' => 'c'], 'c.Gy0_gdbh=g.Gd_gdbh and c.Gy0_yjno=j.yj_yjno')
+            ->select();
+
+
+        foreach ($rows as $key=>$value){
+            if($value['Add_gxmc'] != ''){
+                $rows[$key]['jyGx'] = sprintf("%02d", $value['Gy0_yjno']).'-'.sprintf("%02d", $value['Gy0_gxh']).'-'.$value['Add_gxmc'];
+            }else{
+                $rows[$key]['jyGx'] = sprintf("%02d", $value['Gy0_yjno']).'-'.sprintf("%02d", $value['Gy0_gxh']).'-'.$value['Gy0_gxmc'];
+            }
+        }
+
+        $this->success('成功',$rows);
+    }
+
+    /**
+     * 查询定额代号
+     * @ApiMethod (GET)
+     */
+    public function getDedh()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+
+        $row = db('dic_lzde')
+            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
+            ->where('sys_mc','包装')
+            ->find();
+        $rows = db('dic_lzde')
+            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
+            ->where('Parent',$row['Key_'])
+            ->order('sys_bh asc')
+            ->select();
+        foreach ($rows as $key=>$value){
+            $bool = db('dic_lzde')
+                ->field('Key_,sys_bh, rtrim(sys_mc) as sys_mc')
+                ->where('Parent',$value['Key_'])
+                ->order('sys_bh asc')
+                ->select();
+            if ($bool){
+                foreach ($bool as $k=>$v){
+                    $bool1 = db('dic_lzde')
+                        ->field('sys_bh, rtrim(sys_mc) as sys_mc')
+                        ->where('Parent',$v['Key_'])
+                        ->order('sys_bh asc')
+                        ->select();
+
+                    if ($bool1){
+                        $bool[$k]['bh_mc'] = $bool1;
+                    }
+                }
+                $rows[$key]['bh_mc'] = $bool;
+            }
+        }
+        $row['bh_mc'] = $rows;
+
+        $this->success('成功',$row);
+    }
+
     /**
      * 新增
      * @ApiMethod (POST)