Merge branch 'master' of http://gitea.xxhhcty.xyz:8080/zcdsj/factory
This commit is contained in:
commit
51fb42d597
|
@ -147,7 +147,7 @@ def get_pcoal_heat(year_s: int, month_s: int, day_s: int):
|
|||
myLogger.error(f'获取煤粉热值失败,{e}, {year_s}, {month_s}, {day_s}', exc_info=True)
|
||||
return 25000
|
||||
|
||||
@lock_model_record_d_func(Mlog)
|
||||
# @lock_model_record_d_func(Mlog)
|
||||
def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||
"""
|
||||
生产日志提交后需要执行的操作
|
||||
|
@ -158,8 +158,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
raise ParseError('操作结束时间不能早于操作开始时间')
|
||||
if mlog.count_real == 0:
|
||||
raise ParseError('产出数量不能为0')
|
||||
if mlog.submit_time is not None:
|
||||
return
|
||||
# if mlog.submit_time is not None:
|
||||
# return
|
||||
if now is None:
|
||||
now = timezone.now()
|
||||
if mlog.handle_date is None:
|
||||
|
@ -402,12 +402,12 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
if wprIds:
|
||||
ana_wpr_thread(wprIds, mlog.mgroup)
|
||||
|
||||
@lock_model_record_d_func(Mlog)
|
||||
# @lock_model_record_d_func(Mlog)
|
||||
def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||
"""日志撤回
|
||||
"""
|
||||
if mlog.submit_time is None:
|
||||
return
|
||||
# if mlog.submit_time is None:
|
||||
# return
|
||||
if now is None:
|
||||
now = timezone.now()
|
||||
|
||||
|
|
|
@ -325,9 +325,11 @@ class MlogViewSet(CustomModelViewSet):
|
|||
修改日志
|
||||
"""
|
||||
ins = self.get_object()
|
||||
if ins.submit_time is not None:
|
||||
raise ParseError('该日志已提交!')
|
||||
if ins.ticket and ins.ticket.state != State.STATE_TYPE_START:
|
||||
raise ParseError('该日志在审批中不可修改!')
|
||||
sr = MlogChangeSerializer(instance=ins, data=request.data)
|
||||
sr = MlogChangeSerializer(instance=ins, data=request.data, partial=True)
|
||||
sr.is_valid(raise_exception=True)
|
||||
sr.save()
|
||||
return Response(MlogSerializer(ins).data)
|
||||
|
@ -348,7 +350,13 @@ class MlogViewSet(CustomModelViewSet):
|
|||
raise ParseError('该日志需要审批!')
|
||||
mlog_submit_validate(ins)
|
||||
with transaction.atomic():
|
||||
updated_count = Mlog.objects.filter(id=ins.id, submit_time__isnull=True).update(
|
||||
submit_time=now, submit_user=request.user, update_by=request.user)
|
||||
if updated_count == 1:
|
||||
mlog_submit(ins, self.request.user, now)
|
||||
else:
|
||||
raise ParseError('记录正在处理中,请稍后再试')
|
||||
|
||||
vdata_new = MlogSerializer(ins).data
|
||||
# create_auditlog('submit', ins, vdata_new,
|
||||
# vdata_old, now, self.request.user)
|
||||
|
@ -370,7 +378,13 @@ class MlogViewSet(CustomModelViewSet):
|
|||
raise ParseError('非提交人不可撤销!')
|
||||
now = timezone.now()
|
||||
with transaction.atomic():
|
||||
updated_count = Mlog.objects.filter(id=ins.id, submit_time__isnull=False).update(
|
||||
submit_time=None, update_time=now, submit_user=None, update_by=request.user)
|
||||
if updated_count == 1:
|
||||
mlog_revert(ins, user, now)
|
||||
else:
|
||||
raise ParseError('记录正在处理中,请稍后再试')
|
||||
|
||||
# create_auditlog('revert', ins, {}, {}, now, user,
|
||||
# request.data.get('change_reason', ''))
|
||||
return Response(MlogSerializer(instance=ins).data)
|
||||
|
@ -497,7 +511,7 @@ class HandoverViewSet(CustomModelViewSet):
|
|||
def perform_destroy(self, instance:Handover):
|
||||
user = self.request.user
|
||||
if instance.submit_time is not None:
|
||||
raise ParseError('日志已提交不可变动')
|
||||
raise ParseError('该交接记录已提交不可删除')
|
||||
if instance.send_user != user and instance.recive_user != user and instance.create_by != user:
|
||||
raise ParseError('非交送人和接收人不可删除该记录')
|
||||
ticket:Ticket = instance.ticket
|
||||
|
@ -508,6 +522,8 @@ class HandoverViewSet(CustomModelViewSet):
|
|||
@transaction.atomic
|
||||
def perform_update(self, serializer):
|
||||
ins:Handover = self.get_object()
|
||||
if ins.submit_time is not None:
|
||||
raise ParseError('该交接记录已提交!')
|
||||
ticket:Ticket = ins.ticket
|
||||
if ticket and ticket.state.type != State.STATE_TYPE_START:
|
||||
raise ParseError("该交接记录存在审批,不可修改")
|
||||
|
|
Loading…
Reference in New Issue