Просмотр исходного кода

Merge branch 'Haozi'

# Conflicts:
#	app/Console/Kernel.php
#	app/Http/Controllers/RejectedController.php
LD 5 лет назад
Родитель
Сommit
5fd2961b44

+ 55 - 0
LogExpireDelete.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Carbon\Carbon;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Date;
+use Illuminate\Support\Facades\DB;
+
+class LogExpireDelete extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'LogExpireDelete';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'LogExpireDelete';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $this->deleteLog();
+    }
+
+    public function deleteLog(){
+        //前一天
+//        $date=Carbon::now()->subDays(150)->format('Y-m-d');
+//        DB::table('logs')->where('created_at','like',$date.'%')->delete();
+        DB::table('logs')->insert([
+            ['operation' => 'App', 'type' => 'test','created_at'=>new Date()],
+        ]);
+
+    }
+}

+ 51 - 0
app/Console/Commands/LogExpireDelete.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Carbon\Carbon;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Date;
+use Illuminate\Support\Facades\DB;
+
+class LogExpireDelete extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'LogExpireDelete';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'LogExpireDelete';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $this->deleteLog();
+    }
+
+    public function deleteLog(){
+        //前150天
+        $date=Carbon::now()->subDays(150)->format('Y-m-d');
+        DB::table('logs')->where('created_at','like',$date.'%')->delete();
+    }
+}

+ 4 - 6
app/Console/Kernel.php

@@ -2,10 +2,10 @@
 
 namespace App\Console;
 
