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
254938ba
authored
2021-08-18 14:41:14 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add update interface
1 parent
cc3a4534
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
7 deletions
src/apps/doc/consts.py
src/apps/doc/models.py
src/apps/doc/views.py
src/celery_compare/tasks.py
src/common/response.py
src/common/tools/mssql_script7.py
src/apps/doc/consts.py
View file @
254938b
...
...
@@ -1450,4 +1450,6 @@ HEAD_LIST = ['Info', 'Index', 'License', 'Field', 'Input', 'OCR', 'Result', 'Pos
IMG_PATH_KEY
=
'uniq_img_path_key'
INFO_SOURCE
=
[
'POS'
,
'CMS'
]
...
...
src/apps/doc/models.py
View file @
254938b
...
...
@@ -560,6 +560,7 @@ class AFCSECompareResult(models.Model):
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
# 索引
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
@@ -587,6 +588,7 @@ class AFCCACompareResult(models.Model):
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
# 索引
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
@@ -614,6 +616,7 @@ class HILSECompareResult(models.Model):
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
# 索引
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
@@ -640,6 +643,7 @@ class HILCACompareResult(models.Model):
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
# 索引
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
src/apps/doc/views.py
View file @
254938b
...
...
@@ -778,13 +778,20 @@ class CompareResultView(GenericView):
else
:
whole_result
=
'Y'
if
result_obj
.
is_finish
else
'N'
if
result_obj
is
None
or
result_obj
.
comments
is
None
:
comments
=
''
else
:
comments
=
result_obj
.
comments
compare_result
=
{
'id'
:
0
if
result_obj
is
None
else
result_obj
.
id
,
'application_id'
:
case_id
,
'scheme'
:
consts
.
DOC_SCHEME_LIST
[
0
]
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
consts
.
DOC_SCHEME_LIST
[
1
],
'whole_result'
:
whole_result
,
'update_time'
:
''
if
result_obj
is
None
else
result_obj
.
update_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
'version'
:
''
if
result_obj
is
None
else
result_obj
.
version
,
'latest_compared_time'
:
''
if
result_obj
is
None
else
result_obj
.
update_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
'source'
:
''
if
result_obj
is
None
else
result_obj
.
version
.
split
(
consts
.
SPLIT_STR
)[
0
],
'version'
:
''
if
result_obj
is
None
else
result_obj
.
version
.
split
(
consts
.
SPLIT_STR
)[
1
],
'comments'
:
comments
,
'result'
:
[]
if
result_obj
is
None
else
json
.
loads
(
result_obj
.
result
)
}
...
...
@@ -823,6 +830,53 @@ class CompareResultView(GenericView):
# """.format(body_html)
# return HttpResponse(html)
# 比对结果更新
# @use_args(result_update_args, location='data')
def
post
(
self
,
request
):
tmp_flag
=
random
.
choice
([
0
,
1
])
if
tmp_flag
==
0
:
return
response
.
ok
()
else
:
result_id
=
None
entity
=
"AFC"
scheme
=
'SE'
case_id
=
'CH-S1120929121'
if
entity
==
consts
.
HIL_PREFIX
:
result_table
=
HILCACompareResult
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
HILSECompareResult
else
:
result_table
=
AFCCACompareResult
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
AFCSECompareResult
if
result_id
is
not
None
:
result_obj
=
result_table
.
objects
.
filter
(
id
=
result_id
)
.
first
()
else
:
result_obj
=
result_table
.
objects
.
filter
(
application_id
=
case_id
)
.
first
()
if
result_obj
is
None
:
whole_result
=
''
else
:
whole_result
=
'Y'
if
result_obj
.
is_finish
else
'N'
if
result_obj
is
None
or
result_obj
.
comments
is
None
:
comments
=
''
else
:
comments
=
result_obj
.
comments
compare_result
=
{
'id'
:
0
if
result_obj
is
None
else
result_obj
.
id
,
'application_id'
:
case_id
,
'scheme'
:
consts
.
DOC_SCHEME_LIST
[
0
]
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
consts
.
DOC_SCHEME_LIST
[
1
],
'whole_result'
:
whole_result
,
'latest_compared_time'
:
''
if
result_obj
is
None
else
result_obj
.
update_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
'source'
:
''
if
result_obj
is
None
else
result_obj
.
version
.
split
(
consts
.
SPLIT_STR
)[
0
],
'version'
:
''
if
result_obj
is
None
else
result_obj
.
version
.
split
(
consts
.
SPLIT_STR
)[
1
],
'comments'
:
comments
,
'result'
:
[]
if
result_obj
is
None
else
json
.
loads
(
result_obj
.
result
)
}
return
response
.
need_update
(
data
=
compare_result
)
class
ResourcesView
(
GenericView
):
permission_classes
=
[]
...
...
src/celery_compare/tasks.py
View file @
254938b
...
...
@@ -846,7 +846,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
res_obj
.
compare_count
=
total_fields
res_obj
.
failed_count
=
failed_count
res_obj
.
is_finish
=
failed_count
==
0
res_obj
.
version
=
'
POS-{0}'
.
format
(
last_obj
.
application_version
)
res_obj
.
version
=
'
{0}{1}{2}'
.
format
(
consts
.
INFO_SOURCE
[
0
],
consts
.
SPLIT_STR
,
last_obj
.
application_version
)
# res_obj.reason1_count = reason1_count
res_obj
.
result
=
json
.
dumps
(
compare_result
)
res_obj
.
save
()
...
...
src/common/response.py
View file @
254938b
...
...
@@ -20,6 +20,7 @@ class MetaStatus(NamedEnum):
ASYNC_WAIT
=
(
5
,
'async wait'
)
NO_PERMISSION
=
(
6
,
'no permission'
)
ILLEGAL_OPERATION
=
(
7
,
'illegal operation'
)
NEED_UPDATE
=
(
8
,
'need update'
)
class
APIResponse
(
JsonResponse
):
...
...
@@ -32,3 +33,7 @@ class APIResponse(JsonResponse):
def
ok
(
**
kwargs
):
return
APIResponse
(
MetaStatus
.
SUCCESS
.
value
,
msg
=
MetaStatus
.
SUCCESS
.
verbose_name
,
**
kwargs
)
def
need_update
(
**
kwargs
):
return
APIResponse
(
MetaStatus
.
NEED_UPDATE
.
value
,
msg
=
MetaStatus
.
NEED_UPDATE
.
verbose_name
,
**
kwargs
)
...
...
src/common/tools/mssql_script7.py
View file @
254938b
import
pyodbc
hil_sql
=
"""
ALTER TABLE hil_ca_compare_result ADD version nvarchar(8);
ALTER TABLE hil_se_compare_result ADD version nvarchar(8);
ALTER TABLE hil_ca_compare_result ADD version nvarchar(8)
, comments nvarchar(max)
;
ALTER TABLE hil_se_compare_result ADD version nvarchar(8)
, comments nvarchar(max)
;
"""
afc_sql
=
"""
ALTER TABLE afc_ca_compare_result ADD version nvarchar(8);
ALTER TABLE afc_se_compare_result ADD version nvarchar(8);
ALTER TABLE afc_ca_compare_result ADD version nvarchar(8)
, comments nvarchar(max)
;
ALTER TABLE afc_se_compare_result ADD version nvarchar(8)
, comments nvarchar(max)
;
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
...
...
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