start EDMS
Showing
5 changed files
with
14 additions
and
36 deletions
... | @@ -5,3 +5,5 @@ BUSINESS_TYPE = ['HIL', 'AFC'] | ... | @@ -5,3 +5,5 @@ BUSINESS_TYPE = ['HIL', 'AFC'] |
5 | HIL_SET = {'HIL', 'hil', 'CO00002', 'C000002'} | 5 | HIL_SET = {'HIL', 'hil', 'CO00002', 'C000002'} |
6 | HIL_PREFIX = 'HIL' | 6 | HIL_PREFIX = 'HIL' |
7 | AFC_PREFIX = 'AFC' | 7 | AFC_PREFIX = 'AFC' |
8 | |||
9 | CUSTOM_CLIENT = 'CustomClient' | ... | ... |
... | @@ -8,6 +8,7 @@ import asyncio | ... | @@ -8,6 +8,7 @@ import asyncio |
8 | import aiohttp | 8 | import aiohttp |
9 | from PIL import Image | 9 | from PIL import Image |
10 | from io import BytesIO | 10 | from io import BytesIO |
11 | from zeep import Client | ||
11 | 12 | ||
12 | from django.core.management import BaseCommand | 13 | from django.core.management import BaseCommand |
13 | from common.mixins import LoggerMixin | 14 | from common.mixins import LoggerMixin |
... | @@ -37,6 +38,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -37,6 +38,8 @@ class Command(BaseCommand, LoggerMixin): |
37 | 'X-Auth-Token': conf.OCR_TOKEN, | 38 | 'X-Auth-Token': conf.OCR_TOKEN, |
38 | 'Content-Type': 'application/json' | 39 | 'Content-Type': 'application/json' |
39 | } | 40 | } |
41 | # EDMS web_service_api | ||
42 | self.sm_client = Client(wsdl=conf.SM_WSDL) | ||
40 | # 优雅退出信号:15 | 43 | # 优雅退出信号:15 |
41 | signal.signal(signal.SIGTERM, self.signal_handler) | 44 | signal.signal(signal.SIGTERM, self.signal_handler) |
42 | 45 | ||
... | @@ -67,8 +70,9 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -67,8 +70,9 @@ class Command(BaseCommand, LoggerMixin): |
67 | if doc_info is None: | 70 | if doc_info is None: |
68 | return None, None, None | 71 | return None, None, None |
69 | # TODO EDMS下载pdf | 72 | # TODO EDMS下载pdf |
70 | # pdf_path = '/Users/clay/Desktop/biz/biz_logic/data/2/横版-表格-工商银行CH-B008802400.pdf' | 73 | # session_id = self.sm_client.service.StartSession(login=conf.EDMS_USER, |
71 | # doc_data_path = os.path.dirname(pdf_path) | 74 | # password=conf.EDMS_PWD, |
75 | # clientType=consts.CUSTOM_CLIENT) | ||
72 | 76 | ||
73 | doc_data_path = os.path.join(self.data_dir, business_type, str(doc_id)) | 77 | doc_data_path = os.path.join(self.data_dir, business_type, str(doc_id)) |
74 | pdf_path = os.path.join(doc_data_path, '{0}.pdf'.format(doc_id)) | 78 | pdf_path = os.path.join(doc_data_path, '{0}.pdf'.format(doc_id)) |
... | @@ -194,7 +198,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -194,7 +198,8 @@ class Command(BaseCommand, LoggerMixin): |
194 | # TODO 细化文件状态,不同异常状态采取不同的处理 | 198 | # TODO 细化文件状态,不同异常状态采取不同的处理 |
195 | # TODO 调用接口重试 | 199 | # TODO 调用接口重试 |
196 | def handle(self, *args, **kwargs): | 200 | def handle(self, *args, **kwargs): |
197 | sleep_second = conf.SLEEP_SECOND | 201 | sleep_second = int(conf.SLEEP_SECOND) |
202 | max_sleep_second = int(conf.MAX_SLEEP_SECOND) | ||
198 | while self.switch: | 203 | while self.switch: |
199 | # 1. 从队列获取文件信息 | 204 | # 1. 从队列获取文件信息 |
200 | doc_info, doc_class, doc_id, business_type = self.get_doc_info() | 205 | doc_info, doc_class, doc_id, business_type = self.get_doc_info() |
... | @@ -203,9 +208,9 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -203,9 +208,9 @@ class Command(BaseCommand, LoggerMixin): |
203 | # 队列为空时的处理 | 208 | # 队列为空时的处理 |
204 | if pdf_path is None: | 209 | if pdf_path is None: |
205 | time.sleep(sleep_second) | 210 | time.sleep(sleep_second) |
206 | sleep_second = min(conf.MAX_SLEEP_SECOND, sleep_second+5) | 211 | sleep_second = min(max_sleep_second, sleep_second+5) |
207 | continue | 212 | continue |
208 | sleep_second = conf.SLEEP_SECOND | 213 | sleep_second = int(conf.SLEEP_SECOND) |
209 | try: | 214 | try: |
210 | # 3.PDF文件提取图片 | 215 | # 3.PDF文件提取图片 |
211 | img_save_path = os.path.join(doc_data_path, 'img') | 216 | img_save_path = os.path.join(doc_data_path, 'img') | ... | ... |
src/common/web_services_api/test.py
deleted
100644 → 0
1 | from zeep import Client | ||
2 | from zeep.transports import Transport | ||
3 | from requests.auth import HTTPBasicAuth | ||
4 | from requests import Session | ||
5 | |||
6 | # session = Session() | ||
7 | # session.auth = HTTPBasicAuth('qqedms3', 'azhkilc6') | ||
8 | |||
9 | wsdl_path = '/Users/clay/Desktop/biz/biz_logic/data/sessionmanager.wsdl' | ||
10 | client = Client(wsdl=wsdl_path) | ||
11 | # client = Client(wsdl=wsdl_path, transport=Transport(session=session)) | ||
12 | |||
13 | |||
14 | with client.settings(raw_response=True): | ||
15 | # res = client.service.StartSessionForDomainUser(login='qqedms3', | ||
16 | # password='azhkilc6', | ||
17 | # domain='960c2a5a-869c-45bd-aca8-de396b684f59', | ||
18 | # clientType='CustomClient') | ||
19 | # res = client.service.StartSession(login='qqedms3', password='azhkilc6', clientType='CustomClient') | ||
20 | # res = client.service.StartSession(login='OCRUAT', password='1qaz2wsx', clientType='CustomClient') | ||
21 | res = client.service.GetSessionInfo(sessionId='40f9e3c1-e6cb-4b22-83b0-0b54433bec42') | ||
22 | |||
23 | print(res) | ||
24 | print(res.status_code) | ||
25 | print(res.content) | ||
26 | |||
27 | # client = Client('http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL') | ||
28 | # | ||
29 | # res = client.service.getMobileCodeInfo(mobileCode='15388058517') | ||
30 | # print(res) | ||
31 |
... | @@ -5,8 +5,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fil | ... | @@ -5,8 +5,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fil |
5 | COMMON_CONF_DIR = os.path.dirname(os.path.abspath(__file__)) | 5 | COMMON_CONF_DIR = os.path.dirname(os.path.abspath(__file__)) |
6 | SECRET_CONF_DIR = os.path.join(os.path.dirname(BASE_DIR), 'conf') | 6 | SECRET_CONF_DIR = os.path.join(os.path.dirname(BASE_DIR), 'conf') |
7 | DATA_DIR = os.path.join(os.path.dirname(BASE_DIR), 'data') | 7 | DATA_DIR = os.path.join(os.path.dirname(BASE_DIR), 'data') |
8 | WSDL_DIR = os.path.join(os.path.dirname(BASE_DIR), 'wsdl') | ||
8 | SECRET_CONF_FILE = os.path.join(SECRET_CONF_DIR, 'secret.ini') | 9 | SECRET_CONF_FILE = os.path.join(SECRET_CONF_DIR, 'secret.ini') |
9 | LOGGING_CONFIG_FILE = os.path.join(COMMON_CONF_DIR, 'logging.conf') | 10 | LOGGING_CONFIG_FILE = os.path.join(COMMON_CONF_DIR, 'logging.conf') |
11 | SM_WSDL = os.path.join(WSDL_DIR, 'SessionManager.wsdl') | ||
10 | 12 | ||
11 | # 文件存放根目录 | 13 | # 文件存放根目录 |
12 | LOG_DIR = os.path.join(os.path.dirname(BASE_DIR), 'logs') | 14 | LOG_DIR = os.path.join(os.path.dirname(BASE_DIR), 'logs') | ... | ... |
wsdl/SessionManager.wsdl
0 → 100644
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment