b8034b9f by 周伟奇

start EDMS

1 parent 1379e8b6
......@@ -5,3 +5,5 @@ BUSINESS_TYPE = ['HIL', 'AFC']
HIL_SET = {'HIL', 'hil', 'CO00002', 'C000002'}
HIL_PREFIX = 'HIL'
AFC_PREFIX = 'AFC'
CUSTOM_CLIENT = 'CustomClient'
......
......@@ -8,6 +8,7 @@ import asyncio
import aiohttp
from PIL import Image
from io import BytesIO
from zeep import Client
from django.core.management import BaseCommand
from common.mixins import LoggerMixin
......@@ -37,6 +38,8 @@ class Command(BaseCommand, LoggerMixin):
'X-Auth-Token': conf.OCR_TOKEN,
'Content-Type': 'application/json'
}
# EDMS web_service_api
self.sm_client = Client(wsdl=conf.SM_WSDL)
# 优雅退出信号:15
signal.signal(signal.SIGTERM, self.signal_handler)
......@@ -67,8 +70,9 @@ class Command(BaseCommand, LoggerMixin):
if doc_info is None:
return None, None, None
# TODO EDMS下载pdf
# pdf_path = '/Users/clay/Desktop/biz/biz_logic/data/2/横版-表格-工商银行CH-B008802400.pdf'
# doc_data_path = os.path.dirname(pdf_path)
# session_id = self.sm_client.service.StartSession(login=conf.EDMS_USER,
# password=conf.EDMS_PWD,
# clientType=consts.CUSTOM_CLIENT)
doc_data_path = os.path.join(self.data_dir, business_type, str(doc_id))
pdf_path = os.path.join(doc_data_path, '{0}.pdf'.format(doc_id))
......@@ -194,7 +198,8 @@ class Command(BaseCommand, LoggerMixin):
# TODO 细化文件状态,不同异常状态采取不同的处理
# TODO 调用接口重试
def handle(self, *args, **kwargs):
sleep_second = conf.SLEEP_SECOND
sleep_second = int(conf.SLEEP_SECOND)
max_sleep_second = int(conf.MAX_SLEEP_SECOND)
while self.switch:
# 1. 从队列获取文件信息
doc_info, doc_class, doc_id, business_type = self.get_doc_info()
......@@ -203,9 +208,9 @@ class Command(BaseCommand, LoggerMixin):
# 队列为空时的处理
if pdf_path is None:
time.sleep(sleep_second)
sleep_second = min(conf.MAX_SLEEP_SECOND, sleep_second+5)
sleep_second = min(max_sleep_second, sleep_second+5)
continue
sleep_second = conf.SLEEP_SECOND
sleep_second = int(conf.SLEEP_SECOND)
try:
# 3.PDF文件提取图片
img_save_path = os.path.join(doc_data_path, 'img')
......
from zeep import Client
from zeep.transports import Transport
from requests.auth import HTTPBasicAuth
from requests import Session
# session = Session()
# session.auth = HTTPBasicAuth('qqedms3', 'azhkilc6')
wsdl_path = '/Users/clay/Desktop/biz/biz_logic/data/sessionmanager.wsdl'
client = Client(wsdl=wsdl_path)
# client = Client(wsdl=wsdl_path, transport=Transport(session=session))
with client.settings(raw_response=True):
# res = client.service.StartSessionForDomainUser(login='qqedms3',
# password='azhkilc6',
# domain='960c2a5a-869c-45bd-aca8-de396b684f59',
# clientType='CustomClient')
# res = client.service.StartSession(login='qqedms3', password='azhkilc6', clientType='CustomClient')
# res = client.service.StartSession(login='OCRUAT', password='1qaz2wsx', clientType='CustomClient')
res = client.service.GetSessionInfo(sessionId='40f9e3c1-e6cb-4b22-83b0-0b54433bec42')
print(res)
print(res.status_code)
print(res.content)
# client = Client('http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL')
#
# res = client.service.getMobileCodeInfo(mobileCode='15388058517')
# print(res)
......@@ -5,8 +5,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fil
COMMON_CONF_DIR = os.path.dirname(os.path.abspath(__file__))
SECRET_CONF_DIR = os.path.join(os.path.dirname(BASE_DIR), 'conf')
DATA_DIR = os.path.join(os.path.dirname(BASE_DIR), 'data')
WSDL_DIR = os.path.join(os.path.dirname(BASE_DIR), 'wsdl')
SECRET_CONF_FILE = os.path.join(SECRET_CONF_DIR, 'secret.ini')
LOGGING_CONFIG_FILE = os.path.join(COMMON_CONF_DIR, 'logging.conf')
SM_WSDL = os.path.join(WSDL_DIR, 'SessionManager.wsdl')
# 文件存放根目录
LOG_DIR = os.path.join(os.path.dirname(BASE_DIR), 'logs')
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!