3690e26d by 周伟奇

fix hil e-contract

1 parent 01d81417
...@@ -1101,6 +1101,31 @@ class Finder: ...@@ -1101,6 +1101,31 @@ class Finder:
1101 representative['position'] = bbox 1101 representative['position'] = bbox
1102 return name, id_num, representative 1102 return name, id_num, representative
1103 1103
1104 def get_value_by_findall(self, prefix, suffix, page_num):
1105 value = self.item.copy()
1106 all_text = ''
1107 pno = page_num
1108 for block in self.pdf_info[pno]['blocks']:
1109 if block['type'] != 0:
1110 continue
1111 for line in block['lines']:
1112 for span in line['spans']:
1113 bbox, text = span['bbox'], span['text']
1114 all_text += text
1115 words_list = re.findall(f"{prefix}(.*?){suffix}", all_text)
1116 if len(words_list) > 0:
1117 for block in self.pdf_info[pno]['blocks']:
1118 if block['type'] != 0:
1119 continue
1120 for line in block['lines']:
1121 for span in line['spans']:
1122 bbox, text = span['bbox'], span['text']
1123 if words_list[0] in text:
1124 value['position'] = bbox
1125 value['page'] = pno
1126 value['words'] = words_list[0]
1127 return value
1128
1104 def get_info(self): 1129 def get_info(self):
1105 """ 1130 """
1106 block['type'] == 0 : 表示该元素为图片 1131 block['type'] == 0 : 表示该元素为图片
...@@ -1281,6 +1306,8 @@ class Finder: ...@@ -1281,6 +1306,8 @@ class Finder:
1281 self.init_result_1['承租人-证件号码'] = _id 1306 self.init_result_1['承租人-证件号码'] = _id
1282 # 销售经销商 1307 # 销售经销商
1283 seller = self.get_key_value(key='销售经销商:', page_num='0') 1308 seller = self.get_key_value(key='销售经销商:', page_num='0')
1309 if seller['words'] == "":
1310 seller = self.get_value_by_findall('销售经销商:', '地址:', page_num='0')
1284 self.init_result_1['销售经销商'] = seller 1311 self.init_result_1['销售经销商'] = seller
1285 # 合同编号(正文) 1312 # 合同编号(正文)
1286 contract_no = self.get_contract_no_one() 1313 contract_no = self.get_contract_no_one()
...@@ -1296,6 +1323,9 @@ class Finder: ...@@ -1296,6 +1323,9 @@ class Finder:
1296 self.init_result_1['签字页-承租人签章'] = signature_role_1 1323 self.init_result_1['签字页-承租人签章'] = signature_role_1
1297 # 签字页-销售经销商 1324 # 签字页-销售经销商
1298 seller = self.get_key_value(key='销售经销商:') 1325 seller = self.get_key_value(key='销售经销商:')
1326 if seller['words'] == "":
1327 # 销售经销商:深圳市宝创汽车贸易有限公司南山分公司(请授权代表签字并请盖章)
1328 seller = self.get_value_by_findall('销售经销商:', '(请授权代表签字并请盖章)', page_num='3')
1299 self.init_result_1['签字页-销售经销商'] = seller 1329 self.init_result_1['签字页-销售经销商'] = seller
1300 # 经销商签章 1330 # 经销商签章
1301 pass 1331 pass
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!