Browse Source

人事--总工时以取整后时间计算

haozi 5 năm trước cách đây
mục cha
commit
7201a31b56

+ 1 - 1
app/Http/Controllers/LaborReportController.php

@@ -71,7 +71,7 @@ class LaborReportController extends Controller
         $totalLaborReports=app('laborReportService')->get($param);
         $totalWorkingHours=0;
         foreach ($totalLaborReports as $totalLaborReport){
-            $totalWorkingHours=$totalWorkingHours+$totalLaborReport->thisRecordWorkingTime;
+            $totalWorkingHours=$totalWorkingHours+$totalLaborReport->thisRoundRecordWorkingTime;
         }
         return $totalWorkingHours;
     }

+ 10 - 0
app/Http/Controllers/TestController.php

@@ -828,5 +828,15 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         $service = app('OrderIssueService');
         $service->updateByWmsOrders($orderHeaders);
     }
+    public function testCollectMethod()
+    {
+        $collection = collect(str_split('AABBCCCD'));
+
+        $chunks = $collection->chunkWhile(function($current, $key, $chunk) {
+            return $current === $chunk->last();
+        });
+        $chunks->toArray();
+        dd( $chunks->toArray());
+    }
 
 }

+ 22 - 8
app/LaborReport.php

@@ -20,7 +20,7 @@ class LaborReport extends Model
         'user_duty_check_id','relax_time'
     ];
     protected $appends = [
-        'is_exportGroup','is_export', 'exit_at','enter_at','sequence', 'amountOfJoined','remark','thisRecordOnlineTime','thisRecordWorkingTime',
+        'is_exportGroup','is_export', 'exit_at','enter_at','sequence', 'amountOfJoined','remark','thisRecordOnlineTime','thisRecordWorkingTime','thisRoundRecordWorkingTime',
         'totalOnlineTime','verifyPerson','userDutyCheckVerifyUserId','isAdult','round_check_in_at','round_check_out_at','has_group_verify_right'
     ];
     protected $tempFields = [
@@ -115,11 +115,7 @@ class LaborReport extends Model
     //本轮工作结束时间
     public function getThisRoundOnlineEndTimeAttribute(){
         $laborReports=LaborReport::where('enter_number',$this['enter_number'])->get();
-//        $maxId=$laborReports->max('id');
         foreach ($laborReports as $laborReport){
-//            if ($laborReport['id']==$maxId&&!$laborReport['exit_at']&&$laborReport['check_out_at']){
-//                return $laborReport['check_out_at'];
-//            }
             if ($laborReport['exit_at']&&$laborReport['check_out_at'])
                 return $laborReport['check_out_at'];
         }
@@ -160,12 +156,30 @@ class LaborReport extends Model
             return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime)-$this['relax_time']/60;
         }
     }
