|
@@ -7,6 +7,7 @@ use App\Model\Depart;
|
|
|
use App\Model\Employee;
|
|
use App\Model\Employee;
|
|
|
use App\Model\EmployeeDepartPermission;
|
|
use App\Model\EmployeeDepartPermission;
|
|
|
use App\Model\EmployeeDetails;
|
|
use App\Model\EmployeeDetails;
|
|
|
|
|
+use App\Model\EmployeeFile;
|
|
|
use App\Model\EmployeeRole;
|
|
use App\Model\EmployeeRole;
|
|
|
use App\Model\EmployeeWorkRange;
|
|
use App\Model\EmployeeWorkRange;
|
|
|
use App\Model\Role;
|
|
use App\Model\Role;
|
|
@@ -28,6 +29,7 @@ class EmployeeService extends Service
|
|
|
$model = new Employee();
|
|
$model = new Employee();
|
|
|
$model = $model->where('id',$user['id'])->first();
|
|
$model = $model->where('id',$user['id'])->first();
|
|
|
$model->password = Hash::make($data['new_password']);
|
|
$model->password = Hash::make($data['new_password']);
|
|
|
|
|
+ $model->p_version = $model->p_version + 1;
|
|
|
$model->save();
|
|
$model->save();
|
|
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
@@ -68,6 +70,7 @@ class EmployeeService extends Service
|
|
|
$model->education = $data['education'] ?? "";
|
|
$model->education = $data['education'] ?? "";
|
|
|
$model->id_card = $data['id_card'] ?? "";
|
|
$model->id_card = $data['id_card'] ?? "";
|
|
|
$model->major = $data['major'] ?? "";
|
|
$model->major = $data['major'] ?? "";
|
|
|
|
|
+ $model->position = $data['position'] ?? "";
|
|
|
$model->p_title = $data['p_title'] ?? "";
|
|
$model->p_title = $data['p_title'] ?? "";
|
|
|
$model->state = $data['state'] ?? 0;
|
|
$model->state = $data['state'] ?? 0;
|
|
|
$model->is_admin = $data['is_admin'] ?? 0;
|
|
$model->is_admin = $data['is_admin'] ?? 0;
|
|
@@ -79,6 +82,7 @@ class EmployeeService extends Service
|
|
|
}
|
|
}
|
|
|
$model->save();
|
|
$model->save();
|
|
|
|
|
|
|
|
|
|
+ $time = time();
|
|
|
EmployeeDepartPermission::where('employee_id',$data['id'])->delete();
|
|
EmployeeDepartPermission::where('employee_id',$data['id'])->delete();
|
|
|
if(isset($data['depart'])){
|
|
if(isset($data['depart'])){
|
|
|
$insert = [];
|
|
$insert = [];
|
|
@@ -93,7 +97,7 @@ class EmployeeService extends Service
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
EmployeeRole::where('employee_id',$data['id'])->update([
|
|
EmployeeRole::where('employee_id',$data['id'])->update([
|
|
|
- 'del_time' => time()
|
|
|
|
|
|
|
+ 'del_time' => $time
|
|
|
]);
|
|
]);
|
|
|
if(isset($data['role'])){
|
|
if(isset($data['role'])){
|
|
|
$insert = [];
|
|
$insert = [];
|
|
@@ -101,8 +105,7 @@ class EmployeeService extends Service
|
|
|
$insert[] = [
|
|
$insert[] = [
|
|
|
'employee_id' => $model->id,
|
|
'employee_id' => $model->id,
|
|
|
'role_id' => $value,
|
|
'role_id' => $value,
|
|
|
- 'crt_time' => time(),
|
|
|
|
|
- 'upd_time' => time(),
|
|
|
|
|
|
|
+ 'crt_time' => $time,
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
EmployeeRole::insert($insert);
|
|
EmployeeRole::insert($insert);
|
|
@@ -121,19 +124,39 @@ class EmployeeService extends Service
|
|
|
'total_work_min' => $value['total_work_min'],
|
|
'total_work_min' => $value['total_work_min'],
|
|
|
'top_depart_id' => $value['top_depart_id'],
|
|
'top_depart_id' => $value['top_depart_id'],
|
|
|
'crt_time' => time(),
|
|
'crt_time' => time(),
|
|
|
- 'upd_time' => time(),
|
|
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
EmployeeWorkRange::insert($insert);
|
|
EmployeeWorkRange::insert($insert);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $old = EmployeeFile::where('del_time',0)
|
|
|
|
|
+ ->where('employee_id',$user['id'])
|
|
|
|
|
+ ->pluck('file')
|
|
|
|
|
+ ->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ EmployeeFile::where('del_time',0)
|
|
|
|
|
+ ->where('employee_id',$user['id'])
|
|
|
|
|
+ ->update(['del_time' => $time]);
|
|
|
|
|
+
|
|
|
|
|
+ $new = [];
|
|
|
|
|
+ $insert = [];
|
|
|
|
|
+ if(! empty($data['img_url'])){
|
|
|
|
|
+ $insert[] = [
|
|
|
|
|
+ 'employee_id' => $user['id'],
|
|
|
|
|
+ 'file' => $data['img_url'],
|
|
|
|
|
+ 'crt_time' => $time,
|
|
|
|
|
+ ];
|
|
|
|
|
+ EmployeeFile::insert($insert);
|
|
|
|
|
+ $new[] = $data['img_url'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
return [false, $exception->getMessage()];
|
|
return [false, $exception->getMessage()];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return [true,''];
|
|
|
|
|
|
|
+ return [true, ['file' => ['new' => $new, 'old' => $old]]];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function employeeAdd($data,$user){
|
|
public function employeeAdd($data,$user){
|
|
@@ -150,6 +173,7 @@ class EmployeeService extends Service
|
|
|
$model->education = $data['education'] ?? "";
|
|
$model->education = $data['education'] ?? "";
|
|
|
$model->id_card = $data['id_card'] ?? "";
|
|
$model->id_card = $data['id_card'] ?? "";
|
|
|
$model->major = $data['major'] ?? "";
|
|
$model->major = $data['major'] ?? "";
|
|
|
|
|
+ $model->position = $data['position'] ?? "";
|
|
|
$model->p_title = $data['p_title'] ?? "";
|
|
$model->p_title = $data['p_title'] ?? "";
|
|
|
$model->state = $data['state'] ?? 0;
|
|
$model->state = $data['state'] ?? 0;
|
|
|
$model->crt_id = $user['id'];
|
|
$model->crt_id = $user['id'];
|
|
@@ -161,6 +185,7 @@ class EmployeeService extends Service
|
|
|
$model->top_depart_id = $data['top_depart_id'];
|
|
$model->top_depart_id = $data['top_depart_id'];
|
|
|
$model->save();
|
|
$model->save();
|
|
|
|
|
|
|
|
|
|
+ $time = time();
|
|
|
if(isset($data['depart'])){
|
|
if(isset($data['depart'])){
|
|
|
$insert = [];
|
|
$insert = [];
|
|
|
foreach ($data['depart'] as $value){
|
|
foreach ($data['depart'] as $value){
|
|
@@ -179,8 +204,7 @@ class EmployeeService extends Service
|
|
|
$insert[] = [
|
|
$insert[] = [
|
|
|
'employee_id' => $model->id,
|
|
'employee_id' => $model->id,
|
|
|
'role_id' => $value,
|
|
'role_id' => $value,
|
|
|
- 'crt_time' => time(),
|
|
|
|
|
- 'upd_time' => time(),
|
|
|
|
|
|
|
+ 'crt_time' => $time,
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
EmployeeRole::insert($insert);
|
|
EmployeeRole::insert($insert);
|
|
@@ -197,20 +221,31 @@ class EmployeeService extends Service
|
|
|
'end_time_min' => $value['end_time_min'],
|
|
'end_time_min' => $value['end_time_min'],
|
|
|
'total_work_min' => $value['total_work_min'],
|
|
'total_work_min' => $value['total_work_min'],
|
|
|
'top_depart_id' => $value['top_depart_id'],
|
|
'top_depart_id' => $value['top_depart_id'],
|
|
|
- 'crt_time' => time(),
|
|
|
|
|
- 'upd_time' => time(),
|
|
|
|
|
|
|
+ 'crt_time' => $time,
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
EmployeeWorkRange::insert($insert);
|
|
EmployeeWorkRange::insert($insert);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $new = [];
|
|
|
|
|
+ $insert = [];
|
|
|
|
|
+ if(! empty($data['img_url'])){
|
|
|
|
|
+ $insert[] = [
|
|
|
|
|
+ 'employee_id' => $user['id'],
|
|
|
|
|
+ 'file' => $data['img_url'],
|
|
|
|
|
+ 'crt_time' => $time,
|
|
|
|
|
+ ];
|
|
|
|
|
+ EmployeeFile::insert($insert);
|
|
|
|
|
+ $new[] = $data['img_url'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
}catch (Exception $e){
|
|
}catch (Exception $e){
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
return [false, $e->getMessage()];
|
|
return [false, $e->getMessage()];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return [true,''];
|
|
|
|
|
|
|
+ return [true, ['file' => ['new' => $new]]];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function employeeDel($data){
|
|
public function employeeDel($data){
|
|
@@ -229,13 +264,18 @@ class EmployeeService extends Service
|
|
|
EmployeeDepartPermission::whereIn('employee_id',$data['id'])->delete();
|
|
EmployeeDepartPermission::whereIn('employee_id',$data['id'])->delete();
|
|
|
EmployeeWorkRange::whereIn('employee_id',$data['id'])->delete();
|
|
EmployeeWorkRange::whereIn('employee_id',$data['id'])->delete();
|
|
|
|
|
|
|
|
|
|
+ $old = EmployeeFile::where('del_time',0)
|
|
|
|
|
+ ->whereIn('employee_id',$data['id'])
|
|
|
|
|
+ ->pluck('file')
|
|
|
|
|
+ ->toArray();
|
|
|
|
|
+
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
return [false,$exception->getMessage()];
|
|
return [false,$exception->getMessage()];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return [true, ''];
|
|
|
|
|
|
|
+ return [true, ['file' => ['old' => $old]]];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function employeeDetail($data, $user){
|
|
public function employeeDetail($data, $user){
|
|
@@ -246,6 +286,23 @@ class EmployeeService extends Service
|
|
|
return [true, $user];
|
|
return [true, $user];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getEmployeeImg($data, $user){
|
|
|
|
|
+ $file = EmployeeFile::where('del_time',0)
|
|
|
|
|
+ ->where('employee_id',$user['id'])
|
|
|
|
|
+ ->select('file')
|
|
|
|
|
+ ->get()->toArray();
|
|
|
|
|
+ $file = array_column($file,'file');
|
|
|
|
|
+ $file = $file[0] ?? "";
|
|
|
|
|
+ $img_str = "";
|
|
|
|
|
+ $timeStamp = 86400;
|
|
|
|
|
+ if(! empty($file)){
|
|
|
|
|
+ $fileUploadService = new FileUploadService();
|
|
|
|
|
+ $img_str = $fileUploadService->getFileShow($file, $timeStamp);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [true, ['img_url' => $img_str]];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function employeeCommon($data,$user, $field = []){
|
|
public function employeeCommon($data,$user, $field = []){
|
|
|
if(empty($field)) $field = Employee::$field;
|
|
if(empty($field)) $field = Employee::$field;
|
|
|
|
|
|
|
@@ -569,6 +626,7 @@ class EmployeeService extends Service
|
|
|
if(! empty($data['sex']) && ! isset(Employee::SEX_TYPE[$data['sex']])) return [false, '性别不存在'];
|
|
if(! empty($data['sex']) && ! isset(Employee::SEX_TYPE[$data['sex']])) return [false, '性别不存在'];
|
|
|
if(empty($data['mobile'])) return [false,'联系电话不能为空'];
|
|
if(empty($data['mobile'])) return [false,'联系电话不能为空'];
|
|
|
// if(! $this->isValidPhone($data['mobile'])) return [false, '手机号码格式错误'];
|
|
// if(! $this->isValidPhone($data['mobile'])) return [false, '手机号码格式错误'];
|
|
|
|
|
+ if(empty($data['major'])) return [false, '专业领域不能为空'];
|
|
|
if(! empty($data['education']) && ! isset(Employee::Education[$data['education']])) return [false, '学历不存在'];
|
|
if(! empty($data['education']) && ! isset(Employee::Education[$data['education']])) return [false, '学历不存在'];
|
|
|
if(empty($data['id_card'])) return [false, '身份证号不能为空'];
|
|
if(empty($data['id_card'])) return [false, '身份证号不能为空'];
|
|
|
if(empty($data['depart'])) return [false,'部门不能为空'];
|
|
if(empty($data['depart'])) return [false,'部门不能为空'];
|
|
@@ -580,10 +638,10 @@ class EmployeeService extends Service
|
|
|
if(mb_strlen($data['password']) < 6) return [false, '密码长度不得小于6位长度'];
|
|
if(mb_strlen($data['password']) < 6) return [false, '密码长度不得小于6位长度'];
|
|
|
if(empty($data['role'])) return [false, '角色不能为空'];
|
|
if(empty($data['role'])) return [false, '角色不能为空'];
|
|
|
}
|
|
}
|
|
|
- if(empty($data['man_type'])) return [false,'人员类别不能为空'];
|
|
|
|
|
- if(! isset(Employee::Man_Type[$data['man_type']])) return [false,'人员类别不存在'];
|
|
|
|
|
-// if(empty($data['entrust_type'])) return [false,'委托方式不能为空'];
|
|
|
|
|
-// if(! isset(Employee::WT_Type[$data['entrust_type']])) return [false,'委托方式不存在'];
|
|
|
|
|
|
|
+ if(empty($data['man_type'])) return [false,'是否为技术研究人员不能为空'];
|
|
|
|
|
+ if(! isset(Employee::Man_Type[$data['man_type']])) return [false,'是否为技术研究人员不存在'];
|
|
|
|
|
+ if(! isset($data['entrust_type'])) return [false,'委托方式不能为空'];
|
|
|
|
|
+ if(! isset(Employee::WT_Type[$data['entrust_type']])) return [false,'委托方式不存在'];
|
|
|
$data['top_depart_id'] = $user['top_depart_id'];
|
|
$data['top_depart_id'] = $user['top_depart_id'];
|
|
|
|
|
|
|
|
if(! empty($data['work_range'])){
|
|
if(! empty($data['work_range'])){
|