beebba6a by 周伟奇

se compare part 1

1 parent 3f50c8c2
...@@ -23,7 +23,20 @@ from apps.doc.ocr.edms import EDMS, rh ...@@ -23,7 +23,20 @@ from apps.doc.ocr.edms import EDMS, rh
23 from apps.doc.named_enum import KeywordsType, FailureReason, WorkflowName, ProcessName, RequestTeam, RequestTrigger 23 from apps.doc.named_enum import KeywordsType, FailureReason, WorkflowName, ProcessName, RequestTeam, RequestTrigger
24 from apps.doc.exceptions import EDMSException, OCR1Exception, OCR2Exception, OCR4Exception 24 from apps.doc.exceptions import EDMSException, OCR1Exception, OCR2Exception, OCR4Exception
25 from apps.doc.ocr.wb import BSWorkbook 25 from apps.doc.ocr.wb import BSWorkbook
26 from apps.doc.models import DocStatus, HILDoc, AFCDoc, Keywords, HILOCRResult, AFCOCRResult, HILOCRReport, AFCOCRReport, DDARecords, IDBCRecords 26 from apps.doc.models import (
27 DocStatus,
28 HILDoc,
29 AFCDoc,
30 Keywords,
31 HILOCRResult,
32 AFCOCRResult,
33 AFCSEOCRResult,
34 HILOCRReport,
35 HILSEOCRResult,
36 AFCOCRReport,
37 DDARecords,
38 IDBCRecords
39 )
27 from celery_compare.tasks import compare 40 from celery_compare.tasks import compare
28 41
29 42
...@@ -967,15 +980,21 @@ class Command(BaseCommand, LoggerMixin): ...@@ -967,15 +980,21 @@ class Command(BaseCommand, LoggerMixin):
967 # TODO 识别结果存一张表,方便跑报表 980 # TODO 识别结果存一张表,方便跑报表
968 981
969 # CA比对 982 # CA比对
970 if doc.document_scheme == consts.DOC_SCHEME_LIST[0]: 983 if len(license_summary) > 0 and doc.document_scheme != consts.DOC_SCHEME_LIST[2]:
971 try: 984 try:
985 is_ca = True if doc.document_scheme == consts.DOC_SCHEME_LIST[0] else False
972 # 更新OCR累计识别结果表 986 # 更新OCR累计识别结果表
973 result_class = HILOCRResult if business_type == consts.HIL_PREFIX else AFCOCRResult 987 if business_type == consts.HIL_PREFIX:
988 result_class = HILOCRResult if is_ca else HILSEOCRResult
989 else:
990 result_class = AFCOCRResult if is_ca else AFCSEOCRResult
974 res_obj = result_class.objects.filter(application_id=doc.application_id).first() 991 res_obj = result_class.objects.filter(application_id=doc.application_id).first()
975 if res_obj is None: 992 if res_obj is None:
976 res_obj = result_class() 993 res_obj = result_class()
977 res_obj.application_id = doc.application_id 994 res_obj.application_id = doc.application_id
978 for classify, field in consts.RESULT_MAPPING.items(): 995 for classify, field in consts.RESULT_MAPPING.items():
996 if not hasattr(res_obj, field):
997 continue
979 license_list = license_summary.get(classify) 998 license_list = license_summary.get(classify)
980 if not license_list: 999 if not license_list:
981 continue 1000 continue
...@@ -985,8 +1004,6 @@ class Command(BaseCommand, LoggerMixin): ...@@ -985,8 +1004,6 @@ class Command(BaseCommand, LoggerMixin):
985 elif classify == consts.RP_CLASSIFY and rp_merge: 1004 elif classify == consts.RP_CLASSIFY and rp_merge:
986 license_list[0].update(license_list[1]) 1005 license_list[0].update(license_list[1])
987 license_list.pop(1) 1006 license_list.pop(1)
988 if not hasattr(res_obj, field):
989 continue
990 old_res_str = getattr(res_obj, field) 1007 old_res_str = getattr(res_obj, field)
991 if old_res_str is None: 1008 if old_res_str is None:
992 last_res_str = json.dumps(license_list) 1009 last_res_str = json.dumps(license_list)
...@@ -1006,8 +1023,8 @@ class Command(BaseCommand, LoggerMixin): ...@@ -1006,8 +1023,8 @@ class Command(BaseCommand, LoggerMixin):
1006 # 触发比对 1023 # 触发比对
1007 try: 1024 try:
1008 # pass 1025 # pass
1009 compare.apply_async((doc.application_id, business_type, None, res_obj.id), 1026 compare.apply_async((doc.application_id, business_type, None, res_obj.id,
1010 queue='queue_compare') 1027 is_ca), queue='queue_compare')
1011 except Exception as e: 1028 except Exception as e:
1012 self.online_log.error( 1029 self.online_log.error(
1013 '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format( 1030 '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format(
......
...@@ -268,6 +268,59 @@ class HILOCRResult(models.Model): ...@@ -268,6 +268,59 @@ class HILOCRResult(models.Model):
268 db_table = 'hil_ocr_result' 268 db_table = 'hil_ocr_result'
269 269
270 270
271 # OCR结果累计表
272 class AFCSEOCRResult(models.Model):
273 id = models.AutoField(primary_key=True, verbose_name="id") # 主键
274 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
275
276 bs_ocr = models.TextField(null=True, verbose_name="银行流水")
277 mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票")
278 ic_ocr = models.TextField(null=True, verbose_name="身份证")
279 rp_ocr = models.TextField(null=True, verbose_name="居住证")
280 bc_ocr = models.TextField(null=True, verbose_name="银行卡")
281 bl_ocr = models.TextField(null=True, verbose_name="营业执照")
282 uci_ocr = models.TextField(null=True, verbose_name="二手车发票")
283 eep_ocr = models.TextField(null=True, verbose_name="港澳台通行证")
284 dl_ocr = models.TextField(null=True, verbose_name="行驶证")
285 pp_ocr = models.TextField(null=True, verbose_name="护照")
286 mvc_ocr = models.TextField(null=True, verbose_name="机动车登记证")
287 vat_ocr = models.TextField(null=True, verbose_name="增值税发票")
288
289 update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
290 create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
291
292 class Meta:
293 managed = False
294 db_table = 'afc_se_ocr_result'
295 situ_db_label = 'afc'
296
297
298 # OCR结果累计表
299 class HILSEOCRResult(models.Model):
300 id = models.AutoField(primary_key=True, verbose_name="id") # 主键
301 application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
302
303 bs_ocr = models.TextField(null=True, verbose_name="银行流水")
304 mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票")
305 ic_ocr = models.TextField(null=True, verbose_name="身份证")
306 rp_ocr = models.TextField(null=True, verbose_name="居住证")
307 bc_ocr = models.TextField(null=True, verbose_name="银行卡")
308 bl_ocr = models.TextField(null=True, verbose_name="营业执照")
309 uci_ocr = models.TextField(null=True, verbose_name="二手车发票")
310 eep_ocr = models.TextField(null=True, verbose_name="港澳台通行证")
311 dl_ocr = models.TextField(null=True, verbose_name="行驶证")
312 pp_ocr = models.TextField(null=True, verbose_name="护照")
313 mvc_ocr = models.TextField(null=True, verbose_name="机动车登记证")
314 vat_ocr = models.TextField(null=True, verbose_name="增值税发票")
315
316 update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
317 create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
318
319 class Meta:
320 managed = False
321 db_table = 'hil_se_ocr_result'
322
323
271 # OCR Report 324 # OCR Report
272 class HILOCRReport(models.Model): 325 class HILOCRReport(models.Model):
273 id = models.AutoField(primary_key=True, verbose_name="id") # 主键 326 id = models.AutoField(primary_key=True, verbose_name="id") # 主键
......
...@@ -474,7 +474,8 @@ class CompareView(GenericView): ...@@ -474,7 +474,8 @@ class CompareView(GenericView):
474 corporate_cus_info=corporate_cus_info, 474 corporate_cus_info=corporate_cus_info,
475 ) 475 )
476 # 触发比对 476 # 触发比对
477 compare.apply_async((application_id, business_type, uniq_seq, None), queue='queue_compare') 477 compare.apply_async((application_id, business_type, uniq_seq, None, True),
478 queue='queue_compare')
478 return response.ok() 479 return response.ok()
479 480
480 post.openapi_doc = ''' 481 post.openapi_doc = '''
......
...@@ -150,7 +150,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s ...@@ -150,7 +150,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s
150 150
151 151
152 @app.task 152 @app.task
153 def compare(application_id, application_entity, uniq_seq, ocr_res_id): 153 def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True):
154 # POS: application_id, application_entity, uniq_seq, None 154 # POS: application_id, application_entity, uniq_seq, None
155 # OCR: application_id, business_type(application_entity), None, ocr_res_id 155 # OCR: application_id, business_type(application_entity), None, ocr_res_id
156 156
......
1 import pyodbc
2
3
4 hil_sql = """
5 create table hil_se_ocr_result
6 (
7 id int identity primary key,
8 application_id nvarchar(64) not null,
9 bs_ocr nvarchar(max),
10 mvi_ocr nvarchar(max),
11 ic_ocr nvarchar(max),
12 rp_ocr nvarchar(max),
13 bc_ocr nvarchar(max),
14 bl_ocr nvarchar(max),
15 uci_ocr nvarchar(max),
16 eep_ocr nvarchar(max),
17 dl_ocr nvarchar(max),
18 pp_ocr nvarchar(max),
19 mvc_ocr nvarchar(max),
20 vat_ocr nvarchar(max),
21 update_time datetime not null,
22 create_time datetime not null
23 );
24 create unique index hil_se_ocr_result_application_id_uindex
25 on hil_se_ocr_result (application_id);
26 """
27
28 afc_sql = """
29 create table afc_se_ocr_result
30 (
31 id int identity primary key,
32 application_id nvarchar(64) not null,
33 bs_ocr nvarchar(max),
34 mvi_ocr nvarchar(max),
35 ic_ocr nvarchar(max),
36 rp_ocr nvarchar(max),
37 bc_ocr nvarchar(max),
38 bl_ocr nvarchar(max),
39 uci_ocr nvarchar(max),
40 eep_ocr nvarchar(max),
41 dl_ocr nvarchar(max),
42 pp_ocr nvarchar(max),
43 mvc_ocr nvarchar(max),
44 vat_ocr nvarchar(max),
45 update_time datetime not null,
46 create_time datetime not null
47 );
48 create unique index afc_se_ocr_result_application_id_uindex
49 on afc_se_ocr_result (application_id);
50 """
51
52 hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True)
53 hil_cursor = hil_cnxn.cursor()
54 hil_cursor.execute(hil_sql)
55 hil_cursor.close()
56 hil_cnxn.close()
57
58 afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True)
59 afc_cursor = afc_cnxn.cursor()
60 afc_cursor.execute(afc_sql)
61 afc_cursor.close()
62 afc_cnxn.close()
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!