Browse Source

新增工序优化

unknown 1 week ago
parent
commit
678af342cb
1 changed files with 5 additions and 21 deletions
  1. 5 21
      application/api/controller/WorkOrderProcess.php

+ 5 - 21
application/api/controller/WorkOrderProcess.php

@@ -361,42 +361,26 @@ class WorkOrderProcess extends Api
         if (empty($params['big_process'])) {
         if (empty($params['big_process'])) {
             $this->error('大工艺不能为空');
             $this->error('大工艺不能为空');
         }
         }
-        // if (empty($params['standard_hour'])) {
-        //     $this->error('标准工时不能为空');
-        // }
-        // if (empty($params['standard_score'])) {
-        //     $this->error('标准公分不能为空');
-        // // }
-        // if (empty($params['coefficient'])) {
-        //     $params['coefficient'] = 'C';
-        // }
         if (empty($params['sys_id'])) {
         if (empty($params['sys_id'])) {
             $this->error('系统人不能为空');
             $this->error('系统人不能为空');
         }
         }
 
 
-        // 检查是否传入了process_code
         if (!empty($params['process_code'])) {
         if (!empty($params['process_code'])) {
-            $code = $params['process_code'];
-            // 检查是否存在冲突
+            $code = intval($params['process_code']);
             $exists = db('工单_基础工艺资料')
             $exists = db('工单_基础工艺资料')
                 ->where('work_order', $params['workorder'])
                 ->where('work_order', $params['workorder'])
                 ->where('part_code', $params['part_code'])
                 ->where('part_code', $params['part_code'])
-                ->where('process_code', '>=', $code)
+                ->where('process_code', $code)
+                ->whereNull('del_rq')
                 ->count();
                 ->count();
-
             if ($exists > 0) {
             if ($exists > 0) {
-                // 如果存在冲突,将后续编号自动加1
-                db('工单_基础工艺资料')
-                    ->where('work_order', $params['workorder'])
-                    ->where('part_code', $params['part_code'])
-                    ->where('process_code', '>=', $code)
-                    ->setInc('process_code');
+                $this->error('工序编号已存在');
             }
             }
         } else {
         } else {
-            // 如果没有传入process_code,按照原来的逻辑生成
             $code = db('工单_基础工艺资料')
             $code = db('工单_基础工艺资料')
                 ->where('work_order', $params['workorder'])
                 ->where('work_order', $params['workorder'])
                 ->where('part_code', $params['part_code'])
                 ->where('part_code', $params['part_code'])
+                ->whereNull('del_rq')
                 ->max('process_code');
                 ->max('process_code');
             $code = $code ? $code + 1 : 1;
             $code = $code ? $code + 1 : 1;
         }
         }