0968153b by 周伟奇

fix bug

1 parent 2b705da4
import copy
import re
LONG_NAME = 'long_name'
TIME_NUM = 600000000
PAGE_DEFAULT = 1
......
......@@ -6,6 +6,16 @@ from . import consts
class DocHandler:
@staticmethod
def get_name(info, key, length):
if not isinstance(info, dict):
return ''
src_name = info.get(key, '')
if len(src_name) < length:
return src_name
else:
return consts.LONG_NAME
@staticmethod
def get_link(doc_id, business_type, file='pdf'):
if file == 'pdf':
return '/data/{1}/{2}/{0}/{0}.pdf'.format(doc_id, business_type, consts.TMP_DIR_NAME)
......
......@@ -21,9 +21,9 @@ class BSWorkbook(Workbook):
self.code_header = ('页数', '电子回单验证码')
self.date_header = ('打印时间', '起始日期', '终止日期', '流水区间结果')
self.keyword_header = ('关键词', '记账日期', '金额')
self.interest_keyword = interest_keyword
self.salary_keyword = salary_keyword
self.loan_keyword = loan_keyword
self.interest_keyword = self.replace_newline(interest_keyword)
self.salary_keyword = self.replace_newline(salary_keyword)
self.loan_keyword = self.replace_newline(loan_keyword)
self.wechat_keyword = wechat_keyword
self.proof_res = ('对', '错')
self.loan_fill = PatternFill("solid", fgColor="00FFCC00")
......@@ -33,6 +33,13 @@ class BSWorkbook(Workbook):
self.MAX_MEAN = 31
@staticmethod
def replace_newline(queryset_value):
new_set = set()
for v in queryset_value:
new_set.add(v.replace('\\n', '\n'))
return new_set
@staticmethod
def get_header_col(header_value, classify):
if header_value is None:
return
......
......@@ -30,10 +30,14 @@ def load_data(request, schema):
application_data_args = {'applicationId': fields.Str(required=True, validate=validate.Length(max=64))}
applicant_data_args = {
'mainApplicantName': fields.Str(required=True, validate=validate.Length(max=16)),
'coApplicantName': fields.Str(required=True, validate=validate.Length(max=16)),
'guarantor1Name': fields.Str(required=True, validate=validate.Length(max=16)),
'guarantor2Name': fields.Str(required=True, validate=validate.Length(max=16)),
# 'mainApplicantName': fields.Str(required=True, validate=validate.Length(max=16)),
# 'coApplicantName': fields.Str(required=True, validate=validate.Length(max=16)),
# 'guarantor1Name': fields.Str(required=True, validate=validate.Length(max=16)),
# 'guarantor2Name': fields.Str(required=True, validate=validate.Length(max=16)),
'mainApplicantName': fields.Str(required=True),
'coApplicantName': fields.Str(required=True),
'guarantor1Name': fields.Str(required=True),
'guarantor2Name': fields.Str(required=True),
}
document_args = {
......@@ -108,15 +112,19 @@ class UploadDocView(GenericView, DocHandler):
document_scheme = document.get('documentScheme')
data_source = document.get('dataSource')
document_name = document.get('documentName')
main_name = self.get_name(applicant_data, 'mainApplicantName', 16)
co_name = self.get_name(applicant_data, 'coApplicantName', 16)
g1_name = self.get_name(applicant_data, 'guarantor1Name', 16)
g2_name = self.get_name(applicant_data, 'guarantor2Name', 16)
try:
# 1. 上传信息记录
UploadDocRecords.objects.create(
metadata_version_id=document.get('metadataVersionId'),
application_id=application_id,
main_applicant=applicant_data.get('mainApplicantName'),
co_applicant=applicant_data.get('coApplicantName'),
guarantor_1=applicant_data.get('guarantor1Name'),
guarantor_2=applicant_data.get('guarantor2Name'),
main_applicant=main_name,
co_applicant=co_name,
guarantor_1=g1_name,
guarantor_2=g2_name,
document_name=document_name,
document_scheme=document_scheme,
business_type=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!