feecd311 by 王聪

pos 3045 update

1 parent 3690e26d
...@@ -18,16 +18,16 @@ idna==2.9 ...@@ -18,16 +18,16 @@ idna==2.9
18 idna-ssl==1.1.0 18 idna-ssl==1.1.0
19 isodate==0.6.0 19 isodate==0.6.0
20 jdcal==1.4.1 20 jdcal==1.4.1
21 lxml==4.5.1 21 lxml==4.9.1
22 marshmallow==3.6.1 22 marshmallow==3.6.1
23 multidict==4.7.6 23 multidict==4.7.6
24 oauthlib==3.1.0 24 oauthlib==3.1.0
25 openpyxl==3.0.4 25 openpyxl==3.0.4
26 pdfminer3k==1.3.4 26 pdfminer3k==1.3.4
27 Pillow==7.1.2 27 Pillow==9.2.0
28 ply==3.11 28 ply==3.11
29 PyJWT==1.7.1 29 PyJWT==1.7.1
30 PyMuPDF==1.17.0 30 PyMuPDF==1.20.2
31 PyMySQL==0.9.3 31 PyMySQL==0.9.3
32 pytz==2020.1 32 pytz==2020.1
33 redis==3.4.1 33 redis==3.4.1
......
1 from django.urls import path
2 from pos import views
3
4 urlpatterns = [
5 path(r'nsc/invoice', views.NSCInvoiceView.as_view()),
6 path(r'de-mortgage', views.DeMortgageView.as_view()),
7 ]
...@@ -26,6 +26,7 @@ urlpatterns = [ ...@@ -26,6 +26,7 @@ urlpatterns = [
26 path(r'api/compare/', include('apps.doc.compare_urls')), 26 path(r'api/compare/', include('apps.doc.compare_urls')),
27 path(r'api/doc/', include('apps.doc.internal_urls')), 27 path(r'api/doc/', include('apps.doc.internal_urls')),
28 path(r'api/mpos/', include('apps.doc.mpos_urls')), 28 path(r'api/mpos/', include('apps.doc.mpos_urls')),
29 path(r'api/pos/', include('apps.doc.pos_urls')),
29 path(r'api/go/', include('apps.doc.go_urls')), 30 path(r'api/go/', include('apps.doc.go_urls')),
30 path('api/oauth/', include('oauth2_provider.urls', namespace='oauth2_provider')), 31 path('api/oauth/', include('oauth2_provider.urls', namespace='oauth2_provider')),
31 ] 32 ]
......
1 from common.mixins import GenericView
2 from webargs.djangoparser import use_args, parser
3 from webargs import fields, validate
4 from apps.doc.views import CustomDecimal, CustomDate
5 from common import response
6 from apps.doc.models import HILSEOCRResult, HILOCRResult, AFCSEOCRResult, AFCOCRResult
7 from apps.doc import consts
8
9 params = {
10 'invoiceCode': fields.Str(required=True, validate=validate.Length(max=128)),
11 'invoiceNumber': fields.Str(required=True, validate=validate.Length(max=64)),
12 'issueDate': CustomDate(required=True),
13 'buyerName': fields.Str(required=True, validate=validate.Length(max=64)),
14 "buyerId": fields.Int(required=True),
15 'vin': fields.Str(required=True, validate=validate.Length(max=128)),
16 'dealer': fields.Str(required=False, validate=validate.Length(max=64)),
17 'priceWithVat': CustomDecimal(required=False),
18 'priceNoVat': CustomDecimal(required=True),
19 'priceInCapitals': fields.Str(required=False),
20 'vat': CustomDecimal(required=True),
21 'vatRate': CustomDecimal(required=True),
22 }
23
24 input_args = {
25 'content': fields.Nested(params, required=True)
26 }
27
28
29 # pos 接口接收NSC 发票信息
30 class NSCInvoiceView(GenericView):
31 @use_args(input_args, location='data')
32 def post(self, request, args): # interface_report mpos to ocr
33 content = args.get('content', {})
34 invoice_code = content['invoiceCode']
35 invoice_number = content['invoiceNumber']
36 issue_date = content['issueDate']
37 buyer_name = content['buyerName']
38 buyer_id = content['buyerId']
39 vin = content['vin']
40 dealer = content['dealer']
41 price_with_vat = content['priceWithVat']
42 price_no_vat = content['priceNoVat']
43 price_in_capitals = content['priceInCapitals']
44 vat = content['vat']
45 vat_rate = content['vatRate']
46
47 return response.ok(data=content)
48
49
50 de_mortgage_params = {
51
52 }
53
54 de_mortgage_args = {
55 'content': fields.Nested(de_mortgage_params, required=True)
56 }
57
58
59 # 解除抵押识别处理
60 class DeMortgageView(GenericView):
61 @use_args(de_mortgage_args, location='data')
62 def post(self, request, args): # interface_report mpos to ocr
63 content = args.get('content', {})
64 application_id = content['applicationId']
65 customer_name = content['customerName']
66 application_entity = content['applicationEntity']
67 de_mortgage_date = content['deMortgageDate']
68
69 # ocr 检测
70 # 根据application_id查找OCR累计结果指定license字段,如果没有,结束
71 result_class = HILSEOCRResult if application_entity in consts.HIL_SET else AFCSEOCRResult
72 ca_result_class = HILOCRResult if application_entity in consts.HIL_SET else AFCOCRResult
73
74 ca_ocr_res_dict = ca_result_class.objects.filter(application_id=application_id).values(
75 *consts.CA_ADD_COMPARE_FIELDS_PRE).first()
76 ocr_res_dict = result_class.objects.filter(application_id=application_id).values(
77 *consts.PRE_COMPARE_FIELDS).first()
78 if ocr_res_dict is None:
79 return get_empty_result()
80
81 id_res_list = []
82 for field_name in consts.CA_ADD_COMPARE_FIELDS_PRE:
83 if field_name == consts.IC_OCR_FIELD:
84 id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None)
85 id_res_list.append(ocr_res_dict.get(field_name))
86
87 result = {
88 "is_pass": True,
89 "customer_name": True,
90 "application_entity": True,
91 "de_mortgage_date": True
92 }
93 return response.ok(data=result)
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!