cqpCow 2 жил өмнө
parent
commit
7983d20f58

+ 1 - 1
app/Service/DeleteOrderService.php

@@ -298,7 +298,7 @@ class DeleteOrderService extends Service
     }
 
     //产成品入库
-    public function insertSqlServer($array){return [true, ''];
+    public function insertSqlServer($array){
         if(empty($array)) return [true,''];
 
         $sqlServerModel = new FyySqlServerService();

+ 2 - 2
app/Service/DispatchService.php

@@ -214,7 +214,7 @@ class DispatchService extends Service
 
         $model = OrdersProduct::where('del_time',0)
             ->select('id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity','production_time','production_no','status','crt_id')
-//            ->whereBetween('out_order_no_time',[$data['out_order_no_time'][0],$data['out_order_no_time'][1]])
+            ->whereBetween('out_order_no_time',[$data['out_order_no_time'][0],$data['out_order_no_time'][1]])
             ->whereIn('id',$msg)
             ->orderBy('id','desc');
 
@@ -272,7 +272,7 @@ class DispatchService extends Service
         if($this->isEmpty($data,'process_id')) return [false,'工序不能为空!'];
 
         $result = OrdersProduct::whereIn('id',$data['id'])
-            ->select('id as order_product_id','sale_orders_product_id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','production_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','sale_orders_product_id','out_order_no_time','price')
+            ->select('id as order_product_id','sale_orders_product_id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','production_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','sale_orders_product_id','out_order_no_time','price','customer_name')
             ->orderBy('id','desc')
             ->get()->toArray();
 

+ 10 - 6
app/Service/FinishedOrderService.php

@@ -137,10 +137,14 @@ class FinishedOrderService extends Service
             //反写数量
             $this->writeFinishedQuantity(array_column($result,'sale_orders_product_id'));
 
-            list($status,$msg) = $this->insertSqlServer($insert_sql_server);
-            if(! $status) {
-                DB::rollBack();
-                return [false,$msg];
+            if(! empty($insert_sql_server)){
+                foreach ($insert_sql_server as $value){
+                    list($status,$msg) = $this->insertSqlServer($value);
+                    if(! $status) {
+                        DB::rollBack();
+                        return [false,$msg];
+                    }
+                }
             }
 
             DB::commit();
@@ -207,7 +211,7 @@ class FinishedOrderService extends Service
         if($this->isEmpty($data,'finish_id') && $this->isEmpty($data,'team_id')) return [false,'人员和班组不能都为空!'];
 
         $result = DispatchSub::whereIn('id',$data['id'])
-            ->select('id','finished_num','dispatch_quantity','out_order_no_time','process_id','dispatch_no','order_product_id','sale_orders_product_id','order_no','product_no','product_title','price')
+            ->select('id','finished_num','dispatch_quantity','out_order_no_time','process_id','dispatch_no','order_product_id','sale_orders_product_id','order_no','product_no','product_title','price','customer_name')
             ->orderBy('id','desc')
             ->get()->toArray();
 
@@ -448,7 +452,7 @@ class FinishedOrderService extends Service
     }
 
     //产成品入库
-    public function insertSqlServer($array){return [true, ''];
+    public function insertSqlServer($array){
         if(empty($array)) return [true,''];
 
         $sqlServerModel = new FyySqlServerService();

+ 31 - 25
app/Service/FyySqlServerService.php

@@ -180,7 +180,8 @@ class FyySqlServerService extends Service
         $result = $model->get()->toArray();
         if(empty($result)) return [false,'暂无数据,更新结束!',''];
         list($status,$msg) = $this->orderRule($result);
-        if(! $status) return [false,$msg,''];
+        if(empty($msg)) return [false,'暂无数据,更新结束!',''];
+        $result = $msg;
 
         //查询附带的一些信息(比较少)
         $product_no = array_column($result,'product_no');
@@ -243,9 +244,16 @@ class FyySqlServerService extends Service
             ->whereIn('out_order_no',array_column($data,'out_order_no'))
             ->select('out_order_no')
             ->get()->toArray();
-        if(! empty($result))  return [false,'查询区间内销售订单号已存在'];
+        $out_order_no = array_column($result,'out_order_no');
+        if(! empty($out_order_no)) {
+            foreach ($data as $key => $value){
+                if(in_array($value->out_order_no,$out_order_no)){
+                    unset($data[$key]);
+                }
+            }
+        }
 
-        return [true,''];
+        return [true,$data];
     }
 
     //获取数据(刷新现存量)
@@ -293,29 +301,26 @@ class FyySqlServerService extends Service
         if($bredvouch){
             $cmemo = '来源:福羊羊完工操作撤回';
         }else{
-            $cmemo = '来源:福羊羊完工操作';
+            $cmemo = '来源:福羊羊完工操作 派工单号:'. $data['dispatch_no'];
         }
 
         //数据
-        $bodys = [];
-        foreach ($data as $value){
-            $bodys[] = [
-                "cinvcode" => $value["product_no"],
-                "cposition" => "",
-                "cbatch" => "",
-                "iquantity" => $value["quantity"],
-                "inum" => $value["quantity"],
-                "iunitcost" => $value["price"] * 0.95,
-                "iprice" => $value["price"] * 0.95 * $value['quantity'],
-                "iinvexchrate" => "1.00",
-                "impoids" => "",
-                "cmocode" => "",
-                "imoseq" => "",
-                "cbmemo" => "",
-                "cfree1" => "",
-                "cfree2" => ""
-            ];
-        }
+        $bodys[] = [
+            "cinvcode" => $data["product_no"],
+            "cposition" => "",
+            "cbatch" => "",
+            "iquantity" => $data["quantity"],
+            "inum" => $data["quantity"],
+            "iunitcost" => $data["price"] * 0.95,
+            "iprice" => $data["price"] * 0.95 * $data['quantity'],
+            "iinvexchrate" => "1.00",
+            "impoids" => "",
+            "cmocode" => "",
+            "imoseq" => "",
+            "cbmemo" => "",
+            "cfree1" => "",
+            "cfree2" => "",
+        ];
         $post = [
             "password"=>"cloud@123456",
             "entity"=>"U8Rdrecord10Save",
@@ -335,9 +340,10 @@ class FyySqlServerService extends Service
                 "IsExamine"=>true,
                 "bredvouch"=> $bredvouch,
                 "cwhcode"=>"02",
-                "cdepcode"=>"",
-                "crdcode"=>"",
+                "cdepcode"=>"06",
+                "crdcode"=>"102", //生产入库
                 "cmemo"=> $cmemo,
+                "cdefine10" => $data['customer_name'], //客户名称
                 "bodys"=>$bodys
             ]
         ];