|
|
@@ -91,13 +91,8 @@ class WaybillsController extends Controller
|
|
|
$excel=$this->deliveringExport($waybills);
|
|
|
return $excel;
|
|
|
}
|
|
|
- else $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
- if (!$waybills&&$request->input('waybill_number')){
|
|
|
- $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
- return $query->with('user');
|
|
|
- }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
|
|
|
- ->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
- }
|
|
|
+ if ($request->uriType=='ZF')$waybills=$waybills->where('type','直发车');
|
|
|
+ if ($request->uriType=='ZX')$waybills=$waybills->where('type','专线');
|
|
|
return $waybills;
|
|
|
}
|
|
|
|
|
|
@@ -112,10 +107,15 @@ class WaybillsController extends Controller
|
|
|
})->all();
|
|
|
$waybills = $this->getWaybills();
|
|
|
$waybills=$waybills->whereIn('owner_id',$ownerIds);
|
|
|
- if ($request->uriType=='ZF')$waybills=$waybills->where('type','直发车');
|
|
|
- if ($request->uriType=='ZX')$waybills=$waybills->where('type','专线');
|
|
|
if ($data != null ) {
|
|
|
$waybills=$this->conditionQuery($request,$waybills);
|
|
|
+ if (!$waybills&&$request->input('waybill_number')){
|
|
|
+ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->orderBy('id','DESC')->where('type','专线')
|
|
|
+ ->where('waybill_number',$request->input('waybill_number'));
|
|
|
+ }
|
|
|
+ $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
} else {
|
|
|
$waybills = $waybills->paginate(50);
|
|
|
}
|
|
|
@@ -630,48 +630,18 @@ class WaybillsController extends Controller
|
|
|
|
|
|
public function waybillExport($id,Request $request){
|
|
|
if(!Gate::allows('运输管理-查询')){ return '没有权限'; }
|
|
|
+ ini_set('max_execution_time',2500);
|
|
|
+ ini_set('memory_limit','1526M');
|
|
|
+ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ $query->with('user');
|
|
|
+ }]);
|
|
|
if ($id==-1){
|
|
|
- $id=[];
|
|
|
- $today=Carbon::now()->subDays(15);
|
|
|
- ini_set('max_execution_time',2500);
|
|
|
- ini_set('memory_limit','1526M');
|
|
|
- $waybills=Waybill::select('id');
|
|
|
- if ($request->input('waybill_number')){
|
|
|
- $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
- }
|
|
|
- if ($request->input('carrier_bill')){
|
|
|
- $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
- }
|
|
|
- if ($request->input('carrier_id')){
|
|
|
- $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id'));
|
|
|
- }
|
|
|
- if ($request->input('owner_id')){
|
|
|
- $waybills=$waybills->where('owner_id','=',$request->input('owner_id'));
|
|
|
- }
|
|
|
- if ($request->input('wms_bill_number')){
|
|
|
- $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
- }
|
|
|
- if ($request->input('created_at_start')){
|
|
|
- $waybills=$waybills->where('created_at','>',$request->input('created_at_start'));
|
|
|
- }
|
|
|
- if ($request->input('created_at_end')){
|
|
|
- $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
|
|
|
- }
|
|
|
- if ($request->input('status')){
|
|
|
- $waybills=$waybills->where('status',$request->input('status'));
|
|
|
- }
|
|
|
- if ($request->input('uriType')){
|
|
|
- if ($request->input('uriType')=='ZF')
|
|
|
- $waybills=$waybills->where('type','直发车');
|
|
|
- if ($request->input('uriType')=='ZX')
|
|
|
- $waybills=$waybills->where('type','专线');
|
|
|
- }
|
|
|
+ $waybills=$this->conditionQuery($request,$waybills);
|
|
|
$waybills=$waybills->get();
|
|
|
- foreach ($waybills as $waybill){
|
|
|
- array_push($id,$waybill->id);
|
|
|
- }
|
|
|
- }else $id = explode( ',',$id);
|
|
|
- if (!$id)return ;
|
|
|
+ }else {
|
|
|
+ $id = explode( ',',$id);
|
|
|
+ $waybills=$waybills->whereIn('id',$id)->get();
|
|
|
+ };
|
|
|
$row=[[
|
|
|
'type'=>'运单类型',
|
|
|
'owner'=>'货主',
|
|
|
@@ -706,24 +676,9 @@ class WaybillsController extends Controller
|
|
|
unset($row[0]['fee'],$row[0]['pick_up_fee'],$row[0]['other_fee'],$row[0]['collect_fee']);
|
|
|
}
|
|
|
$list=[];
|
|
|
- for ($i=0; $i<count($id);$i++){
|
|
|
- $waybill=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
- return $query->with('user');
|
|
|
- }])->find($id[$i]);
|
|
|
- foreach ($waybill->waybillAuditLogs as $waybillAuditLog){
|
|
|
- if ($waybillAuditLog->audit_stage=="运单阶段"){
|
|
|
- $waybillAuditor=$waybillAuditLog->user->name;
|
|
|
- }else{
|
|
|
- $waybillAuditor='';
|
|
|
- }
|
|
|
- if ($waybillAuditLog->audit_stage=="调度阶段"){
|
|
|
- $dispatchAuditor=$waybillAuditLog->user->name;
|
|
|
- }else{
|
|
|
- $dispatchAuditor='';
|
|
|
- }
|
|
|
- };
|
|
|
+ for ($i=0; $i<count($waybills);$i++){
|
|
|
+ $waybill=$waybills[$i];
|
|
|
$w=[
|
|
|
-
|
|
|
'type'=>isset($waybill->type)?$waybill->type:'',
|
|
|
'waybill_number'=>isset($waybill->waybill_number)?$waybill->waybill_number:'',
|
|
|
'owner'=>isset($waybill->owner->name)?$waybill->owner->name:'',
|
|
|
@@ -765,7 +720,6 @@ class WaybillsController extends Controller
|
|
|
}
|
|
|
$list[$i]=$w;
|
|
|
}
|
|
|
- $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']);
|
|
|
return Excel::download(new Export($row,$list), date('Y:m:d ') . '运单列表.xlsx');
|
|
|
}
|
|
|
|