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
236b64e0
authored
2021-01-06 10:21:15 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'feature/main' into feature/mssql
2 parents
13774eb6
a308e1ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/license_statistics.py
src/apps/doc/ocr/wb.py
src/apps/doc/consts.py
View file @
236b64e
...
...
@@ -153,8 +153,8 @@ RESULT_IDX = FIXED_HEADERS.index('核对结果')
# '借贷状态': ('贷', '借'), # 竖版-特殊-交通银行
# '收/支': ('收入', '支出'), # 横版-表格-北京银行
BORROW_HEADERS_SET
=
{
'借贷'
,
'借贷状态'
,
'收/支'
,
'收支标志'
}
BORROW_INCOME_SET
=
{
'贷'
,
'收入'
,
'收'
}
BORROW_OUTLAY_SET
=
{
'借'
,
'支出'
,
'支'
}
BORROW_INCOME_SET
=
{
'贷'
,
'收入'
,
'收'
,
'收(Cr)'
}
BORROW_OUTLAY_SET
=
{
'借'
,
'支出'
,
'支'
,
'付(Dr)'
}
INCOME_HEADERS_SET
=
{
'收入金额'
,
'收入'
,
'存入'
,
'存入金额(贷)'
,
'存入金额(贷)'
}
OUTLAY_HEADERS_SET
=
{
'支出金额'
,
'支出'
,
'支取金额(借)'
,
'支取金额(借)'
}
...
...
@@ -818,14 +818,14 @@ UCI_PID = 60
UCI_FIELD_ORDER
=
((
'发票代码'
,
'发票代码'
),
(
'发票号码'
,
'发票号码'
),
(
'开票日期'
,
'开票日期'
),
(
'
车价合计
'
,
'车价合计小写'
),
(
'发票
联
'
,
'发票联'
),
(
'购方
单位
'
,
'买方单位/个人'
),
(
'购方
号码
'
,
'买方单位代码/身份证号码'
),
(
'车架号
码
'
,
'车架号'
),
(
'
车价
合计大写'
,
'车价合计大写'
),
(
'
价税合计小写
'
,
'车价合计小写'
),
(
'发票
类型
'
,
'发票联'
),
(
'购方
名称
'
,
'买方单位/个人'
),
(
'购方
纳税人识别号
'
,
'买方单位代码/身份证号码'
),
(
'车架号'
,
'车架号'
),
(
'
价税
合计大写'
,
'车价合计大写'
),
(
'二手车市场'
,
'二手车市场'
),
(
'发票章
有无
'
,
'发票章有无'
),
(
'发票章'
,
'发票章有无'
),
(
'空行占位'
,
None
),
(
'车牌照号'
,
'车牌照号'
),
(
'登记证号'
,
'登记证号'
),
...
...
@@ -834,7 +834,7 @@ UCI_FIELD_ORDER = (('发票代码', '发票代码'),
(
'厂牌型号'
,
'厂牌型号'
),
(
'车管所名称'
,
'转入地车辆管理所名称'
),
(
'销方名称'
,
'卖方单位/个人'
),
(
'销方
号码
'
,
'卖方单位代码/身份证号码'
),
(
'销方
纳税人识别号
'
,
'卖方单位代码/身份证号码'
),
(
'销方地址'
,
'卖方单位/个人住址'
),)
# 港澳台通行证
EEP_CN_NAME
=
'港澳台通行证'
...
...
@@ -943,8 +943,8 @@ FOLDER_LICENSE_ORDER = ((MVI_CLASSIFY, (MVI_PID, MVI_CN_NAME, MVI_FIELD_ORDER, F
LICENSE_CLASSIFY_MAPPING
=
dict
(
LICENSE_ORDER
)
OTHER_CLASSIFY_SET
=
{
OTHER_CLASSIFY
}
LICENSE_CLASSIFY_SET_1
=
{
IC_CLASSIFY
,
VAT_CLASSIFY
,
MVC_CLASSIFY
,
MVI_CLASSIFY
}
LICENSE_CLASSIFY_SET_2
=
{
BL_CLASSIFY
,
UCI_CLASSIFY
,
EEP_CLASSIFY
,
DL_CLASSIFY
,
PP_CLASSIFY
,
BC_CLASSIFY
}
LICENSE_CLASSIFY_SET_1
=
{
IC_CLASSIFY
,
VAT_CLASSIFY
,
MVC_CLASSIFY
,
MVI_CLASSIFY
,
UCI_CLASSIFY
}
LICENSE_CLASSIFY_SET_2
=
{
BL_CLASSIFY
,
EEP_CLASSIFY
,
DL_CLASSIFY
,
PP_CLASSIFY
,
BC_CLASSIFY
}
NYYH_CLASSIFY
=
{
17
,
18
}
MS_CLASSIFY
=
21
...
...
src/apps/doc/management/commands/license_statistics.py
View file @
236b64e
...
...
@@ -82,6 +82,8 @@ class Command(BaseCommand, LoggerMixin):
wb
=
Workbook
()
for
classify
,
(
_
,
name
,
_
,
_
,
_
,
_
)
in
consts
.
LICENSE_ORDER
:
if
classify
==
consts
.
DL_CLASSIFY
or
classify
==
consts
.
VAT_CLASSIFY
:
continue
ws
=
wb
.
create_sheet
(
name
)
headers
=
self
.
header_map
.
get
(
classify
,
[])
for
header
in
headers
:
...
...
@@ -96,9 +98,16 @@ class Command(BaseCommand, LoggerMixin):
business_type
,
doc_id_str
=
task_str
.
split
(
consts
.
SPLIT_STR
)
doc_id
=
int
(
doc_id_str
)
doc_class
=
HILDoc
if
business_type
==
consts
.
HIL_PREFIX
else
AFCDoc
application_id
=
doc_class
.
objects
.
filter
(
id
=
doc_id
)
.
values_list
(
'application_id'
,
flat
=
True
)
doc_queryset
=
doc_class
.
objects
.
filter
(
id
=
doc_id
)
.
values_list
(
'application_id'
,
'document_scheme'
)
if
len
(
doc_queryset
)
==
0
:
continue
application_id
,
document_scheme
=
doc_queryset
[
0
]
if
document_scheme
!=
consts
.
DOC_SCHEME_LIST
[
1
]:
continue
for
classify
,
(
_
,
name
,
field_order
,
side_diff
,
_
,
_
)
in
consts
.
LICENSE_ORDER
:
if
classify
==
consts
.
DL_CLASSIFY
or
classify
==
consts
.
VAT_CLASSIFY
:
continue
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
...
...
@@ -119,5 +128,5 @@ class Command(BaseCommand, LoggerMixin):
all_value
.
append
(
'
\n
'
.
join
(
field_value
))
else
:
all_value
.
append
(
field_value
)
ws
.
append
((
application_id
[
0
]
,
*
all_value
))
ws
.
append
((
application_id
,
*
all_value
))
wb
.
save
(
excel_path
)
...
...
src/apps/doc/ocr/wb.py
View file @
236b64e
...
...
@@ -103,6 +103,9 @@ class BSWorkbook(Workbook):
sheet_header_info
.
setdefault
(
ws
.
title
,
{})
.
setdefault
(
consts
.
HEADER_KEY
,
first_row
)
for
idx
,
header_value
in
enumerate
(
first_row
):
header_col
=
self
.
get_header_col
(
header_value
,
classify
)
if
classify
==
consts
.
MS_CLASSIFY
and
header_col
==
consts
.
OVER_KEY
and
\
header_value
==
'账户余额现转标志'
and
not
first_row
[
idx
-
1
]:
idx
-=
1
if
header_col
is
not
None
:
header_col_list
.
append
((
idx
,
header_col
))
...
...
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