|
|
@@ -61,7 +61,7 @@ class PersonnelController extends Controller
|
|
|
]);
|
|
|
LaborReportStatus::query()->create([
|
|
|
'labor_report_id'=>$laborReport['id'],
|
|
|
- 'status'=>'已进组',
|
|
|
+ 'status'=>'已入场',
|
|
|
'created_at'=>$checked_at,
|
|
|
]);
|
|
|
if ($remark)$laborReportService->addOrUpdateRemark($remark,$laborReport->id);
|
|
|
@@ -99,13 +99,19 @@ class PersonnelController extends Controller
|
|
|
}
|
|
|
break;
|
|
|
case '退组':
|
|
|
-// $laborReport=LaborReport::query()->with('userDutyCheck')
|
|
|
-// ->where('user_id',$user_id)
|
|
|
-// ->where('created_at','like',$checkedAtDate.'%')
|
|
|
-// ->orderBy('id','desc')->first();
|
|
|
+ $round_time=round(Carbon::parse($checked_at)->diffInSeconds(Carbon::parse($laborReport->round_check_in_at))/3600,2);
|
|
|
+ $relax_time=$request->input('relax_time')??null;
|
|
|
+ $working_duration=null;
|
|
|
+ if ($relax_time){
|
|
|
+ $working_duration=$this->minusLunchTime($laborReport->round_check_in_at,$checked_at,$round_time)-$relax_time/60;//减去晚饭时间
|
|
|
+ }else{
|
|
|
+ $working_duration=$this->minusLunchTime($laborReport->round_check_in_at,$checked_at,$round_time);
|
|
|
+ }
|
|
|
if ($laborReport && !$laborReport->check_out_at){
|
|
|
$laborReport->update([
|
|
|
'check_out_at'=>$checked_at,
|
|
|
+ 'relax_time'=>$relax_time,
|
|
|
+ 'working_duration'=>$working_duration,
|
|
|
]);
|
|
|
LaborReportStatus::query()->create([
|
|
|
'labor_report_id'=>$laborReport['id'],
|
|
|
@@ -142,6 +148,21 @@ class PersonnelController extends Controller
|
|
|
return ['success'=>true,'data'=>$userDutyCheck];
|
|
|
}
|
|
|
}
|
|
|
+ public function minusLunchTime($checkInTime,$checkOutTime,$hour){
|
|
|
+ $checkInTime=Carbon::parse($checkInTime);
|
|
|
+ $checkOutTime=Carbon::parse($checkOutTime);
|
|
|
+ //白班:第一餐 默认减去1小时
|
|
|
+ if ($checkInTime->lessThanOrEqualTo($checkInTime->clone()->setHours(11)->setMinutes(30))//进组时间小于等于进组当天11:30
|
|
|
+ &&Carbon::parse($checkOutTime)->gte(Carbon::parse($checkInTime->clone()->setHour(13)->setMinute(00)->setSecond(00)))){//退组时间大于进组当天的13:00
|
|
|
+ $hour=$hour-1;
|
|
|
+ }
|
|
|
+ //夜班:第一餐 默认减去半小时
|
|
|
+ if ($checkInTime->lessThanOrEqualTo($checkInTime->clone()->setHours(23)->setMinutes(59))//进组时间小于等于当天23:59
|
|
|
+ &&Carbon::parse($checkOutTime)->gte(Carbon::parse($checkInTime->clone()->subDays(-1)->setHour(1)))){//退组时间大于等于进组后一天的1:00
|
|
|
+ $hour=$hour-0.5;
|
|
|
+ }
|
|
|
+ return $hour;
|
|
|
+ }
|
|
|
//补卡创建或修改临时工报表
|
|
|
public function makeOrUpdateLaborReport($userDutyCheck,$remark){
|
|
|
$checkedAtDate=Carbon::parse($userDutyCheck->checked_at)->format('Y-m-d');
|