2d500b7a by 王聪

Merge branch 'feature/fsm-full' into feature/uat-tmp

2 parents 68af8930 303c44f8
...@@ -1072,7 +1072,6 @@ class NscInvoice(models.Model): ...@@ -1072,7 +1072,6 @@ class NscInvoice(models.Model):
1072 class Meta: 1072 class Meta:
1073 managed = False 1073 managed = False
1074 db_table = 'nsc_invoice' 1074 db_table = 'nsc_invoice'
1075 situ_db_label = 'hil'
1076 1075
1077 1076
1078 class AFCCmsStatusInfo(models.Model): 1077 class AFCCmsStatusInfo(models.Model):
...@@ -1100,4 +1099,3 @@ class HILCmsStatusInfo(models.Model): ...@@ -1100,4 +1099,3 @@ class HILCmsStatusInfo(models.Model):
1100 class Meta: 1099 class Meta:
1101 managed = False 1100 managed = False
1102 db_table = 'hil_cms_status_info' 1101 db_table = 'hil_cms_status_info'
1103 situ_db_label = 'hil'
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -60,8 +60,11 @@ from .mixins import DocHandler, MPOSHandler, PreSEHandler ...@@ -60,8 +60,11 @@ from .mixins import DocHandler, MPOSHandler, PreSEHandler
60 from . import consts 60 from . import consts
61 from apps.account.authentication import OAuth2AuthenticationWithUser 61 from apps.account.authentication import OAuth2AuthenticationWithUser
62 from celery_compare.tasks import compare, fsm_compare 62 from celery_compare.tasks import compare, fsm_compare
63 from prese.compare import get_empty_result
63 64
64 import time 65 import time
66
67
65 class CustomDate(fields.Date): 68 class CustomDate(fields.Date):
66 69
67 def _deserialize(self, value, attr, data, **kwargs): 70 def _deserialize(self, value, attr, data, **kwargs):
...@@ -557,6 +560,7 @@ class UploadDocView(GenericView, DocHandler): ...@@ -557,6 +560,7 @@ class UploadDocView(GenericView, DocHandler):
557 # authentication_classes = [] 560 # authentication_classes = []
558 permission_classes = [IsAuthenticated] 561 permission_classes = [IsAuthenticated]
559 authentication_classes = [OAuth2AuthenticationWithUser] 562 authentication_classes = [OAuth2AuthenticationWithUser]
563
560 # required_scopes = ['write'] 564 # required_scopes = ['write']
561 565
562 # 上传(接收)文件接口 566 # 上传(接收)文件接口
...@@ -581,7 +585,8 @@ class UploadDocView(GenericView, DocHandler): ...@@ -581,7 +585,8 @@ class UploadDocView(GenericView, DocHandler):
581 585
582 # fsm激活状态, 更新ocr_result 表fsm状态 586 # fsm激活状态, 更新ocr_result 表fsm状态
583 self.running_log.info('[doc upload applicationId-{0}] [applicationStatus-{1}, activated-{2}]' 587 self.running_log.info('[doc upload applicationId-{0}] [applicationStatus-{1}, activated-{2}]'
584 .format(application_id, application_status, True if consts.FSM_ACTIVITED_STATUS.get(application_status) else False)) 588 .format(application_id, application_status,
589 True if consts.FSM_ACTIVITED_STATUS.get(application_status) else False))
585 if consts.FSM_ACTIVITED_STATUS.get(application_status): 590 if consts.FSM_ACTIVITED_STATUS.get(application_status):
586 result_class = None 591 result_class = None
587 if business_type == consts.HIL_PREFIX: 592 if business_type == consts.HIL_PREFIX:
...@@ -852,6 +857,9 @@ class CompareView(GenericView): ...@@ -852,6 +857,9 @@ class CompareView(GenericView):
852 ''' 857 '''
853 858
854 859
860 pre_fsm_url = conf.PRE_FSM_URL
861
862
855 class SECompareView(GenericView, PreSEHandler): 863 class SECompareView(GenericView, PreSEHandler):
856 permission_classes = [IsAuthenticated] 864 permission_classes = [IsAuthenticated]
857 authentication_classes = [OAuth2AuthenticationWithUser] 865 authentication_classes = [OAuth2AuthenticationWithUser]
...@@ -873,6 +881,50 @@ class SECompareView(GenericView, PreSEHandler): ...@@ -873,6 +881,50 @@ class SECompareView(GenericView, PreSEHandler):
873 fsm_special_car = content.get('fsmSpecialCar', False) 881 fsm_special_car = content.get('fsmSpecialCar', False)
874 fsm_best_price = content.get('fsmBestPrice', False) 882 fsm_best_price = content.get('fsmBestPrice', False)
875 883
884 if fsm_special_car:
885 compare_result = {
886 "is_pass": False,
887 "particulars": [{
888 "object_name": "",
889 "fields": [{
890 "input": "",
891 "ocr": "",
892 "field_is_pass": False,
893 "comments": "此申请为FSM 特殊申请,暂不支持预放款流程"
894 }]
895 }]
896 }
897 elif fsm_best_price:
898 compare_result = {
899 "is_pass": False,
900 "particulars": [{
901 "object_name": "",
902 "fields": [{
903 "input": "",
904 "ocr": "",
905 "field_is_pass": False,
906 "comments": "此申请为FSM 特殊申请,暂不支持预放款流程"
907 }]
908 }]
909 }
910 elif fsm_flag and (not fsm_special_car or not fsm_best_price):
911 # 调用Java pre fsm接口
912 try:
913 self.running_log.info("{0} request java pre fsm api, url:{1}, body:{2}".format(log_base, pre_fsm_url, json.dumps(content)))
914 headers = {
915 'Content-Type': 'application/json'
916 }
917 resp = requests.post(pre_fsm_url, headers=headers, json=content)
918 self.running_log.info("{0} response from java pre fsm api, resp:{1}".format(log_base, resp.text))
919 result = json.loads(resp.text)
920 compare_result = result.get("result")
921 if not compare_result:
922 compare_result = get_empty_result()
923 except Exception as e:
924 self.running_log.error("{0} pre fsm request to java error, url:{1}, param:{2}, errorMsg:{3}".format(
925 log_base, pre_fsm_url, json.dumps(content), traceback.format_exc()))
926 compare_result = get_empty_result()
927 elif not fsm_flag:
876 # 存库, 用于银行卡比对 928 # 存库, 用于银行卡比对
877 try: 929 try:
878 bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification 930 bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification
...@@ -896,7 +948,8 @@ class SECompareView(GenericView, PreSEHandler): ...@@ -896,7 +948,8 @@ class SECompareView(GenericView, PreSEHandler):
896 # preSettlement比对 948 # preSettlement比对
897 compare_result = self.pre_compare_entrance(content) 949 compare_result = self.pre_compare_entrance(content)
898 self.running_log.info('{0} [prese completed] [applicationEntity={1}] [application_id={2}] [uniq_seq={3}] ' 950 self.running_log.info('{0} [prese completed] [applicationEntity={1}] [application_id={2}] [uniq_seq={3}] '
899 '[result={4}]'.format(log_base, business_type, application_id, uniq_seq, compare_result)) 951 '[result={4}]'.format(log_base, business_type, application_id, uniq_seq,
952 compare_result))
900 953
901 try: 954 try:
902 end_time = time.time() 955 end_time = time.time()
...@@ -999,10 +1052,10 @@ class DocView(GenericView, DocHandler): ...@@ -999,10 +1052,10 @@ class DocView(GenericView, DocHandler):
999 application_id_query = Q(application_id__contains=application_id) if application_id is not None else Q() 1052 application_id_query = Q(application_id__contains=application_id) if application_id is not None else Q()
1000 data_source_query = Q(data_source=data_source) if data_source is not None else Q() 1053 data_source_query = Q(data_source=data_source) if data_source is not None else Q()
1001 upload_finish_time_query = Q(upload_finish_time__gte=upload_time_start, 1054 upload_finish_time_query = Q(upload_finish_time__gte=upload_time_start,
1002 upload_finish_time__lt=upload_time_end + datetime.timedelta(days=1))\ 1055 upload_finish_time__lt=upload_time_end + datetime.timedelta(days=1)) \
1003 if upload_time_start is not None and upload_time_end is not None else Q() 1056 if upload_time_start is not None and upload_time_end is not None else Q()
1004 create_time_query = Q(create_time__gte=create_time_start, 1057 create_time_query = Q(create_time__gte=create_time_start,
1005 create_time__lt=create_time_end + datetime.timedelta(days=1))\ 1058 create_time__lt=create_time_end + datetime.timedelta(days=1)) \
1006 if create_time_start is not None and create_time_end is not None else Q() 1059 if create_time_start is not None and create_time_end is not None else Q()
1007 query = application_id_query & status_query & data_source_query & upload_finish_time_query & create_time_query 1060 query = application_id_query & status_query & data_source_query & upload_finish_time_query & create_time_query
1008 val_tuple = ('id', 'application_id', 'upload_finish_time', 'create_time', 'document_scheme', 'data_source', 1061 val_tuple = ('id', 'application_id', 'upload_finish_time', 'create_time', 'document_scheme', 'data_source',
...@@ -1014,10 +1067,11 @@ class DocView(GenericView, DocHandler): ...@@ -1014,10 +1067,11 @@ class DocView(GenericView, DocHandler):
1014 if start_index >= total > 0: 1067 if start_index >= total > 0:
1015 raise self.invalid_params('页数不存在') 1068 raise self.invalid_params('页数不存在')
1016 1069
1017 doc_queryset = doc_class.objects.filter(query).values(*val_tuple).order_by('-create_time')[start_index: end_index] 1070 doc_queryset = doc_class.objects.filter(query).values(*val_tuple).order_by('-create_time')[
1071 start_index: end_index]
1018 # doc_list = self.get_doc_list(doc_queryset, prefix) 1072 # doc_list = self.get_doc_list(doc_queryset, prefix)
1019 for doc_dict in doc_queryset: 1073 for doc_dict in doc_queryset:
1020 tmp_scheme = consts.COMPARE_DOC_SCHEME_LIST[0] if doc_dict['document_scheme'] == consts.DOC_SCHEME_LIST[0]\ 1074 tmp_scheme = consts.COMPARE_DOC_SCHEME_LIST[0] if doc_dict['document_scheme'] == consts.DOC_SCHEME_LIST[0] \
1021 else consts.COMPARE_DOC_SCHEME_LIST[1] 1075 else consts.COMPARE_DOC_SCHEME_LIST[1]
1022 application_link = '{0}/showList/showList?entity={1}&scheme={2}&case_id={3}'.format( 1076 application_link = '{0}/showList/showList?entity={1}&scheme={2}&case_id={3}'.format(
1023 conf.BASE_URL, prefix, tmp_scheme, doc_dict['application_id']) 1077 conf.BASE_URL, prefix, tmp_scheme, doc_dict['application_id'])
...@@ -1064,7 +1118,6 @@ class DocView(GenericView, DocHandler): ...@@ -1064,7 +1118,6 @@ class DocView(GenericView, DocHandler):
1064 # os.remove(tmp_save_path) 1118 # os.remove(tmp_save_path)
1065 # raise self.invalid_params(msg='invalid params: PDF file XSS') 1119 # raise self.invalid_params(msg='invalid params: PDF file XSS')
1066 1120
1067
1068 file.close() 1121 file.close()
1069 # 1. 上传信息记录 1122 # 1. 上传信息记录
1070 application_id = '{0}{1}'.format(consts.FIXED_APPLICATION_ID_PREFIX, metadata_version_id) 1123 application_id = '{0}{1}'.format(consts.FIXED_APPLICATION_ID_PREFIX, metadata_version_id)
...@@ -1147,7 +1200,8 @@ class CompareResultView(GenericView): ...@@ -1147,7 +1200,8 @@ class CompareResultView(GenericView):
1147 latest_compared_time = '' 1200 latest_compared_time = ''
1148 else: 1201 else:
1149 whole_result = consts.RESULT_Y if result_obj.ocr_auto_result_pass else consts.RESULT_N 1202 whole_result = consts.RESULT_Y if result_obj.ocr_auto_result_pass else consts.RESULT_N
1150 latest_compared_time = '' if result_obj.ocr_latest_comparison_time is None else result_obj.ocr_latest_comparison_time.strftime('%Y-%m-%d %H:%M') 1203 latest_compared_time = '' if result_obj.ocr_latest_comparison_time is None else result_obj.ocr_latest_comparison_time.strftime(
1204 '%Y-%m-%d %H:%M')
1151 1205
1152 source = consts.INFO_SOURCE[1] 1206 source = consts.INFO_SOURCE[1]
1153 version = comments = '' 1207 version = comments = ''
...@@ -1163,7 +1217,8 @@ class CompareResultView(GenericView): ...@@ -1163,7 +1217,8 @@ class CompareResultView(GenericView):
1163 'source': source, 1217 'source': source,
1164 'version': version, 1218 'version': version,
1165 'comments': comments, 1219 'comments': comments,
1166 'result': [] if result_obj is None or not result_obj.ocr_auto_result else json.loads(result_obj.ocr_auto_result) 1220 'result': [] if result_obj is None or not result_obj.ocr_auto_result else json.loads(
1221 result_obj.ocr_auto_result)
1167 } 1222 }
1168 1223
1169 return response.ok(data=compare_result) 1224 return response.ok(data=compare_result)
...@@ -1198,7 +1253,8 @@ class CompareResultView(GenericView): ...@@ -1198,7 +1253,8 @@ class CompareResultView(GenericView):
1198 'id': 0 if result_obj is None else result_obj.id, 1253 'id': 0 if result_obj is None else result_obj.id,
1199 'application_id': case_id, 1254 'application_id': case_id,
1200 'entity': entity, 1255 'entity': entity,
1201 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else consts.DOC_SCHEME_LIST[1], 1256 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else
1257 consts.DOC_SCHEME_LIST[1],
1202 'whole_result': whole_result, 1258 'whole_result': whole_result,
1203 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'), 1259 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'),
1204 'source': source, 1260 'source': source,
...@@ -1371,7 +1427,8 @@ class SECMSView(GenericView): ...@@ -1371,7 +1427,8 @@ class SECMSView(GenericView):
1371 1427
1372 args = request.data 1428 args = request.data
1373 cms_info = args.get('content', {}) 1429 cms_info = args.get('content', {})
1374 business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith('宝马') else consts.HIL_PREFIX 1430 business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith(
1431 '宝马') else consts.HIL_PREFIX
1375 src_application_id = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') 1432 src_application_id = cms_info.get('settlemnetVerification', {}).get('applicationNo', '')
1376 application_id = src_application_id[:src_application_id.rfind('-')] 1433 application_id = src_application_id[:src_application_id.rfind('-')]
1377 1434
...@@ -1416,15 +1473,19 @@ class SECMSView(GenericView): ...@@ -1416,15 +1473,19 @@ class SECMSView(GenericView):
1416 cms_status_info = cms_status_class.objects.filter(application_id=application_id).first() 1473 cms_status_info = cms_status_class.objects.filter(application_id=application_id).first()
1417 if cms_status_info: 1474 if cms_status_info:
1418 cms_status_info.is_fsm = 1 1475 cms_status_info.is_fsm = 1
1476 cms_status_info.update_time = datetime.datetime.now()
1419 cms_status_info.save() 1477 cms_status_info.save()
1420 else: 1478 else:
1421 cms_status_info = cms_status_class() 1479 cms_status_info = cms_status_class()
1422 cms_status_info.application_id = application_id 1480 cms_status_info.application_id = application_id
1423 cms_status_info.business_type = business_type 1481 cms_status_info.business_type = business_type
1424 cms_status_info.is_fsm = 1 1482 cms_status_info.is_fsm = 1
1483 cms_status_info.update_time = datetime.datetime.now()
1484 cms_status_info.create_time = datetime.datetime.now()
1425 cms_status_info.save() 1485 cms_status_info.save()
1426 except Exception as e: 1486 except Exception as e:
1427 self.exception_log.exception('[cms view] [cms_status_info db save failed] [error={0}]'.format(traceback.format_exc())) 1487 self.exception_log.exception(
1488 '[cms view] [cms_status_info db save failed] [error={0}]'.format(traceback.format_exc()))
1428 fsm_compare.apply_async((application_id, business_type, None, None, False, True), 1489 fsm_compare.apply_async((application_id, business_type, None, None, False, True),
1429 queue='queue_compare') 1490 queue='queue_compare')
1430 else: 1491 else:
...@@ -1523,7 +1584,7 @@ class AutoSettlementView(GenericView): ...@@ -1523,7 +1584,7 @@ class AutoSettlementView(GenericView):
1523 whole_result_query = Q(ocr_whole_result_pass=whole_result) if not isinstance(whole_result, str) else Q() 1584 whole_result_query = Q(ocr_whole_result_pass=whole_result) if not isinstance(whole_result, str) else Q()
1524 rpa_result_query = Q(rpa_result=rpa_result) if not isinstance(rpa_result, str) else Q() 1585 rpa_result_query = Q(rpa_result=rpa_result) if not isinstance(rpa_result, str) else Q()
1525 time1_query = Q(rpa_get_case_from_ocr_time__gte=get_case_from_ocr_time_start, 1586 time1_query = Q(rpa_get_case_from_ocr_time__gte=get_case_from_ocr_time_start,
1526 rpa_get_case_from_ocr_time__lt=get_case_from_ocr_time_end + datetime.timedelta(days=1))\ 1587 rpa_get_case_from_ocr_time__lt=get_case_from_ocr_time_end + datetime.timedelta(days=1)) \
1527 if get_case_from_ocr_time_start is not None and get_case_from_ocr_time_end is not None else Q() 1588 if get_case_from_ocr_time_start is not None and get_case_from_ocr_time_end is not None else Q()
1528 time2_query = Q(rpa_activated_time__gte=activated_time_start, 1589 time2_query = Q(rpa_activated_time__gte=activated_time_start,
1529 rpa_activated_time__lt=activated_time_end + datetime.timedelta(days=1)) \ 1590 rpa_activated_time__lt=activated_time_end + datetime.timedelta(days=1)) \
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!