Browse Source

Merge branch 'zzd'

# Conflicts:
#	app/Console/Kernel.php
LD 5 years ago
parent
commit
e43eee927e

+ 50 - 0
app/Console/Commands/MakeServiceCommand.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+
+class MakeServiceCommand extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'make:service {name : fileName}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Create Service file';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        if (!file_exists(base_path('app\\Services'))){
+            mkdir('app\\Services',666,false);
+        }
+        $fileName=$this->argument('name');
+        if (!file_exists(base_path('app\\Services\\'.$fileName.'.php'))){
+            file_put_contents(base_path('app\\Services\\'.$fileName.'.php'),
+                '<?php '.PHP_EOL.PHP_EOL.'namespace App\Services; '.PHP_EOL.PHP_EOL.'Class '.$fileName.PHP_EOL.'{ '.PHP_EOL.PHP_EOL.PHP_EOL.'}');
+        }
+        else echo $this->error("ERROR: file exists;");
+    }
+}

+ 1 - 0
app/Console/Kernel.php

@@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
      */
     protected $commands = [
         \App\Console\Commands\LogExpireDelete::class,
+        \App\Console\Commands\MakeServiceCommand::class,
         \App\Console\Commands\FluxOrderFix::class,
     ];
 

+ 18 - 2
app/Http/Controllers/OrderController.php

@@ -69,7 +69,7 @@ class OrderController extends Controller
         if ($soreference5){
             $arr=array_filter(preg_split('/[,, ]+/is', $soreference5));
             if (count($arr)>0){
-                $sql.=" and soreference5 in (";
+                $sql.=" and (soreference5 in (";
                 foreach ($arr as $index=>$str){
                     if ($index==0){
                         $sql.="'".$str."'";
@@ -77,6 +77,21 @@ class OrderController extends Controller
                     }
                     $sql.=",'".$str."'";
                 }
+                $sql.=") ";
+                /*分箱号*/
+                $oracleActAllocationDetails=DB::connection('oracle')->table('ACT_ALLOCATION_DETAILS')->whereIn('picktotraceid',$arr)->get();
+                $picktotraceids=array_unique(array_column($oracleActAllocationDetails->toArray(),'orderno'));
+                if (count($picktotraceids)>0){
+                    $sql.='OR orderno IN (';
+                    foreach ($picktotraceids as $index=>$str){
+                        if ($index==0){
+                            $sql.="'".$str."'";
+                            continue;
+                        }
+                        $sql.=",'".$str."'";
+                    }
+                    $sql.=") ";
+                }
                 $sql.=")";
             }
         }
@@ -132,7 +147,7 @@ class OrderController extends Controller
                       left join BAS_Customer on BAS_Customer.customerid=DOC_ORDER_HEADER.customerid
                       left join  BAS_SKU on DOC_Order_Details.CustomerID=BAS_SKU.CustomerID and DOC_Order_Details.SKU=BAS_SKU.SKU
                       left join ACT_ALLOCATION_DETAILS on DOC_Order_Details.orderno=ACT_ALLOCATION_DETAILS.orderno and DOC_Order_Details.orderlineno=ACT_ALLOCATION_DETAILS.orderlineno
-                      LEFT JOIN (select listagg(picktotraceid,',') WITHIN GROUP ( order by ORDERNO) as picktotraceid,
+                      LEFT JOIN (select XMLAGG(XMLPARSE(CONTENT picktotraceid || ',' WELLFORMED) ORDER BY ORDERNO).GETCLOBVAL() as picktotraceid,
                                     ORDERNO from ACT_ALLOCATION_DETAILS group by ORDERNO)ACT_ALLOCATION_DETAILS_temp
                                 ON DOC_ORDER_HEADER.orderno = ACT_ALLOCATION_DETAILS_temp.orderno";
         if ($alternate_sku1)$sql.=" where BAS_SKU.Alternate_SKU1 like '".$alternate_sku1."%'";
@@ -140,6 +155,7 @@ class OrderController extends Controller
         $commodities=[];
         foreach ($orders as $index=>$order){
             if ($order->picktotraceid){
+                $order->picktotraceid=rtrim($order->picktotraceid, ',');
                 $picktotraceid=array_unique(explode(',',$order->picktotraceid));
                 $order->picktotraceid=$picktotraceid;
             }

+ 38 - 3
app/Http/Controllers/ProcessController.php

@@ -127,9 +127,10 @@ class ProcessController extends Controller
         $id=$request->input('id');
         $processDailies=ProcessDaily::with(['processDailyParticipants','process'])->orderBy('date','DESC')
             ->where('process_id',$id)->get();
-        $process=Process::find($id);
+        $process=Process::with('automaticSupplementSign')->find($id);
         if (count($processDailies)>0){
-            if ((($process->amount)-($process->completed_amount))<=0 || $process->status=='交接完成')$result=true;
+            if ((($process->amount)-($process->completed_amount))<=0 || $process->status=='交接完成'
+                || $process->automaticSupplementSign)$result=true;
             else $result=$this->createDeficiencyData($processDailies,$today);
             if ($result){
                 $processDailies=ProcessDaily::with(['processDailyParticipants','process'])
@@ -206,6 +207,7 @@ class ProcessController extends Controller
     }
     //生成二次加工单缺失时间记录及本日记录
     private function createDeficiencyData($processDailies,$today){
+        $today=Carbon::parse($today);
         $processDailiesArr=[];
         foreach ($processDailies as $processDaily){
             $processDailiesArr[$processDaily->date]=$processDaily;
@@ -856,7 +858,7 @@ class ProcessController extends Controller
 
     //修改二次加工单每日单的起始日期
     public function updateStartDate(Request $request){
-        $start_date=$request->start_date;
+        $start_date=$request->date;
         $process_id=$request->process_id;
         if (!$start_date || !$process_id)return ['success'=>false,'data'=>'起始日期为空或单据已不存在!'];
         $processDailiesId=[];
@@ -891,6 +893,39 @@ class ProcessController extends Controller
         return ['success'=>true,'data'=>$processDailies];
     }
 
+    //修改二次加工单终止日期
+    public function updateEndDate(Request $request){
+        $end_date=$request->date;
+        $process_id=$request->process_id;
+        if (!$end_date || !$process_id)return ['success'=>false,'data'=>'终止日期为空或单据已不存在!'];
+        $processDailiesId=[];
+        $processDailies=ProcessDaily::where('process_id',$process_id)->get();
+        foreach ($processDailies as $processDaily){
+            if (Carbon::parse($processDaily->date)->gt(Carbon::parse($end_date))){
+                array_push($processDailiesId,$processDaily->id);
+                unset($processDaily);
+            }
+        }
+        ProcessDaily::destroy($processDailiesId);
+        ProcessDailyParticipant::whereIn('process_daily_id',$processDailiesId)->delete();
+        $this->createDeficiencyData($processDailies,$end_date);
+        $processDailies=ProcessDaily::with('processDailyParticipants')->where('process_id',$process_id)
+            ->orderBy('date','DESC')->get();
+        $this->createAutomaticSupplement($process_id);
+        $this->log(__METHOD__,"修改二次加工单加工日记录_".__FUNCTION__,json_encode($request),Auth::user()['id']);
+        return ['success'=>true,'data'=>$processDailies];
+    }
+
+    //增加填充标记
+    private function createAutomaticSupplement($process_id){
+        Sign::create([
+            'signable_type'=>'processes',
+            'signable_id'=>$process_id,
+            'field'=>'automatic_supplement',
+            'mark'=>"停止自动补充每日记录单"
+        ]);
+    }
+
     //执行
     public function export($processes){
         if(!Gate::allows('二次加工管理-查询')){ return '没有权限';  }

+ 21 - 67
app/Http/Controllers/WaybillsController.php

@@ -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');
     }
 

+ 6 - 1
app/Process.php

@@ -39,7 +39,12 @@ class Process extends Model
     }
     public function signs(){
         return $this->hasMany('App\Sign','signable_id','id')
-            ->where('signable_type','processes');
+            ->where('signable_type','processes')->where('field','unit_price');
+    }
+
+    public function automaticSupplementSign(){
+        return $this->hasOne('App\Sign','signable_id','id')
+            ->where('signable_type','processes')->where('field','automatic_supplement');
     }
 
 

+ 38 - 17
resources/views/process/index.blade.php

@@ -424,11 +424,18 @@
                         <table class="table-sm table-bordered table-condensed">
                             <tr class="text-success">
                                 <td>
-                                    <button v-if="!is_update_start_date" @click="is_update_start_date=true;start_date=''" type="button" class="btn btn-sm btn-outline-primary">设定起始日期</button>
-                                    <div v-else>
-                                        <input type="date" class="form-control form-control-sm" style="width: 137px" v-model="start_date">
-                                        <button type="button" @click="update_process_start_date(processDailyParticipants[0])" class="btn btn-sm btn-outline-success">确定</button>
-                                        <button type="button" @click="is_update_start_date=false;" class="btn btn-sm btn-outline-danger">取消</button>
+                                    <button v-if="!is_update_date && dateTextMap.end_date==='终'" @click="is_update_date='start_date';date=''"
+                                            @mouseenter="dateTextMap.start_date='设定起始日期'" @mouseleave="dateTextMap.start_date='起'"
+                                            type="button" class="btn btn-sm btn-outline-primary">@{{ dateTextMap.start_date }}</button>
+                                    <button v-if="!is_update_date && dateTextMap.start_date==='起'" @click="is_update_date='end_date';date=''" type="button"
+                                            @mouseenter="dateTextMap.end_date='设定终止日期'" @mouseleave="dateTextMap.end_date='终'"
+                                            class="btn btn-sm btn-outline-dark">@{{ dateTextMap.end_date }}</button>
+                                    <div v-if="is_update_date">
+                                        <input type="date" class="form-control form-control-sm" :class="is_update_date=='start_date' ? 'text-info border-info':''"
+                                               style="width: 137px" v-model="date" :max="today"
+                                               :min="is_update_date=='end_date' ? processDailyParticipants[(processDailyParticipants.length)-1].date : ''">
+                                        <button type="button" @click="update_process_date(processDailyParticipants[0])" class="btn btn-sm btn-outline-success">确定</button>
+                                        <button type="button" @click="is_update_date='';dateTextMap.end_date='终';dateTextMap.start_date='起'" class="btn btn-sm btn-outline-danger">取消</button>
                                     </div>
                                 </td>
                                 <td>当日产量</td>
@@ -571,8 +578,10 @@
                 processUnfold:[],
                 processFullSum:[],
                 signs:[],
-                is_update_start_date:false,
-                start_date:'',
+                is_update_date:false,
+                date:'',
+                today:'',
+                dateTextMap:{'start_date':'起','end_date':'终'},
             },
             watch:{
                 checkData:{
@@ -603,6 +612,8 @@
                 this.resetProcessData();
                 $(".tooltipTarget").tooltip({'trigger':'hover'});
                 $('#process').removeClass('d-none');
+                var today=new Date();
+                this.today = today.getFullYear() + "-" + ((today.getMonth() + 1) < 10 ? "0"+(today.getMonth() + 1) : (today.getMonth() + 1)) + "-" + today.getDate();
             },
             methods: {
                 arrayFilter: function (processesContents, process) {
@@ -1531,27 +1542,37 @@
                         this.submit();
                     },1);
                 },
-                update_process_start_date(processDailyParticipant){
-                    let start_date=this.start_date;
+                update_process_date(processDailyParticipant){
+                    let date=this.date;
+                    let is_update_date=this.is_update_date;
                     let _this=this;
-                    if (!start_date){
-                        tempTip.show('未输入起始日期!');
+                    if (is_update_date==='start_date') _this.dateTextMap.start_date='起';
+                    else _this.dateTextMap.end_date='终';
+                    if (!date){
+                        tempTip.show('未输入日期!');
                         return;
                     }
-                    if (!confirm('确定要设定“'+start_date+'”为新的起始日期吗?以往记录将被删除!'))return;
-                    axios.post('{{url('process/updateStartDate')}}',{process_id:processDailyParticipant.process_id,start_date:start_date})
+                    let url='';
+                    if (is_update_date==='start_date'){
+                        if (!confirm('确定要设定“'+date+'”为新的起始日期吗?以往记录将被删除!'))return;
+                        url='{{url('process/updateStartDate')}}';
+                    }
+                    else{
+                        if (!confirm('确定要设定“'+date+'”为新的终止日期吗?'))return;
+                        url='{{url('process/updateEndDate')}}';
+                    }
+                    axios.post(url,{process_id:processDailyParticipant.process_id,date:date})
                         .then(function (response) {
                             if(response.data.success){
                                 _this.resetProcessDaily(response.data.data,processDailyParticipant.process_id);
-                                _this.is_update_start_date=false;
+                                _this.is_update_date='';
                                 tempTip.setDuration(2000);
-                                tempTip.showSuccess('成功修改“'+start_date+'”为新的起始时间!');
+                                tempTip.showSuccess('成功修改“'+date+'”为新的'+(is_update_date==='start_date' ? '起始时间' :'终止时间')+'!');
                                 return;
                             }
                             tempTip.setDuration(3000);
-                            tempTip.show(err);
+                            tempTip.show(response.data.data);
                         }).catch(function (err) {
-                            console.log(err);
                             tempTip.setDuration(3000);
                             tempTip.show('网络错误:'+err);
                         })

+ 2 - 8
routes/web.php

@@ -74,10 +74,6 @@ Route::resource('maintenance/waybillPriceModel','WaybillPriceModelsController');
 Route::get('maintenance/waybillPriceModel/excel/goImport',function (){return view('maintenance.waybillPriceModel.import');});
 Route::get('maintenance/waybillPriceModel/cities/{province_id}','WaybillPriceModelsController@getCities');
 
-Route::get('waybill/waybillFinancialSnapshot/ZF','WaybillFinancialSnapshotsController@indexZF');
-Route::get('waybill/waybillFinancialSnapshot/ZX','WaybillFinancialSnapshotsController@indexZX');
-Route::get('waybill/waybillFinancialExcepted/ZF','WaybillFinancialExceptedController@indexZF');
-Route::get('waybill/waybillFinancialExcepted/ZX','WaybillFinancialExceptedController@indexZX');
 Route::resource('waybill/waybillFinancialSnapshot','WaybillFinancialSnapshotsController');
 Route::resource('waybill/waybillFinancialExcepted','WaybillFinancialExceptedController');
 
@@ -85,14 +81,10 @@ Route::get('waybill/recycle', 'WaybillsController@recycle');   //回收站
 Route::any('waybill/ontop/top','WaybillsController@waybillOnTop');
 Route::any('waybill/ontop/cancel','WaybillsController@cancelOnTop');
 
-Route::any('waybill/create/ZF','WaybillsController@createZF');
-Route::any('waybill/create/ZX','WaybillsController@createZX');
 Route::get('waybill/index','WaybillsController@index');
 Route::get('waybill/delivering','WaybillsController@delivering');
 Route::post('waybill/storeCarrierBill','WaybillsController@storeCarrierBill');
 Route::resource('waybill','WaybillsController');
-Route::get('waybill/index/ZF','WaybillsController@indexZF');
-Route::get('waybill/index/ZX','WaybillsController@indexZX');
 Route::post('waybill/is/waybillPriceModel','WaybillsController@isWaybillPriceModel');
 Route::post('waybill/addCounty','WaybillsController@addCounty');
 Route::any('waybill/waybillAudit','WaybillsController@waybillAudit');
@@ -234,6 +226,8 @@ Route::group(['prefix'=>'process'],function(){
     Route::post('accountantVerify','ProcessController@accountantVerify');
     //修改起始日期
     Route::post('updateStartDate','ProcessController@updateStartDate');
+    //修改终止日期
+    Route::post('updateEndDate','ProcessController@updateEndDate');
 });
 //process主方法 restful
 Route::resource('process','ProcessController');