9b2170ec by 周伟奇

prune

1 parent 3ff06858
...@@ -837,7 +837,7 @@ class Command(BaseCommand, LoggerMixin): ...@@ -837,7 +837,7 @@ class Command(BaseCommand, LoggerMixin):
837 # 重构Excel文件 837 # 重构Excel文件
838 # src_excel_path = os.path.join(doc_data_path, 'src.xlsx') 838 # src_excel_path = os.path.join(doc_data_path, 'src.xlsx')
839 # wb.save(src_excel_path) 839 # wb.save(src_excel_path)
840 count_list = wb.rebuild(merged_bs_summary, license_summary, res_list, doc.document_scheme) 840 wb.rebuild(merged_bs_summary, license_summary, res_list, doc.document_scheme)
841 wb.save(excel_path) 841 wb.save(excel_path)
842 842
843 except Exception as e: 843 except Exception as e:
...@@ -878,9 +878,9 @@ class Command(BaseCommand, LoggerMixin): ...@@ -878,9 +878,9 @@ class Command(BaseCommand, LoggerMixin):
878 try: 878 try:
879 doc.end_time = timezone.now() 879 doc.end_time = timezone.now()
880 doc.duration = min((doc.end_time - doc.start_time).seconds, 32760) 880 doc.duration = min((doc.end_time - doc.start_time).seconds, 32760)
881 for field, count in count_list: 881 # for field, count in count_list:
882 if hasattr(doc, field): 882 # if hasattr(doc, field):
883 setattr(doc, field, count) 883 # setattr(doc, field, count)
884 doc.save() 884 doc.save()
885 except Exception as e: 885 except Exception as e:
886 self.online_log.error('{0} [process error (db save)] [task={1}] [error={2}]'.format( 886 self.online_log.error('{0} [process error (db save)] [task={1}] [error={2}]'.format(
......
...@@ -633,12 +633,12 @@ class BSWorkbook(Workbook): ...@@ -633,12 +633,12 @@ class BSWorkbook(Workbook):
633 for sheet in sheets_list: 633 for sheet in sheets_list:
634 self.remove(self.get_sheet_by_name(sheet)) 634 self.remove(self.get_sheet_by_name(sheet))
635 635
636 def license_rebuild(self, license_summary, document_scheme, count_list): 636 def license_rebuild(self, license_summary, document_scheme):
637 for classify, (_, name, field_order, side_diff, scheme_diff, field_str) in consts.LICENSE_ORDER: 637 for classify, (_, name, field_order, side_diff, scheme_diff, _) in consts.LICENSE_ORDER:
638 license_list = license_summary.get(classify) 638 license_list = license_summary.get(classify)
639 if not license_list: 639 if not license_list:
640 continue 640 continue
641 count = 0 641 # count = 0
642 ws = self.create_sheet(name) 642 ws = self.create_sheet(name)
643 if scheme_diff and document_scheme == consts.DOC_SCHEME_LIST[1]: 643 if scheme_diff and document_scheme == consts.DOC_SCHEME_LIST[1]:
644 classify = consts.MVC_CLASSIFY_SE 644 classify = consts.MVC_CLASSIFY_SE
...@@ -653,8 +653,8 @@ class BSWorkbook(Workbook): ...@@ -653,8 +653,8 @@ class BSWorkbook(Workbook):
653 else: 653 else:
654 ws.append((write_field, field_value)) 654 ws.append((write_field, field_value))
655 ws.append((None, )) 655 ws.append((None, ))
656 count += 1 656 # count += 1
657 count_list.append((field_str, count)) 657 # count_list.append((field_str, count))
658 658
659 def simple_license_rebuild(self, license_summary, document_scheme): 659 def simple_license_rebuild(self, license_summary, document_scheme):
660 # for ic_license_dict in license_summary.get(consts.IC_CLASSIFY, []): 660 # for ic_license_dict in license_summary.get(consts.IC_CLASSIFY, []):
...@@ -708,13 +708,13 @@ class BSWorkbook(Workbook): ...@@ -708,13 +708,13 @@ class BSWorkbook(Workbook):
708 self.remove(self.get_sheet_by_name('Sheet')) 708 self.remove(self.get_sheet_by_name('Sheet'))
709 709
710 def rebuild(self, bs_summary, license_summary, res_list, document_scheme): 710 def rebuild(self, bs_summary, license_summary, res_list, document_scheme):
711 count_list = [(consts.MODEL_FIELD_BS, len(self.sheetnames) - 1)] 711 # count_list = [(consts.MODEL_FIELD_BS, len(self.sheetnames) - 1)]
712 if document_scheme == consts.DOC_SCHEME_LIST[1]: 712 if document_scheme == consts.DOC_SCHEME_LIST[1]:
713 self.license_rebuild(license_summary, document_scheme, count_list) 713 self.license_rebuild(license_summary, document_scheme)
714 self.bs_rebuild(bs_summary) 714 self.bs_rebuild(bs_summary)
715 else: 715 else:
716 self.bs_rebuild(bs_summary) 716 self.bs_rebuild(bs_summary)
717 self.license_rebuild(license_summary, document_scheme, count_list) 717 self.license_rebuild(license_summary, document_scheme)
718 self.res_sheet(res_list) 718 self.res_sheet(res_list)
719 self.remove_base_sheet() 719 self.remove_base_sheet()
720 return count_list 720 # return count_list
......
...@@ -16,7 +16,7 @@ from common import response ...@@ -16,7 +16,7 @@ from common import response
16 from common.mixins import GenericView 16 from common.mixins import GenericView
17 from common.tools.file_tools import file_write 17 from common.tools.file_tools import file_write
18 from common.redis_cache import redis_handler as rh 18 from common.redis_cache import redis_handler as rh
19 from .models import UploadDocRecords, DocStatus, PriorityApplication, GCAPRecords, AFCComparisonInfo, HILComparisonInfo 19 from .models import DocStatus, PriorityApplication, GCAPRecords, AFCComparisonInfo, HILComparisonInfo
20 from .mixins import DocHandler 20 from .mixins import DocHandler
21 from . import consts 21 from . import consts
22 from apps.account.authentication import OAuth2AuthenticationWithUser 22 from apps.account.authentication import OAuth2AuthenticationWithUser
...@@ -288,36 +288,36 @@ class UploadDocView(GenericView, DocHandler): ...@@ -288,36 +288,36 @@ class UploadDocView(GenericView, DocHandler):
288 @use_args(doc_upload_args, location='data') 288 @use_args(doc_upload_args, location='data')
289 def post(self, request, args): 289 def post(self, request, args):
290 application_data = args.get('applicationData') 290 application_data = args.get('applicationData')
291 applicant_data = args.get('applicantData') 291 # applicant_data = args.get('applicantData')
292 document = args.get('document') 292 document = args.get('document')
293 business_type = document.get('businessType') 293 business_type = document.get('businessType')
294 application_id = application_data.get('applicationId') 294 application_id = application_data.get('applicationId')
295 document_scheme = document.get('documentScheme') 295 document_scheme = document.get('documentScheme')
296 data_source = document.get('dataSource') 296 data_source = document.get('dataSource')
297 document_name = document.get('documentName') 297 document_name = document.get('documentName')
298 main_name = self.get_name(applicant_data, 'mainApplicantName', 16) 298 # main_name = self.get_name(applicant_data, 'mainApplicantName', 16)
299 co_name = self.get_name(applicant_data, 'coApplicantName', 16) 299 # co_name = self.get_name(applicant_data, 'coApplicantName', 16)
300 g1_name = self.get_name(applicant_data, 'guarantor1Name', 16) 300 # g1_name = self.get_name(applicant_data, 'guarantor1Name', 16)
301 g2_name = self.get_name(applicant_data, 'guarantor2Name', 16) 301 # g2_name = self.get_name(applicant_data, 'guarantor2Name', 16)
302 try: 302 # try:
303 # 1. 上传信息记录 303 # # 1. 上传信息记录
304 UploadDocRecords.objects.create( 304 # UploadDocRecords.objects.create(
305 metadata_version_id=document.get('metadataVersionId'), 305 # metadata_version_id=document.get('metadataVersionId'),
306 application_id=application_id, 306 # application_id=application_id,
307 main_applicant=main_name, 307 # main_applicant=main_name,
308 co_applicant=co_name, 308 # co_applicant=co_name,
309 guarantor_1=g1_name, 309 # guarantor_1=g1_name,
310 guarantor_2=g2_name, 310 # guarantor_2=g2_name,
311 document_name=document_name, 311 # document_name=document_name,
312 document_scheme=document_scheme, 312 # document_scheme=document_scheme,
313 business_type=business_type, 313 # business_type=business_type,
314 data_source=data_source, 314 # data_source=data_source,
315 upload_finish_time=document.get('uploadFinishTime'), 315 # upload_finish_time=document.get('uploadFinishTime'),
316 ) 316 # )
317 except IntegrityError as e: 317 # except IntegrityError as e:
318 self.running_log.info('[doc upload fail] [args={0}] [err={1}]'.format(args, e)) 318 # self.running_log.info('[doc upload fail] [args={0}] [err={1}]'.format(args, e))
319 self.invalid_params(msg='metadataVersionId repeat') 319 # self.invalid_params(msg='metadataVersionId repeat')
320 else: 320 # else:
321 data_source = self.fix_data_source(data_source) 321 data_source = self.fix_data_source(data_source)
322 if data_source == consts.DATA_SOURCE_LIST[1]: 322 if data_source == consts.DATA_SOURCE_LIST[1]:
323 if isinstance(document_name, str): 323 if isinstance(document_name, str):
...@@ -590,19 +590,19 @@ class DocView(GenericView, DocHandler): ...@@ -590,19 +590,19 @@ class DocView(GenericView, DocHandler):
590 upload_finish_time = timezone.now() 590 upload_finish_time = timezone.now()
591 document_scheme = random.choice(consts.DOC_SCHEME_LIST) 591 document_scheme = random.choice(consts.DOC_SCHEME_LIST)
592 data_source = random.choice(consts.DATA_SOURCE_LIST) 592 data_source = random.choice(consts.DATA_SOURCE_LIST)
593 UploadDocRecords.objects.create( 593 # UploadDocRecords.objects.create(
594 metadata_version_id=metadata_version_id, 594 # metadata_version_id=metadata_version_id,
595 application_id=application_id, 595 # application_id=application_id,
596 main_applicant='', 596 # main_applicant='',
597 co_applicant='', 597 # co_applicant='',
598 guarantor_1='', 598 # guarantor_1='',
599 guarantor_2='', 599 # guarantor_2='',
600 document_name=application_id, 600 # document_name=application_id,
601 document_scheme=document_scheme, 601 # document_scheme=document_scheme,
602 business_type=business_type, 602 # business_type=business_type,
603 data_source=data_source, 603 # data_source=data_source,
604 upload_finish_time=upload_finish_time, 604 # upload_finish_time=upload_finish_time,
605 ) 605 # )
606 606
607 # 2. 根据业务类型分库存储 607 # 2. 根据业务类型分库存储
608 doc_class, prefix = self.get_doc_class(business_type) 608 doc_class, prefix = self.get_doc_class(business_type)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!