瀏覽代碼

工单资料

qiuenguang 1 年之前
父節點
當前提交
028024dda6
共有 1 個文件被更改,包括 108 次插入22 次删除
  1. 108 22
      application/api/controller/WorkOrder.php

+ 108 - 22
application/api/controller/WorkOrder.php

@@ -75,25 +75,27 @@ class WorkOrder extends Api
             $this->error('请求错误');
         }
         $search = input('search');
-
         $limit = input('limit');
-//        $page = input('page');
         $clientNumber = input('Gd_khdh');
         $startTime = input('start');
         $endTime = input('end');
-        $where = [
-            '成品代号' => ['like',$clientNumber.'%']
-        ];
-//        if (isset($search)){
-//            $where['']
-//        }
-        if (isset($startTime) && isset($endTime)){
+        $workOrder = input('workOrder');
+        $productCode = input('productCode');
+        if (!empty($clientNumber)){
+            $where['成品代号'] = ['like',$clientNumber.'%'];
+        }
+        if (!empty($workOrder)){
+            $where['Gd_gdbh'] = $workOrder;
+        }
+        if (!empty($productCode)){
+            $where['Gd_cpdh'] = $productCode;
+        }
+        if (!empty($search)){
+            $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$search.'%'];
+        }
+        if (!empty($startTime) && !empty($endTime)){
             $where['接单日期'] = ['between',[$startTime,$endTime]];
         }
-//        $config = [
-//            'page_param' => $page,
-//            'per_page' => $limit
-//        ];
         $list = Db::table('工单_基本资料')
             ->where($where)
             ->order('接单日期 desc')
@@ -121,6 +123,7 @@ class WorkOrder extends Api
                 '建档用户' => rtrim($value['Sys_id']),
                 '建档时间' => rtrim($value['Sys_rq']),
                 '更新时间' => rtrim($value['Mod_rq']),
+                'Uniqid' => rtrim($value['Uniqid'])
             ];
         }
         $this->success('成功',$data);
@@ -248,7 +251,8 @@ class WorkOrder extends Api
                     '质量要求' => rtrim($value['质量要求']),
                     '质量隐患' => rtrim($value['质量隐患']),
                     '开数' => rtrim($value['Gy0_ks']),
-                    '联数' => rtrim($value['Gy0_ls'])
+                    '联数' => rtrim($value['Gy0_ls']),
+                    'UniqId' => rtrim($value['UniqId'])
                 ];
             }
         }
@@ -309,7 +313,7 @@ class WorkOrder extends Api
         $field = 'rtrim(Gd_lx) as 重点工单,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_生产分类) as 生产类型,rtrim(Gd_khdh) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
         rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(开单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
         rtrim(投料率) as 投料率,rtrim(实际投料) as 万小张,rtrim(计量单位) as 单位,rtrim(投料大箱) as 投料大箱,rtrim(排产时库存) as 库存大箱,rtrim(警语版面) as 警语版面,
-        rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注';
+        rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注,rtrim(Uniqid) as Uniqid';
         $list = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
         if (empty($list)){
             $this->error('未找到该工单信息');
@@ -330,7 +334,7 @@ class WorkOrder extends Api
     /**
      * 工单资料修改
      * @ApiMethod (POST)
-     * @param  array $data   上传数据
+     * @param  void
      * @return void
      * @throws \think\Exception
      * @throws \think\exception\PDOException
@@ -341,16 +345,41 @@ class WorkOrder extends Api
         if ($this->request->isPost() === false){
             $this->error('请求错误');
         }
-        $data = input('data');
-        if (empty($data)){
+        $param = $this->request->param();
+        if (empty($param) || isset($param['Uniqid']) === false){
             $this->error('参数错误');
         }
-        $sql = Db::table('工单_基本资料')->where('Gd_gdbh',$data['Gd_gdbh'])->fetchSql(true)->update($data);
+        $row = [
+            'Gd_lx' => isset($param['lx'])?$param['lx']:'',
+            '开单日期' => isset($param['kdrq'])?$param['kdrq']:'',
+            'Gd_gdbh' => isset($param['gdbh'])?$param['gdbh']:'',
+            'Gd_生产分类' => isset($param['scfl'])?$param['scfl']:'',
+            'Gd_客户代号' => isset($param['khdh'])?$param['khdh']:'',
+            'Gd_客户名称' => isset($param['khmc'])?$param['khmc']:'',
+            '成品代号' => isset($param['cpdh'])?$param['cpdh']:'',
+            '成品名称' => isset($param['cpmc'])?$param['cpmc']:'',
+            '订单数量' => isset($param['ddsl'])?$param['ddsl']:'',
+            '交货日期' => isset($param['jhrq'])?$param['jhrq']:'',
+            '投料率' => isset($param['tll'])?$param['tll']:'',
+            '计划投料' => isset($param['jhtl'])?$param['jhtl']:'',
+            '实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
+            '计量单位' => isset($param['jldw'])?$param['jldw']:'',
+            '投料大箱' => isset($param['tldx'])?$param['tldx']:'',
+            '销售订单号' => isset($param['xsddh'])?$param['xsddh']:'',
+            '警语版面' => isset($param['jymb'])?$param['jymb']:'',
+            '产品版本号' => isset($param['bbh'])?$param['bbh']:'',
+            '客户ERP编码' => isset($param['erp'])?$param['erp']:'',
+            '码源数量' => isset($param['ymsl'])?$param['ymsl']:'',
+            '进程备注' => isset($param['jcbz'])?$param['jcbz']:'',
+            'Gd_desc' => isset($param['desc'])?$param['desc']:'',
+        ];
+        $sql = Db::table('工单_基本资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($row);
         $res = Db::query($sql);
-        if ($res === 0){
-            $this->error('修改失败');
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
         }
-        $this->success('成功');
     }
 
 
@@ -890,4 +919,61 @@ class WorkOrder extends Api
         }
 
     }
+
+    /**
+     * 工艺资料修改
+     * @ApiMethod (POST)
+     * @param void
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function ProcessDetailEdit()
+    {
+        if ($this->request->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param) || isset($param['UniqId']) === false){
+            $this->error('参数错误');
+        }
+        $rate = Db::table('dic_lzsh')->where('sys_bh',$param['shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
+        $data = [
+            'Gy0_yjno' => isset($param['yjno'])?$param['yjno']:'',
+            'Gy0_gxh' => isset($param['gxh'])?$param['gxh']:'',
+            '重点工序' => isset($param['zdgx'])?$param['zdgx']:'',
+            'Gy0_ks' => isset($param['ks'])?$param['ks']:'',
+            'Gy0_ls' => isset($param['ls'])?$param['ls']:'',
+            'Gy0_SITE' => isset($param['site'])?$param['site']:'',
+            'Gy0_gxmc' => isset($param['gxmc'])?$param['gxmc']:'',
+            'Add_gxmc' => isset($param['add_gxmc'])?$param['add_gxmc']:'',
+            'Gy0_ms' => isset($param['ms'])?$param['ms']:'',
+            'Gy0_sbbh' => isset($param['sbbh'])?$param['sbbh']:'',
+            'Gy0_Rate0' => $rate['rate0'],
+            'Gy0_Rate1' => $rate['rate1'],
+            'Gy0_辅助工时' => isset($param['fzgs'])?$param['fzgs']:'',
+            'Gy0_小时产能' => isset($param['xscn'])?$param['xscn']:'',
+            'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
+            '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
+            '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
+            '印刷方式' => isset($param['ysfs'])?$param['ysfs']:'',
+            '版距' => isset($param['bj'])?$param['bj']:'',
+            '工序备注' => isset($param['gxbz'])?$param['gxbz']:'',
+            '质量要求' => isset($param['zlyq'])?$param['zlyq']:'',
+            '质量隐患' => isset($param['sbyh'])?$param['sbyh']:'',
+            'Mod_rq' => date('Y-m-d H:i:s',time()),
+        ];
+        $sql = Db::table('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
+        $res = Db::query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    //
 }