소스 검색

工单工序调整

qiuenguang 1 년 전
부모
커밋
1d16157371
1개의 변경된 파일48개의 추가작업 그리고 31개의 파일을 삭제
  1. 48 31
      application/api/controller/WorkOrder.php

+ 48 - 31
application/api/controller/WorkOrder.php

@@ -724,42 +724,59 @@ class WorkOrder extends Api
         if (empty($param)){
         if (empty($param)){
             $this->error('参数错误');
             $this->error('参数错误');
         }
         }
-        $UniqId = [];
-        $lastId = \db('工单_工艺资料')->field('rtrim(UniqId) as id')->order('UniqId desc')->find();
-        if ($lastId['id']>10000000){
-            $lastUniqId = $lastId['id'];
-        }else{
-            $lastUniqId = 10000000;
-        }
-        foreach ($param as $key=>$value){
-            $UniqId[$key] = $value['UniqId'];
-        }
-        $processList = \db('工单_工艺资料')->where('UniqId','in',$UniqId)->select();
-        if (empty($processList)){
-            $this->success('未找到工艺资料');
-        }
-        $data = [];
-        foreach ($param as $key=>$value){
-            foreach ($processList as $k=>$v){
-                if ($value['UniqId'] = $v['UniqId']){
-                    $data[$key] = $v;
-                    $data[$key]['Gy0_gxh'] = $value['gxh'];
-                    $data[$key]['Gy0_gdbh'] = $value['workOrder'];
-                    $data[$key]['UniqId'] = $lastUniqId + $key + 1;
-                }
+        $i = 0;
+        foreach ($param as $key => $value){
+            $sql = \db('工单_工艺资料')
+                ->where('UniqId',$value['UniqId'])
+                ->fetchSql(true)
+                ->update(['Gy0_gxh'=>$value['gxh']]);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $i++;
             }
             }
         }
         }
-        $res = \db('工单_工艺资料')->where(['Gy0_gdbh'=>$param[0]['workOrder']])->delete();
-        if ($res !== false){
-            $result = \db('工单_工艺资料')->insertAll($data);
-            if ($result !== false){
-                $this->success('成功');
-            }else{
-                $this->error('失败');
-            }
+        if ($i === 0){
+            $this->success('成功');
         }else{
         }else{
             $this->error('失败');
             $this->error('失败');
         }
         }
+//        $UniqId = [];
+//        $lastId = \db('工单_工艺资料')->field('rtrim(UniqId) as id')->order('UniqId desc')->find();
+//        if ($lastId['id']>10000000){
+//            $lastUniqId = $lastId['id'];
+//        }else{
+//            $lastUniqId = 10000000;
+//        }
+//        foreach ($param as $key=>$value){
+//            $UniqId[$key] = $value['UniqId'];
+//        }
+//        $processList = \db('工单_工艺资料')->where('UniqId','in',$UniqId)->select();
+//        if (empty($processList)){
+//            $this->success('未找到工艺资料');
+//        }
+//        halt($processList);
+//        $data = [];
+//        foreach ($param as $key=>$value){
+//            foreach ($processList as $k=>$v){
+//                if ($value['UniqId'] = $v['UniqId']){
+//                    $data[$key] = $v;
+//                    $data[$key]['Gy0_gxh'] = $value['gxh'];
+//                    $data[$key]['Gy0_gdbh'] = $value['workOrder'];
+//                    $data[$key]['UniqId'] = $lastUniqId + $key + 1;
+//                }
+//            }
+//        }
+//        $res = \db('工单_工艺资料')->where(['Gy0_gdbh'=>$param[0]['workOrder']])->delete();
+//        if ($res !== false){
+//            $result = \db('工单_工艺资料')->insertAll($data);
+//            if ($result !== false){
+//                $this->success('成功');
+//            }else{
+//                $this->error('失败');
+//            }
+//        }else{
+//            $this->error('失败');
+//        }
     }
     }
 
 
     /**
     /**