8c2c2380 by 周伟奇

fix upload bug

1 parent 4de905f7
...@@ -27,16 +27,16 @@ class ECM: ...@@ -27,16 +27,16 @@ class ECM:
27 self.token_type_key = 'token_type' 27 self.token_type_key = 'token_type'
28 self.expires_key = 'expires_in' 28 self.expires_key = 'expires_in'
29 self.doc_type_map = { 29 self.doc_type_map = {
30 'ACCEPTANCE': ('acceptance', conf.ECM_FOLDER_CA), 30 'ACCEPTANCE': ('acceptance', conf.ECM_FOLDER_CA, conf.ECM_FOLDER_CA_HIL),
31 'SETTLEMENT': ('settlement', conf.ECM_FOLDER_SE), 31 'SETTLEMENT': ('settlement', conf.ECM_FOLDER_SE, conf.ECM_FOLDER_SE_HIL),
32 'CONTRACTMANAGEMENT': ('contract_management', conf.ECM_FOLDER_CA), 32 'CONTRACTMANAGEMENT': ('contract_management', conf.ECM_FOLDER_CA, conf.ECM_FOLDER_CA_HIL),
33 } 33 }
34 self.doc_base_map = { 34 self.doc_base_map = {
35 'AFC': 'SF5_CN', 35 'AFC': 'SF5_CN',
36 'HIL': 'SF5_CL', 36 'HIL': 'SF5_CL',
37 } 37 }
38 self.prefix = 'OCR' 38 self.prefix = 'OCR'
39 self.upload_fields = ["b_region", "b_region_name", "r_object_type", "r_content_type", "r_creation_date", 39 self.upload_fields = ["b_region", "b_region_name", "r_object_type", "r_creation_date",
40 "r_creator_name", "r_modify_date", "r_modifier", "owner", "b_short_application_no", 40 "r_creator_name", "r_modify_date", "r_modifier", "owner", "b_short_application_no",
41 "b_short_contract_no", "b_customer_id", "b_customer_name", "b_customer_mobile", 41 "b_short_contract_no", "b_customer_id", "b_customer_name", "b_customer_mobile",
42 "b_coborrower_id", "b_coborrower_name", "b_guarantor_id", "b_guarantor_name", 42 "b_coborrower_id", "b_coborrower_name", "b_guarantor_id", "b_guarantor_name",
...@@ -67,7 +67,7 @@ class ECM: ...@@ -67,7 +67,7 @@ class ECM:
67 return {'Authorization': '{0} {1}'.format(self.token_type, self.get_oauth_token())} 67 return {'Authorization': '{0} {1}'.format(self.token_type, self.get_oauth_token())}
68 68
69 def download(self, save_path, object_id, document_scheme, business_type): 69 def download(self, save_path, object_id, document_scheme, business_type):
70 doc_type, _ = self.doc_type_map.get(document_scheme) 70 doc_type, _, _ = self.doc_type_map.get(document_scheme)
71 download_json = { 71 download_json = {
72 "userName": self.username, 72 "userName": self.username,
73 "password": self.pwd, 73 "password": self.pwd,
...@@ -96,7 +96,8 @@ class ECM: ...@@ -96,7 +96,8 @@ class ECM:
96 return '{0}{1}'.format(self.prefix, doc_name) 96 return '{0}{1}'.format(self.prefix, doc_name)
97 97
98 def upload(self, file_path, doc, business_type): 98 def upload(self, file_path, doc, business_type):
99 doc_type, folder = self.doc_type_map.get(doc.document_scheme) 99 doc_type, folder_afc, folder_hil = self.doc_type_map.get(doc.document_scheme)
100 folder = folder_afc if business_type == 'AFC' else folder_hil
100 args = { 101 args = {
101 "username": self.username, 102 "username": self.username,
102 "password": self.pwd, 103 "password": self.pwd,
...@@ -104,9 +105,10 @@ class ECM: ...@@ -104,9 +105,10 @@ class ECM:
104 "documentType": doc_type, 105 "documentType": doc_type,
105 "object_name": self.get_doc_file_name(doc.document_name), 106 "object_name": self.get_doc_file_name(doc.document_name),
106 "folder": folder, 107 "folder": folder,
107 "format": "xlsx", 108 "format": "excel12book",
109 "r_content_type": "excel12book",
108 "b_application_no": doc.application_id, 110 "b_application_no": doc.application_id,
109 "file_base64_content": "", 111 # "file_base64_content": "",
110 } 112 }
111 for key in self.upload_fields: 113 for key in self.upload_fields:
112 args[key] = '' 114 args[key] = ''
...@@ -117,6 +119,7 @@ class ECM: ...@@ -117,6 +119,7 @@ class ECM:
117 args['file_base64_content'] = file_data 119 args['file_base64_content'] = file_data
118 response = requests.post(self.upload_url, headers=self.get_headers(), json=args, verify=False) 120 response = requests.post(self.upload_url, headers=self.get_headers(), json=args, verify=False)
119 if response.status_code != 200: 121 if response.status_code != 200:
120 raise ECMException('ECM upload failed with code: {0}'.format(response.status_code)) 122 raise ECMException('ECM upload failed with code: {0} , with headers: {1}'.format(
123 response.status_code, response.headers))
121 if 'ns6:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}): 124 if 'ns6:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}):
122 raise ECMException('ECM upload failed: {0}'.format(response.json())) 125 raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers))
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!