Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2a430194
authored
2021-12-20 20:07:29 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add auto settlement
1 parent
50de32a9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
756 additions
and
62 deletions
src/apps/doc/consts.py
src/apps/doc/models.py
src/apps/doc/views.py
src/celery_compare/tasks.py
src/common/tools/mssql_script13.py
src/apps/doc/consts.py
View file @
2a43019
...
...
@@ -1477,6 +1477,9 @@ SE_HIL_CON_1_MAP = {
'融资成本总额'
:
(
5
,
4
,
7
,
'融资成本总额'
,
None
),
'租期'
:
(
5
,
4
,
7
,
'租期'
,
None
),
'还款计划表'
:
(
5
,
5
,
7
,
'付款计划表'
,
None
),
'还款账号'
:
(
5
,
5
,
7
,
'银行账户-银行账号'
,
None
),
'户名'
:
(
5
,
5
,
7
,
'银行账户-户名'
,
None
),
'开户行'
:
(
5
,
5
,
7
,
'银行账户-开户行'
,
None
),
'ASP项目详情'
:
(
5
,
4
,
7
,
'车辆附加产品明细表'
,
None
),
'承租人法定代表人或授权代表'
:
(
1
,
1
,
7
,
'承租人-法定代表人或授权代表'
,
None
),
...
...
@@ -1532,11 +1535,11 @@ SE_AFC_CON_FIELD = ['-瘥△', '韐剛膠颲遠-撠-
'车辆贷款本金金额-重要条款'
,
'附加产品融资贷款本金总额-重要条款'
,
'所购车辆价格'
,
'车架号'
,
'经销商'
,
'贷款本金金额'
,
'车辆贷款本金金额'
,
'附加产品融资贷款本金总额'
,
'贷款期限'
,
'还款账号'
,
'户名'
,
'开户行'
,
'还款计划表'
,
'见证人签字'
,
'见证人日期'
,
'ASP项目详情-重要条款'
,
'购置税校验'
,
'ASP项目详情'
]
AFC_
CON_BANK_FIELD
=
[
'还款账号'
,
'户名'
,
'开户行'
]
CON_BANK_FIELD
=
[
'还款账号'
,
'户名'
,
'开户行'
]
# '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表'
SE_HIL_CON_1_FIELD
=
[
'合同编号-每页'
,
'合同编号-正文'
,
'车辆识别代码'
,
'车辆卖方'
,
'车辆原始销售价格'
,
'融资成本总额'
,
'租期'
,
'还款计划表'
,
'ASP项目详情'
,
'购置税校验'
,
'承租人法定代表人或授权代表'
]
'还款计划表'
,
'ASP项目详情'
,
'购置税校验'
,
'承租人法定代表人或授
权代表'
,
'还款账号'
,
'户名'
,
'开户行'
]
SE_HIL_CON_2_FIELD
=
[
'合同编号'
,
'合同编号-正文'
,
'车辆识别代码'
,
'租金总额'
,
'融资租赁期限'
]
SE_HIL_CON_3_FIELD
=
[
'合同编号-每页'
,
'承租人姓名'
,
'承租人证件号码'
,
'销售经销商'
,
'合同编号-正文'
,
'姓名/名称'
,
'自然人身份证件号码/法人执照号码'
,
'承租人签字'
]
...
...
@@ -1820,6 +1823,9 @@ HIL_CONTRACT_1_COMPARE_LOGIC = {
'还款计划表'
:
(
'还款计划表'
,
'se_schedule_compare'
,
{
"value_idx"
:
1
},
'售后回租合同还款计划表与系统不一致'
),
'ASP项目详情'
:
(
'ASP项目详情'
,
'se_asp_compare'
,
{},
'售后回租合同ASP名称或者金额与系统不一致'
),
'承租人法定代表人或授权代表'
:
(
'承租人法定代表人或授权代表'
,
'se_name_compare'
,
{},
'售后回租合同承租人法定代表人或授权代表与系统不一致'
),
'还款账号'
:
(
'还款账号'
,
'se_common_compare'
,
{
'remove_space'
:
True
},
'售后回租合同还款账号与系统不一致'
),
'户名'
:
(
'户名'
,
'se_common_compare'
,
{},
'售后回租合同户名与系统不一致'
),
'开户行'
:
(
'开户行'
,
'se_both_contain_compare'
,
{},
'售后回租合同开户行与系统不一致'
),
'承租人姓名'
:
(
'承租人姓名'
,
'se_name_compare'
,
{},
'售后回租合同承租人姓名与系统不一致'
),
'承租人证件号'
:
(
'承租人证件号'
,
'se_common_compare'
,
{},
'售后回租合同承租人证件号与系统不一致'
),
...
...
src/apps/doc/models.py
View file @
2a43019
...
...
@@ -813,24 +813,62 @@ class HILCACompareResultRecord(models.Model):
db_table
=
'hil_ca_compare_result_record'
# class HILContract(models.Model):
# id = models.AutoField(primary_key=True, verbose_name="id") # 主键
# application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
# create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
class
HILAutoSettlement
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
aa_type
=
models
.
CharField
(
null
=
True
,
max_length
=
64
,
verbose_name
=
"aa_type"
)
rpa_result
=
models
.
SmallIntegerField
(
null
=
True
,
verbose_name
=
"原因10数目"
)
rpa_1st_eye_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_1st_eye_tat'
)
rpa_2nd_eye_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_2nd_eye_tat'
)
rpa_3rd_eye_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_3rd_eye_tat'
)
rpa_total_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_total_tat'
)
rpa_activated_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_activated_time'
)
rpa_get_case_from_ocr_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_get_case_from_ocr_time'
)
rpa_get_case_from_oc_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_get_case_from_oc_time'
)
rpa_payment_authorize_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_payment_authorize_time'
)
rpa_second_eye_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_second_eye_time'
)
on_off
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否有效"
)
ocr_auto_result_pass
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"整体结果"
)
ocr_auto_result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"auto比对结果"
)
ocr_latest_comparison_time
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
,
verbose_name
=
'最新比对时间'
)
update_time
=
models
.
DateTimeField
(
auto_now
=
False
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'hil_auto_settlement'
# class Meta:
# managed = False
# db_table = 'hil_contract'
class
AFCAutoSettlement
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
aa_type
=
models
.
CharField
(
null
=
True
,
max_length
=
64
,
verbose_name
=
"aa_type"
)
rpa_result
=
models
.
SmallIntegerField
(
null
=
True
,
verbose_name
=
"原因10数目"
)
rpa_1st_eye_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_1st_eye_tat'
)
rpa_2nd_eye_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_2nd_eye_tat'
)
rpa_3rd_eye_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_3rd_eye_tat'
)
rpa_total_tat
=
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'rpa_total_tat'
)
rpa_activated_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_activated_time'
)
rpa_get_case_from_ocr_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_get_case_from_ocr_time'
)
rpa_get_case_from_oc_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_get_case_from_oc_time'
)
rpa_payment_authorize_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_payment_authorize_time'
)
rpa_second_eye_time
=
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'rpa_second_eye_time'
)
# class AFCContract(models.Model):
# id = models.AutoField(primary_key=True, verbose_name="id") # 主键
# application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
# create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建
时间')
on_off
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否有效"
)
ocr_auto_result_pass
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"整体结果"
)
ocr_auto_result
=
models
.
TextField
(
verbose_name
=
"auto比对结果"
)
ocr_latest_comparison_time
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
,
verbose_name
=
'最新比对
时间'
)
# class Meta:
# managed = False
# db_table = 'afc_contract'
# situ_db_label = 'afc'
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'afc_auto_settlement'
situ_db_label
=
'afc'
...
...
src/apps/doc/views.py
View file @
2a43019
...
...
@@ -6,7 +6,7 @@ import datetime
import
fitz
import
shutil
from
django.utils
import
timezone
from
django.http
import
HttpResponse
#
from django.http import HttpResponse
from
django.db.models
import
Q
from
rest_framework.permissions
import
IsAuthenticated
from
webargs
import
fields
,
validate
...
...
@@ -17,14 +17,15 @@ from common.mixins import GenericView
from
common.tools.file_tools
import
file_write
from
common.redis_cache
import
redis_handler
as
rh
from
.models
import
(
# UploadDocRecords,
DocStatus
,
PriorityApplication
,
GCAPRecords
,
AFCComparisonInfo
,
AFCSEComparisonInfo
,
#
AFCSEComparisonInfo,
AFCSECMSInfo
,
HILComparisonInfo
,
HILSEComparisonInfo
,
#
HILSEComparisonInfo,
HILSECMSInfo
,
AFCCompareOfflineReport
,
HILCompareOfflineReport
,
...
...
@@ -36,6 +37,8 @@ from .models import (
AFCSECompareResultRecord
,
HILCACompareResultRecord
,
HILSECompareResultRecord
,
HILAutoSettlement
,
AFCAutoSettlement
,
)
from
.named_enum
import
ErrorType
from
.mixins
import
DocHandler
...
...
@@ -213,6 +216,7 @@ se_compare_content = {
'customerType'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
CUSTOMER_TYPE
)),
"firstSubmmisonDate"
:
CustomDate
(
required
=
True
),
'propertyDocumentPolicy'
:
fields
.
Str
(
required
=
False
,
validate
=
validate
.
Length
(
max
=
16
)),
'isAutoSettlement'
:
fields
.
Boolean
(
required
=
False
),
'individualCusInfo'
:
fields
.
List
(
fields
.
Nested
(
se_individual_args
),
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
,
max
=
4
)),
...
...
@@ -283,6 +287,7 @@ compare_result_args = {
'scheme'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
COMPARE_DOC_SCHEME_LIST
)),
'id'
:
fields
.
Int
(
required
=
False
,
validate
=
lambda
val
:
val
>=
1
),
'case_id'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
'auto'
:
fields
.
Int
(
required
=
False
),
}
upload_pdf_args
=
{
...
...
@@ -500,27 +505,29 @@ class UploadDocView(GenericView, DocHandler):
# co_name = self.get_name(applicant_data, 'coApplicantName', 16)
# g1_name = self.get_name(applicant_data, 'guarantor1Name', 16)
# g2_name = self.get_name(applicant_data, 'guarantor2Name', 16)
# try:
# # 1. 上传信息记录
# UploadDocRecords.objects.create(
# metadata_version_id=document.get('metadataVersionId'),
# application_id=application_id,
# main_applicant=
main_name
,
# co_applicant=
co_name
,
# guarantor_1=
g1_name
,
# guarantor_2=
g2_name
,
# main_applicant=
'main_name'
,
# co_applicant=
'co_name'
,
# guarantor_1=
'g1_name'
,
# guarantor_2=
'g2_name'
,
# document_name=document_name,
# document_scheme=document_scheme,
# business_type=business_type,
# data_source=data_source,
# upload_finish_time=document.get('uploadFinishTime'),
# )
# except IntegrityError as e:
# self.running_log.info('[doc upload fail] [args={0}] [err={1}]'.format(args, e))
# self.invalid_params(msg='metadataVersionId repeat')
# else:
# except Exception as e:
# self.running_log.info('[doc upload success] [same file skip] [args={0}]'.format(args))
# # self.invalid_params(msg='metadataVersionId repeat')
# return response.ok()
data_source
=
self
.
fix_data_source
(
data_source
)
document_scheme
=
self
.
fix_scheme
(
document_scheme
)
document_scheme
=
self
.
fix_scheme
(
document_scheme
)
if
document_name
.
endswith
(
'.zip'
):
self
.
running_log
.
info
(
'[doc upload success] [zip file skip] [args={0}]'
.
format
(
args
))
...
...
@@ -531,6 +538,7 @@ class UploadDocView(GenericView, DocHandler):
if
document_name
.
endswith
(
'-证书.pdf'
)
or
document_name
.
endswith
(
'-证书'
):
self
.
running_log
.
info
(
'[doc upload success] [eapp license skip] [args={0}]'
.
format
(
args
))
return
response
.
ok
()
# 2. 根据业务类型分库存储
doc_class
,
prefix
=
self
.
get_doc_class
(
business_type
)
doc
=
doc_class
.
objects
.
create
(
...
...
@@ -707,37 +715,52 @@ class SECompareView(GenericView):
def
post
(
self
,
request
,
args
):
# 存库
content
=
args
.
get
(
'content'
,
{})
uniq_seq
=
content
.
get
(
'uniqSeq'
)
business_type
=
content
.
get
(
'applicationEntity'
)
application_id
=
content
.
get
(
'applicationId'
)
individual_cus_info
=
json
.
dumps
(
content
.
get
(
'individualCusInfo'
))
vehicle_info
=
json
.
dumps
(
content
.
get
(
'vehicleInfo'
))
insurance_info
=
json
.
dumps
(
content
.
get
(
'insuranceInfo'
))
bank_info
=
json
.
dumps
(
content
.
get
(
'bankInfo'
))
quotationt_info
=
json
.
dumps
(
content
.
get
(
'quotationtInfo'
))
corporate_cus_info
=
json
.
dumps
(
content
.
get
(
'corporateCusInfo'
))
if
isinstance
(
content
.
get
(
'corporateCusInfo'
),
dict
)
else
None
comparison_class
=
HILSEComparisonInfo
if
business_type
in
consts
.
HIL_SET
else
AFCSEComparisonInfo
comparison_class
.
objects
.
create
(
uniq_seq
=
uniq_seq
,
is_auto
=
content
.
get
(
'isAutoSettlement'
,
False
)
if
is_auto
:
# 加入优先级队列
PriorityApplication
.
objects
.
update_or_create
(
application_id
=
application_id
,
defaults
=
{
'on_off'
:
True
})
# 加入auto表
auto_class
=
HILAutoSettlement
if
business_type
in
consts
.
HIL_SET
else
AFCAutoSettlement
is_auto
=
auto_class
.
objects
.
filter
(
application_id
=
application_id
,
on_off
=
True
)
.
exists
()
if
not
is_auto
:
auto_class
.
objects
.
create
(
application_id
=
application_id
,
application_version
=
content
.
get
(
'applicationVersion'
),
customer_type
=
content
.
get
(
'customerType'
),
first_submmison_date
=
content
.
get
(
'firstSubmmisonDate'
),
property_doc_policy
=
content
.
get
(
'propertyDocumentPolicy'
,
None
),
individual_cus_info
=
individual_cus_info
,
corporate_cus_info
=
corporate_cus_info
,
vehicle_info
=
vehicle_info
,
insurance_info
=
insurance_info
,
bank_info
=
bank_info
,
quotationt_info
=
quotationt_info
)
return
response
.
ok
()
# uniq_seq = content.get('uniqSeq')
# business_type = content.get('applicationEntity')
# application_id = content.get('applicationId')
#
# individual_cus_info = json.dumps(content.get('individualCusInfo'))
# vehicle_info = json.dumps(content.get('vehicleInfo'))
# insurance_info = json.dumps(content.get('insuranceInfo'))
# bank_info = json.dumps(content.get('bankInfo'))
# quotationt_info = json.dumps(content.get('quotationtInfo'))
# corporate_cus_info = json.dumps(content.get('corporateCusInfo')) if isinstance(
# content.get('corporateCusInfo'), dict) else None
# comparison_class = HILSEComparisonInfo if business_type in consts.HIL_SET else AFCSEComparisonInfo
# comparison_class.objects.create(
# uniq_seq=uniq_seq,
# application_id=application_id,
# application_version=content.get('applicationVersion'),
# customer_type=content.get('customerType'),
# first_submmison_date=content.get('firstSubmmisonDate'),
# property_doc_policy=content.get('propertyDocumentPolicy', None),
# individual_cus_info=individual_cus_info,
# corporate_cus_info=corporate_cus_info,
# vehicle_info=vehicle_info,
# insurance_info=insurance_info,
# bank_info=bank_info,
# quotationt_info=quotationt_info
# )
# 触发比对
# compare.apply_async((application_id, business_type, uniq_seq, None, False, False),
# queue='queue_compare')
return
response
.
ok
()
post
.
openapi_doc
=
'''
tags: [info]
...
...
@@ -944,6 +967,38 @@ class CompareResultView(GenericView):
entity
=
args
.
get
(
'entity'
)
scheme
=
args
.
get
(
'scheme'
)
case_id
=
args
.
get
(
'case_id'
)
is_auto
=
args
.
get
(
'auto'
)
if
is_auto
==
1
:
result_table
=
HILAutoSettlement
if
entity
==
consts
.
HIL_PREFIX
else
AFCAutoSettlement
if
result_id
is
not
None
:
result_obj
=
result_table
.
objects
.
filter
(
id
=
result_id
)
.
first
()
else
:
result_obj
=
result_table
.
objects
.
filter
(
application_id
=
case_id
)
.
first
()
if
result_obj
is
None
:
whole_result
=
''
else
:
whole_result
=
consts
.
RESULT_Y
if
result_obj
.
ocr_auto_result_pass
else
consts
.
RESULT_N
source
=
consts
.
INFO_SOURCE
[
1
]
version
=
comments
=
''
compare_result
=
{
'id'
:
0
if
result_obj
is
None
else
result_obj
.
id
,
'application_id'
:
case_id
,
'entity'
:
entity
,
'scheme'
:
consts
.
DOC_SCHEME_LIST
[
0
]
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
consts
.
DOC_SCHEME_LIST
[
1
],
'whole_result'
:
whole_result
,
'latest_compared_time'
:
''
if
result_obj
is
None
else
result_obj
.
ocr_latest_comparison_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
'source'
:
source
,
'version'
:
version
,
'comments'
:
comments
,
'result'
:
[]
if
result_obj
is
None
else
json
.
loads
(
result_obj
.
ocr_auto_result
)
}
return
response
.
ok
(
data
=
compare_result
)
if
entity
==
consts
.
HIL_PREFIX
:
result_table
=
HILCACompareResult
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
HILSECompareResult
...
...
@@ -1132,7 +1187,7 @@ class SECMSView(GenericView):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
#
pos
上传比对信息接口 SE
#
CMS
上传比对信息接口 SE
# @use_args(se_cms_args, location='data')
def
post
(
self
,
request
):
args
=
request
.
data
...
...
src/celery_compare/tasks.py
View file @
2a43019
...
...
@@ -27,6 +27,8 @@ from apps.doc.models import (
AFCCACompareResult
,
HILSECompareResult
,
HILCACompareResult
,
HILAutoSettlement
,
AFCAutoSettlement
,
)
from
apps.doc
import
consts
from
apps.doc.ocr.gcap
import
gcap
...
...
@@ -870,6 +872,481 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
traceback
.
format_exc
()))
def
get_se_cms_compare_info_auto
(
last_obj
,
application_entity
):
cms_info
=
json
.
loads
(
last_obj
.
content
)
compare_info
=
{}
individual_info_dict
=
{}
main_role_info
=
{}
company_info_list
=
[]
# 个人信息证件---------------------------------------------------------------------------------------------------------
# province = cms_info.get('province', '')
for
individual_info
in
cms_info
.
get
(
'applicantInformation'
,
[]):
all_id_num
=
[]
license_dict
=
{}
customer_name
=
individual_info
.
get
(
'name'
,
''
)
legal_name
=
individual_info
.
get
(
'legalRepName'
,
''
)
# establishment_date = individual_info.get('establishmentDate', '')
# date_of_birth = individual_info.get('dateOfBirth', '')
for
id_info
in
individual_info
.
get
(
'IDInformation'
,
[]):
if
id_info
.
get
(
'idType'
)
in
consts
.
SE_CMS_FIRST_ID_FIELD_MAPPING
:
license_en
,
is_prc
=
consts
.
SE_CMS_FIRST_ID_FIELD_MAPPING
[
id_info
[
'idType'
]]
# ['customerName', 'idNum', 'dateOfBirth', 'idExpiryDate', 'hukouProvince']
id_num
=
decode_des
(
id_info
.
get
(
'idNum'
,
''
),
des_key
)
field_input
=
[
(
'customerName'
,
customer_name
),
(
'idNum'
,
id_num
),
# ('dateOfBirth', date_of_birth),
# ('idExpiryDate', id_info.get('idExpiryDate', '')),
]
if
is_prc
:
# field_input.append(('hukouProvince', province))
field_input
.
append
((
'真伪'
,
consts
.
IC_RES_MAPPING
.
get
(
1
)))
field_input
.
append
((
'idExpiryDate'
,
id_info
.
get
(
'idExpiryDate'
,
''
)))
license_dict
[
license_en
]
=
field_input
all_id_num
.
append
(
id_num
)
# 营业执照 --------------------------------------------------------------------------------------------------
elif
id_info
.
get
(
'idType'
)
in
[
'Unified Social Credit Code'
,
'Tax Number'
,
'Business License Number'
]:
# ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode',
# 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate']
id_num
=
decode_des
(
id_info
.
get
(
'idNum'
,
''
),
des_key
)
# bl_field_input = [
# ('companyName', customer_name),
# ('legalRepName', legal_name),
# ('businessLicenseNo', id_num),
# ('organizationCreditCode', id_num),
# ('taxRegistrationCertificateNo', id_num),
# ('establishmentDate', establishment_date),
# ('businessLicenseDueDate', id_info.get('idExpiryDate', '')),
# ]
# license_dict[consts.BL_EN] = bl_field_input
all_id_num
.
append
(
id_num
)
if
individual_info
.
get
(
'customersubType'
,
''
)
==
'Corporate'
:
company_info_list
.
append
((
customer_name
,
id_num
,
legal_name
))
# SME营业执照---------------------------------------------------------------------------------------------------
# if individual_info.get('customersubType', '').startswith('Self Employed'):
# sep_field_input = [
# ('legalRepName', customer_name),
# ('businessLicenseDueDate', ''),
# ]
# license_dict[consts.SME_BL_EN] = sep_field_input
if
len
(
all_id_num
)
>
0
:
main_role_info
.
setdefault
(
individual_info
[
'applicantType'
],
[])
.
append
(
(
customer_name
,
'、'
.
join
(
all_id_num
),
all_id_num
[
0
])
)
if
len
(
license_dict
)
>
0
:
individual_info_dict
.
setdefault
(
individual_info
[
'applicantType'
],
[])
.
append
(
license_dict
)
compare_info
[
'applicantInformation'
]
=
individual_info_dict
main_name
=
main_num
=
hmh_name
=
hmh_id
=
''
for
applicant_type
in
consts
.
APPLICANT_TYPE_ORDER
:
if
applicant_type
in
main_role_info
:
# main_name, main_num, _ = main_role_info[applicant_type][0]
hmh_name
,
_
,
hmh_id
=
main_role_info
[
applicant_type
][
0
]
break
# dda_name_list = []
# dda_num_list = []
# for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]:
# if applicant_type in main_role_info:
# for dda_name_part, _, dda_num_part in main_role_info[applicant_type]:
# dda_name_list.append(dda_name_part)
# dda_num_list.append(dda_num_part)
# dda_name = '、'.join(dda_name_list)
# dda_num = '、'.join(dda_num_list)
# del main_role_info
if
len
(
company_info_list
)
>
0
:
company_info
=
company_info_list
[
0
]
else
:
company_info
=
None
vehicle_info
=
{}
vehicle_field_input
=
[]
vehicle_status
=
cms_info
.
get
(
'vehicleStatus'
,
''
)
first_submission_date
=
cms_info
.
get
(
'submissionDate'
,
''
)
vin_no
=
cms_info
.
get
(
'vehicleInformation'
,
{})
.
get
(
'vinNo'
,
''
)
amount
=
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'vehiclePrice'
,
'0.0'
))
# 新车发票----------------------------------------------------------------------------------------------------------
if
vehicle_status
==
'New'
:
vehicle_field_input
.
append
((
'vinNo'
,
vin_no
))
vehicle_field_input
.
append
((
'dealer'
,
'、'
.
join
([
cms_info
.
get
(
'dealerName'
,
''
),
cms_info
.
get
(
'fapiaoIssuerDealer'
,
''
)])))
vehicle_field_input
.
append
((
'vehicleTransactionAmount'
,
amount
))
if
isinstance
(
company_info
,
tuple
):
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
0
],
company_info
[
0
]))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
1
],
company_info
[
1
]))
else
:
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
0
],
hmh_name
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
1
],
hmh_id
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
2
],
first_submission_date
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
3
],
consts
.
SE_STAMP_VALUE
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
4
],
consts
.
SE_FPL_VALUE
))
bhsj
=
float
(
amount
)
/
1.13
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
5
],
consts
.
SPLIT_STR
.
join
([
format
(
bhsj
,
'.2f'
),
format
(
float
(
amount
)
-
bhsj
,
'.2f'
),
consts
.
RESULT_Y
])))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
6
],
consts
.
SE_LAYOUT_VALUE
))
vehicle_info
[
consts
.
MVI_EN
]
=
vehicle_field_input
compare_info
[
'vehicleInfo'
]
=
vehicle_info
# 二手车发票、交易凭证、绿本------------------------------------------------------------------------------------------
# else:
# gb_field_input = [
# ('vinNo', vin_no),
# ]
# gb34_field_input = []
# jypz_field_input = []
# vehicle_field_input.append(('vinNo', vin_no))
# vehicle_field_input.append(('vehicleTransactionAmount', amount))
# if isinstance(company_info, tuple):
# vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0]))
# vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1]))
# jypz_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0]))
# jypz_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1]))
# gb34_field_input.append((consts.SE_GB_USED_FIELD[0], company_info[0]))
# gb34_field_input.append((consts.SE_GB_USED_FIELD[1], company_info[1]))
# else:
# vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name))
# vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num))
# jypz_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name))
# jypz_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num))
# gb34_field_input.append((consts.SE_GB_USED_FIELD[0], main_name))
# gb34_field_input.append((consts.SE_GB_USED_FIELD[1], main_num))
# gb34_field_input.append((consts.SE_GB_USED_FIELD[2], first_submission_date))
# vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date))
# vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE))
# jypz_field_input.append(('vinNo', vin_no))
# jypz_field_input.append(('vehicleTransactionAmount', amount))
# jypz_field_input.append((consts.SE_GB_USED_FIELD[-1], first_submission_date))
#
# vehicle_info[consts.MVC_EN] = gb_field_input
# vehicle_info[consts.MVC34_EN] = gb34_field_input
# if not detect_list[0]:
# vehicle_info[consts.UCI_EN] = vehicle_field_input
# if not detect_list[1]:
# vehicle_info[consts.JYPZ_EN] = jypz_field_input
# if detect_list[0] and detect_list[1]:
# vehicle_info[consts.UCI_EN] = vehicle_field_input
# compare_info['vehicleInfo'] = vehicle_info
# 银行卡-------------------------------------------------------------------------------------------------------
bank_info
=
{}
bank_name
=
cms_info
.
get
(
'bankAccountDetails'
,
{})
.
get
(
'bankName'
,
''
)
account_no
=
decode_des
(
cms_info
.
get
(
'bankAccountDetails'
,
{})
.
get
(
'accountNo'
,
''
),
des_key
)
is_gsyh
=
True
if
'工商'
in
bank_name
else
False
bank_field_input
=
[
(
'accountNo'
,
account_no
),
(
'bankName'
,
bank_name
),
(
'type'
,
consts
.
BC_TYPE_VALUE
),
]
bank_info
[
consts
.
BC_EN
]
=
bank_field_input
# DDA------------------------------------------------------------------------------------------------------------
# if is_gsyh or not detect_list[-1]:
# dda_field_input = [
# ('applicationId(1)', last_obj.application_id),
# ('applicationId(2)', last_obj.application_id),
# ('bankName', bank_name),
# ('companyName', consts.HIL_COMPANY_NAME if application_entity in consts.HIL_SET else consts.AFC_COMPANY_NAME),
# ('customerName', dda_name),
# ('idNum', dda_num),
# ('accountHolderName', cms_info.get('bankAccountDetails', {}).get('accountHolderName', '')),
# ('accountNo', account_no),
# ]
# bank_info[consts.DDA_EN] = dda_field_input
compare_info
[
'bankInfo'
]
=
bank_info
# 银行流水 --------------------------------------------------------------------
if
cms_info
.
get
(
'autoApprovedDetails'
,
{})
.
get
(
'aaType'
,
''
)
in
[
'CAA1'
,
'CAA2'
]:
bs_role_list
=
[]
for
applicant_type
in
consts
.
APPLICANT_TYPE_ORDER
[:
2
]:
if
applicant_type
in
main_role_info
:
for
bs_role
,
_
,
_
in
main_role_info
[
applicant_type
]:
bs_role_list
.
append
(
bs_role
)
bs_info
=
dict
()
bs_field_input
=
[
(
consts
.
SE_BS_FIELD
[
0
],
bs_role_list
),
(
consts
.
SE_BS_FIELD
[
1
],
first_submission_date
),
(
consts
.
SE_BS_FIELD
[
2
],
'90天'
),
]
dbr_bs_role_list
=
[]
for
dbr_bs_role
,
_
,
_
in
main_role_info
.
get
(
consts
.
APPLICANT_TYPE_ORDER
[
2
],
[]):
dbr_bs_role_list
.
append
(
dbr_bs_role
)
if
len
(
dbr_bs_role_list
)
>=
1
:
bs_field_input
.
extend
([
(
consts
.
SE_BS_FIELD
[
3
],
dbr_bs_role_list
[
0
]),
(
consts
.
SE_BS_FIELD
[
4
],
first_submission_date
),
(
consts
.
SE_BS_FIELD
[
5
],
'90天'
),
])
if
len
(
dbr_bs_role_list
)
>=
2
:
bs_field_input
.
extend
([
(
consts
.
SE_BS_FIELD
[
6
],
dbr_bs_role_list
[
1
]),
(
consts
.
SE_BS_FIELD
[
7
],
first_submission_date
),
(
consts
.
SE_BS_FIELD
[
8
],
'90天'
),
])
bs_info
[
consts
.
BS_EN
]
=
bs_field_input
compare_info
[
'Bank Statement'
]
=
bs_info
# 抵押登记豁免函----------------------------------------------------------------------------------------------------
other_info
=
{}
full_no
=
cms_info
.
get
(
'settlemnetVerification'
,
{})
.
get
(
'applicationNo'
,
''
)
if
cms_info
.
get
(
'mortgageType'
,
''
)
==
'Mortgage Free'
or
cms_info
.
get
(
'mortgageType'
,
''
)
==
'MortgageFree'
:
hmh_field_input
=
[
(
consts
.
SE_HMH_FIELD
[
0
],
hmh_name
),
(
consts
.
SE_HMH_FIELD
[
1
],
hmh_id
),
(
consts
.
SE_HMH_FIELD
[
2
],
full_no
),
(
consts
.
SE_HMH_FIELD
[
3
],
cms_info
.
get
(
'financeCompany'
,
''
)),
(
consts
.
SE_HMH_FIELD
[
4
],
consts
.
SE_STAMP_VALUE
),
]
other_info
[
consts
.
HMH_EN
]
=
hmh_field_input
# ASP -------------------------------------------------------------------------------------------------------
asp_list
=
[]
gzs_status
=
consts
.
GZS_STATUS
[
1
]
gzs_list
=
[
gzs_status
]
gzs_price
=
'0.00'
is_asp
=
False
# insurance_price = None
if
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'associatedServicePrincipal'
,
'0.00'
))
!=
'0.00'
:
is_asp
=
True
# for asp_info in cms_info.get('associatedServices', []):
for
asp_info
in
cms_info
.
get
(
'associatedServices'
,
{})
.
get
(
'SubassociatedServices'
,
[]):
tmp_asp_name
=
asp_info
.
get
(
'associatedServices'
)
if
isinstance
(
tmp_asp_name
,
str
)
and
len
(
tmp_asp_name
)
>
0
:
if
gzs_status
==
consts
.
GZS_STATUS
[
1
]
and
tmp_asp_name
.
find
(
consts
.
GZS_NAME
)
!=
-
1
:
gzs_status
=
consts
.
GZS_STATUS
[
2
]
gzs_price
=
asp_info
.
get
(
'price'
,
'0.00'
)
asp_list
.
append
(
(
tmp_asp_name
,
asp_info
.
get
(
'price'
,
'0.00'
),
asp_info
.
get
(
'financed'
,
'0.00'
)
)
)
# 保单费合计
# if tmp_asp_name.find('机动车辆保险') != -1:
# insurance_price = asp_info.get('price', '0.00')
# fin_total = 0
fin_total_tmp
=
cms_info
.
get
(
'associatedServices'
,
{})
.
get
(
'financed total'
,
'0.00'
)
fin_total
=
'0.00'
if
fin_total_tmp
.
strip
()
==
''
else
fin_total_tmp
for
asp_name
,
_
,
asp_fin
in
asp_list
:
if
gzs_status
==
consts
.
GZS_STATUS
[
2
]
and
asp_name
.
find
(
consts
.
GZS_NAME
)
==
-
1
:
gzs_status
=
consts
.
GZS_STATUS
[
0
]
# fin_total += float(asp_fin)
asp_list
.
append
(
(
consts
.
ASP_SUM_NAME
,
''
,
fin_total
,
# format(fin_total, '.2f'),
)
)
# CMS Vehicle Price / 1.13 * 10 %
if
gzs_status
!=
consts
.
GZS_STATUS
[
1
]:
gzs_value
=
float
(
amount
)
*
0.1
/
1.13
gzs_list
.
append
(
gzs_value
)
gzs_list
.
append
(
float
(
gzs_price
))
# 保单 -----------------------------------------------------------------------------------------------------------
# is_insurance = 0
fp_campaign
=
cms_info
.
get
(
'fpCampaign'
,
''
)
# insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '')
# if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str):
# is_insurance = 1
# elif insurance_type == 'Comprehensive Insurance':
# is_insurance = 2
# if is_insurance != 0:
# if fp_campaign.find('OCU') == -1:
# ssx_amount = amount
# else:
# ssx_amount = format(float(amount) * 0.8, '.2f')
# if fp_campaign.find('Joy_Plus') == -1 or fp_campaign.find('JoyPlus') == -1:
# dszx_amount = '200000'
# else:
# dszx_amount = '500000'
# bd_field_input = [
# (consts.SE_BD_FIELD[0], hmh_name),
# (consts.SE_BD_FIELD[1], hmh_id),
# (consts.SE_BD_FIELD[2], vin_no),
# (consts.SE_BD_FIELD[3], ssx_amount),
# (consts.SE_BD_FIELD[4], dszx_amount),
# (consts.SE_BD_FIELD[5], consts.JDMPV_VALUE),
# (consts.SE_BD_FIELD[6], cms_info.get('insuranceDetails', {}).get('startDate', '')),
# (consts.SE_BD_FIELD[7], cms_info.get('insuranceDetails', {}).get('endDate', '')),
# (consts.SE_BD_FIELD[8], consts.SE_STAMP_VALUE),
# (consts.SE_BD_FIELD[9], consts.SE_STAMP_VALUE),
# ]
# if is_insurance == 1:
# bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price))
# other_info[consts.BD_EN] = bd_field_input
if
len
(
other_info
)
>
0
:
compare_info
[
'other'
]
=
other_info
schedule_list
=
[]
total_amount
=
0
for
schedule_dict
in
cms_info
.
get
(
'paymentSchedule'
,
[]):
tmp_str
=
"{1}{0}{2}"
.
format
(
consts
.
SPLIT_STR
,
str
(
schedule_dict
.
get
(
'no'
,
''
)),
str
(
schedule_dict
.
get
(
'grossRentalAmount'
,
''
)))
schedule_list
.
append
(
tmp_str
)
total_amount
+=
float
(
schedule_dict
.
get
(
'grossRentalAmount'
,
'0.0'
))
schedule_list_str
=
consts
.
SCHEDULE_SPLIT_STR
.
join
(
schedule_list
)
online_sign
=
cms_info
.
get
(
'contractSource'
,
'Online Sign'
)
==
'Online Sign'
contract_info
=
{}
if
application_entity
in
consts
.
HIL_SET
:
# HIL合同 售后回租合同 --------------------------------------------------------------------------------------
hil_contract_1_input
=
[
(
consts
.
SE_HIL_CON_1_FIELD
[
0
],
[
full_no
]
if
online_sign
else
full_no
),
(
consts
.
SE_HIL_CON_1_FIELD
[
1
],
full_no
),
(
consts
.
SE_HIL_CON_1_FIELD
[
2
],
vin_no
),
(
consts
.
SE_HIL_CON_1_FIELD
[
3
],
cms_info
.
get
(
'dealerName'
,
''
)),
(
consts
.
SE_HIL_CON_1_FIELD
[
4
],
amount
),
(
consts
.
SE_HIL_CON_1_FIELD
[
5
],
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'originationPrincipal'
,
'0.0'
))),
(
consts
.
SE_HIL_CON_1_FIELD
[
6
],
str
(
cms_info
.
get
(
'terms'
,
'0'
))),
(
consts
.
SE_HIL_CON_1_FIELD
[
7
],
schedule_list_str
),
(
consts
.
SE_HIL_CON_1_FIELD
[
11
],
account_no
),
(
consts
.
SE_HIL_CON_1_FIELD
[
12
],
cms_info
.
get
(
'bankAccountDetails'
,
{})
.
get
(
'accountHolderName'
,
''
)),
(
consts
.
SE_HIL_CON_1_FIELD
[
13
],
bank_name
),
]
if
is_asp
:
hil_contract_1_input
.
append
((
consts
.
SE_HIL_CON_1_FIELD
[
8
],
asp_list
))
hil_contract_1_input
.
append
((
consts
.
SE_HIL_CON_1_FIELD
[
9
],
gzs_list
))
if
isinstance
(
company_info
,
tuple
):
hil_contract_1_input
.
append
((
consts
.
SE_HIL_CON_1_FIELD
[
10
],
company_info
[
2
]))
for
key
,
app_type
,
id_idx
,
field_idx
,
is_force
,
e_write
in
consts
.
ROLE_LIST_1
:
if
not
e_write
and
not
online_sign
:
continue
is_find
=
False
if
app_type
in
main_role_info
:
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
hil_contract_1_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
hil_contract_1_input
.
append
((
key
,
field_idx
))
if
not
is_find
and
is_force
:
hil_contract_1_input
.
append
((
key
,
empty_str
))
contract_info
[
consts
.
HIL_CONTRACT_1_EN
]
=
hil_contract_1_input
# HIL合同 车辆处置协议 --------------------------------------------------------------------------------------
if
fp_campaign
.
find
(
'Joy_Select'
)
!=
-
1
or
fp_campaign
.
find
(
'JoySelect'
)
!=
-
1
:
hil_contract_3_input
=
[
(
consts
.
SE_HIL_CON_3_FIELD
[
0
],
[
full_no
]
if
online_sign
else
full_no
),
(
consts
.
SE_HIL_CON_3_FIELD
[
1
],
hmh_name
),
(
consts
.
SE_HIL_CON_3_FIELD
[
2
],
hmh_id
),
(
consts
.
SE_HIL_CON_3_FIELD
[
3
],
cms_info
.
get
(
'dealerName'
,
''
)),
(
consts
.
SE_HIL_CON_3_FIELD
[
4
],
full_no
),
(
consts
.
SE_HIL_CON_3_FIELD
[
5
],
hmh_name
),
(
consts
.
SE_HIL_CON_3_FIELD
[
6
],
hmh_id
),
]
if
online_sign
:
hil_contract_3_input
.
append
((
consts
.
SE_HIL_CON_3_FIELD
[
7
],
hmh_name
))
contract_info
[
consts
.
HIL_CONTRACT_3_EN
]
=
hil_contract_3_input
# HIL合同 车辆租赁抵押合同 --------------------------------------------------------------------------------------
hil_contract_2_input
=
[
(
consts
.
SE_HIL_CON_2_FIELD
[
0
],
full_no
),
(
consts
.
SE_HIL_CON_2_FIELD
[
1
],
full_no
),
(
consts
.
SE_HIL_CON_2_FIELD
[
2
],
vin_no
),
(
consts
.
SE_HIL_CON_2_FIELD
[
3
],
format
(
total_amount
,
'.2f'
)),
(
consts
.
SE_HIL_CON_2_FIELD
[
4
],
str
(
cms_info
.
get
(
'terms'
,
'0'
))),
]
for
key
,
app_type
,
id_idx
,
field_idx
,
is_force
,
e_write
in
consts
.
ROLE_LIST_2
:
if
not
e_write
and
not
online_sign
:
continue
is_find
=
False
if
app_type
in
main_role_info
:
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
hil_contract_2_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
hil_contract_2_input
.
append
((
key
,
field_idx
))
if
not
is_find
and
is_force
:
hil_contract_2_input
.
append
((
key
,
empty_str
))
contract_info
[
consts
.
HIL_CONTRACT_2_EN
]
=
hil_contract_2_input
compare_info
[
'contract'
]
=
contract_info
return
compare_info
,
cms_info
.
get
(
'autoApprovedDetails'
,
{})
.
get
(
'aaType'
,
''
),
is_gsyh
else
:
# AFC合同-----------------------------------------------------------------------------------------------------------
vehicle_principal_str
=
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'vehiclePrincipal'
,
'0.0'
))
afc_contract_input
=
[
(
consts
.
SE_AFC_CON_FIELD
[
0
],
full_no
),
(
consts
.
SE_AFC_CON_FIELD
[
1
],
amount
),
(
consts
.
SE_AFC_CON_FIELD
[
2
],
vin_no
),
(
consts
.
SE_AFC_CON_FIELD
[
3
],
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'originationPrincipal'
,
'0.0'
))),
(
consts
.
SE_AFC_CON_FIELD
[
4
],
str
(
cms_info
.
get
(
'terms'
,
'0'
))),
(
consts
.
SE_AFC_CON_FIELD
[
5
],
vehicle_principal_str
),
(
consts
.
SE_AFC_CON_FIELD
[
6
],
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'associatedServicePrincipal'
,
'0.0'
))),
(
consts
.
SE_AFC_CON_FIELD
[
7
],
amount
),
(
consts
.
SE_AFC_CON_FIELD
[
8
],
vin_no
),
(
consts
.
SE_AFC_CON_FIELD
[
9
],
cms_info
.
get
(
'dealerName'
,
''
)),
(
consts
.
SE_AFC_CON_FIELD
[
10
],
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'originationPrincipal'
,
'0.0'
))),
(
consts
.
SE_AFC_CON_FIELD
[
11
],
vehicle_principal_str
),
(
consts
.
SE_AFC_CON_FIELD
[
12
],
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'associatedServicePrincipal'
,
'0.0'
))),
(
consts
.
SE_AFC_CON_FIELD
[
13
],
str
(
cms_info
.
get
(
'terms'
,
'0'
))),
(
consts
.
SE_AFC_CON_FIELD
[
14
],
account_no
),
(
consts
.
SE_AFC_CON_FIELD
[
15
],
cms_info
.
get
(
'bankAccountDetails'
,
{})
.
get
(
'accountHolderName'
,
''
)),
(
consts
.
SE_AFC_CON_FIELD
[
16
],
bank_name
),
(
consts
.
SE_AFC_CON_FIELD
[
17
],
schedule_list_str
),
]
if
is_asp
:
afc_contract_input
.
append
((
consts
.
SE_AFC_CON_FIELD
[
20
],
asp_list
))
afc_contract_input
.
append
((
consts
.
SE_AFC_CON_FIELD
[
22
],
asp_list
))
afc_contract_input
.
append
((
consts
.
SE_AFC_CON_FIELD
[
21
],
gzs_list
))
else
:
afc_contract_input
.
pop
(
5
)
afc_contract_input
.
pop
(
5
)
afc_contract_input
.
pop
(
9
)
afc_contract_input
.
pop
(
9
)
# '借款人签字及时间', 'Borrower', 0, 0, True
for
key
,
app_type
,
id_idx
,
field_idx
,
is_force
,
e_write
in
consts
.
ROLE_LIST
:
if
not
e_write
and
not
online_sign
:
continue
is_find
=
False
if
app_type
in
main_role_info
:
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
afc_contract_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
afc_contract_input
.
append
((
key
,
field_idx
))
if
not
is_find
and
is_force
:
afc_contract_input
.
append
((
key
,
empty_str
))
if
online_sign
:
afc_contract_input
.
append
((
consts
.
SE_AFC_CON_FIELD
[
18
],
consts
.
SE_STAMP_VALUE
))
afc_contract_input
.
append
((
consts
.
SE_AFC_CON_FIELD
[
19
],
empty_str
))
contract_info
[
consts
.
AFC_CONTRACT_EN
]
=
afc_contract_input
compare_info
[
'contract'
]
=
contract_info
return
compare_info
,
cms_info
.
get
(
'autoApprovedDetails'
,
{})
.
get
(
'aaType'
,
''
),
is_gsyh
def
get_se_cms_compare_info
(
last_obj
,
application_entity
,
detect_list
):
cms_info
=
json
.
loads
(
last_obj
.
content
)
...
...
@@ -1173,7 +1650,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
ssx_amount
=
amount
else
:
ssx_amount
=
format
(
float
(
amount
)
*
0.8
,
'.2f'
)
if
fp_campaign
.
find
(
'Joy_Plus'
)
==
-
1
:
if
fp_campaign
.
find
(
'Joy_Plus'
)
==
-
1
or
fp_campaign
.
find
(
'JoyPlus'
)
==
-
1
:
dszx_amount
=
'200000'
else
:
dszx_amount
=
'500000'
...
...
@@ -1219,6 +1696,9 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
(
consts
.
SE_HIL_CON_1_FIELD
[
5
],
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'originationPrincipal'
,
'0.0'
))),
(
consts
.
SE_HIL_CON_1_FIELD
[
6
],
str
(
cms_info
.
get
(
'terms'
,
'0'
))),
(
consts
.
SE_HIL_CON_1_FIELD
[
7
],
schedule_list_str
),
(
consts
.
SE_HIL_CON_1_FIELD
[
11
],
account_no
),
(
consts
.
SE_HIL_CON_1_FIELD
[
12
],
cms_info
.
get
(
'bankAccountDetails'
,
{})
.
get
(
'accountHolderName'
,
''
)),
(
consts
.
SE_HIL_CON_1_FIELD
[
13
],
bank_name
),
]
if
is_asp
:
...
...
@@ -1244,7 +1724,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
contract_info
[
consts
.
HIL_CONTRACT_1_EN
]
=
hil_contract_1_input
# HIL合同 车辆处置协议 --------------------------------------------------------------------------------------
if
fp_campaign
.
find
(
'Joy_Select'
)
!=
-
1
:
if
fp_campaign
.
find
(
'Joy_Select'
)
!=
-
1
or
fp_campaign
.
find
(
'JoySelect'
)
!=
-
1
:
hil_contract_3_input
=
[
(
consts
.
SE_HIL_CON_3_FIELD
[
0
],
[
full_no
]
if
online_sign
else
full_no
),
(
consts
.
SE_HIL_CON_3_FIELD
[
1
],
hmh_name
),
...
...
@@ -1917,12 +2397,12 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh):
else
:
ocr_str_or_list
=
ocr_res
.
get
(
compare_logic
[
name
][
0
])
if
ocr_str_or_list
is
None
and
license_en
==
consts
.
AFC_CONTRACT_EN
\
and
is_gsyh
is
True
and
name
in
consts
.
AFC_
CON_BANK_FIELD
:
and
is_gsyh
is
True
and
name
in
consts
.
CON_BANK_FIELD
:
result
=
consts
.
RESULT_Y
ocr_str
=
empty_str
reason
=
compare_logic
[
name
][
3
]
elif
isinstance
(
ocr_str_or_list
,
str
)
or
isinstance
(
ocr_str_or_list
,
list
):
if
license_en
==
consts
.
AFC_CONTRACT_EN
and
is_gsyh
is
True
and
name
in
consts
.
AFC_
CON_BANK_FIELD
:
if
is_gsyh
is
True
and
name
in
consts
.
CON_BANK_FIELD
:
update_args
=
{
'is_gsyh'
:
is_gsyh
}
for
k
,
v
in
compare_logic
[
name
][
2
]
.
items
():
update_args
[
k
]
=
v
...
...
@@ -2223,6 +2703,35 @@ def se_result_detect(ocr_res_dict):
return
detect_list
def
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
):
try
:
# 比对逻辑
# detect_list = se_result_detect(ocr_res_dict)
compare_info
,
aa_type
,
is_gsyh
=
get_se_cms_compare_info_auto
(
last_obj
,
application_entity
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
cn_failure_reason_str
,
bs_failure_reason_str
=
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
)
compare_log
.
info
(
'{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
compare_result
))
except
Exception
as
e
:
compare_log
.
error
(
'{0} [Auto SE] [compare error] [entity={1}] [id={2}] [ocr_res_id={3}] '
'[error={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
traceback
.
format_exc
()))
else
:
# 将比对结果写入数据库 auto settlement
try
:
auto_obj
.
aa_type
=
aa_type
auto_obj
.
ocr_auto_result_pass
=
successful_at_this_level
auto_obj
.
ocr_auto_result
=
json
.
dumps
(
compare_result
)
auto_obj
.
ocr_latest_comparison_time
=
datetime
.
now
()
auto_obj
.
save
()
compare_log
.
info
(
'{0} [Auto SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
))
except
Exception
as
e
:
compare_log
.
error
(
'{0} [Auto SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] '
'[error={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
traceback
.
format_exc
()))
def
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
):
try
:
# 比对逻辑
...
...
@@ -2317,6 +2826,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
compare_log
.
info
(
'{0} [SE] [cms success] [entity={1}] [id={2}] [ocr_res_id={3}] [response={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
response
))
@app.task
def
compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
# POS: application_id, application_entity, uniq_seq, None
...
...
@@ -2348,12 +2858,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
else
:
result_class
=
HILSEOCRResult
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCSEOCRResult
ca_result_class
=
HILOCRResult
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCOCRResult
if
ocr_res_id
is
None
:
#
if ocr_res_id is None:
ca_ocr_res_dict
=
ca_result_class
.
objects
.
filter
(
application_id
=
application_id
)
.
values
(
*
consts
.
CA_ADD_COMPARE_FIELDS
)
.
first
()
else
:
ca_ocr_res_dict
=
ca_result_class
.
objects
.
filter
(
id
=
ocr_res_id
)
.
values
(
*
consts
.
CA_ADD_COMPARE_FIELDS
)
.
first
()
#
else:
#
ca_ocr_res_dict = ca_result_class.objects.filter(id=ocr_res_id).values(
#
*consts.CA_ADD_COMPARE_FIELDS).first()
if
ocr_res_id
is
None
:
ocr_res_dict
=
result_class
.
objects
.
filter
(
application_id
=
application_id
)
.
values
(
*
consts
.
COMPARE_FIELDS
)
.
first
()
else
:
...
...
@@ -2374,4 +2884,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
tmp_se_result
=
json
.
loads
(
ocr_res_dict
.
get
(
field_name
))
tmp_ca_result
.
extend
(
tmp_se_result
)
ocr_res_dict
[
field_name
]
=
json
.
dumps
(
tmp_ca_result
)
# auto settlement
auto_class
=
HILAutoSettlement
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCAutoSettlement
auto_obj
=
auto_class
.
objects
.
filter
(
application_id
=
application_id
,
on_off
=
True
)
.
first
()
if
auto_obj
is
not
None
:
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
)
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
)
...
...
src/common/tools/mssql_script13.py
0 → 100644
View file @
2a43019
import
pyodbc
hil_sql
=
"""
create table hil_auto_settlement
(
id bigint identity primary key,
application_id nvarchar(64) not null,
aa_type nvarchar(64),
rpa_result smallint,
rpa_1st_eye_tat decimal(18,0),
rpa_2nd_eye_tat decimal(18,0),
rpa_3rd_eye_tat decimal(18,0),
rpa_total_tat decimal(18,0),
rpa_activated_time datetime,
rpa_get_case_from_ocr_time datetime,
rpa_get_case_from_oc_time datetime,
rpa_payment_authorize_time datetime,
rpa_second_eye_time datetime,
on_off bit default 1 not null,
ocr_auto_result_pass bit default 0 not null,
ocr_auto_result nvarchar(max),
ocr_latest_comparison_time datetime,
update_time datetime not null,
create_time datetime not null
);
create index hil_auto_settlement_application_id_index
on hil_auto_settlement (application_id);
"""
afc_sql
=
"""
create table afc_auto_settlement
(
id bigint identity primary key,
application_id nvarchar(64) not null,
aa_type nvarchar(64),
rpa_result smallint,
rpa_1st_eye_tat decimal(18,0),
rpa_2nd_eye_tat decimal(18,0),
rpa_3rd_eye_tat decimal(18,0),
rpa_total_tat decimal(18,0),
rpa_activated_time datetime,
rpa_get_case_from_ocr_time datetime,
rpa_get_case_from_oc_time datetime,
rpa_payment_authorize_time datetime,
rpa_second_eye_time datetime,
on_off bit default 1 not null,
ocr_auto_result_pass bit default 0 not null,
ocr_auto_result nvarchar(max),
ocr_latest_comparison_time datetime,
update_time datetime not null,
create_time datetime not null
);
create index afc_auto_settlement_application_id_index
on afc_auto_settlement (application_id);
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
hil_cursor
=
hil_cnxn
.
cursor
()
hil_cursor
.
execute
(
hil_sql
)
hil_cursor
.
close
()
hil_cnxn
.
close
()
afc_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
afc_cursor
=
afc_cnxn
.
cursor
()
afc_cursor
.
execute
(
afc_sql
)
afc_cursor
.
close
()
afc_cnxn
.
close
()
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment