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
cc65b4fb
authored
2022-07-28 14:45:47 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add bankcard
1 parent
1b812e1f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
35 deletions
src/apps/doc/models.py
src/apps/doc/ocr/wb.py
src/apps/doc/views.py
src/celery_compare/tasks.py
src/common/tools/mssql_script18.py
src/apps/doc/models.py
View file @
cc65b4f
...
...
@@ -882,3 +882,25 @@ class AFCAutoSettlement(models.Model):
situ_db_label
=
'afc'
class
HILbankVerification
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
on_off
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否有效"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'hil_bank_verification'
class
AFCbankVerification
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
on_off
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否有效"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'afc_bank_verification'
...
...
src/apps/doc/ocr/wb.py
View file @
cc65b4f
...
...
@@ -495,7 +495,7 @@ class BSWorkbook(Workbook):
high_light_keyword
=
self
.
wechat_keyword
else
:
high_light_keyword
=
self
.
loan_keyword
for
month
in
sorted
(
month_mapping
.
keys
()):
for
month
in
sorted
(
month_mapping
.
keys
()
,
reverse
=
True
):
# 3.1.拷贝数据
parts
=
month_mapping
.
get
(
month
)
new_ws
=
self
.
create_sheet
(
'{0}({1})'
.
format
(
month
,
card
))
...
...
src/apps/doc/views.py
View file @
cc65b4f
...
...
@@ -42,6 +42,8 @@ from .models import (
HILSECompareResultRecord
,
HILAutoSettlement
,
AFCAutoSettlement
,
HILbankVerification
,
AFCbankVerification
,
)
from
.named_enum
import
ErrorType
,
AutoResult
,
WholeResult
,
RPAResult
from
.mixins
import
DocHandler
,
MPOSHandler
...
...
@@ -112,7 +114,7 @@ se_bank_args = {
'applicantType'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
16
)),
'accountHolderName'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
256
)),
'accountNo'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
256
)),
'bankVerificationStatus'
:
fields
.
Str
(
required
=
False
,
validate
=
validate
.
Length
(
max
=
1
6
)),
'bankVerificationStatus'
:
fields
.
Str
(
required
=
False
,
validate
=
validate
.
Length
(
max
=
1
28
)),
'isAllDocUploaded'
:
fields
.
Boolean
(
required
=
False
)
}
...
...
@@ -748,29 +750,25 @@ class SECompareView(GenericView):
@use_args
(
se_compare_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
# 存库
# content = args.get('content', {})
# business_type = content.get('applicationEntity')
# application_id = content.get('applicationId')
# is_auto = content.get('isAutoSettlement', False)
#
# auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement
# auto_obj = auto_class.objects.filter(application_id=application_id).first()
# if is_auto:
# # 加入优先级队列
# PriorityApplication.objects.update_or_create(
# application_id=application_id, defaults={'on_off': True})
# # 加入auto表
# if auto_obj is None:
# auto_class.objects.create(
# application_id=application_id,
# )
# elif auto_obj.on_off is False:
# auto_obj.on_off = True
# auto_obj.save()
# else:
# if auto_obj is not None and auto_obj.on_off is True:
# auto_obj.on_off = False
# auto_obj.save()
content
=
args
.
get
(
'content'
,
{})
business_type
=
content
.
get
(
'applicationEntity'
)
application_id
=
content
.
get
(
'applicationId'
)
bank_verify
=
content
.
get
(
'bankInfo'
,
{})
.
get
(
'bankVerificationStatus'
,
''
)
bank_class
=
HILbankVerification
if
business_type
in
consts
.
HIL_SET
else
AFCbankVerification
bank_obj
=
bank_class
.
objects
.
filter
(
application_id
=
application_id
)
.
first
()
if
bank_obj
is
None
and
bank_verify
==
'PASS'
:
bank_class
.
objects
.
create
(
application_id
=
application_id
,
)
elif
bank_obj
is
not
None
and
bank_verify
==
'PASS'
and
bank_obj
.
on_off
is
False
:
bank_obj
.
on_off
=
True
bank_obj
.
save
()
elif
bank_obj
is
not
None
and
bank_verify
!=
'PASS'
and
bank_obj
.
on_off
is
True
:
bank_obj
.
on_off
=
False
bank_obj
.
save
()
return
response
.
ok
()
post
.
openapi_doc
=
'''
...
...
src/celery_compare/tasks.py
View file @
cc65b4f
...
...
@@ -29,6 +29,8 @@ from apps.doc.models import (
HILCACompareResult
,
HILAutoSettlement
,
AFCAutoSettlement
,
HILbankVerification
,
AFCbankVerification
,
)
from
apps.doc
import
consts
from
apps.doc.ocr.gcap
import
gcap
...
...
@@ -872,7 +874,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
traceback
.
format_exc
()))
def
get_se_cms_compare_info_auto
(
last_obj
,
application_entity
,
auto
=
True
):
def
get_se_cms_compare_info_auto
(
last_obj
,
application_entity
,
auto
=
True
,
ignore_bank
=
False
):
cms_info
=
json
.
loads
(
last_obj
.
content
)
compare_info
=
{}
...
...
@@ -1083,7 +1085,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True):
if
isinstance
(
company_info
,
tuple
)
and
company_info
[
0
]
==
account_holder_name
:
pass
el
se
:
el
if
not
ignore_bank
:
bank_field_input
=
[
(
'accountNo'
,
account_no
),
(
'bankName'
,
bank_name
),
...
...
@@ -1408,7 +1410,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True):
return
compare_info
,
cms_info
.
get
(
'autoApprovedDetails'
,
{})
.
get
(
'aaType'
,
''
),
is_gsyh
def
get_se_cms_compare_info
(
last_obj
,
application_entity
,
detect_list
,
auto
=
False
):
def
get_se_cms_compare_info
(
last_obj
,
application_entity
,
detect_list
,
auto
=
False
,
ignore_bank
=
False
):
cms_info
=
json
.
loads
(
last_obj
.
content
)
compare_info
=
{}
...
...
@@ -1618,7 +1620,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals
if
isinstance
(
company_info
,
tuple
)
and
company_info
[
0
]
==
account_holder_name
:
pass
el
se
:
el
if
not
ignore_bank
:
bank_field_input
=
[
(
'accountNo'
,
account_no
),
(
'bankName'
,
bank_name
),
...
...
@@ -2700,12 +2702,12 @@ def se_result_detect(ocr_res_dict):
return
detect_list
def
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
):
def
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
,
ignore_bank
):
try
:
# 比对逻辑
# detect_list = se_result_detect(ocr_res_dict)
compare_info
,
aa_type
,
is_gsyh
=
get_se_cms_compare_info_auto
(
last_obj
,
application_entity
)
last_obj
,
application_entity
,
ignore_bank
=
ignore_bank
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
cn_failure_reason_str
,
bs_failure_reason_str
,
_
=
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
,
True
)
compare_log
.
info
(
'{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
compare_result
))
...
...
@@ -2744,13 +2746,13 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc
return
successful_at_this_level
def
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
,
auto_result
):
def
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
,
auto_result
,
ignore_bank
):
try
:
# 比对逻辑
start_time
=
datetime
.
now
()
detect_list
=
se_result_detect
(
ocr_res_dict
)
compare_info
,
application_version
,
is_gsyh
=
get_se_cms_compare_info
(
last_obj
,
application_entity
,
detect_list
)
last_obj
,
application_entity
,
detect_list
,
ignore_bank
=
ignore_bank
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
cn_failure_reason_str
,
bs_failure_reason_str
,
rpa_failure_reason
=
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
,
False
)
compare_log
.
info
(
'{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
compare_result
))
...
...
@@ -2903,12 +2905,14 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
# auto settlement
auto_class
=
HILAutoSettlement
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCAutoSettlement
auto_obj
=
auto_class
.
objects
.
filter
(
application_id
=
application_id
,
on_off
=
True
)
.
first
()
bank_class
=
HILbankVerification
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCbankVerification
ignore_bank
=
bank_class
.
objects
.
filter
(
application_id
=
application_id
,
on_off
=
True
)
.
exists
()
if
auto_obj
is
not
None
:
auto_result
=
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
)
auto_result
=
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
,
ignore_bank
)
else
:
auto_result
=
None
full_result
=
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
,
auto_result
)
full_result
=
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
,
auto_result
,
ignore_bank
)
if
auto_obj
is
not
None
:
try
:
...
...
src/common/tools/mssql_script18.py
0 → 100644
View file @
cc65b4f
import
pyodbc
hil_sql
=
"""
create table hil_bank_verification
(
id bigint identity primary key,
application_id nvarchar(64) not null,
on_off bit default 1 not null,
update_time datetime not null,
create_time datetime not null
);
create index hil_bank_verification_application_id_index
on hil_bank_verification (application_id);
"""
afc_sql
=
"""
create table afc_bank_verification
(
id bigint identity primary key,
application_id nvarchar(64) not null,
on_off bit default 1 not null,
update_time datetime not null,
create_time datetime not null
);
create index afc_bank_verification_application_id_index
on afc_bank_verification (application_id);
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
hil_cursor
=
hil_cnxn
.
cursor
()
hil_cursor
.
execute
(
hil_sql
)
hil_cursor
.
close
()
hil_cnxn
.
close
()
afc_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
afc_cursor
=
afc_cnxn
.
cursor
()
afc_cursor
.
execute
(
afc_sql
)
afc_cursor
.
close
()
afc_cnxn
.
close
()
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