add auto
Showing
6 changed files
with
188 additions
and
7 deletions
... | @@ -2199,3 +2199,17 @@ HIL_CONTRACT_TYPE_MAP = { | ... | @@ -2199,3 +2199,17 @@ HIL_CONTRACT_TYPE_MAP = { |
2199 | str(HIL_CONTRACT_2_CLASSIFY): 2, | 2199 | str(HIL_CONTRACT_2_CLASSIFY): 2, |
2200 | str(HIL_CONTRACT_3_CLASSIFY): 1, | 2200 | str(HIL_CONTRACT_3_CLASSIFY): 1, |
2201 | } | 2201 | } |
2202 | |||
2203 | RESULT_MAP = { | ||
2204 | 0: None, | ||
2205 | 1: True, | ||
2206 | 2: False | ||
2207 | } | ||
2208 | |||
2209 | RPA_RESULT_MAP = { | ||
2210 | 0: None, | ||
2211 | 1: 1, | ||
2212 | 2: 2, | ||
2213 | 3: 3, | ||
2214 | } | ||
2215 | ... | ... |
... | @@ -823,16 +823,17 @@ class HILAutoSettlement(models.Model): | ... | @@ -823,16 +823,17 @@ class HILAutoSettlement(models.Model): |
823 | rpa_2nd_eye_tat = models.DecimalField(max_digits=18, decimal_places=0, null=True, verbose_name='rpa_2nd_eye_tat') | 823 | rpa_2nd_eye_tat = models.DecimalField(max_digits=18, decimal_places=0, null=True, verbose_name='rpa_2nd_eye_tat') |
824 | rpa_3rd_eye_tat = models.DecimalField(max_digits=18, decimal_places=0, null=True, verbose_name='rpa_3rd_eye_tat') | 824 | rpa_3rd_eye_tat = models.DecimalField(max_digits=18, decimal_places=0, null=True, verbose_name='rpa_3rd_eye_tat') |
825 | rpa_total_tat = models.DecimalField(max_digits=18, decimal_places=0, null=True, verbose_name='rpa_total_tat') | 825 | rpa_total_tat = models.DecimalField(max_digits=18, decimal_places=0, null=True, verbose_name='rpa_total_tat') |
826 | rpa_activated_time = models.DateTimeField(null=True, verbose_name='rpa_activated_time') | 826 | rpa_activated_time = models.DateTimeField(null=True, verbose_name='rpa_activated_time') # 索引 |
827 | rpa_get_case_from_ocr_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_ocr_time') | 827 | rpa_get_case_from_ocr_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_ocr_time') # 索引 |
828 | rpa_get_case_from_oc_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_oc_time') | 828 | rpa_get_case_from_oc_time = models.DateTimeField(null=True, verbose_name='rpa_get_case_from_oc_time') |
829 | rpa_payment_authorize_time = models.DateTimeField(null=True, verbose_name='rpa_payment_authorize_time') | 829 | rpa_payment_authorize_time = models.DateTimeField(null=True, verbose_name='rpa_payment_authorize_time') |
830 | rpa_second_eye_time = models.DateTimeField(null=True, verbose_name='rpa_second_eye_time') | 830 | rpa_second_eye_time = models.DateTimeField(null=True, verbose_name='rpa_second_eye_time') |
831 | 831 | ||
832 | on_off = models.BooleanField(default=True, verbose_name="是否有效") | 832 | on_off = models.BooleanField(default=True, verbose_name="是否有效") |
833 | ocr_auto_result_pass = models.BooleanField(default=False, verbose_name="整体结果") | 833 | ocr_auto_result_pass = models.BooleanField(null=True, verbose_name="auto结果") |
834 | ocr_whole_result_pass = models.BooleanField(null=True, verbose_name="整体结果") | ||
834 | ocr_auto_result = models.TextField(null=True, verbose_name="auto比对结果") | 835 | ocr_auto_result = models.TextField(null=True, verbose_name="auto比对结果") |
835 | ocr_latest_comparison_time = models.DateTimeField(auto_now=True, null=True, verbose_name='最新比对时间') | 836 | ocr_latest_comparison_time = models.DateTimeField(auto_now=True, null=True, verbose_name='最新比对时间') # 索引 |
836 | 837 | ||
837 | update_time = models.DateTimeField(auto_now=False, verbose_name='修改时间') | 838 | update_time = models.DateTimeField(auto_now=False, verbose_name='修改时间') |
838 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 839 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ... | ... |
... | @@ -66,3 +66,20 @@ class ErrorType(NamedEnum): | ... | @@ -66,3 +66,20 @@ class ErrorType(NamedEnum): |
66 | IMAGE = (3, '图片问题') | 66 | IMAGE = (3, '图片问题') |
67 | OTHER = (4, '其他') | 67 | OTHER = (4, '其他') |
68 | 68 | ||
69 | |||
70 | class AutoResult(NamedEnum): | ||
71 | Y = (1, 'Y') | ||
72 | N = (2, 'N') | ||
73 | NULL = (0, 'NULL') | ||
74 | |||
75 | class WholeResult(NamedEnum): | ||
76 | Y = (1, 'Y') | ||
77 | N = (2, 'N') | ||
78 | NULL = (0, 'NULL') | ||
79 | |||
80 | |||
81 | class RPAResult(NamedEnum): | ||
82 | SUCCESS = (1, 'success') | ||
83 | ERROR1 = (2, 'business error') | ||
84 | ERROR2 = (3, 'system error') | ||
85 | NULL = (0, 'null') | ... | ... |
... | @@ -40,7 +40,7 @@ from .models import ( | ... | @@ -40,7 +40,7 @@ from .models import ( |
40 | HILAutoSettlement, | 40 | HILAutoSettlement, |
41 | AFCAutoSettlement, | 41 | AFCAutoSettlement, |
42 | ) | 42 | ) |
43 | from .named_enum import ErrorType | 43 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult |
44 | from .mixins import DocHandler | 44 | from .mixins import DocHandler |
45 | from . import consts | 45 | from . import consts |
46 | from apps.account.authentication import OAuth2AuthenticationWithUser | 46 | from apps.account.authentication import OAuth2AuthenticationWithUser |
... | @@ -282,6 +282,29 @@ doc_list_args = { | ... | @@ -282,6 +282,29 @@ doc_list_args = { |
282 | 'create_time_end': fields.Date(required=False), | 282 | 'create_time_end': fields.Date(required=False), |
283 | } | 283 | } |
284 | 284 | ||
285 | auto_list_args = { | ||
286 | 'page': fields.Int(required=False, | ||
287 | missing=consts.PAGE_DEFAULT, | ||
288 | validate=lambda val: val >= 1), | ||
289 | 'page_size': fields.Int(required=False, | ||
290 | missing=consts.PAGE_SIZE_DEFAULT, | ||
291 | validate=lambda val: val >= 1), | ||
292 | 'business_type': fields.Str(required=True, validate=validate.OneOf(consts.BUSINESS_TYPE_LIST)), | ||
293 | 'application_id': fields.Str(required=False, validate=validate.Length(max=64)), | ||
294 | 'auto_result': fields.Int(required=False, | ||
295 | validate=validate.OneOf(AutoResult.get_value_lst())), | ||
296 | 'whole_result': fields.Int(required=False, | ||
297 | validate=validate.OneOf(WholeResult.get_value_lst())), | ||
298 | 'rpa_result': fields.Int(required=False, | ||
299 | validate=validate.OneOf(RPAResult.get_value_lst())), | ||
300 | 'get_case_from_ocr_time_start': fields.Date(required=False), | ||
301 | 'get_case_from_ocr_time_end': fields.Date(required=False), | ||
302 | 'activated_time_start': fields.Date(required=False), | ||
303 | 'activated_time_end': fields.Date(required=False), | ||
304 | 'comparison_time_start': fields.Date(required=False), | ||
305 | 'comparison_time_end': fields.Date(required=False), | ||
306 | } | ||
307 | |||
285 | compare_result_args = { | 308 | compare_result_args = { |
286 | 'entity': fields.Str(required=True, validate=validate.OneOf(consts.BUSINESS_TYPE_LIST)), | 309 | 'entity': fields.Str(required=True, validate=validate.OneOf(consts.BUSINESS_TYPE_LIST)), |
287 | 'scheme': fields.Str(required=True, validate=validate.OneOf(consts.COMPARE_DOC_SCHEME_LIST)), | 310 | 'scheme': fields.Str(required=True, validate=validate.OneOf(consts.COMPARE_DOC_SCHEME_LIST)), |
... | @@ -1180,9 +1203,18 @@ class ResourcesView(GenericView): | ... | @@ -1180,9 +1203,18 @@ class ResourcesView(GenericView): |
1180 | 1203 | ||
1181 | def get(self, request): | 1204 | def get(self, request): |
1182 | error_type_map = ErrorType.get_mappings() | 1205 | error_type_map = ErrorType.get_mappings() |
1206 | auto_result_map = AutoResult.get_mappings() | ||
1207 | whole_result_map = WholeResult.get_mappings() | ||
1208 | rpa_result_map = RPAResult.get_mappings() | ||
1183 | error_type = [{'label': v, 'value': k} for k, v in error_type_map.items()] | 1209 | error_type = [{'label': v, 'value': k} for k, v in error_type_map.items()] |
1210 | auto_result = [{'label': v, 'value': k} for k, v in auto_result_map.items()] | ||
1211 | whole_result = [{'label': v, 'value': k} for k, v in whole_result_map.items()] | ||
1212 | rpa_result = [{'label': v, 'value': k} for k, v in rpa_result_map.items()] | ||
1184 | resources = { | 1213 | resources = { |
1185 | 'error_type': error_type | 1214 | 'error_type': error_type, |
1215 | 'auto_result': auto_result, | ||
1216 | 'whole_result': whole_result, | ||
1217 | 'rpa_result': rpa_result | ||
1186 | } | 1218 | } |
1187 | return response.ok(data=resources) | 1219 | return response.ok(data=resources) |
1188 | 1220 | ||
... | @@ -1247,3 +1279,75 @@ class SEContractView(GenericView): | ... | @@ -1247,3 +1279,75 @@ class SEContractView(GenericView): |
1247 | # forwarding_station.apply_async((application_id, entity), queue='queue_compare', countdown=conf.DELAY_SECONDS) | 1279 | # forwarding_station.apply_async((application_id, entity), queue='queue_compare', countdown=conf.DELAY_SECONDS) |
1248 | self.running_log.info('[e-contract pos in] [args={0}]'.format(args)) | 1280 | self.running_log.info('[e-contract pos in] [args={0}]'.format(args)) |
1249 | return response.ok() | 1281 | return response.ok() |
1282 | |||
1283 | |||
1284 | class AutoSettlementView(GenericView): | ||
1285 | permission_classes = [] | ||
1286 | authentication_classes = [] | ||
1287 | # permission_classes = [IsAuthenticated] | ||
1288 | # authentication_classes = [OAuth2AuthenticationWithUser] | ||
1289 | |||
1290 | # 获取比对结果 | ||
1291 | @use_args(auto_list_args, location='querystring') | ||
1292 | def get(self, request, args): | ||
1293 | page = args.get('page', consts.PAGE_DEFAULT) | ||
1294 | page_size = args.get('page_size', consts.PAGE_SIZE_DEFAULT) | ||
1295 | business_type = args.get('business_type') | ||
1296 | application_id = args.get('application_id') | ||
1297 | |||
1298 | get_case_from_ocr_time_start = args.get('get_case_from_ocr_time_start') | ||
1299 | get_case_from_ocr_time_end = args.get('get_case_from_ocr_time_end') | ||
1300 | activated_time_start = args.get('activated_time_start') | ||
1301 | activated_time_end = args.get('activated_time_end') | ||
1302 | comparison_time_start = args.get('comparison_time_start') | ||
1303 | comparison_time_end = args.get('comparison_time_end') | ||
1304 | |||
1305 | auto_result = args.get('auto_result', '') | ||
1306 | whole_result = args.get('whole_result', '') | ||
1307 | rpa_result = args.get('rpa_result', '') | ||
1308 | |||
1309 | if isinstance(auto_result, int): | ||
1310 | auto_result = consts.RESULT_MAP.get(auto_result) | ||
1311 | if isinstance(whole_result, int): | ||
1312 | whole_result = consts.RESULT_MAP.get(whole_result) | ||
1313 | if isinstance(rpa_result, int): | ||
1314 | rpa_result = consts.RPA_RESULT_MAP.get(rpa_result) | ||
1315 | |||
1316 | application_id_query = Q(application_id__contains=application_id) if application_id is not None else Q() | ||
1317 | auto_result_query = Q(ocr_auto_result_pass=auto_result) if not isinstance(auto_result, str) else Q() | ||
1318 | whole_result_query = Q(ocr_whole_result_pass=whole_result) if not isinstance(whole_result, str) else Q() | ||
1319 | rpa_result_query = Q(rpa_result=rpa_result) if not isinstance(rpa_result, str) else Q() | ||
1320 | time1_query = Q(rpa_get_case_from_ocr_time__gte=get_case_from_ocr_time_start, | ||
1321 | rpa_get_case_from_ocr_time__lt=get_case_from_ocr_time_end + datetime.timedelta(days=1))\ | ||
1322 | if get_case_from_ocr_time_start is not None and get_case_from_ocr_time_end is not None else Q() | ||
1323 | time2_query = Q(rpa_activated_time__gte=activated_time_start, | ||
1324 | rpa_activated_time__lt=activated_time_end + datetime.timedelta(days=1)) \ | ||
1325 | if activated_time_start is not None and activated_time_end is not None else Q() | ||
1326 | time3_query = Q(ocr_latest_comparison_time__gte=comparison_time_start, | ||
1327 | ocr_latest_comparison_time__lt=comparison_time_end + datetime.timedelta(days=1)) \ | ||
1328 | if comparison_time_start is not None and comparison_time_end is not None else Q() | ||
1329 | |||
1330 | query = application_id_query & auto_result_query & whole_result_query & rpa_result_query \ | ||
1331 | & time1_query & time2_query & time3_query | ||
1332 | |||
1333 | auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement | ||
1334 | |||
1335 | total = auto_class.objects.filter(query).count() | ||
1336 | start_index = page_size * (page - 1) | ||
1337 | end_index = page_size * page | ||
1338 | if start_index >= total > 0: | ||
1339 | raise self.invalid_params('页数不存在') | ||
1340 | |||
1341 | val_tuple = ('application_id', 'ocr_latest_comparison_time', 'ocr_auto_result_pass', 'ocr_whole_result_pass', | ||
1342 | 'rpa_result', 'rpa_activated_time', 'rpa_get_case_from_ocr_time') | ||
1343 | auto_queryset = auto_class.objects.filter(query).values(*val_tuple).order_by( | ||
1344 | '-ocr_latest_comparison_time')[start_index: end_index] | ||
1345 | |||
1346 | # total = len(doc_list) | ||
1347 | pagination = {'current': page, 'total': total, 'page_size': page_size} | ||
1348 | res = { | ||
1349 | 'pagination': pagination, | ||
1350 | 'auto_list': list(auto_queryset) | ||
1351 | } | ||
1352 | self.running_log.info('[get auto list] [args={0}] [res={1}]'.format(args, res)) | ||
1353 | return response.ok(data=res) | ... | ... |
... | @@ -1374,7 +1374,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1374,7 +1374,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1374 | 1374 | ||
1375 | license_dict = {} | 1375 | license_dict = {} |
1376 | 1376 | ||
1377 | customer_name = individual_info.get('name', '') | 1377 | customer_name = individual_info.get('name', '').strip() |
1378 | legal_name = individual_info.get('legalRepName', '') | 1378 | legal_name = individual_info.get('legalRepName', '') |
1379 | establishment_date = individual_info.get('establishmentDate', '') | 1379 | establishment_date = individual_info.get('establishmentDate', '') |
1380 | # date_of_birth = individual_info.get('dateOfBirth', '') | 1380 | # date_of_birth = individual_info.get('dateOfBirth', '') | ... | ... |
src/common/tools/mssql_script14.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | ALTER TABLE hil_auto_settlement ADD ocr_whole_result_pass bit; | ||
5 | ALTER TABLE hil_auto_settlement ALTER COLUMN ocr_auto_result_pass bit; | ||
6 | |||
7 | create index hil_auto_settlement_rpa_activated_time_index | ||
8 | on hil_auto_settlement (rpa_activated_time); | ||
9 | |||
10 | create index hil_auto_settlement_rpa_get_case_from_ocr_time_index | ||
11 | on hil_auto_settlement (rpa_get_case_from_ocr_time); | ||
12 | |||
13 | create index hil_auto_settlement_ocr_latest_comparison_time_index | ||
14 | on hil_auto_settlement (ocr_latest_comparison_time); | ||
15 | """ | ||
16 | |||
17 | afc_sql = """ | ||
18 | ALTER TABLE afc_auto_settlement ADD ocr_whole_result_pass bit; | ||
19 | ALTER TABLE afc_auto_settlement ALTER COLUMN ocr_auto_result_pass bit; | ||
20 | |||
21 | create index afc_auto_settlement_rpa_activated_time_index | ||
22 | on afc_auto_settlement (rpa_activated_time); | ||
23 | |||
24 | create index afc_auto_settlement_rpa_get_case_from_ocr_time_index | ||
25 | on afc_auto_settlement (rpa_get_case_from_ocr_time); | ||
26 | |||
27 | create index afc_auto_settlement_ocr_latest_comparison_time_index | ||
28 | on afc_auto_settlement (ocr_latest_comparison_time); | ||
29 | """ | ||
30 | |||
31 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
32 | |||
33 | hil_cursor = hil_cnxn.cursor() | ||
34 | hil_cursor.execute(hil_sql) | ||
35 | |||
36 | hil_cursor.close() | ||
37 | hil_cnxn.close() | ||
38 | |||
39 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
40 | |||
41 | afc_cursor = afc_cnxn.cursor() | ||
42 | afc_cursor.execute(afc_sql) | ||
43 | |||
44 | afc_cursor.close() | ||
45 | afc_cnxn.close() |
-
Please register or sign in to post a comment