+    //本次取整工作时长
+    public function getThisRoundRecordWorkingTimeAttribute(){
+        if ($this['round_check_in_at']&&!$this['round_check_out_at']&&!$this['relax_time']){
+            $workingTime=round(Carbon::parse(Carbon::now())->diffInSeconds(Carbon::parse($this['round_check_in_at']))/3600,2);
+            $checkInTime=Carbon::parse($this['round_check_in_at']);
+            $checkOutTime=Carbon::parse(Carbon::now())->format('H');
+            return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime);
+        }
+        if ($this['round_check_in_at']&&$this['round_check_out_at']&&!$this['relax_time']){
+            $workingTime=round(Carbon::parse($this['round_check_out_at'])->diffInSeconds(Carbon::parse($this['round_check_in_at']))/3600,2);
+            $checkInTime=Carbon::parse($this['round_check_in_at']);
+            $checkOutTime=Carbon::parse($this['round_check_out_at'])->format('H');
+            return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime);
+        }
+        if ($this['round_check_in_at']&&$this['round_check_out_at']&&$this['relax_time']){
+            $workingTime=round(Carbon::parse($this['round_check_out_at'])->diffInSeconds(Carbon::parse($this['round_check_in_at']))/3600,2);
+            $checkInTime=Carbon::parse($this['round_check_in_at']);
+            $checkOutTime=Carbon::parse($this['round_check_out_at'])->format('H');
+            return  $this->minusLunchTime($checkInTime,$checkOutTime,$workingTime)-$this['relax_time']/60;
+        }
+    }
 
     //工作时长减午饭休息时间
     public function minusLunchTime($checkInTime,$checkOutTime,$hour){
-//        if ((int)$checkInTime<=12&&(int)$checkOutTime>=13){
-//            $hour=$hour-1;
-//        }
         if ($checkInTime->lessThanOrEqualTo($checkInTime->clone()->setHours(11)->setMinutes(30))&&(int)$checkOutTime>=13){
             $hour=$hour-1;
         }

+ 4 - 2
resources/views/personnel/laborReport/index.blade.php

@@ -83,7 +83,7 @@
                 <td class="text-muted"><span v-if="laborReport.relax_time">@{{laborReport.relax_time}}</span></td>
                 {{--                        <td class="text-muted"><span v-if="laborReport.onlineDuration">@{{laborReport.onlineDuration}}</span></td>--}}
                 <td class="text-muted"><span v-if="laborReport.thisRecordOnlineTime">@{{laborReport.thisRecordOnlineTime}}</span></td>
-                <td><span v-if="laborReport.thisRecordWorkingTime">@{{laborReport.thisRecordWorkingTime}}</span></td>
+                <td><span v-if="laborReport.thisRoundRecordWorkingTime">@{{laborReport.thisRoundRecordWorkingTime}}</span></td>
                 {{--                        <td><span v-if="laborReport.workingDuration">@{{laborReport.workingDuration}}</span></td>--}}
                 <td>
                     @can('人事管理-临时工报表-编辑备注')
@@ -296,7 +296,9 @@
                             workingDuration:'{{$laborReport->working_duration}}', created_at:'{{$laborReport->created_at}}',
                             enter_at:'{{$laborReport->enter_at}}',exit_at:'{{$laborReport->exit_at}}',
                             thisRecordOnlineTime:'{{$laborReport->thisRecordOnlineTime}}',
-                            thisRecordWorkingTime:'{{$laborReport->thisRecordWorkingTime}}',isAdult:'{{$laborReport->isAdult}}',has_group_verify_right:'{{$laborReport->has_group_verify_right}}',
+                            thisRecordWorkingTime:'{{$laborReport->thisRecordWorkingTime}}',
+                            thisRoundRecordWorkingTime:'{{$laborReport->thisRoundRecordWorkingTime}}',
+                            isAdult:'{{$laborReport->isAdult}}',has_group_verify_right:'{{$laborReport->has_group_verify_right}}',
                             sequence:'{{$laborReport->sequence}}',amountOfJoined:'{{$laborReport->amountOfJoined}}',remark:'{{$laborReport->remark}}',
                             @if($laborReport->userDutyCheck)user_duty_check_id:'{{$laborReport->userDutyCheck->id}}', userDutyCheckVerifyUserId:'{{$laborReport->userDutyCheck->verify_user_id}}'
                             ,userDutyCheckType:'{{$laborReport->userDutyCheck->type}}',userDutyCheckAt:'{{$laborReport->userDutyCheck->checked_at}}',@endif},

+ 16 - 13
tests/Services/StoreService/AsnSyncTest.php

@@ -8,6 +8,7 @@ use App\Services\OracleDocAsnDetailService;
 use App\Services\OracleDocAsnHerderService;
 use App\Services\StoreService;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Auth;
 use Tests\TestCase;
 
 class AsnSyncTest extends TestCase
@@ -22,20 +23,22 @@ class AsnSyncTest extends TestCase
 
 
     public function testAsnSync(){
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
-
-        $syncStartDate = data_get(config('sync'), 'asn_sync.start_at');
-
-        if($syncStartDate ?? false){
-            $syncStartDate = Carbon::parse($syncStartDate);
-            if ($startDate->lt($syncStartDate)) {
-                $startDate = $syncStartDate;
-            }
-        }
-//        $startDate=Carbon::parse('2020-10-22 00:00:00')->subDays(1)->format('Y-m-d H:i:s');
+//        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
+//
+//        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+//
+//        $syncStartDate = data_get(config('sync'), 'asn_sync.start_at');
+//
+//        if($syncStartDate ?? false){
+//            $syncStartDate = Carbon::parse($syncStartDate);
+//            if ($startDate->lt($syncStartDate)) {
+//                $startDate = $syncStartDate;
+//            }
+//        }
+        //$startDate=Carbon::parse('2020-10-22 00:00:00')->subDays(1)->format('Y-m-d H:i:s');
+//        app('LogService')->log(__METHOD__,"start".__FUNCTION__,Carbon::now());
         //app(StoreService::class)->syncWmsAsnData($startDate);
+//        app('LogService')->log(__METHOD__,"end".__FUNCTION__,Carbon::now());
         //$asnHeaders=app(OracleDocAsnHerderService::class)->getWmsAsnOnStartDateCreate($startDate);
         //dd($asnHeaders);