liuhairui преди 2 седмици
родител
ревизия
23d237d8b3
променени са 1 файла, в които са добавени 68 реда и са изтрити 0 реда
  1. 68 0
      application/api/controller/Product.php

+ 68 - 0
application/api/controller/Product.php

@@ -420,6 +420,7 @@ class Product extends Api
             a.big_process,
             a.standard_hour,
             a.standard_score,
+            a.difficulty_coef,
             a.sys_id,
             a.sys_rq,
             a.updatetime,
@@ -559,6 +560,73 @@ class Product extends Api
         }
     }
 
+    /**
+     * 调整部件与工艺序号牌组
+     */
+    public function UpdataSort(){
+        if (!Request::instance()->isPost()) {
+            $this->error('非法请求');
+        }
+
+        $params = Request::instance()->param();
+
+        $product_code = $params['product_code'];
+        $sys_id       = $params['sys_id'];
+
+        if (empty($product_code)) {
+            $this->error('产品编号不能为空');
+        }
+
+        // ======================
+        // 更新 产品_部件资料
+        // ======================
+        if (!empty($params['part_list']) && is_array($params['part_list'])) {
+            foreach ($params['part_list'] as $item) {
+                $id = $item['id'] ?? 0;
+                if ($id <= 0) continue;
+
+                // 🔥 把要更新的内容放变量里
+                $updateData = [
+                    'part_sort' => $item['part_sort'],
+                    'part_name' => $item['part_name'],
+                    'sys_id'  => $sys_id
+                ];
+
+                Db::name('产品_部件资料')
+                    ->where('id', $id)
+                    ->update($updateData);
+            }
+        }
+
+        // ======================
+        // 更新 产品_工艺资料
+        // ======================
+        if (!empty($params['process_list']) && is_array($params['process_list'])) {
+            foreach ($params['process_list'] as $item) {
+                $id = $item['id'] ?? 0;
+                if ($id <= 0) continue;
+
+                // 🔥 把要更新的内容放变量里
+                $updateData = [
+                    'gy_sort'        => $item['gy_sort'],
+                    'gy_name'        => $item['gy_name'] ,
+                    'big_process'    => $item['big_process'],
+                    'standard_hour'  => $item['standard_hour'],
+                    'standard_score' => $item['standard_score'],
+                    'part_sort'      => $item['part_sort'],
+                    'part_name'      => $item['part_name'],
+                    'sys_id'       => $sys_id
+                ];
+
+                Db::name('产品_工艺资料')
+                    ->where('id', $id)
+                    ->update($updateData);
+            }
+        }
+
+        $this->success('排序更新成功');
+    }
+
     /**
      * Excel 导入 部件 + 工艺
      */