feat: wpr增加自动编号逻辑2

This commit is contained in:
caoqianming 2025-05-16 16:04:37 +08:00
parent 88a5d55425
commit 05bf1def23
1 changed files with 3 additions and 2 deletions

View File

@ -690,15 +690,16 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
from apps.wpmw.models import Wpr
now = timezone.now()
c_year = now.year
c_year2 = str(c_year)[-2:]
c_month = now.month
m_model = material_out.model
wps_qs = Wpr.objects.filter(material_start=material_out, create_time__year=c_year, create_time__month=c_month).order_by("create_time")
n_count = wps_qs.count() + 1
try:
if gen_count == 1:
return rule.format(c_year=c_year, c_month=c_month, m_model=m_model, n_count=n_count)
return rule.format(c_year=c_year, c_month=c_month, m_model=m_model, n_count=n_count, c_year2=c_year2)
else:
return [rule.format(c_year=c_year, c_month=c_month, m_model=m_model, n_count=n_count+i) for i in range(gen_count)]
return [rule.format(c_year=c_year, c_month=c_month, m_model=m_model, n_count=n_count+i, c_year2=c_year2) for i in range(gen_count)]
except (KeyError, ValueError) as e:
raise ParseError(f"个号生成错误: {e}")