ソースを参照

印版领用记录

qiuenguang 1 年間 前
コミット
d27794834f
1 ファイル変更67 行追加1 行削除
  1. 67 1
      application/api/controller/Facility.php

+ 67 - 1
application/api/controller/Facility.php

@@ -925,7 +925,8 @@ class Facility extends Api
                 SUBSTRING(a.YB_Cpdh,1,4) as `客户编号`,
                 RTRIM(f.`Gd_客户名称`) as `客户名称`,
                 RTRIM(a.YB_Cpdh) as `产品编号`,
-                RTRIM(f.Gd_cpmc) as `产品名称`
+                RTRIM(f.Gd_cpmc) as `产品名称`,
+                RTRIM(d.UniqID) as UniqId
                 FROM `产品_印版资料` as a 
                 LEFT JOIN `产品_印版库` as b ON b.`存货编码` = a.`存货编码`
                 JOIN `物料_存货编码` as c ON c.`物料代码` = a.`存货编码`
@@ -1736,4 +1737,69 @@ class Facility extends Api
             $this->error('删除失败');
         }
     }
+
+    /**
+     * 印版领用记录添加
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function PrintDetailAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $lastId = \db('工单_印版领用记录')->order('UniqID desc')->value('UniqID');
+        foreach ($param as $key=>$value){
+            $param[$key]['Yb_领用日期'] = date('Y-m-d H:i:s',time());
+            $param[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
+            $param[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
+            $param[$key]['UniqID'] = $lastId + $key +1;
+        }
+        $sql = \db('工单_印版领用记录')->fetchSql(true)->insertAll($param);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('添加成功');
+        }else{
+            $this->error('添加失败');
+        }
+    }
+
+    /**
+     * 印版领用记录退还
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function PrintDetailEdit()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$param['id']);
+        $i = 0;
+        foreach ($idList as $key=>$value){
+            $data['Yb_退还日期'] = date('Y-m-d H:i:s',time());
+            $data['Mod_rq'] = date('Y-m-d H:i:s',time());
+            $sql = \db('工单_印版领用记录')->where('UniqID',$value)->fetchSql(true)->update($data);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $i++;
+            }
+        }
+        if ($i !== 0){
+            $this->error('退还失败');
+        }else{
+            $this->success('退还成功');
+        }
+    }
 }