|
@@ -20,7 +20,7 @@ class LaborReport extends Model
|
|
|
'user_duty_check_id','relax_time'
|
|
'user_duty_check_id','relax_time'
|
|
|
];
|
|
];
|
|
|
protected $appends = [
|
|
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'
|
|
'totalOnlineTime','verifyPerson','userDutyCheckVerifyUserId','isAdult','round_check_in_at','round_check_out_at','has_group_verify_right'
|
|
|
];
|
|
];
|
|
|
protected $tempFields = [
|
|
protected $tempFields = [
|
|
@@ -115,11 +115,7 @@ class LaborReport extends Model
|
|
|
//本轮工作结束时间
|
|
//本轮工作结束时间
|
|
|
public function getThisRoundOnlineEndTimeAttribute(){
|
|
public function getThisRoundOnlineEndTimeAttribute(){
|
|
|
$laborReports=LaborReport::where('enter_number',$this['enter_number'])->get();
|
|
$laborReports=LaborReport::where('enter_number',$this['enter_number'])->get();
|
|
|
-// $maxId=$laborReports->max('id');
|
|
|
|
|
foreach ($laborReports as $laborReport){
|
|
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'])
|
|
if ($laborReport['exit_at']&&$laborReport['check_out_at'])
|
|
|
return $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;
|
|
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){
|
|
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){
|
|
if ($checkInTime->lessThanOrEqualTo($checkInTime->clone()->setHours(11)->setMinutes(30))&&(int)$checkOutTime>=13){
|
|
|
$hour=$hour-1;
|
|
$hour=$hour-1;
|
|
|
}
|
|
}
|