cqpCow 1 年之前
父节点
当前提交
5f56e7ba1c
共有 2 个文件被更改,包括 27 次插入5 次删除
  1. 1 1
      app/Http/Middleware/RequestLog.php
  2. 26 4
      app/Service/ExportFileService.php

+ 1 - 1
app/Http/Middleware/RequestLog.php

@@ -32,7 +32,7 @@ class RequestLog
         }
         $params = $request->all();
         if($request->path() != 'api/reportCount'){
-            Log::channel('request')->info('request', ['param'=>json_encode($params),'ip' => $ip,'uri'=>$request->path()]);
+            Log::channel('request')->info('request', ['param'=>$params,'ip' => $ip,'uri'=>$request->path()]);
         }
         return $next($request);
     }

+ 26 - 4
app/Service/ExportFileService.php

@@ -14,6 +14,7 @@ use App\Model\CarFiles;
 use App\Model\CarType;
 use App\Model\Company;
 use App\Model\Construction;
+use App\Model\ConstructionInfo;
 use App\Model\ConstructionOrder;
 use App\Model\ConstructionOrderImg;
 use App\Model\ConstructionOrderSub;
@@ -498,14 +499,31 @@ class ExportFileService extends Service
 
         DB::table('construction')
             ->whereIn('id', $id)
-            ->select('id','order_number','title','sales_order_id','handover_time','install_method','install_position','mark','urgency','start_time','end_time','crt_time','crt_id','state','pq_state','day_start_stamp','day_end_stamp')
+            ->select('id','order_number','title','sales_order_id','handover_time','install_method','install_position','mark','urgency','start_time','end_time','crt_time','crt_id','state',"construction_fee")
             ->orderBy('id','desc')
             ->chunk(500,function ($data) use(&$return){
                 $data = $data->toArray();
                 $emp_map = Employee::whereIn('id',array_unique(array_column($data,'crt_id')))
                     ->pluck('emp_name','id')
                     ->toArray();
-
+                $construction_info = ConstructionInfo::where('del_time',0)
+                    ->where('type',ConstructionInfo::type_three)
+                    ->whereIn('construction_id',array_unique(array_column($data,'id')))
+                    ->select('construction_id','employee_id')
+                    ->get()->toArray();
+                $emp_map2 = Employee::whereIn('id',array_unique(array_column($construction_info,'employee_id')))
+                    ->pluck('emp_name','id')
+                    ->toArray();
+                $construction_info_map = [];
+                foreach ($construction_info as $value){
+                    $emp = $emp_map2[$value['employee_id']] ?? "";
+                    if(! $emp) continue;
+                    if(isset($construction_info_map[$value['construction_id']])){
+                        $construction_info_map[$value['construction_id']] .= ',' . $emp;
+                    }else{
+                        $construction_info_map[$value['construction_id']] = $emp;
+                    }
+                }
                 $sales = SalesOrder::whereIn('id',array_unique(array_column($data,'sales_order_id')))->select('order_number','id','handover_time')->get()->toArray();
                 $sales_map = [];
                 foreach ($sales as $value){
@@ -546,13 +564,15 @@ class ExportFileService extends Service
                     $construction_period = $start_time . '——' . $end_time;
                     $state =  Construction::$name[$value->state] ?? '';
                     $product_tmp = $product[$value->id] ?? [];
-
+                    $emp_tmp = $construction_info_map[$value->id] ?? "";
                     foreach ($product_tmp as $val){
                         if(in_array($val['construction_id'], $flag)){
                             $return[] = [
                                 'order_number' => "",
                                 'title' => "",
                                 'sales_order_title' => "",
+                                'money' => "",
+                                'emp' => '',
                                 'handover_time' => "",
                                 'install_method' => "",
                                 'install_position' => "",
@@ -575,6 +595,8 @@ class ExportFileService extends Service
                                 'order_number' => $value->order_number,
                                 'title' => $value->title,
                                 'sales_order_title' => $sales_order_number,
+                                'money' => $value->construction_fee,
+                                'emp' => $emp_tmp,
                                 'handover_time' => $handover_time,
                                 'install_method' => $install_method_title,
                                 'install_position' => $install_position_title,
@@ -596,7 +618,7 @@ class ExportFileService extends Service
                 }
             });
 
-        $header = ['施工单号','工单来源','关联单号','交车日期','安装方式','安装地点','备注','紧急程度','施工时间','订单状态','创建时间','创建人','产品名称','产品编码','产品规格','产品单价','产品数量','产品合同金额'];
+        $header = ['施工单号','工单来源','关联单号','施工费用','负责人','交车日期','安装方式','安装地点','备注','紧急程度','施工时间','订单状态','创建时间','创建人','产品名称','产品编码','产品规格','产品单价','产品数量','产品合同金额'];
 
         return $this->saveExportData($return,$header);
     }