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
7aa0284c
authored
2020-07-21 20:00:02 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
eDMS add doc info
1 parent
1c0f538f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
9 deletions
src/apps/doc/consts.py
src/apps/doc/edms.py
src/apps/doc/management/commands/doc_process.py
wsdl/DocumentManager.wsdl
src/apps/doc/consts.py
View file @
7aa0284
...
...
@@ -13,3 +13,14 @@ CUSTOM_CLIENT = 'CustomClient'
FIXED_TOKEN
=
'00000000-0000-0000-0000-000000000000'
FIXED_FILE_SIZE
=
0
DOWNLOAD_ACTION_TYPE
=
'Downloaded'
DOC_SCHEMA_ID_FILL
=
{
'Acceptance'
:
(
1
,
'DFE-AutoFilingScript'
),
'Settlement'
:
(
20
,
'DFE-AutoFilingScript'
),
'Contract Management'
:
(
86
,
'Schema-Based'
)
}
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'
...
...
src/apps/doc/edms.py
View file @
7aa0284
import
requests
from
zeep
import
Client
from
zeep
import
Client
,
xsd
from
settings
import
conf
from
.
import
consts
from
common.redis_cache
import
redis_handler
as
rh
...
...
@@ -80,18 +80,54 @@ class EDMS:
else
:
raise
Exception
def
add_doc_info
(
self
,
headers
,
token
,
app_info
):
def
get_doc_info
(
self
,
token
,
doc_info
):
doc_schema_id
,
auto_filing
=
consts
.
DOC_SCHEMA_ID_FILL
.
get
(
doc_info
.
get
(
'document_scheme'
))
application_id
=
doc_info
.
get
(
'application_id'
)
doc_file_name
=
doc_info
.
get
(
'doc_file_name'
)
business_type
=
doc_info
.
get
(
'business_type'
)
fields_with_value
=
[
{
'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
)},
{
'FieldId'
:
consts
.
BUSINESS_TYPE_META_FIELD_id
,
'FieldValue'
:
xsd
.
AnyObject
(
xsd
.
String
(),
business_type
)},
]
fields_with_values
=
{
'FieldWithValue'
:
fields_with_value
}
info
=
{
'DocumentSchemaId'
:
doc_schema_id
,
'DocumentName'
:
doc_file_name
,
'FieldsWithValues'
:
fields_with_values
,
'UploadToken'
:
token
,
'OriginalFileName'
:
doc_file_name
,
'SendEmailToMembers'
:
False
,
'AutoFilingScriptToUse'
:
auto_filing
,
'DocumentSchemaType'
:
consts
.
DOC_SCHEMA_TYPE
,
}
return
info
def
add_doc_info
(
self
,
headers
,
token
,
doc_info
):
info
=
self
.
get_doc_info
(
token
,
doc_info
)
with
self
.
dm_client
.
settings
(
extra_http_headers
=
headers
):
res
=
self
.
dm_client
.
service
.
AddDocumentInfo
(
)
return
res
metadata_version_id
=
self
.
dm_client
.
service
.
AddDocumentInfo
(
info
=
info
)
return
metadata_version_id
def
upload
(
self
,
file_path
,
file_size
,
app_info
):
def
upload
(
self
,
file_path
,
file_size
,
doc_info
):
# file_path = '/Users/clay/Postman/files/OCRuploadTest4.txt'
# file_size = 16
# doc_info = {
# 'document_scheme': 'Acceptance',
# 'application_id': 'CH-B100014248',
# 'doc_file_name': 'OCRuploadTest4.txt',
# 'business_type': 'CO00001',
# }
headers
=
self
.
get_headers
()
token
=
self
.
create_upload_token
(
headers
,
file_size
)
headers
.
update
({
'Content-Type'
:
'application/octet-stream'
})
params
=
{
'token'
:
token
}
self
.
upload_handler
(
file_path
,
params
,
headers
)
headers
.
pop
(
'Content-Type'
)
self
.
add_doc_info
(
headers
,
token
,
app_info
)
metadata_version_id
=
self
.
add_doc_info
(
headers
,
token
,
doc_info
)
return
metadata_version_id
...
...
src/apps/doc/management/commands/doc_process.py
View file @
7aa0284
...
...
@@ -56,7 +56,7 @@ class Command(BaseCommand, LoggerMixin):
doc_id
=
int
(
doc_id_str
)
doc_class
=
HILDoc
if
business_type
==
consts
.
HIL_PREFIX
else
AFCDoc
doc_info
=
doc_class
.
objects
.
filter
(
id
=
doc_id
,
status
=
DocStatus
.
INIT
.
value
)
.
values
(
'id'
,
'metadata_version_id'
,
'application_id'
,
'document_name'
)
.
first
()
'id'
,
'metadata_version_id'
,
'application_id'
,
'document_name'
,
'document_scheme'
)
.
first
()
if
doc_info
is
None
:
self
.
cronjob_log
.
warn
(
'{0} [get_doc_info] [doc completed] [task_str={1}] [is_priority={2}]'
.
format
(
self
.
log_base
,
task_str
,
is_priority
))
...
...
wsdl/DocumentManager.wsdl
View file @
7aa0284
...
...
@@ -701,13 +701,13 @@
</s:element>
<s:complexType
name=
"DocumentInfo"
>
<s:sequence>
<s:element
minOccurs=
"
1
"
maxOccurs=
"1"
name=
"FolderId"
type=
"s:int"
/>
<s:element
minOccurs=
"
0
"
maxOccurs=
"1"
name=
"FolderId"
type=
"s:int"
/>
<s:element
minOccurs=
"1"
maxOccurs=
"1"
name=
"DocumentSchemaId"
type=
"s:int"
/>
<s:element
minOccurs=
"0"
maxOccurs=
"1"
name=
"DocumentName"
type=
"s:string"
/>
<s:element
minOccurs=
"0"
maxOccurs=
"1"
name=
"FieldsWithValues"
type=
"tns:ArrayOfFieldWithValue"
/>
<s:element
minOccurs=
"1"
maxOccurs=
"1"
name=
"UploadToken"
type=
"s1:guid"
/>
<s:element
minOccurs=
"0"
maxOccurs=
"1"
name=
"OriginalFileName"
type=
"s:string"
/>
<s:element
minOccurs=
"
1
"
maxOccurs=
"1"
name=
"SnapshotId"
type=
"s1:guid"
/>
<s:element
minOccurs=
"
0
"
maxOccurs=
"1"
name=
"SnapshotId"
type=
"s1:guid"
/>
<s:element
minOccurs=
"1"
maxOccurs=
"1"
name=
"SendEmailToMembers"
type=
"s:boolean"
/>
<s:element
minOccurs=
"0"
maxOccurs=
"1"
name=
"DocumentNumber"
type=
"s:string"
/>
<s:element
minOccurs=
"0"
maxOccurs=
"1"
name=
"VersionNumber"
type=
"s:string"
/>
...
...
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