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
fdc07b8c
authored
2022-01-07 16:23:30 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add auto
1 parent
ae762243
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
188 additions
and
7 deletions
src/apps/doc/consts.py
src/apps/doc/models.py
src/apps/doc/named_enum.py
src/apps/doc/views.py
src/celery_compare/tasks.py
src/common/tools/mssql_script14.py
src/apps/doc/consts.py
View file @
fdc07b8
...
...
@@ -2199,3 +2199,17 @@ HIL_CONTRACT_TYPE_MAP = {
str
(
HIL_CONTRACT_2_CLASSIFY
):
2
,
str
(
HIL_CONTRACT_3_CLASSIFY
):
1
,
}
RESULT_MAP
=
{
0
:
None
,
1
:
True
,
2
:
False
}
RPA_RESULT_MAP
=
{
0
:
None
,
1
:
1
,
2
:
2
,
3
:
3
,
}
...
...
src/apps/doc/models.py
View file @
fdc07b8
...
...
@@ -823,16 +823,17 @@ class HILAutoSettlement(models.Model):
rpa_2nd_eye_tat
=
models
.
DecimalField
(
max_digits
=
18
,
decimal_places
=
0
,
null
=
True
,
verbose_name
=
'rpa_2nd_eye_tat'
)
rpa_3rd_eye_tat
=
models
.
DecimalField
(
max_digits
=
18
,
decimal_places
=
0
,
null
=
True
,
verbose_name
=
'rpa_3rd_eye_tat'
)
rpa_total_tat
=
models
.
DecimalField
(
max_digits
=
18
,
decimal_places
=
0
,
null
=
True
,
verbose_name
=
'rpa_total_tat'
)
rpa_activated_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_activated_time'
)
rpa_get_case_from_ocr_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_get_case_from_ocr_time'
)
rpa_activated_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_activated_time'
)
# 索引
rpa_get_case_from_ocr_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_get_case_from_ocr_time'
)
# 索引
rpa_get_case_from_oc_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_get_case_from_oc_time'
)
rpa_payment_authorize_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_payment_authorize_time'
)
rpa_second_eye_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_second_eye_time'
)
on_off
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否有效"
)
ocr_auto_result_pass
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"整体结果"
)
ocr_auto_result_pass
=
models
.
BooleanField
(
null
=
True
,
verbose_name
=
"auto结果"
)
ocr_whole_result_pass
=
models
.
BooleanField
(
null
=
True
,
verbose_name
=
"整体结果"
)
ocr_auto_result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"auto比对结果"
)
ocr_latest_comparison_time
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
,
verbose_name
=
'最新比对时间'
)
ocr_latest_comparison_time
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
,
verbose_name
=
'最新比对时间'
)
# 索引
update_time
=
models
.
DateTimeField
(
auto_now
=
False
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
src/apps/doc/named_enum.py
View file @
fdc07b8
...
...
@@ -66,3 +66,20 @@ class ErrorType(NamedEnum):
IMAGE
=
(
3
,
'图片问题'
)
OTHER
=
(
4
,
'其他'
)
class
AutoResult
(
NamedEnum
):
Y
=
(
1
,
'Y'
)
N
=
(
2
,
'N'
)
NULL
=
(
0
,
'NULL'
)
class
WholeResult
(
NamedEnum
):
Y
=
(
1
,
'Y'
)
N
=
(
2
,
'N'
)
NULL
=
(
0
,
'NULL'
)
class
RPAResult
(
NamedEnum
):
SUCCESS
=
(
1
,
'success'
)
ERROR1
=
(
2
,
'business error'
)
ERROR2
=
(
3
,
'system error'
)
NULL
=
(
0
,
'null'
)
...
...
src/apps/doc/views.py
View file @
fdc07b8
...
...
@@ -40,7 +40,7 @@ from .models import (
HILAutoSettlement
,
AFCAutoSettlement
,
)
from
.named_enum
import
ErrorType
from
.named_enum
import
ErrorType
,
AutoResult
,
WholeResult
,
RPAResult
from
.mixins
import
DocHandler
from
.
import
consts
from
apps.account.authentication
import
OAuth2AuthenticationWithUser
...
...
@@ -282,6 +282,29 @@ doc_list_args = {
'create_time_end'
:
fields
.
Date
(
required
=
False
),
}
auto_list_args
=
{
'page'
:
fields
.
Int
(
required
=
False
,
missing
=
consts
.
PAGE_DEFAULT
,
validate
=
lambda
val
:
val
>=
1
),
'page_size'
:
fields
.
Int
(
required
=
False
,
missing
=
consts
.
PAGE_SIZE_DEFAULT
,
validate
=
lambda
val
:
val
>=
1
),
'business_type'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
BUSINESS_TYPE_LIST
)),
'application_id'
:
fields
.
Str
(
required
=
False
,
validate
=
validate
.
Length
(
max
=
64
)),
'auto_result'
:
fields
.
Int
(
required
=
False
,
validate
=
validate
.
OneOf
(
AutoResult
.
get_value_lst
())),
'whole_result'
:
fields
.
Int
(
required
=
False
,
validate
=
validate
.
OneOf
(
WholeResult
.
get_value_lst
())),
'rpa_result'
:
fields
.
Int
(
required
=
False
,
validate
=
validate
.
OneOf
(
RPAResult
.
get_value_lst
())),
'get_case_from_ocr_time_start'
:
fields
.
Date
(
required
=
False
),
'get_case_from_ocr_time_end'
:
fields
.
Date
(
required
=
False
),
'activated_time_start'
:
fields
.
Date
(
required
=
False
),
'activated_time_end'
:
fields
.
Date
(
required
=
False
),
'comparison_time_start'
:
fields
.
Date
(
required
=
False
),
'comparison_time_end'
:
fields
.
Date
(
required
=
False
),
}
compare_result_args
=
{
'entity'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
BUSINESS_TYPE_LIST
)),
'scheme'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
COMPARE_DOC_SCHEME_LIST
)),
...
...
@@ -1180,9 +1203,18 @@ class ResourcesView(GenericView):
def
get
(
self
,
request
):
error_type_map
=
ErrorType
.
get_mappings
()
auto_result_map
=
AutoResult
.
get_mappings
()
whole_result_map
=
WholeResult
.
get_mappings
()
rpa_result_map
=
RPAResult
.
get_mappings
()
error_type
=
[{
'label'
:
v
,
'value'
:
k
}
for
k
,
v
in
error_type_map
.
items
()]
auto_result
=
[{
'label'
:
v
,
'value'
:
k
}
for
k
,
v
in
auto_result_map
.
items
()]
whole_result
=
[{
'label'
:
v
,
'value'
:
k
}
for
k
,
v
in
whole_result_map
.
items
()]
rpa_result
=
[{
'label'
:
v
,
'value'
:
k
}
for
k
,
v
in
rpa_result_map
.
items
()]
resources
=
{
'error_type'
:
error_type
'error_type'
:
error_type
,
'auto_result'
:
auto_result
,
'whole_result'
:
whole_result
,
'rpa_result'
:
rpa_result
}
return
response
.
ok
(
data
=
resources
)
...
...
@@ -1247,3 +1279,75 @@ class SEContractView(GenericView):
# forwarding_station.apply_async((application_id, entity), queue='queue_compare', countdown=conf.DELAY_SECONDS)
self
.
running_log
.
info
(
'[e-contract pos in] [args={0}]'
.
format
(
args
))
return
response
.
ok
()
class
AutoSettlementView
(
GenericView
):
permission_classes
=
[]
authentication_classes
=
[]
# permission_classes = [IsAuthenticated]
# authentication_classes = [OAuth2AuthenticationWithUser]
# 获取比对结果
@use_args
(
auto_list_args
,
location
=
'querystring'
)
def
get
(
self
,
request
,
args
):
page
=
args
.
get
(
'page'
,
consts
.
PAGE_DEFAULT
)
page_size
=
args
.
get
(
'page_size'
,
consts
.
PAGE_SIZE_DEFAULT
)
business_type
=
args
.
get
(
'business_type'
)
application_id
=
args
.
get
(
'application_id'
)
get_case_from_ocr_time_start
=
args
.
get
(
'get_case_from_ocr_time_start'
)
get_case_from_ocr_time_end
=
args
.
get
(
'get_case_from_ocr_time_end'
)
activated_time_start
=
args
.
get
(
'activated_time_start'
)
activated_time_end
=
args
.
get
(
'activated_time_end'
)
comparison_time_start
=
args
.
get
(
'comparison_time_start'
)
comparison_time_end
=
args
.
get
(
'comparison_time_end'
)
auto_result
=
args
.
get
(
'auto_result'
,
''
)
whole_result
=
args
.
get
(
'whole_result'
,
''
)
rpa_result
=
args
.
get
(
'rpa_result'
,
''
)
if
isinstance
(
auto_result
,
int
):
auto_result
=
consts
.
RESULT_MAP
.
get
(
auto_result
)
if
isinstance
(
whole_result
,
int
):
whole_result
=
consts
.
RESULT_MAP
.
get
(
whole_result
)
if
isinstance
(
rpa_result
,
int
):
rpa_result
=
consts
.
RPA_RESULT_MAP
.
get
(
rpa_result
)
application_id_query
=
Q
(
application_id__contains
=
application_id
)
if
application_id
is
not
None
else
Q
()
auto_result_query
=
Q
(
ocr_auto_result_pass
=
auto_result
)
if
not
isinstance
(
auto_result
,
str
)
else
Q
()
whole_result_query
=
Q
(
ocr_whole_result_pass
=
whole_result
)
if
not
isinstance
(
whole_result
,
str
)
else
Q
()
rpa_result_query
=
Q
(
rpa_result
=
rpa_result
)
if
not
isinstance
(
rpa_result
,
str
)
else
Q
()
time1_query
=
Q
(
rpa_get_case_from_ocr_time__gte
=
get_case_from_ocr_time_start
,
rpa_get_case_from_ocr_time__lt
=
get_case_from_ocr_time_end
+
datetime
.
timedelta
(
days
=
1
))
\
if
get_case_from_ocr_time_start
is
not
None
and
get_case_from_ocr_time_end
is
not
None
else
Q
()
time2_query
=
Q
(
rpa_activated_time__gte
=
activated_time_start
,
rpa_activated_time__lt
=
activated_time_end
+
datetime
.
timedelta
(
days
=
1
))
\
if
activated_time_start
is
not
None
and
activated_time_end
is
not
None
else
Q
()
time3_query
=
Q
(
ocr_latest_comparison_time__gte
=
comparison_time_start
,
ocr_latest_comparison_time__lt
=
comparison_time_end
+
datetime
.
timedelta
(
days
=
1
))
\
if
comparison_time_start
is
not
None
and
comparison_time_end
is
not
None
else
Q
()
query
=
application_id_query
&
auto_result_query
&
whole_result_query
&
rpa_result_query
\
&
time1_query
&
time2_query
&
time3_query
auto_class
=
HILAutoSettlement
if
business_type
in
consts
.
HIL_SET
else
AFCAutoSettlement
total
=
auto_class
.
objects
.
filter
(
query
)
.
count
()
start_index
=
page_size
*
(
page
-
1
)
end_index
=
page_size
*
page
if
start_index
>=
total
>
0
:
raise
self
.
invalid_params
(
'页数不存在'
)
val_tuple
=
(
'application_id'
,
'ocr_latest_comparison_time'
,
'ocr_auto_result_pass'
,
'ocr_whole_result_pass'
,
'rpa_result'
,
'rpa_activated_time'
,
'rpa_get_case_from_ocr_time'
)
auto_queryset
=
auto_class
.
objects
.
filter
(
query
)
.
values
(
*
val_tuple
)
.
order_by
(
'-ocr_latest_comparison_time'
)[
start_index
:
end_index
]
# total = len(doc_list)
pagination
=
{
'current'
:
page
,
'total'
:
total
,
'page_size'
:
page_size
}
res
=
{
'pagination'
:
pagination
,
'auto_list'
:
list
(
auto_queryset
)
}
self
.
running_log
.
info
(
'[get auto list] [args={0}] [res={1}]'
.
format
(
args
,
res
))
return
response
.
ok
(
data
=
res
)
...
...
src/celery_compare/tasks.py
View file @
fdc07b8
...
...
@@ -1374,7 +1374,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
license_dict
=
{}
customer_name
=
individual_info
.
get
(
'name'
,
''
)
customer_name
=
individual_info
.
get
(
'name'
,
''
)
.
strip
()
legal_name
=
individual_info
.
get
(
'legalRepName'
,
''
)
establishment_date
=
individual_info
.
get
(
'establishmentDate'
,
''
)
# date_of_birth = individual_info.get('dateOfBirth', '')
...
...
src/common/tools/mssql_script14.py
0 → 100644
View file @
fdc07b8
import
pyodbc
hil_sql
=
"""
ALTER TABLE hil_auto_settlement ADD ocr_whole_result_pass bit;
ALTER TABLE hil_auto_settlement ALTER COLUMN ocr_auto_result_pass bit;
create index hil_auto_settlement_rpa_activated_time_index
on hil_auto_settlement (rpa_activated_time);
create index hil_auto_settlement_rpa_get_case_from_ocr_time_index
on hil_auto_settlement (rpa_get_case_from_ocr_time);
create index hil_auto_settlement_ocr_latest_comparison_time_index
on hil_auto_settlement (ocr_latest_comparison_time);
"""
afc_sql
=
"""
ALTER TABLE afc_auto_settlement ADD ocr_whole_result_pass bit;
ALTER TABLE afc_auto_settlement ALTER COLUMN ocr_auto_result_pass bit;
create index afc_auto_settlement_rpa_activated_time_index
on afc_auto_settlement (rpa_activated_time);
create index afc_auto_settlement_rpa_get_case_from_ocr_time_index
on afc_auto_settlement (rpa_get_case_from_ocr_time);
create index afc_auto_settlement_ocr_latest_comparison_time_index
on afc_auto_settlement (ocr_latest_comparison_time);
"""
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