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
a619e9ec
authored
2021-12-15 19:39:32 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add ht image
1 parent
e199bcb2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
59 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/ocr_process.py
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/apps/doc/consts.py
View file @
a619e9e
...
...
@@ -1798,7 +1798,7 @@ HIL_CONTRACT_1_COMPARE_LOGIC = {
'车辆卖方'
:
(
'车辆卖方'
,
'se_common_compare'
,
{},
'售后回租合同车辆卖方与系统经销商不一致'
),
'车辆原始销售价格'
:
(
'车辆原始销售价格'
,
'se_amount_str_compare'
,
{},
'售后回租合同车辆原始销售价格与系统车辆价格不一致'
),
'融资成本总额'
:
(
'融资成本总额'
,
'se_amount_str_compare'
,
{},
'售后回租合同ASP融资成本总额与系统不一致'
),
'租期'
:
(
'租期'
,
'se_contain_compare
_2
'
,
{},
'售后回租合同首页中贷款期限系统不一致'
),
'租期'
:
(
'租期'
,
'se_contain_compare'
,
{},
'售后回租合同首页中贷款期限系统不一致'
),
'还款计划表'
:
(
'还款计划表'
,
'se_schedule_compare'
,
{
"value_idx"
:
3
},
'售后回租合同还款计划表与系统不一致'
),
'ASP项目详情'
:
(
'ASP项目详情'
,
'se_asp_compare'
,
{},
'售后回租合同ASP名称或者金额与系统不一致'
),
'承租人法定代表人或授权代表'
:
(
'承租人法定代表人或授权代表'
,
'se_name_compare'
,
{},
'售后回租合同承租人法定代表人或授权代表与系统不一致'
),
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
a619e9e
...
...
@@ -298,62 +298,10 @@ class Command(BaseCommand, LoggerMixin):
elif
isinstance
(
sub_value
[
text_key
],
str
):
page_compare_dict
[
key
][
sub_key
]
=
sub_value
[
text_key
]
page_compare_dict
[
consts
.
IMG_PATH_KEY
]
=
img_path
contract_result_compare
.
setdefault
(
classify
,
dict
())[
consts
.
ASP_KEY
]
=
contract_dict
.
get
(
consts
.
ASP_KEY
,
False
)
contract_result_compare
.
setdefault
(
classify
,
dict
())[
page_num_only
]
=
page_compare_dict
# def rebuild_result(self, ocr_data, classify, img_path):
# license_data = ocr_data.get('data')
# if not license_data:
# return
# if classify == consts.IC_CLASSIFY:
# rebuild_data_dict = {}
# card_type = license_data.get('type', '')
# is_ic = card_type.startswith('身份证')
# is_info_side = card_type.endswith('信息面')
# rebuild_data_dict['类别'] = '0' if is_ic else '1'
# if is_ic:
# field_map = consts.IC_MAP_0 if is_info_side else consts.IC_MAP_1
# else:
# field_map = consts.RP_MAP_0 if is_info_side else consts.RP_MAP_1
# for write_field, search_field in field_map:
# rebuild_data_dict[write_field] = license_data.get('words_result', {}).get(search_field, {}).get('words', '')
# if not is_info_side:
# start_time = license_data.get('words_result', {}).get('签发日期', {}).get('words', '')
# end_time = license_data.get('words_result', {}).get('失效日期', {}).get('words', '')
# rebuild_data_dict['有效期限'] = '{0}-{1}'.format(start_time, end_time)
# return [rebuild_data_dict]
# elif classify == consts.MVC_CLASSIFY:
# # license_data[consts.IMG_PATH_KEY] = img_path
# rebuild_data_dict = {}
# mvc_page = license_data.pop('page', 'VehicleRCI')
# mvc_res = license_data.pop('results', {})
# if mvc_page == 'VehicleRegArea':
# rebuild_data_dict['机动车登记证书编号'] = mvc_res.get('机动车登记证书编号', {}).get('words', '')
# for register_info in mvc_res.get('登记信息', []):
# register_info.pop('register_type', None)
# register_info.pop('register_type_name', None)
# for cn_key, detail_dict in register_info.items():
# rebuild_data_dict.setdefault(cn_key, []).append(
# detail_dict.get('words', ''))
# else:
# for cn_key, detail_dict in mvc_res.items():
# rebuild_data_dict[cn_key] = detail_dict.get('words', '')
# del mvc_res
# return [rebuild_data_dict]
# elif classify == consts.MVI_CLASSIFY:
# rebuild_data_dict = {}
# mvi_res = license_data.pop('result', {})
# for en_key, detail_dict in mvi_res.items():
# rebuild_data_dict[detail_dict.get('chinese_key', '')] = detail_dict.get('words', '')
# return [rebuild_data_dict]
# elif classify == consts.UCI_CLASSIFY:
# rebuild_data_dict = {}
# mvi_res = license_data.pop('result', {})
# for en_key, detail_dict in mvi_res.items():
# rebuild_data_dict[detail_dict.get('chinese_key', '')] = detail_dict.get('words', '')
# return [rebuild_data_dict]
def
license1_process
(
self
,
ocr_data
,
license_summary
,
classify
,
res_list
,
pno
,
ino
,
part_idx
,
img_path
,
do_dda
,
dda_id_bc_mapping
):
# 类别:'0'身份证, '1'居住证
...
...
@@ -924,8 +872,12 @@ class Command(BaseCommand, LoggerMixin):
res
.
setdefault
(
key
,
list
())
.
append
(
page_info_dict
.
get
(
str
(
i
),
{})
.
get
(
key1
,
''
))
elif
key2
is
None
:
res
[
key
]
=
page_info_dict
.
get
(
str
(
pno
),
{})
.
get
(
key1
,
''
)
res
.
setdefault
(
consts
.
IMG_PATH_KEY
,
dict
())[
key
]
=
page_info_dict
.
get
(
str
(
pno
),
{})
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
else
:
res
[
key
]
=
page_info_dict
.
get
(
str
(
pno
),
{})
.
get
(
key1
,
{})
.
get
(
key2
,
''
)
res
.
setdefault
(
consts
.
IMG_PATH_KEY
,
dict
())[
key
]
=
page_info_dict
.
get
(
str
(
pno
),
{})
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
license_summary
[
classify
]
=
[
res
]
else
:
...
...
@@ -936,14 +888,22 @@ class Command(BaseCommand, LoggerMixin):
res
.
setdefault
(
key
,
list
())
.
append
(
page_info_dict
.
get
(
str
(
i
),
{})
.
get
(
key1
,
''
))
elif
key2
is
None
:
tmp_res
=
page_info_dict
.
get
(
str
(
pno1
),
{})
.
get
(
key1
)
img_pno
=
pno1
if
tmp_res
is
None
and
isinstance
(
pno2
,
int
):
tmp_res
=
page_info_dict
.
get
(
str
(
pno2
),
{})
.
get
(
key1
,
''
)
img_pno
=
pno1
res
[
key
]
=
tmp_res
res
.
setdefault
(
consts
.
IMG_PATH_KEY
,
dict
())[
key
]
=
page_info_dict
.
get
(
str
(
img_pno
),
{})
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
else
:
tmp_res
=
page_info_dict
.
get
(
str
(
pno1
),
{})
.
get
(
key1
,
{})
.
get
(
key2
)
img_pno
=
pno1
if
tmp_res
is
None
and
isinstance
(
pno2
,
int
):
tmp_res
=
page_info_dict
.
get
(
str
(
pno2
),
{})
.
get
(
key1
,
{})
.
get
(
key2
,
''
)
img_pno
=
pno1
res
[
key
]
=
tmp_res
res
.
setdefault
(
consts
.
IMG_PATH_KEY
,
dict
())[
key
]
=
page_info_dict
.
get
(
str
(
img_pno
),
{})
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
license_summary
[
classify
]
=
[
res
]
...
...
@@ -1648,7 +1608,6 @@ class Command(BaseCommand, LoggerMixin):
else
:
raise
EDMSException
(
edms_exc
)
except
Exception
as
e
:
report_list
[
0
]
=
FailureReason
.
EDMS
.
value
doc
.
status
=
DocStatus
.
UPLOAD_FAILED
.
value
self
.
online_log
.
warn
(
'{0} [process failed (edms upload)] [task={1}] [error={2}]'
.
format
(
...
...
src/celery_compare/tasks.py
View file @
a619e9e
...
...
@@ -1212,10 +1212,12 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
(
consts
.
SE_HIL_CON_1_FIELD
[
5
],
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'originationPrincipal'
,
'0.0'
))),
(
consts
.
SE_HIL_CON_1_FIELD
[
6
],
str
(
cms_info
.
get
(
'terms'
,
'0'
))),
(
consts
.
SE_HIL_CON_1_FIELD
[
7
],
schedule_list_str
),
(
consts
.
SE_HIL_CON_1_FIELD
[
8
],
asp_list
),
(
consts
.
SE_HIL_CON_1_FIELD
[
9
],
gzs_list
),
]
if
is_asp
:
hil_contract_1_input
.
append
((
consts
.
SE_HIL_CON_1_FIELD
[
8
],
asp_list
))
hil_contract_1_input
.
append
((
consts
.
SE_HIL_CON_1_FIELD
[
9
],
gzs_list
))
if
isinstance
(
company_info
,
tuple
):
hil_contract_1_input
.
append
((
consts
.
SE_HIL_CON_1_FIELD
[
10
],
company_info
[
2
]))
...
...
@@ -1844,7 +1846,8 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list):
ocr_str
=
empty_str
reason
=
compare_logic
[
name
][
3
]
img_path
=
empty_str
# img_path = empty_str
img_path
=
ocr_res
.
get
(
consts
.
IMG_PATH_KEY
,
{})
.
get
(
compare_logic
[
name
][
0
],
empty_str
)
if
result
==
consts
.
RESULT_N
else
empty_str
error_type
=
empty_error_type
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
if
isinstance
(
value
,
list
):
value
=
json
.
dumps
(
value
,
ensure_ascii
=
False
)
...
...
src/common/tools/comparison.py
View file @
a619e9e
...
...
@@ -183,7 +183,9 @@ class Comparison:
schedule_list
=
[]
for
row_list
in
ocr_str_or_list
:
tmp_str
=
"{1}{0}{2}"
.
format
(
self
.
SPLIT_STR
,
row_list
[
0
],
row_list
[
kwargs
.
get
(
'value_idx'
,
1
)]
.
replace
(
','
,
''
))
self
.
SPLIT_STR
,
row_list
[
0
]
.
replace
(
'.'
,
''
),
row_list
[
kwargs
.
get
(
'value_idx'
,
1
)]
.
replace
(
','
,
''
))
schedule_list
.
append
(
tmp_str
)
return
self
.
build_res
(
self
.
SCHEDULE_SPLIT_STR
.
join
(
schedule_list
)
==
input_str
)
else
:
...
...
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