优化自动建案逻辑

This commit is contained in:
27942
2026-01-31 11:21:46 +08:00
parent ce2e460a93
commit 3aa416f756
2 changed files with 12 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
from django.urls import path
from .models import Schedule
from .views import registration,registrationDetail,Project,Projectquerytype,ProjectDetail,EditProject,BidRegistration,BidDetail,registrationList,caseManagement,caseManagementDetail,CaseAttachmentUpload,CaseAttachmentUpdate,Uploadinvoice,InvoiceDetail,Log,LogDetail,accumulate,preFilingLinkedCases,Application,ApplicationDetail,WarehousingRegistration,WarehousingDetail,PlatformRegistration,PlatformDetail,EditPlatformDetail,DeletePlatformDetail,bulletin,BulletinDetail,EditBulletin,deleteBulletin,Lawyersdocuments,LawyersdocumentsDetail,LwaDetail,CreateSchedule,DeleteSchedule,ScheduleDetail,handleSchedule,AddRermission,DisplayRermission,DeleteRermission,EditRermission,addRole,DeleteRole,EditRole,displayRole,modifypermissions,getRolePermissions,DeleteRegistration,EditRegistration,DeleteProject,EditBid,DeleteBid,EditCase,DeleteCase,EditApplication,DeleteApplication,EditWarehousing,DeleteWarehousing,EditLawyerFlie,EditSchedule,TransferCase,CaseChangeRequestCreate,CaseChangeRequestList,CaseChangeRequestDetail,ProjectDropdownList,CaseDropdownList,ConflictSearch,CreateCaseTag,CaseTagList,CaseTagDetail,EditCaseTag,DeleteCaseTag,CaseTagDropdownList,CaseListByTag,SetCaseTags,PropagandaEit
from .views import registration,registrationDetail,Project,Projectquerytype,ProjectDetail,EditProject,BidRegistration,BidDetail,registrationList,caseManagement,caseManagementDetail,CaseAttachmentUpload,CaseAttachmentUpdate,Uploadinvoice,InvoiceDetail,accumulate,preFilingLinkedCases,Application,ApplicationDetail,WarehousingRegistration,WarehousingDetail,PlatformRegistration,PlatformDetail,EditPlatformDetail,DeletePlatformDetail,bulletin,BulletinDetail,EditBulletin,deleteBulletin,Lawyersdocuments,LawyersdocumentsDetail,LwaDetail,CreateSchedule,DeleteSchedule,ScheduleDetail,handleSchedule,AddRermission,DisplayRermission,DeleteRermission,EditRermission,addRole,DeleteRole,EditRole,displayRole,modifypermissions,getRolePermissions,DeleteRegistration,EditRegistration,DeleteProject,EditBid,DeleteBid,EditCase,DeleteCase,EditApplication,DeleteApplication,EditWarehousing,DeleteWarehousing,EditLawyerFlie,EditSchedule,TransferCase,CaseChangeRequestCreate,CaseChangeRequestList,CaseChangeRequestDetail,ProjectDropdownList,CaseDropdownList,ConflictSearch,CreateCaseTag,CaseTagList,CaseTagDetail,EditCaseTag,DeleteCaseTag,CaseTagDropdownList,CaseListByTag,SetCaseTags,PropagandaEit
urlpatterns = [
path('register',registration.as_view(),name='register'),
@@ -27,8 +27,6 @@ urlpatterns = [
path('deleteCase',DeleteCase.as_view(),name='deleteCase'),
path('uploadinvoice',Uploadinvoice.as_view(),name='uploadinvoice'),
path('invoicedetail',InvoiceDetail.as_view(),name='invoicedetail'),
path('log',Log.as_view(),name='log'),
path('logdetail',LogDetail.as_view(),name='logdetail'),
path('accumulate',accumulate.as_view(),name='accumulate'),
path('preFilingLinkedCases',preFilingLinkedCases.as_view(),name='preFilingLinkedCases'),
path('application',Application.as_view(),name='application'),

View File

@@ -1366,7 +1366,7 @@ class caseManagement(APIView):
def post(self, request, *args, **kwargs):
"""
补充案件资料(立项审批通过即成案件,本接口用于创建/补充案件材料)
- 立项审批通过后,用本接口补充代理合同、合同返还、结案申请等资料。
- 立项审批通过后,用本接口补充合同返还、结案申请等资料。
- 首次调用(该立项尚无案件):创建案件,立案时间 = 立项审批通过时间(无则用请求 times 或当前日期)。
- 再次调用(该立项已有案件):仅更新/补充材料,不修改立案时间。
:param request:
@@ -1376,7 +1376,6 @@ class caseManagement(APIView):
"""
project_id = request.data.get('project_id') # 立项登记ID
times = request.data.get('times') # 立案时间(仅当无审批通过时间时使用)
AgencyContract = request.FILES.getlist('AgencyContract')
Contractreturn = request.FILES.getlist('Contractreturn')
Closingapplication = request.FILES.getlist('Closingapplication')
invoice_status = request.data.get('invoice_status') # 已开票
@@ -1409,8 +1408,7 @@ class caseManagement(APIView):
else:
filing_time = times if times else datetime.now().strftime('%Y-%m-%d')
# 处理材料上传后存储URL列表
agency_contract_list = flies(AgencyContract)
# 处理材料上传后存储URL列表(代理合同字段已从案件管理移除,创建时存空)
contract_return_list = flies(Contractreturn)
closing_application_list = flies(Closingapplication)
@@ -1432,7 +1430,7 @@ class caseManagement(APIView):
responsiblefor=project_responsiblefor,
charge=project_charge,
times=filing_time,
AgencyContract=json.dumps(agency_contract_list, ensure_ascii=False),
AgencyContract=json.dumps([], ensure_ascii=False), # 代理合同已从案件管理移除,库字段保留
Contractreturn=json.dumps(contract_return_list, ensure_ascii=False),
Closingapplication=json.dumps(closing_application_list, ensure_ascii=False),
ChangeRequest="",
@@ -1497,16 +1495,12 @@ class caseManagement(APIView):
return Response({'status': 'error', 'message': '案件不存在', 'code': 1},
status=status.HTTP_400_BAD_REQUEST)
# 执行更新逻辑
# 执行更新逻辑(代理合同已从案件管理移除,不再接收或更新)
update_fields_list = []
if times:
case.times = times
update_fields_list.append('times')
if AgencyContract:
case.AgencyContract = json.dumps(flies(AgencyContract), ensure_ascii=False)
update_fields_list.append('AgencyContract')
if Contractreturn:
case.Contractreturn = json.dumps(flies(Contractreturn), ensure_ascii=False)
update_fields_list.append('Contractreturn')
@@ -1532,13 +1526,13 @@ class caseManagement(APIView):
class CaseAttachmentUpload(APIView):
def post(self, request, *args, **kwargs):
"""
案件材料上传(代理合同/合同返还/结案申请)
案件材料上传(合同返还/结案申请)
通过 type 指定上传类型返回文件URL列表
"""
upload_type = request.data.get('type')
files = request.FILES.getlist('file') or request.FILES.getlist('files')
allowed_types = ["AgencyContract", "Contractreturn", "Closingapplication"]
allowed_types = ["Contractreturn", "Closingapplication"]
if upload_type not in allowed_types:
return Response({
'status': 'error',
@@ -1564,7 +1558,7 @@ class CaseAttachmentUpload(APIView):
class CaseAttachmentUpdate(APIView):
def post(self, request, *args, **kwargs):
"""
案件材料更新(代理合同/合同返还/结案申请)
案件材料更新(合同返还/结案申请)
通过 type 指定更新哪一种材料
"""
case_id = request.data.get('case_id')
@@ -1578,7 +1572,7 @@ class CaseAttachmentUpdate(APIView):
return Response({'status': 'error', 'message': '缺少参数case_id', 'code': 1},
status=status.HTTP_400_BAD_REQUEST)
allowed_types = ["AgencyContract", "Contractreturn", "Closingapplication"]
allowed_types = ["Contractreturn", "Closingapplication"]
if upload_type not in allowed_types:
return Response({
'status': 'error',
@@ -1599,10 +1593,7 @@ class CaseAttachmentUpdate(APIView):
file_urls = flies(files)
update_fields = []
if upload_type == "AgencyContract":
case.AgencyContract = json.dumps(file_urls, ensure_ascii=False)
update_fields = ['AgencyContract']
elif upload_type == "Contractreturn":
if upload_type == "Contractreturn":
case.Contractreturn = json.dumps(file_urls, ensure_ascii=False)
update_fields = ['Contractreturn']
elif upload_type == "Closingapplication":
@@ -1806,28 +1797,15 @@ class caseManagementDetail(APIView):
except (json.JSONDecodeError, TypeError):
responsiblefor_dict = responsiblefor_raw if responsiblefor_raw else {}
# 解析代理合同和结案申请JSON字符串转列表
try:
agency_contract_list = json.loads(info.AgencyContract) if info.AgencyContract else []
except (json.JSONDecodeError, TypeError):
agency_contract_list = []
# 解析结案申请JSON字符串转列表;代理合同已从案件管理移除,不再返回
try:
closing_application_list = json.loads(info.Closingapplication) if info.Closingapplication else []
except (json.JSONDecodeError, TypeError):
closing_application_list = []
# 如果没有文件,返回空字符串而不是空数组
if not agency_contract_list:
agency_contract_list = ""
if not closing_application_list:
closing_application_list = ""
# 将 AgencyContract、Contractreturn 和 Closingapplication 字段的空数组转换为空字符串
agency_contract_str = info.AgencyContract or ""
if agency_contract_str.strip() in ["[]", ""]:
agency_contract_str = ""
contractreturn_str = info.Contractreturn or ""
if contractreturn_str.strip() in ["[]", ""]:
contractreturn_str = ""
@@ -1850,19 +1828,6 @@ class caseManagementDetail(APIView):
invoice_status_value = normalize_amount_value(info.invoice_status)
paymentcollection_value = normalize_amount_value(info.paymentcollection)
# 将 AgencyContract、Contractreturn 和 Closingapplication 字段的空数组转换为空字符串
agency_contract_str = info.AgencyContract or ""
if agency_contract_str.strip() in ["[]", ""]:
agency_contract_str = ""
contractreturn_str = info.Contractreturn or ""
if contractreturn_str.strip() in ["[]", ""]:
contractreturn_str = ""
closing_application_str = info.Closingapplication or ""
if closing_application_str.strip() in ["[]", ""]:
closing_application_str = ""
# 获取案件标签
tags = info.tags.filter(is_deleted=False)
tag_list = []
@@ -1894,8 +1859,6 @@ class caseManagementDetail(APIView):
"responsiblefor": responsiblefor_value, # 负责人信息(字典格式,没有数据时返回空字符串)
"charge": charge or "", # 收费情况(没有数据时返回空字符串)
'times': info.times or "", # 立案时间(没有数据时返回空字符串)
"AgencyContract": agency_contract_str, # 代理合同JSON字符串没有文件时返回空字符串
"AgencyContractUrls": agency_contract_list if agency_contract_list else "", # 代理合同URL列表没有文件时返回空字符串
"Contractreturn": contractreturn_str, # 合同返还(没有数据时返回空字符串)
"Closingapplication": closing_application_str, # 结案申请JSON字符串没有文件时返回空字符串
"ClosingapplicationUrls": closing_application_list if closing_application_list else "", # 结案申请URL列表没有文件时返回空字符串
@@ -1925,7 +1888,6 @@ class EditCase(APIView):
"""
id = request.data.get('id')
times = request.data.get('times')
AgencyContract = request.FILES.getlist('AgencyContract')
Contractreturn = request.FILES.getlist('Contractreturn')
Closingapplication = request.FILES.getlist('Closingapplication')
invoice_status = request.data.get('invoice_status') # 已开票
@@ -1962,10 +1924,6 @@ class EditCase(APIView):
case.times = times
update_fields_list.append('times')
if AgencyContract:
case.AgencyContract = json.dumps(flies(AgencyContract), ensure_ascii=False)
update_fields_list.append('AgencyContract')
if Contractreturn:
case.Contractreturn = json.dumps(flies(Contractreturn), ensure_ascii=False)
update_fields_list.append('Contractreturn')
@@ -4925,28 +4883,15 @@ class CaseListByTag(APIView):
except (json.JSONDecodeError, TypeError):
responsiblefor_dict = responsiblefor_raw if responsiblefor_raw else {}
# 解析代理合同和结案申请
try:
agency_contract_list = json.loads(info.AgencyContract) if info.AgencyContract else []
except (json.JSONDecodeError, TypeError):
agency_contract_list = []
# 解析结案申请;代理合同已从案件管理移除,不再返回
try:
closing_application_list = json.loads(info.Closingapplication) if info.Closingapplication else []
except (json.JSONDecodeError, TypeError):
closing_application_list = []
# 如果没有文件,返回空字符串而不是空数组
if not agency_contract_list:
agency_contract_list = ""
if not closing_application_list:
closing_application_list = ""
# 将 AgencyContract、Contractreturn 和 Closingapplication 字段的空数组转换为空字符串
agency_contract_str = info.AgencyContract or ""
if agency_contract_str.strip() in ["[]", ""]:
agency_contract_str = ""
contractreturn_str = info.Contractreturn or ""
if contractreturn_str.strip() in ["[]", ""]:
contractreturn_str = ""
@@ -4979,8 +4924,6 @@ class CaseListByTag(APIView):
"responsiblefor": responsiblefor_dict,
"charge": charge,
'times': info.times,
"AgencyContract": agency_contract_str, # 代理合同JSON字符串没有文件时返回空字符串
"AgencyContractUrls": agency_contract_list if agency_contract_list else "", # 代理合同URL列表没有文件时返回空字符串
"Contractreturn": contractreturn_str, # 合同返还(没有数据时返回空字符串)
"Closingapplication": closing_application_str, # 结案申请JSON字符串没有文件时返回空字符串
"ClosingapplicationUrls": closing_application_list if closing_application_list else "", # 结案申请URL列表没有文件时返回空字符串