-use App\Http\Controllers\Controller;
 use Carbon\Carbon;
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
+use Illuminate\Support\Facades\DB;
 
 class Kernel extends ConsoleKernel
 {
@@ -15,7 +15,7 @@ class Kernel extends ConsoleKernel
      * @var array
      */
     protected $commands = [
-        //
+        \App\Console\Commands\LogExpireDelete::class,
     ];
 
     /**
@@ -26,9 +26,8 @@ class Kernel extends ConsoleKernel
      */
     protected function schedule(Schedule $schedule)
     {
-        $schedule->call(function () {
-            Controller::logS(__METHOD__,__FUNCTION__,'test'.Carbon::now()->toString());
-        })->everyMinute();
+        $schedule->command('LogExpireDelete')->daily();
+//        $schedule->command('LogExpireDelete')->everyMinute();
     }
 
     /**
@@ -39,7 +38,6 @@ class Kernel extends ConsoleKernel
     protected function commands()
     {
         $this->load(__DIR__.'/Commands');
-
         require base_path('routes/console.php');
     }
 }

+ 7 - 6
app/Http/Controllers/UserWorkgroupController.php

@@ -65,10 +65,8 @@ class UserWorkgroupController extends Controller
         if(!Gate::allows('工作组-编辑')){ return redirect(url('/'));  }
         $this->validatorUserWorkgroup($request,$id)->validate();
         $data=$request->input();
-        $warehouse=$data['warehouse'];
-        $warehouseId=Warehouse::where('name',$warehouse)->value('id');
         $userWorkgroup=UserWorkgroup::find($id);
-        $userWorkgroup['warehouse_id']=$warehouseId;
+        $userWorkgroup['warehouse_id']= $data['warehouse_id'];
         if ($data['name']!=$userWorkgroup->name){
             $authority=Authority::where("name",$userWorkgroup->name)->first();
             if ($authority){
@@ -80,7 +78,10 @@ class UserWorkgroupController extends Controller
                 $this->storeAuthority($data['name'],$id);
             }
             $userWorkgroup->fill($data);
-            $userWorkgroup->save();
+            $userWorkgroup->update();
+            $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        }else{
+            $userWorkgroup->update();
             $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
         }
         return redirect('maintenance/userWorkgroup')->with('successTip','工作组“'.$request->input('name').'”修改成功');
@@ -99,14 +100,14 @@ class UserWorkgroupController extends Controller
         if ($id){$name=$id;}
         $validator=Validator::make($request->input(),[
             'name'=>['required','max:10',isset($name)?"unique:user_workgroups,name,$name":'unique:user_workgroups,name'],
-            'warehouse'=>['required'],
+            'warehouse_id'=>['required'],
         ],[
             'required'=>':attribute 为必填项',
             'max'=>':attribute 过长',
             'unique'=>':attribute 已存在',
         ],[
             'name'=>'工作组名称',
-            'warehouse'=>'仓库名称',
+            'warehouse_id'=>'仓库名称',
         ]);
         return $validator;
     }

+ 5 - 8
app/LaborReport.php

@@ -78,13 +78,6 @@ class LaborReport extends Model
         }
         if ($userDutyCheck->type=='登入'&&$userDutyCheckOld->checked_at<$userDutyCheck->checked_at){
             $userDutyCheck->save();
-//            $userDutyCheckStart=UserDutyCheck::where('user_id',$laborReport->user_id)->where('workgroup_id',$laborReport->user_workgroup_id)->where('checked_at','>=',$date." 11:00".":00")
-//                ->where('checked_at','<=',$date." 14:00:00")->where('type','登出')->first();
-//            $userDutyCheckEnd=UserDutyCheck::where('user_id',$laborReport->user_id)->where('workgroup_id',$laborReport->user_workgroup_id)->where('type','登入')->where('checked_at','>=',$date." 11:00".":00")
-//                ->where('checked_at','<=',$date." 14:00:00")->first();
-//            $beginTime=Carbon::parse($userDutyCheckStart['checked_at']);
-//            $endTime=Carbon::parse($userDutyCheckEnd['checked_at']);
-//            $lunchHour=($endTime->diffInSeconds($beginTime))/3600;
             $laborReport['working_duration']=$laborReport['online_duration'];
             $laborReport->update();
         }
@@ -106,7 +99,11 @@ class LaborReport extends Model
             $beginTime=Carbon::parse($userDutyCheckStart['checked_at']);
             $endTime=Carbon::parse($userDutyCheckEnd['checked_at']);
             $lunchHour=($endTime->diffInSeconds($beginTime))/3600;
-            $laborReport['working_duration']=$laborReport['online_duration']-$lunchHour;
+            if($userDutyCheck->type=='登入'&&$userDutyCheck->checked_at<=$date." 14:00:00"){
+                $laborReport['working_duration']=$laborReport['online_duration'];
+            }else{
+                $laborReport['working_duration']=$laborReport['online_duration']-$lunchHour;
+            }
             $laborReport->update();
         }
         return;

Разница между файлами не показана из-за своего большого размера
+ 400 - 120
composer.lock


+ 2 - 0
config/logging.php

@@ -5,6 +5,8 @@ use Monolog\Handler\SyslogUdpHandler;
 
 return [
 
+
+    'expire_duration'=>'150', //天数,日志超过时长的就在服务中删除
     /*
     |--------------------------------------------------------------------------
     | Default Log Channel

BIN
public/images/QRCodeIMG/1.png


BIN
public/images/QRCodeIMG/10.png


BIN
public/images/QRCodeIMG/2.png


BIN
public/images/QRCodeIMG/4.png


BIN
public/images/QRCodeIMG/5.png


+ 5 - 5
resources/views/weight/package/create.blade.php

@@ -28,7 +28,7 @@
                             <div class="form-group row">
                                 <label for="name" class="col-2 col-form-label text-right">快递单号</label>
                                 <div class="col-8">
-                                    <input type="text" class="form-control @error('logistic_number') is-invalid @enderror"
+                                    <input id="input" type="text" class="form-control @error('logistic_number') is-invalid @enderror"
                                            name="logistic_number" autocomplete="off" value="{{ old('logistic_number')}}">
                                     @error('logistic_number')
                                     <span class="invalid-feedback" role="alert">
@@ -42,7 +42,7 @@
                         <div class="form-group row">
                             <label for="order_code" class="col-2 col-form-label text-right text-info">订单号</label>
                             <div class="col-8">
-                                <input id="order_code" type="text" class="form-control @error('order_code') is-invalid @enderror"
+                                <input id="input" type="text" class="form-control @error('order_code') is-invalid @enderror"
                                        name="order_code" autocomplete="off" value="{{ old('order_code')}}">
                                 @error('order_code')
                                 <span class="invalid-feedback" role="alert">
@@ -56,7 +56,7 @@
                             <div class="form-group row">
                                 <label for="batch_number" class="col-2 col-form-label text-right">波次号</label>
                                 <div class="col-8">
-                                    <input type="text" class="form-control @error('batch_number') is-invalid @enderror"
+                                    <input type="text" id="input" class="form-control @error('batch_number') is-invalid @enderror"
                                            name="batch_number" autocomplete="off" value="{{ old('batch_number')}}">
                                     @error('batch_number')
                                     <span class="invalid-feedback" role="alert">
@@ -69,7 +69,7 @@
                     <div class="form-group row">
                         <label for="weight" class="col-2 col-form-label text-right">重量</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('weight') is-invalid @enderror"
+                            <input type="text" id="input" class="form-control @error('weight') is-invalid @enderror"
                                    name="weight" autocomplete="off" value="{{ old('weight')}}">
                             @error('weight')
                             <span class="invalid-feedback" role="alert">
@@ -167,7 +167,7 @@
         $("#form").on("keydown","input",function(){
             let e = event || window.event;
             if(e && e.keyCode==13) {
-                let inputs = $("#form input");
+                let inputs = $("#form #input");
                 let idx = inputs.index(this);     // 获取当前焦点输入框所处的位置
                 if (idx == inputs.length - 1) {       // 判断是否是最后一个输入框
                         $("#form").submit(); // 提交表单

+ 8 - 0
runServes.sh

@@ -9,3 +9,11 @@ nohup php artisan queue:work --tries=2 --delay=2 >/dev/null 2>&1 &
 nohup php artisan queue:work --tries=2 --delay=2 >/dev/null 2>&1 &
 nohup php artisan queue:work --tries=2 --delay=2 >/dev/null 2>&1 &
 nohup php artisan queue:work --tries=2 --delay=2 >/dev/null 2>&1 &
+
+
+
+isExistStr=$(cat /etc/crontab|grep '* * * * * root cd /var/www_test/was && php artisan schedule:run >> /dev/null 2>&1')
+if [ ! -n "$isExistStr" ]; then
+echo -e '\n* * * * * root cd /var/www_test/was && php artisan schedule:run >> /dev/null 2>&1' >> /etc/crontab
+fi
+systemctl restart crond

Некоторые файлы не были показаны из-за большого количества измененных файлов