Merge remote-tracking branch 'origin/feature/fsm-full' into feature/uat-tmp
# Conflicts: # src/apps/doc/models.py
Showing
5 changed files
with
121 additions
and
15 deletions
| ... | @@ -2467,3 +2467,26 @@ MPOS_MAP = { | ... | @@ -2467,3 +2467,26 @@ MPOS_MAP = { |
| 2467 | } | 2467 | } |
| 2468 | 2468 | ||
| 2469 | FOLDER_WSC_CLASSIFY = 199 | 2469 | FOLDER_WSC_CLASSIFY = 199 |
| 2470 | |||
| 2471 | |||
| 2472 | FSM_BEFORE_ACTIVITED_STATUS = { | ||
| 2473 | "APSVD": "Saved", | ||
| 2474 | "APEAE": "E-app Editing", | ||
| 2475 | "APADA": "Awaiting Dealer Action", | ||
| 2476 | "APAPR": "Acceptance Processing", | ||
| 2477 | "APPSB": "Pre-submit Processed", | ||
| 2478 | "APSBT": "Submitted", | ||
| 2479 | "APAPP": "Approved", | ||
| 2480 | "APHOC": "Held Offer-Docs", | ||
| 2481 | "APHOD": "Held Offer-Data", | ||
| 2482 | "APINI": "Initiated", | ||
| 2483 | "APSEP": "Settlement Processing" | ||
| 2484 | } | ||
| 2485 | |||
| 2486 | FSM_ACTIVITED_STATUS = { | ||
| 2487 | "APADF": "Activated-Document Follow up", | ||
| 2488 | "APASC": "Activated-Awaiting Settlement Check", | ||
| 2489 | "APIPN": "Activated-Invoice Passed-Non PT", | ||
| 2490 | "APIPP": "Activated-Invoice Passed-PT Doc Required", | ||
| 2491 | "APARD": "Activated-Review done", | ||
| 2492 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -329,9 +329,11 @@ class AFCOCRResult(models.Model): | ... | @@ -329,9 +329,11 @@ class AFCOCRResult(models.Model): |
| 329 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") | 329 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") |
| 330 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") | 330 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") |
| 331 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") | 331 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") |
| 332 | fsm_wep_ocr = models.TextField(null=True, verbose_name="FSM-WEP") | 332 | fsm_wep_ocr = models.TextField(null=True, verbose_name="延长保修合同") |
| 333 | fsm_msi_ocr = models.TextField(null=True, verbose_name="FSM-MSI") | 333 | fsm_msi_ocr = models.TextField(null=True, verbose_name="长悦保养合同") |
| 334 | fsm_sc_ocr = models.TextField(null=True, verbose_name="FSM-SC") | 334 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
| 335 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | ||
| 336 | |||
| 335 | 337 | ||
| 336 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 338 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| 337 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 339 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| ... | @@ -368,9 +370,11 @@ class HILOCRResult(models.Model): | ... | @@ -368,9 +370,11 @@ class HILOCRResult(models.Model): |
| 368 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") | 370 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") |
| 369 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") | 371 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") |
| 370 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") | 372 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") |
| 371 | fsm_wep_ocr = models.TextField(null=True, verbose_name="FSM-WEP") | 373 | |
| 372 | fsm_msi_ocr = models.TextField(null=True, verbose_name="FSM-MSI") | 374 | fsm_wep_ocr = models.TextField(null=True, verbose_name="延长保修合同") |
| 373 | fsm_sc_ocr = models.TextField(null=True, verbose_name="FSM-SC") | 375 | fsm_msi_ocr = models.TextField(null=True, verbose_name="长悦保养合同") |
| 376 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | ||
| 377 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | ||
| 374 | 378 | ||
| 375 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 379 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| 376 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 380 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| ... | @@ -406,9 +410,11 @@ class AFCSEOCRResult(models.Model): | ... | @@ -406,9 +410,11 @@ class AFCSEOCRResult(models.Model): |
| 406 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") | 410 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") |
| 407 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") | 411 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") |
| 408 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") | 412 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") |
| 409 | fsm_wep_ocr = models.TextField(null=True, verbose_name="FSM-WEP") | 413 | |
| 410 | fsm_msi_ocr = models.TextField(null=True, verbose_name="FSM-MSI") | 414 | fsm_wep_ocr = models.TextField(null=True, verbose_name="延长保修合同") |
| 411 | fsm_sc_ocr = models.TextField(null=True, verbose_name="FSM-SC") | 415 | fsm_msi_ocr = models.TextField(null=True, verbose_name="长悦保养合同") |
| 416 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | ||
| 417 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | ||
| 412 | 418 | ||
| 413 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 419 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| 414 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 420 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| ... | @@ -445,9 +451,10 @@ class HILSEOCRResult(models.Model): | ... | @@ -445,9 +451,10 @@ class HILSEOCRResult(models.Model): |
| 445 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") | 451 | hil_contract_2_ocr = models.TextField(null=True, verbose_name="HIL合同2") |
| 446 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") | 452 | hil_contract_3_ocr = models.TextField(null=True, verbose_name="HIL合同3") |
| 447 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") | 453 | qrs_ocr = models.TextField(null=True, verbose_name="AFC合同确认书") |
| 448 | fsm_wep_ocr = models.TextField(null=True, verbose_name="FSM-WEP") | 454 | fsm_wep_ocr = models.TextField(null=True, verbose_name="延长保修合同") |
| 449 | fsm_msi_ocr = models.TextField(null=True, verbose_name="FSM-MSI") | 455 | fsm_msi_ocr = models.TextField(null=True, verbose_name="长悦保养合同") |
| 450 | fsm_sc_ocr = models.TextField(null=True, verbose_name="FSM-SC") | 456 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
| 457 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | ||
| 451 | 458 | ||
| 452 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 459 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| 453 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 460 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| ... | @@ -1054,3 +1061,17 @@ class AFCCompareReportNew(models.Model): | ... | @@ -1054,3 +1061,17 @@ class AFCCompareReportNew(models.Model): |
| 1054 | managed = False | 1061 | managed = False |
| 1055 | db_table = 'afc_compare_report_new' | 1062 | db_table = 'afc_compare_report_new' |
| 1056 | situ_db_label = 'afc' | 1063 | situ_db_label = 'afc' |
| 1064 | |||
| 1065 | |||
| 1066 | class NscInvoice(models.Model): | ||
| 1067 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
| 1068 | vin = models.CharField(max_length=64, verbose_name="车架号") # 索引 | ||
| 1069 | content = models.TextField(null=True, verbose_name="nsc发票信息") | ||
| 1070 | create_time = models.DateTimeField(verbose_name='创建时间') | ||
| 1071 | |||
| 1072 | class Meta: | ||
| 1073 | managed = False | ||
| 1074 | db_table = 'nsc_invoice' | ||
| 1075 | situ_db_label = 'hil' | ||
| 1076 | |||
| 1077 | ... | ... |
| ... | @@ -48,12 +48,16 @@ from .models import ( | ... | @@ -48,12 +48,16 @@ from .models import ( |
| 48 | MposReport, | 48 | MposReport, |
| 49 | GenericOCRReport, | 49 | GenericOCRReport, |
| 50 | InterfaceReport, | 50 | InterfaceReport, |
| 51 | HILOCRResult, | ||
| 52 | HILSEOCRResult, | ||
| 53 | AFCOCRResult, | ||
| 54 | AFCSEOCRResult | ||
| 51 | ) | 55 | ) |
| 52 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName | 56 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam |
| 53 | from .mixins import DocHandler, MPOSHandler, PreSEHandler | 57 | from .mixins import DocHandler, MPOSHandler, PreSEHandler |
| 54 | from . import consts | 58 | from . import consts |
| 55 | from apps.account.authentication import OAuth2AuthenticationWithUser | 59 | from apps.account.authentication import OAuth2AuthenticationWithUser |
| 56 | from celery_compare.tasks import compare | 60 | from celery_compare.tasks import compare, fsm_compare |
| 57 | 61 | ||
| 58 | import time | 62 | import time |
| 59 | class CustomDate(fields.Date): | 63 | class CustomDate(fields.Date): |
| ... | @@ -563,6 +567,8 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -563,6 +567,8 @@ class UploadDocView(GenericView, DocHandler): |
| 563 | document = args.get('document') | 567 | document = args.get('document') |
| 564 | business_type = document.get('businessType') | 568 | business_type = document.get('businessType') |
| 565 | application_id = application_data.get('applicationId') | 569 | application_id = application_data.get('applicationId') |
| 570 | # 包含FSM 激活状态 | ||
| 571 | application_status = application_data.get('applicationStatus', '') | ||
| 566 | document_scheme = document.get('documentScheme') | 572 | document_scheme = document.get('documentScheme') |
| 567 | data_source = document.get('dataSource') | 573 | data_source = document.get('dataSource') |
| 568 | document_name = document.get('documentName', '') | 574 | document_name = document.get('documentName', '') |
| ... | @@ -571,6 +577,24 @@ class UploadDocView(GenericView, DocHandler): | ... | @@ -571,6 +577,24 @@ class UploadDocView(GenericView, DocHandler): |
| 571 | data_source = self.fix_data_source(data_source) | 577 | data_source = self.fix_data_source(data_source) |
| 572 | document_scheme = self.fix_scheme(document_scheme) | 578 | document_scheme = self.fix_scheme(document_scheme) |
| 573 | 579 | ||
| 580 | # fsm激活状态, 更新ocr_result 表fsm状态 | ||
| 581 | if consts.FSM_ACTIVITED_STATUS.get(application_status): | ||
| 582 | ocr_result_obj = None | ||
| 583 | if business_type == consts.HIL_PREFIX: | ||
| 584 | if document_scheme == RequestTeam.ACCEPTANCE[1]: | ||
| 585 | ocr_result_obj = HILOCRResult.objects.filter(application_id=application_id).first() | ||
| 586 | elif document_scheme == RequestTeam.SETTLEMENT[1]: | ||
| 587 | ocr_result_obj = HILSEOCRResult.objects.filter(application_id=application_id).first() | ||
| 588 | elif business_type == consts.AFC_PREFIX: | ||
| 589 | if document_scheme == RequestTeam.ACCEPTANCE[1]: | ||
| 590 | ocr_result_obj = AFCOCRResult.objects.filter(application_id=application_id).first() | ||
| 591 | elif document_scheme == RequestTeam.SETTLEMENT[1]: | ||
| 592 | ocr_result_obj = AFCSEOCRResult.objects.filter(application_id=application_id).first() | ||
| 593 | |||
| 594 | if ocr_result_obj: | ||
| 595 | ocr_result_obj.fsmActivited = 1 | ||
| 596 | ocr_result_obj.save() | ||
| 597 | |||
| 574 | if data_source == consts.DATA_SOURCE_LIST[1]: | 598 | if data_source == consts.DATA_SOURCE_LIST[1]: |
| 575 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书'): | 599 | if document_name.endswith('-证书.pdf') or document_name.endswith('-证书'): |
| 576 | self.running_log.info('[doc upload success] [eapp license skip] [args={0}]'.format(args)) | 600 | self.running_log.info('[doc upload success] [eapp license skip] [args={0}]'.format(args)) |
| ... | @@ -1372,6 +1396,14 @@ class SECMSView(GenericView): | ... | @@ -1372,6 +1396,14 @@ class SECMSView(GenericView): |
| 1372 | content=content_str, | 1396 | content=content_str, |
| 1373 | ) | 1397 | ) |
| 1374 | 1398 | ||
| 1399 | # 检查是否fsm流程(SE) | ||
| 1400 | fsm_contract = cms_info.get('fsmContract', False) | ||
| 1401 | fsm_best_price = cms_info.get('fsmBestPrice', False) | ||
| 1402 | if fsm_contract: | ||
| 1403 | fsm_compare.apply_async((application_id, business_type, None, None, False, True), | ||
| 1404 | queue='queue_compare') | ||
| 1405 | |||
| 1406 | else: | ||
| 1375 | # 触发比对 | 1407 | # 触发比对 |
| 1376 | compare.apply_async((application_id, business_type, None, None, False, True), | 1408 | compare.apply_async((application_id, business_type, None, None, False, True), |
| 1377 | queue='queue_compare') | 1409 | queue='queue_compare') | ... | ... |
| ... | @@ -7,6 +7,9 @@ import traceback | ... | @@ -7,6 +7,9 @@ import traceback |
| 7 | import numpy as np | 7 | import numpy as np |
| 8 | from datetime import datetime, timedelta | 8 | from datetime import datetime, timedelta |
| 9 | from collections import OrderedDict | 9 | from collections import OrderedDict |
| 10 | |||
| 11 | import requests | ||
| 12 | |||
| 10 | from . import app | 13 | from . import app |
| 11 | from settings import conf | 14 | from settings import conf |
| 12 | from apps.doc.models import ( | 15 | from apps.doc.models import ( |
| ... | @@ -3266,6 +3269,29 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3266,6 +3269,29 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
| 3266 | 3269 | ||
| 3267 | 3270 | ||
| 3268 | @app.task | 3271 | @app.task |
| 3272 | def fsm_compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | ||
| 3273 | compare_log.info('{0} [receive fsm task] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] [is_ca={5}] ' | ||
| 3274 | '[is_cms={6}]'.format(log_base, application_entity, application_id, uniq_seq, ocr_res_id, | ||
| 3275 | is_ca, is_cms)) | ||
| 3276 | # 调用java fsm 比对流程接口(http) | ||
| 3277 | # 调用Java fsm 比对流程接口, fsm 是se流程, ca可以暂时忽略 | ||
| 3278 | url = conf.FSM_URL | ||
| 3279 | body = { | ||
| 3280 | 'applicationId': application_id, | ||
| 3281 | 'businessType': application_entity, | ||
| 3282 | 'ocrResId': ocr_res_id, | ||
| 3283 | 'isCa': is_ca, | ||
| 3284 | 'isCms': is_cms | ||
| 3285 | } | ||
| 3286 | try: | ||
| 3287 | resp = requests.post(url, data=body) | ||
| 3288 | compare_log.info(resp.text) | ||
| 3289 | except Exception as e: | ||
| 3290 | compare_log.error("fsm full request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | ||
| 3291 | url, json.dumps(body), traceback.format_exc())) | ||
| 3292 | |||
| 3293 | |||
| 3294 | @app.task | ||
| 3269 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): | 3295 | def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False): |
| 3270 | # POS: application_id, application_entity, uniq_seq, None | 3296 | # POS: application_id, application_entity, uniq_seq, None |
| 3271 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | 3297 | # OCR: application_id, business_type(application_entity), None, ocr_res_id | ... | ... |
| ... | @@ -8,6 +8,9 @@ from common.tools.comparison import cp | ... | @@ -8,6 +8,9 @@ from common.tools.comparison import cp |
| 8 | from common.mixins import LoggerMixin | 8 | from common.mixins import LoggerMixin |
| 9 | from rest_framework.permissions import IsAuthenticated | 9 | from rest_framework.permissions import IsAuthenticated |
| 10 | from apps.account.authentication import OAuth2AuthenticationWithUser | 10 | from apps.account.authentication import OAuth2AuthenticationWithUser |
| 11 | from apps.doc.models import NscInvoice | ||
| 12 | import json | ||
| 13 | from datetime import datetime | ||
| 11 | 14 | ||
| 12 | params = { | 15 | params = { |
| 13 | 'invoiceCode': fields.Str(required=True, validate=validate.Length(max=128)), | 16 | 'invoiceCode': fields.Str(required=True, validate=validate.Length(max=128)), |
| ... | @@ -29,7 +32,7 @@ input_args = { | ... | @@ -29,7 +32,7 @@ input_args = { |
| 29 | } | 32 | } |
| 30 | 33 | ||
| 31 | 34 | ||
| 32 | # poss 接口接收NSC 发票信息 | 35 | # pos 接口接收NSC 发票信息 |
| 33 | class NSCInvoiceView(GenericView): | 36 | class NSCInvoiceView(GenericView): |
| 34 | permission_classes = [IsAuthenticated] | 37 | permission_classes = [IsAuthenticated] |
| 35 | authentication_classes = [OAuth2AuthenticationWithUser] | 38 | authentication_classes = [OAuth2AuthenticationWithUser] |
| ... | @@ -50,6 +53,7 @@ class NSCInvoiceView(GenericView): | ... | @@ -50,6 +53,7 @@ class NSCInvoiceView(GenericView): |
| 50 | vat = content.get('vat', 0.0) | 53 | vat = content.get('vat', 0.0) |
| 51 | vat_rate = content.get('vatRate', 0.0) | 54 | vat_rate = content.get('vatRate', 0.0) |
| 52 | 55 | ||
| 56 | NscInvoice.objects.create(vin=vin, content=json.dumps(content), create_time=datetime.now()) | ||
| 53 | return response.ok() | 57 | return response.ok() |
| 54 | 58 | ||
| 55 | 59 | ... | ... |
-
Please register or sign in to post a comment