|
|
@@ -40,12 +40,12 @@ class PersonnelController extends Controller
|
|
|
$checkedAtDate=Carbon::parse($checked_at)->format('Y-m-d');
|
|
|
/** @var LaborReportService $laborReportService */
|
|
|
$laborReportService=app(LaborReportService::class);
|
|
|
+ $laborReport=LaborReport::query()->with('userDutyCheck','user.userDetail')
|
|
|
+ ->where('user_id',$user_id)
|
|
|
+ ->where('created_at','like',$checkedAtDate.'%')
|
|
|
+ ->orderBy('id','desc')->first();
|
|
|
switch ($type) {
|
|
|
case '进组':
|
|
|
- $laborReport=LaborReport::query()->with('userDutyCheck','user.userDetail')
|
|
|
- ->where('user_id',$user_id)
|
|
|
- ->where('created_at','like',$checkedAtDate.'%')
|
|
|
- ->orderBy('id','desc')->first();
|
|
|
if ($laborReport && !$laborReport->check_in_at && !$laborReport->user_workgroup_id){ //第一次进组
|
|
|
$laborReport->update([
|
|
|
'check_in_at'=>$checked_at,
|
|
|
@@ -91,11 +91,12 @@ class PersonnelController extends Controller
|
|
|
app('LogService')->log(__METHOD__,"录入进组补卡".__FUNCTION__,json_encode($newReport),Auth::user()['id']);
|
|
|
return ['success'=>true,'data'=>$newReport->userDutyCheck];
|
|
|
}
|
|
|
+ break;
|
|
|
case '退组':
|
|
|
- $laborReport=LaborReport::query()->with('userDutyCheck')
|
|
|
- ->where('user_id',$user_id)
|
|
|
- ->where('created_at','like',$checkedAtDate.'%')
|
|
|
- ->orderBy('id','desc')->first();
|
|
|
+// $laborReport=LaborReport::query()->with('userDutyCheck')
|
|
|
+// ->where('user_id',$user_id)
|
|
|
+// ->where('created_at','like',$checkedAtDate.'%')
|
|
|
+// ->orderBy('id','desc')->first();
|
|
|
if ($laborReport && !$laborReport->check_out_at){
|
|
|
$laborReport->update([
|
|
|
'check_out_at'=>$checked_at,
|
|
|
@@ -118,7 +119,8 @@ class PersonnelController extends Controller
|
|
|
'verify_user_id'=>Auth::user()['id'],
|
|
|
]);
|
|
|
$userDutyCheckBefore=UserDutyCheck::query()->where('user_id',$user_id)->where('checked_at','like',$checkedAtDate.'%')->orderBy('id','desc')->first();
|
|
|
- if ($userDutyCheckBefore['type']=='登入'&&$userDutyCheck->type=='登入')return ['result'=>true,'data'=>'已存在进场记录!'];
|
|
|
+// if ($userDutyCheckBefore['type']=='登入'&&$userDutyCheck->type=='登入')return ['result'=>true,'data'=>'已存在进场记录!'];
|
|
|
+ if ($laborReport && $userDutyCheck->type=='登入')return ['result'=>true,'data'=>'已存在进场记录!'];
|
|
|
if ($userDutyCheckBefore['type']=='登出'&&$userDutyCheck->type=='登出')return ['result'=>true,'data'=>'已存在出场记录!'];
|
|
|
$userDutyCheck->save();
|
|
|
app('LogService')->log(__METHOD__,"录入补卡".__FUNCTION__,json_encode($userDutyCheck),Auth::user()['id']);
|