7c6bee8a by 周伟奇

add configs table

1 parent b300b5b7
...@@ -35,7 +35,6 @@ DOC_SCHEMA_TYPE = 'ElectronicRecord' ...@@ -35,7 +35,6 @@ DOC_SCHEMA_TYPE = 'ElectronicRecord'
35 APPLICATION_ID_META_FIELD_id = 1 35 APPLICATION_ID_META_FIELD_id = 1
36 DEALER_CODE_META_FIELD_id = 13 36 DEALER_CODE_META_FIELD_id = 13
37 BUSINESS_TYPE_META_FIELD_id = 93 37 BUSINESS_TYPE_META_FIELD_id = 93
38 DEALER_CODE = 'ocr_situ_group'
39 38
40 RETRY_TIMES = 3 39 RETRY_TIMES = 3
41 40
...@@ -48,12 +47,17 @@ TRANS_MAP = { ...@@ -48,12 +47,17 @@ TRANS_MAP = {
48 'o': "0", 47 'o': "0",
49 'O': "0", 48 'O': "0",
50 'D': "0", 49 'D': "0",
50 'U': "0",
51 'n': "0",
51 52
52 '[': "1", 53 '[': "1",
53 ']': "1", 54 ']': "1",
54 'l': "1", 55 'l': "1",
55 'L': "1", 56 'L': "1",
56 57
58 'z': "2",
59 'Z': "2",
60
57 'A': "4", 61 'A': "4",
58 62
59 's': "5", 63 's': "5",
......
...@@ -37,7 +37,7 @@ class Command(BaseCommand, LoggerMixin): ...@@ -37,7 +37,7 @@ class Command(BaseCommand, LoggerMixin):
37 self.ocr_url_2 = conf.OCR_URL_2 37 self.ocr_url_2 = conf.OCR_URL_2
38 self.ocr_url_3 = conf.BC_URL 38 self.ocr_url_3 = conf.BC_URL
39 # EDMS web_service_api 39 # EDMS web_service_api
40 self.edms = EDMS(conf.EDMS_USER, conf.EDMS_PWD) 40 self.edms = EDMS()
41 # 优雅退出信号:15 41 # 优雅退出信号:15
42 signal.signal(signal.SIGTERM, self.signal_handler) 42 signal.signal(signal.SIGTERM, self.signal_handler)
43 43
...@@ -217,6 +217,7 @@ class Command(BaseCommand, LoggerMixin): ...@@ -217,6 +217,7 @@ class Command(BaseCommand, LoggerMixin):
217 } 217 }
218 ocr_res_1 = await self.fetch_ocr_1_result(self.ocr_url_1, json_data_1) 218 ocr_res_1 = await self.fetch_ocr_1_result(self.ocr_url_1, json_data_1)
219 if ocr_res_1 is None: 219 if ocr_res_1 is None:
220 skip_img.append(self.parse_img_path(img_path))
220 raise Exception('ocr 1 error, img_path={0}'.format(img_path)) 221 raise Exception('ocr 1 error, img_path={0}'.format(img_path))
221 else: 222 else:
222 self.cronjob_log.info('{0} [ocr_1 result] [img={1}] [res={2}]'.format( 223 self.cronjob_log.info('{0} [ocr_1 result] [img={1}] [res={2}]'.format(
...@@ -237,9 +238,9 @@ class Command(BaseCommand, LoggerMixin): ...@@ -237,9 +238,9 @@ class Command(BaseCommand, LoggerMixin):
237 pid, _, _, _, _ = consts.LICENSE_CLASSIFY_MAPPING.get(classify) 238 pid, _, _, _, _ = consts.LICENSE_CLASSIFY_MAPPING.get(classify)
238 json_data_2 = { 239 json_data_2 = {
239 "pid": str(pid), 240 "pid": str(pid),
240 "key": conf.OCR_KEY, 241 # "key": conf.OCR_KEY,
241 "secret": conf.OCR_SECRET, 242 # "secret": conf.OCR_SECRET,
242 "file": file_data 243 "filedata": file_data
243 } 244 }
244 ocr_res_2 = await self.fetch_ocr_2_result(self.ocr_url_2, json_data_2) 245 ocr_res_2 = await self.fetch_ocr_2_result(self.ocr_url_2, json_data_2)
245 if ocr_res_2 is None: 246 if ocr_res_2 is None:
...@@ -364,7 +365,9 @@ class Command(BaseCommand, LoggerMixin): ...@@ -364,7 +365,9 @@ class Command(BaseCommand, LoggerMixin):
364 @staticmethod 365 @staticmethod
365 def parse_img_path(img_path): 366 def parse_img_path(img_path):
366 img_name, _ = os.path.splitext(os.path.basename(img_path)) 367 img_name, _ = os.path.splitext(os.path.basename(img_path))
367 return int(img_name[5])+1, int(img_name[11])+1 368 part_list = img_name.split('_')
369 # page_7_img_11_0
370 return int(part_list[1])+1, int(part_list[3])+1
368 371
369 @staticmethod 372 @staticmethod
370 def get_most(value_list): 373 def get_most(value_list):
......
...@@ -122,3 +122,16 @@ class Keywords(models.Model): ...@@ -122,3 +122,16 @@ class Keywords(models.Model):
122 verbose_name = '银行流水关键词' 122 verbose_name = '银行流水关键词'
123 verbose_name_plural = verbose_name 123 verbose_name_plural = verbose_name
124 124
125
126 class Configs(models.Model):
127 id = models.AutoField(primary_key=True, verbose_name="id")
128 value = models.CharField(max_length=255, verbose_name="配置值")
129 comment = models.CharField(max_length=64, verbose_name="说明")
130
131 class Meta:
132 managed = False
133 situ_db_label = 'afc'
134 db_table = 'configs'
135 verbose_name = '配置信息'
136 verbose_name_plural = verbose_name
137
......
...@@ -8,15 +8,17 @@ from common.redis_cache import redis_handler as rh ...@@ -8,15 +8,17 @@ from common.redis_cache import redis_handler as rh
8 8
9 class EDMS: 9 class EDMS:
10 10
11 def __init__(self, user_name, pwd): 11 def __init__(self):
12 self.sm_client = Client(wsdl=conf.SM_WSDL) 12 self.sm_client = Client(wsdl=conf.SM_WSDL)
13 self.dm_client = Client(wsdl=conf.DM_WSDL) 13 self.dm_client = Client(wsdl=conf.DM_WSDL)
14 self.df_client = Client(wsdl=conf.DF_WSDL) 14 self.df_client = Client(wsdl=conf.DF_WSDL)
15 self.rc_client = Client(wsdl=conf.RC_WSDL) 15 self.rc_client = Client(wsdl=conf.RC_WSDL)
16 self.download_url = conf.EDMS_DOWNLOAD_URL 16 self.download_url = conf.EDMS_DOWNLOAD_URL
17 self.upload_url = conf.EDMS_UPLOAD_URL 17 self.upload_url = conf.EDMS_UPLOAD_URL
18 self.user_name = user_name 18 self.dealer_code = conf.DEALER_CODE
19 self.pwd = pwd 19
20 self.user_name = conf.EDMS_USER
21 self.pwd = conf.EDMS_PWD
20 self.session_id = None 22 self.session_id = None
21 23
22 def set_session_id(self): 24 def set_session_id(self):
...@@ -98,7 +100,7 @@ class EDMS: ...@@ -98,7 +100,7 @@ class EDMS:
98 {'FieldId': consts.APPLICATION_ID_META_FIELD_id, 100 {'FieldId': consts.APPLICATION_ID_META_FIELD_id,
99 'FieldValue': xsd.AnyObject(xsd.String(), application_id)}, 101 'FieldValue': xsd.AnyObject(xsd.String(), application_id)},
100 {'FieldId': consts.DEALER_CODE_META_FIELD_id, 102 {'FieldId': consts.DEALER_CODE_META_FIELD_id,
101 'FieldValue': xsd.AnyObject(xsd.String(), consts.DEALER_CODE)}, 103 'FieldValue': xsd.AnyObject(xsd.String(), self.dealer_code)},
102 {'FieldId': consts.BUSINESS_TYPE_META_FIELD_id, 104 {'FieldId': consts.BUSINESS_TYPE_META_FIELD_id,
103 'FieldValue': xsd.AnyObject(xsd.String(), business_type)}, 105 'FieldValue': xsd.AnyObject(xsd.String(), business_type)},
104 ] 106 ]
......
...@@ -335,7 +335,9 @@ hil_sql_2 = """ ...@@ -335,7 +335,9 @@ hil_sql_2 = """
335 335
336 create index hil_doc_application_id_status_index 336 create index hil_doc_application_id_status_index
337 on hil_doc (application_id, status); 337 on hil_doc (application_id, status);
338 338 """
339
340 afc_sql = """
339 create table upload_doc_records 341 create table upload_doc_records
340 ( 342 (
341 id int identity 343 id int identity
...@@ -357,10 +359,8 @@ hil_sql_2 = """ ...@@ -357,10 +359,8 @@ hil_sql_2 = """
357 359
358 create unique index upload_doc_records_metadata_version_id_uindex 360 create unique index upload_doc_records_metadata_version_id_uindex
359 on upload_doc_records (metadata_version_id); 361 on upload_doc_records (metadata_version_id);
360 """ 362
361 363 create table keywords
362 afc_sql = """
363 create table keywords
364 ( 364 (
365 id int identity primary key, 365 id int identity primary key,
366 keyword nvarchar(64) not null, 366 keyword nvarchar(64) not null,
...@@ -369,6 +369,13 @@ create table keywords ...@@ -369,6 +369,13 @@ create table keywords
369 update_time datetime not null, 369 update_time datetime not null,
370 create_time datetime not null 370 create_time datetime not null
371 ); 371 );
372
373 create table configs
374 (
375 id int identity primary key,
376 value nvarchar(255) not null,
377 comment nvarchar(64) not null,
378 );
372 379
373 create table priority_application 380 create table priority_application
374 ( 381 (
...@@ -429,7 +436,7 @@ create table keywords ...@@ -429,7 +436,7 @@ create table keywords
429 on afc_doc (application_id, status); 436 on afc_doc (application_id, status);
430 """ 437 """
431 438
432 hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=hil;UID=SA;PWD=19951019Mssql', autocommit=True) 439 hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=hil;UID=SA;PWD=pwd', autocommit=True)
433 440
434 hil_cursor = hil_cnxn.cursor() 441 hil_cursor = hil_cnxn.cursor()
435 hil_cursor.execute(hil_sql_1) 442 hil_cursor.execute(hil_sql_1)
...@@ -438,7 +445,7 @@ hil_cursor.execute(hil_sql_2) ...@@ -438,7 +445,7 @@ hil_cursor.execute(hil_sql_2)
438 hil_cursor.close() 445 hil_cursor.close()
439 hil_cnxn.close() 446 hil_cnxn.close()
440 447
441 afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=afc;UID=SA;PWD=19951019Mssql', autocommit=True) 448 afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=47.97.220.40;DATABASE=afc;UID=SA;PWD=pwd', autocommit=True)
442 449
443 afc_cursor = afc_cnxn.cursor() 450 afc_cursor = afc_cnxn.cursor()
444 afc_cursor.execute(afc_sql) 451 afc_cursor.execute(afc_sql)
......
...@@ -4,4 +4,6 @@ SLEEP_SECOND = 5 ...@@ -4,4 +4,6 @@ SLEEP_SECOND = 5
4 MAX_SLEEP_SECOND = 60 4 MAX_SLEEP_SECOND = 60
5 5
6 EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx 6 EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx
7 EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
...\ No newline at end of file ...\ No newline at end of file
7 EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx\
8 DEALER_CODE = ocr_situ_group
9
......
...@@ -4,4 +4,5 @@ SLEEP_SECOND = 5 ...@@ -4,4 +4,5 @@ SLEEP_SECOND = 5
4 MAX_SLEEP_SECOND = 60 4 MAX_SLEEP_SECOND = 60
5 5
6 EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx 6 EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx
7 EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
...\ No newline at end of file ...\ No newline at end of file
7 EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
8 DEALER_CODE = ocr_situ_group
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,4 +4,5 @@ SLEEP_SECOND = 5 ...@@ -4,4 +4,5 @@ SLEEP_SECOND = 5
4 MAX_SLEEP_SECOND = 60 4 MAX_SLEEP_SECOND = 60
5 5
6 EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx 6 EDMS_DOWNLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx
7 EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
...\ No newline at end of file ...\ No newline at end of file
7 EDMS_UPLOAD_URL = https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
8 DEALER_CODE = ocr_situ_group
...\ No newline at end of file ...\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!