f80b8302 by 周伟奇

Merge branch 'feature/SE3'

2 parents 6dce1268 94c1a856
......@@ -1031,9 +1031,9 @@ JYPZ_FIELD_ORDER = (("type", "标题"),
("buyer_id", "购买方身份证号码/营业执照号码"),
("vin", "车辆识别代号/车架号码"),
("price", "车辆价格"),
("date", "购买方交易日期"),
("date", "出卖方交易日期"),
("date", "经销商交易日期"),
("buyer_date", "购买方交易日期"),
("seller_date", "出卖方交易日期"),
("agent_date", "经销商交易日期"),
("stamp_signature_buyer", "购买方签字/盖章"),
("stamp_signature_seller", "出卖方签字/盖章"),
("stamp_signature_agent", "经销商签字/盖章"),)
......@@ -1439,6 +1439,8 @@ SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', '
SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字']
SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计']
JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', '']
JYPZ_TYPE_1 = ['二手车交易凭证']
JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证']
SE_BANK_FIELD = ['accountNo', 'bankName']
SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo']
......@@ -1582,19 +1584,21 @@ SE_HIL_CON_MAP = {
SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款',
'车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商',
'贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行',
'还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情']
'还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情',
'合同编号-每页(no-asp)', '无ASP产品']
CON_BANK_FIELD = ['还款账号', '户名', '开户行']
# '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表'
SE_HIL_CON_1_FIELD = ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期',
'还款计划表', 'ASP项目详情', '购置税校验', '承租人法定代表人或授权代表', '还款账号', '户名', '开户行',
'共同承租人法定代表人或授权代表']
'共同承租人法定代表人或授权代表', '无ASP产品']
SE_HIL_CON_2_FIELD = ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限']
SE_HIL_CON_3_FIELD = ['合同编号-每页', '承租人姓名', '承租人证件号码', '销售经销商', '合同编号-正文', '姓名/名称',
'自然人身份证件号码/法人执照号码', '承租人签字']
ROLE_LIST = [
# key_afc1, cdfl_key, app_type, id_idx, field_idx, is_force, e_write
('借款人签字及时间', '借款人签字及时间', 'Borrower', 0, 0, True, False),
('借款人姓名', '借款人姓名', 'Borrower', 0, 0, True, True),
('借款人证件号', '借款人证件号', 'Borrower', 0, 2, True, True),
......@@ -1810,14 +1814,21 @@ DDA_COMPARE_LOGIC = {
}
JYPZ_COMPARE_LOGIC = {
'type': ('type', 'super_list_compare', {}, '二手车凭证类型与产品不符'),
'vinNo': ('vin', 'se_common_compare', {}, '二手车凭证车辆识别代号与系统车架号不一致'),
'dealerName': ('authorized_dealer', 'se_common_compare', {}, '二手车凭证经销商与系统经销商不一致'),
'vehicleTransactionAmount': ('price', 'se_amount_compare', {}, '二手车凭证购买方交易价格与系统车辆价格不一致'),
'customerName': ('buyer_name', 'se_name_compare', {'is_passport': True}, '二手车凭证购买方姓名与系统主借人姓名不一致'),
'idNum': ('buyer_id', 'se_contain_compare_2', {}, '二手车凭证购买方证件号与系统主借人证件号不一致'),
'date': ('date', 'se_date_compare_2', {'three_month': True}, '二手车凭证交易日期早于submissionDate'),
# 'date': ('date', 'se_date_compare_2', {'three_month': True}, '二手车凭证交易日期早于submissionDate'),
'date': ('buyer_date', 'se_jypz_date_compare', {}, '二手车交易凭证交易日期不一致或二手车凭证交易日期早于submissionDate'),
}
JYPZ_DATE_FIELD_1 = 'date'
JYPZ_DATE_FIELD_2 = 'buyer_date'
JYPZ_DATE_FIELD_3 = 'seller_date'
JYPZ_DATE_FIELD_4 = 'agent_date'
HMH_COMPARE_LOGIC = {
'借款人/承租人姓名': ('借款/承租人姓名', 'se_name_compare', {}, '抵押登记豁免函借款人/承租人姓名与系统不符'),
'借款人/承租人证件号': ('证件号码', 'se_common_compare', {}, '抵押登记豁免函借款人/承租人证件号码与系统不符'),
......@@ -1911,6 +1922,9 @@ HIL_CONTRACT_1_COMPARE_LOGIC = {
'保证人姓名2': ('保证人姓名2', 'se_name_compare', {}, '售后回租合同保证人姓名2与系统不一致'),
'保证人证件号2': ('保证人证件号2', 'se_common_compare', {}, '售后回租合同保证人证件号2与系统不一致'),
'保证人签字2': ('保证人签字2', 'se_contain_compare', {}, '售后回租合同保证人签字2与系统不一致'),
'购置税校验': ('购置税校验', 'se_self_compare_gzs', {}, GZS_REASON_2),
'无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1),
}
# ['合同编号', '合同编号-正文', '车辆识别代码', '租金总额', '融资租赁期限']
......@@ -1943,6 +1957,8 @@ HIL_CONTRACT_3_COMPARE_LOGIC = {
HT_COMPARE_LOGIC = {
'合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'),
# '合同编号-每页(no-asp)': ('合同编号-每页', 'se_list_compare', {'pop_last': True}, '合同编号与系统不一致'),
'合同编号-每页(no-asp)': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'),
'所购车辆价格-小写-重要条款': ('所购车辆价格-小写-重要条款', 'se_amount_str_compare', {}, '合同首页中车辆价格与系统不一致'),
'车架号-重要条款': ('车架号-重要条款', 'se_common_compare', {}, '合同首页中车架号与系统不一致'),
'贷款本金金额-重要条款': ('贷款本金金额-重要条款', 'se_amount_str_compare', {}, '合同首页中贷款本金与系统不一致'),
......@@ -1988,8 +2004,12 @@ HT_COMPARE_LOGIC = {
'ASP项目详情-重要条款': ('ASP项目详情-重要条款', 'se_asp_compare', {}, '合同(重要条款)ASP名称或者金额与系统不一致'),
'ASP项目详情': ('ASP项目详情', 'se_asp_compare', {}, '合同ASP名称或者金额与系统不一致'),
'购置税校验': ('购置税校验', 'se_self_compare_gzs', {}, GZS_REASON_2),
'无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1),
}
AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2']
# MVC_OCR_FIELD = 'mvc_ocr'
......
......@@ -919,6 +919,7 @@ class Command(BaseCommand, LoggerMixin):
'role': bs_info.get('role', ''),
'print_time': print_date,
'timedelta': bs_info.get('timedelta', ''),
'verify': bs_info.get('verify', True)
}
)
return res
......@@ -928,12 +929,14 @@ class Command(BaseCommand, LoggerMixin):
if classify == consts.CONTRACT_CLASSIFY:
res = {}
is_asp = page_info_dict.get(consts.ASP_KEY, False)
# is_asp = True
for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items():
pno = pno_asp if is_asp else pno_not_asp
if pno is None:
if isinstance(pno_asp, int):
continue
end_idx = 9 if is_asp else 8
end_idx = 9
# end_idx = 9 if is_asp else 8
for i in range(1, end_idx):
res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, ''))
elif key2 is None:
......
......@@ -882,3 +882,26 @@ class AFCAutoSettlement(models.Model):
situ_db_label = 'afc'
class HILbankVerification(models.Model):
id = models.AutoField(primary_key=True, verbose_name="id") # 主键
application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
on_off = models.BooleanField(default=True, verbose_name="是否有效")
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 = 'hil_bank_verification'
class AFCbankVerification(models.Model):
id = models.AutoField(primary_key=True, verbose_name="id") # 主键
application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
on_off = models.BooleanField(default=True, verbose_name="是否有效")
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_bank_verification'
situ_db_label = 'afc'
......
......@@ -392,7 +392,9 @@ class BSWorkbook(Workbook):
cell.fill = self.amount_fill
for cell in ms[4]:
cell.fill = self.amount_fill
return ms, timedelta
verify_res = False if len(metadata_highlight_row) > 0 or len(verify_highlight_row) > 0 else True
return ms, timedelta, verify_res
@staticmethod
def amount_format(amount_str):
......@@ -723,20 +725,21 @@ class BSWorkbook(Workbook):
# 2.元信息提取表
confidence = self.get_confidence(max_find_count, classify)
is_verify_classify = classify in consts.BS_VERIFY_CLASSIFY
ms, timedelta = self.build_meta_sheet(role_name,
new_card,
confidence,
summary.get('code'),
summary.get('verify'),
summary.get('print_time'),
start_date,
end_date,
res_count_tuple,
is_verify_classify,
metadata)
ms, timedelta, verify_res = self.build_meta_sheet(role_name,
new_card,
confidence,
summary.get('code'),
summary.get('verify'),
summary.get('print_time'),
start_date,
end_date,
res_count_tuple,
is_verify_classify,
metadata)
summary['timedelta'] = timedelta
summary['end_date'] = end_date
summary['verify'] = verify_res
# 3.创建月份表、提取/高亮关键行
# 倒序处理
......
......@@ -42,6 +42,8 @@ from .models import (
HILSECompareResultRecord,
HILAutoSettlement,
AFCAutoSettlement,
HILbankVerification,
AFCbankVerification,
)
from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult
from .mixins import DocHandler, MPOSHandler
......@@ -112,7 +114,7 @@ se_bank_args = {
'applicantType': fields.Str(required=True, validate=validate.Length(max=16)),
'accountHolderName': fields.Str(required=True, validate=validate.Length(max=256)),
'accountNo': fields.Str(required=True, validate=validate.Length(max=256)),
'bankVerificationStatus': fields.Str(required=False, validate=validate.Length(max=16)),
'bankVerificationStatus': fields.Str(required=False, validate=validate.Length(max=128)),
'isAllDocUploaded': fields.Boolean(required=False)
}
......@@ -249,10 +251,10 @@ applicant_data_args = {
# 'coApplicantName': fields.Str(required=True, validate=validate.Length(max=16)),
# 'guarantor1Name': fields.Str(required=True, validate=validate.Length(max=16)),
# 'guarantor2Name': fields.Str(required=True, validate=validate.Length(max=16)),
'mainApplicantName': fields.Str(required=True),
'coApplicantName': fields.Str(required=True),
'guarantor1Name': fields.Str(required=True),
'guarantor2Name': fields.Str(required=True),
'mainApplicantName': fields.Str(required=False),
'coApplicantName': fields.Str(required=False),
'guarantor1Name': fields.Str(required=False),
'guarantor2Name': fields.Str(required=False),
}
document_args = {
......@@ -267,7 +269,7 @@ document_args = {
doc_upload_args = {
'applicationData': fields.Nested(application_data_args, required=True),
'applicantData': fields.Nested(applicant_data_args, required=True),
'applicantData': fields.Nested(applicant_data_args, required=False),
'document': fields.Nested(document_args, required=True),
}
......@@ -748,61 +750,26 @@ class SECompareView(GenericView):
@use_args(se_compare_args, location='data')
def post(self, request, args):
# 存库
# content = args.get('content', {})
# business_type = content.get('applicationEntity')
# application_id = content.get('applicationId')
# is_auto = content.get('isAutoSettlement', False)
#
# auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement
# auto_obj = auto_class.objects.filter(application_id=application_id).first()
# if is_auto:
# # 加入优先级队列
# PriorityApplication.objects.update_or_create(
# application_id=application_id, defaults={'on_off': True})
# # 加入auto表
# if auto_obj is None:
# auto_class.objects.create(
# application_id=application_id,
# )
# elif auto_obj.on_off is False:
# auto_obj.on_off = True
# auto_obj.save()
# else:
# if auto_obj is not None and auto_obj.on_off is True:
# auto_obj.on_off = False
# auto_obj.save()
return response.ok()
content = args.get('content', {})
business_type = content.get('applicationEntity')
application_id = content.get('applicationId')
bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '')
bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification
bank_obj = bank_class.objects.filter(application_id=application_id).first()
if bank_obj is None and bank_verify == 'PASS':
bank_class.objects.create(
application_id=application_id,
)
elif bank_obj is not None and bank_verify == 'PASS' and bank_obj.on_off is False:
bank_obj.on_off = True
bank_obj.save()
elif bank_obj is not None and bank_verify != 'PASS' and bank_obj.on_off is True:
bank_obj.on_off = False
bank_obj.save()
# 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]
......
......@@ -173,6 +173,11 @@ class Comparison:
return self.RESULT_Y
return self.RESULT_N
else:
# if kwargs.get('pop_last', False):
# for item in ocr_str_or_list[:-1]:
# if item != input_str_or_list:
# return self.RESULT_N
# else:
for item in ocr_str_or_list:
if item != input_str_or_list:
return self.RESULT_N
......@@ -582,6 +587,27 @@ class Comparison:
else:
return self.RESULT_N
def se_self_compare_gzs(self, input_list, ocr_str, **kwargs):
if isinstance(input_list, list) and len(input_list) == 2:
try:
if isinstance(input_list[0], float) and isinstance(input_list[1], float) \
and input_list[0] >= input_list[1]:
return self.RESULT_Y
except Exception as e:
return self.RESULT_N
return self.RESULT_N
def se_self_compare_other_asp(self, input_str, ocr_str, **kwargs):
return self.RESULT_N
def se_jypz_date_compare(self, input_str, ocr_date_list, **kwargs):
ocr_date_set = set(ocr_date_list)
if len(ocr_date_set) > 1:
return self.RESULT_N
if not any(ocr_date_set):
return self.RESULT_N
return self.se_date_compare_2(input_str, ocr_date_set.pop(), three_month=True)
cp = Comparison()
......
import pyodbc
hil_sql = """
create table hil_bank_verification
(
id bigint identity primary key,
application_id nvarchar(64) not null,
on_off bit default 1 not null,
update_time datetime not null,
create_time datetime not null
);
create index hil_bank_verification_application_id_index
on hil_bank_verification (application_id);
"""
afc_sql = """
create table afc_bank_verification
(
id bigint identity primary key,
application_id nvarchar(64) not null,
on_off bit default 1 not null,
update_time datetime not null,
create_time datetime not null
);
create index afc_bank_verification_application_id_index
on afc_bank_verification (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()
import os
import re
import json
import cv2
import shutil
......@@ -48,8 +49,9 @@ class PDFBuild:
class PDFHandler:
def __init__(self, path, img_dir_path, document_name=None):
def __init__(self, path, img_dir_path, document_name=None, pwd_list=[]):
self.path = path
self.pwd_list = self.get_pwd_list(document_name, pwd_list)
self.img_dir_path = img_dir_path
self.img_path_list = []
self.img_count = 0
......@@ -75,6 +77,12 @@ class PDFHandler:
self.page_count = None
self.metadata = None
@staticmethod
def get_pwd_list(doc_name, pwd_list):
pwd_list_from_doc_name = re.findall(r'\d{6}', doc_name)
pwd_list_from_doc_name.extend(pwd_list)
return pwd_list_from_doc_name
def get_suffix(self, file_name):
if file_name is None:
return None
......@@ -370,6 +378,12 @@ class PDFHandler:
self.img_path_list.append(img_save_path)
else:
with fitz.Document(self.path) as pdf:
# 解密
for pwd in self.pwd_list:
if not pdf.isEncrypted:
break
pdf.authenticate(pwd)
self.metadata = pdf.metadata
self.page_count = pdf.pageCount
if isinstance(max_img_count, int) and pdf.pageCount >= max_img_count:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!