Merge branch 'master' of https://e.coding.net/ctcdevteam/ehs/ehs_server
This commit is contained in:
commit
71dd916dbf
|
@ -15,7 +15,7 @@ def check_phone_code(phone, code, raise_exception=True):
|
|||
|
||||
def validate_password(password):
|
||||
# 正则表达式匹配规则
|
||||
pattern = r"^(?=.*[a-zA-Z])(?=.*\d)(?=.*[@#$%^&+=!])(?!.*\s).{8,}$"
|
||||
pattern = r"^(?=.*[a-zA-Z])(?=.*\d)(?=.*[@#$%^&.+=!])(?!.*\s).{8,}$"
|
||||
|
||||
# 使用正则表达式进行匹配
|
||||
if re.match(pattern, password):
|
||||
|
|
|
@ -72,6 +72,8 @@ class FtestWorkCreateUpdateSerializer(CustomModelSerializer):
|
|||
if 'wm' not in attrs:
|
||||
raise ValidationError('请选择车间库存')
|
||||
wm:WMaterial = attrs['wm']
|
||||
if wm.state not in [WMaterial.WM_OK, WMaterial.WM_TEST]:
|
||||
raise ValidationError('不支持对该物料检验')
|
||||
attrs['material'] = wm.material
|
||||
attrs['batch'] = wm.batch
|
||||
count_notok_json = attrs.get('count_notok_json', None)
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.utils import timezone
|
|||
|
||||
def ftestwork_submit(ins:FtestWork, user: User):
|
||||
wm:WMaterial = ins.wm
|
||||
if wm.count_xtest is not None: # 如果关心检验数量 一般是全检
|
||||
if wm.state == WMaterial.WM_TEST:
|
||||
# 更新对应的车间库存
|
||||
wm.count = wm.count - ins.count
|
||||
if wm.count >= 0:
|
||||
|
@ -24,9 +24,7 @@ def ftestwork_submit(ins:FtestWork, user: User):
|
|||
batch=wm.batch,
|
||||
mgroup=wm.mgroup,
|
||||
belong_dept=wm.belong_dept,
|
||||
notok_sign=None,
|
||||
material_origin=None,
|
||||
count_xtest=None,
|
||||
state=WMaterial.WM_OK,
|
||||
defaults={
|
||||
'count': count_ok,
|
||||
'material': wm.material,
|
||||
|
@ -56,15 +54,15 @@ def ftestwork_submit(ins:FtestWork, user: User):
|
|||
mgroup=wm.mgroup,
|
||||
belong_dept=wm.belong_dept,
|
||||
notok_sign=notok_sign,
|
||||
material_origin=None,
|
||||
count_xtest=None,
|
||||
state=WMaterial.WM_NOTOK,
|
||||
defaults={
|
||||
'count': v,
|
||||
'material': wm.material,
|
||||
'batch': wm.batch,
|
||||
'mgroup': wm.mgroup,
|
||||
'belong_dept': wm.belong_dept,
|
||||
'notok_sign': notok_sign
|
||||
'notok_sign': notok_sign,
|
||||
'state': WMaterial.WM_NOTOK,
|
||||
}
|
||||
)
|
||||
if not new_create:
|
||||
|
|
|
@ -38,6 +38,7 @@ class WMaterialFilter(filters.FilterSet):
|
|||
model = WMaterial
|
||||
fields = {
|
||||
"material": ["exact", "in"],
|
||||
"state": ["exact", "in"],
|
||||
"material__type": ["exact", "in"],
|
||||
"material__name": ["exact", "in", "contains"],
|
||||
"material__process": ["exact", "in"],
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2024-08-15 02:41
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wpm', '0060_auto_20240812_1048'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='wmaterial',
|
||||
name='state',
|
||||
field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'),
|
||||
),
|
||||
]
|
|
@ -89,6 +89,12 @@ class WMaterial(CommonBDModel):
|
|||
"""
|
||||
belong_dept是所在车间
|
||||
"""
|
||||
WM_OK = 10
|
||||
WM_NOTOK = 20
|
||||
WM_REPAIR = 30
|
||||
WM_TEST = 40
|
||||
WM_SCRAP = 50
|
||||
state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废')))
|
||||
material = models.ForeignKey(
|
||||
Material, verbose_name='物料', on_delete=models.CASCADE, related_name='wm_m')
|
||||
mgroup = models.ForeignKey(Mgroup, verbose_name='所在工段', on_delete=models.CASCADE, null=True, blank=True)
|
||||
|
|
|
@ -383,6 +383,8 @@ class MlogbInSerializer(CustomModelSerializer):
|
|||
mlog: Mlog = attrs['mlog']
|
||||
mtask: Mtask = attrs['mtask']
|
||||
wm_in: WMaterial = attrs['wm_in']
|
||||
if wm_in.state != WMaterial.WM_OK:
|
||||
raise ValidationError('非合格品不可使用')
|
||||
if mlog.route != mtask.route:
|
||||
raise ValidationError('工序不匹配')
|
||||
route = mlog.route
|
||||
|
|
|
@ -120,9 +120,7 @@ def do_out(mio: MIO):
|
|||
# 领到车间库存(或工段)
|
||||
wm, new_create = WMaterial.objects.get_or_create(batch=xbatch, material=xmaterial,
|
||||
belong_dept=belong_dept, mgroup=mgroup,
|
||||
notok_sign=None,
|
||||
material_origin=None,
|
||||
count_xtest=None,
|
||||
state=WMaterial.WM_OK,
|
||||
defaults={
|
||||
"batch": xbatch,
|
||||
"material": xmaterial,
|
||||
|
@ -130,6 +128,7 @@ def do_out(mio: MIO):
|
|||
"create_by": do_user,
|
||||
"belong_dept": belong_dept,
|
||||
"mgroup": mgroup,
|
||||
"state": WMaterial.WM_OK,
|
||||
})
|
||||
if not new_create:
|
||||
wm.count = wm.count + item.count
|
||||
|
@ -165,7 +164,7 @@ def do_in(mio: MIO):
|
|||
for al in action_list:
|
||||
xmaterial, xbatch, xcount = al
|
||||
# 优先从车间库存里拿
|
||||
wm_qs = WMaterial.objects.filter(batch=xbatch, material=xmaterial, belong_dept=belong_dept, mgroup=mgroup, notok_sign=None, material_origin=None, count_xtest=None)
|
||||
wm_qs = WMaterial.objects.filter(batch=xbatch, material=xmaterial, belong_dept=belong_dept, mgroup=mgroup, state=WMaterial.WM_OK)
|
||||
# if not wm_qs.exists():
|
||||
# wm_qs = WMaterial.objects.filter(batch=xbatch, material=xmaterial, belong_dept=belong_dept, mgroup__isnull=False, notok_sign=None, material_origin=None, count_xtest=None)
|
||||
|
||||
|
@ -218,9 +217,9 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
if mi_wm_in:
|
||||
wm_qs = WMaterial.objects.filter(id=mi_wm_in.id)
|
||||
else:
|
||||
wm_qs = WMaterial.objects.filter(batch=mi_batch, material=mi_ma, mgroup=mgroup, notok_sign=None, count_xtest=None, material_origin=None)
|
||||
wm_qs = WMaterial.objects.filter(batch=mi_batch, material=mi_ma, mgroup=mgroup, state=WMaterial.WM_OK)
|
||||
if not wm_qs.exists():
|
||||
wm_qs = WMaterial.objects.filter(batch=mi_batch, material=mi_ma, belong_dept=belong_dept, mgroup=None, notok_sign=None, count_xtest=None, material_origin=None)
|
||||
wm_qs = WMaterial.objects.filter(batch=mi_batch, material=mi_ma, belong_dept=belong_dept, mgroup=None, state=WMaterial.WM_OK)
|
||||
|
||||
count_x = wm_qs.count()
|
||||
if count_x == 1:
|
||||
|
@ -260,7 +259,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
|
||||
for mo in m_outs_list:
|
||||
mo_ma, mo_batch, mo_count, mo_count_eweight, notok_sign = mo
|
||||
lookup = {'batch': mo_batch, 'material': mo_ma, 'mgroup': None, 'notok_sign': notok_sign, 'material_origin': None, 'count_xtest': None}
|
||||
wm_state = WMaterial.WM_OK if notok_sign is None else WMaterial.WM_NOTOK
|
||||
lookup = {'batch': mo_batch, 'material': mo_ma, 'mgroup': None, 'notok_sign': notok_sign, 'state': wm_state}
|
||||
if into_wm_mgroup:
|
||||
lookup['mgroup'] = mgroup
|
||||
stored_mgroup = True
|
||||
|
@ -310,7 +310,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
mi_wm_in.save()
|
||||
else:
|
||||
# 针对光子的情况,实际上必须需要wm_in
|
||||
lookup = {'batch': mi_batch, 'material': mi_ma, 'mgroup': None, 'notok_sign': None, 'material_origin': None, 'count_xtest': None}
|
||||
lookup = {'batch': mi_batch, 'material': mi_ma, 'mgroup': None, 'state': WMaterial.WM_OK}
|
||||
if into_wm_mgroup:
|
||||
# 退回到本工段
|
||||
lookup['mgroup'] = mgroup
|
||||
|
@ -339,7 +339,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
|
||||
for mo in m_outs_list:
|
||||
mo_ma, mo_batch, mo_count, _, notok_sign = mo
|
||||
lookup = {'batch': mo_batch, 'material': mo_ma, 'mgroup': None, 'notok_sign': notok_sign, 'material_origin': None, 'count_xtest': None}
|
||||
wm_state = WMaterial.WM_OK if notok_sign is None else WMaterial.WM_NOTOK
|
||||
lookup = {'batch': mo_batch, 'material': mo_ma, 'mgroup': None, 'notok_sign': notok_sign, 'state': wm_state}
|
||||
if stored_mgroup:
|
||||
lookup['mgroup'] = mgroup
|
||||
else:
|
||||
|
@ -522,19 +523,16 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
batch=batch,
|
||||
material=material,
|
||||
mgroup=handover.recive_mgroup,
|
||||
material_origin=None,
|
||||
notok_sign=None,
|
||||
count_xtest=None,
|
||||
state=WMaterial.WM_OK,
|
||||
defaults={"batch": batch, "material": material, "mgroup": handover.recive_mgroup, "belong_dept": handover.recive_dept},
|
||||
)
|
||||
else:
|
||||
wm_to, _ = WMaterial.objects.get_or_create(
|
||||
batch=batch,
|
||||
material=material,
|
||||
belong_dept=handover.recive_dept,
|
||||
material_origin=None,
|
||||
notok_sign=None,
|
||||
count_xtest=None,
|
||||
belong_dept=handover.recive_dept,
|
||||
mgroup=None,
|
||||
state=WMaterial.WM_OK,
|
||||
defaults={"batch": batch, "material": material, "belong_dept": handover.recive_dept}
|
||||
)
|
||||
elif handover.type == Handover.H_REPAIR:
|
||||
|
@ -545,7 +543,7 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
mgroup=handover.recive_mgroup,
|
||||
notok_sign=handover.wm.notok_sign,
|
||||
material_origin=handover.material,
|
||||
count_xtest=None,
|
||||
state=WMaterial.WM_REPAIR,
|
||||
defaults={
|
||||
"batch": batch,
|
||||
"material": handover.material_changed,
|
||||
|
@ -553,6 +551,7 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
"notok_sign": handover.wm.notok_sign,
|
||||
"material_origin": handover.material,
|
||||
"belong_dept": handover.recive_dept,
|
||||
"state": WMaterial.WM_REPAIR
|
||||
},
|
||||
)
|
||||
else:
|
||||
|
@ -563,23 +562,23 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
batch=batch,
|
||||
material=material,
|
||||
mgroup=handover.recive_mgroup,
|
||||
material_origin=None,
|
||||
notok_sign=None,
|
||||
state=WMaterial.WM_TEST,
|
||||
defaults={
|
||||
"batch": batch,
|
||||
"material": material,
|
||||
"mgroup": handover.recive_mgroup,
|
||||
"belong_dept": handover.recive_dept,
|
||||
"count_xtest": 0},
|
||||
"count_xtest": 0,
|
||||
"state": WMaterial.WM_TEST},
|
||||
)
|
||||
else:
|
||||
wm_to, _ = WMaterial.objects.get_or_create(
|
||||
batch=batch,
|
||||
material=material,
|
||||
belong_dept=handover.recive_dept,
|
||||
material_origin=None,
|
||||
notok_sign=None,
|
||||
defaults={"batch": batch, "material": material, "belong_dept": handover.recive_dept, "count_xtest": 0},
|
||||
mgroup=None,
|
||||
state=WMaterial.WM_TEST,
|
||||
defaults={"batch": batch, "material": material, "belong_dept": handover.recive_dept, "count_xtest": 0, "state": WMaterial.WM_TEST},
|
||||
)
|
||||
else:
|
||||
raise ParseError("不支持交接类型")
|
||||
|
|
Loading…
Reference in New Issue