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
15d73747
authored
2021-01-19 14:36:00 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
idcard script
1 parent
9e8023a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
28 deletions
src/apps/doc/management/commands/idcard_statistics.py
src/apps/doc/management/commands/idcard_statistics.py
View file @
15d7374
...
...
@@ -14,7 +14,7 @@ class Command(BaseCommand, LoggerMixin):
def
__init__
(
self
):
super
()
.
__init__
()
self
.
sheet_names
=
(
'AFC'
,
'HIL'
)
self
.
sheet_names
=
(
consts
.
AFC_PREFIX
,
consts
.
HIL_PREFIX
)
self
.
header
=
(
'申请号'
,
'身份证号'
,
'民族'
,
'时间戳'
)
def
add_arguments
(
self
,
parser
):
...
...
@@ -53,34 +53,28 @@ class Command(BaseCommand, LoggerMixin):
with
open
(
log_path
,
'r'
,
encoding
=
'utf-8'
)
as
fp
:
for
line
in
fp
:
search_obj
=
re
.
search
(
r'[(.*)] [task=(.*)] [idcard=(.*)]'
,
line
)
task_str
=
search_obj
.
group
(
1
)
license_summary
=
ast
.
literal_eval
(
search_obj
.
group
(
2
))
search_obj
=
re
.
match
(
r'\[(.*)] \[task=(.*)] \[idcard=(.*)]'
,
line
)
idcard_str
=
search_obj
.
group
(
3
)
idcard_list
=
ast
.
literal_eval
(
idcard_str
)
content_list
=
[]
for
idcard_dict
in
idcard_list
:
nation
=
idcard_dict
.
get
(
'民族'
)
if
nation
is
None
:
continue
if
idcard_dict
.
get
(
'类别'
)
==
'1'
:
continue
content_list
.
append
((
idcard_dict
.
get
(
'公民身份号码'
),
nation
))
if
len
(
content_list
)
==
0
:
continue
time_str
=
search_obj
.
group
(
1
)
task_str
=
search_obj
.
group
(
2
)
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
)
application_id
=
doc_class
.
objects
.
filter
(
id
=
int
(
doc_id_str
))
.
values_list
(
'application_id'
,
flat
=
True
)
ws
=
wb
.
get_sheet_by_name
(
business_type
)
for
id_num
,
nation
in
content_list
:
ws
.
append
((
application_id
[
0
],
id_num
,
nation
,
time_str
))
for
classify
,
(
_
,
name
,
field_order
,
side_diff
,
_
,
_
)
in
consts
.
LICENSE_ORDER
:
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
ws
=
wb
.
get_sheet_by_name
(
name
)
for
license_dict
in
license_list
:
if
classify
==
consts
.
IC_CLASSIFY
and
license_dict
.
get
(
'类别'
)
==
'1'
:
# 居住证处理
license_summary
.
setdefault
(
consts
.
RP_CLASSIFY
,
[])
.
append
(
license_dict
)
continue
if
side_diff
:
key
,
field_order_yes
,
field_order_no
=
consts
.
FIELD_ORDER_MAP
.
get
(
classify
)
field_order
=
field_order_yes
if
key
in
license_dict
else
field_order_no
all_value
=
[]
for
search_field
,
write_field
in
field_order
:
if
write_field
is
None
:
continue
field_value
=
license_dict
.
get
(
search_field
,
''
)
if
isinstance
(
field_value
,
list
):
all_value
.
append
(
'
\n
'
.
join
(
field_value
))
else
:
all_value
.
append
(
field_value
)
ws
.
append
((
application_id
[
0
],
*
all_value
))
wb
.
save
(
excel_path
)
...
...
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