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
45e2bd71
authored
2021-07-28 18:51:52 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
result get
1 parent
906f258d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
34 deletions
src/apps/doc/models.py
src/apps/doc/views.py
src/common/tools/mssql_script7.py
src/apps/doc/models.py
View file @
45e2bd7
...
...
@@ -585,6 +585,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
=
"比对结果"
)
version
=
models
.
CharField
(
max_length
=
8
,
verbose_name
=
"POS/CMS version"
)
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 @
45e2bd7
...
...
@@ -768,41 +768,57 @@ class CompareResultView(GenericView):
result_table
=
AFCCACompareResult
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
AFCSECompareResult
if
result_id
is
not
None
:
result_
str_list
=
result_table
.
objects
.
filter
(
id
=
result_id
)
.
values_list
(
'result'
,
flat
=
True
)
result_
obj
=
result_table
.
objects
.
filter
(
id
=
result_id
)
.
first
(
)
else
:
result_
str_list
=
result_table
.
objects
.
filter
(
application_id
=
case_id
)
.
values_list
(
'result'
,
flat
=
True
)
result_
obj
=
result_table
.
objects
.
filter
(
application_id
=
case_id
)
.
first
(
)
if
len
(
result_str_list
)
==
0
:
compare_result_list
=
[]
if
result_obj
is
None
:
whole_result
=
''
else
:
compare_result_list
=
json
.
loads
(
result_str_list
[
0
])
whole_result
=
'Y'
if
result_obj
.
is_finish
else
'N'
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
,
'result'
:
[]
if
result_obj
is
None
else
json
.
loads
(
result_obj
.
result
)
}
return
response
.
ok
(
data
=
compare_result
)
# if len(result_str_list) == 0:
# compare_result_list = []
# else:
# compare_result_list = json.loads(result_str_list[0])
#
# if len(compare_result_list) == 0:
# body_html = "<h1>没有比对结果</h1>"
# else:
# head_content = ''.join(['<th>{0}</th>'.format(head_name) for head_name in consts.HEAD_LIST])
# head_html = '<tr>{0}</tr>'.format(head_content)
# row_html_list = []
# for row_dict in compare_result_list:
# row_list = [row_dict.get(head, '') for head in consts.HEAD_LIST]
# row_content = ''.join(['<td>{0}</td>'.format(row_str) for row_str in row_list])
# row_html = '<tr>{0}</tr>'.format(row_content)
# row_html_list.append(row_html)
# content_html = ''.join(row_html_list)
# body_html = '<table border="1">{0}{1}</table>'.format(head_html, content_html)
#
# html = """
# <!DOCTYPE html>
# <html>
# <head>
# <meta charset="utf-8">
# <title>比对结果</title>
# </head>
# <body>
# {0}
# </body>
# </html>
# """.format(body_html)
# return HttpResponse(html)
if
len
(
compare_result_list
)
==
0
:
body_html
=
"<h1>没有比对结果</h1>"
else
:
head_content
=
''
.
join
([
'<th>{0}</th>'
.
format
(
head_name
)
for
head_name
in
consts
.
HEAD_LIST
])
head_html
=
'<tr>{0}</tr>'
.
format
(
head_content
)
row_html_list
=
[]
for
row_dict
in
compare_result_list
:
row_list
=
[
row_dict
.
get
(
head
,
''
)
for
head
in
consts
.
HEAD_LIST
]
row_content
=
''
.
join
([
'<td>{0}</td>'
.
format
(
row_str
)
for
row_str
in
row_list
])
row_html
=
'<tr>{0}</tr>'
.
format
(
row_content
)
row_html_list
.
append
(
row_html
)
content_html
=
''
.
join
(
row_html_list
)
body_html
=
'<table border="1">{0}{1}</table>'
.
format
(
head_html
,
content_html
)
html
=
"""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>比对结果</title>
</head>
<body>
{0}
</body>
</html>
"""
.
format
(
body_html
)
return
HttpResponse
(
html
)
# return response.ok(data=compare_result)
...
...
src/common/tools/mssql_script7.py
0 → 100644
View file @
45e2bd7
import
pyodbc
hil_sql
=
"ALTER TABLE hil_ocr_report ADD notes nvarchar(2048)"
afc_sql
=
"ALTER TABLE afc_ocr_report ADD notes nvarchar(2048)"
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