chenqp 1 year ago
parent
commit
1b5f8ffc61

+ 4 - 2
app/Console/Commands/InsertCloudCommand.php

@@ -3,6 +3,7 @@
 namespace App\Console\Commands;
 
 use App\Service\CloudDataService;
+use App\Service\InspectService;
 use Illuminate\Console\Command;
 
 class InsertCloudCommand extends Command
@@ -39,8 +40,9 @@ class InsertCloudCommand extends Command
     public function handle()
     {
         echo 'start---------------';
-        $service = new CloudDataService();
-        $service->cloudData();
+        $service = new InspectService();
+        list($status,$msg) = $service->addOnSiteInspectionOrder();
+        if(! $status) echo $msg;
         echo 'end-------------';
     }
 }

+ 13 - 0
app/Http/Controllers/Api/FyyOrderController.php

@@ -23,6 +23,19 @@ class FyyOrderController extends BaseController
         }
     }
 
+    public function salesOrderList(Request $request)
+    {
+        $service = new FyyOrderService();
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->salesOrderList($request->all(),$userData);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
     public function add(Request $request)
     {
         $service = new FyyOrderService();

+ 193 - 81
app/Service/Box/BoxService.php

@@ -5,10 +5,14 @@ namespace App\Service\Box;
 
 use App\Model\Box;
 use App\Model\BoxDetail;
+use App\Model\DispatchSub;
 use App\Model\Header_ext;
 use App\Model\OrdersProduct;
+use App\Model\OrdersProductBom;
+use App\Model\OrdersProductProcess;
 use App\Model\SaleOrdersProduct;
 use App\Model\Team;
+use App\Service\DispatchService;
 use App\Service\FinishedOrderService;
 use App\Service\FyySqlServerService;
 use App\Service\Service;
@@ -25,15 +29,13 @@ class BoxService extends Service
     protected static $box_header;
     protected static $box_detail_header;
     protected static $box_hook;
-    public $lock_key = 'box';
+    public $lock_key = 'hc_box_add';
 
     public function __construct()
     {
-
         self::$box_header = Header_ext::where('type', 'box')->pluck('value', 'key')->toArray();
         self::$box_detail_header = Header_ext::where('type', 'box_detail')->pluck('value', 'key')->toArray();
         self::$box_hook = BoxHookService::getInstance();
-
     }
 
     /**
@@ -67,12 +69,15 @@ class BoxService extends Service
         }
         $insert = [];
 
+        //限制频率
+        $limit_key = $this->lock_key;
+        list($status,$msg) = $this->limitingSendRequestBackgNeed($limit_key);
+        if(! $status) return [false, '正常生成包装数据,以及用友数据,请稍后操作!'];
+
         try{
             DB::beginTransaction();
-            $time = time();
-            $key = $this->lock_key.'_'.$v['id'];
-            $lock_status = $this->isLock($key);
-            if(!$lock_status) return [false,'操作过于频繁'];
+
+            //数据获取
             $product_list = OrdersProduct::wherein('id', $ids)->get()->toArray();
             $sale_product_list = SaleOrdersProduct::wherein('id', $sale_ids)->get()->toArray();
 
@@ -83,8 +88,8 @@ class BoxService extends Service
                 $total = $num_list['total'];
                 $detail = $num_list['detail'];
                 $team_id = $num_list['team_id'];
-                $un_box_num = $v['dispatch_complete_quantity'] - $v['box_num'];//todo
-                if ($total > $un_box_num) return [false, $v['product_title'] . '数量不足'];
+                $un_box_num = bcsub($v['dispatch_complete_quantity'] , $v['box_num'],3);
+                if ($total > $un_box_num) return [false, $v['product_title'] . ' ' . $v['technology_name'] . ' 可包装的数量不足'];
 
                 $ext_1 = $v['product_no'];//产品编号
                 $ext_2 = $v['technology_material']; //工艺材质 废弃
@@ -122,8 +127,8 @@ class BoxService extends Service
                 ]);
             }
 
-            //销售订单包装----------------
-            foreach ($sale_product_list as $v) {
+            //销售订单包装----------------todo 目前只能按找生产包所以continue
+            foreach ($sale_product_list as $v) {continue;
                 $box_type = 0;
                 if($v['id'] < 0)  {
                     $v['id'] = -$v['id'];
@@ -134,7 +139,7 @@ class BoxService extends Service
                 $detail = $num_list['detail'];
                 $team_id = $num_list['team_id'];
                 $box_detail = new BoxDetail(['channel'=>$top_order_no]);
-                $un_box_num = $v['order_quantity'] - $v['box_num'] - $box_detail->where('top_id',$v['id'])->where('del_time',0)->where('box_type',1)->sum('num');//todo
+                $un_box_num = $v['order_quantity'] - $v['box_num'] - $box_detail->where('top_id',$v['id'])->where('del_time',0)->where('box_type',1)->sum('num');
                 if ($total > $un_box_num) return [false, $v['product_title'] . '数量不足'];
 
                 $ext_1 = $v['product_no'];//产品编号
@@ -181,10 +186,18 @@ class BoxService extends Service
             $insert['shipment_order_no'] = $transport_no;
             list($status,$msg) = self::$box_hook->boxInsert($insert);
             if(! $status) {
-                $this->delLock($key);
+                $this->dellimitingSendRequestBackgNeed($limit_key);
+                DB::rollBack();
+                return [false,$msg];
+            }
+
+            //更新完工数量
+            list($status, $msg) = $this->updateFinish($product_list,$key_list);
+            if(! $status) {
+                $this->dellimitingSendRequestBackgNeed($limit_key);
                 DB::rollBack();
                 return [false,$msg];
-            }$this->delLock($key);
+            }
 
             //用友 ------产成品入库
             $package_data = $msg->toArray();
@@ -192,71 +205,167 @@ class BoxService extends Service
                 $service = new FinishedOrderService();
                 list($status,$msg) = $service->U8Rdrecord10Save($package_data,$user);
                 if(! $status) {
+                    $this->dellimitingSendRequestBackgNeed($limit_key);
                     DB::rollBack();
                     return [false, $msg];
                 }
             }
 
             DB::commit();
+            $this->dellimitingSendRequestBackgNeed($limit_key);
             return [true, ['package_data' => $package_data]];
         }catch (\Exception $e){
             DB::rollBack();
+            $this->dellimitingSendRequestBackgNeed($limit_key);
             return [false,$e->getLine().':'.$e->getMessage()];
         }
     }
 
-    public function saveOutOrder($data,$user){
-        list($status,$msg) = $this->saveOutOrderRule($data,$user);
-        if(! $status) return [false, $msg];
-
-        //组织数据
-        $yongyou_data = $update = [];
-        foreach ($data['out_data'] as $value){
-            $pro_tmp = [];
-            foreach ($value['product'] as $p){
-                $t_k = $p['cinvcode'] . $p['cfree1'];
-                $pro_tmp[$t_k] = [
-                    'cinvcode' => $p['cinvcode'],
-                    'cfree1' => $p['cfree1'],
-                    'iquantity' => $p['iquantity'],
-                ];
-            }
+    public function updateFinish($production_list = [], $map){
+        if(empty($production_list)) return [true,''];
 
-            if(isset($yongyou_data[$value['customer_code']])){
-                $yongyou_data[$value['customer_code']]['cdlcode_string'] .= ',' . $value['cdlcode'];
-                foreach ($pro_tmp as $k => $v){
-                    if(isset($yongyou_data[$value['customer_code']]['product'][$k])){
-                        $yongyou_data[$value['customer_code']]['product'][$k]['iquantity'] += $v['iquantity'];
-                    }else{
-                        $yongyou_data[$value['customer_code']]['product'][$k] = $v;
-                    }
+        //组织派工数据
+        $dispatch = DispatchSub::where('del_time',0)
+            ->where('order_product_id', array_column($production_list,'id'))
+            ->get()->toArray();
+        if(empty($dispatch)) return [true,''];
+        $dispatch_map = [];
+        foreach ($dispatch as $value){
+            $key = $value['order_product_id'] . '|' .  $value['crt_time']; //同一次下的派工单
+            $dispatch_map[$key][] = $value;
+        }
+        $result = [];
+        foreach ($dispatch_map as $value){
+            $dispatch_quantity = array_sum(array_column($value, 'dispatch_quantity'));
+            $finished_num = array_sum(array_column($value, 'finished_num'));
+            if($dispatch_quantity == $finished_num) continue; //同一批派工 且 全部完工的 跳过
+            foreach ($value as $val){
+                if($val['dispatch_quantity'] <= $val['finished_num']) continue; //某一个工序完工
+                //包装数量
+                $tmp_num = $map[$val['order_product_id']]['total'] ?? 0;
+                if($tmp_num < 0) continue;
+                $tmp_num2 = bcsub($val['dispatch_quantity'] , $val['finished_num'],3);
+                if($tmp_num2 >= $tmp_num){
+                    $val['quantity'] = $tmp_num;
+                }else{
+                    $val['quantity'] = $tmp_num2;
                 }
-            }else{
-                $yongyou_data[$value['customer_code']] = [
-                    'customer_code' => $value['customer_code'],
-                    'cdlcode_string' => $value['cdlcode'],
-                    'product' => $pro_tmp
-                ];
+                $result[] = $val;
             }
+        }
+        if(empty($result)) return [true,''];
+        $time = time();
+
+        try {
+            DB::beginTransaction();
+            //根据派工数据回写
+            foreach ($result as $value){
+                $finished_num = $value['quantity'] + $value['finished_num'];
 
-            foreach ($value['box_no'] as $box_no){
-                $update[$box_no] = $value['cdlcode'];
+                DispatchSub::where('id',$value['id'])->update([
+                    'finished_num' => $finished_num
+                ]);
+
+                $quantity = $value['quantity'] * 1000;
+                //工序表
+                $process_model = new OrdersProductProcess(['channel' => date("Ymd",$value['out_order_no_time'])]);
+                $process_model->where('order_product_id',$value['order_product_id'])
+                    ->where('process_id',$value['process_id'])
+                    ->where('dispatch_no',$value['dispatch_no'])
+                    ->where('status', 1)
+                    ->take($quantity)
+                    ->update([
+                        'finished_time' => $time,
+                        'status' => 2,
+                        'finished_id' => 1,
+                        'team_id' => 72,
+                        'equipment_id' => 13,
+                    ]);
             }
+
+            $service = new FinishedOrderService();
+            //反写数量
+            //生产订单
+            $id = array_column($result,'order_product_id');
+            $service->writeFinishedQuantityByOrdersProductId($id);
+            //销售订单
+            $service->writeFinishedQuantity($id);
+            DB::commit();
+        }catch (\Throwable $exception){
+            DB::rollBack();
+            return [false, $exception->getLine().':'.$exception->getMessage() . ':' . $exception->getFile()];
         }
-        if(empty($yongyou_data)) return [false, '暂无写入用友发货出库数据!'];
 
-        //用友 ------发货出库
-        $service = new FinishedOrderService();
-        list($status,$msg) = $service->U8Rdrecord32Save($yongyou_data,$user);
+        return [true, ''];
+    }
+
+    public function saveOutOrder($data,$user){
+        list($status,$msg) = $this->saveOutOrderRule($data,$user);
         if(! $status) return [false, $msg];
 
-        //本地数据更新
-        if(! empty($update)){
-            foreach ($update as $key => $value){
-                Box::where('order_no', $key)->update([
-                    'shipment_order_no' => $value
-                ]);
+        $limit_key = "saveOutOrder" . $user['id'];
+        list($status,$msg) = $this->limitingSendRequestBackgNeed($limit_key);
+        if(! $status) return [false, '正在生成销售出库订单数据,请稍后尝试!'];
+
+        try {
+            DB::beginTransaction();
+            //组织数据
+            $yongyou_data = $update = [];
+            foreach ($data['out_data'] as $value){
+                $pro_tmp = [];
+                foreach ($value['product'] as $p){
+                    $t_k = $p['cinvcode'] . $p['cfree1'];
+                    $pro_tmp[$t_k] = [
+                        'cinvcode' => $p['cinvcode'],
+                        'cfree1' => $p['cfree1'],
+                        'iquantity' => $p['iquantity'],
+                        'line' => $p['line'],
+                    ];
+                }
+
+                if(isset($yongyou_data[$value['customer_code']])){
+                    $yongyou_data[$value['customer_code']]['cdlcode_string'] .= ',' . $value['cdlcode'];
+                    foreach ($pro_tmp as $k => $v){
+                        if(isset($yongyou_data[$value['customer_code']]['product'][$k])){
+                            $yongyou_data[$value['customer_code']]['product'][$k]['iquantity'] += $v['iquantity'];
+                        }else{
+                            $yongyou_data[$value['customer_code']]['product'][$k] = $v;
+                        }
+                    }
+                }else{
+                    $yongyou_data[$value['customer_code']] = [
+                        'customer_code' => $value['customer_code'],
+                        'cdlcode_string' => $value['cdlcode'],
+                        'product' => $pro_tmp
+                    ];
+                }
+
+                foreach ($value['box_no'] as $box_no){
+                    $update[$box_no] = $value['cdlcode'];
+                }
             }
+            if(empty($yongyou_data)) return [false, '暂无写入用友发货出库数据!'];
+
+            //用友 ------发货出库
+            $service = new FinishedOrderService();
+            list($status,$msg) = $service->U8Rdrecord32Save($yongyou_data,$user);
+            if(! $status) return [false, $msg];
+
+            //本地数据更新
+            if(! empty($update)){
+                foreach ($update as $key => $value){
+                    Box::where('order_no', $key)->update([
+                        'shipment_order_no' => $value
+                    ]);
+                }
+            }
+
+            DB::commit();
+            $this->dellimitingSendRequestBackgNeed($limit_key);
+        }catch (\Throwable $exception){
+            $this->dellimitingSendRequestBackgNeed($limit_key);
+            DB::rollBack();
+            return [false, $exception->getFile() . $exception->getFile() . $exception->getMessage()];
         }
 
         return [true, ''];
@@ -307,6 +416,7 @@ class BoxService extends Service
             }
             if(empty($value['product'])) return [false, '发货产品不能为空!'];
             foreach ($value['product'] as $p){
+                if(empty($p['line'])) return [false, '存货行号不能为空!'];
                 if(empty($p['cinvcode'])) return [false, '存货编码不能为空!'];
                 if(empty($p['cfree1'])) return [false, '存货颜色不能为空!'];
                 $p_k = $p['cinvcode'] . $p['cfree1'];
@@ -469,38 +579,45 @@ class BoxService extends Service
             ->select('id','out_order_no','order_no','customer_no','customer_name','product_no','product_title','product_size','crt_time as production_time','id as sale_orders_product_id','finished_num as dispatch_complete_quantity','box_num','technology_name','wood_name','crt_time','order_quantity','technology_material','technology_name','wood_name','process_mark')
             ->orderBy('id','desc')
             ->get()->toArray();
+        //原先按照完工数量 未包装 = 完工数量 - 已包数量
         $product_list = ordersProduct::where('del_time',0)
-            ->whereIn('sale_orders_product_id',$sale_order_ids)->select('id','out_order_no','customer_no','customer_name','product_no','sale_orders_product_id','product_title','product_size','box_num','technology_name','wood_name','crt_time',DB::raw('(production_quantity - scrapp_num) as production_quantity'),DB::raw('finished_num as dispatch_complete_quantity'),'technology_material','technology_name','wood_name','process_mark',"production_no")->get()->toArray();
+            ->whereIn('sale_orders_product_id',$sale_order_ids)->select('id','out_order_no','customer_no','customer_name','product_no','sale_orders_product_id','product_title','product_size','box_num','technology_name','wood_name','crt_time','production_quantity','dispatch_complete_quantity','technology_material','technology_name','wood_name','process_mark',"production_no")
+            ->get()->toArray();
         $model_key_list = [];
         foreach ($model as $v){
             $model_key_list[$v['id']] = $v;
         }
+        $model = [];
 
         //存在生产订单,组织数据
         if(! empty($product_list)){
             $product_key_num_list = [];
             foreach ($product_list as $v){
-                if(!isset($product_key_num_list[$v['sale_orders_product_id']][$v['id']]))$product_key_num_list[$v['sale_orders_product_id']][$v['id']] = [
-                    'product_num' => 0 ,
-                    'box_num' => 0 ,
-                ];
+                if($v['production_quantity'] == $v['box_num']) continue;
+                if(!isset($product_key_num_list[$v['sale_orders_product_id']][$v['id']])) {
+                    $product_key_num_list[$v['sale_orders_product_id']][$v['id']] = [
+                        'product_num' => 0 ,
+                        'box_num' => 0 ,
+                    ];
+                }
                 $product_key_num_list[$v['sale_orders_product_id']][$v['id']]['product_num'] += $v['production_quantity'];
                 $product_key_num_list[$v['sale_orders_product_id']][$v['id']]['box_num'] += $v['box_num'];
                 $detail = $model_key_list[$v['sale_orders_product_id']];
                 $detail['box_type'] = 1;
                 $detail['id'] = $v['id'];
                 $detail['box_num'] = $v['box_num'];
-                $detail['un_box_num'] = $v['dispatch_complete_quantity'] - $v['box_num'];
+                $detail['dispatch_complete_quantity'] = $v['dispatch_complete_quantity'];
+                $detail['un_box_num'] = bcsub($v['dispatch_complete_quantity'] , $v['box_num'],3);
                 $detail['type'] = 1;
                 $detail['production_no'] = $v['production_no'];
+                $detail['production_quantity'] = $v['production_quantity'];
                 $model[] = $detail;
             }
         }
 
         $return = [];
-        $product_key_list = [];
         foreach ($model as $v){
-            if(!isset($v['box_type'])) {
+            if(!isset($v['box_type'])) {continue; //没有销售订单直接包了。
                 $product_num = 0;
                 $box_num = 0;
                 if(isset($product_key_num_list[$v['id']])){
@@ -550,14 +667,12 @@ class BoxService extends Service
                     'is_box_num' => $v['box_num'],
                     'un_box_num' => $v['un_box_num'],
                     'sale_num' => $v['order_quantity'],
+                    'production_num' => $v['production_quantity'],
+                    'dispatch_complete_quantity' => $v['dispatch_complete_quantity']
                 ];
             }
         }
 
-        foreach ($product_key_list as $v){
-            $return[] = $v;
-        }
-
         return [true,$return];
     }
 
@@ -935,25 +1050,22 @@ class BoxService extends Service
             ->get()->toArray();
         $detail_list = [];
         foreach ($list as $v){
-        if(empty($v['transport_no'])) return [false, "包装单:" . $v['transport_no'] . "已在发货单(" . $v['transport_no'] .")中发出!"];
+        if(! empty($v['transport_no'])) return [false, "包装单:" . $v['transport_no'] . "已在发货单(" . $v['transport_no'] .")中发出!"];
             $model = new BoxDetail(['channel'=>$v['top_order_no']]);
             $detail_list = array_merge($detail_list,$model->where('order_no',$v['order_no'])->where('top_order_no',$v['top_order_no'])->get()->toArray());
         }
 
         $return = [];
         foreach ($detail_list as $value){
-            //销售订单号  包装单号  产品编码  颜色
-            $key = $value['ext_1'] . $value['ext_3'];
-            if(isset($return[$key])){
-                $return[$key]['num'] += $value['num'];
-            }else{
-                $return[$key] = [
-                    'ext_1' =>  $value['ext_1'],
-                    'ext_3' =>  $value['ext_3'],
-                    'ext_8' =>  $value['ext_8'],
-                    'num' =>  $value['num'],
-                ];
-            }
+            //销售订单号  产品编码  颜色
+            $return[] = [
+                'ext_1' =>  $value['ext_1'],
+                'ext_3' =>  $value['ext_3'],
+                'ext_8' =>  $value['ext_8'],
+                'num' =>  $value['num'],
+                'out_order_no' => $value['out_order_no'],
+                'box_no' => $value['order_no']
+            ];
         }
 
         return [true, array_values($return)];

+ 16 - 11
app/Service/CommandService.php

@@ -33,12 +33,17 @@ class CommandService extends Service
     public function productionAdd($data,$user,$id){
         $service = new ProductionOrderService();
         list($status,$msg) = $service->orderRule($data);
+        //生产数据的源数据
+        $result = $msg[0];
+        $quantity_map = $msg[1];
+
         if(! $status) {
             CommandList::where('id', $id)
                 ->update([
                     'mark' => $msg,
                     'del_time' => 1,
                 ]);
+            $this->delList($result);
             return;
         }
 
@@ -49,12 +54,12 @@ class CommandService extends Service
                     'mark' => '单据号生成失败',
                     'del_time' => 1,
                 ]);
+            $this->delList($result);
             return;
         }
 
         //工序
         $process_arr = $data['process_id'];
-
         try{
             DB::beginTransaction();
 
@@ -63,12 +68,7 @@ class CommandService extends Service
             //主表数据写入
             OrdersProductMain::insert(['production_no' => $production_no,'crt_time' => $time,'crt_id' => $user['id'], 'process_id' => implode(',',$process_arr)]);
 
-            //生产数据的源数据
-            $result = $msg[0];
-            $quantity_map = $msg[1];
-
             $boom = $process = [];
-
             foreach ($result as $key => $value){
                 $result[$key]['process_id'] = implode(',', $process_arr);
                 $result[$key]['production_no'] = $production_no;
@@ -134,11 +134,6 @@ class CommandService extends Service
                 echo "剩余 " . $size . " 条写入成功\n";
             }
 
-            foreach ($result as $value){
-                $key = "productionAdd" . $value['sale_orders_product_id'];
-                $this->dellimitingSendRequestBackgNeed($key);
-            }
-
             CommandList::where('id', $id)
                 ->update([
                     'mark' => '',
@@ -146,8 +141,10 @@ class CommandService extends Service
                     'is_use' => 2
                 ]);
 
+            $this->delList($result);
             DB::commit();
         }catch (\Exception $e){
+            $this->delList($result);
             DB::rollBack();
             CommandList::where('id', $id)
                 ->update([
@@ -157,6 +154,14 @@ class CommandService extends Service
         }
     }
 
+    function delList($result){
+        if(empty($result)) return;
+        foreach ($result as $value){
+            $key = "productionAdd" . $value['sale_orders_product_id'];
+            $this->dellimitingSendRequestBackgNeed($key);
+        }
+    }
+
     function batchInsertData(array $boom, array $process, array $time_arr)
     {
         foreach ($time_arr as $t) {

+ 20 - 0
app/Service/FyyOrderService.php

@@ -13,6 +13,26 @@ use Illuminate\Support\Facades\Redis;
 
 class FyyOrderService extends Service
 {
+    public function salesOrderList($data,$user){
+        $model = SaleOrdersProduct::where('del_time',0)
+            ->select('out_order_no','customer_name')
+            ->groupBy('out_order_no')
+            ->orderBy('crt_time','desc')
+            ->orderBy('id','asc');
+
+        if(! empty($data['out_order_no'])) {
+            if(! is_array($data['out_order_no'])) {
+                $model->where('out_order_no', 'LIKE', '%'.$data['out_order_no'].'%');
+            }else{
+                $model->whereIn('out_order_no', $data['out_order_no']);
+            }
+        }
+
+        $list = $this->limit($model,'',$data);
+
+        return [true, $list];
+    }
+
     public function edit($data){
         return [true,'保存成功!'];
     }

+ 16 - 15
app/Service/FyySqlServerService.php

@@ -306,7 +306,7 @@ class FyySqlServerService extends Service
         if ($bredvouch) {
             $cmemo = '来源:恒诚塑业完工操作撤回';
         } else {
-            $cmemo = '来源:恒诚塑业完工操作 包装单号:' . $data['order_no'];
+            $cmemo = '来源:恒诚塑业包装操作 包装单号:' . $data['order_no'];
         }
 
         //数据
@@ -369,7 +369,7 @@ class FyySqlServerService extends Service
 
         Log::channel('apiLog')->info('产成品入库:源数据', ["param" => $post]);
 
-        $return = $this->post_helper($this->url, json_encode($post), ['Content-Type:application/json'],20);
+        $return = $this->post_helper($this->url, json_encode($post), ['Content-Type:application/json'],70);
 
         Log::channel('apiLog')->info('产成品入库:返回结果', ["param" => $return]);
 
@@ -392,8 +392,8 @@ class FyySqlServerService extends Service
             foreach ($value['product'] as $v){
                 $bodys_tmp[] = [
                     "idlsid" => "",
-                    "cdlcode" => "",
-                    "dlrowno" => "",
+                    "cdlcode" => $value['cdlcode_string'],
+                    "dlrowno" => $v['line'],
                     "cbdlcode" => "",
                     "cinvcode" => $v['cinvcode'],
                     "cposition" => "",
@@ -440,9 +440,9 @@ class FyySqlServerService extends Service
         }
 
         Log::channel('apiLog')->info('销售出库单:源数据', ["param" => $post_tmp]);
-        $return = $this->post_helper($this->url, json_encode($post_tmp), ['Content-Type:application/json']);
+        $return = $this->post_helper($this->url, json_encode($post_tmp), ['Content-Type:application/json'], 70);
 
-        Log::channel('apiLog')->info('产成品入库:返回结果', ["param" => $return]);
+        Log::channel('apiLog')->info('销售出库单:返回结果', ["param" => $return]);
 
         if (empty($return)) return [false, '异常错误,请确认请求接口地址!'];
         if (! $return['flag']) return [false, $return['msg']];
@@ -519,7 +519,7 @@ class FyySqlServerService extends Service
             $model = $this->db->table('DispatchList as a')
             ->leftJoin('DispatchLists as b', 'b.DLID', 'a.DLID')
             ->leftJoin('Inventory as c', 'c.cInvCode', 'b.cInvCode')
-            ->select('a.cDLCode as cdlcode', 'a.DLID as id', 'a.cCusName as customer_name', 'b.cSOCode as csocode', 'a.cDepCode as cdepcode', 'a.cCusCode as cuscode', 'a.dDate as date', 'b.iDLsID as idlsid', 'b.cWhCode as cwhcode', 'b.cInvCode as cinvcode', 'b.cInvName as product_title', 'b.cFree1 as cfree1', 'b.cFree2 as cfree2', 'b.cPosition as cposition', 'b.cBatch as cbatch', 'b.iQuantity as iquantity', 'b.iNum as inum', 'b.iInvExchRate as iinvexchrate', 'b.fOutQuantity as out_quantity', 'b.iUnitPrice as iunitcost', 'b.iMoney as imoney', 'b.cDefine28 as technology_material', 'b.cDefine30 as process_mark', 'c.cInvStd as product_size', DB::raw('(b.iQuantity - b.fOutQuantity) as quantity'), 'a.cMemo as table_header_mark', 'b.cMemo as table_body_mark')
+            ->select('a.cDLCode as cdlcode', 'a.DLID as id', 'a.cCusName as customer_name', 'b.cSOCode as csocode', 'a.cDepCode as cdepcode', 'a.cCusCode as cuscode', 'a.dDate as date','b.irowno', 'b.iDLsID as idlsid', 'b.cWhCode as cwhcode', 'b.cInvCode as cinvcode', 'b.cInvName as product_title', 'b.cFree1 as cfree1', 'b.cFree2 as cfree2', 'b.cPosition as cposition', 'b.cBatch as cbatch', 'b.iQuantity as iquantity', 'b.iNum as inum', 'b.iInvExchRate as iinvexchrate', 'b.fOutQuantity as out_quantity', 'b.iUnitPrice as iunitcost', 'b.iMoney as imoney', 'b.cDefine28 as technology_material', 'b.cDefine30 as process_mark', 'c.cInvStd as product_size', DB::raw('(b.iQuantity - b.fOutQuantity) as quantity'), 'a.cMemo as table_header_mark', 'b.cMemo as table_body_mark')
             ->whereNotNull('a.cVerifier')
 //            ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
             ->where('a.dDate', '>=', $data['time'][0])
@@ -553,10 +553,10 @@ class FyySqlServerService extends Service
             $new_data = [];
             foreach ($list['data'] as $value) {
                 $unit = $messageMap[$value['cinvcode']] ?? '';
-                $iquantity = intval($value['iquantity']);
-                $out_quantity = intval($value['out_quantity']);
-                $quantity = intval($value['quantity']);
-                $inum = intval($value['inum']);
+                $iquantity = floatval($value['iquantity']);
+                $out_quantity = floatval($value['out_quantity']);
+                $quantity = floatval($value['quantity']);
+                $inum = floatval($value['inum']);
                 $pro = [
                     "cinvcode" => $value['cinvcode'],
                     "product_title" => $value['product_title'],
@@ -566,7 +566,8 @@ class FyySqlServerService extends Service
                     "out_quantity" => $out_quantity,
                     "product_size" => $value['product_size'] ?? "",
                     "quantity" => $quantity,
-                    "unit" => $unit
+                    "unit" => $unit,
+                    "line" => $value['irowno'],
                 ];
 
                 if(isset($new_data[$value['cdlcode']])){
@@ -608,9 +609,9 @@ class FyySqlServerService extends Service
 
             $new_data = [];
             foreach ($list as $value) {
-                $iquantity = intval($value['iquantity']);
-                $out_quantity = intval($value['out_quantity']);
-                $inum = intval($value['inum']);
+                $iquantity = floatval($value['iquantity']);
+                $out_quantity = floatval($value['out_quantity']);
+                $inum = floatval($value['inum']);
                 $pro = [
                     "cinvcode" => $value['cinvcode'],
                     "product_title" => $value['product_title'],

+ 5 - 2
app/Service/ProductionOrderService.php

@@ -234,7 +234,7 @@ class ProductionOrderService extends Service
 
         foreach ($result as $key => $value){
             $quantity_tmp = $map[$value['sale_orders_product_id']] ?? 0;
-            if($value['production_quantity'] + $quantity_tmp > $value['order_quantity']) return [false,'生产数量不能大于订单数量'];
+//            if($value['production_quantity'] + $quantity_tmp > $value['order_quantity']) return [false,'生产数量不能大于订单数量'];
             unset($result[$key]['production_quantity']);//删除销售订单的已生产数量
         }
 
@@ -252,7 +252,10 @@ class ProductionOrderService extends Service
             $data['data'][$key]['out_checker_time'] = $value['out_checker_time'] ? date('Y-m-d',$value['out_checker_time']) : '';
             $data['data'][$key]['production_time'] = $value['production_time'] ? date('Y-m-d',$value['production_time']) : '';
             $data['data'][$key]['pre_shipment_time'] = $value['pre_shipment_time'] ? date('Y-m-d',$value['pre_shipment_time']) : '';
-            $data['data'][$key]['not_production'] = bcsub($value['order_quantity'] ,($production_map[$value['sale_orders_product_id']] ?? 0),3);
+            $all_production = $production_map[$value['sale_orders_product_id']] ?? 0;
+            $not_production = bcsub($value['order_quantity'] , $all_production,3);
+            if($not_production < 0) $not_production = "0.000";
+            $data['data'][$key]['not_production'] = $not_production;
             if($value['dispatch_complete_quantity'] >= $value['production_quantity']){
                 $data['data'][$key]['is_create'] = 1;
             }else{

+ 12 - 0
app/Service/ReportFormsService.php

@@ -89,6 +89,10 @@ class ReportFormsService extends Service
             $detail_key = $value['production_no'] . "|";
             foreach ($detail as $key_son => $value_son) {
                 if (strpos($key_son,$detail_key) !== false) {
+                    $dispatch_count = bcdiv($value_son['dispatch_count'],1000,3);
+                    $finish_count = bcdiv($value_son['finish_count'],1000,3);
+                    $value_son['dispatch_count'] = $dispatch_count;
+                    $value_son['finish_count'] = $finish_count;
                     $value_son['rate'] = number_format($value_son['finish_count'] / $value['order_quantity'] * 100, 2);
                     $list[$key]['process'][] = $value_son;
                 }
@@ -201,6 +205,14 @@ class ReportFormsService extends Service
             $tmp['sub'] = array_values($return_team_time_tmp[$key]);
             $return_team_time[] = $tmp;
         }unset($return_team_time_tmp);
+        foreach ($return_team as $key => $value){
+            $return_team[$key]['num'] = bcdiv($value['num'],1000,3);
+        }
+        foreach ($return_team_time as $key => $value){
+            foreach ($value['sub'] as $k => $v){
+                $return_team_time[$key]['sub'][$k]['num'] = bcdiv($v['num'],1000,3);
+            }
+        }
 
         //列表数据 图表数据
         return [true,['list'=>array_values($return_team),'chart'=>$return_team_time]];

+ 4 - 0
app/Service/Service.php

@@ -311,6 +311,8 @@ dd(filter_var($ip, FILTER_VALIDATE_IP) === false);
     //后台端 某些需要限制请求频率的接口
     //需要主动删除  Redis::del($key)
     public function limitingSendRequestBackgNeed($key,$value=0){
+        $prefix = config('app.name') . ':';
+        $key = $prefix . $key;
         if(! empty($value)) $value = 1;
         // 使用Redis Facade设置,当键名不存在时才设置成功
         if (Redis::setnx($key, $value)) return [true, ''];
@@ -319,6 +321,8 @@ dd(filter_var($ip, FILTER_VALIDATE_IP) === false);
     }
 
     public function dellimitingSendRequestBackgNeed($key){
+        $prefix = config('app.name') . ':';
+        $key = $prefix . $key;
         Redis::del($key);
     }
 }

+ 1 - 0
routes/api.php

@@ -122,6 +122,7 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('scrappList', 'Api\ScrappController@scrappList');
 
     //销售订单----------------------
+    $route->any('salesOrderList', 'Api\FyyOrderController@salesOrderList');
     $route->any('fyyAdd', 'Api\FyyOrderController@add');
     $route->any('fyyList', 'Api\FyyOrderController@orderList');
     $route->any('fyyRefreshOnHandQuantity', 'Api\FyyOrderController@fyyRefreshOnHandQuantity');