fix merge
Showing
9 changed files
with
1241 additions
and
78 deletions
| ... | @@ -6,4 +6,5 @@ urlpatterns = [ | ... | @@ -6,4 +6,5 @@ urlpatterns = [ |
| 6 | path(r'v1', views.CompareView.as_view()), | 6 | path(r'v1', views.CompareView.as_view()), |
| 7 | path(r'settlement/v1', views.SECompareView.as_view()), | 7 | path(r'settlement/v1', views.SECompareView.as_view()), |
| 8 | path(r'offline/v1', views.CompareOfflineView.as_view()), | 8 | path(r'offline/v1', views.CompareOfflineView.as_view()), |
| 9 | path(r'result', views.CompareResultView.as_view()), | ||
| 9 | ] | 10 | ] | ... | ... |
| ... | @@ -12,6 +12,7 @@ FIXED_APPLICATION_ID_PREFIX = 'CH-S' | ... | @@ -12,6 +12,7 @@ FIXED_APPLICATION_ID_PREFIX = 'CH-S' |
| 12 | 12 | ||
| 13 | DOC_SCHEME_LIST = ['ACCEPTANCE', 'SETTLEMENT', 'CONTRACTMANAGEMENT'] | 13 | DOC_SCHEME_LIST = ['ACCEPTANCE', 'SETTLEMENT', 'CONTRACTMANAGEMENT'] |
| 14 | DATA_SOURCE_LIST = ['POS', 'EAPP', 'ECONTRACT'] | 14 | DATA_SOURCE_LIST = ['POS', 'EAPP', 'ECONTRACT'] |
| 15 | COMPARE_DOC_SCHEME_LIST = ['CA', 'SE'] | ||
| 15 | 16 | ||
| 16 | HIL_PREFIX = 'HIL' | 17 | HIL_PREFIX = 'HIL' |
| 17 | AFC_PREFIX = 'AFC' | 18 | AFC_PREFIX = 'AFC' |
| ... | @@ -1055,13 +1056,13 @@ IC_RES_MAPPING = { | ... | @@ -1055,13 +1056,13 @@ IC_RES_MAPPING = { |
| 1055 | 1: '真实证件', | 1056 | 1: '真实证件', |
| 1056 | } | 1057 | } |
| 1057 | 1058 | ||
| 1058 | # ----------------- compare --------------------- | 1059 | # ----------------- CA compare --------------------- |
| 1059 | ENTITY = ['HIL', 'AFC'] | 1060 | ENTITY = ['HIL', 'AFC'] |
| 1060 | CUSTOMER_TYPE = ['TCCOR', 'TCDAS', 'TCFRE', 'TCIAS', 'TCIND', 'TCSEP', 'TCURE'] | 1061 | CUSTOMER_TYPE = ['TCCOR', 'TCDAS', 'TCFRE', 'TCIAS', 'TCIND', 'TCSEP', 'TCURE'] |
| 1061 | NO_COMPARE_CUSTOMER_TYPE = ['TCFRE', 'TCIND'] | 1062 | NO_COMPARE_CUSTOMER_TYPE = ['TCFRE', 'TCIND'] |
| 1062 | VEHICLE_STATUS = ['PCUSD', 'PCNEW'] | 1063 | VEHICLE_STATUS = ['PCUSD', 'PCNEW'] |
| 1063 | 1064 | ||
| 1064 | APPLICANT_TYPE = ['COAPP', 'CUSTR', 'GAUTR1', 'GAUTR2'] | 1065 | APPLICANT_TYPE = ['CUSTR', 'COAPP', 'GAUTR1', 'GAUTR2'] |
| 1065 | ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID', 'ITUSC', 'ITCCU'] | 1066 | ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID', 'ITUSC', 'ITCCU'] |
| 1066 | SECOND_ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID'] | 1067 | SECOND_ID_TYPE = ['ITARI', 'ITHKM', 'ITPRC', 'ITPSP', 'ITRES', 'ITTID'] |
| 1067 | SUB_TYPE = ['CSIBM', 'CSOTH', 'CSSME'] | 1068 | SUB_TYPE = ['CSIBM', 'CSOTH', 'CSSME'] |
| ... | @@ -1087,22 +1088,38 @@ EEP_OCR_FIELD = 'eep_ocr' | ... | @@ -1087,22 +1088,38 @@ EEP_OCR_FIELD = 'eep_ocr' |
| 1087 | DL_OCR_FIELD = 'dl_ocr' | 1088 | DL_OCR_FIELD = 'dl_ocr' |
| 1088 | PP_OCR_FIELD = 'pp_ocr' | 1089 | PP_OCR_FIELD = 'pp_ocr' |
| 1089 | MVC_OCR_FIELD = 'mvc_ocr' | 1090 | MVC_OCR_FIELD = 'mvc_ocr' |
| 1091 | MVI_OCR_FIELD = 'mvi_ocr' | ||
| 1092 | BC_OCR_FIELD = 'bc_ocr' | ||
| 1093 | UCI_OCR_FIELD = 'uci_ocr' | ||
| 1094 | DDA_OCR_FIELD = 'bs_ocr' | ||
| 1090 | 1095 | ||
| 1091 | RESULT_MAPPING = { | 1096 | RESULT_MAPPING = { |
| 1092 | # MVI_CLASSIFY: 'mvi_ocr', | 1097 | MVI_CLASSIFY: MVI_OCR_FIELD, |
| 1093 | IC_CLASSIFY: IC_OCR_FIELD, | 1098 | IC_CLASSIFY: IC_OCR_FIELD, |
| 1094 | RP_CLASSIFY: RP_OCR_FIELD, | 1099 | RP_CLASSIFY: RP_OCR_FIELD, |
| 1095 | # BC_CLASSIFY: 'bc_ocr', | 1100 | BC_CLASSIFY: BC_OCR_FIELD, |
| 1096 | BL_CLASSIFY: BL_OCR_FIELD, | 1101 | BL_CLASSIFY: BL_OCR_FIELD, |
| 1097 | # UCI_CLASSIFY: 'uci_ocr', | 1102 | UCI_CLASSIFY: UCI_OCR_FIELD, |
| 1098 | EEP_CLASSIFY: EEP_OCR_FIELD, | 1103 | EEP_CLASSIFY: EEP_OCR_FIELD, |
| 1099 | DL_CLASSIFY: DL_OCR_FIELD, | 1104 | DL_CLASSIFY: DL_OCR_FIELD, |
| 1100 | PP_CLASSIFY: PP_OCR_FIELD, | 1105 | PP_CLASSIFY: PP_OCR_FIELD, |
| 1101 | MVC_CLASSIFY: MVC_OCR_FIELD, | 1106 | MVC_CLASSIFY: MVC_OCR_FIELD, |
| 1107 | DDA_CLASSIFY: DDA_OCR_FIELD, | ||
| 1102 | # VAT_CLASSIFY: 'vat_ocr', | 1108 | # VAT_CLASSIFY: 'vat_ocr', |
| 1103 | } | 1109 | } |
| 1104 | 1110 | ||
| 1105 | COMPARE_FIELDS = (IC_OCR_FIELD, RP_OCR_FIELD, BL_OCR_FIELD, EEP_OCR_FIELD, DL_OCR_FIELD, PP_OCR_FIELD, MVC_OCR_FIELD) | 1111 | COMPARE_FIELDS = (MVI_OCR_FIELD, |
| 1112 | IC_OCR_FIELD, | ||
| 1113 | RP_OCR_FIELD, | ||
| 1114 | BC_OCR_FIELD, | ||
| 1115 | BL_OCR_FIELD, | ||
| 1116 | UCI_OCR_FIELD, | ||
| 1117 | EEP_OCR_FIELD, | ||
| 1118 | DL_OCR_FIELD, | ||
| 1119 | PP_OCR_FIELD, | ||
| 1120 | MVC_OCR_FIELD, | ||
| 1121 | DDA_OCR_FIELD, | ||
| 1122 | ) | ||
| 1106 | 1123 | ||
| 1107 | # 身份证 | 1124 | # 身份证 |
| 1108 | ITPRC = [ | 1125 | ITPRC = [ |
| ... | @@ -1253,5 +1270,167 @@ DDA_MAPPING = [ | ... | @@ -1253,5 +1270,167 @@ DDA_MAPPING = [ |
| 1253 | 1270 | ||
| 1254 | DDA_PRO_MIN = 0.6 | 1271 | DDA_PRO_MIN = 0.6 |
| 1255 | 1272 | ||
| 1273 | # ----------------------- SE compare ----------------------- | ||
| 1274 | SE_FIRST_ID_FIELD = ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate'] | ||
| 1275 | SE_ID_CARD_FIELD = ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate', 'hukouProvince', 'hukouCity'] | ||
| 1276 | SE_SECOND_ID_FIELD = [ | ||
| 1277 | ('customerName', 'customerName'), | ||
| 1278 | ('secondIdNum', 'idNum'), | ||
| 1279 | ] | ||
| 1280 | SE_CORPORATE_ID_FIELD = [ | ||
| 1281 | ('legalRepName', 'customerName'), | ||
| 1282 | ('firstIdNo', 'idNum') | ||
| 1283 | ] | ||
| 1284 | SE_SEP_FIELD = [ | ||
| 1285 | ('companyName', 'companyName'), | ||
| 1286 | ('customerName', 'legalRepName'), | ||
| 1287 | ('registeredCapital', 'registeredCapital'), | ||
| 1288 | ('selfEmployedSubType', 'organizationType') | ||
| 1289 | ] | ||
| 1290 | SE_CORPORATE_FIELD = ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', | ||
| 1291 | 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] | ||
| 1292 | SE_CORPORATE_ALL_FIELD = ['companyName', 'legalRepName', 'firstIdNo', 'businessLicenseNo', 'organizationCreditCode', | ||
| 1293 | 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] | ||
| 1294 | SE_NEW_FIELD = ['vinNo', 'dealer', 'vehicleTransactionAmount'] | ||
| 1295 | SE_USED_FIELD = ['vinNo', 'vehicleTransactionAmount'] | ||
| 1296 | SE_NEW_ADD_FIELD = ['customerName', 'idNum', 'dateOfInvoice'] | ||
| 1297 | SE_GB_NEW_FIELD = ['vinNo'] | ||
| 1298 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] | ||
| 1299 | |||
| 1300 | SE_BANK_FIELD = ['accountNo', 'bankName'] | ||
| 1301 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | ||
| 1302 | |||
| 1303 | HIL_COMPANY_NAME = '先锋国际融资租赁有限公司' | ||
| 1304 | AFC_COMPANY_NAME = '宝马汽车金融(中国)有限公司' | ||
| 1305 | |||
| 1306 | ID_EN = 'PRC ID' | ||
| 1307 | PP_EN = 'Passport' | ||
| 1308 | EEP_EN = 'Resident Permit to Mainland' | ||
| 1309 | RP_EN = 'Resident ID' | ||
| 1310 | BL_EN = 'Business permit' | ||
| 1311 | MVI_EN = 'newCar Invoice' | ||
| 1312 | UCI_EN = 'usedCar Invoice' | ||
| 1313 | MVC_EN = 'Green Book' | ||
| 1314 | BC_EN = 'Bank Card' | ||
| 1315 | DDA_EN = 'DDA' | ||
| 1316 | |||
| 1317 | ID_COMPARE_LOGIC = { | ||
| 1318 | 'customerName': ('姓名', 'se_name_compare', {}), | ||
| 1319 | 'idNum': ('公民身份号码', 'se_common_compare', {}), | ||
| 1320 | 'dateOfBirth': ('出生年月', 'se_date_compare', {'input_replace': ''}), | ||
| 1321 | 'idExpiryDate': ('有效期限', 'se_date_compare', {'long': True, 'ocr_split': True, 'input_replace': ''}), | ||
| 1322 | 'hukouProvince': ('住址', 'se_contain_compare', {}), | ||
| 1323 | 'hukouCity': ('住址', 'se_contain_compare', {}), | ||
| 1324 | } | ||
| 1325 | |||
| 1326 | PP_COMPARE_LOGIC = { | ||
| 1327 | 'customerName': ('英文姓名', 'se_name_compare', {'is_passport': True}), | ||
| 1328 | 'idNum': ('护照号码', 'se_common_compare', {}), | ||
| 1329 | 'dateOfBirth': ('出生日期', 'se_date_compare', {'input_replace': ''}), | ||
| 1330 | 'idExpiryDate': ('有效期至', 'se_date_compare', {'input_replace': ''}), | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | EEP_COMPARE_LOGIC = { | ||
| 1334 | 'customerName': ('中文名', 'se_common_compare', {}), | ||
| 1335 | 'idNum': ('证件号码', 'se_common_compare', {}), | ||
| 1336 | 'dateOfBirth': ('出生日期', 'se_date_compare', {'input_replace': '.'}), | ||
| 1337 | 'idExpiryDate': ('有效期限', 'se_date_compare', {'ocr_split': True, 'input_replace': '.'}), | ||
| 1338 | } | ||
| 1339 | |||
| 1340 | RP_COMPARE_LOGIC = { | ||
| 1341 | 'customerName': ('姓名', 'se_name_compare', {}), | ||
| 1342 | 'idNum': ('公民身份号码', 'se_common_compare', {}), | ||
| 1343 | 'dateOfBirth': ('出生年月', 'se_date_compare', {'input_replace': ''}), | ||
| 1344 | 'idExpiryDate': ('有效期限', 'se_date_compare', {'ocr_split': True, 'input_replace': ''}), | ||
| 1345 | 'hukouProvince': ('住址', 'se_contain_compare', {}), | ||
| 1346 | 'hukouCity': ('住址', 'se_contain_compare', {}), | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | BL_COMPARE_LOGIC = { | ||
| 1350 | 'companyName': ('企业名称', 'se_company_compare', {}), | ||
| 1351 | 'legalRepName': ('经营者姓名', 'se_name_compare', {}), | ||
| 1352 | 'firstIdNo': ('注册号', 'se_common_compare', {}), | ||
| 1353 | 'businessLicenseNo': ('注册号', 'se_common_compare', {}), | ||
| 1354 | 'organizationCreditCode': ('注册号', 'se_common_compare', {}), | ||
| 1355 | 'taxRegistrationCertificateNo': ('注册号', 'se_common_compare', {}), | ||
| 1356 | 'establishmentDate': ('成立日期', 'se_date_compare', {'ocr_replace': True}), | ||
| 1357 | 'businessLicenseDueDate': ('营业期限', 'se_date_compare', {'ocr_split': True, 'long': True, 'ocr_replace': True}), | ||
| 1358 | 'organizationType': ('企业类型', 'se_type_compare', {}), | ||
| 1359 | 'registeredCapital': ('注册资本', 'se_rmb_compare', {}), | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | MVI_COMPARE_LOGIC = { | ||
| 1363 | 'vinNo': ('车辆识别代码', 'se_common_compare', {}), | ||
| 1364 | 'dealer': ('销方名称', 'se_common_compare', {}), | ||
| 1365 | 'vehicleTransactionAmount': ('价税合计小写', 'se_amount_compare', {}), | ||
| 1366 | 'customerName': ('购方名称', 'se_name_compare', {}), | ||
| 1367 | 'idNum': ('购买方身份证号或组织机构代码', 'se_common_compare', {}), | ||
| 1368 | 'dateOfInvoice': ('开票日期', 'se_date_compare', {}), | ||
| 1369 | } | ||
| 1370 | |||
| 1371 | UCI_COMPARE_LOGIC = { | ||
| 1372 | 'vinNo': ('车架号', 'se_common_compare', {}), | ||
| 1373 | 'vehicleTransactionAmount': ('价税合计小写', 'se_amount_compare', {}), | ||
| 1374 | 'customerName': ('购方名称', 'se_name_compare', {}), | ||
| 1375 | 'idNum': ('购方纳税人识别号', 'se_common_compare', {}), | ||
| 1376 | } | ||
| 1377 | |||
| 1378 | MVC_COMPARE_LOGIC = { | ||
| 1379 | 'vinNo': ('9.车辆识别代号/车架号', 'se_common_compare', {}), | ||
| 1380 | # 'customerName': ('姓名/名称', ), | ||
| 1381 | # 'idNum': ('身份证明名称/号码', ), | ||
| 1382 | # 'date': ('转移登记日期', ), | ||
| 1383 | } | ||
| 1384 | |||
| 1385 | BC_COMPARE_LOGIC = { | ||
| 1386 | 'accountNo': ('CardNum', 'se_common_compare', {}), | ||
| 1387 | 'bankName': ('BankName', 'se_common_compare', {}), | ||
| 1388 | } | ||
| 1389 | |||
| 1390 | DDA_COMPARE_LOGIC = { | ||
| 1391 | 'applicationId(1)': ('check_Num', ), | ||
| 1392 | 'applicationId(2)': ('check_Num', ), | ||
| 1393 | 'bankName': ('to_bank', ), | ||
| 1394 | 'companyName': ('to_company', ), | ||
| 1395 | 'customerName': (DDA_IC_NAME, ), | ||
| 1396 | 'idNum': (DDA_IC_ID, ), | ||
| 1397 | 'accountHolderName': (DDA_BC_NAME, ), | ||
| 1398 | 'accountNo': (DDA_BC_ID, ), | ||
| 1399 | } | ||
| 1400 | |||
| 1401 | |||
| 1402 | # MVC_OCR_FIELD = 'mvc_ocr' | ||
| 1403 | |||
| 1404 | SE_COMPARE_FIELD = { | ||
| 1405 | ID_EN: (IC_OCR_FIELD, ID_COMPARE_LOGIC, True), | ||
| 1406 | PP_EN: (PP_OCR_FIELD, PP_COMPARE_LOGIC, False), | ||
| 1407 | EEP_EN: (EEP_OCR_FIELD, EEP_COMPARE_LOGIC, False), | ||
| 1408 | RP_EN: (RP_OCR_FIELD, RP_COMPARE_LOGIC, True), | ||
| 1409 | BL_EN: (BL_OCR_FIELD, BL_COMPARE_LOGIC, False), | ||
| 1410 | MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, False), | ||
| 1411 | UCI_EN: (UCI_OCR_FIELD, UCI_COMPARE_LOGIC, False), | ||
| 1412 | MVC_EN: (MVC_OCR_FIELD, MVC_COMPARE_LOGIC, False), | ||
| 1413 | BC_EN: (BC_OCR_FIELD, BC_COMPARE_LOGIC, False), | ||
| 1414 | DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False), | ||
| 1415 | } | ||
| 1416 | |||
| 1417 | |||
| 1418 | SE_FIRST_ID_FIELD_MAPPING = { | ||
| 1419 | 'ITPRC': (ID_EN, SE_ID_CARD_FIELD), | ||
| 1420 | 'ITPSP': (PP_EN, SE_FIRST_ID_FIELD), | ||
| 1421 | 'ITHKM': (EEP_EN, SE_FIRST_ID_FIELD), | ||
| 1422 | 'ITTID': (EEP_EN, SE_FIRST_ID_FIELD), | ||
| 1423 | 'ITRES': (RP_EN, SE_FIRST_ID_FIELD), | ||
| 1424 | } | ||
| 1425 | |||
| 1426 | SE_SECOND_ID_FIELD_MAPPING = { | ||
| 1427 | 'ITPRC': (ID_EN, SE_SECOND_ID_FIELD), | ||
| 1428 | 'ITPSP': (PP_EN, SE_SECOND_ID_FIELD), | ||
| 1429 | 'ITHKM': (EEP_EN, SE_SECOND_ID_FIELD), | ||
| 1430 | 'ITTID': (EEP_EN, SE_SECOND_ID_FIELD), | ||
| 1431 | 'ITRES': (RP_EN, SE_SECOND_ID_FIELD), | ||
| 1432 | } | ||
| 1433 | |||
| 1434 | HEAD_LIST = ['Info', 'Index', 'License', 'Field', 'Input', 'OCR', 'Result', 'Position', 'Image', 'errorType'] | ||
| 1256 | 1435 | ||
| 1257 | 1436 | ... | ... |
| ... | @@ -23,7 +23,21 @@ from apps.doc.ocr.edms import EDMS, rh | ... | @@ -23,7 +23,21 @@ 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, Configs | 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 | Configs, | ||
| 40 | ) | ||
| 27 | from celery_compare.tasks import compare | 41 | from celery_compare.tasks import compare |
| 28 | 42 | ||
| 29 | 43 | ||
| ... | @@ -990,16 +1004,22 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -990,16 +1004,22 @@ class Command(BaseCommand, LoggerMixin): |
| 990 | finally: | 1004 | finally: |
| 991 | # TODO 识别结果存一张表,方便跑报表 | 1005 | # TODO 识别结果存一张表,方便跑报表 |
| 992 | 1006 | ||
| 993 | # CA比对 | 1007 | # 比对 |
| 994 | if doc.document_scheme == consts.DOC_SCHEME_LIST[0] and len(license_summary) > 0: | 1008 | if len(license_summary) > 0 and doc.document_scheme != consts.DOC_SCHEME_LIST[2]: |
| 995 | try: | 1009 | try: |
| 1010 | is_ca = True if doc.document_scheme == consts.DOC_SCHEME_LIST[0] else False | ||
| 996 | # 更新OCR累计识别结果表 | 1011 | # 更新OCR累计识别结果表 |
| 997 | result_class = HILOCRResult if business_type == consts.HIL_PREFIX else AFCOCRResult | 1012 | if business_type == consts.HIL_PREFIX: |
| 1013 | result_class = HILOCRResult if is_ca else HILSEOCRResult | ||
| 1014 | else: | ||
| 1015 | result_class = AFCOCRResult if is_ca else AFCSEOCRResult | ||
| 998 | res_obj = result_class.objects.filter(application_id=doc.application_id).first() | 1016 | res_obj = result_class.objects.filter(application_id=doc.application_id).first() |
| 999 | if res_obj is None: | 1017 | if res_obj is None: |
| 1000 | res_obj = result_class() | 1018 | res_obj = result_class() |
| 1001 | res_obj.application_id = doc.application_id | 1019 | res_obj.application_id = doc.application_id |
| 1002 | for classify, field in consts.RESULT_MAPPING.items(): | 1020 | for classify, field in consts.RESULT_MAPPING.items(): |
| 1021 | if not hasattr(res_obj, field): | ||
| 1022 | continue | ||
| 1003 | license_list = license_summary.get(classify) | 1023 | license_list = license_summary.get(classify) |
| 1004 | if not license_list: | 1024 | if not license_list: |
| 1005 | continue | 1025 | continue |
| ... | @@ -1009,8 +1029,6 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1009,8 +1029,6 @@ class Command(BaseCommand, LoggerMixin): |
| 1009 | elif classify == consts.RP_CLASSIFY and rp_merge: | 1029 | elif classify == consts.RP_CLASSIFY and rp_merge: |
| 1010 | license_list[0].update(license_list[1]) | 1030 | license_list[0].update(license_list[1]) |
| 1011 | license_list.pop(1) | 1031 | license_list.pop(1) |
| 1012 | if not hasattr(res_obj, field): | ||
| 1013 | continue | ||
| 1014 | old_res_str = getattr(res_obj, field) | 1032 | old_res_str = getattr(res_obj, field) |
| 1015 | if old_res_str is None: | 1033 | if old_res_str is None: |
| 1016 | last_res_str = json.dumps(license_list) | 1034 | last_res_str = json.dumps(license_list) |
| ... | @@ -1030,8 +1048,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1030,8 +1048,8 @@ class Command(BaseCommand, LoggerMixin): |
| 1030 | # 触发比对 | 1048 | # 触发比对 |
| 1031 | try: | 1049 | try: |
| 1032 | # pass | 1050 | # pass |
| 1033 | compare.apply_async((doc.application_id, business_type, None, res_obj.id), | 1051 | compare.apply_async((doc.application_id, business_type, None, res_obj.id, |
| 1034 | queue='queue_compare') | 1052 | is_ca), queue='queue_compare') |
| 1035 | except Exception as e: | 1053 | except Exception as e: |
| 1036 | self.online_log.error( | 1054 | self.online_log.error( |
| 1037 | '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format( | 1055 | '{0} [process error (comparison info send)] [task={1}] [error={2}]'.format( | ... | ... |
| ... | @@ -190,6 +190,58 @@ class AFCComparisonInfo(models.Model): | ... | @@ -190,6 +190,58 @@ class AFCComparisonInfo(models.Model): |
| 190 | db_table = 'afc_comparison_info' | 190 | db_table = 'afc_comparison_info' |
| 191 | situ_db_label = 'afc' | 191 | situ_db_label = 'afc' |
| 192 | 192 | ||
| 193 | # 比对信息表 | ||
| 194 | class AFCSEComparisonInfo(models.Model): | ||
| 195 | id = models.BigAutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 196 | uniq_seq = models.CharField(max_length=128, verbose_name="唯一序列号") # 索引 | ||
| 197 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 198 | application_version = models.SmallIntegerField(default=0, verbose_name="应用版本") | ||
| 199 | # CUSTOMER_TYPE = ['TCCOR', 'TCDAS', 'TCFRE', 'TCIAS', 'TCIND', 'TCSEP', 'TCURE'] | ||
| 200 | customer_type = models.CharField(max_length=16, verbose_name="顾客类型") | ||
| 201 | first_submmison_date = models.CharField(max_length=16, verbose_name="首次提交时间") | ||
| 202 | property_doc_policy = models.CharField(null=True, max_length=16, verbose_name="申请及文件政策") | ||
| 203 | |||
| 204 | individual_cus_info = models.TextField(verbose_name="个人信息") | ||
| 205 | corporate_cus_info = models.TextField(null=True, verbose_name="公司信息") | ||
| 206 | vehicle_info = models.TextField(verbose_name="车辆信息") | ||
| 207 | insurance_info = models.TextField(verbose_name="保险信息") | ||
| 208 | bank_info = models.TextField(verbose_name="银行信息") | ||
| 209 | quotationt_info = models.TextField(verbose_name="报价信息") | ||
| 210 | |||
| 211 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
| 212 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') # 索引 | ||
| 213 | |||
| 214 | class Meta: | ||
| 215 | managed = False | ||
| 216 | db_table = 'afc_se_comparison_info' | ||
| 217 | situ_db_label = 'afc' | ||
| 218 | |||
| 219 | |||
| 220 | # 比对信息表 | ||
| 221 | class HILSEComparisonInfo(models.Model): | ||
| 222 | id = models.BigAutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 223 | uniq_seq = models.CharField(max_length=128, verbose_name="唯一序列号") # 索引 | ||
| 224 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 225 | application_version = models.SmallIntegerField(default=0, verbose_name="应用版本") | ||
| 226 | # CUSTOMER_TYPE = ['TCCOR', 'TCDAS', 'TCFRE', 'TCIAS', 'TCIND', 'TCSEP', 'TCURE'] | ||
| 227 | customer_type = models.CharField(max_length=16, verbose_name="顾客类型") | ||
| 228 | first_submmison_date = models.CharField(max_length=16, verbose_name="首次提交时间") | ||
| 229 | property_doc_policy = models.CharField(null=True, max_length=16, verbose_name="申请及文件政策") | ||
| 230 | |||
| 231 | individual_cus_info = models.TextField(verbose_name="个人信息") | ||
| 232 | corporate_cus_info = models.TextField(null=True, verbose_name="公司信息") | ||
| 233 | vehicle_info = models.TextField(verbose_name="车辆信息") | ||
| 234 | insurance_info = models.TextField(verbose_name="保险信息") | ||
| 235 | bank_info = models.TextField(verbose_name="银行信息") | ||
| 236 | quotationt_info = models.TextField(verbose_name="报价信息") | ||
| 237 | |||
| 238 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
| 239 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') # 索引 | ||
| 240 | |||
| 241 | class Meta: | ||
| 242 | managed = False | ||
| 243 | db_table = 'hil_se_comparison_info' | ||
| 244 | |||
| 193 | 245 | ||
| 194 | # 比对信息表 | 246 | # 比对信息表 |
| 195 | class HILComparisonInfo(models.Model): | 247 | class HILComparisonInfo(models.Model): |
| ... | @@ -220,7 +272,7 @@ class AFCOCRResult(models.Model): | ... | @@ -220,7 +272,7 @@ class AFCOCRResult(models.Model): |
| 220 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 272 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| 221 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | 273 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
| 222 | 274 | ||
| 223 | bs_ocr = models.TextField(null=True, verbose_name="银行流水") | 275 | bs_ocr = models.TextField(null=True, verbose_name="DDA") |
| 224 | mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票") | 276 | mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票") |
| 225 | ic_ocr = models.TextField(null=True, verbose_name="身份证") | 277 | ic_ocr = models.TextField(null=True, verbose_name="身份证") |
| 226 | rp_ocr = models.TextField(null=True, verbose_name="居住证") | 278 | rp_ocr = models.TextField(null=True, verbose_name="居住证") |
| ... | @@ -247,7 +299,7 @@ class HILOCRResult(models.Model): | ... | @@ -247,7 +299,7 @@ class HILOCRResult(models.Model): |
| 247 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 299 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| 248 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | 300 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 |
| 249 | 301 | ||
| 250 | bs_ocr = models.TextField(null=True, verbose_name="银行流水") | 302 | bs_ocr = models.TextField(null=True, verbose_name="DDA") |
| 251 | mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票") | 303 | mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票") |
| 252 | ic_ocr = models.TextField(null=True, verbose_name="身份证") | 304 | ic_ocr = models.TextField(null=True, verbose_name="身份证") |
| 253 | rp_ocr = models.TextField(null=True, verbose_name="居住证") | 305 | rp_ocr = models.TextField(null=True, verbose_name="居住证") |
| ... | @@ -268,6 +320,59 @@ class HILOCRResult(models.Model): | ... | @@ -268,6 +320,59 @@ class HILOCRResult(models.Model): |
| 268 | db_table = 'hil_ocr_result' | 320 | db_table = 'hil_ocr_result' |
| 269 | 321 | ||
| 270 | 322 | ||
| 323 | # OCR结果累计表 | ||
| 324 | class AFCSEOCRResult(models.Model): | ||
| 325 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 326 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 327 | |||
| 328 | bs_ocr = models.TextField(null=True, verbose_name="DDA") | ||
| 329 | mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票") | ||
| 330 | ic_ocr = models.TextField(null=True, verbose_name="身份证") | ||
| 331 | rp_ocr = models.TextField(null=True, verbose_name="居住证") | ||
| 332 | bc_ocr = models.TextField(null=True, verbose_name="银行卡") | ||
| 333 | bl_ocr = models.TextField(null=True, verbose_name="营业执照") | ||
| 334 | uci_ocr = models.TextField(null=True, verbose_name="二手车发票") | ||
| 335 | eep_ocr = models.TextField(null=True, verbose_name="港澳台通行证") | ||
| 336 | dl_ocr = models.TextField(null=True, verbose_name="行驶证") | ||
| 337 | pp_ocr = models.TextField(null=True, verbose_name="护照") | ||
| 338 | mvc_ocr = models.TextField(null=True, verbose_name="机动车登记证") | ||
| 339 | vat_ocr = models.TextField(null=True, verbose_name="增值税发票") | ||
| 340 | |||
| 341 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
| 342 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 343 | |||
| 344 | class Meta: | ||
| 345 | managed = False | ||
| 346 | db_table = 'afc_se_ocr_result' | ||
| 347 | situ_db_label = 'afc' | ||
| 348 | |||
| 349 | |||
| 350 | # OCR结果累计表 | ||
| 351 | class HILSEOCRResult(models.Model): | ||
| 352 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 353 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 354 | |||
| 355 | bs_ocr = models.TextField(null=True, verbose_name="DDA") | ||
| 356 | mvi_ocr = models.TextField(null=True, verbose_name="机动车销售统一发票") | ||
| 357 | ic_ocr = models.TextField(null=True, verbose_name="身份证") | ||
| 358 | rp_ocr = models.TextField(null=True, verbose_name="居住证") | ||
| 359 | bc_ocr = models.TextField(null=True, verbose_name="银行卡") | ||
| 360 | bl_ocr = models.TextField(null=True, verbose_name="营业执照") | ||
| 361 | uci_ocr = models.TextField(null=True, verbose_name="二手车发票") | ||
| 362 | eep_ocr = models.TextField(null=True, verbose_name="港澳台通行证") | ||
| 363 | dl_ocr = models.TextField(null=True, verbose_name="行驶证") | ||
| 364 | pp_ocr = models.TextField(null=True, verbose_name="护照") | ||
| 365 | mvc_ocr = models.TextField(null=True, verbose_name="机动车登记证") | ||
| 366 | vat_ocr = models.TextField(null=True, verbose_name="增值税发票") | ||
| 367 | |||
| 368 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
| 369 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 370 | |||
| 371 | class Meta: | ||
| 372 | managed = False | ||
| 373 | db_table = 'hil_se_ocr_result' | ||
| 374 | |||
| 375 | |||
| 271 | # OCR Report | 376 | # OCR Report |
| 272 | class HILOCRReport(models.Model): | 377 | class HILOCRReport(models.Model): |
| 273 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 378 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| ... | @@ -437,3 +542,105 @@ class IDBCRecords(models.Model): | ... | @@ -437,3 +542,105 @@ class IDBCRecords(models.Model): |
| 437 | db_table = 'idbc_records' | 542 | db_table = 'idbc_records' |
| 438 | 543 | ||
| 439 | 544 | ||
| 545 | class AFCSECompareResult(models.Model): | ||
| 546 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 547 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 548 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | ||
| 549 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 550 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 551 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 552 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 553 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 554 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 555 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 556 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 557 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 558 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 559 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 560 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 561 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 562 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | ||
| 563 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 564 | |||
| 565 | class Meta: | ||
| 566 | managed = False | ||
| 567 | db_table = 'afc_se_compare_result' | ||
| 568 | situ_db_label = 'afc' | ||
| 569 | |||
| 570 | |||
| 571 | class AFCCACompareResult(models.Model): | ||
| 572 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 573 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 574 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | ||
| 575 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 576 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 577 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 578 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 579 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 580 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 581 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 582 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 583 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 584 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 585 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 586 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 587 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 588 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | ||
| 589 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 590 | |||
| 591 | class Meta: | ||
| 592 | managed = False | ||
| 593 | db_table = 'afc_ca_compare_result' | ||
| 594 | situ_db_label = 'afc' | ||
| 595 | |||
| 596 | |||
| 597 | class HILSECompareResult(models.Model): | ||
| 598 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 599 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 600 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | ||
| 601 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 602 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 603 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 604 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 605 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 606 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 607 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 608 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 609 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 610 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 611 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 612 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 613 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 614 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | ||
| 615 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 616 | |||
| 617 | class Meta: | ||
| 618 | managed = False | ||
| 619 | db_table = 'hil_se_compare_result' | ||
| 620 | |||
| 621 | |||
| 622 | class HILCACompareResult(models.Model): | ||
| 623 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 624 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
| 625 | is_finish = models.BooleanField(default=False, verbose_name="是否完成") | ||
| 626 | compare_count = models.SmallIntegerField(default=0, verbose_name="比对字段总数") | ||
| 627 | failed_count = models.SmallIntegerField(default=0, verbose_name="比对失败数目") | ||
| 628 | reason1_count = models.SmallIntegerField(default=0, verbose_name="原因1数目") | ||
| 629 | reason2_count = models.SmallIntegerField(default=0, verbose_name="原因2数目") | ||
| 630 | reason3_count = models.SmallIntegerField(default=0, verbose_name="原因3数目") | ||
| 631 | reason4_count = models.SmallIntegerField(default=0, verbose_name="原因4数目") | ||
| 632 | reason5_count = models.SmallIntegerField(default=0, verbose_name="原因5数目") | ||
| 633 | reason6_count = models.SmallIntegerField(default=0, verbose_name="原因6数目") | ||
| 634 | reason7_count = models.SmallIntegerField(default=0, verbose_name="原因7数目") | ||
| 635 | reason8_count = models.SmallIntegerField(default=0, verbose_name="原因8数目") | ||
| 636 | reason9_count = models.SmallIntegerField(default=0, verbose_name="原因9数目") | ||
| 637 | reason10_count = models.SmallIntegerField(default=0, verbose_name="原因10数目") | ||
| 638 | result = models.TextField(null=True, verbose_name="比对结果") | ||
| 639 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') # 索引 | ||
| 640 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
| 641 | |||
| 642 | class Meta: | ||
| 643 | managed = False | ||
| 644 | db_table = 'hil_ca_compare_result' | ||
| 645 | |||
| 646 | ... | ... |
| ... | @@ -51,6 +51,7 @@ class ProcessName(NamedEnum): | ... | @@ -51,6 +51,7 @@ class ProcessName(NamedEnum): |
| 51 | IDCARD = (2, 'F2_IDReport') | 51 | IDCARD = (2, 'F2_IDReport') |
| 52 | DDA = (3, 'CL_S1_DDAConsolidation') | 52 | DDA = (3, 'CL_S1_DDAConsolidation') |
| 53 | CACOMPARE = (4, 'S1_CA_DocumentVerify') | 53 | CACOMPARE = (4, 'S1_CA_DocumentVerify') |
| 54 | SE_CACOMPARE = (5, 'S1_SE_DocumentVerify') | ||
| 54 | 55 | ||
| 55 | 56 | ||
| 56 | class WorkflowName(NamedEnum): | 57 | class WorkflowName(NamedEnum): | ... | ... |
| ... | @@ -6,7 +6,7 @@ import datetime | ... | @@ -6,7 +6,7 @@ import datetime |
| 6 | import fitz | 6 | import fitz |
| 7 | import shutil | 7 | import shutil |
| 8 | from django.utils import timezone | 8 | from django.utils import timezone |
| 9 | from django.db.utils import IntegrityError | 9 | from django.http import HttpResponse |
| 10 | from django.db.models import Q | 10 | from django.db.models import Q |
| 11 | from rest_framework.permissions import IsAuthenticated | 11 | from rest_framework.permissions import IsAuthenticated |
| 12 | from webargs import fields, validate | 12 | from webargs import fields, validate |
| ... | @@ -16,7 +16,21 @@ from common import response | ... | @@ -16,7 +16,21 @@ from common import response |
| 16 | from common.mixins import GenericView | 16 | from common.mixins import GenericView |
| 17 | from common.tools.file_tools import file_write | 17 | from common.tools.file_tools import file_write |
| 18 | from common.redis_cache import redis_handler as rh | 18 | from common.redis_cache import redis_handler as rh |
| 19 | from .models import DocStatus, PriorityApplication, GCAPRecords, AFCComparisonInfo, HILComparisonInfo, AFCCompareOfflineReport, HILCompareOfflineReport | 19 | from .models import ( |
| 20 | DocStatus, | ||
| 21 | PriorityApplication, | ||
| 22 | GCAPRecords, | ||
| 23 | AFCComparisonInfo, | ||
| 24 | AFCSEComparisonInfo, | ||
| 25 | HILComparisonInfo, | ||
| 26 | HILSEComparisonInfo, | ||
| 27 | AFCCompareOfflineReport, | ||
| 28 | HILCompareOfflineReport, | ||
| 29 | AFCCACompareResult, | ||
| 30 | AFCSECompareResult, | ||
| 31 | HILCACompareResult, | ||
| 32 | HILSECompareResult, | ||
| 33 | ) | ||
| 20 | from .mixins import DocHandler | 34 | from .mixins import DocHandler |
| 21 | from . import consts | 35 | from . import consts |
| 22 | from apps.account.authentication import OAuth2AuthenticationWithUser | 36 | from apps.account.authentication import OAuth2AuthenticationWithUser |
| ... | @@ -257,6 +271,13 @@ doc_list_args = { | ... | @@ -257,6 +271,13 @@ doc_list_args = { |
| 257 | 'create_time_end': fields.Date(required=False), | 271 | 'create_time_end': fields.Date(required=False), |
| 258 | } | 272 | } |
| 259 | 273 | ||
| 274 | compare_result_args = { | ||
| 275 | 'entity': fields.Str(required=True, validate=validate.OneOf(consts.BUSINESS_TYPE_LIST)), | ||
| 276 | 'scheme': fields.Str(required=True, validate=validate.OneOf(consts.COMPARE_DOC_SCHEME_LIST)), | ||
| 277 | 'id': fields.Int(required=False, validate=lambda val: val >= 1), | ||
| 278 | 'case_id': fields.Str(required=True, validate=validate.Length(max=64)), | ||
| 279 | } | ||
| 280 | |||
| 260 | upload_pdf_args = { | 281 | upload_pdf_args = { |
| 261 | 'pdf_file': fields.Raw(required=True), | 282 | 'pdf_file': fields.Raw(required=True), |
| 262 | } | 283 | } |
| ... | @@ -474,7 +495,8 @@ class CompareView(GenericView): | ... | @@ -474,7 +495,8 @@ class CompareView(GenericView): |
| 474 | corporate_cus_info=corporate_cus_info, | 495 | corporate_cus_info=corporate_cus_info, |
| 475 | ) | 496 | ) |
| 476 | # 触发比对 | 497 | # 触发比对 |
| 477 | compare.apply_async((application_id, business_type, uniq_seq, None), queue='queue_compare') | 498 | compare.apply_async((application_id, business_type, uniq_seq, None, True), |
| 499 | queue='queue_compare') | ||
| 478 | return response.ok() | 500 | return response.ok() |
| 479 | 501 | ||
| 480 | post.openapi_doc = ''' | 502 | post.openapi_doc = ''' |
| ... | @@ -504,7 +526,38 @@ class SECompareView(GenericView): | ... | @@ -504,7 +526,38 @@ class SECompareView(GenericView): |
| 504 | # pos上传比对信息接口 SE | 526 | # pos上传比对信息接口 SE |
| 505 | @use_args(se_compare_args, location='data') | 527 | @use_args(se_compare_args, location='data') |
| 506 | def post(self, request, args): | 528 | def post(self, request, args): |
| 507 | self.running_log.info('se compare in') | 529 | # 存库 |
| 530 | content = args.get('content', {}) | ||
| 531 | uniq_seq = content.get('uniqSeq') | ||
| 532 | business_type = content.get('applicationEntity') | ||
| 533 | application_id = content.get('applicationId') | ||
| 534 | |||
| 535 | individual_cus_info = json.dumps(content.get('individualCusInfo')) | ||
| 536 | vehicle_info = json.dumps(content.get('vehicleInfo')) | ||
| 537 | insurance_info = json.dumps(content.get('insuranceInfo')) | ||
| 538 | bank_info = json.dumps(content.get('bankInfo')) | ||
| 539 | quotationt_info = json.dumps(content.get('quotationtInfo')) | ||
| 540 | corporate_cus_info = json.dumps(content.get('corporateCusInfo')) if isinstance( | ||
| 541 | content.get('corporateCusInfo'), dict) else None | ||
| 542 | |||
| 543 | comparison_class = HILSEComparisonInfo if business_type in consts.HIL_SET else AFCSEComparisonInfo | ||
| 544 | comparison_class.objects.create( | ||
| 545 | uniq_seq=uniq_seq, | ||
| 546 | application_id=application_id, | ||
| 547 | application_version=content.get('applicationVersion'), | ||
| 548 | customer_type=content.get('customerType'), | ||
| 549 | first_submmison_date=content.get('firstSubmmisonDate'), | ||
| 550 | property_doc_policy=content.get('propertyDocumentPolicy', None), | ||
| 551 | individual_cus_info=individual_cus_info, | ||
| 552 | corporate_cus_info=corporate_cus_info, | ||
| 553 | vehicle_info=vehicle_info, | ||
| 554 | insurance_info=insurance_info, | ||
| 555 | bank_info=bank_info, | ||
| 556 | quotationt_info=quotationt_info | ||
| 557 | ) | ||
| 558 | # 触发比对 | ||
| 559 | compare.apply_async((application_id, business_type, uniq_seq, None, False), | ||
| 560 | queue='queue_compare') | ||
| 508 | return response.ok() | 561 | return response.ok() |
| 509 | 562 | ||
| 510 | post.openapi_doc = ''' | 563 | post.openapi_doc = ''' |
| ... | @@ -695,3 +748,59 @@ class DocView(GenericView, DocHandler): | ... | @@ -695,3 +748,59 @@ class DocView(GenericView, DocHandler): |
| 695 | is_priority, enqueue_res)) | 748 | is_priority, enqueue_res)) |
| 696 | data = {'excel_path': os.path.join(save_dir_path, '{0}.xlsx'.format(doc.id))} | 749 | data = {'excel_path': os.path.join(save_dir_path, '{0}.xlsx'.format(doc.id))} |
| 697 | return response.ok(data=data) | 750 | return response.ok(data=data) |
| 751 | |||
| 752 | |||
| 753 | class CompareResultView(GenericView): | ||
| 754 | |||
| 755 | # 获取比对结果 | ||
| 756 | @use_args(compare_result_args, location='querystring') | ||
| 757 | def get(self, request, args): | ||
| 758 | result_id = args.get('id', None) | ||
| 759 | entity = args.get('entity') | ||
| 760 | scheme = args.get('scheme') | ||
| 761 | case_id = args.get('case_id') | ||
| 762 | |||
| 763 | if entity == consts.HIL_PREFIX: | ||
| 764 | result_table = HILCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else HILSECompareResult | ||
| 765 | else: | ||
| 766 | result_table = AFCCACompareResult if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else AFCSECompareResult | ||
| 767 | |||
| 768 | if result_id is None: | ||
| 769 | result_str_list = result_table.objects.filter(id=result_id).values_list('result', flat=True) | ||
| 770 | else: | ||
| 771 | result_str_list = result_table.objects.filter(application_id=case_id).values_list('result', flat=True) | ||
| 772 | |||
| 773 | if len(result_str_list) == 0: | ||
| 774 | compare_result_list = [] | ||
| 775 | else: | ||
| 776 | compare_result_list = json.loads(result_str_list[0]) | ||
| 777 | |||
| 778 | if len(compare_result_list) == 0: | ||
| 779 | body_html = "<h1>没有比对结果</h1>" | ||
| 780 | else: | ||
| 781 | head_content = ''.join(['<th>{0}</th>'.format(head_name) for head_name in consts.HEAD_LIST]) | ||
| 782 | head_html = '<tr>{0}</tr>'.format(head_content) | ||
| 783 | row_html_list = [] | ||
| 784 | for row_dict in compare_result_list: | ||
| 785 | row_list = [row_dict.get(head, '') for head in consts.HEAD_LIST] | ||
| 786 | row_content = ''.join(['<td>{0}</td>'.format(row_str) for row_str in row_list]) | ||
| 787 | row_html = '<tr>{0}</tr>'.format(row_content) | ||
| 788 | row_html_list.append(row_html) | ||
| 789 | content_html = ''.join(row_html_list) | ||
| 790 | body_html = '<table border="1">{0}{1}</table>'.format(head_html, content_html) | ||
| 791 | |||
| 792 | html = """ | ||
| 793 | <!DOCTYPE html> | ||
| 794 | <html> | ||
| 795 | <head> | ||
| 796 | <meta charset="utf-8"> | ||
| 797 | <title>比对结果</title> | ||
| 798 | </head> | ||
| 799 | <body> | ||
| 800 | {0} | ||
| 801 | </body> | ||
| 802 | </html> | ||
| 803 | """.format(body_html) | ||
| 804 | return HttpResponse(html) | ||
| 805 | |||
| 806 | # return response.ok(data=compare_result) | ... | ... |
| ... | @@ -5,7 +5,21 @@ import traceback | ... | @@ -5,7 +5,21 @@ import traceback |
| 5 | from datetime import datetime, timedelta | 5 | from datetime import datetime, timedelta |
| 6 | from collections import OrderedDict | 6 | from collections import OrderedDict |
| 7 | from . import app | 7 | from . import app |
| 8 | from apps.doc.models import AFCOCRResult, HILOCRResult, AFCComparisonInfo, HILComparisonInfo, Configs, HILCompareReport, AFCCompareReport | 8 | from apps.doc.models import ( |
| 9 | AFCOCRResult, | ||
| 10 | AFCSEOCRResult, | ||
| 11 | HILOCRResult, | ||
| 12 | HILSEOCRResult, | ||
| 13 | AFCComparisonInfo, | ||
| 14 | AFCSEComparisonInfo, | ||
| 15 | HILComparisonInfo, | ||
| 16 | HILSEComparisonInfo, | ||
| 17 | Configs, | ||
| 18 | HILCompareReport, | ||
| 19 | AFCCompareReport, | ||
| 20 | AFCSECompareResult, | ||
| 21 | HILSECompareResult, | ||
| 22 | ) | ||
| 9 | from apps.doc import consts | 23 | from apps.doc import consts |
| 10 | from apps.doc.ocr.gcap import gcap | 24 | from apps.doc.ocr.gcap import gcap |
| 11 | from apps.doc.exceptions import GCAPException | 25 | from apps.doc.exceptions import GCAPException |
| ... | @@ -181,34 +195,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s | ... | @@ -181,34 +195,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s |
| 181 | return is_find and key_right, no_match_vino | 195 | return is_find and key_right, no_match_vino |
| 182 | 196 | ||
| 183 | 197 | ||
| 184 | @app.task | 198 | def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict): |
| 185 | def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ||
| 186 | # POS: application_id, application_entity, uniq_seq, None | ||
| 187 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | ||
| 188 | |||
| 189 | compare_log.info('{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | ||
| 190 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | ||
| 191 | |||
| 192 | # 根据application_id查找最新的比对信息,如果没有,结束 | ||
| 193 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | ||
| 194 | last_obj = comparison_class.objects.filter(application_id=application_id).last() | ||
| 195 | if last_obj is None: | ||
| 196 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | ||
| 197 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | ||
| 198 | return | ||
| 199 | |||
| 200 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 | ||
| 201 | result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | ||
| 202 | if ocr_res_id is None: | ||
| 203 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() | ||
| 204 | else: | ||
| 205 | ocr_res_dict = result_class.objects.filter(id=ocr_res_id).values(*consts.COMPARE_FIELDS).first() | ||
| 206 | if ocr_res_dict is None: | ||
| 207 | compare_log.info('{0} [ocr info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | ||
| 208 | log_base, application_entity, application_id, uniq_seq, ocr_res_id | ||
| 209 | )) | ||
| 210 | return | ||
| 211 | |||
| 212 | start_time = datetime.now() | 199 | start_time = datetime.now() |
| 213 | compare_failed = False | 200 | compare_failed = False |
| 214 | 201 | ||
| ... | @@ -339,38 +326,36 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -339,38 +326,36 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 339 | 326 | ||
| 340 | comparison_res['OCR_Input']['corporateCusInfo'] = order_corporate_cus_info | 327 | comparison_res['OCR_Input']['corporateCusInfo'] = order_corporate_cus_info |
| 341 | 328 | ||
| 342 | comparison_res['OCR_Input']['wholeResult'] = consts.RESULT_N if consts.RESULT_N in res_set or consts.RESULT_NA in res_set else consts.RESULT_Y | 329 | comparison_res['OCR_Input'][ |
| 330 | 'wholeResult'] = consts.RESULT_N if consts.RESULT_N in res_set or consts.RESULT_NA in res_set else consts.RESULT_Y | ||
| 343 | 331 | ||
| 344 | except Exception as e: | 332 | except Exception as e: |
| 345 | compare_failed = True | 333 | compare_failed = True |
| 346 | compare_log.error('{0} [compare error] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 334 | compare_log.error('{0} [CA] [compare error] [entity={1}] [id={2}] [ocr_res_id={3}] [error={4}]'.format( |
| 347 | '[error={5}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | 335 | log_base, application_entity, application_id, ocr_res_id, traceback.format_exc())) |
| 348 | traceback.format_exc())) | ||
| 349 | else: | 336 | else: |
| 350 | compare_log.info('{0} [compare success] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 337 | compare_log.info('{0} [CA] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [compare_res={4}]'.format( |
| 351 | '[compare_res={5}]'.format(log_base, application_entity, application_id, uniq_seq, | 338 | log_base, application_entity, application_id, ocr_res_id, comparison_res)) |
| 352 | ocr_res_id, comparison_res)) | ||
| 353 | 339 | ||
| 354 | is_gcap_send = Configs.objects.filter(id=1).first() | 340 | is_gcap_send = Configs.objects.filter(id=1).first() |
| 355 | if is_gcap_send is not None and is_gcap_send.value == 'N': | 341 | if is_gcap_send is not None and is_gcap_send.value == 'N': |
| 356 | compare_log.info('{0} [gcap closed] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | 342 | compare_log.info('{0} [CA] [gcap closed] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
| 357 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | 343 | log_base, application_entity, application_id, ocr_res_id)) |
| 358 | return | 344 | return |
| 359 | 345 | ||
| 360 | # 时间延迟 | 346 | # 时间延迟 |
| 361 | send_time = last_obj.create_time + timedelta(seconds=15) | 347 | send_time = last_obj.create_time + timedelta(seconds=15) |
| 362 | while datetime.now() < send_time: | 348 | while datetime.now() < send_time: |
| 363 | compare_log.info('{0} [time wait 5s] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | 349 | compare_log.info('{0} [CA] [time wait 5s] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
| 364 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | 350 | log_base, application_entity, application_id, ocr_res_id)) |
| 365 | time.sleep(5) | 351 | time.sleep(5) |
| 366 | 352 | ||
| 367 | # 将比对结果发送GCAP | 353 | # 将比对结果发送GCAP |
| 368 | try: | 354 | try: |
| 369 | data = gcap.dict_to_xml(comparison_res) | 355 | data = gcap.dict_to_xml(comparison_res) |
| 370 | except Exception as e: | 356 | except Exception as e: |
| 371 | compare_log.error('{0} [dict to xml failed] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 357 | compare_log.error('{0} [CA] [dict to xml failed] [entity={1}] [id={2}] [ocr_res_id={3}] [error={4}]'.format( |
| 372 | '[error={5}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | 358 | log_base, application_entity, application_id, ocr_res_id, traceback.format_exc())) |
| 373 | traceback.format_exc())) | ||
| 374 | else: | 359 | else: |
| 375 | try: | 360 | try: |
| 376 | for times in range(consts.RETRY_TIMES): | 361 | for times in range(consts.RETRY_TIMES): |
| ... | @@ -383,16 +368,15 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -383,16 +368,15 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 383 | else: | 368 | else: |
| 384 | raise GCAPException(gcap_exc) | 369 | raise GCAPException(gcap_exc) |
| 385 | except Exception as e: | 370 | except Exception as e: |
| 386 | compare_log.error('{0} [gcap failed] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 371 | compare_log.error('{0} [CA] [gcap failed] [entity={1}] [id={2}] [ocr_res_id={3}] [error={4}]'.format( |
| 387 | '[error={5}]'.format(log_base, application_entity, application_id, uniq_seq, | 372 | log_base, application_entity, application_id, ocr_res_id, traceback.format_exc())) |
| 388 | ocr_res_id, traceback.format_exc())) | ||
| 389 | else: | 373 | else: |
| 390 | compare_log.info('{0} [gcap success] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 374 | compare_log.info('{0} [CA] [gcap success] [entity={1}] [id={2}] [ocr_res_id={3}] [response={4}]'.format( |
| 391 | '[response={5}]'.format(log_base, application_entity, application_id, uniq_seq, | 375 | log_base, application_entity, application_id, ocr_res_id, res_text)) |
| 392 | ocr_res_id, res_text)) | 376 | compare_log.info('{0} [CA] [task success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
| 393 | compare_log.info('{0} [task success] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | 377 | log_base, application_entity, application_id, ocr_res_id)) |
| 394 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | ||
| 395 | 378 | ||
| 379 | # report | ||
| 396 | try: | 380 | try: |
| 397 | end_time = datetime.now() | 381 | end_time = datetime.now() |
| 398 | if compare_failed: | 382 | if compare_failed: |
| ... | @@ -400,7 +384,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -400,7 +384,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 400 | failure_reason = 'Compare process error' | 384 | failure_reason = 'Compare process error' |
| 401 | total_fields = 0 | 385 | total_fields = 0 |
| 402 | else: | 386 | else: |
| 403 | successful_at_this_level = True if comparison_res['OCR_Input']['wholeResult'] == consts.RESULT_Y else False | 387 | successful_at_this_level = True if comparison_res['OCR_Input'][ |
| 388 | 'wholeResult'] == consts.RESULT_Y else False | ||
| 404 | field_failed = { | 389 | field_failed = { |
| 405 | 'individualCusInfo': [], | 390 | 'individualCusInfo': [], |
| 406 | 'corporateCusInfo': [], | 391 | 'corporateCusInfo': [], |
| ... | @@ -471,7 +456,6 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -471,7 +456,6 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 471 | else: | 456 | else: |
| 472 | failure_reason = '' | 457 | failure_reason = '' |
| 473 | 458 | ||
| 474 | |||
| 475 | request_trigger = RequestTrigger.SUBMITING.value if ocr_res_id is None else RequestTrigger.UPLOADING.value | 459 | request_trigger = RequestTrigger.SUBMITING.value if ocr_res_id is None else RequestTrigger.UPLOADING.value |
| 476 | report_class = HILCompareReport if application_entity == consts.HIL_PREFIX else AFCCompareReport | 460 | report_class = HILCompareReport if application_entity == consts.HIL_PREFIX else AFCCompareReport |
| 477 | report_class.objects.create( | 461 | report_class.objects.create( |
| ... | @@ -486,10 +470,359 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -486,10 +470,359 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 486 | total_fields=total_fields, | 470 | total_fields=total_fields, |
| 487 | workflow_name=last_obj.customer_type, | 471 | workflow_name=last_obj.customer_type, |
| 488 | ) | 472 | ) |
| 489 | compare_log.info('{0} [report save success] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | 473 | compare_log.info( |
| 490 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | 474 | '{0} [CA] [report save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( |
| 475 | log_base, application_entity, application_id, ocr_res_id)) | ||
| 491 | except Exception as e: | 476 | except Exception as e: |
| 492 | compare_log.error('{0} [report save success] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 477 | compare_log.error('{0} [CA] [report save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' |
| 493 | '[error={5}]'.format(log_base, application_entity, application_id, uniq_seq, | 478 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
| 494 | ocr_res_id, traceback.format_exc())) | 479 | traceback.format_exc())) |
| 480 | |||
| 481 | |||
| 482 | def get_se_compare_info(last_obj, application_entity): | ||
| 483 | compare_info = {} | ||
| 484 | individual_info_dict = {} | ||
| 485 | main_role_info = {} | ||
| 486 | for individual_info in json.loads(last_obj.individual_cus_info): | ||
| 487 | main_role_info.setdefault(individual_info['applicantType'], []).append( | ||
| 488 | (individual_info['customerName'], individual_info['idNum'])) | ||
| 489 | |||
| 490 | license_dict = {} | ||
| 491 | |||
| 492 | if individual_info['idType'] in consts.SE_FIRST_ID_FIELD_MAPPING: | ||
| 493 | license_en, field_list = consts.SE_FIRST_ID_FIELD_MAPPING[individual_info['idType']] | ||
| 494 | field_input = [] | ||
| 495 | for field in field_list: | ||
| 496 | if field in individual_info: | ||
| 497 | field_input.append((field, individual_info[field])) | ||
| 498 | license_dict[license_en] = field_input | ||
| 499 | |||
| 500 | if individual_info['secondIdType'] in consts.SE_SECOND_ID_FIELD_MAPPING: | ||
| 501 | second_license_en, second_field_list = consts.SE_SECOND_ID_FIELD_MAPPING[individual_info['secondIdType']] | ||
| 502 | if second_license_en not in license_dict: | ||
| 503 | second_field_input = [] | ||
| 504 | for second_field, write_field in second_field_list: | ||
| 505 | if second_field in individual_info: | ||
| 506 | second_field_input.append((write_field, individual_info[second_field])) | ||
| 507 | license_dict[second_license_en] = second_field_input | ||
| 508 | |||
| 509 | if individual_info['customerType'] == consts.CUSTOMER_TYPE[5]: | ||
| 510 | sep_field_input = [] | ||
| 511 | for sep_field, sep_write_field in consts.SE_SEP_FIELD: | ||
| 512 | if sep_field in individual_info: | ||
| 513 | sep_field_input.append((sep_write_field, individual_info[sep_field])) | ||
| 514 | license_dict[consts.BL_EN] = sep_field_input | ||
| 515 | |||
| 516 | if len(license_dict) > 0: | ||
| 517 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) | ||
| 518 | |||
| 519 | compare_info['individualCusInfo'] = individual_info_dict | ||
| 520 | |||
| 521 | for applicant_type in consts.APPLICANT_TYPE: | ||
| 522 | if applicant_type in main_role_info: | ||
| 523 | main_name, main_num = main_role_info[applicant_type][0] | ||
| 524 | break | ||
| 525 | del main_role_info | ||
| 526 | |||
| 527 | company_info = None | ||
| 528 | if isinstance(last_obj.corporate_cus_info, str): | ||
| 529 | corporate_info_dict = json.loads(last_obj.corporate_cus_info) | ||
| 530 | corporate_info = {} | ||
| 531 | company_info = (corporate_info_dict['companyName'], corporate_info_dict['businessLicenseNo']) | ||
| 532 | if corporate_info_dict['firstIdType'] == consts.ID_TYPE[6]: | ||
| 533 | bl_field_input = [] | ||
| 534 | for bl_field in consts.SE_CORPORATE_ALL_FIELD: | ||
| 535 | bl_field_input.append((bl_field, corporate_info_dict[bl_field])) | ||
| 536 | corporate_info[consts.BL_EN] = bl_field_input | ||
| 537 | else: | ||
| 538 | if corporate_info_dict['firstIdType'] in consts.SE_FIRST_ID_FIELD_MAPPING: | ||
| 539 | license_en, _ = consts.SE_FIRST_ID_FIELD_MAPPING[corporate_info_dict['firstIdType']] | ||
| 540 | first_id_field_input = [] | ||
| 541 | for first_id_field, first_id_write_field in consts.SE_CORPORATE_ID_FIELD: | ||
| 542 | first_id_field_input.append((first_id_write_field, corporate_info_dict[first_id_field])) | ||
| 543 | corporate_info[license_en] = first_id_field_input | ||
| 544 | bl_field_input = [] | ||
| 545 | for bl_field in consts.SE_CORPORATE_FIELD: | ||
| 546 | bl_field_input.append((bl_field, corporate_info_dict[bl_field])) | ||
| 547 | corporate_info[consts.BL_EN] = bl_field_input | ||
| 548 | |||
| 549 | compare_info['corporateCusInfo'] = corporate_info | ||
| 550 | |||
| 551 | vehicle_info_dict = json.loads(last_obj.vehicle_info) # TODO 车辆登记证 | ||
| 552 | vehicle_info = {} | ||
| 553 | vehicle_field_input = [] | ||
| 554 | gb_field_input = [] | ||
| 555 | if vehicle_info_dict['vehicleStatus'] == 'New': | ||
| 556 | for vehicle_field in consts.SE_NEW_FIELD: | ||
| 557 | vehicle_field_input.append((vehicle_field, vehicle_info_dict[vehicle_field])) | ||
| 558 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) | ||
| 559 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) | ||
| 560 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], last_obj.first_submmison_date)) | ||
| 561 | for gb_field in consts.SE_GB_NEW_FIELD: | ||
| 562 | gb_field_input.append((gb_field, vehicle_info_dict[gb_field])) | ||
| 563 | vehicle_info[consts.MVI_EN] = vehicle_field_input | ||
| 564 | vehicle_info[consts.MVC_EN] = gb_field_input | ||
| 565 | else: | ||
| 566 | for vehicle_field in consts.SE_USED_FIELD: | ||
| 567 | vehicle_field_input.append((vehicle_field, vehicle_info_dict[vehicle_field])) | ||
| 568 | for gb_field in consts.SE_GB_NEW_FIELD: | ||
| 569 | gb_field_input.append((gb_field, vehicle_info_dict[gb_field])) | ||
| 570 | if isinstance(company_info, tuple): | ||
| 571 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0])) | ||
| 572 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1])) | ||
| 573 | # gb_field_input.append((consts.SE_GB_USED_FIELD[0], company_info[0])) | ||
| 574 | # gb_field_input.append((consts.SE_GB_USED_FIELD[1], company_info[1])) | ||
| 575 | else: | ||
| 576 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) | ||
| 577 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) | ||
| 578 | # gb_field_input.append((consts.SE_GB_USED_FIELD[0], main_name)) | ||
| 579 | # gb_field_input.append((consts.SE_GB_USED_FIELD[1], main_num)) | ||
| 580 | # gb_field_input.append((consts.SE_GB_USED_FIELD[2], last_obj.first_submmison_date)) | ||
| 581 | vehicle_info[consts.UCI_EN] = vehicle_field_input | ||
| 582 | vehicle_info[consts.MVC_EN] = gb_field_input | ||
| 583 | compare_info['vehicleInfo'] = vehicle_info | ||
| 584 | |||
| 585 | bank_info_dict = json.loads(last_obj.bank_info) | ||
| 586 | bank_info = {} | ||
| 587 | bank_field_input = [] | ||
| 588 | for bank_field in consts.SE_BANK_FIELD: | ||
| 589 | bank_field_input.append((bank_field, bank_info_dict[bank_field])) | ||
| 590 | bank_info[consts.BC_EN] = bank_field_input | ||
| 591 | |||
| 592 | dda_field_input = [] | ||
| 593 | for dda_field in consts.SE_DDA_FIELD: | ||
| 594 | if dda_field.startswith('applicationId'): | ||
| 595 | dda_field_input.append((dda_field, last_obj.application_id)) | ||
| 596 | elif dda_field == 'companyName': | ||
| 597 | company_name = consts.HIL_COMPANY_NAME if application_entity in consts.HIL_SET else consts.AFC_COMPANY_NAME | ||
| 598 | dda_field_input.append((dda_field, company_name)) | ||
| 599 | elif dda_field == 'customerName': | ||
| 600 | dda_field_input.append((dda_field, main_name)) | ||
| 601 | elif dda_field == 'idNum': | ||
| 602 | dda_field_input.append((dda_field, main_num)) | ||
| 603 | else: | ||
| 604 | dda_field_input.append((dda_field, bank_info_dict[dda_field])) | ||
| 605 | bank_info[consts.DDA_EN] = dda_field_input | ||
| 606 | compare_info['bankInfo'] = bank_info | ||
| 607 | |||
| 608 | return compare_info | ||
| 609 | |||
| 610 | |||
| 611 | def se_compare_license(license_en, ocr_res_dict, field_list): | ||
| 612 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | ||
| 613 | |||
| 614 | is_find = False | ||
| 615 | result_field_list = [] | ||
| 616 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
| 617 | if ocr_res_str is not None: | ||
| 618 | ocr_res_list = json.loads(ocr_res_str) | ||
| 619 | length = len(ocr_res_list) | ||
| 620 | |||
| 621 | # 身份证、居住证 过期期限特殊处理 | ||
| 622 | if special_expiry_date: | ||
| 623 | expiry_dates = set() | ||
| 624 | key = compare_logic.get('idExpiryDate')[0] | ||
| 625 | for ocr_res in ocr_res_list: | ||
| 626 | if key in ocr_res: | ||
| 627 | expiry_dates.add(ocr_res[key]) | ||
| 628 | else: | ||
| 629 | expiry_dates = set() | ||
| 630 | |||
| 631 | for ocr_res in ocr_res_list: | ||
| 632 | if is_find: | ||
| 633 | break | ||
| 634 | |||
| 635 | for idx, (name, value) in enumerate(field_list): | ||
| 636 | ocr_str = ocr_res.get(compare_logic[name][0]) | ||
| 637 | if not isinstance(ocr_str, str): | ||
| 638 | result = consts.RESULT_N | ||
| 639 | else: | ||
| 640 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
| 641 | |||
| 642 | if idx == 0 and result == consts.RESULT_N and length > 1: | ||
| 643 | break | ||
| 644 | |||
| 645 | is_find = True | ||
| 646 | |||
| 647 | # 过期期限特殊处理 | ||
| 648 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: | ||
| 649 | for expiry_date in expiry_dates: | ||
| 650 | expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date, **compare_logic[name][2]) | ||
| 651 | if expiry_date_res == consts.RESULT_Y: | ||
| 652 | ocr_str = expiry_date | ||
| 653 | result = expiry_date_res | ||
| 654 | break | ||
| 655 | |||
| 656 | result_field_list.append((name, value, result, ocr_str)) | ||
| 657 | |||
| 658 | if not is_find: | ||
| 659 | for name, value in field_list: | ||
| 660 | result_field_list.append((name, value, consts.RESULT_N, '')) | ||
| 661 | |||
| 662 | return result_field_list | ||
| 663 | |||
| 664 | |||
| 665 | def se_compare_process(compare_info, ocr_res_dict): | ||
| 666 | # individualCusInfo | ||
| 667 | # corporateCusInfo | ||
| 668 | # vehicleInfo | ||
| 669 | # bankInfo | ||
| 670 | compare_result = [] | ||
| 671 | total_fields = 0 | ||
| 672 | failed_count = 0 | ||
| 673 | successful_at_this_level = True | ||
| 674 | failure_reason = {} | ||
| 675 | |||
| 676 | for info_key, info_value in compare_info.items(): | ||
| 677 | if info_key == 'individualCusInfo': | ||
| 678 | for idx, license_dict in info_value.items(): | ||
| 679 | for license_en, field_list in license_dict.items(): | ||
| 680 | failure_field = [] | ||
| 681 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | ||
| 682 | for name, value, result, ocr_str in result_field_list: | ||
| 683 | total_fields += 1 | ||
| 684 | if result == consts.RESULT_N: | ||
| 685 | failed_count += 1 | ||
| 686 | successful_at_this_level = False | ||
| 687 | failure_field.append(name) | ||
| 688 | compare_result.append( | ||
| 689 | { | ||
| 690 | 'Info': info_key, | ||
| 691 | 'Index': idx, | ||
| 692 | 'License': license_en, | ||
| 693 | 'Field': name, | ||
| 694 | 'Input': value, | ||
| 695 | 'OCR': ocr_str, | ||
| 696 | 'Result': result, | ||
| 697 | 'Position': '', | ||
| 698 | 'Image': '', | ||
| 699 | 'errorType': '', | ||
| 700 | } | ||
| 701 | ) | ||
| 702 | failure_reason.setdefault(license_en, []).append('/'.join(failure_field)) | ||
| 703 | else: | ||
| 704 | for license_en, field_list in info_value.items(): | ||
| 705 | failure_field = [] | ||
| 706 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | ||
| 707 | for name, value, result, ocr_str in result_field_list: | ||
| 708 | total_fields += 1 | ||
| 709 | if result == consts.RESULT_N: | ||
| 710 | failed_count += 1 | ||
| 711 | successful_at_this_level = False | ||
| 712 | failure_field.append(name) | ||
| 713 | compare_result.append( | ||
| 714 | { | ||
| 715 | 'Info': info_key, | ||
| 716 | 'Index': 0, | ||
| 717 | 'License': license_en, | ||
| 718 | 'Field': name, | ||
| 719 | 'Input': value, | ||
| 720 | 'OCR': ocr_str, | ||
| 721 | 'Result': result, | ||
| 722 | 'Position': '', | ||
| 723 | 'Image': '', | ||
| 724 | 'errorType': '', | ||
| 725 | } | ||
| 726 | ) | ||
| 727 | failure_reason.setdefault(license_en, []).append('/'.join(failure_field)) | ||
| 728 | failure_reason_list = [] | ||
| 729 | for license_en, failed_field_list in failure_reason.items(): | ||
| 730 | failure_reason_list.append('{0}:{1}'.format(license_en, ';'.join(failed_field_list))) | ||
| 731 | failure_reason_str = '、'.join(failure_reason_list) | ||
| 732 | return compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str | ||
| 733 | |||
| 734 | |||
| 735 | def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict): | ||
| 736 | try: | ||
| 737 | # 比对逻辑 | ||
| 738 | start_time = datetime.now() | ||
| 739 | compare_info = get_se_compare_info(last_obj, application_entity) | ||
| 740 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str = se_compare_process( | ||
| 741 | compare_info, ocr_res_dict) | ||
| 742 | except Exception as e: | ||
| 743 | pass | ||
| 744 | else: | ||
| 745 | # 将比对结果写入数据库 | ||
| 746 | try: | ||
| 747 | result_table = HILSECompareResult if application_entity == consts.HIL_PREFIX else AFCSECompareResult | ||
| 748 | res_obj = result_table.objects.filter(application_id=application_id).first() | ||
| 749 | if res_obj is None: | ||
| 750 | res_obj = result_table() | ||
| 751 | res_obj.application_id = application_id | ||
| 752 | res_obj.compare_count = total_fields | ||
| 753 | res_obj.failed_count = failed_count | ||
| 754 | # res_obj.reason1_count = reason1_count | ||
| 755 | res_obj.result = json.dumps(compare_result) | ||
| 756 | res_obj.save() | ||
| 757 | compare_log.info('{0} [SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
| 758 | log_base, application_entity, application_id, ocr_res_id)) | ||
| 759 | except Exception as e: | ||
| 760 | compare_log.error('{0} [SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
| 761 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
| 762 | traceback.format_exc())) | ||
| 763 | |||
| 764 | # report | ||
| 765 | end_time = datetime.now() | ||
| 766 | try: | ||
| 767 | request_trigger = RequestTrigger.SUBMITING.value if ocr_res_id is None else RequestTrigger.UPLOADING.value | ||
| 768 | report_class = HILCompareReport if application_entity == consts.HIL_PREFIX else AFCCompareReport | ||
| 769 | report_class.objects.create( | ||
| 770 | case_number=application_id, | ||
| 771 | request_team=RequestTeam.SETTLEMENT.value, | ||
| 772 | request_trigger=request_trigger, | ||
| 773 | transaction_start=start_time, | ||
| 774 | transaction_end=end_time, | ||
| 775 | successful_at_this_level=successful_at_this_level, | ||
| 776 | failure_reason=failure_reason_str, | ||
| 777 | process_name=ProcessName.SE_CACOMPARE.value, | ||
| 778 | total_fields=total_fields, | ||
| 779 | workflow_name=last_obj.customer_type, | ||
| 780 | ) | ||
| 781 | compare_log.info('{0} [SE] [report save success] [entity={1}] [id={2}] [ocr_res_id={3}]'.format( | ||
| 782 | log_base, application_entity, application_id, ocr_res_id)) | ||
| 783 | except Exception as e: | ||
| 784 | compare_log.error('{0} [SE] [report save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
| 785 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
| 786 | traceback.format_exc())) | ||
| 787 | |||
| 788 | |||
| 789 | @app.task | ||
| 790 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True): | ||
| 791 | # POS: application_id, application_entity, uniq_seq, None | ||
| 792 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | ||
| 793 | |||
| 794 | compare_log.info('{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}]'.format( | ||
| 795 | log_base, application_entity, application_id, uniq_seq, ocr_res_id, is_ca)) | ||
| 796 | |||
| 797 | # 根据application_id查找最新的比对信息,如果没有,结束 | ||
| 798 | if is_ca: | ||
| 799 | comparison_class = HILComparisonInfo if application_entity == consts.HIL_PREFIX else AFCComparisonInfo | ||
| 800 | else: | ||
| 801 | comparison_class = HILSEComparisonInfo if application_entity == consts.HIL_PREFIX else AFCSEComparisonInfo | ||
| 802 | last_obj = comparison_class.objects.filter(application_id=application_id).last() | ||
| 803 | if last_obj is None: | ||
| 804 | compare_log.info('{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | ||
| 805 | '[is_ca={5}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, is_ca)) | ||
| 806 | return | ||
| 807 | |||
| 808 | # 根据application_id查找OCR累计结果指定license字段,如果没有,结束 | ||
| 809 | if is_ca: | ||
| 810 | result_class = HILOCRResult if application_entity == consts.HIL_PREFIX else AFCOCRResult | ||
| 811 | else: | ||
| 812 | result_class = HILSEOCRResult if application_entity == consts.HIL_PREFIX else AFCSEOCRResult | ||
| 813 | if ocr_res_id is None: | ||
| 814 | ocr_res_dict = result_class.objects.filter(application_id=application_id).values(*consts.COMPARE_FIELDS).first() | ||
| 815 | else: | ||
| 816 | ocr_res_dict = result_class.objects.filter(id=ocr_res_id).values(*consts.COMPARE_FIELDS).first() | ||
| 817 | if ocr_res_dict is None: | ||
| 818 | compare_log.info('{0} [ocr info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | ||
| 819 | '[is_ca={5}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, is_ca)) | ||
| 820 | return | ||
| 821 | |||
| 822 | if is_ca: | ||
| 823 | ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | ||
| 824 | else: | ||
| 825 | se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict) | ||
| 826 | |||
| 827 | |||
| 495 | 828 | ... | ... |
| ... | @@ -136,6 +136,85 @@ class Comparison: | ... | @@ -136,6 +136,85 @@ class Comparison: |
| 136 | 136 | ||
| 137 | return self.build_res(input_str == compare_str), compare_str | 137 | return self.build_res(input_str == compare_str), compare_str |
| 138 | 138 | ||
| 139 | def se_name_compare(self, input_str, ocr_str, **kwargs): | ||
| 140 | if kwargs.get('is_passport'): | ||
| 141 | input_tmp = input_str.upper().replace(' ', '') | ||
| 142 | ocr_tmp = ocr_str.upper().replace(' ', '') | ||
| 143 | if input_tmp.find(ocr_tmp) == -1: | ||
| 144 | return self.RESULT_N | ||
| 145 | else: | ||
| 146 | return self.RESULT_Y | ||
| 147 | else: | ||
| 148 | # if re.search(r'[a-zA-Z]]', input_str): | ||
| 149 | # return self.RESULT_NA, ocr_str | ||
| 150 | input_s = input_str.translate(self.TRANS) | ||
| 151 | ocr_s = ocr_str.translate(self.TRANS) | ||
| 152 | return self.build_res(input_s == ocr_s) | ||
| 153 | |||
| 154 | def se_common_compare(self, input_str, ocr_str, **kwargs): | ||
| 155 | return self.build_res(input_str == ocr_str) | ||
| 156 | |||
| 157 | def se_date_compare(self, input_str, ocr_str, **kwargs): | ||
| 158 | if kwargs.get('long', False): | ||
| 159 | if '长期' in ocr_str or '永久' in ocr_str: | ||
| 160 | if input_str in ['2099-12-31', '2099-01-01', '2999-12-31', '2999-01-01']: | ||
| 161 | return self.RESULT_Y | ||
| 162 | else: | ||
| 163 | return self.RESULT_N | ||
| 164 | if kwargs.get('ocr_split', False): | ||
| 165 | if '至' in ocr_str: | ||
| 166 | ocr_str = ocr_str.split('至')[-1] | ||
| 167 | elif '-' in ocr_str: | ||
| 168 | ocr_str = ocr_str.split('-')[-1] | ||
| 169 | if kwargs.get('ocr_replace', False): | ||
| 170 | ocr_str = ocr_str.replace('年', '-').replace('月', '-').replace('日', '') | ||
| 171 | if kwargs.get('input_replace') is not None: | ||
| 172 | input_str = input_str.replace('-', kwargs.get('input_replace')) | ||
| 173 | return self.build_res(input_str == ocr_str) | ||
| 174 | |||
| 175 | def se_contain_compare(self, input_str, ocr_str, **kwargs): | ||
| 176 | if ocr_str.find(input_str) == -1: | ||
| 177 | return self.RESULT_N | ||
| 178 | else: | ||
| 179 | return self.RESULT_Y | ||
| 180 | |||
| 181 | def se_amount_compare(self, input_str, ocr_str, **kwargs): | ||
| 182 | if input_str == ocr_str: | ||
| 183 | return self.RESULT_Y | ||
| 184 | else: | ||
| 185 | try: | ||
| 186 | float_input = float(input_str) | ||
| 187 | float_ocr = float(ocr_str) | ||
| 188 | except Exception as e: | ||
| 189 | return self.RESULT_N | ||
| 190 | else: | ||
| 191 | return self.build_res(float_ocr == float_input) | ||
| 192 | |||
| 193 | def se_company_compare(self, input_str, ocr_str, **kwargs): | ||
| 194 | input_tmp = re.sub(self.re_obj, '', input_str).strip() | ||
| 195 | ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip() | ||
| 196 | return self.build_res(input_tmp == ocr_tmp) | ||
| 197 | |||
| 198 | def se_rmb_compare(self, input_str, ocr_str, **kwargs): | ||
| 199 | try: | ||
| 200 | ocr_lower = rmb_handler.to_rmb_lower(ocr_str) | ||
| 201 | res = self.build_res(float(input_str) == ocr_lower) | ||
| 202 | # input_rmb_upper = to_rmb_upper(float(input_str)) | ||
| 203 | # res = self.build_res(input_rmb_upper == ocr_str) | ||
| 204 | except Exception as e: | ||
| 205 | return self.RESULT_N | ||
| 206 | else: | ||
| 207 | return res | ||
| 208 | |||
| 209 | def se_type_compare(self, input_str, ocr_str, **kwargs): | ||
| 210 | for map_tuple in self.TYPE_MAPPING: | ||
| 211 | if re.search(map_tuple[0], ocr_str) is not None: | ||
| 212 | compare_str = map_tuple[1] | ||
| 213 | break | ||
| 214 | else: | ||
| 215 | compare_str = self.CSOTH | ||
| 216 | return self.build_res(input_str == compare_str) | ||
| 217 | |||
| 139 | 218 | ||
| 140 | cp = Comparison() | 219 | cp = Comparison() |
| 141 | 220 | ... | ... |
src/common/tools/mssql_script6.py
0 → 100644
| 1 | import pyodbc | ||
| 2 | |||
| 3 | |||
| 4 | hil_sql = """ | ||
| 5 | create table hil_se_comparison_info | ||
| 6 | ( | ||
| 7 | id bigint identity primary key, | ||
| 8 | uniq_seq nvarchar(128) not null, | ||
| 9 | application_id nvarchar(64) not null, | ||
| 10 | application_version tinyint default 0 not null, | ||
| 11 | customer_type nvarchar(16) not null, | ||
| 12 | first_submmison_date nvarchar(16) not null, | ||
| 13 | property_doc_policy nvarchar(16), | ||
| 14 | |||
| 15 | individual_cus_info nvarchar(max) not null, | ||
| 16 | corporate_cus_info nvarchar(max), | ||
| 17 | vehicle_info nvarchar(max) not null, | ||
| 18 | insurance_info nvarchar(max) not null, | ||
| 19 | bank_info nvarchar(max) not null, | ||
| 20 | quotationt_info nvarchar(max) not null, | ||
| 21 | |||
| 22 | update_time datetime not null, | ||
| 23 | create_time datetime not null | ||
| 24 | ); | ||
| 25 | |||
| 26 | create index hil_se_comparison_info_application_id_index | ||
| 27 | on hil_se_comparison_info (application_id); | ||
| 28 | |||
| 29 | create index hil_se_comparison_info_create_time_index | ||
| 30 | on hil_se_comparison_info (create_time); | ||
| 31 | |||
| 32 | create index hil_se_comparison_info_uniq_seq_index | ||
| 33 | on hil_se_comparison_info (uniq_seq); | ||
| 34 | |||
| 35 | create table hil_se_ocr_result | ||
| 36 | ( | ||
| 37 | id int identity primary key, | ||
| 38 | application_id nvarchar(64) not null, | ||
| 39 | bs_ocr nvarchar(max), | ||
| 40 | mvi_ocr nvarchar(max), | ||
| 41 | ic_ocr nvarchar(max), | ||
| 42 | rp_ocr nvarchar(max), | ||
| 43 | bc_ocr nvarchar(max), | ||
| 44 | bl_ocr nvarchar(max), | ||
| 45 | uci_ocr nvarchar(max), | ||
| 46 | eep_ocr nvarchar(max), | ||
| 47 | dl_ocr nvarchar(max), | ||
| 48 | pp_ocr nvarchar(max), | ||
| 49 | mvc_ocr nvarchar(max), | ||
| 50 | vat_ocr nvarchar(max), | ||
| 51 | update_time datetime not null, | ||
| 52 | create_time datetime not null | ||
| 53 | ); | ||
| 54 | |||
| 55 | create unique index hil_se_ocr_result_application_id_uindex | ||
| 56 | on hil_se_ocr_result (application_id); | ||
| 57 | |||
| 58 | create table hil_ca_compare_result | ||
| 59 | ( | ||
| 60 | id int identity primary key, | ||
| 61 | application_id nvarchar(64) not null, | ||
| 62 | is_finish bit default 0 not null, | ||
| 63 | compare_count smallint default 0 not null, | ||
| 64 | failed_count smallint default 0 not null, | ||
| 65 | reason1_count smallint default 0 not null, | ||
| 66 | reason2_count smallint default 0 not null, | ||
| 67 | reason3_count smallint default 0 not null, | ||
| 68 | reason4_count smallint default 0 not null, | ||
| 69 | reason5_count smallint default 0 not null, | ||
| 70 | reason6_count smallint default 0 not null, | ||
| 71 | reason7_count smallint default 0 not null, | ||
| 72 | reason8_count smallint default 0 not null, | ||
| 73 | reason9_count smallint default 0 not null, | ||
| 74 | reason10_count smallint default 0 not null, | ||
| 75 | result nvarchar(max), | ||
| 76 | update_time datetime not null, | ||
| 77 | create_time datetime not null | ||
| 78 | ); | ||
| 79 | |||
| 80 | create unique index hil_ca_compare_result_application_id_uindex | ||
| 81 | on hil_ca_compare_result (application_id); | ||
| 82 | |||
| 83 | create index hil_ca_compare_result_update_time_index | ||
| 84 | on hil_ca_compare_result (update_time); | ||
| 85 | |||
| 86 | create table hil_se_compare_result | ||
| 87 | ( | ||
| 88 | id int identity primary key, | ||
| 89 | application_id nvarchar(64) not null, | ||
| 90 | is_finish bit default 0 not null, | ||
| 91 | compare_count smallint default 0 not null, | ||
| 92 | failed_count smallint default 0 not null, | ||
| 93 | reason1_count smallint default 0 not null, | ||
| 94 | reason2_count smallint default 0 not null, | ||
| 95 | reason3_count smallint default 0 not null, | ||
| 96 | reason4_count smallint default 0 not null, | ||
| 97 | reason5_count smallint default 0 not null, | ||
| 98 | reason6_count smallint default 0 not null, | ||
| 99 | reason7_count smallint default 0 not null, | ||
| 100 | reason8_count smallint default 0 not null, | ||
| 101 | reason9_count smallint default 0 not null, | ||
| 102 | reason10_count smallint default 0 not null, | ||
| 103 | result nvarchar(max), | ||
| 104 | update_time datetime not null, | ||
| 105 | create_time datetime not null | ||
| 106 | ); | ||
| 107 | |||
| 108 | create unique index hil_se_compare_result_application_id_uindex | ||
| 109 | on hil_se_compare_result (application_id); | ||
| 110 | |||
| 111 | create index hil_se_compare_result_update_time_index | ||
| 112 | on hil_se_compare_result (update_time); | ||
| 113 | """ | ||
| 114 | |||
| 115 | afc_sql = """ | ||
| 116 | create table afc_se_comparison_info | ||
| 117 | ( | ||
| 118 | id bigint identity primary key, | ||
| 119 | uniq_seq nvarchar(128) not null, | ||
| 120 | application_id nvarchar(64) not null, | ||
| 121 | application_version tinyint default 0 not null, | ||
| 122 | customer_type nvarchar(16) not null, | ||
| 123 | first_submmison_date nvarchar(16) not null, | ||
| 124 | property_doc_policy nvarchar(16), | ||
| 125 | |||
| 126 | individual_cus_info nvarchar(max) not null, | ||
| 127 | corporate_cus_info nvarchar(max), | ||
| 128 | vehicle_info nvarchar(max) not null, | ||
| 129 | insurance_info nvarchar(max) not null, | ||
| 130 | bank_info nvarchar(max) not null, | ||
| 131 | quotationt_info nvarchar(max) not null, | ||
| 132 | |||
| 133 | update_time datetime not null, | ||
| 134 | create_time datetime not null | ||
| 135 | ); | ||
| 136 | |||
| 137 | create index afc_se_comparison_info_application_id_index | ||
| 138 | on afc_se_comparison_info (application_id); | ||
| 139 | |||
| 140 | create index afc_se_comparison_info_create_time_index | ||
| 141 | on afc_se_comparison_info (create_time); | ||
| 142 | |||
| 143 | create index afc_se_comparison_info_uniq_seq_index | ||
| 144 | on afc_se_comparison_info (uniq_seq); | ||
| 145 | |||
| 146 | create table afc_se_ocr_result | ||
| 147 | ( | ||
| 148 | id int identity primary key, | ||
| 149 | application_id nvarchar(64) not null, | ||
| 150 | bs_ocr nvarchar(max), | ||
| 151 | mvi_ocr nvarchar(max), | ||
| 152 | ic_ocr nvarchar(max), | ||
| 153 | rp_ocr nvarchar(max), | ||
| 154 | bc_ocr nvarchar(max), | ||
| 155 | bl_ocr nvarchar(max), | ||
| 156 | uci_ocr nvarchar(max), | ||
| 157 | eep_ocr nvarchar(max), | ||
| 158 | dl_ocr nvarchar(max), | ||
| 159 | pp_ocr nvarchar(max), | ||
| 160 | mvc_ocr nvarchar(max), | ||
| 161 | vat_ocr nvarchar(max), | ||
| 162 | update_time datetime not null, | ||
| 163 | create_time datetime not null | ||
| 164 | ); | ||
| 165 | |||
| 166 | create unique index afc_se_ocr_result_application_id_uindex | ||
| 167 | on afc_se_ocr_result (application_id); | ||
| 168 | |||
| 169 | create table afc_ca_compare_result | ||
| 170 | ( | ||
| 171 | id int identity primary key, | ||
| 172 | application_id nvarchar(64) not null, | ||
| 173 | is_finish bit default 0 not null, | ||
| 174 | compare_count smallint default 0 not null, | ||
| 175 | failed_count smallint default 0 not null, | ||
| 176 | reason1_count smallint default 0 not null, | ||
| 177 | reason2_count smallint default 0 not null, | ||
| 178 | reason3_count smallint default 0 not null, | ||
| 179 | reason4_count smallint default 0 not null, | ||
| 180 | reason5_count smallint default 0 not null, | ||
| 181 | reason6_count smallint default 0 not null, | ||
| 182 | reason7_count smallint default 0 not null, | ||
| 183 | reason8_count smallint default 0 not null, | ||
| 184 | reason9_count smallint default 0 not null, | ||
| 185 | reason10_count smallint default 0 not null, | ||
| 186 | result nvarchar(max), | ||
| 187 | update_time datetime not null, | ||
| 188 | create_time datetime not null | ||
| 189 | ); | ||
| 190 | |||
| 191 | create unique index afc_ca_compare_result_application_id_uindex | ||
| 192 | on afc_ca_compare_result (application_id); | ||
| 193 | |||
| 194 | create index afc_ca_compare_result_update_time_index | ||
| 195 | on afc_ca_compare_result (update_time); | ||
| 196 | |||
| 197 | create table afc_se_compare_result | ||
| 198 | ( | ||
| 199 | id int identity primary key, | ||
| 200 | application_id nvarchar(64) not null, | ||
| 201 | is_finish bit default 0 not null, | ||
| 202 | compare_count smallint default 0 not null, | ||
| 203 | failed_count smallint default 0 not null, | ||
| 204 | reason1_count smallint default 0 not null, | ||
| 205 | reason2_count smallint default 0 not null, | ||
| 206 | reason3_count smallint default 0 not null, | ||
| 207 | reason4_count smallint default 0 not null, | ||
| 208 | reason5_count smallint default 0 not null, | ||
| 209 | reason6_count smallint default 0 not null, | ||
| 210 | reason7_count smallint default 0 not null, | ||
| 211 | reason8_count smallint default 0 not null, | ||
| 212 | reason9_count smallint default 0 not null, | ||
| 213 | reason10_count smallint default 0 not null, | ||
| 214 | result nvarchar(max), | ||
| 215 | update_time datetime not null, | ||
| 216 | create_time datetime not null | ||
| 217 | ); | ||
| 218 | |||
| 219 | create unique index afc_se_compare_result_application_id_uindex | ||
| 220 | on afc_se_compare_result (application_id); | ||
| 221 | |||
| 222 | create index afc_se_compare_result_update_time_index | ||
| 223 | on afc_se_compare_result (update_time); | ||
| 224 | """ | ||
| 225 | |||
| 226 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
| 227 | hil_cursor = hil_cnxn.cursor() | ||
| 228 | hil_cursor.execute(hil_sql) | ||
| 229 | hil_cursor.close() | ||
| 230 | hil_cnxn.close() | ||
| 231 | |||
| 232 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
| 233 | afc_cursor = afc_cnxn.cursor() | ||
| 234 | afc_cursor.execute(afc_sql) | ||
| 235 | afc_cursor.close() | ||
| 236 | afc_cnxn.close() |
-
Please register or sign in to post a comment