cqpCow 1 year ago
parent
commit
844f5673ce

+ 3 - 3
app/Service/DispatchService.php

@@ -265,7 +265,7 @@ class DispatchService extends Service
     }
 
     public function orderListRule($data){
-        if(empty($data['process_id'])) return [false, '工序必须选择!'];
+//        if(empty($data['process_id'])) return [false, '工序必须选择!'];
         if(empty($data['out_order_no_time'][0]) || empty($data['out_order_no_time'][1])) return [false,'制单日期必须选择'];
         $bool = $this->is_same_month($data['out_order_no_time'][0],$data['out_order_no_time'][1]);
         if(! $bool) return [false,'制单日期必须同月!'];
@@ -274,7 +274,7 @@ class DispatchService extends Service
         $process_model = new OrdersProductProcess(['channel' => $time]);
         if(! $process_model->is_table_isset()) return [true, []];//不存在process子表 返回空数据
         $process_array = $process_model->where('del_time',0)
-            ->where('process_id',$data['process_id'])
+//            ->where('process_id',$data['process_id'])
             ->distinct()
             ->select('order_product_id')
             ->get()->toArray();
@@ -290,7 +290,7 @@ class DispatchService extends Service
         if(in_array(false, $data['quantity'], true) || in_array(0, $data['quantity'], true) || in_array('', $data['quantity'], true))return [false,'数量不能为空!'];
         if(empty($data['dispatch_time'][0]) || empty($data['dispatch_time'][1])) return [false,'计划生产时间不能为空!'];
         if(empty($data['out_order_no_time'][0]) || empty($data['out_order_no_time'][1])) return [false,'制单时间不能为空!'];
-        if($this->isEmpty($data,'process_id')) return [false,'工序不能为空!'];
+//        if($this->isEmpty($data,'process_id')) return [false,'工序不能为空!'];
         if(! isset($data['is_split'])) return [false,'是否拆分标识不能为空!'];
 
         $result = OrdersProduct::whereIn('id',$data['id'])

+ 11 - 7
app/Service/ProductionOrderService.php

@@ -51,12 +51,8 @@ class ProductionOrderService extends Service
         $production_no = $this->setOrderNO();
         if(empty($production_no)) return [false,'单据号生成失败!'];
         
-        //工艺 -> 工序
-        $technology = Technology::where('del_time',0)
-            ->orderBy('id','desc')
-            ->first();
-        if(empty($technology)) return [false,'工艺不存在!'];
-        $process_arr = explode(',',$technology->process_id);
+        //工序
+        $process_arr = explode(',',$data['technology']['process_id']);
 
         try{
             DB::beginTransaction();
@@ -189,7 +185,15 @@ class ProductionOrderService extends Service
         return [200,$list];
     }
 
-    public function orderRule($data){
+    public function orderRule(&$data){
+        if($this->isEmpty($data,'technology_id')) return [false, '工艺路线不能为空!'];
+        //工艺 -> 工序
+        $technology = Technology::where('del_time',0)
+            ->where('id',$data['technology_id'])
+            ->first();
+        if(empty($technology)) return [false,'工艺路线不存在或已被删除!'];
+        $technology = $technology->toArray();
+        $data['technology'] = $technology;
         if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
         if($this->isEmpty($data,'quantity')) return [false,'数量不能为空!'];
         if(in_array(false, $data['quantity'], true) || in_array(0, $data['quantity'], true) || in_array('', $data['quantity'], true)) return [false,'数量不能为空!'];

+ 1 - 1
app/Service/TechnologyService.php

@@ -54,7 +54,7 @@ class TechnologyService extends Service
     }
 
     public function technologyList($data){
-        $model = Technology::where('del_time',0)->select('*');
+        $model = Technology::where('del_time',0)->select('*')->orderBy('id', 'asc');
 
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');