Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
61b268cd
authored
2021-09-07 15:26:21 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
cms part 1
1 parent
bbb1a4ad
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
10 deletions
src/apps/doc/views.py
src/celery_compare/tasks.py
src/apps/doc/views.py
View file @
61b268c
...
...
@@ -647,7 +647,7 @@ class CompareView(GenericView):
corporate_cus_info
=
corporate_cus_info
,
)
# 触发比对
compare
.
apply_async
((
application_id
,
business_type
,
uniq_seq
,
None
,
True
),
compare
.
apply_async
((
application_id
,
business_type
,
uniq_seq
,
None
,
True
,
False
),
queue
=
'queue_compare'
)
return
response
.
ok
()
...
...
@@ -708,7 +708,7 @@ class SECompareView(GenericView):
quotationt_info
=
quotationt_info
)
# 触发比对
compare
.
apply_async
((
application_id
,
business_type
,
uniq_seq
,
None
,
False
),
compare
.
apply_async
((
application_id
,
business_type
,
uniq_seq
,
None
,
False
,
False
),
queue
=
'queue_compare'
)
return
response
.
ok
()
...
...
@@ -1091,7 +1091,10 @@ class SECMSView(GenericView):
# pos上传比对信息接口 SE
@use_args
(
se_cms_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
self
.
running_log
.
info
(
'cms in'
)
# 触发比对
compare
.
apply_async
((
application_id
,
business_type
,
uniq_seq
,
None
,
False
,
True
),
queue
=
'queue_compare'
)
return
response
.
ok
()
post
.
openapi_doc
=
'''
...
...
src/celery_compare/tasks.py
View file @
61b268c
...
...
@@ -881,6 +881,110 @@ def get_se_compare_info(last_obj, application_entity, detect_list):
return
compare_info
,
is_gsyh
def
cms_get_se_compare_info
(
last_obj
,
application_entity
,
detect_list
):
# {
# "content": {
# "financeCompany": "宝马汽车金融有限公司",
# "contractNo": "CH-B100000123",
# "status": "HIL",
# "branch": "宝马汽车金融有限公司",
# "fpCampaign": "Q1_2021_BMW_BASIC",
# "applicationVersion": 1,
# "submissionDate": {},
# "mortgageType": "Mortgage Contract",
# "dealerRegion": "West",
# "insuranceRealNameCity": false,
# "totalFinanceAmount": 1234.56,
# "terms": 24,
# "dealerName": "乐山长宝汽车销售服务有限公司",
# "tier": "2",
# "province": "四川省",
# "fapiaoIssuerDealer": "乐山长宝汽车销售服务有限公司",
# "customerName": "蔡红",
# "customerIdNo": "511102196706080000",
# "vehicleStatus": "Used",
# "applicationSource": "eApp",
# "contractSource": "Online Sign",
# "applicationRating": 100,
# "applicantInformation": [
# {
# "applicantType": "Borrower",
# "customersubType": "TCCOR",
# "selfEmployedSubType": "CSIBM",
# "name": "李四",
# "legalRepName": "张三",
# "dateOfBirth": {},
# "nationality": "中国",
# "establishmentDate": {},
# "IDInformation": [
# {
# "idType": "ITARI",
# "idNum": "111111199404251100",
# "idExpiryDate": {}
# }
# ]
# }
# ],
# "autoApprovedDetails": {
# "aaType": "CAA1"
# },
# "financialInformation": {
# "vehiclePrice": 1234.56,
# "grossPrice": 1234.56,
# "associatedServicePrice": 1234.56,
# "vehiclePrincipal": 1234.56,
# "associatedServicePrincipal": 1234.56,
# "originationPrincipal": 1234.56,
# "totalDownPayment": 1234.56,
# "vehicleDownPaymentRatio": 1234.56,
# "optionAmount": 1234.56,
# "sumOfMSRPAndOption": 1234.56
# },
# "paymentSchedule": [
# {
# "no": 3,
# "grossRentalAmount": 1234.56
# }
# ],
# "associatedServices": [
# {
# "associatedServices": "机动车保险",
# "price": 1234.56,
# "financed": 1234.56,
# "total": 1234.56
# }
# ],
# "vehicleInformation": {
# "vinNo": "LBV23482934DJFKD"
# },
# "bankAccountDetails": {
# "bankName": "中国银行",
# "accountHolderName": "张三",
# "accountNo": "12312123123123124"
# },
# "insuranceDetails": {
# "insuranceType": "ComprehensiveInsurance",
# "insuranceAmount": "60000000",
# "startDate": {},
# "endDate": {}
# },
# "corporateFinancialInformation": {
# "hashCode": "238231",
# "borrowerName": "张三",
# "fiscalYear": 2019,
# "totaAssets": 1234.56,
# "totalLiabilitiesAndOwnersEquity": 1234.56,
# "cashAndCashEquivalentAtEndOfPeriod": 1234.56,
# "netProfit": 1234.56
# },
# "settlemnetVerification": {
# "applicationNo": "CH-B100000123"
# }
# }
# }
pass
def
se_compare_license
(
license_en
,
ocr_res_dict
,
field_list
):
ocr_field
,
compare_logic
,
special_expiry_date
=
consts
.
SE_COMPARE_FIELD
[
license_en
]
...
...
@@ -1094,11 +1198,15 @@ def se_result_detect(ocr_res_dict):
detect_list
.
append
(
ocr_res_str
is
None
)
return
detect_list
def
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
):
def
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
):
try
:
# 比对逻辑
start_time
=
datetime
.
now
()
detect_list
=
se_result_detect
(
ocr_res_dict
)
if
is_cms
:
compare_info
,
is_gsyh
=
cms_get_se_compare_info
(
last_obj
,
application_entity
,
detect_list
)
else
:
compare_info
,
is_gsyh
=
get_se_compare_info
(
last_obj
,
application_entity
,
detect_list
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
=
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
)
...
...
@@ -1155,14 +1263,17 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
'[error={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
traceback
.
format_exc
()))
# cms结果发送
@app.task
def
compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
):
def
compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
# POS: application_id, application_entity, uniq_seq, None
# OCR: application_id, business_type(application_entity), None, ocr_res_id
compare_log
.
info
(
'{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}]'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
is_ca
))
compare_log
.
info
(
'{0} [receive task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] '
'[is_cms={6}]'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
is_ca
,
is_cms
))
# 根据application_id查找最新的比对信息,如果没有,结束
if
is_ca
:
...
...
@@ -1172,7 +1283,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
last_obj
=
comparison_class
.
objects
.
filter
(
application_id
=
application_id
)
.
last
()
if
last_obj
is
None
:
compare_log
.
info
(
'{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] '
'[is_ca={5}]'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
is_ca
))
'[is_ca={5}] [is_cms]={6}'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
is_ca
,
is_cms
))
return
# 根据application_id查找OCR累计结果指定license字段,如果没有,结束
...
...
@@ -1186,13 +1298,14 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
ocr_res_dict
=
result_class
.
objects
.
filter
(
id
=
ocr_res_id
)
.
values
(
*
consts
.
COMPARE_FIELDS
)
.
first
()
if
ocr_res_dict
is
None
:
compare_log
.
info
(
'{0} [ocr info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] '
'[is_ca={5}]'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
is_ca
))
'[is_ca={5}] [is_cms]={6}'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
is_ca
,
is_cms
))
return
if
is_ca
:
ca_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
)
else
:
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
)
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment