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
7c6bee8a
authored
2020-11-01 16:13:03 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add configs table
1 parent
b300b5b7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
20 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/doc_ocr_process.py
src/apps/doc/models.py
src/apps/doc/ocr/edms.py
src/common/tools/mssql_script.py
src/settings/conf/prd.ini
src/settings/conf/sit.ini
src/settings/conf/uat.ini
src/apps/doc/consts.py
View file @
7c6bee8
...
...
@@ -35,7 +35,6 @@ DOC_SCHEMA_TYPE = 'ElectronicRecord'
APPLICATION_ID_META_FIELD_id
=
1
DEALER_CODE_META_FIELD_id
=
13
BUSINESS_TYPE_META_FIELD_id
=
93
DEALER_CODE
=
'ocr_situ_group'
RETRY_TIMES
=
3
...
...
@@ -48,12 +47,17 @@ TRANS_MAP = {
'o'
:
"0"
,
'O'
:
"0"
,
'D'
:
"0"
,
'U'
:
"0"
,
'n'
:
"0"
,
'['
:
"1"
,
']'
:
"1"
,
'l'
:
"1"
,
'L'
:
"1"
,
'z'
:
"2"
,
'Z'
:
"2"
,
'A'
:
"4"
,
's'
:
"5"
,
...
...
src/apps/doc/management/commands/doc_ocr_process.py
View file @
7c6bee8
...
...
@@ -37,7 +37,7 @@ class Command(BaseCommand, LoggerMixin):
self
.
ocr_url_2
=
conf
.
OCR_URL_2
self
.
ocr_url_3
=
conf
.
BC_URL
# EDMS web_service_api
self
.
edms
=
EDMS
(
conf
.
EDMS_USER
,
conf
.
EDMS_PWD
)
self
.
edms
=
EDMS
()
# 优雅退出信号:15
signal
.
signal
(
signal
.
SIGTERM
,
self
.
signal_handler
)
...
...
@@ -217,6 +217,7 @@ class Command(BaseCommand, LoggerMixin):
}
ocr_res_1
=
await
self
.
fetch_ocr_1_result
(
self
.
ocr_url_1
,
json_data_1
)
if
ocr_res_1
is
None
:
skip_img
.
append
(
self
.
parse_img_path
(
img_path
))
raise
Exception
(
'ocr 1 error, img_path={0}'
.
format
(
img_path
))
else
:
self
.
cronjob_log
.
info
(
'{0} [ocr_1 result] [img={1}] [res={2}]'
.
format
(
...
...
@@ -237,9 +238,9 @@ class Command(BaseCommand, LoggerMixin):
pid
,
_
,
_
,
_
,
_
=
consts
.
LICENSE_CLASSIFY_MAPPING
.
get
(
classify
)
json_data_2
=
{
"pid"
:
str
(
pid
),
"key"
:
conf
.
OCR_KEY
,
"secret"
:
conf
.
OCR_SECRET
,
"file"
:
file_data
#
"key": conf.OCR_KEY,
#
"secret": conf.OCR_SECRET,
"file
data
"
:
file_data
}
ocr_res_2
=
await
self
.
fetch_ocr_2_result
(
self
.
ocr_url_2
,
json_data_2
)
if
ocr_res_2
is
None
:
...
...
@@ -364,7 +365,9 @@ class Command(BaseCommand, LoggerMixin):
@staticmethod
def
parse_img_path
(
img_path
):
img_name
,
_
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
img_path
))
return
int
(
img_name
[
5
])
+
1
,
int
(
img_name
[
11
])
+
1
part_list
=
img_name
.
split
(
'_'
)
# page_7_img_11_0
return
int
(
part_list
[
1
])
+
1
,
int
(
part_list
[
3
])
+
1
@staticmethod
def
get_most
(
value_list
):
...
...
src/apps/doc/models.py
View file @
7c6bee8
...
...
@@ -122,3 +122,16 @@ class Keywords(models.Model):
verbose_name
=
'银行流水关键词'
verbose_name_plural
=
verbose_name
class
Configs
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
value
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
"配置值"
)
comment
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"说明"
)
class
Meta
:
managed
=
False
situ_db_label
=
'afc'
db_table
=
'configs'
verbose_name
=
'配置信息'
verbose_name_plural
=
verbose_name
...
...
src/apps/doc/ocr/edms.py
View file @
7c6bee8
...
...
@@ -8,15 +8,17 @@ from common.redis_cache import redis_handler as rh
class
EDMS
:
def
__init__
(
self
,
user_name
,
pwd
):
def
__init__
(
self
):
self
.
sm_client
=
Client
(
wsdl
=
conf
.
SM_WSDL
)
self
.
dm_client
=
Client
(
wsdl
=
conf
.
DM_WSDL
)
self
.
df_client
=
Client
(
wsdl
=
conf
.
DF_WSDL
)
self
.
rc_client
=
Client
(
wsdl
=
conf
.
RC_WSDL
)
self
.
download_url
=
conf
.
EDMS_DOWNLOAD_URL
self
.
upload_url
=
conf
.
EDMS_UPLOAD_URL
self
.
user_name
=
user_name
self
.
pwd
=
pwd
self
.
dealer_code
=
conf
.
DEALER_CODE
self
.
user_name
=
conf
.
EDMS_USER
self
.
pwd
=
conf
.
EDMS_PWD
self
.
session_id
=
None
def
set_session_id
(
self
):
...
...
@@ -98,7 +100,7 @@ class EDMS:
{
'FieldId'
:
consts
.
APPLICATION_ID_META_FIELD_id
,
'FieldValue'
:
xsd
.
AnyObject
(
xsd
.
String
(),
application_id
)},
{
'FieldId'
:
consts
.
DEALER_CODE_META_FIELD_id
,
'FieldValue'
:
xsd
.
AnyObject
(
xsd
.
String
(),
consts
.
DEALER_CODE
)},
'FieldValue'
:
xsd
.
AnyObject
(
xsd
.
String
(),
self
.
dealer_code
)},
{
'FieldId'
:
consts
.
BUSINESS_TYPE_META_FIELD_id
,
'FieldValue'
:
xsd
.
AnyObject
(
xsd
.
String
(),
business_type
)},
]
...
...
src/common/tools/mssql_script.py
View file @
7c6bee8
...
...
@@ -335,7 +335,9 @@ hil_sql_2 = """
create index hil_doc_application_id_status_index
on hil_doc (application_id, status);
"""
afc_sql
=
"""
create table upload_doc_records
(
id int identity
...
...
@@ -357,10 +359,8 @@ hil_sql_2 = """
create unique index upload_doc_records_metadata_version_id_uindex
on upload_doc_records (metadata_version_id);
"""
afc_sql
=
"""
create table keywords
create table keywords
(
id int identity primary key,
keyword nvarchar(64) not null,
...
...
@@ -369,6 +369,13 @@ create table keywords
update_time datetime not null,
create_time datetime not null
);
create table configs
(
id int identity primary key,
value nvarchar(255) not null,
comment nvarchar(64) not null,
);
create table priority_application
(
...
...
@@ -429,7 +436,7 @@ create table keywords
on afc_doc (application_id, status);
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=hil;UID=SA;PWD=
19951019Mssql
'
,
autocommit
=
True
)
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=hil;UID=SA;PWD=
pwd
'
,
autocommit
=
True
)
hil_cursor
=
hil_cnxn
.
cursor
()
hil_cursor
.
execute
(
hil_sql_1
)
...
...
@@ -438,7 +445,7 @@ hil_cursor.execute(hil_sql_2)
hil_cursor
.
close
()
hil_cnxn
.
close
()
afc_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=afc;UID=SA;PWD=
19951019Mssql
'
,
autocommit
=
True
)
afc_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=afc;UID=SA;PWD=
pwd
'
,
autocommit
=
True
)
afc_cursor
=
afc_cnxn
.
cursor
()
afc_cursor
.
execute
(
afc_sql
)
...
...
src/settings/conf/prd.ini
View file @
7c6bee8
...
...
@@ -4,4 +4,6 @@ SLEEP_SECOND = 5
MAX_SLEEP_SECOND
=
60
EDMS_DOWNLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx
EDMS_UPLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
\ No newline at end of file
EDMS_UPLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
\
DEALER_CODE = ocr_situ_group
...
...
src/settings/conf/sit.ini
View file @
7c6bee8
...
...
@@ -4,4 +4,5 @@ SLEEP_SECOND = 5
MAX_SLEEP_SECOND
=
60
EDMS_DOWNLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx
EDMS_UPLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
\ No newline at end of file
EDMS_UPLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
DEALER_CODE
=
ocr_situ_group
\ No newline at end of file
...
...
src/settings/conf/uat.ini
View file @
7c6bee8
...
...
@@ -4,4 +4,5 @@ SLEEP_SECOND = 5
MAX_SLEEP_SECOND
=
60
EDMS_DOWNLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx
EDMS_UPLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
\ No newline at end of file
EDMS_UPLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
DEALER_CODE
=
ocr_situ_group
\ No newline at end of file
...
...
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