cqpCow 2 年之前
父节点
当前提交
44b3d5b338
共有 2 个文件被更改,包括 8 次插入5 次删除
  1. 6 4
      app/Service/DispatchService.php
  2. 2 1
      app/Service/ProductionOrderService.php

+ 6 - 4
app/Service/DispatchService.php

@@ -48,15 +48,18 @@ class DispatchService extends Service
         list($status,$msg) = $this->orderRule($data);
         list($status,$msg) = $this->orderRule($data);
         if(!$status) return [$status,$msg];
         if(!$status) return [$status,$msg];
 
 
+        $dispatch_no = $this->setOrderNO();
+        if(empty($dispatch_no)) return [false,'单据号生成失败!'];
+
         try{
         try{
             DB::beginTransaction();
             DB::beginTransaction();
 
 
             if($data['is_split']){
             if($data['is_split']){
                 foreach ($msg as $value){
                 foreach ($msg as $value){
-                    $this->insertDispatch([$value],$data,$user);
+                    $this->insertDispatch([$value],$data,$user,$dispatch_no);
                 }
                 }
             }else{
             }else{
-                $this->insertDispatch($msg,$data,$user);
+                $this->insertDispatch($msg,$data,$user,$dispatch_no);
             }
             }
 
 
             //反写已派工数量
             //反写已派工数量
@@ -145,12 +148,11 @@ class DispatchService extends Service
         return $arr;
         return $arr;
     }
     }
 
 
-    public function insertDispatch($msg, $data, $user){
+    public function insertDispatch($msg, $data, $user,$dispatch_no){
         //生产数据的源数据
         //生产数据的源数据
         $result = $msg;
         $result = $msg;
         $time = time();
         $time = time();
 
 
-        $dispatch_no = $this->setOrderNO();
         //主表
         //主表
         Dispatch::insert(['dispatch_no' => $dispatch_no,'crt_time' => $time]);
         Dispatch::insert(['dispatch_no' => $dispatch_no,'crt_time' => $time]);
 
 

+ 2 - 1
app/Service/ProductionOrderService.php

@@ -49,7 +49,8 @@ class ProductionOrderService extends Service
         if(!$status) return [$status,$msg];
         if(!$status) return [$status,$msg];
 
 
         $production_no = $this->setOrderNO();
         $production_no = $this->setOrderNO();
-
+        if(empty($production_no)) return [false,'单据号生成失败!'];
+        
         //工艺 -> 工序
         //工艺 -> 工序
         $technology = Technology::where('del_time',0)
         $technology = Technology::where('del_time',0)
             ->orderBy('id','desc')
             ->orderBy('id','desc')