Browse Source

根据工单展示

曹鹤洋 1 year ago
parent
commit
222bcfaab3

+ 182 - 12
application/api/controller/Inspect.php

@@ -51,6 +51,41 @@ class Inspect extends Api
         $this->success('请求成功',$list);
     }
 
+    /**
+     * 获取手工检验左侧菜单栏
+     * 通过工单
+     * @ApiMethod GET
+    */
+    public function getInspectCountByGdbh(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $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'])
+                ->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')
+                ->select();
+
+            $list[$key]['cpmc'] = $dataCount[0]['yj_yjmc'];
+            // 提取 sys_id 列成新数组
+            $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;
+                $list[$key]['sys'][$i]['count'] = $v;
+                $i++;
+            }
+        }
+        $this->success('请求成功',$list);
+    }
+
+
     /**
      * 获取某个日期手工单据
      *
@@ -62,8 +97,58 @@ class Inspect extends Api
             $this->error('非法请求');
         }
         $params = Request::instance()->param();
-        $date = $params['date'];
-        if (!isset($date)){
+
+        if (!isset($params['date']) || empty($params['date'])) $this->error('参数缺失');
+
+        $pages = 1;
+        $limit = 15;
+        if (isset($req['pages']) && !empty($req['pages'])) $pages = $req['page'];
+        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
+
+        if(strpos($params['date'],'-')){
+            $where = ['a.sys_rq'=>['like','%'.$params['date'].'%']];
+            $option = ['sys_rq'=>['like','%'.$params['date'].'%']];
+        }else{
+            $where = ['a.sczl_gdbh'=>$params['date']];
+            $option = ['sczl_gdbh'=>$params['date']];
+        }
+        if (isset($req['sys_id']) && !empty($req['sys_id'])){
+            $where['a.sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
+            $option['sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
+        }
+
+
+        $field = 'a.sczl_gdbh,a.sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,a.sczl_dedh,a.sczl_废品率系数,a.sczl_检验类别,a.sczl_bh0,
+        rtrim(a.qczl_NumDesc) as qczl_NumDesc,rtrim(a.sys_id) as sys_id,a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c.员工姓名) as 员工姓名,rtrim(d.yj_yjmc) as yj_yjmc';
+        $list = Db::name('db_手工检验')->alias('a')
+            ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
+            ->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')
+            ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq,a.UniqId asc')->select();
+
+        $count = Db::name('db_手工检验')->where($option)->count();
+
+        $data['data'] = $list;
+        $data['total'] = $count;
+
+        $this->success('请求成功',$data);
+    }
+
+    /**
+     * 获取某个日期手工单据
+     * 通过工单
+     * @ApiMethod GET
+     * @params string gdbh
+     */
+    /*public function getDateListByGdbh(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        $gdbh = $params['gdbh'];
+        if (!isset($gdbh)){
             $this->error('参数不能为空');
         }
         $limit = $params['limit'];
@@ -77,23 +162,21 @@ class Inspect extends Api
 
         $field = 'a.sczl_gdbh,a.sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,a.sczl_dedh,a.sczl_废品率系数,a.sczl_检验类别,a.sczl_bh0,
         rtrim(a.qczl_NumDesc) as qczl_NumDesc,rtrim(a.sys_id) as sys_id,a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c.员工姓名) as 员工姓名,rtrim(d.yj_yjmc) as yj_yjmc';
-        $where = [$date.' 00:00:00',$date.'24:00:00'];
         $list = Db::name('db_手工检验')->alias('a')
             ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
             ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
             ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
-            ->where('a.sys_rq','between time',$where)
+            ->where('a.sczl_gdbh',$gdbh)
             ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
             ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq,a.UniqId asc')->select();
 
-        $option['sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
-        $count = Db::name('db_手工检验')->where($option)->count();
+        $count = Db::name('db_手工检验')->where('sczl_gdbh',$gdbh)->count();
 
         $data['data'] = $list;
         $data['total'] = $count;
 
         $this->success('请求成功',$data);
-    }
+    }*/
 
     /**
      * 获取机器检验左侧菜单栏
@@ -124,6 +207,39 @@ class Inspect extends Api
         $this->success('请求成功',$list);
     }
 
+    /**
+     * 获取机器检验左侧菜单栏
+     *
+     * @ApiMethod GET
+    */
+    public function getMachineCountByGdbh(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $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'])
+                ->field('rtrim(d.sys_id) as sys_id, rtrim(g.Gd_cpmc) as Gd_cpmc')
+                ->join(['工单_基本资料'=>'g'],'d.sczl_gdbh=g.Gd_gdbh')
+                ->order('sys_id asc')
+                ->select();
+            $list[$key]['cpmc'] = $dataCount[0]['Gd_cpmc'];
+            // 提取 sys_id 列成新数组
+            $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;
+                $list[$key]['sys'][$i]['count'] = $v;
+                $i++;
+            }
+        }
+        $this->success('请求成功',$list);
+    }
+
     /**
      * 获取某个日期机器单据
      *
@@ -135,8 +251,62 @@ class Inspect extends Api
             $this->error('非法请求');
         }
         $params = Request::instance()->param();
-        $date = $params['date'];
-        if (!isset($date)){
+
+        if (!isset($params['date']) || empty($params['date'])) $this->error('参数缺失');
+
+        $pages = 1;
+        $limit = 15;
+        if (isset($req['pages']) && !empty($req['pages'])) $pages = $req['page'];
+        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
+
+        if(strpos($params['date'],'-')){
+            $where = ['a.sys_rq'=>['like','%'.$params['date'].'%']];
+            $option = ['sys_rq'=>['like','%'.$params['date'].'%']];
+        }else{
+            $where = ['a.sczl_gdbh'=>$params['date']];
+            $option = ['sczl_gdbh'=>$params['date']];
+        }
+        if (isset($req['sys_id']) && !empty($req['sys_id'])){
+            $where['a.sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
+            $option['sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
+        }
+
+        $where['a.sczl_单据类型'] = '初检单';
+        $field = 'a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,a.sczl_jtbh,a.sczl_bzdh,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,rtrim(a.sczl_单据类型) as sczl_单据类型,
+        a.sczl_设备运行工时,a.sczl_dedh,a.sczl_废品率系数,rtrim(a.sczl_检验类别) as sczl_检验类别,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.qczl_NumDesc,rtrim(a.sys_id) as sys_id,
+        a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,rtrim(c3.员工姓名) as sczl_bh3_name,
+        rtrim(c4.员工姓名) as sczl_bh4_name,rtrim(d.yj_yjmc) as yj_yjmc';
+        $list = Db::name('db_机器检验')->alias('a')
+            ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
+            ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
+            ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
+            ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
+            ->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')
+            ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq asc,a.UniqId desc')->select();
+        $option['sczl_单据类型'] = '初检单';
+        $count = Db::name('db_机器检验')->where($option)->count();
+
+        $data['data'] = $list;
+        $data['total'] = $count;
+        $this->success('请求成功',$data);
+    }
+
+    /**
+     * 获取某个日期机器单据
+     *
+     * @ApiMethod GET
+     * @params string date
+     */
+    /*public function getDateMachineByGdbh(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        $gdbh = $params['gdbh'];
+        if (!isset($gdbh)){
             $this->error('参数不能为空');
         }
         $limit = $params['limit'];
@@ -148,7 +318,7 @@ class Inspect extends Api
             $pages = 1;
         }
         $where['a.sczl_单据类型'] = '初检单';
-        $where['a.sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
+        $where['a.sczl_gdbh'] = $gdbh;
         $field = 'a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,a.sczl_jtbh,a.sczl_bzdh,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,rtrim(a.sczl_单据类型) as sczl_单据类型,
         a.sczl_设备运行工时,a.sczl_dedh,a.sczl_废品率系数,rtrim(a.sczl_检验类别) as sczl_检验类别,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.qczl_NumDesc,rtrim(a.sys_id) as sys_id,
         a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,rtrim(c3.员工姓名) as sczl_bh3_name,
@@ -164,13 +334,13 @@ class Inspect extends Api
             ->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'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
+        $option['sys_rq'] = $gdbh;
         $count = Db::name('db_机器检验')->where($option)->count();
 
         $data['data'] = $list;
         $data['total'] = $count;
         $this->success('请求成功',$data);
-    }
+    }*/
 
     /**
      * 定位

+ 0 - 1
application/api/controller/PackagingProcessOutput.php

@@ -87,7 +87,6 @@ class PackagingProcessOutput extends Api
             $this->error('参数错误');
         }
         if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
-        if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
 
         $rows = db()->table('db_包装产量预报')
             ->field('rtrim(sys_id) as sys_id, LEFT(sczl_rq, 10) as sczl_rq,