diff --git a/apps/hrm/migrations/0007_alter_employee_job_state.py b/apps/hrm/migrations/0007_alter_employee_job_state.py new file mode 100644 index 00000000..8131112f --- /dev/null +++ b/apps/hrm/migrations/0007_alter_employee_job_state.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.12 on 2023-03-02 09:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hrm', '0006_alter_employee_user'), + ] + + operations = [ + migrations.AlterField( + model_name='employee', + name='job_state', + field=models.IntegerField(choices=[(10, '在职'), (20, '离职'), (30, '退休')], default=10, verbose_name='在职状态'), + ), + ] diff --git a/apps/hrm/models.py b/apps/hrm/models.py index 2bc0f7f9..0b5e3e05 100755 --- a/apps/hrm/models.py +++ b/apps/hrm/models.py @@ -10,9 +10,11 @@ class Employee(CommonBModel): """ JOB_ON = 10 JOB_OFF = 20 + JOB_RETIRE = 30 jobstate_choices = ( (JOB_ON, '在职'), (JOB_OFF, '离职'), + (JOB_RETIRE, '退休') ) PEOPLE_TYPE_CHOICES = ( ('employee', '内部员工'), diff --git a/apps/hrm/serializers.py b/apps/hrm/serializers.py index 4b867100..9f853d27 100755 --- a/apps/hrm/serializers.py +++ b/apps/hrm/serializers.py @@ -79,7 +79,7 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer): elif instance.type in ['visitor', 'driver']: # 如果是访客或司机 from apps.vm.services import sync_to_visitor sync_to_visitor(instance) - if instance.job_state == 20 and instance.user: # 如果离职了关闭账户 + if instance.job_state in [20, 30] and instance.user: # 如果离职了关闭账户 instance.user.is_active = False instance.user.save() # 同时去除门禁授权 @@ -92,10 +92,10 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer): if instance.third_info.get('dh_face_card', None) is None and instance.type == 'employee': # 如果是正式员工,给长时间期限 start_time = now end_time = now + timedelta(days=7300) - if instance.job_state == 20 and old_job_state == 10: # 离职 + if instance.job_state in [20, 30] and old_job_state == 10: # 离职或退休 start_time = now end_time = now + timedelta(minutes=60) - elif instance.job_state == 10 and old_job_state == 20 and instance.type == 'employee': # 正式员工重新在职 + elif instance.job_state == 10 and old_job_state in [20, 30] and instance.type == 'employee': # 正式员工重新在职 start_time = now end_time = now + timedelta(days=7300) HrmService.sync_dahua_employee(ep=instance, old_photo=old_photo,