fix bug
Showing
4 changed files
with
38 additions
and
11 deletions
... | @@ -6,6 +6,16 @@ from . import consts | ... | @@ -6,6 +6,16 @@ from . import consts |
6 | class DocHandler: | 6 | class DocHandler: |
7 | 7 | ||
8 | @staticmethod | 8 | @staticmethod |
9 | def get_name(info, key, length): | ||
10 | if not isinstance(info, dict): | ||
11 | return '' | ||
12 | src_name = info.get(key, '') | ||
13 | if len(src_name) < length: | ||
14 | return src_name | ||
15 | else: | ||
16 | return consts.LONG_NAME | ||
17 | |||
18 | @staticmethod | ||
9 | def get_link(doc_id, business_type, file='pdf'): | 19 | def get_link(doc_id, business_type, file='pdf'): |
10 | if file == 'pdf': | 20 | if file == 'pdf': |
11 | return '/data/{1}/{2}/{0}/{0}.pdf'.format(doc_id, business_type, consts.TMP_DIR_NAME) | 21 | return '/data/{1}/{2}/{0}/{0}.pdf'.format(doc_id, business_type, consts.TMP_DIR_NAME) | ... | ... |
... | @@ -21,9 +21,9 @@ class BSWorkbook(Workbook): | ... | @@ -21,9 +21,9 @@ class BSWorkbook(Workbook): |
21 | self.code_header = ('页数', '电子回单验证码') | 21 | self.code_header = ('页数', '电子回单验证码') |
22 | self.date_header = ('打印时间', '起始日期', '终止日期', '流水区间结果') | 22 | self.date_header = ('打印时间', '起始日期', '终止日期', '流水区间结果') |
23 | self.keyword_header = ('关键词', '记账日期', '金额') | 23 | self.keyword_header = ('关键词', '记账日期', '金额') |
24 | self.interest_keyword = interest_keyword | 24 | self.interest_keyword = self.replace_newline(interest_keyword) |
25 | self.salary_keyword = salary_keyword | 25 | self.salary_keyword = self.replace_newline(salary_keyword) |
26 | self.loan_keyword = loan_keyword | 26 | self.loan_keyword = self.replace_newline(loan_keyword) |
27 | self.wechat_keyword = wechat_keyword | 27 | self.wechat_keyword = wechat_keyword |
28 | self.proof_res = ('对', '错') | 28 | self.proof_res = ('对', '错') |
29 | self.loan_fill = PatternFill("solid", fgColor="00FFCC00") | 29 | self.loan_fill = PatternFill("solid", fgColor="00FFCC00") |
... | @@ -33,6 +33,13 @@ class BSWorkbook(Workbook): | ... | @@ -33,6 +33,13 @@ class BSWorkbook(Workbook): |
33 | self.MAX_MEAN = 31 | 33 | self.MAX_MEAN = 31 |
34 | 34 | ||
35 | @staticmethod | 35 | @staticmethod |
36 | def replace_newline(queryset_value): | ||
37 | new_set = set() | ||
38 | for v in queryset_value: | ||
39 | new_set.add(v.replace('\\n', '\n')) | ||
40 | return new_set | ||
41 | |||
42 | @staticmethod | ||
36 | def get_header_col(header_value, classify): | 43 | def get_header_col(header_value, classify): |
37 | if header_value is None: | 44 | if header_value is None: |
38 | return | 45 | return | ... | ... |
... | @@ -30,10 +30,14 @@ def load_data(request, schema): | ... | @@ -30,10 +30,14 @@ def load_data(request, schema): |
30 | application_data_args = {'applicationId': fields.Str(required=True, validate=validate.Length(max=64))} | 30 | application_data_args = {'applicationId': fields.Str(required=True, validate=validate.Length(max=64))} |
31 | 31 | ||
32 | applicant_data_args = { | 32 | applicant_data_args = { |
33 | 'mainApplicantName': fields.Str(required=True, validate=validate.Length(max=16)), | 33 | # 'mainApplicantName': fields.Str(required=True, validate=validate.Length(max=16)), |
34 | 'coApplicantName': fields.Str(required=True, validate=validate.Length(max=16)), | 34 | # 'coApplicantName': fields.Str(required=True, validate=validate.Length(max=16)), |
35 | 'guarantor1Name': fields.Str(required=True, validate=validate.Length(max=16)), | 35 | # 'guarantor1Name': fields.Str(required=True, validate=validate.Length(max=16)), |
36 | 'guarantor2Name': fields.Str(required=True, validate=validate.Length(max=16)), | 36 | # 'guarantor2Name': fields.Str(required=True, validate=validate.Length(max=16)), |
37 | 'mainApplicantName': fields.Str(required=True), | ||
38 | 'coApplicantName': fields.Str(required=True), | ||
39 | 'guarantor1Name': fields.Str(required=True), | ||
40 | 'guarantor2Name': fields.Str(required=True), | ||
37 | } | 41 | } |
38 | 42 | ||
39 | document_args = { | 43 | document_args = { |
... | @@ -108,15 +112,19 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -108,15 +112,19 @@ class UploadDocView(GenericView, DocHandler): |
108 | document_scheme = document.get('documentScheme') | 112 | document_scheme = document.get('documentScheme') |
109 | data_source = document.get('dataSource') | 113 | data_source = document.get('dataSource') |
110 | document_name = document.get('documentName') | 114 | document_name = document.get('documentName') |
115 | main_name = self.get_name(applicant_data, 'mainApplicantName', 16) | ||
116 | co_name = self.get_name(applicant_data, 'coApplicantName', 16) | ||
117 | g1_name = self.get_name(applicant_data, 'guarantor1Name', 16) | ||
118 | g2_name = self.get_name(applicant_data, 'guarantor2Name', 16) | ||
111 | try: | 119 | try: |
112 | # 1. 上传信息记录 | 120 | # 1. 上传信息记录 |
113 | UploadDocRecords.objects.create( | 121 | UploadDocRecords.objects.create( |
114 | metadata_version_id=document.get('metadataVersionId'), | 122 | metadata_version_id=document.get('metadataVersionId'), |
115 | application_id=application_id, | 123 | application_id=application_id, |
116 | main_applicant=applicant_data.get('mainApplicantName'), | 124 | main_applicant=main_name, |
117 | co_applicant=applicant_data.get('coApplicantName'), | 125 | co_applicant=co_name, |
118 | guarantor_1=applicant_data.get('guarantor1Name'), | 126 | guarantor_1=g1_name, |
119 | guarantor_2=applicant_data.get('guarantor2Name'), | 127 | guarantor_2=g2_name, |
120 | document_name=document_name, | 128 | document_name=document_name, |
121 | document_scheme=document_scheme, | 129 | document_scheme=document_scheme, |
122 | business_type=business_type, | 130 | business_type=business_type, | ... | ... |
-
Please register or sign in to post a comment