浏览代码

引用工单

qiuenguang 1 年之前
父节点
当前提交
4701123785
共有 1 个文件被更改,包括 91 次插入13 次删除
  1. 91 13
      application/api/controller/WorkOrder.php

+ 91 - 13
application/api/controller/WorkOrder.php

@@ -505,13 +505,19 @@ class WorkOrder extends Api
         {
             $this->error('参数错误');
         }
+        $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
+        if ($lastId<10000000){
+            $lastId = 10000000;
+        }else{
+            $lastId = $lastId + 1;
+        }
         //获取原工单工艺资料
         $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->select();
         $ProsessUniqId = \db('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
         foreach ($oldProcessData as $k=>$v){
             $oldProcessData[$k]['Gy0_gdbh']  = $newWorkOrder;
             $oldProcessData[$k]['Sys_id'] = '';
-            $oldProcessData[$k]['UniqId'] = $ProsessUniqId['UniqId'] + $k + 1;
+            $oldProcessData[$k]['UniqId'] = $lastId + $k;
         }
         if (\db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->find()){
             \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->delete();
@@ -1464,18 +1470,90 @@ class WorkOrder extends Api
         $this->success('成功',$list);
     }
 
+    /**
+     * 新增印件资料->印件资料添加
+     * @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');
+        if ($lastId<1000000){
+            $lastId = 1000000;
+        }else{
+            $lastId = $lastId + 1;
+        }
+        $param['Uniqid'] = $lastId;
+        $param['Sys_rq'] = date('Y-m-d H:i:s',time());
+        $param['Mod_rq'] = date('Y-m-d H:i:s',time());
+        $sql = \db('工单_印件资料')->fetchSql(true)->insert($param);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+
+    //新增工艺资料->工艺资料添加
+
+    public function ProcessDetailAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
+        if ($lastId<100000000){
+            $lastId = 100000000;
+        }else{
+            $lastId = $lastId + 1;
+        }
+
+    }
+
+    /**
+     * 新增工艺资料->印件编号获取
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function PrintDetailList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $printList = \db('工单_印件资料')
+            ->where('Yj_Gdbh',$param['workOrder'])
+            ->order('yj_Yjno')
+            ->select();
+        if (empty($printList)){
+            $this->success('未找到该工单印件资料');
+        }
+        $list = [];
+        foreach ($printList as $key=>$value){
+            $list[$key]['name'] = rtrim($value['yj_Yjno']).'-->'.rtrim($value['yj_yjmc']);
+            $list[$key]['no'] = rtrim($value['yj_Yjno']);
+        }
+        $this->success('成功',$list);
+    }
 
-    //新增印件资料->印件资料添加
 
-//    public function PrintDetailAdd()
-//    {
-//        if (Request::instance()->isPost() === false){
-//            $this->error('请求错误');
-//        }
-//        $param = Request::instance()->post();
-//        if (empty($param)){
-//            $this->error('参数错误');
-//        }
-//
-//    }
 }