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
d1c086a8
authored
2020-12-08 16:59:20 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
modify bs statistics
1 parent
c8a6639d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
src/apps/doc/management/commands/bs_statistics.py
src/apps/doc/management/commands/bs_statistics.py
View file @
d1c086a
...
...
@@ -8,6 +8,7 @@ from django.core.management import BaseCommand
from
settings
import
conf
from
common.mixins
import
LoggerMixin
from
apps.doc
import
consts
from
apps.doc.models
import
HILDoc
,
AFCDoc
class
Command
(
BaseCommand
,
LoggerMixin
):
...
...
@@ -40,17 +41,30 @@ class Command(BaseCommand, LoggerMixin):
print
(
'log_path not exists'
)
return
wb
=
Workbook
()
ws
=
wb
.
get_sheet_by_name
(
'Sheet'
)
ws
.
title
=
date_str
ws
.
append
((
'版式'
,
'数目'
))
summary_dict
=
{}
with
open
(
log_path
,
'r'
,
encoding
=
'utf-8'
)
as
fp
:
for
line
in
fp
:
search_obj
=
re
.
search
(
r'(\d{1,2}):(\d+)'
,
line
)
classify
=
search_obj
.
group
(
1
)
count
=
search_obj
.
group
(
2
)
label
=
consts
.
CLASSIFY_LIST
[
int
(
classify
)][
0
]
ws
.
append
((
label
,
int
(
count
)))
search_obj
=
re
.
search
(
r'task=(.*) merged_bs_summary=(.*)'
,
line
)
task_str
=
search_obj
.
group
(
1
)
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
)
bs_summary_str
=
search_obj
.
group
(
2
)
new_bs_summary_str
=
re
.
sub
(
r'datetime.date\(\d+, \d+, \d+\)'
,
'None'
,
bs_summary_str
)
bs_summary
=
ast
.
literal_eval
(
new_bs_summary_str
)
for
value_dict
in
bs_summary
.
values
():
classify
=
value_dict
.
get
(
'classify'
)
if
classify
is
None
:
continue
summary_dict
.
setdefault
(
classify
,
[])
.
append
(
application_id
[
0
])
wb
=
Workbook
()
wb
.
remove
(
wb
.
get_sheet_by_name
(
'Sheet'
))
for
classify
,
application_id_list
in
summary_dict
.
items
():
sheet_name
=
consts
.
CLASSIFY_LIST
[
classify
][
0
]
ws
=
wb
.
create_sheet
(
sheet_name
)
for
application_id
in
application_id_list
:
ws
.
append
((
application_id
,
None
))
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