定时关闭访客/相关方入厂项目
This commit is contained in:
parent
e7403c2f32
commit
5f0f715e34
|
@ -9,6 +9,7 @@ from datetime import datetime
|
|||
from django.utils import timezone
|
||||
myLogger = logging.getLogger('log')
|
||||
|
||||
|
||||
class HrmService:
|
||||
|
||||
@classmethod
|
||||
|
@ -199,13 +200,13 @@ class HrmService:
|
|||
from apps.rpm.models import Rpj
|
||||
nodeCode = data['info']['nodeCode']
|
||||
device = TDevice.objects.filter(code=nodeCode).first()
|
||||
|
||||
|
||||
if device:
|
||||
id_number = data['info']['extend'].get('paperNumber', None)
|
||||
if id_number: # 如果有身份证号
|
||||
if device.is_clock:
|
||||
# 如果设置为关联考勤
|
||||
myLogger.info(data['info']['extend'])
|
||||
# myLogger.info(data['info']['extend'])
|
||||
if data['info']['extend']['enterOrExit'] == 1:
|
||||
# 如果是进门
|
||||
ep = Employee.objects.filter(id_number=id_number, type__in=["employee", "remployee"]).first()
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2022-08-24 07:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rpm', '0003_auto_20220823_1628'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='rpj',
|
||||
name='remployees',
|
||||
field=models.ManyToManyField(related_name='rpj_remployees', through='rpm.Rpjmember', to='rpm.Remployee'),
|
||||
),
|
||||
]
|
|
@ -43,12 +43,14 @@ class Rpj(CommonBDModel):
|
|||
RPJ_ENTER = 30
|
||||
RPJ_WORKING = 40
|
||||
RPJ_DONE = 50
|
||||
RPJ_CLOSE = 60
|
||||
RP_STATE_CHOICES = (
|
||||
(10, '创建中'),
|
||||
(20, '审批中'),
|
||||
(30, '待入厂'),
|
||||
(40, '进行中'),
|
||||
(50, '已完成')
|
||||
(50, '已完成'),
|
||||
(60, '已关闭')
|
||||
)
|
||||
RP_TYPE_CHOICES = (
|
||||
(10, '建筑施工'),
|
||||
|
@ -63,7 +65,7 @@ class Rpj(CommonBDModel):
|
|||
leave_time = models.DateTimeField('离厂时间')
|
||||
state = models.PositiveSmallIntegerField('状态', default=10)
|
||||
rparty = models.ForeignKey(Rparty, verbose_name='关联相关方', on_delete=models.CASCADE)
|
||||
remployees = models.ManyToManyField('rpm.remployee', through='rpm.rpjmember')
|
||||
remployees = models.ManyToManyField('rpm.remployee', through='rpm.rpjmember', related_name='rpj_remployees')
|
||||
# belong_dept是业务部门可以带过来
|
||||
ticket = models.ForeignKey(Ticket, verbose_name='关联工单',
|
||||
on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
# Create your tasks here
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from apps.hrm.models import Certificate, Employee
|
||||
from apps.rpm.models import Rcertificate, Remployee, Rpj, Rpjcertificate, Rpjmember
|
||||
from apps.rpm.models import Rpj
|
||||
from apps.utils.tasks import CustomTask
|
||||
from celery import shared_task
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
@shared_task(base=CustomTask)
|
||||
def close_rpj_by_leave_time():
|
||||
"""
|
||||
定时关闭相关方入厂项目
|
||||
"""
|
||||
now = timezone.now()
|
||||
# 正常结束/其他关闭
|
||||
rpjs = Rpj.objects.filter(leave_time__lt=now)
|
||||
for i in rpjs:
|
||||
if i.state == Rpj.RPJ_WORKING:
|
||||
i.state = Rpj.RPJ_DONE
|
||||
i.save()
|
||||
else:
|
||||
i.state = Rpj.RPJ_CLOSE
|
||||
i.save()
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2022-08-24 07:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vm', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='visit',
|
||||
name='state',
|
||||
field=models.PositiveSmallIntegerField(choices=[(10, '创建中'), (20, '审批中'), (30, '待入厂'), (40, '进行中'), (50, '已完成'), (60, '已关闭')], default=10),
|
||||
),
|
||||
]
|
|
@ -22,12 +22,14 @@ class Visit(CommonBModel):
|
|||
V_ENTER = 30
|
||||
V_WORKING = 40
|
||||
V_DONE = 50
|
||||
V_CLOSE = 60
|
||||
V_STATE_CHOICES = (
|
||||
(10, '创建中'),
|
||||
(20, '审批中'),
|
||||
(30, '待入厂'),
|
||||
(40, '进行中'),
|
||||
(50, '已完成')
|
||||
(50, '已完成'),
|
||||
(60, '已关闭')
|
||||
)
|
||||
V_LEVEL_CHOICES = (
|
||||
(10, '一般'),
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
# Create your tasks here
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from apps.hrm.models import Employee
|
||||
from apps.vm.models import Visit
|
||||
from apps.utils.tasks import CustomTask
|
||||
from apps.vm.models import Visit, Vpeople
|
||||
from apps.wf.models import Ticket
|
||||
from celery import shared_task
|
||||
from apps.hrm.services import HrmService
|
||||
from apps.wf.services import WfService
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
@shared_task(base=CustomTask)
|
||||
def close_visit_by_leave_time():
|
||||
"""
|
||||
定时关闭访客入厂项目
|
||||
"""
|
||||
now = timezone.now()
|
||||
# 正常结束/其他关闭
|
||||
vs = Visit.objects.filter(leave_time__lt=now)
|
||||
for i in vs:
|
||||
if i.state == Visit.V_WORKING:
|
||||
i.state = Visit.V_DONE
|
||||
i.save()
|
||||
else:
|
||||
i.state = Visit.V_CLOSE
|
||||
i.save()
|
||||
|
|
Loading…
Reference in New Issue