cqp 3 månader sedan
förälder
incheckning
5c99e4da82
2 ändrade filer med 4 tillägg och 7 borttagningar
  1. 1 1
      app/Service/CommandService.php
  2. 3 6
      app/Service/ProductionOrderService.php

+ 1 - 1
app/Service/CommandService.php

@@ -30,7 +30,7 @@ class CommandService extends Service
 //        }
     }
 
-    public function productionAdd($data,$user,$id){dd(1);
+    public function productionAdd($data,$user,$id){
         $service = new ProductionOrderService();
         list($status,$msg) = $service->orderRule($data);
         //生产数据的源数据

+ 3 - 6
app/Service/ProductionOrderService.php

@@ -213,14 +213,11 @@ class ProductionOrderService extends Service
     public function orderRule(&$data){
         if($this->isEmpty($data,'process_id')) return [false, '工序不能为空!'];
         //工序
-        $process = Process::whereIn('id', $data['process_id'])->get()->toArray();
+        $process = Process::whereIn('id', $data['process_id'])->where("del_time",0)->pluck("title","id")->toArray();
         if(empty($process)) return [false,'工序不存在或已被删除!'];
-        $process_id = [];
-        foreach ($process as $value){
-            if($value['del_time'] > 0) return [false, '工序:' . $value['title'] . '不存在或已被删除!'];
-            $process_id[] = $value['id'];
+        foreach ($data['process_id'] as $value){
+            if(! isset($process[$value])) return [false, "工序不存在或已被删除"];
         }
-        $data['process_id'] = $process_id;
         if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
         if($this->isEmpty($data,'quantity')) return [false,'数量不能为空!'];
         $quantities = array_map('floatval', $data['quantity']);