Browse Source

接口优化,机台生产详细信息

曹鹤洋 1 year ago
parent
commit
5ff7250d65

+ 18 - 15
application/api/controller/Inspect.php

@@ -62,9 +62,11 @@ class Inspect extends Api
         }
         $sql = 'SELECT DISTINCT sczl_gdbh  FROM `db_手工检验` ORDER BY sczl_gdbh DESC LIMIT 65 ';
         $list = Db::query($sql);
+
         foreach ($list as $key => $value){
             $dataCount = Db::name('db_手工检验')->alias('d')
                 ->where('sczl_gdbh',$value['sczl_gdbh'])
+                ->where('SUBSTR(d.sczl_yjgx,1,2) = g.yj_Yjno')
                 ->field('rtrim(d.sys_id) as sys_id, rtrim(g.yj_yjmc) as yj_yjmc')
                 ->join(['工单_印件资料'=>'g'],'d.sczl_gdbh=g.Yj_Gdbh')
                 ->order('sys_id asc')
@@ -75,6 +77,7 @@ class Inspect extends Api
             $sysIds = array_column($dataCount, 'sys_id');
             //统计每个不同的 sys_id 的数量
             $counts = array_count_values($sysIds);
+
             $i = 0;
             foreach ($counts as $k=>$v){
                 $list[$key]['sys'][$i]['sys_id'] = $k;
@@ -125,7 +128,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq,a.UniqId asc')->select();
 
         $count = Db::name('db_手工检验')->where($option)->count();
@@ -167,7 +170,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where('a.sczl_gdbh',$gdbh)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq,a.UniqId asc')->select();
 
         $count = Db::name('db_手工检验')->where('sczl_gdbh',$gdbh)->count();
@@ -283,7 +286,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->limit($limit)->page($pages)->order('a.UniqId desc')->select();
         $count = Db::name('db_机器检验')->where($option)->count();
 
@@ -329,7 +332,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq asc,a.UniqId desc')->select();
         $option['sczl_单据类型'] = '初检单';
         $option['sys_rq'] = $gdbh;
@@ -373,7 +376,7 @@ class Inspect extends Api
                 ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
                 ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
                 ->where($where)
-                ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+                ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
                 ->field($field)->page($page,$limit)->order('a.sczl_rq,a.UniqId asc')->select();
 
             $option['sczl_gdbh'] = [ 'like', '%' . $req['gdbh'] . '%'];
@@ -394,7 +397,7 @@ class Inspect extends Api
                     ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
                     ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
                     ->where($where)
-                    ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+                    ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
                     ->field($field)->page($page,$limit)->order('a.sczl_rq,a.UniqId asc')->select();
 
                 $option['sczl_gdbh'] = ['in', $gd];
@@ -449,7 +452,7 @@ class Inspect extends Api
                 ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
                 ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
                 ->where($where)
-                ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+                ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
                 ->field($field)->page($page,$limit)->order('a.sczl_rq asc,a.UniqId desc')->select();
             $option['sczl_单据类型'] = '初检单';
             $option['sczl_gdbh'] = [ 'like', '%' . $req['gdbh'] . '%'];
@@ -477,7 +480,7 @@ class Inspect extends Api
                     ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
                     ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
                     ->where($where)
-                    ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+                    ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
                     ->field($field)->page($page,$limit)->order('a.sczl_rq asc,a.UniqId desc')->select();
                 $option['sczl_单据类型'] = '初检单';
                 $option['sczl_gdbh'] = ['in', $gd];
@@ -547,7 +550,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c12','a.sczl_bh12 = c12.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->find();
 
         $this->success('成功',$rows);
@@ -598,7 +601,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c8','a.sczl_bh8 = c8.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->find();
 
         $this->success('成功',$rows);
@@ -635,7 +638,7 @@ class Inspect extends Api
             ->where(['g.Gd_gdbh'=>$gdbh])
             ->where(['c.Gy0_gxmc'=>$gxmcs])
             ->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')
+            ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Gd_gdbh and c.Gy0_yjno=j.yj_Yjno')
             ->select();
 
         foreach ($rows as $key=>$value){
@@ -676,7 +679,7 @@ class Inspect extends Api
             ->where(['g.Gd_gdbh'=>$gdbh])
             ->where(['c.Gy0_gxmc'=>$gxmcs])
             ->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')
+            ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Gd_gdbh and c.Gy0_yjno=j.yj_Yjno')
             ->select();
 
         foreach ($rows as $key=>$value){
@@ -1178,7 +1181,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->order('a.sczl_rq,a.UniqId asc')->select();
 
         foreach ($rows as $key=>$value) {
@@ -1268,7 +1271,7 @@ class Inspect extends Api
             ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->field($field)->order('a.UniqId desc')->select();
 
         foreach ($rows as $key=>$value) {
@@ -1337,7 +1340,7 @@ class Inspect extends Api
         $rows = db()->table('db_手工检验')->alias('a')
             ->field($field)
             ->where($where)
-            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
+            ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_Yjno')
             ->join('工单_印件资料 d', 'a.sczl_gdbh = d.Yj_Gdbh', 'left')
             ->group('a.sczl_gdbh, d.yj_yjmc, a.sczl_yjgx')
             ->order('a.sczl_gdbh asc')

+ 67 - 10
application/api/controller/MachineProductionReport.php

@@ -541,17 +541,74 @@ class MachineProductionReport extends Api
         }
 
         $rows = db()->table('db_sczl')->alias('a')
-            ->field('a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-            a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp, 
-            a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-            a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, 
-            a.拆片联拼系数, a.拆片条小盒系数, a.sczl_工价系数, d.日定额, d.千件工价, d.补产标准, 
-            rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId')
-            ->where('UniqId', $UniqId)
+            ->field('a.sczl_gdbh, rtrim(j.Gd_cpmc) as Gd_cpmc, 
+            a.sczl_yjno, rtrim(y.yj_yjmc) as yj_yjmc, 
+            rtrim(a.sczl_gxmc) as sczl_gxmc, a.sczl_gxh, rtrim(a.sczl_type) as sczl_type, 
+            LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, a.sczl_bzdh, 
+            a.sczl_ms, a.sczl_ls, a.sczl_cl, a.sczl_fp as sczl_zcfp, 
+            a.sczl_装版总工时, a.sczl_装版工时, a.sczl_保养工时, a.sczl_异常停机工时, 
+            a.sczl_打样总工时, a.sczl_打样工时, a.sczl_设备运行工时, 
+            a.拆片联拼系数, a.拆片条小盒系数, 
+            a.sczl_dedh, a.sczl_工价系数, a.sczl_计产系数, 
+            a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, 
+            a.sczl_bh6, a.sczl_bh7, a.sczl_bh8, a.sczl_bh9, a.sczl_bh10,
+            a.sczl_rate1, a.sczl_rate2, a.sczl_rate3, a.sczl_rate4, a.sczl_rate5, 
+            a.sczl_rate6, a.sczl_rate7, a.sczl_rate8, a.sczl_rate9, a.sczl_rate10
+            ')
+            ->where('a.UniqId', $UniqId)
             ->where('a.sczl_yjno = y.yj_yjno')
-            ->join(['dic_lzde'=>'d'],'a.sczl_dedh=d.sys_bh')
-            ->join(['工单_基本资料'=>'j'],'a.sczl_gdbh=j.Gd_gdbh')
-            ->join(['工单_印件资料'=>'y'],'a.sczl_gdbh=y.Yj_Gdbh')
+            ->join(['工单_基本资料'=>'j'],'a.sczl_gdbh = j.Gd_gdbh')
+            ->join(['工单_印件资料'=>'y'],'a.sczl_gdbh = y.Yj_Gdbh')
+            ->find();
+        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
+        for($i=1;$i<=10;$i++){
+            if(trim($rows['sczl_bh'.$i])!=''){
+                $rows['sczl_bh'.$i.'_name'] = array_key_exists($rows['sczl_bh'.$i],$rs) ? trim($rs[$rows['sczl_bh'.$i]]) : '';
+            }else{
+                $rows['sczl_bh'.$i.'_name'] = '';
+            }
+        }
+
+        $this->success('成功',$rows);
+    }
+
+    /**
+     * 获取机台生产日报表信息
+     * @ApiMethod (GET)
+     * @param string $UniqId UniqId
+     */
+    public function add()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        if (isset($req['UniqId']) && !empty($req['UniqId'])){
+            $UniqId = $req['UniqId'];
+        }else{
+            $this->error('参数错误');
+        }
+
+        $rows = db()->table('db_sczl')->alias('a')
+            ->field('a.sczl_gdbh, rtrim(j.Gd_cpmc) as Gd_cpmc, 
+            a.sczl_yjno, rtrim(y.yj_yjmc) as yj_yjmc, 
+            rtrim(a.sczl_gxmc) as sczl_gxmc, a.sczl_gxh, rtrim(a.sczl_type) as sczl_type, 
+            LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, a.sczl_bzdh, 
+            a.sczl_ms, a.sczl_ls, a.sczl_cl, a.sczl_fp as sczl_zcfp, 
+            a.sczl_装版总工时, a.sczl_装版工时, a.sczl_保养工时, a.sczl_异常停机工时, 
+            a.sczl_打样总工时, a.sczl_打样工时, a.sczl_设备运行工时, 
+            a.拆片联拼系数, a.拆片条小盒系数, 
+            a.sczl_dedh, a.sczl_工价系数, a.sczl_计产系数, 
+            a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, 
+            a.sczl_bh6, a.sczl_bh7, a.sczl_bh8, a.sczl_bh9, a.sczl_bh10, 
+            d.日定额, d.千件工价, d.补产标准
+            ')
+            ->where('a.UniqId', $UniqId)
+            ->where('a.sczl_yjno = y.yj_yjno')
+            ->join(['dic_lzde'=>'d'],'a.sczl_dedh = d.sys_bh')
+            ->join(['工单_基本资料'=>'j'],'a.sczl_gdbh = j.Gd_gdbh')
+            ->join(['工单_印件资料'=>'y'],'a.sczl_gdbh = y.Yj_Gdbh')
             ->find();