浏览代码

手检/机检定额代号获取,废品系数获取,增删改

曹鹤洋 1 年之前
父节点
当前提交
abeb5ddc2e

+ 427 - 4
application/api/controller/Inspect.php

@@ -472,8 +472,6 @@ class Inspect extends Api
 
         foreach ($rows as $key=>$value){
             $rows[$key]['jyGx'] =  sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
-            unset($rows[$key]['Gy0_yjno']);
-            unset($rows[$key]['Gy0_gxh']);
         }
 
         $this->success('成功',$rows);
@@ -515,10 +513,435 @@ class Inspect extends Api
 
         foreach ($rows as $key=>$value){
             $rows[$key]['jyGx'] =  sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
-            unset($rows[$key]['Gy0_yjno']);
-            unset($rows[$key]['Gy0_gxh']);
         }
 
         $this->success('成功',$rows);
     }
+
+    /**
+     * 查询定额代号
+     * @ApiMethod (GET)
+     */
+    public function getDedh()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+
+        $row = db()->table('dic_lzde')
+            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
+            ->where('sys_mc','初检(手工)')
+            ->find();
+        $rows = db()->table('dic_lzde')
+            ->field('sys_bh, rtrim(sys_mc) as sys_mc')
+            ->where('Parent',$row['Key_'])
+            ->select();
+        $row['bh_mc'] = $rows;
+
+        $this->success('成功',$row);
+    }
+
+    /**
+     * 查询定额代号
+     * @ApiMethod (GET)
+     */
+    public function getMachineDedh()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+//        $req = $this->request->param();
+//        if (isset($req['sys_mc']) && !empty($req['sys_mc'])){
+//            $sys_mc = $req['sys_mc'];
+//        }else{
+//            $this->error('参数错误');
+//        }
+        $row = db()->table('dic_lzde')
+            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
+            ->where('适用机型','JP01#')
+            ->find();
+        $rows = db()->table('dic_lzde')
+            ->field('sys_bh, rtrim(sys_mc) as sys_mc')
+            ->where('Parent',$row['Key_'])
+            ->select();
+        $row['bh_mc'] = $rows;
+
+        $this->success('成功',$row);
+    }
+
+    /**
+     * 查询废品系数
+     * @ApiMethod (GET)
+     */
+    public function getScrapFactor()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        isset($req['gdbh']) && !empty($req['gdbh']) ? $gdbh = $req['gdbh'] : $this->error('参数错误');
+        isset($req['yjno']) && !empty($req['yjno']) ? $yjno = $req['yjno'] : $this->error('参数错误');
+        isset($req['gxh'])  && !empty($req['gxh'])  ? $gxh  = $req['gxh']  : $this->error('参数错误');
+        isset($req['type']) && !empty($req['type']) ? $type = $req['type'] : $this->error('参数错误');
+
+        switch ($type){
+            case '正品板':
+                $field = '人工检_正品板 as num';
+            case '次品板':
+                $field = '人工检_次品板 as num';
+            case '废品板':
+                $field = '人工检_废检 as num';
+        }
+        $rows = db()->table('工单_工艺资料')
+            ->field($field)
+            ->where(['Gy0_gdbh'=>$gdbh, 'Gy0_yjno'=>$yjno, 'Gy0_gxh'=>$gxh])
+            ->find();
+
+        $this->success('成功',$rows);
+    }
+    /**
+     * 查询废品系数
+     * @ApiMethod (GET)
+     */
+    public function getMachineScrapFactor()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        isset($req['gdbh']) && !empty($req['gdbh']) ? $gdbh = $req['gdbh'] : $this->error('参数错误');
+        isset($req['yjno']) && !empty($req['yjno']) ? $yjno = $req['yjno'] : $this->error('参数错误');
+        isset($req['gxh'])  && !empty($req['gxh'])  ? $gxh  = $req['gxh']  : $this->error('参数错误');
+        isset($req['type']) && !empty($req['type']) ? $type = $req['type'] : $this->error('参数错误');
+
+        switch ($type){
+            case '正品板':
+                $field = '机检_正品板 as num';
+            case '次品板':
+                $field = '机检_次品板 as num';
+            case '废品板':
+                $field = '机检_废检 as num';
+        }
+        $rows = db()->table('工单_工艺资料')
+            ->field($field)
+            ->where(['Gy0_gdbh'=>$gdbh, 'Gy0_yjno'=>$yjno, 'Gy0_gxh'=>$gxh])
+            ->find();
+
+        $this->success('成功',$rows);
+    }
+
+    /**
+     * 查询机台
+     * @ApiMethod (GET)
+     */
+    public function getJtbh()
+    {
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        if (isset($req['sys_mc']) && !empty($req['sys_mc'])){
+            $sys_mc = $req['sys_mc'];
+        }else{
+            $this->error('参数错误');
+        }
+        $row = db()->table('dic_lzde')
+            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
+            ->where('sys_mc',$sys_mc)
+            ->find();
+        $rows = db()->table('dic_lzde')->alias('d')
+            ->field('rtrim(s.设备编号) as jtbh, rtrim(s.设备名称) as jtmc')
+            ->where('Parent',$row['Key_'])
+            ->join(['设备_基本资料'=>'s'],'d.适用机型=s.设备编号')
+            ->select();
+
+        $this->success('成功',$rows);
+    }
+
+    /**
+     * 新增
+     * @ApiMethod (POST)
+     * @param string
+     */
+    public function add()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        //sczl_num, sczl_gs, sczl_fp
+        $arr = [
+            'sys_id','sczl_rq','sczl_bzdh','sczl_bh0','sczl_cl0','sczl_fp0',
+            'sczl_gdbh','sczl_yjgx','sczl_gxmc',
+            'sczl_cl','sczl_dedh','sczl_检验类别','sczl_废品率系数',
+            'sczl_jsss','sczl_冲定额',
+            'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
+            'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
+            'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6',
+            'sczl_bh7','sczl_bh8','sczl_bh9','sczl_bh10','sczl_bh11', 'sczl_bh12',
+            'sczl_cl1','sczl_cl2','sczl_cl3','sczl_cl4','sczl_cl5','sczl_cl6',
+            'sczl_cl7','sczl_cl8','sczl_cl9','sczl_cl10','sczl_cl11','sczl_cl12',
+            'sczl_fp1','sczl_fp2','sczl_fp3','sczl_fp4','sczl_fp5','sczl_fp6',
+            'sczl_fp7','sczl_fp8','sczl_fp9','sczl_fp10','sczl_fp11','sczl_fp12','sczl_desc'
+        ];
+        $data = [];
+        foreach ($arr as $key => $value){
+            if (!(isset($req[$value]))){
+                $this->error('参数错误',$value,$key+1);
+            }
+            $data[$value] = $req[$value];
+        }
+        $data['sys_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_手工检验')->fetchSql(true)->insert($data);
+            $bool = db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($bool===false) $this->error('失败');
+
+        $this->success('成功');
+
+    }
+
+    /**
+     * 新增
+     * @ApiMethod (POST)
+     * @param string
+     */
+    public function machineAdd()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        //sczl_num, sczl_NumDesc, sczl_fp
+        $arr = [
+            'sys_id','sczl_rq','sczl_bzdh',
+            'sczl_gdbh','sczl_yjgx','sczl_gxmc',
+            'sczl_jtbh','sczl_单据类型','sczl_检验类别','sczl_废品率系数',
+            'sczl_cl','sczl_PgCl','sczl_dedh',
+            'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
+            'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
+            'sczl_装版工时','sczl_保养工时','sczl_异常停机工时','sczl_设备运行工时',
+            'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6','sczl_bh7','sczl_bh8',
+            'sczl_desc'
+        ];
+        $data = [];
+        foreach ($arr as $key => $value){
+            if (!(isset($req[$value]))){
+                $this->error('参数错误',$value,$key+1);
+            }
+            $data[$value] = $req[$value];
+        }
+        $data['sys_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_机器检验')->fetchSql(true)->insert($data);
+            $bool = db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($bool===false) $this->error('失败');
+
+        $this->success('成功');
+
+    }
+
+    /**
+     * 修改
+     * @ApiMethod (POST)
+     * @param string 'UniqId'
+     */
+    public function edit()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        $arr = [
+            'sczl_rq','sczl_bzdh','sczl_bh0','sczl_cl0','sczl_fp0',
+            'sczl_gdbh','sczl_yjgx','sczl_gxmc',
+            'sczl_cl','sczl_dedh','sczl_检验类别','sczl_废品率系数',
+            'sczl_jsss','sczl_冲定额',
+            'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
+            'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
+            'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6',
+            'sczl_bh7','sczl_bh8','sczl_bh9','sczl_bh10','sczl_bh11', 'sczl_bh12',
+            'sczl_cl1','sczl_cl2','sczl_cl3','sczl_cl4','sczl_cl5','sczl_cl6',
+            'sczl_cl7','sczl_cl8','sczl_cl9','sczl_cl10','sczl_cl11','sczl_cl12',
+            'sczl_fp1','sczl_fp2','sczl_fp3','sczl_fp4','sczl_fp5','sczl_fp6',
+            'sczl_fp7','sczl_fp8','sczl_fp9','sczl_fp10','sczl_fp11','sczl_fp12','sczl_desc'
+        ];
+        $data = [];
+        foreach ($arr as $key => $value){
+            if (!(isset($req[$value]))){
+                continue;
+            }
+            $data[$value] = $req[$value];
+        }
+        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
+            $this->error('参数错误','UniqId',100);
+        }
+        $data['mod_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_手工检验')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
+            $bool = db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($bool===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+
+    /**
+     * 修改
+     * @ApiMethod (POST)
+     * @param string 'UniqId'
+     */
+    public function machineEdit()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        $arr = [
+            'sys_id','sczl_rq','sczl_bzdh',
+            'sczl_gdbh','sczl_yjgx','sczl_gxmc',
+            'sczl_jtbh','sczl_单据类型','sczl_检验类别','sczl_废品率系数',
+            'sczl_cl','sczl_PgCl','sczl_dedh',
+            'qczl_Num','qczl_NumDesc1','qczl_NumDesc2','qczl_NumDesc3','qczl_NumDesc4',
+            'qczl_NumDesc5','qczl_NumDesc6','qczl_NumDesc7','qczl_NumDesc8','qczl_NumDesc',
+            'sczl_装版工时','sczl_保养工时','sczl_异常停机工时','sczl_设备运行工时',
+            'sczl_bh1','sczl_bh2','sczl_bh3','sczl_bh4','sczl_bh5', 'sczl_bh6','sczl_bh7','sczl_bh8',
+            'sczl_desc'
+        ];
+        $data = [];
+        foreach ($arr as $key => $value){
+            if (!(isset($req[$value]))){
+                continue;
+            }
+            $data[$value] = $req[$value];
+        }
+        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
+            $this->error('参数错误','UniqId',100);
+        }
+        $data['mod_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_机器检验')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
+            $bool = db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($bool===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+
+    /**
+     * 修改
+     * @ApiMethod (POST)
+     * @param string 'UniqId'
+     */
+    public function del()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
+            $this->error('参数错误','UniqId',100);
+        }
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $bool = db()->table('db_手工检验')->where('UniqId',$req['UniqId'])->delete();
+
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($bool===false) $this->error('失败');
+
+        $this->success('成功');
+
+    }
+
+    /**
+     * 修改
+     * @ApiMethod (POST)
+     * @param string 'UniqId'
+     */
+    public function machineDel()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
+            $this->error('参数错误','UniqId',100);
+        }
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $bool = db()->table('db_机器检验')->where('UniqId',$req['UniqId'])->delete();
+
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($bool===false) $this->error('失败');
+
+        $this->success('成功');
+
+    }
 }

+ 0 - 2
application/api/controller/PackagingCountDocument.php

@@ -261,8 +261,6 @@ class PackagingCountDocument extends Api
 
         foreach ($rows as $key=>$value){
             $rows[$key]['jyGx'] =  sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
-            unset($rows[$key]['Gy0_yjno']);
-            unset($rows[$key]['Gy0_gxh']);
         }
 
         $this->success('成功',$rows);

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

@@ -255,8 +255,6 @@ class PackagingProcessOutput extends Api
             ->select();
         foreach ($rows as $key=>$value){
             $rows[$key]['jyGx'] =  sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
-            unset($rows[$key]['Gy0_yjno']);
-            unset($rows[$key]['Gy0_gxh']);
         }
 
         $this->success('成功',$rows);