619710a3 by 冯轩

Merge branch 'feature/uat-tmp' of gitlab.situdata.com:zhouweiqi/bmw-ocr into feature/uat-tmp

2 parents bd43dc3a 0b550510
......@@ -60,8 +60,11 @@ from .mixins import DocHandler, MPOSHandler, PreSEHandler
from . import consts
from apps.account.authentication import OAuth2AuthenticationWithUser
from celery_compare.tasks import compare, fsm_compare
from prese.compare import get_empty_result
import time
class CustomDate(fields.Date):
def _deserialize(self, value, attr, data, **kwargs):
......@@ -558,6 +561,7 @@ class UploadDocView(GenericView, DocHandler):
# authentication_classes = []
permission_classes = [IsAuthenticated]
authentication_classes = [OAuth2AuthenticationWithUser]
# required_scopes = ['write']
# 上传(接收)文件接口
......@@ -582,7 +586,8 @@ class UploadDocView(GenericView, DocHandler):
# fsm激活状态, 更新ocr_result 表fsm状态
self.running_log.info('[doc upload applicationId-{0}] [applicationStatus-{1}, activated-{2}]'
.format(application_id, application_status, True if consts.FSM_ACTIVITED_STATUS.get(application_status) else False))
.format(application_id, application_status,
True if consts.FSM_ACTIVITED_STATUS.get(application_status) else False))
if consts.FSM_ACTIVITED_STATUS.get(application_status):
result_class = None
if business_type == consts.HIL_PREFIX:
......@@ -854,6 +859,9 @@ class CompareView(GenericView):
'''
pre_fsm_url = conf.PRE_FSM_URL
class SECompareView(GenericView, PreSEHandler):
permission_classes = [IsAuthenticated]
authentication_classes = [OAuth2AuthenticationWithUser]
......@@ -876,6 +884,50 @@ class SECompareView(GenericView, PreSEHandler):
fsm_best_price = content.get('fsmBestPrice', False)
fsm_landing_dealer = content.get('fsmLandingDealer')
if fsm_special_car:
compare_result = {
"is_pass": False,
"particulars": [{
"object_name": "",
"fields": [{
"input": "",
"ocr": "",
"field_is_pass": False,
"comments": "此申请为FSM 特殊申请,暂不支持预放款流程"
}]
}]
}
elif fsm_best_price:
compare_result = {
"is_pass": False,
"particulars": [{
"object_name": "",
"fields": [{
"input": "",
"ocr": "",
"field_is_pass": False,
"comments": "此申请为FSM 特殊申请,暂不支持预放款流程"
}]
}]
}
elif fsm_flag and (not fsm_special_car or not fsm_best_price):
# 调用Java pre fsm接口
try:
self.running_log.info("{0} request java pre fsm api, url:{1}, body:{2}".format(log_base, pre_fsm_url, json.dumps(content)))
headers = {
'Content-Type': 'application/json'
}
resp = requests.post(pre_fsm_url, headers=headers, json=content)
self.running_log.info("{0} response from java pre fsm api, resp:{1}".format(log_base, resp.text))
result = json.loads(resp.text)
compare_result = result.get("result")
if not compare_result:
compare_result = get_empty_result()
except Exception as e:
self.running_log.error("{0} pre fsm request to java error, url:{1}, param:{2}, errorMsg:{3}".format(
log_base, pre_fsm_url, json.dumps(content), traceback.format_exc()))
compare_result = get_empty_result()
elif not fsm_flag:
# 存库, 用于银行卡比对
try:
bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification
......@@ -899,7 +951,8 @@ class SECompareView(GenericView, PreSEHandler):
# preSettlement比对
compare_result = self.pre_compare_entrance(content)
self.running_log.info('{0} [prese completed] [applicationEntity={1}] [application_id={2}] [uniq_seq={3}] '
'[result={4}]'.format(log_base, business_type, application_id, uniq_seq, compare_result))
'[result={4}]'.format(log_base, business_type, application_id, uniq_seq,
compare_result))
try:
end_time = time.time()
......@@ -1002,10 +1055,10 @@ class DocView(GenericView, DocHandler):
application_id_query = Q(application_id__contains=application_id) if application_id is not None else Q()
data_source_query = Q(data_source=data_source) if data_source is not None else Q()
upload_finish_time_query = Q(upload_finish_time__gte=upload_time_start,
upload_finish_time__lt=upload_time_end + datetime.timedelta(days=1))\
upload_finish_time__lt=upload_time_end + datetime.timedelta(days=1)) \
if upload_time_start is not None and upload_time_end is not None else Q()
create_time_query = Q(create_time__gte=create_time_start,
create_time__lt=create_time_end + datetime.timedelta(days=1))\
create_time__lt=create_time_end + datetime.timedelta(days=1)) \
if create_time_start is not None and create_time_end is not None else Q()
query = application_id_query & status_query & data_source_query & upload_finish_time_query & create_time_query
val_tuple = ('id', 'application_id', 'upload_finish_time', 'create_time', 'document_scheme', 'data_source',
......@@ -1017,10 +1070,11 @@ class DocView(GenericView, DocHandler):
if start_index >= total > 0:
raise self.invalid_params('页数不存在')
doc_queryset = doc_class.objects.filter(query).values(*val_tuple).order_by('-create_time')[start_index: end_index]
doc_queryset = doc_class.objects.filter(query).values(*val_tuple).order_by('-create_time')[
start_index: end_index]
# doc_list = self.get_doc_list(doc_queryset, prefix)
for doc_dict in doc_queryset:
tmp_scheme = consts.COMPARE_DOC_SCHEME_LIST[0] if doc_dict['document_scheme'] == consts.DOC_SCHEME_LIST[0]\
tmp_scheme = consts.COMPARE_DOC_SCHEME_LIST[0] if doc_dict['document_scheme'] == consts.DOC_SCHEME_LIST[0] \
else consts.COMPARE_DOC_SCHEME_LIST[1]
application_link = '{0}/showList/showList?entity={1}&scheme={2}&case_id={3}'.format(
conf.BASE_URL, prefix, tmp_scheme, doc_dict['application_id'])
......@@ -1067,7 +1121,6 @@ class DocView(GenericView, DocHandler):
# os.remove(tmp_save_path)
# raise self.invalid_params(msg='invalid params: PDF file XSS')
file.close()
# 1. 上传信息记录
application_id = '{0}{1}'.format(consts.FIXED_APPLICATION_ID_PREFIX, metadata_version_id)
......@@ -1150,7 +1203,8 @@ class CompareResultView(GenericView):
latest_compared_time = ''
else:
whole_result = consts.RESULT_Y if result_obj.ocr_auto_result_pass else consts.RESULT_N
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')
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')
source = consts.INFO_SOURCE[1]
version = comments = ''
......@@ -1166,7 +1220,8 @@ class CompareResultView(GenericView):
'source': source,
'version': version,
'comments': comments,
'result': [] if result_obj is None or not result_obj.ocr_auto_result else json.loads(result_obj.ocr_auto_result)
'result': [] if result_obj is None or not result_obj.ocr_auto_result else json.loads(
result_obj.ocr_auto_result)
}
return response.ok(data=compare_result)
......@@ -1201,7 +1256,8 @@ class CompareResultView(GenericView):
'id': 0 if result_obj is None else result_obj.id,
'application_id': case_id,
'entity': entity,
'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else consts.DOC_SCHEME_LIST[1],
'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else
consts.DOC_SCHEME_LIST[1],
'whole_result': whole_result,
'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'),
'source': source,
......@@ -1374,7 +1430,8 @@ class SECMSView(GenericView):
args = request.data
cms_info = args.get('content', {})
business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith('宝马') else consts.HIL_PREFIX
business_type = consts.AFC_PREFIX if cms_info.get('financeCompany', '').startswith(
'宝马') else consts.HIL_PREFIX
src_application_id = cms_info.get('settlemnetVerification', {}).get('applicationNo', '')
application_id = src_application_id[:src_application_id.rfind('-')]
......@@ -1430,7 +1487,8 @@ class SECMSView(GenericView):
cms_status_info.create_time = datetime.datetime.now()
cms_status_info.save()
except Exception as e:
self.exception_log.exception('[cms view] [cms_status_info db save failed] [error={0}]'.format(traceback.format_exc()))
self.exception_log.exception(
'[cms view] [cms_status_info db save failed] [error={0}]'.format(traceback.format_exc()))
fsm_compare.apply_async((application_id, business_type, None, None, False, True),
queue='queue_compare')
else:
......@@ -1529,7 +1587,7 @@ class AutoSettlementView(GenericView):
whole_result_query = Q(ocr_whole_result_pass=whole_result) if not isinstance(whole_result, str) else Q()
rpa_result_query = Q(rpa_result=rpa_result) if not isinstance(rpa_result, str) else Q()
time1_query = Q(rpa_get_case_from_ocr_time__gte=get_case_from_ocr_time_start,
rpa_get_case_from_ocr_time__lt=get_case_from_ocr_time_end + datetime.timedelta(days=1))\
rpa_get_case_from_ocr_time__lt=get_case_from_ocr_time_end + datetime.timedelta(days=1)) \
if get_case_from_ocr_time_start is not None and get_case_from_ocr_time_end is not None else Q()
time2_query = Q(rpa_activated_time__gte=activated_time_start,
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!