소스 검색

包装工序产量维护新增删除修改

曹鹤洋 1 년 전
부모
커밋
de2cea68e6
1개의 변경된 파일133개의 추가작업 그리고 22개의 파일을 삭제
  1. 133 22
      application/api/controller/PackagingProcessOutput.php

+ 133 - 22
application/api/controller/PackagingProcessOutput.php

@@ -257,41 +257,152 @@ class PackagingProcessOutput extends Api
     }
 
     /**
-     * 获取工单信息信息
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
+     * 新增
+     * @ApiMethod (POST)
+     * @param string 'sys_id','sczl_rq',
+    'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
+    'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
+    'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
+    'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
+    'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
+    'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
      */
     public function add()
     {
         //get请求
-        if(!$this->request->post()){
+        if(!$this->request->isPost()){
             $this->error('请求方式错误');
         }
         $req = $this->request->param();
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
+        $arr = [
+            'sys_id','sczl_rq',
+            'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
+            'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
+            'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
+            'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
+            'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
+            'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
+        ];
+        $data = [];
+        foreach ($arr as $key => $value){
+            if (!(isset($req[$value]) && trim($req[$value])!='')){
+                $this->error('参数错误',$value,$key+1);
+            }
+            $data[$value] = $req[$value];
         }
-        $gxmc = '包装';
+        $data['sys_rq'] = date('Y-m-d H:i:s');
 
-        $rows = db()->table('工单_基本资料')
-            ->field('行号, rtrim(Gd_cpmc) as Gd_cpmc, 成品代号')
-            ->where('Gd_gdbh',$gdbh)
-            ->select();
-        foreach ($rows as $key=>$value){
-            $row = db()->table('产品_工艺资料')
-                ->field('Gy0_gxh')
-                ->where(['Gy0_cpdh'=>$value['成品代号'],'Gy0_yjno'=>$value['行号'], 'gy0_gxmc'=>['like','%'.$gxmc.'%']])
-                ->find();
-            $rows[$key]['jyGx'] =  sprintf("%02d", $value['行号']).'-'.$row['Gy0_gxh'];
-            unset($rows[$key]['行号']);
-            unset($rows[$key]['成品代号']);
+        //开启事务
+        db()->startTrans();
+        try{
+            $bool = db()->table('db_包装产量预报')->insert($data);
+
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
         }
 
-        $this->success('成功',$rows);
+        if($bool===false) $this->error('失败');
+
+        $this->success('成功');
+
+    }
+
+    /**
+     * 修改
+     * @ApiMethod (POST)
+     * @param string 'UniqId','sczl_rq',
+    'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
+    'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
+    'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
+    'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
+    'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
+    'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
+     */
+    public function edit()
+    {
+        //get请求
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        $arr = [
+            'sczl_rq',
+            'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
+            'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
+            'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
+            'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
+            'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
+            'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
+        ];
+        $data = [];
+        foreach ($arr as $key => $value){
+            if (!(isset($req[$value]) && trim($req[$value])!='')){
+                $this->error('参数错误',$value,$key+1);
+            }
+            $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{
+            $bool = db()->table('db_包装产量预报')->where('UniqId',$req['UniqId'])->update($data);
+
+            // 提交事务
+            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()
+    {
+        //get请求
+        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('成功');
+
+    }
 }