Compare commits
	
		
			2 Commits
		
	
	
		
			a0c3443d9e
			...
			839fc2af82
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 839fc2af82 | |
|  | cecffbdb78 | 
|  | @ -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() | ||||
| 
 | ||||
|  |  | |||
|  | @ -348,7 +348,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 +376,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) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue