优化结案流程

This commit is contained in:
27942
2026-02-01 14:36:21 +08:00
parent f187a4939a
commit dcbf5bb829

View File

@@ -2772,8 +2772,8 @@ class ApprovalStatusCheck(APIView):
is_finance_view = True
approval.state = "已通过"
approval.save(update_fields=['state'])
# 投标/立项/案件变更:当前为「待查看」且当前用户是申请人时,调用本接口即视为申请人已查看,消除待查看状态
elif type in ("投标登记", "立项登记", "案件变更") and approval.state == "待查看" and getattr(approval, 'applicant', None) and approval.personincharge == approval.applicant and current_user.username == approval.applicant:
# 投标/立项/案件变更/结案申请:当前为「待查看」且当前用户是申请人时,调用本接口即视为申请人已查看,消除待查看状态
elif type in ("投标登记", "立项登记", "案件变更", "结案申请") and approval.state == "待查看" and getattr(approval, 'applicant', None) and approval.personincharge == approval.applicant and current_user.username == approval.applicant:
is_applicant_view = True
approval.state = "已通过"
update_fields = ['state', 'content']
@@ -2938,6 +2938,37 @@ class ApprovalStatusCheck(APIView):
is_approved = (schedule.state == "已完成")
except Schedule.DoesNotExist:
pass
elif type == "结案申请":
# 结案申请类型:使用 Schedule 作为承载对象
from business.models import Schedule, Case
try:
schedule = Schedule.objects.get(id=approval.user_id, is_deleted=False)
business_state = schedule.state
is_approved = (schedule.state == "已完成" or approval.state == "已通过")
# 申请人通过本接口查看后,消除待查看并更新业务记录为已完成,同时更新 Case.Closingapplication
if is_applicant_view:
if schedule.state != "已完成":
schedule.state = "已完成"
schedule.save(update_fields=['state'])
business_state = "已完成"
is_approved = True
# 更新 Case.Closingapplication 字段
try:
import json
remark_data = json.loads(schedule.remark) if schedule.remark else {}
case_id = remark_data.get('case_id')
closing_files = remark_data.get('closing_application_files', [])
if case_id and closing_files:
case = Case.objects.filter(id=case_id, is_deleted=False).first()
if case:
case.Closingapplication = json.dumps(closing_files, ensure_ascii=False)
case.save(update_fields=['Closingapplication'])
except Exception as e:
import logging
logger = logging.getLogger(__name__)
logger.error(f"结案申请待查看确认后更新 Case.Closingapplication 失败: {str(e)}")
except Schedule.DoesNotExist:
pass
# 可以根据需要添加其他类型
except Exception as e:
import logging