ソースを参照

优化接口列表分页及新增接口

huangsanjia 1 年間 前
コミット
c2817a805b

+ 148 - 0
application/api/controller/Inspect.php

@@ -0,0 +1,148 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use \think\Request;
+use \think\Db;
+/**
+ * 检验计件单据维护接口
+ */
+class Inspect extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 首页
+     *
+     */
+    public function index()
+    {
+        $this->success('请求成功');
+    }
+    /**
+     * 获取手工检验左侧菜单栏
+     *
+     * @ApiMethod GET
+    */
+    public function getInspectCount(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $sql = 'SELECT DISTINCT DATE(sys_rq) AS sys_rq  FROM `db_手工检验` ORDER BY sys_rq DESC LIMIT 30 ';
+        $list = Db::query($sql);
+
+        foreach ($list as $key => $value){
+            $where = [$value['sys_rq'].'00:00:00',$value['sys_rq'].'24:00:00'];
+            $list[$key]['count'] = Db::name('db_手工检验')->where('sys_rq','between time',$where)->count();
+        }
+        $this->success('请求成功',$list);
+    }
+    /**
+     * 获取某个日期手工单据
+     *
+     * @ApiMethod GET
+     * @params string date
+    */
+    public function getDateList(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        $date = $params['date'];
+        if (!isset($date)){
+            $this->error('参数不能为空');
+        }
+        $limit = $params['limit'];
+        if (empty($limit)){
+            $limit = 15;
+        }
+        $pages = $params['page'];
+        if (empty($pages)){
+            $pages = 1;
+        }
+
+        $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('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();
+
+        $data['data'] = $list;
+        $data['total'] = $count;
+
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 获取机器检验左侧菜单栏
+     *
+     * @ApiMethod GET
+    */
+    public function getMachineCount(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $sql = 'SELECT DISTINCT DATE(sys_rq) AS sys_rq  FROM `db_机器检验` ORDER BY sys_rq DESC LIMIT 30 ';
+        $list = Db::query($sql);
+        foreach ($list as $key => $value){
+            $where = [$value['sys_rq'].'00:00:00',$value['sys_rq'].'24:00:00'];
+            $list[$key]['count'] = Db::name('db_机器检验')->where('sys_rq','between time',$where)->count();
+        }
+        $this->success('请求成功',$list);
+    }
+    /**
+     * 获取某个日期机器单据
+     *
+     * @ApiMethod GET
+     * @params string date
+    */
+    public function getDateMachine(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        $date = $params['date'];
+        if (!isset($date)){
+            $this->error('参数不能为空');
+        }
+        $limit = $params['limit'];
+        if (empty($limit)){
+            $limit = 15;
+        }
+        $pages = $params['page'];
+        if (empty($pages)){
+            $pages = 1;
+        }
+        $where['a.sczl_单据类型'] = '初检单';
+        $where['a.sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
+        $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_废品率系数,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_单据类型'] = '初检单';
+        $option['sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
+        $count = Db::name('db_机器检验')->where($option)->count();
+
+        $data['data'] = $list;
+        $data['total'] = $count;
+        $this->success('请求成功',$data);
+    }
+}

+ 4 - 1
application/api/controller/Machine.php

@@ -48,7 +48,10 @@ class Machine extends Api
         $where['使用部门'] = $department;
         $field = '设备编号,rtrim(设备名称) as 设备名称,rtrim(生产工序) as 生产工序,日定额,千件工价,机长,副机,调墨,二手,飞达,辅助,放卷,分切1,分切2,检验,rtrim(使用部门) as 使用部门,sys_id,sys_rq,mod_rq,UniqId';
         $list = Db::name('设备_基本资料')->where($where)->field($field)->limit($limit)->page($pages)->order('设备编号 asc')->select();
-        $this->success('请求成功',$list);
+        $count = Db::name('设备_基本资料')->where($where)->field($field)->count();
+        $data['data'] = $list;
+        $data['total'] = $count;
+        $this->success('请求成功',$data);
     }
     /**
      * 获取车间部门列表

+ 6 - 1
application/api/controller/Product.php

@@ -43,17 +43,20 @@ class Product extends Api
         }else{
             $pages = ($params['page']-1) * $limit;
         }
+        $total = 0;
         if (isset($params['custom_code'])){
             $customCode  = $params['custom_code'];
             $sql = "SELECT rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,客户料号,rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,版本号,成品规格,
                     rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
                     FROM `产品_基本资料` WHERE `客户编号` = '{$customCode}' ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END, 
                     `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
+            $total = Db::name('产品_基本资料')->where('客户编号',$customCode)->count();
         }else{
             $sql = "SELECT rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,客户料号,rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,版本号,成品规格,
                     rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
                     FROM `产品_基本资料` ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END, 
                     `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
+            $total = Db::name('产品_基本资料')->count();
         }
         $list = Db::query($sql);
         foreach ($list as $key=>$value){
@@ -77,7 +80,9 @@ class Product extends Api
                 $list[$key]['yjData'] = $yjRes[0]['total'];
             }
         }
-        $this->success('请求成功',$list);
+        $data['data'] = $list;
+        $data['total'] = $total;
+        $this->success('请求成功',$data);
     }
     /**
      * 获取产品基础数据